tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1405857 - in /openejb/trunk/openejb: container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ container/openejb-core/src/main/java/org/apache/openejb/monitoring/ container/openejb-core/src/main/java/org/apache/openejb/res...
Date Mon, 05 Nov 2012 16:01:32 GMT
Author: rmannibucau
Date: Mon Nov  5 16:01:31 2012
New Revision: 1405857

URL: http://svn.apache.org/viewvc?rev=1405857&view=rev
Log:
TOMEE-525 no jmx by default

Modified:
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ReloadableEntityManagerFactory.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/monitoring/LocalMBeanServer.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/dbcp/JMXBasicDataSource.java
    openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/EjbdJmxTest.java
    openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/ServiceManager.java
    openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/SimpleServiceManager.java
    openejb/trunk/openejb/tomee/tomee-common/src/main/java/org/apache/tomee/installer/Installer.java

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java?rev=1405857&r1=1405856&r2=1405857&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
Mon Nov  5 16:01:31 2012
@@ -966,19 +966,21 @@ public class Assembler extends Assembler
             instance = bm.getReference(bean, clazz, bm.createCreationalContext(bean));
         }
 
-        final MBeanServer server = LocalMBeanServer.get();
-        try {
-            final ObjectName leaf = new ObjectNameBuilder("openejb.user.mbeans")
-                    .set("application", id)
-                    .set("group", clazz.getPackage().getName())
-                    .set("name", clazz.getSimpleName())
-                    .build();
-
-            server.registerMBean(new DynamicMBeanWrapper(instance), leaf);
-            appMbeans.put(mbeanClass, leaf.getCanonicalName());
-            logger.info("Deployed MBean(" + leaf.getCanonicalName() + ")");
-        } catch (Exception e) {
-            logger.error("the mbean " + mbeanClass + " can't be registered", e);
+        if (LocalMBeanServer.isJMXActive()) {
+            final MBeanServer server = LocalMBeanServer.get();
+            try {
+                final ObjectName leaf = new ObjectNameBuilder("openejb.user.mbeans")
+                        .set("application", id)
+                        .set("group", clazz.getPackage().getName())
+                        .set("name", clazz.getSimpleName())
+                        .build();
+
+                server.registerMBean(new DynamicMBeanWrapper(instance), leaf);
+                appMbeans.put(mbeanClass, leaf.getCanonicalName());
+                logger.info("Deployed MBean(" + leaf.getCanonicalName() + ")");
+            } catch (Exception e) {
+                logger.error("the mbean " + mbeanClass + " can't be registered", e);
+            }
         }
     }
 
@@ -1568,7 +1570,7 @@ public class Assembler extends Assembler
 
         logger.getChildLogger("service").debug("createService.success", serviceInfo.service,
serviceInfo.id, serviceInfo.className);
 
