Author: jbonofre
Date: Sun Aug 2 05:37:56 2009
New Revision: 799996
URL: http://svn.apache.org/viewvc?rev=799996&view=rev
Log:
Resume the RMI provider endpoint.
Add POJO support in the RMI consumer endpoint (will be used in replacement of
the bridge endpoint).
Modified:
servicemix/components/bindings/servicemix-rmi/trunk/src/main/java/org/apache/servicemix/rmi/RmiConsumerEndpoint.java
servicemix/components/bindings/servicemix-rmi/trunk/src/main/java/org/apache/servicemix/rmi/RmiProviderEndpoint.java
Modified:
servicemix/components/bindings/servicemix-rmi/trunk/src/main/java/org/apache/servicemix/rmi/RmiConsumerEndpoint.java
URL:
http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-rmi/trunk/src/main/java/org/apache/servicemix/rmi/RmiConsumerEndpoint.java?rev=799996&r1=799995&r2=799996&view=diff
==============================================================================
---
servicemix/components/bindings/servicemix-rmi/trunk/src/main/java/org/apache/servicemix/rmi/RmiConsumerEndpoint.java
(original)
+++
servicemix/components/bindings/servicemix-rmi/trunk/src/main/java/org/apache/servicemix/rmi/RmiConsumerEndpoint.java
Sun Aug 2 05:37:56 2009
@@ -45,6 +45,7 @@
private List<Class> remoteInterfaces; // the remote interfaces
private int port = 1099; // the RMI registry port number
private String name; // the endpoint name into the RMI registry
+ private Object pojo; // delegate method call to a POJO
private Registry registry = null; // the RMI registry
private Remote stub; // the remote stub
@@ -115,10 +116,16 @@
* @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object,
java.lang.reflect.Method, java.lang.Object[])
*/
public Object invoke(Object proxy, Method method, Object[] args) throws
Throwable {
- // TODO transform RMI request into NMR message using a marshaler
logger.debug("Proxy: " + proxy);
logger.debug("Method: " + method);
logger.debug("Args: " + args);
+ if (pojo != null) {
+ // bypass to POJO delegation
+ method.invoke(pojo, args);
+ } else {
+ // going through the NMR
+ // TODO use a marshaler
+ }
return null;
}
Modified:
servicemix/components/bindings/servicemix-rmi/trunk/src/main/java/org/apache/servicemix/rmi/RmiProviderEndpoint.java
URL:
http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-rmi/trunk/src/main/java/org/apache/servicemix/rmi/RmiProviderEndpoint.java?rev=799996&r1=799995&r2=799996&view=diff
==============================================================================
---
servicemix/components/bindings/servicemix-rmi/trunk/src/main/java/org/apache/servicemix/rmi/RmiProviderEndpoint.java
(original)
+++
servicemix/components/bindings/servicemix-rmi/trunk/src/main/java/org/apache/servicemix/rmi/RmiProviderEndpoint.java
Sun Aug 2 05:37:56 2009
@@ -16,14 +16,17 @@
*/
package org.apache.servicemix.rmi;
+import java.lang.reflect.Method;
import java.rmi.Remote;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import javax.jbi.management.DeploymentException;
+import javax.jbi.messaging.ExchangeStatus;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessagingException;
import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.namespace.QName;
import javax.xml.transform.TransformerException;
import org.apache.servicemix.common.endpoints.ProviderEndpoint;
@@ -128,7 +131,26 @@
* @throws MessagingException on messaging errors,
*/
private void process(MessageExchange exchange, NormalizedMessage in)
throws TransformerException, MessagingException {
- // TODO parse the in message (using a marshaler and transform it in
RMI call
+ if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
+ return;
+ }
+
+ // get the called method using the exchange operation
+ QName operationName = exchange.getOperation();
+ if (operationName == null) {
+ // TODO try to define a default operation to use
+ throw new MessagingException("The exchange operation is not set.");
+ }
+
+ // get the method call using the operation name
+ try {
+ // TODO correct the method detection (parameter types)
+ Method method =
stub.getClass().getMethod(operationName.toString(), null);
+ Object result = method.invoke(stub, null);
+ // TODO contruct the out normalized message using the object
+ } catch (Exception e) {
+ throw new MessagingException("RMI call failed.", e);
+ }
}