svn commit: r702954 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/main/java/org/apache/camel/management/ components/camel-spring/src/main/java/org/apache/camel/spring/ examples/camel-example-spring/src/main/...

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r702954 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/main/java/org/apache/camel/management/ components/camel-spring/src/main/java/org/apache/camel/spring/ examples/camel-example-spring/src/main/...

hadrian-3
Author: hadrian
Date: Wed Oct  8 11:24:27 2008
New Revision: 702954

URL: http://svn.apache.org/viewvc?rev=702954&view=rev
Log:
CAMEL-865.

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/EventDrivenConsumerRoute.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/CamelNamingStrategy.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
    activemq/camel/trunk/examples/camel-example-spring/src/main/resources/META-INF/spring/camel-context.xml
    activemq/camel/trunk/examples/camel-example-spring/src/test/java/org/apache/camel/example/spring/IntegrationTest.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=702954&r1=702953&r2=702954&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Wed Oct  8 11:24:27 2008
@@ -419,6 +419,7 @@
     public void addService(Object object) throws Exception {
         if (object instanceof Service) {
             Service service = (Service) object;
+            getLifecycleStrategy().onServiceAdd(this, service);
             service.start();
             servicesToClose.add(service);
         }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/EventDrivenConsumerRoute.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/EventDrivenConsumerRoute.java?rev=702954&r1=702953&r2=702954&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/EventDrivenConsumerRoute.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/EventDrivenConsumerRoute.java Wed Oct  8 11:24:27 2008
@@ -65,8 +65,7 @@
         }
         Processor processor = getProcessor();
         if (processor instanceof Service) {
-            Service service = (Service) processor;
-            services.add(service);
+            services.add((Service)processor);
         }
     }
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/CamelNamingStrategy.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/CamelNamingStrategy.java?rev=702954&r1=702953&r2=702954&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/CamelNamingStrategy.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/CamelNamingStrategy.java Wed Oct  8 11:24:27 2008
@@ -23,9 +23,11 @@
 import javax.management.ObjectName;
 
 import org.apache.camel.CamelContext;
+import org.apache.camel.Consumer;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.Route;
+import org.apache.camel.Service;
 import org.apache.camel.model.ProcessorType;
 import org.apache.camel.spi.RouteContext;
 
@@ -43,8 +45,8 @@
     public static final String TYPE_CONTEXT = "context";
     public static final String TYPE_ENDPOINT = "endpoint";
     public static final String TYPE_PROCESSOR = "processor";
+    public static final String TYPE_CONSUMER = "consumer";
     public static final String TYPE_ROUTE = "route";
-    public static final String TYPE_SERVICE = "service";
 
     protected String domainName;
     protected String hostName = "locahost";
@@ -103,11 +105,21 @@
      * <tt>&lt;domain&gt;:context=&lt;context-name&gt;,type=service,name=&lt;service-name&gt;</tt>
      */
     public ObjectName getObjectName(CamelContext context, ManagedService mbean) throws MalformedObjectNameException {
+        String serviceBranch;
+        Service service = mbean.getService();
+        if (service instanceof Consumer) {
+            serviceBranch = TYPE_CONSUMER;
+        } else {
+            return null;
+        }
+        
         StringBuffer buffer = new StringBuffer();
         buffer.append(domainName).append(":");
         buffer.append(KEY_CONTEXT + "=").append(getContextId(context)).append(",");
-        buffer.append(KEY_TYPE + "=" + TYPE_SERVICE + ",");
-        buffer.append(KEY_NAME + "=").append(Integer.toHexString(mbean.getService().hashCode()));
+        buffer.append(KEY_TYPE + "=" + serviceBranch + ",");
+        buffer.append(KEY_NAME + "=")
+            .append(service.getClass().getSimpleName())
+            .append("(0x").append(Integer.toHexString(mbean.getService().hashCode())).append(")");
         return createObjectName(buffer);
     }
 

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java?rev=702954&r1=702953&r2=702954&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java Wed Oct  8 11:24:27 2008
@@ -27,6 +27,7 @@
 import javax.management.ObjectName;
 
 import org.apache.camel.CamelContext;
