You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2007/05/09 23:53:12 UTC
svn commit: r536673 -
/incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingProvider.java
Author: antelder
Date: Wed May 9 14:53:12 2007
New Revision: 536673
URL: http://svn.apache.org/viewvc?view=rev&rev=536673
Log:
Change RMI binding for new SPI invoker method
Modified:
incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingProvider.java
Modified: incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingProvider.java?view=diff&rev=536673&r1=536672&r2=536673
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingProvider.java (original)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingProvider.java Wed May 9 14:53:12 2007
@@ -33,13 +33,11 @@
import org.apache.tuscany.core.RuntimeComponent;
import org.apache.tuscany.core.RuntimeComponentReference;
import org.apache.tuscany.core.RuntimeComponentService;
-import org.apache.tuscany.core.RuntimeWire;
import org.apache.tuscany.interfacedef.Interface;
import org.apache.tuscany.interfacedef.InterfaceContract;
import org.apache.tuscany.interfacedef.Operation;
import org.apache.tuscany.interfacedef.java.JavaInterface;
import org.apache.tuscany.interfacedef.java.impl.JavaInterfaceUtil;
-import org.apache.tuscany.invocation.InvocationChain;
import org.apache.tuscany.invocation.Invoker;
import org.apache.tuscany.invocation.Message;
import org.apache.tuscany.invocation.MessageImpl;
@@ -47,15 +45,10 @@
import org.apache.tuscany.provider.ServiceBindingProvider;
import org.apache.tuscany.rmi.RMIHost;
import org.apache.tuscany.rmi.RMIHostException;
-import org.apache.tuscany.spi.component.WorkContext;
import org.apache.tuscany.spi.component.WorkContextTunnel;
-
/**
- *
* RMIBindingProvider
- *
- * @version $Rev: $ $Date: $
*/
public class RMIBindingProvider implements ReferenceBindingProvider<RMIBinding>,
ServiceBindingProvider<RMIBinding>, MethodInterceptor {
@@ -65,7 +58,6 @@
private RuntimeComponentReference reference;
private RMIBinding binding;
private RMIHost rmiHost;
- private RuntimeWire wire;
//need this member to morph the service interface to extend from Remote if it does not
// the base class's member variable interfaze is to be maintained to enable the connection
@@ -99,8 +91,6 @@
URI uri = URI.create(component.getURI() + "/" + binding.getName());
binding.setURI(uri.toString());
- //TODO : Need to figure out why we do a get(0)... will this work always...
- this.wire = service.getRuntimeWires().get(0);
this.serviceInterface = service.getInterfaceContract().getInterface();
Remote rmiProxy = createRmiService();
@@ -194,40 +184,22 @@
// since incoming method signatures have 'remotemethod invocation' it will not match with the
// wired component's method signatures. Hence need to pull in the corresponding method from the
// component's service contract interface to make this invocation.
-
-
+
return invokeTarget(JavaInterfaceUtil.findOperation(method, serviceInterface.getOperations()),
args);
}
- public Object invokeTarget(Operation op,
- Object[] args) throws InvocationTargetException {
- InvocationChain chain = null;
-
- for (InvocationChain ic : wire.getInvocationChains()) {
- if (ic.getSourceOperation().equals(op)) {
- chain = ic;
- }
- }
- if (chain == null) {
- throw new IllegalStateException("no InvocationChain on wire for operation " + op);
- }
-
- Invoker headInvoker = chain.getHeadInvoker();
- WorkContext workContext = WorkContextTunnel.getThreadWorkContext();
-
- Message msg = new MessageImpl();
- msg.setBody(args);
- msg.setWorkContext(workContext);
-
- Message resp;
- // dispatch the wire down the chain and get the response
- resp = headInvoker.invoke(msg);
- Object body = resp.getBody();
- if (resp.isFault()) {
- throw new InvocationTargetException((Throwable) body);
+ public Object invokeTarget(Operation op, Object[] args) throws InvocationTargetException {
+ Message requestMsg = new MessageImpl();
+ requestMsg.setWorkContext(WorkContextTunnel.getThreadWorkContext());
+ requestMsg.setBody(args);
+
+ Message responseMsg = service.getInvoker(binding, op).invoke(requestMsg);
+
+ if (responseMsg.isFault()) {
+ throw new InvocationTargetException((Throwable)responseMsg.getBody());
}
- return body;
+ return responseMsg.getBody();
}
protected int getPort(String port) {
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org