diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2012-08-16 14:37:51 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2012-08-16 14:37:51 +0000 |
commit | 9ea7e9a5cd01ce64222a930a9f66bb622deb2ce0 (patch) | |
tree | bb044d3ca707e9d901be8659298e27999ddb6ab1 /sca-java-2.x/trunk/modules/domain-node/src/main | |
parent | 7ae19091161e7ef5f87806d55b1fce5057a7a7c5 (diff) |
Update to support DOMInvoker with remote endpoints
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1373865 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/domain-node/src/main')
-rw-r--r-- | sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/ServiceHelper.java | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/ServiceHelper.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/ServiceHelper.java index 274b15d063..47bee4fa65 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/ServiceHelper.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/ServiceHelper.java @@ -35,15 +35,19 @@ import org.apache.tuscany.sca.assembly.Service; import org.apache.tuscany.sca.context.CompositeContext;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointReferenceImpl;
import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
import org.apache.tuscany.sca.core.invocation.ProxyFactory;
import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.invocation.impl.AsyncJDKInvocationHandler;
+import org.apache.tuscany.sca.core.invocation.impl.DOMInvokerImpl;
import org.apache.tuscany.sca.deployment.Deployer;
import org.apache.tuscany.sca.interfacedef.Interface;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.invocation.MessageFactory;
import org.apache.tuscany.sca.runtime.ContributionDescription;
import org.apache.tuscany.sca.runtime.DOMInvoker;
import org.apache.tuscany.sca.runtime.DomainRegistry;
@@ -54,6 +58,7 @@ import org.apache.tuscany.sca.runtime.TuscanyServiceReference; import org.oasisopen.sca.NoSuchServiceException;
import org.oasisopen.sca.ServiceRuntimeException;
import org.oasisopen.sca.annotation.Remotable;
+import org.w3c.dom.Node;
/**
* TODO: Merge this into sca-client RemoteServiceInvocationHandler
@@ -106,8 +111,8 @@ public class ServiceHelper { if (((RuntimeComponent)ep.getComponent()).getComponentContext() != null) {
return ((TuscanyServiceReference<?>)((RuntimeComponent)ep.getComponent()).getServiceReference(null, serviceName)).getDOMInvoker();
} else {
- throw new NoSuchServiceException(serviceURI);
-// return getRemoteProxy(interfaze, ep, domainRegistry, extensionPointRegistry, deployer);
+// throw new NoSuchServiceException(serviceURI);
+ return getRemoteDOMInvoker(ep, domainRegistry, extensionPointRegistry, deployer);
}
}
@@ -145,6 +150,44 @@ public class ServiceHelper { return proxyFactory.createProxy(serviceInterface, epr);
}
+ private static DOMInvoker getRemoteDOMInvoker(Endpoint endpoint, DomainRegistry domainRegistry, ExtensionPointRegistry extensionPointRegistry, Deployer deployer) throws NoSuchServiceException {
+ FactoryExtensionPoint factories = extensionPointRegistry.getExtensionPoint(FactoryExtensionPoint.class);
+ AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ JavaInterfaceFactory javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
+ ProxyFactory proxyFactory =
+ new ExtensibleProxyFactory(extensionPointRegistry.getExtensionPoint(ProxyFactoryExtensionPoint.class));
+
+ CompositeContext compositeContext =
+ new CompositeContext(extensionPointRegistry, domainRegistry, null, null, null,
+ deployer.getSystemDefinitions());
+
+ RuntimeEndpointReference epr;
+ try {
+ epr =
+ createEndpointReference(javaInterfaceFactory,
+ compositeContext,
+ assemblyFactory,
+ endpoint,
+ null);
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+
+ InterfaceContract ic;
+ try {
+ ic = (InterfaceContract)epr.getGeneratedWSDLContract(epr.getBindingInterfaceContract()).clone();
+ } catch (CloneNotSupportedException e) {
+ throw new RuntimeException(e);
+ }
+ ic.getInterface().resetDataBinding(Node.class.getName());
+
+ ((RuntimeEndpointReferenceImpl)epr).setreferenceInterfaceContract(ic);
+ epr.rebuild();
+
+ AsyncJDKInvocationHandler handler = new AsyncJDKInvocationHandler(extensionPointRegistry, factories.getFactory(MessageFactory.class), null, epr);
+ return new DOMInvokerImpl(handler);
+ }
+
private static RuntimeEndpointReference createEndpointReference(JavaInterfaceFactory javaInterfaceFactory,
CompositeContext compositeContext,
AssemblyFactory assemblyFactory,
|