camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r937203 - in /camel/trunk/components/camel-jetty/src: main/java/org/apache/camel/component/jetty/JettyHttpComponent.java test/java/org/apache/camel/component/jetty/JettyEnableJmxTest.java
Date Fri, 23 Apr 2010 09:15:14 GMT
Author: davsclaus
Date: Fri Apr 23 09:15:13 2010
New Revision: 937203

URL: http://svn.apache.org/viewvc?rev=937203&view=rev
Log:
Do not WARN on shutdown if JMX was disabled, that the JMX will be disabled for Jetty JMX extensions.

Modified:
    camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
    camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyEnableJmxTest.java

Modified: camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java?rev=937203&r1=937202&r2=937203&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
(original)
+++ camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
Fri Apr 23 09:15:13 2010
@@ -194,7 +194,8 @@ public class JettyHttpComponent extends 
                 connector.setPort(endpoint.getPort());
                 connector.setHost(endpoint.getHttpUri().getHost());
                 if ("localhost".equalsIgnoreCase(endpoint.getHttpUri().getHost())) {
-                    LOG.warn("You use localhost interface! It means that no external connections
will be available. Don't you want to use 0.0.0.0 instead (all network interfaces)?");
+                    LOG.warn("You use localhost interface! It means that no external connections
will be available."
+                            + " Don't you want to use 0.0.0.0 instead (all network interfaces)?
" + endpoint);
                 }
                 Server server = createServer();
                 if (endpoint.isEnableJmx()) {
@@ -222,6 +223,7 @@ public class JettyHttpComponent extends 
     private void enableJmx(Server server) {
         MBeanContainer containerToRegister = getMbContainer();
         if (containerToRegister != null) {
+            LOG.info("Jetty JMX Extensions is enabled");
             server.getContainer().addEventListener(containerToRegister);
             // Since we may have many Servers running, don't tie the MBeanContainer
             // to a Server lifecycle or we end up closing it while it is still in use.
@@ -264,10 +266,9 @@ public class JettyHttpComponent extends 
                     CONNECTORS.remove(connectorKey);
                     // Camel controls the lifecycle of these entities so remove the
                     // registered MBeans when Camel is done with the managed objects.
-                    MBeanContainer containerToClean = getMbContainer(); 
-                    if (containerToClean != null) {
-                        containerToClean.removeBean(connectorRef.server);
-                        containerToClean.removeBean(connectorRef.connector);
+                    if (mbContainer != null) {
+                        mbContainer.removeBean(connectorRef.server);
+                        mbContainer.removeBean(connectorRef.connector);
                     }
                 }
             }
@@ -425,8 +426,7 @@ public class JettyHttpComponent extends 
         if (mbContainer == null) {
             MBeanServer mbs = null;
             
-            final ManagementStrategy mStrategy = 
-                this.getCamelContext().getManagementStrategy();
+            final ManagementStrategy mStrategy = this.getCamelContext().getManagementStrategy();
             final ManagementAgent mAgent = mStrategy.getManagementAgent();
             if (mAgent != null) {
                 mbs = mAgent.getMBeanServer();
@@ -436,7 +436,7 @@ public class JettyHttpComponent extends 
                 mbContainer = new MBeanContainer(mbs);
                 startMbContainer();
             } else {
-                LOG.warn("JMX disabled in Camel Context.  The Camel Context takes precedent
and JMX will not be enabled in Jetty.");
+                LOG.warn("JMX disabled in CamelContext. Jetty JMX extensions will remain
disabled.");
             }
         }
         
@@ -492,10 +492,9 @@ public class JettyHttpComponent extends 
     }
     
     /**
-     * Starts {@link #mbContainer} and registers the
-     * container with itself as a managed bean logging an error
-     * if there is a problem starting the container.  Does nothing
-     * if {@link #mbContainer} is {@code null}.
+     * Starts {@link #mbContainer} and registers the container with itself as a managed bean
+     * logging an error if there is a problem starting the container.
+     * Does nothing if {@link #mbContainer} is {@code null}.
      */
     protected void startMbContainer() {
         if (mbContainer != null && !mbContainer.isStarted()) {
@@ -504,8 +503,8 @@ public class JettyHttpComponent extends 
                 // Publish the container itself for consistency with
                 // traditional embedded Jetty configurations.
                 mbContainer.addBean(mbContainer);
-            } catch (Exception e) {
-                LOG.warn("Could not start Jetty MBeanContainer.  Jetty JMX extensions will
remain disabled.", e);
+            } catch (Throwable e) {
+                LOG.warn("Could not start Jetty MBeanContainer. Jetty JMX extensions will
remain disabled.", e);
             }
         }
     }

Modified: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyEnableJmxTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyEnableJmxTest.java?rev=937203&r1=937202&r2=937203&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyEnableJmxTest.java
(original)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyEnableJmxTest.java
Fri Apr 23 09:15:13 2010
@@ -31,7 +31,7 @@ import org.apache.camel.test.junit4.Came
 import org.junit.Test;
 
 
-public class JettyEnableJmxTest  extends CamelTestSupport {
+public class JettyEnableJmxTest extends CamelTestSupport {
     
     private String serverUri0 = 
         "http://localhost:9080/myservice?enableJmx=true";
@@ -48,10 +48,12 @@ public class JettyEnableJmxTest  extends
         releaseMBeanServers();
         mbsc = null;
         super.tearDown();
+        disableJMX();
     }
 
     @Override
     public void setUp() throws Exception {
+        enableJMX();
         releaseMBeanServers();
         super.setUp();
         mbsc = getMBeanConnection();
@@ -61,8 +63,7 @@ public class JettyEnableJmxTest  extends
     public void testEnableJmxProperty() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         String expectedBody = "<html><body>foo</body></html>";
-        mock.expectedBodiesReceived(
-                expectedBody, expectedBody, expectedBody, expectedBody);
+        mock.expectedBodiesReceived(expectedBody, expectedBody, expectedBody, expectedBody);
         mock.expectedHeaderReceived("x", "foo");
 
         template.requestBody(serverUri0 + "&x=foo", null, Object.class);
@@ -142,8 +143,7 @@ public class JettyEnableJmxTest  extends
     }
     
     protected void releaseMBeanServers() {
-        List<MBeanServer> servers =
-            (List<MBeanServer>)MBeanServerFactory.findMBeanServer(null);
+        List<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null);
 
         for (MBeanServer server : servers) {
             MBeanServerFactory.releaseMBeanServer(server);



Mime
View raw message