You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2007/05/01 15:57:36 UTC

svn commit: r534095 - in /activemq/camel/trunk: ./ camel-rmi/ camel-rmi/src/ camel-rmi/src/main/ camel-rmi/src/main/java/ camel-rmi/src/main/java/org/ camel-rmi/src/main/java/org/apache/ camel-rmi/src/main/java/org/apache/camel/ camel-rmi/src/main/java...

Author: chirino
Date: Tue May  1 06:57:33 2007
New Revision: 534095

URL: http://svn.apache.org/viewvc?view=rev&rev=534095
Log:
Added a camel-rmi component that can bind PojoExchanges to RMI/JRMP

Added:
    activemq/camel/trunk/camel-rmi/
    activemq/camel/trunk/camel-rmi/pom.xml
    activemq/camel/trunk/camel-rmi/src/
    activemq/camel/trunk/camel-rmi/src/main/
    activemq/camel/trunk/camel-rmi/src/main/java/
    activemq/camel/trunk/camel-rmi/src/main/java/org/
    activemq/camel/trunk/camel-rmi/src/main/java/org/apache/
    activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/
    activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/
    activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/
    activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiComponent.java
    activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiConsumer.java
    activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiEndpoint.java
    activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiProducer.java
    activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/package.html
    activemq/camel/trunk/camel-rmi/src/main/resources/
    activemq/camel/trunk/camel-rmi/src/main/resources/META-INF/
    activemq/camel/trunk/camel-rmi/src/main/resources/META-INF/services/
    activemq/camel/trunk/camel-rmi/src/main/resources/META-INF/services/org/
    activemq/camel/trunk/camel-rmi/src/main/resources/META-INF/services/org/apache/
    activemq/camel/trunk/camel-rmi/src/main/resources/META-INF/services/org/apache/camel/
    activemq/camel/trunk/camel-rmi/src/main/resources/META-INF/services/org/apache/camel/component/
    activemq/camel/trunk/camel-rmi/src/main/resources/META-INF/services/org/apache/camel/component/rmi
    activemq/camel/trunk/camel-rmi/src/test/
    activemq/camel/trunk/camel-rmi/src/test/ide-resources/
    activemq/camel/trunk/camel-rmi/src/test/ide-resources/log4j.properties
    activemq/camel/trunk/camel-rmi/src/test/java/
    activemq/camel/trunk/camel-rmi/src/test/java/org/
    activemq/camel/trunk/camel-rmi/src/test/java/org/apache/
    activemq/camel/trunk/camel-rmi/src/test/java/org/apache/camel/
    activemq/camel/trunk/camel-rmi/src/test/java/org/apache/camel/component/
    activemq/camel/trunk/camel-rmi/src/test/java/org/apache/camel/component/rmi/
    activemq/camel/trunk/camel-rmi/src/test/java/org/apache/camel/component/rmi/ISay.java
    activemq/camel/trunk/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiRouteTest.java
    activemq/camel/trunk/camel-rmi/src/test/java/org/apache/camel/component/rmi/SayService.java
    activemq/camel/trunk/camel-rmi/src/test/resources/
    activemq/camel/trunk/camel-rmi/src/test/resources/log4j.properties
    activemq/camel/trunk/camel-rmi/src/test/resources/org/
    activemq/camel/trunk/camel-rmi/src/test/resources/org/apache/
    activemq/camel/trunk/camel-rmi/src/test/resources/org/apache/camel/
    activemq/camel/trunk/camel-rmi/src/test/resources/org/apache/camel/component/
    activemq/camel/trunk/camel-rmi/src/test/resources/org/apache/camel/component/rmi/
Modified:
    activemq/camel/trunk/pom.xml

