tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgallim...@apache.org
Subject [04/12] tomee git commit: Provide ConnectionFactory stats
Date Fri, 14 Sep 2018 15:22:34 GMT
Provide ConnectionFactory stats


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/65768eaf
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/65768eaf
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/65768eaf

Branch: refs/heads/master
Commit: 65768eaf3fea34b45472d1da6f5fea928e0a1361
Parents: 79ea0f8
Author: Jonathan Gallimore <jon@jrg.me.uk>
Authored: Mon Sep 3 13:38:13 2018 +0100
Committer: Jonathan Gallimore <jon@jrg.me.uk>
Committed: Mon Sep 3 13:38:13 2018 +0100

----------------------------------------------------------------------
 .../openejb/assembler/classic/Assembler.java    | 40 +++++++++++++++++---
 1 file changed, 35 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/65768eaf/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
index 91b3933..76feebc 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
@@ -19,6 +19,7 @@ package org.apache.openejb.assembler.classic;
 
 import org.apache.geronimo.connector.GeronimoBootstrapContext;
 import org.apache.geronimo.connector.outbound.AbstractConnectionManager;
+import org.apache.geronimo.connector.outbound.GenericConnectionManager;
 import org.apache.geronimo.connector.work.GeronimoWorkManager;
 import org.apache.geronimo.connector.work.HintsContextHandler;
 import org.apache.geronimo.connector.work.TransactionContextHandler;
@@ -107,9 +108,7 @@ import org.apache.openejb.loader.JarLocation;
 import org.apache.openejb.loader.Options;
 import org.apache.openejb.loader.ProvisioningUtil;
 import org.apache.openejb.loader.SystemInstance;
-import org.apache.openejb.monitoring.DynamicMBeanWrapper;
-import org.apache.openejb.monitoring.LocalMBeanServer;
-import org.apache.openejb.monitoring.ObjectNameBuilder;
+import org.apache.openejb.monitoring.*;
 import org.apache.openejb.monitoring.remote.RemoteResourceMonitor;
 import org.apache.openejb.observer.Observes;
 import org.apache.openejb.persistence.JtaEntityManagerRegistry;
@@ -3250,10 +3249,41 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
             logger.getChildLogger("service").info("createResource.createConnectionManager",
serviceInfo.id, service.getClass().getName());
 
             // create the connection manager
-            final ConnectionManager connectionManager = (ConnectionManager) connectionManagerRecipe.create();
-            // TODO: wrap GenericConnectionManager with something to provide stats via JMX
+            final GenericConnectionManager connectionManager = (GenericConnectionManager)
connectionManagerRecipe.create();
 
 
+            String txSupport = "xa";
+            try {
+                txSupport = (String) connectionManagerRecipe.getProperty("transactionSupport");
+            } catch (Exception e) {
+                // ignore
+            }
+
+            if (txSupport == null || txSupport.trim().length() == 0) {
+                txSupport = "xa";
+            }
+
+            final ConnectionFactoryMonitor cfm = new ConnectionFactoryMonitor(serviceInfo.id,
connectionManager, txSupport);
+
+            final MBeanServer server = LocalMBeanServer.get();
+
+            final ObjectNameBuilder jmxName = new ObjectNameBuilder("openejb.management");
+            jmxName.set("J2EEServer", "openejb");
+            jmxName.set("J2EEApplication", null);
+            jmxName.set("j2eeType", "");
+            jmxName.set("name",serviceInfo.id);
+
+            // register the invocation stats interceptor
+            try {
+                final ObjectName objectName = jmxName.set("j2eeType", "ConnectionFactory").build();
+                if (server.isRegistered(objectName)) {
+                    server.unregisterMBean(objectName);
+                }
+                server.registerMBean(new ManagedMBean(cfm), objectName);
+            } catch (final Exception e) {
+                logger.error("Unable to register MBean ", e);
+            }
+
             if (connectionManager == null) {
                 throw new OpenEJBRuntimeException(messages.format("assembler.invalidConnectionManager",
serviceInfo.id));
             }


Mime
View raw message