+import org.apache.camel.Consumer;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.Route;
@@ -136,7 +137,8 @@
         if (!initialized) {
             return;
         }
-        if (service instanceof ServiceSupport) {
+        if (service instanceof ServiceSupport && service instanceof Consumer) {
+            // TODO: add support for non-consumer services?
             try {
                 ManagedService ms = new ManagedService((ServiceSupport)service);
                 agent.register(ms, getNamingStrategy().getObjectName(context, ms));

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java?rev=702954&r1=702953&r2=702954&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java Wed Oct  8 11:24:27 2008
@@ -77,6 +77,7 @@
     private static final Log LOG = LogFactory.getLog(CamelContextFactoryBean.class);
 
     @XmlAttribute(required = false)
+    @Deprecated
     private Boolean useJmx = Boolean.TRUE;
     @XmlAttribute(required = false)
     private Boolean autowireRouteBuilders = Boolean.TRUE;
@@ -224,8 +225,7 @@
         // lets force any lazy creation
         getContext().addRouteDefinitions(routes);
 
-        if (!isJmxEnabled()
-                || (camelJMXAgent != null && camelJMXAgent.isDisabled() != null && camelJMXAgent.isDisabled())) {
+        if (!isJmxEnabled() || (camelJMXAgent != null && camelJMXAgent.isDisabled())) {
             LOG.debug("JMXAgent disabled");
             getContext().setLifecycleStrategy(new DefaultLifecycleStrategy());
         } else if (camelJMXAgent != null) {
@@ -394,6 +394,9 @@
         return useJmx.booleanValue();
     }
 
+    /**
+     * @deprecated Please the jmxAgent element instead. Will be removed in Camel 2.0.
+     */
     public Boolean getUseJmx() {
         return useJmx;
     }

Modified: activemq/camel/trunk/examples/camel-example-spring/src/main/resources/META-INF/spring/camel-context.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-spring/src/main/resources/META-INF/spring/camel-context.xml?rev=702954&r1=702953&r2=702954&view=diff
==============================================================================
--- activemq/camel/trunk/examples/camel-example-spring/src/main/resources/META-INF/spring/camel-context.xml (original)
+++ activemq/camel/trunk/examples/camel-example-spring/src/main/resources/META-INF/spring/camel-context.xml Wed Oct  8 11:24:27 2008
@@ -25,6 +25,9 @@
   <camelContext id="camel"
                 xmlns="http://activemq.apache.org/camel/schema/spring">
     <package>org.apache.camel.example.spring</package>
+    
+    <!-- Default JMX connector url: "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi/camel" -->
+    <jmxAgent id="agent" createConnector="true"/>    
   </camelContext>
 
   <!-- lets configure the default ActiveMQ broker URL -->

Modified: activemq/camel/trunk/examples/camel-example-spring/src/test/java/org/apache/camel/example/spring/IntegrationTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-spring/src/test/java/org/apache/camel/example/spring/IntegrationTest.java?rev=702954&r1=702953&r2=702954&view=diff
==============================================================================
--- activemq/camel/trunk/examples/camel-example-spring/src/test/java/org/apache/camel/example/spring/IntegrationTest.java (original)
+++ activemq/camel/trunk/examples/camel-example-spring/src/test/java/org/apache/camel/example/spring/IntegrationTest.java Wed Oct  8 11:24:27 2008
@@ -26,7 +26,6 @@
 
     public void testCamelRulesDeployCorrectlyInSpring() throws Exception {
         // let's boot up the Spring application context for 2 seconds to check that it works OK
-        // System.setProperty("org.apache.camel.jmx.createRmiConnector", "true");        
         Main.main("-duration", "2s", "-o", "target/site/cameldoc");
     }
 }