Added: activemq/camel/trunk/camel-rmi/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-rmi/pom.xml?view=auto&rev=534095
==============================================================================
--- activemq/camel/trunk/camel-rmi/pom.xml (added)
+++ activemq/camel/trunk/camel-rmi/pom.xml Tue May  1 06:57:33 2007
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-parent</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>camel-rmi</artifactId>
+  <name>Camel :: RMI</name>
+  <description>Camel RMI support</description>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+      <type>test-jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>apache-activemq</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <forkMode>once</forkMode>
+	  <argLine>-Duser.home=C:\DOCUME~1\chirino</argLine>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Added: activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiComponent.java?view=auto&rev=534095
==============================================================================
--- activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiComponent.java (added)
+++ activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiComponent.java Tue May  1 06:57:33 2007
@@ -0,0 +1,45 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.rmi;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.component.pojo.PojoExchange;
+import org.apache.camel.impl.DefaultComponent;
+
+/**
+ * @version $Revision:520964 $
+ */
+public class RmiComponent extends DefaultComponent<PojoExchange> {
+
+	public RmiComponent() {
+	}
+
+	public RmiComponent(CamelContext context) {
+		super(context);
+	}
+
+	@Override
+	protected Endpoint<PojoExchange> createEndpoint(String uri,
+			String remaining, Map parameters) throws Exception {
+		return new RmiEndpoint(uri, this);
+	}
+
+}

Added: activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiConsumer.java?view=auto&rev=534095
==============================================================================
--- activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiConsumer.java (added)
+++ activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiConsumer.java Tue May  1 06:57:33 2007
@@ -0,0 +1,107 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.rmi;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.rmi.Remote;
+import java.rmi.registry.Registry;
+import java.rmi.server.UnicastRemoteObject;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.component.pojo.PojoExchange;
+import org.apache.camel.component.pojo.PojoInvocation;
+import org.apache.camel.impl.DefaultConsumer;
+
+/**
+ * A {@link Consumer} which uses RMI's {@see UnicastRemoteObject} to consume method invocations.
+ *
+ * @version $Revision: 533758 $
+ */
+public class RmiConsumer extends DefaultConsumer<PojoExchange> implements InvocationHandler {
+
+	private final RmiEndpoint endpoint;
+	private Remote stub;
+	private Remote proxy;
+
+	public RmiConsumer(RmiEndpoint endpoint, Processor<PojoExchange> processor) {
+		super(endpoint, processor);
+		this.endpoint = endpoint;
+		
+	}
+
+	@Override
+	protected void doStart() throws Exception {
+		Class[] interfaces = new Class[endpoint.getRemoteInterfaces().size()];
+		endpoint.getRemoteInterfaces().toArray(interfaces);
+		proxy = (Remote) Proxy.newProxyInstance(endpoint.getClassLoader(), interfaces, this);
+		stub = UnicastRemoteObject.exportObject(proxy,endpoint.getPort());
+		
+        try { 
+    		Registry registry = endpoint.getRegistry();
+        	String name = endpoint.getName();        	
+			registry.bind(name, stub);
+			
+		} catch (Exception e) { // Registration might fail.. clean up..
+			try { 
+				UnicastRemoteObject.unexportObject(stub, true);
+			} catch (Throwable e1) {
+			}
+			stub=null;
+			throw e;
+		}
+        super.doStart();
+	}
+	
+	@Override
+	protected void doStop() throws Exception {
+		super.doStop();
+		try {
+	        Registry registry = endpoint.getRegistry();
+	        registry.unbind(endpoint.getName());
+		} catch( Throwable e ) { // do our best to unregister
+		}
+		UnicastRemoteObject.unexportObject(proxy, true);		
+	}
+	
+	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+        if (!isStarted()) {
+            throw new IllegalStateException("The endpoint is not active: " + getEndpoint().getEndpointUri());
+        }
+        PojoInvocation invocation = new PojoInvocation(proxy, method, args);
+        PojoExchange exchange = getEndpoint().createExchange();
+        exchange.setInvocation(invocation);
+        getProcessor().process(exchange);
+        Throwable fault = exchange.getException();
+        if (fault != null) {
+            throw new InvocationTargetException(fault);
+        }
+        return exchange.getOut().getBody();
+	}
+
+	public Remote getProxy() {
+		return proxy;
+	}
+
+	public Remote getStub() {
+		return stub;
+	}
+}

