camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r579301 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/ camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/main/java/org/apache/camel/management/ camel-core/src/test/java/org/apache/camel/management/ compo...
Date Tue, 25 Sep 2007 15:51:47 GMT
Author: chirino
Date: Tue Sep 25 08:51:35 2007
New Revision: 579301

URL: http://svn.apache.org/viewvc?rev=579301&view=rev
Log:
Appling http://issues.apache.org/activemq/browse/CAMEL-154

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java
    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/management/CamelNamingStrategy.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/ManagedService.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/managment/JmxInstrumentationWithConnectorTest.java
    activemq/camel/trunk/components/camel-stringtemplate/src/test/java/org/apache/camel/component/stringtemplate/StringTemplateTest.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java?rev=579301&r1=579300&r2=579301&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java Tue Sep
25 08:51:35 2007
@@ -36,6 +36,11 @@
  */
 public interface CamelContext extends Service {
 
+    /**
+     * Gets the name of the this context.
+     */
+    String getName();
+
     // Component Management Methods
     //-----------------------------------------------------------------------
 

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=579301&r1=579300&r2=579301&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
Tue Sep 25 08:51:35 2007
@@ -62,7 +62,10 @@
  */
 public class DefaultCamelContext extends ServiceSupport implements CamelContext, Service
{
     private static final transient Log LOG = LogFactory.getLog(DefaultCamelContext.class);
+    private static final String NAME_PREFIX = "camel-";
+    private static int NAME_SUFFIX = 0;
 
+    private String name;
     private Map<String, Endpoint> endpoints = new HashMap<String, Endpoint>();
     private Map<String, Component> components = new HashMap<String, Component>();
     private List<Route> routes;
@@ -78,6 +81,7 @@
     private List<RouteType> routeDefinitions = new ArrayList<RouteType>();
 
     public DefaultCamelContext() {
+    	name = NAME_PREFIX + ++NAME_SUFFIX;
     }
 
     /**
@@ -94,7 +98,22 @@
      * Creates the {@link CamelContext} using the given registry
      */
     public DefaultCamelContext(Registry registry) {
+    	this();
         this.registry = registry;
+    }
+
+    /**
+     * Gets the name of the this context.
+     */
+    public String getName() {
+    	return name;
+    }
+
+    /**
+     * Sets the name of the this context.
+     */
+    public void setName(String name) {
+    	this.name = name;
     }
 
     /**

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=579301&r1=579300&r2=579301&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
Tue Sep 25 08:51:35 2007
@@ -28,14 +28,18 @@
 
 public class CamelNamingStrategy {
     public static final String VALUE_UNKNOWN = "unknown";
-    public static final String KEY_CONTEXT = "context";
-    public static final String KEY_CLASS = "class";
-    public static final String KEY_TYPE = "type";
+    public static final String VALUE_ROUTE = "route";
     public static final String KEY_NAME = "name";
+    public static final String KEY_TYPE = "type";
+    public static final String KEY_CONTEXT = "context";
+    public static final String KEY_GROUP = "group";
+    public static final String KEY_COMPONENT = "component";
+    public static final String KEY_ROUTE_TYPE = "routeType";
     public static final String KEY_ROUTE = "route";
-    public static final String CLASS_ENDPOINTS = "endpoints";
-    public static final String CLASS_SERVICES = "services";
-    public static final String CLASS_ROUTES = "routes";
+    public static final String GROUP_ENDPOINTS = "endpoints";
+    public static final String GROUP_SERVICES = "services";
+    public static final String GROUP_ROUTE_BUILDER = "routeBuilder";
+    public static final String GROUP_ROUTE_TYPE = "routeType";
     protected String domainName;
     protected String hostName = "locahost";
 
@@ -87,7 +91,8 @@
         StringBuffer buffer = new StringBuffer();
         buffer.append(domainName + ":");
         buffer.append(KEY_CONTEXT + "=" + getContextId(ep.getContext()) + ",");
-        buffer.append(KEY_CLASS + "=" + CLASS_ENDPOINTS + ",");
+        buffer.append(KEY_GROUP + "=" + GROUP_ENDPOINTS + ",");
+        buffer.append(KEY_COMPONENT + "=" + getComponentId(ep) + ",");
         buffer.append(KEY_NAME + "=" + getEndpointId(ep));
         return createObjectName(buffer);
     }
@@ -105,7 +110,7 @@
         StringBuffer buffer = new StringBuffer();
         buffer.append(domainName + ":");
         buffer.append(KEY_CONTEXT + "=" + getContextId(context) + ",");
-        buffer.append(KEY_CLASS + "=" + CLASS_SERVICES + ",");
+        buffer.append(KEY_GROUP + "=" + GROUP_SERVICES + ",");
         buffer.append(KEY_NAME + "=" + Integer.toHexString(mbean.getService().hashCode()));
         return createObjectName(buffer);
     }
@@ -123,12 +128,17 @@
     public ObjectName getObjectName(ManagedRoute mbean) throws MalformedObjectNameException
{
         Endpoint ep = mbean.getRoute().getEndpoint();
         String ctxid = ep != null ? getContextId(ep.getContext()) : VALUE_UNKNOWN;
-
+        String cid = getComponentId(ep);
+        String id = VALUE_UNKNOWN.equals(cid) ? getEndpointId(ep) : 
+        	"[" + cid + "]" + getEndpointId(ep);
+        
         StringBuffer buffer = new StringBuffer();
         buffer.append(domainName + ":");
         buffer.append(KEY_CONTEXT + "=" + ctxid + ",");
-        buffer.append(KEY_CLASS + "=" + CLASS_ROUTES + ",");
-        buffer.append(KEY_ROUTE + "=" + getEndpointId(ep));
+        buffer.append(KEY_GROUP + "=" + GROUP_ROUTE_BUILDER + ",");
+        buffer.append(KEY_ROUTE_TYPE + "=" + GROUP_ROUTE_TYPE + ",");
+        buffer.append(KEY_ROUTE + "=" + id + ",");
+        buffer.append(KEY_NAME + "=" + VALUE_ROUTE);
         return createObjectName(buffer);
     }
 
@@ -145,8 +155,8 @@
         StringBuffer buffer = new StringBuffer();
         buffer.append(domainName + ":");
         buffer.append(KEY_CONTEXT + "=" + getContextId(context) + ",");
-        buffer.append(KEY_CLASS + "=" + CLASS_ROUTES + ",");
-        buffer.append(KEY_ROUTE + "=" + "Route.Counter" + ",");     // TODO: figure out the
route id
+        buffer.append(KEY_GROUP + "=" + GROUP_ENDPOINTS + ",");
+        buffer.append(KEY_ROUTE + "=" + "Route.Counter" + ",");
         buffer.append(KEY_NAME + "=" + "Stats");
         return createObjectName(buffer);
     }
@@ -168,15 +178,20 @@
     }
 
     protected String getContextId(CamelContext context) {
-        String id = context != null ? Integer.toString(context.hashCode()) : VALUE_UNKNOWN;
+        String id = context != null ? context.getName() : VALUE_UNKNOWN;
         return hostName + "/" + id;
     }
 
+    protected String getComponentId(Endpoint ep) {
+        String uri = ep.getEndpointUri();
+        int pos = uri.indexOf(':');
+        return (pos == -1) ? VALUE_UNKNOWN : uri.substring(0, pos);
+    }
+    
     protected String getEndpointId(Endpoint ep) {
         String uri = ep.getEndpointUri();
         int pos = uri.indexOf(':');
-        String id = (pos == -1) ? uri :
-                "[" + uri.substring(0, pos) + "]" + uri.substring(pos + 1);
+        String id = (pos == -1) ? uri : uri.substring(pos + 1);
 		if (!ep.isSingleton()) { 
 			id += "." + Integer.toString(ep.hashCode());
 		}

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=579301&r1=579300&r2=579301&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
Tue Sep 25 08:51:35 2007
@@ -95,12 +95,16 @@
 		PerformanceCounter mc = new PerformanceCounter();
 		routeType.intercept(new InstrumentationProcessor(mc));
 
+		/*
+		 *  Merge performance counter with the MBean it represents instead 
+		 *  of registering a new MBean
 		try {
 			agent.register(mc, getNamingStrategy().getObjectName(context, mc));
 		}
 		catch(JMException e) {
 			LOG.warn("Could not register Counter MBean", e);
 		}
+		*/
 	}
 
     public CamelNamingStrategy getNamingStrategy() {

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/ManagedService.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/ManagedService.java?rev=579301&r1=579300&r2=579301&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/ManagedService.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/ManagedService.java
Tue Sep 25 08:51:35 2007
@@ -41,7 +41,7 @@
 	}
 	
 	@ManagedAttribute(description = "Service running state")
-    private boolean isStarted() throws IOException {
+    public boolean isStarted() throws IOException {
     	return service.isStarted();
     }
 

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java?rev=579301&r1=579300&r2=579301&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java
Tue Sep 25 08:51:35 2007
@@ -17,12 +17,9 @@
  */
 package org.apache.camel.management;
 
-import java.io.IOException;
 import java.util.Iterator;
 import java.util.Set;
 
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanInfo;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
@@ -46,7 +43,7 @@
 
     	resolveMandatoryEndpoint("mock:end", MockEndpoint.class);
 
-        ObjectName name = new ObjectName(domainName + ":class=endpoints,*");
+        ObjectName name = new ObjectName(domainName + ":group=endpoints,*");
         Set s = iAgent.getMBeanServer().queryNames(name, null);
 
         if (sleepSoYouCanBrowseInJConsole) {
@@ -62,6 +59,9 @@
 
         resultEndpoint.assertIsSatisfied();
 
+        /* 
+         * Fixme: after stats are merged with the mbean they represent
+         * 
         MBeanServer mbs = iAgent.getMBeanServer();
         ObjectName name = new ObjectName(domainName + ":name=Stats,*");
         Set s = mbs.queryNames(name, null);
@@ -95,6 +95,7 @@
         		"'<domain>:name=Stats,*' key must be of type PerformanceCounter.class", valueofMeanProcessingTime);
         assertTrue(valueofMeanProcessingTime >= valueofMinProcessingTime &&
         		valueofMeanProcessingTime <= valueofMaxProcessingTime);
+         */
     }
 
     protected void enableJmx() {

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=579301&r1=579300&r2=579301&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
Tue Sep 25 08:51:35 2007
@@ -239,7 +239,9 @@
      * Create the context
      */
     protected SpringCamelContext createContext() {
-        return new SpringCamelContext(getApplicationContext());
+    	SpringCamelContext ctx = new SpringCamelContext(getApplicationContext());
+    	ctx.setName(getId());
+    	return ctx;
     }
 
     /**

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java?rev=579301&r1=579300&r2=579301&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
Tue Sep 25 08:51:35 2007
@@ -135,6 +135,7 @@
             Object value = parseUsingJaxb(element, parserContext);
             if (value instanceof CamelContextFactoryBean) {
                 CamelContextFactoryBean factoryBean = (CamelContextFactoryBean)value;
+                builder.addPropertyValue("id", contextId);
                 builder.addPropertyValue("routes", factoryBean.getRoutes());
 
                 if (factoryBean.getPackages().length > 0) {

Modified: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/managment/JmxInstrumentationWithConnectorTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/managment/JmxInstrumentationWithConnectorTest.java?rev=579301&r1=579300&r2=579301&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/managment/JmxInstrumentationWithConnectorTest.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/managment/JmxInstrumentationWithConnectorTest.java
Tue Sep 25 08:51:35 2007
@@ -34,4 +34,8 @@
 	protected ClassPathXmlApplicationContext createApplicationContext() {
         return new ClassPathXmlApplicationContext("org/apache/camel/spring/management/jmxInstrumentationWithConnector.xml");
 	}
+    
+    public void testGetContext() {
+        assertNotNull(this.applicationContext.getBean("camel"));        
+    }
 }

Modified: activemq/camel/trunk/components/camel-stringtemplate/src/test/java/org/apache/camel/component/stringtemplate/StringTemplateTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-stringtemplate/src/test/java/org/apache/camel/component/stringtemplate/StringTemplateTest.java?rev=579301&r1=579300&r2=579301&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-stringtemplate/src/test/java/org/apache/camel/component/stringtemplate/StringTemplateTest.java
(original)
+++ activemq/camel/trunk/components/camel-stringtemplate/src/test/java/org/apache/camel/component/stringtemplate/StringTemplateTest.java
Tue Sep 25 08:51:35 2007
@@ -22,8 +22,6 @@
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import static org.apache.camel.language.simple.SimpleLanguage.simple;
-import org.apache.camel.util.ExchangeHelper;
 
 /**
  * @version $Revision: 1.1 $



Mime
View raw message