[jboss-cvs] JBossAS SVN: r111105 - in projects/jboss-jca/trunk: adapters/src/main/java/org/jboss/jca/adapters/jdbc and 8 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Apr 5 10:47:25 EDT 2011
Author: jesper.pedersen
Date: 2011-04-05 10:47:24 -0400 (Tue, 05 Apr 2011)
New Revision: 111105
Added:
projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/statistics/
projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/statistics/JdbcStatisticsPlugin.java
projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/statistics/package.html
projects/jboss-jca/trunk/adapters/src/main/resources/jdbc/jar/jdbc.properties
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/statistics/
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/statistics/Statistics.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/statistics/StatisticsPlugin.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/statistics/package.html
Removed:
projects/jboss-jca/trunk/adapters/src/main/resources/jdbc/jar/META-INF/
Modified:
projects/jboss-jca/trunk/adapters/build.xml
projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/BaseWrapperManagedConnectionFactory.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/DataSource.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java
projects/jboss-jca/trunk/web/src/main/resources/console/displaymbeans.jsp
projects/jboss-jca/trunk/web/src/main/resources/console/displayopresult.jsp
projects/jboss-jca/trunk/web/src/main/resources/console/error.jsp
projects/jboss-jca/trunk/web/src/main/resources/console/inspectmbean.jsp
Log:
[JBJCA-542] Statistics support (Part 1)
Modified: projects/jboss-jca/trunk/adapters/build.xml
===================================================================
--- projects/jboss-jca/trunk/adapters/build.xml 2011-04-05 14:44:09 UTC (rev 111104)
+++ projects/jboss-jca/trunk/adapters/build.xml 2011-04-05 14:47:24 UTC (rev 111105)
@@ -77,13 +77,18 @@
Target: jars
================================= -->
<target name="jars" depends="compile">
+ <copy todir="${build.adapters.dir}/impl">
+ <fileset dir="src/main/resources/jdbc/jar"
+ includes="**/*.properties"/>
+ </copy>
+
<jar destfile="${target.dir}/${name}-jdbc.jar"
basedir="${build.adapters.dir}/impl"
index="true"
indexMetaInf="true"
update="true"
level="9"
- includes="**/jdbc/**">
+ includes="**/jdbc/**,**/*.properties">
<manifest>
<attribute name="Implementation-Title" value="IronJacamar JDBC Resource Adapter"/>
<attribute name="Implementation-Version" value="${major}.${minor}.${patch}.${type}"/>
Modified: projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/BaseWrapperManagedConnectionFactory.java
===================================================================
--- projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/BaseWrapperManagedConnectionFactory.java 2011-04-05 14:44:09 UTC (rev 111104)
+++ projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/BaseWrapperManagedConnectionFactory.java 2011-04-05 14:47:24 UTC (rev 111105)
@@ -32,7 +32,9 @@
import org.jboss.jca.adapters.jdbc.spi.URLSelectorStrategy;
import org.jboss.jca.adapters.jdbc.spi.ValidConnectionChecker;
import org.jboss.jca.adapters.jdbc.spi.reauth.ReauthPlugin;
+import org.jboss.jca.adapters.jdbc.statistics.JdbcStatisticsPlugin;
import org.jboss.jca.adapters.jdbc.util.Injection;
+import org.jboss.jca.core.spi.statistics.Statistics;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -74,7 +76,7 @@
*/
public abstract class BaseWrapperManagedConnectionFactory
- implements ManagedConnectionFactory, ValidatingManagedConnectionFactory, Serializable
+ implements ManagedConnectionFactory, ValidatingManagedConnectionFactory, Statistics, Serializable
{
/** @since 4.0.1 */
static final long serialVersionUID = -84923705377702088L;
@@ -230,6 +232,9 @@
/** The JNDI name for the user transaction */
private String userTransactionJndiName;
+ /** The statistics plugin */
+ private JdbcStatisticsPlugin statisticsPlugin = new JdbcStatisticsPlugin();
+
/**
* Constructor
*/
@@ -883,6 +888,15 @@
}
/**
+ * Get the statistics plugin
+ * @return The value
+ */
+ public JdbcStatisticsPlugin getStatistics()
+ {
+ return statisticsPlugin;
+ }
+
+ /**
* Get the invalid connections
* @param connectionSet The connection set
* @return The invalid connections
Added: projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/statistics/JdbcStatisticsPlugin.java
===================================================================
--- projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/statistics/JdbcStatisticsPlugin.java (rev 0)
+++ projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/statistics/JdbcStatisticsPlugin.java 2011-04-05 14:47:24 UTC (rev 111105)
@@ -0,0 +1,146 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.adapters.jdbc.statistics;
+
+import org.jboss.jca.core.spi.statistics.StatisticsPlugin;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * JDBC statistics.
+ *
+ * @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class JdbcStatisticsPlugin implements StatisticsPlugin
+{
+ private Set<String> names;
+ private Map<String, Class> types;
+ private AtomicBoolean enabled;
+ private Map<Locale, ResourceBundle> rbs;
+
+ /**
+ * Constructor
+ */
+ public JdbcStatisticsPlugin()
+ {
+ Set<String> n = new HashSet<String>();
+ Map<String, Class> t = new HashMap<String, Class>();
+
+ this.names = Collections.unmodifiableSet(n);
+ this.types = Collections.unmodifiableMap(t);
+ this.enabled = new AtomicBoolean(true);
+
+ ResourceBundle defaultResourceBundle =
+ ResourceBundle.getBundle("jdbc", Locale.US, JdbcStatisticsPlugin.class.getClassLoader());
+ this.rbs = new HashMap<Locale, ResourceBundle>(1);
+ this.rbs.put(Locale.US, defaultResourceBundle);
+
+ clear();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set<String> getNames()
+ {
+ return names;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Class getType(String name)
+ {
+ return types.get(name);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getDescription(String name)
+ {
+ return getDescription(name, Locale.US);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getDescription(String name, Locale locale)
+ {
+ ResourceBundle rb = rbs.get(locale);
+
+ if (rb == null)
+ {
+ ResourceBundle newResourceBundle =
+ ResourceBundle.getBundle("jdbc", locale, JdbcStatisticsPlugin.class.getClassLoader());
+
+ if (newResourceBundle != null)
+ rbs.put(locale, newResourceBundle);
+ }
+
+ if (rb == null)
+ rb = rbs.get(Locale.US);
+
+ if (rb != null)
+ return rb.getString(name);
+
+ return "";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getValue(String name)
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isEnabled()
+ {
+ return enabled.get();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setEnabled(boolean v)
+ {
+ enabled.set(v);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public synchronized void clear()
+ {
+ }
+}
Added: projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/statistics/package.html
===================================================================
--- projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/statistics/package.html (rev 0)
+++ projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/statistics/package.html 2011-04-05 14:47:24 UTC (rev 111105)
@@ -0,0 +1,3 @@
+<body>
+This package contains the statistics module for the JDBC adapter
+</body>
Added: projects/jboss-jca/trunk/adapters/src/main/resources/jdbc/jar/jdbc.properties
===================================================================
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/DataSource.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/DataSource.java 2011-04-05 14:44:09 UTC (rev 111104)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/DataSource.java 2011-04-05 14:47:24 UTC (rev 111105)
@@ -24,6 +24,7 @@
import org.jboss.jca.core.api.connectionmanager.pool.Pool;
import org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration;
+import org.jboss.jca.core.spi.statistics.StatisticsPlugin;
import java.lang.ref.WeakReference;
@@ -46,6 +47,9 @@
/** The pool configuration instance */
private WeakReference<PoolConfiguration> poolConfiguration;
+ /** The statistics */
+ private WeakReference<StatisticsPlugin> statistics;
+
/**
* Constructor
* @param xa datasource is xa or not
@@ -132,6 +136,30 @@
}
/**
+ * Get the statistics instance.
+ *
+ * Note, that the value may be <code>null</code> if the statistics module was
+ * undeployed and this object wasn't cleared up correctly.
+ * @return The instance
+ */
+ public StatisticsPlugin getStatistics()
+ {
+ if (statistics == null)
+ return null;
+
+ return statistics.get();
+ }
+
+ /**
+ * Set the statistics
+ * @param v The statistics module
+ */
+ public void setStatistics(StatisticsPlugin v)
+ {
+ this.statistics = new WeakReference<StatisticsPlugin>(v);
+ }
+
+ /**
* String representation
* @return The string
*/
@@ -144,6 +172,7 @@
sb.append(" jndiName=").append(getJndiName());
sb.append(" pool=").append(getPool());
sb.append(" poolconfiguration=").append(getPoolConfiguration());
+ sb.append(" statistics=").append(getStatistics());
sb.append("]");
return sb.toString();
Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/statistics/Statistics.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/statistics/Statistics.java (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/statistics/Statistics.java 2011-04-05 14:47:24 UTC (rev 111105)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.core.spi.statistics;
+
+/**
+ * Defines the contract for a statistics enabled resource adapter.
+ *
+ * This interface can be applied to ManagedConnectionFactory and ResourceAdapter
+ * instances.
+ *
+ * @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public interface Statistics
+{
+ /**
+ * Get the statistics plugin
+ * @return The value
+ */
+ public StatisticsPlugin getStatistics();
+}
Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/statistics/StatisticsPlugin.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/statistics/StatisticsPlugin.java (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/statistics/StatisticsPlugin.java 2011-04-05 14:47:24 UTC (rev 111105)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.core.spi.statistics;
+
+import java.util.Locale;
+import java.util.Set;
+
+/**
+ * Defines the contract for a statistics plugin.
+ *
+ * @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public interface StatisticsPlugin
+{
+ /**
+ * Get the statistics names
+ * @return The value
+ */
+ public Set<String> getNames();
+
+ /**
+ * Get the type
+ * @param name The name of the statistics
+ * @return The value
+ */
+ public Class getType(String name);
+
+ /**
+ * Get the description
+ * @param name The name of the statistics
+ * @return The value
+ */
+ public String getDescription(String name);
+
+ /**
+ * Get the description
+ * @param name The name of the statistics
+ * @param locale The locale
+ * @return The value
+ */
+ public String getDescription(String name, Locale locale);
+
+ /**
+ * Get the value of the statistics
+ * @param name The name of the statistics
+ * @return The value
+ */
+ public Object getValue(String name);
+
+ /**
+ * Is the statistics module enabled
+ * @return The value
+ */
+ public boolean isEnabled();
+
+ /**
+ * Set the statistics module enabled
+ * @param v The value
+ */
+ public void setEnabled(boolean v);
+
+ /**
+ * Clear all statistics
+ */
+ public void clear();
+}
Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/statistics/package.html
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/statistics/package.html (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/statistics/package.html 2011-04-05 14:47:24 UTC (rev 111105)
@@ -0,0 +1,3 @@
+<body>
+This package contains the SPI for exposing statistics information from the resource adapter.
+</body>
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java 2011-04-05 14:44:09 UTC (rev 111104)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java 2011-04-05 14:47:24 UTC (rev 111105)
@@ -47,6 +47,7 @@
import org.jboss.jca.core.recovery.DefaultRecoveryPlugin;
import org.jboss.jca.core.spi.mdr.MetadataRepository;
import org.jboss.jca.core.spi.recovery.RecoveryPlugin;
+import org.jboss.jca.core.spi.statistics.Statistics;
import org.jboss.jca.core.spi.transaction.TransactionIntegration;
import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecovery;
import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecoveryRegistry;
@@ -366,6 +367,9 @@
mgtDs.setPoolConfiguration(pc);
mgtDs.setPool(pool);
+ if (mcf instanceof Statistics)
+ mgtDs.setStatistics(((Statistics)mcf).getStatistics());
+
log.debugf("Adding management datasource: %s", mgtDs);
getManagementRepository().getDataSources().add(mgtDs);
@@ -520,6 +524,9 @@
mgtDs.setPoolConfiguration(pc);
mgtDs.setPool(pool);
+ if (mcf instanceof Statistics)
+ mgtDs.setStatistics(((Statistics)mcf).getStatistics());
+
log.debugf("Adding management datasource: %s", mgtDs);
getManagementRepository().getDataSources().add(mgtDs);
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java 2011-04-05 14:44:09 UTC (rev 111104)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java 2011-04-05 14:47:24 UTC (rev 111105)
@@ -384,6 +384,18 @@
ons.add(dsPON);
}
+
+ if (mgtDs.getStatistics() != null)
+ {
+ String dsSName = baseName + ",type=Statistics";
+
+ DynamicMBean dsSDMB = JMX.createMBean(mgtDs.getStatistics(), "Statistics");
+ ObjectName dsSON = new ObjectName(dsSName);
+
+ server.registerMBean(dsSDMB, dsSON);
+
+ ons.add(dsSON);
+ }
}
}
Modified: projects/jboss-jca/trunk/web/src/main/resources/console/displaymbeans.jsp
===================================================================
--- projects/jboss-jca/trunk/web/src/main/resources/console/displaymbeans.jsp 2011-04-05 14:44:09 UTC (rev 111104)
+++ projects/jboss-jca/trunk/web/src/main/resources/console/displaymbeans.jsp 2011-04-05 14:47:24 UTC (rev 111105)
@@ -70,7 +70,7 @@
<table width="100%" class="copyright">
<tr>
<td class="copyright">
- Copyright © 2010 <a href="http://www.jboss.org/ironjacamar" target="_blank">JBoss, by Red Hat</a>
+ Copyright © 2011 <a href="http://www.jboss.org/ironjacamar" target="_blank">JBoss, by Red Hat</a>
</td>
</tr>
</table>
Modified: projects/jboss-jca/trunk/web/src/main/resources/console/displayopresult.jsp
===================================================================
--- projects/jboss-jca/trunk/web/src/main/resources/console/displayopresult.jsp 2011-04-05 14:44:09 UTC (rev 111104)
+++ projects/jboss-jca/trunk/web/src/main/resources/console/displayopresult.jsp 2011-04-05 14:47:24 UTC (rev 111105)
@@ -94,7 +94,7 @@
<table width="100%" class="copyright">
<tr>
<td class="copyright">
- Copyright © 2010 <a href="http://www.jboss.org/ironjacamar" target="_blank">JBoss, by Red Hat</a>
+ Copyright © 2011 <a href="http://www.jboss.org/ironjacamar" target="_blank">JBoss, by Red Hat</a>
</td>
</tr>
</table>
Modified: projects/jboss-jca/trunk/web/src/main/resources/console/error.jsp
===================================================================
--- projects/jboss-jca/trunk/web/src/main/resources/console/error.jsp 2011-04-05 14:44:09 UTC (rev 111104)
+++ projects/jboss-jca/trunk/web/src/main/resources/console/error.jsp 2011-04-05 14:47:24 UTC (rev 111105)
@@ -21,7 +21,7 @@
<table width="100%" class="copyright">
<tr>
<td class="copyright">
- Copyright © 2010 <a href="http://www.jboss.org/ironjacamar" target="_blank">JBoss, by Red Hat</a>
+ Copyright © 2011 <a href="http://www.jboss.org/ironjacamar" target="_blank">JBoss, by Red Hat</a>
</td>
</tr>
</table>
Modified: projects/jboss-jca/trunk/web/src/main/resources/console/inspectmbean.jsp
===================================================================
--- projects/jboss-jca/trunk/web/src/main/resources/console/inspectmbean.jsp 2011-04-05 14:44:09 UTC (rev 111104)
+++ projects/jboss-jca/trunk/web/src/main/resources/console/inspectmbean.jsp 2011-04-05 14:47:24 UTC (rev 111105)
@@ -402,7 +402,7 @@
<table width="100%" class="copyright">
<tr>
<td class="copyright">
- Copyright © 2010 <a href="http://www.jboss.org/ironjacamar" target="_blank">JBoss, by Red Hat</a>
+ Copyright © 2011 <a href="http://www.jboss.org/ironjacamar" target="_blank">JBoss, by Red Hat</a>
</td>
</tr>
</table>
More information about the jboss-cvs-commits
mailing list