Added: activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiEndpoint.java?view=auto&rev=534095
==============================================================================
--- activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiEndpoint.java (added)
+++ activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiEndpoint.java Tue May  1 06:57:33 2007
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.rmi;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.pojo.PojoExchange;
+import org.apache.camel.impl.DefaultEndpoint;
+
+/**
+ * @version $Revision:520964 $
+ */
+public class RmiEndpoint extends DefaultEndpoint<PojoExchange> {
+
+	private List<Class> remoteInterfaces;
+	private ClassLoader classLoader;
+	private URI uri;
+	private int port;
+
+	protected RmiEndpoint(String endpointUri, RmiComponent component) throws URISyntaxException {
+		super(endpointUri, component);
+		this.uri = new URI(endpointUri);
+	}
+
+	public boolean isSingleton() {
+		return false;
+	}
+
+	public PojoExchange createExchange() {
+		return new PojoExchange(getContext());
+	}
+
+	public Consumer<PojoExchange> createConsumer(Processor<PojoExchange> processor) throws Exception {
+		if( remoteInterfaces == null || remoteInterfaces.size()==0 )
+			throw new RuntimeCamelException("To create an RMI consumer, the RMI endpoint's remoteInterfaces property must be be configured.");
+		return new RmiConsumer(this, processor);
+	}
+
+	public Producer<PojoExchange> createProducer() throws Exception {
+		return new RmiProducer(this);
+	}
+
+	public String getName() {
+		String path = uri.getPath();
+		if( path == null )
+			path = uri.getSchemeSpecificPart();
+		return path;
+	}
+
+	public Registry getRegistry() throws RemoteException {
+		if( uri.getHost()!=null ) {
+			if( uri.getPort() == -1 ) {
+				return LocateRegistry.getRegistry(uri.getHost());
+			} else {
+				return LocateRegistry.getRegistry(uri.getHost(), uri.getPort());				
+			}
+		} else {
+			return LocateRegistry.getRegistry();
+		}
+	}
+
+	public List<Class> getRemoteInterfaces() {
+		return remoteInterfaces;
+	}
+
+	public void setRemoteInterfaces(List<Class> remoteInterfaces) {
+		this.remoteInterfaces = remoteInterfaces;
+		if( classLoader== null && !remoteInterfaces.isEmpty() ) {
+			classLoader = remoteInterfaces.get(0).getClassLoader();
+		}
+	}
+	public void setRemoteInterfaces(Class... remoteInterfaces) {
+		setRemoteInterfaces(Arrays.asList(remoteInterfaces));		
+	}
+
+	public ClassLoader getClassLoader() {
+		return classLoader;
+	}
+	public void setClassLoader(ClassLoader classLoader) {
+		this.classLoader = classLoader;
+	}
+
+	public int getPort() {
+		return port;
+	}
+
+	public void setPort(int port) {
+		this.port = port;
+	}
+
+
+}

Added: activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiProducer.java?view=auto&rev=534095
==============================================================================
--- activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiProducer.java (added)
+++ activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiProducer.java Tue May  1 06:57:33 2007
@@ -0,0 +1,56 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.rmi;
+
+import java.rmi.AccessException;
+import java.rmi.NotBoundException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.registry.Registry;
+
+import org.apache.camel.component.pojo.PojoEndpoint;
+import org.apache.camel.component.pojo.PojoExchange;
+import org.apache.camel.impl.DefaultProducer;
+
+/**
+ * @version $Revision: 533076 $
+ */
+public class RmiProducer extends DefaultProducer<PojoExchange> {
+
+	private final RmiEndpoint endpoint;
+	private Remote remote;
+
+	public RmiProducer(RmiEndpoint endpoint) throws AccessException, RemoteException, NotBoundException {
+		super(endpoint);
+		this.endpoint = endpoint;
+	}
+
+	public void process(PojoExchange exchange) throws AccessException, RemoteException, NotBoundException {
+		
+		PojoEndpoint.invoke(getRemote(), exchange);
+	}
+
+	public Remote getRemote() throws AccessException, RemoteException, NotBoundException {
+		if( remote == null ) {
+			Registry registry = endpoint.getRegistry();				
+			remote = registry.lookup(endpoint.getName());			
+		}
+		return remote;
+	}
+	
+}