-        if (service instanceof Container) {
+        if (service instanceof Container && LocalMBeanServer.isJMXActive()) {
             final ObjectName objectName = ObjectNameBuilder.uniqueName("containers", serviceInfo.id,
service);
             try {
                 LocalMBeanServer.get().registerMBean(new DynamicMBeanWrapper(new JMXContainer(serviceInfo,
(Container) service)), objectName);

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ReloadableEntityManagerFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ReloadableEntityManagerFactory.java?rev=1405857&r1=1405856&r2=1405857&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ReloadableEntityManagerFactory.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ReloadableEntityManagerFactory.java
Mon Nov  5 16:01:31 2012
@@ -185,6 +185,10 @@ public class ReloadableEntityManagerFact
     }
 
     public void register() throws OpenEJBException {
+        if (!LocalMBeanServer.isJMXActive()) {
+            return;
+        }
+
         final MBeanServer server = LocalMBeanServer.get();
         try {
             generateObjectName();

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/monitoring/LocalMBeanServer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/monitoring/LocalMBeanServer.java?rev=1405857&r1=1405856&r2=1405857&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/monitoring/LocalMBeanServer.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/monitoring/LocalMBeanServer.java
Mon Nov  5 16:01:31 2012
@@ -48,6 +48,7 @@ public class LocalMBeanServer implements
     public static final String OPENEJB_JMX_ACTIVE = "openejb.jmx.active";
 
     private static final LocalMBeanServer INSTANCE = new LocalMBeanServer();
+    private static final boolean ACTIVE = SystemInstance.get().getOptions().get(OPENEJB_JMX_ACTIVE,
false);
 
     private LocalMBeanServer() {
         // no-op
@@ -58,7 +59,7 @@ public class LocalMBeanServer implements
     }
 
     public static boolean isJMXActive() {
-        return SystemInstance.get().getOptions().get(OPENEJB_JMX_ACTIVE, true);
+        return ACTIVE;
     }
 
     private static MBeanServer s() {

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/dbcp/JMXBasicDataSource.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/dbcp/JMXBasicDataSource.java?rev=1405857&r1=1405856&r2=1405857&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/dbcp/JMXBasicDataSource.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/dbcp/JMXBasicDataSource.java
Mon Nov  5 16:01:31 2012
@@ -39,19 +39,25 @@ public class JMXBasicDataSource {
     public JMXBasicDataSource(final String name, final org.apache.commons.dbcp.BasicDataSource
ds) {
         this.ds = ds;
 
-        objectName = ObjectNameBuilder.uniqueName("datasources", name, ds);
-        final MBeanServer server = LocalMBeanServer.get();
-        try {
-            if (server.isRegistered(objectName)) {
-                server.unregisterMBean(objectName);
+        if (LocalMBeanServer.isJMXActive()) {
+            objectName = ObjectNameBuilder.uniqueName("datasources", name, ds);
+            final MBeanServer server = LocalMBeanServer.get();
+            try {
+                if (server.isRegistered(objectName)) {
+                    server.unregisterMBean(objectName);
+                }
+                server.registerMBean(new DynamicMBeanWrapper(this), objectName);
+            } catch (Exception e) {
+                e.printStackTrace(); // TODO
             }
-            server.registerMBean(new DynamicMBeanWrapper(this), objectName);
-        } catch (Exception e) {
-            e.printStackTrace(); // TODO
         }
     }
 
     public void unregister() {
+        if (objectName == null) {
+            return;
+        }
+
         try {
             LocalMBeanServer.get().unregisterMBean(objectName);
         } catch (Exception e) {

Modified: openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/EjbdJmxTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/EjbdJmxTest.java?rev=1405857&r1=1405856&r2=1405857&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/EjbdJmxTest.java
(original)
+++ openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/EjbdJmxTest.java
Mon Nov  5 16:01:31 2012
@@ -35,6 +35,7 @@ public class EjbdJmxTest {
 
     @Test
     public void test() throws Exception {
+        System.setProperty("openejb.jmx.active", "true");
         final MBeanServer server = LocalMBeanServer.get();
 
         OpenEJB.init(new Properties());

Modified: openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/ServiceManager.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/ServiceManager.java?rev=1405857&r1=1405856&r2=1405857&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/ServiceManager.java
(original)
+++ openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/ServiceManager.java
Mon Nov  5 16:01:31 2012
@@ -162,9 +162,11 @@ public abstract class ServiceManager {
                     registry.addDiscoveryAgent(agent);
                 }
 
-                MBeanServer server = LocalMBeanServer.get();
+                if (LocalMBeanServer.isJMXActive()) {
+                    MBeanServer server = LocalMBeanServer.get();
 
-                register(serviceName, service, server);
+                    register(serviceName, service, server);
+                }
 
                 return service;
             } catch (Throwable t) {

Modified: openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/SimpleServiceManager.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/SimpleServiceManager.java?rev=1405857&r1=1405856&r2=1405857&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/SimpleServiceManager.java
(original)
+++ openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/SimpleServiceManager.java
Mon Nov  5 16:01:31 2012
@@ -228,20 +228,22 @@ public class SimpleServiceManager extend
         final ServerService[] services = daemons.clone();
 
         final MBeanServer server = LocalMBeanServer.get();
-        for (int i = 0; i < services.length; i++) {
-            final ObjectName on = getObjectName(services[i].getName());
-            if (server.isRegistered(on)) {
-                try {
-                    server.unregisterMBean(on);
-                } catch (Exception ignored) {
-                    // no-op
+        for (ServerService service : services) {
+            if (LocalMBeanServer.isJMXActive()) {
+                final ObjectName on = getObjectName(service.getName());
+                if (server.isRegistered(on)) {
+                    try {
+                        server.unregisterMBean(on);
+                    } catch (Exception ignored) {
+                        // no-op
+                    }
                 }
             }
 
             try {
-                services[i].stop();
+                service.stop();
             } catch (ServiceException e) {
-                logger.fatal("Service Shutdown Failed: " + services[i].getName() + ".  Exception:
" + e.getMessage(), e);
+                logger.fatal("Service Shutdown Failed: " + service.getName() + ".  Exception:
" + e.getMessage(), e);
             }
         }
 

Modified: openejb/trunk/openejb/tomee/tomee-common/src/main/java/org/apache/tomee/installer/Installer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/tomee/tomee-common/src/main/java/org/apache/tomee/installer/Installer.java?rev=1405857&r1=1405856&r2=1405857&view=diff
==============================================================================
--- openejb/trunk/openejb/tomee/tomee-common/src/main/java/org/apache/tomee/installer/Installer.java
(original)
+++ openejb/trunk/openejb/tomee/tomee-common/src/main/java/org/apache/tomee/installer/Installer.java
Mon Nov  5 16:01:31 2012
@@ -599,6 +599,7 @@ public class Installer {
 
                 systemPropertiesWriter.write("\n");
                 systemPropertiesWriter.write("# openejb.servicemanager.enabled = true\n");
+                systemPropertiesWriter.write("# openejb.jmx.active = false\n");
                 systemPropertiesWriter.write("# openejb.descriptors.output = false\n");
                 systemPropertiesWriter.write("# openejb.strict.interface.declaration = false\n");
                 systemPropertiesWriter.write("# openejb.conf.file = conf/tomee.xml\n");
@@ -617,7 +618,6 @@ public class Installer {
                 systemPropertiesWriter.write("# openejb.jndiname.failoncollision = true\n");
                 systemPropertiesWriter.write("# openejb.wsAddress.format = /{ejbDeploymentId}\n");
                 systemPropertiesWriter.write("# org.apache.openejb.server.webservices.saaj.provider
= \n");
-                systemPropertiesWriter.write("# openejb.jmx.active = true\n");
                 systemPropertiesWriter.write("# openejb.nobanner = true\n");
                 systemPropertiesWriter.write("# openejb.offline = false\n");
                 systemPropertiesWriter.write("# openejb.jmx.active = true\n");



Mime
View raw message