Added: activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/package.html
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/package.html?view=auto&rev=534095
==============================================================================
--- activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/package.html (added)
+++ activemq/camel/trunk/camel-rmi/src/main/java/org/apache/camel/component/rmi/package.html Tue May  1 06:57:33 2007
@@ -0,0 +1,25 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+   
+    http://www.apache.org/licenses/LICENSE-2.0
+   
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<html>
+<head>
+</head>
+<body>
+
+Defines the <a href="http://activemq.apache.org/camel/jms.html">JMS Component</a>
+
+</body>
+</html>

Added: activemq/camel/trunk/camel-rmi/src/main/resources/META-INF/services/org/apache/camel/component/rmi
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-rmi/src/main/resources/META-INF/services/org/apache/camel/component/rmi?view=auto&rev=534095
==============================================================================
--- activemq/camel/trunk/camel-rmi/src/main/resources/META-INF/services/org/apache/camel/component/rmi (added)
+++ activemq/camel/trunk/camel-rmi/src/main/resources/META-INF/services/org/apache/camel/component/rmi Tue May  1 06:57:33 2007
@@ -0,0 +1 @@
+class=org.apache.camel.component.rmi.RmiComponent

Added: activemq/camel/trunk/camel-rmi/src/test/ide-resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-rmi/src/test/ide-resources/log4j.properties?view=auto&rev=534095
==============================================================================
--- activemq/camel/trunk/camel-rmi/src/test/ide-resources/log4j.properties (added)
+++ activemq/camel/trunk/camel-rmi/src/test/ide-resources/log4j.properties Tue May  1 06:57:33 2007
@@ -0,0 +1,30 @@
+## ------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ------------------------------------------------------------------------
+
+#
+# The logging properties used for eclipse testing, We want to see debug output on the console.
+#
+log4j.rootLogger=INFO, out
+
+#log4j.logger.org.apache.activemq=DEBUG
+log4j.logger.org.apache.camel=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n

Added: activemq/camel/trunk/camel-rmi/src/test/java/org/apache/camel/component/rmi/ISay.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-rmi/src/test/java/org/apache/camel/component/rmi/ISay.java?view=auto&rev=534095
==============================================================================
--- activemq/camel/trunk/camel-rmi/src/test/java/org/apache/camel/component/rmi/ISay.java (added)
+++ activemq/camel/trunk/camel-rmi/src/test/java/org/apache/camel/component/rmi/ISay.java Tue May  1 06:57:33 2007
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.rmi;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+public interface ISay extends Remote {
+	public String say() throws RemoteException;
+}

Added: activemq/camel/trunk/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiRouteTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiRouteTest.java?view=auto&rev=534095
==============================================================================
--- activemq/camel/trunk/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiRouteTest.java (added)
+++ activemq/camel/trunk/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiRouteTest.java Tue May  1 06:57:33 2007
@@ -0,0 +1,98 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.rmi;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.rmi.registry.LocateRegistry;
+
+import junit.framework.TestCase;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.pojo.PojoComponent;
+import org.apache.camel.component.pojo.PojoConsumer;
+import org.apache.camel.impl.DefaultCamelContext;
+
+/**
+ * @version $Revision: 520220 $
+ */
+public class RmiRouteTest extends TestCase {
+	
+    public void testPojoRoutes() throws Exception {    	
+    	if( classPathHasSpaces() ) {
+    		return;
+    	}
+    	
+    	// Boot up a local RMI registry
+    	LocateRegistry.createRegistry(1099);    	
+    	
+        CamelContext camelContext = new DefaultCamelContext();
+        
+        // START SNIPPET: register
+        PojoComponent component = new PojoComponent();
+        camelContext.addComponent("pojo", component);
+        component.addService("bye", new SayService("Good Bye!"));
+        // END SNIPPET: register
+        
+        // START SNIPPET: route
+        // lets add simple route
+        camelContext.addRoutes(new RouteBuilder() {
+            public void configure() {
+            	from("pojo:hello").to("rmi://localhost:1099/bye");                
+
+            	// When exposing an RMI endpoint, the interfaces it exposes must be configured.
+                RmiEndpoint bye = (RmiEndpoint) endpoint("rmi://localhost:1099/bye");
+            	bye.setRemoteInterfaces(ISay.class);
+                from(bye).to("pojo:bye");
+            }
+        });
+        // END SNIPPET: route
+
+        camelContext.start();
+        
+        // START SNIPPET: invoke
+        PojoConsumer consumer = component.getConsumer("hello");        
+        ISay proxy = consumer.createProxy(ISay.class);
+        String rc = proxy.say();
+        assertEquals("Good Bye!", rc);
+        // END SNIPPET: invoke
+        
+        camelContext.stop();
+    }
+
+	private boolean classPathHasSpaces() {		
+		ClassLoader cl = getClass().getClassLoader();
+		if( cl instanceof URLClassLoader ) {
+			URLClassLoader ucl = (URLClassLoader) cl;
+			URL[] urls = ucl.getURLs();
+			for (int i = 0; i < urls.length; i++) {
+				if( urls[i].getPath().contains(" ") ) {
+					System.err.println("=======================================================================");
+					System.err.println(" TEST Skipped: "+getName());
+					System.err.println("   Your probably on windows.  We detected that the classpath");
+					System.err.println("   has a space in it.  Try running maven with the following option: ");
+					System.err.println("   -Dmaven.repo.local=C:\\DOCUME~1\\userid\\.m2\\repository");
+					System.err.println("=======================================================================");
+					return true;
+				}
+			}
+		}
+		return false;
+	}
+}

Added: activemq/camel/trunk/camel-rmi/src/test/java/org/apache/camel/component/rmi/SayService.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-rmi/src/test/java/org/apache/camel/component/rmi/SayService.java?view=auto&rev=534095
==============================================================================
--- activemq/camel/trunk/camel-rmi/src/test/java/org/apache/camel/component/rmi/SayService.java (added)
+++ activemq/camel/trunk/camel-rmi/src/test/java/org/apache/camel/component/rmi/SayService.java Tue May  1 06:57:33 2007
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.rmi;
+
+public class SayService implements ISay {
+	String message = "Hello";
+	
+	public SayService() {
+	}
+	public SayService(String message) {
+		this.message = message;
+	}
+
+	public String say() {
+		return message;
+	}
+
+	public String getMessage() {
+		return message;
+	}
+
+	public void setMessage(String message) {
+		this.message = message;
+	}
+
+}

Added: activemq/camel/trunk/camel-rmi/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-rmi/src/test/resources/log4j.properties?view=auto&rev=534095
==============================================================================
--- activemq/camel/trunk/camel-rmi/src/test/resources/log4j.properties (added)
+++ activemq/camel/trunk/camel-rmi/src/test/resources/log4j.properties Tue May  1 06:57:33 2007
@@ -0,0 +1,30 @@
+## ------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ------------------------------------------------------------------------
+
+#
+# The logging properties used for eclipse testing, We want to see debug output on the console.
+#
+log4j.rootLogger=INFO, out
+
+#log4j.logger.org.apache.activemq=DEBUG
+#log4j.logger.org.apache.camel=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n

Modified: activemq/camel/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/pom.xml?view=diff&rev=534095&r1=534094&r2=534095
==============================================================================
--- activemq/camel/trunk/pom.xml (original)
+++ activemq/camel/trunk/pom.xml Tue May  1 06:57:33 2007
@@ -129,6 +129,7 @@
     <module>camel-jpa</module>
     <module>camel-mail</module>
     <module>camel-mina</module>
+    <module>camel-rmi</module>
     <module>camel-saxon</module>
     <module>camel-script</module>
     <module>camel-spring</module>