diff options
139 files changed, 2226 insertions, 3425 deletions
diff --git a/java/sca/itest/jms/exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java b/java/sca/itest/jms/exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java index 1e1a0987ad..a1a6c4aae0 100644 --- a/java/sca/itest/jms/exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java +++ b/java/sca/itest/jms/exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java @@ -105,7 +105,7 @@ public class ExceptionsTestCase { Object o = ((ObjectMessage)m).getObject();
assertTrue(o instanceof RuntimeException);
assertTrue("java.lang.RuntimeException".equals(o.getClass().getName()));
- assertEquals("java.lang.RuntimeException: bla", ((RuntimeException)o).getMessage());
+ assertEquals("bla", ((RuntimeException)o).getMessage());
}
@Test
@@ -151,7 +151,7 @@ public class ExceptionsTestCase { Object o = ((ObjectMessage)m).getObject();
assertTrue(o instanceof RuntimeException);
assertTrue("java.lang.RuntimeException".equals(o.getClass().getName()));
- assertEquals("java.lang.RuntimeException: bla", ((RuntimeException)o).getMessage());
+ assertEquals("bla", ((RuntimeException)o).getMessage());
}
@After
diff --git a/java/sca/itest/jms/exceptions1/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java b/java/sca/itest/jms/exceptions1/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java index 170e28b15d..0d897d8703 100644 --- a/java/sca/itest/jms/exceptions1/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java +++ b/java/sca/itest/jms/exceptions1/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java @@ -97,7 +97,7 @@ public class ExceptionsTestCase { service.throwUnChecked();
fail();
} catch (Exception e) {
- assertEquals("java.lang.RuntimeException: bla", e.getCause().getMessage());
+ assertEquals("bla", e.getCause().getMessage());
}
}
diff --git a/java/sca/itest/jms/format-jmsobject/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSObjectTestCase.java b/java/sca/itest/jms/format-jmsobject/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSObjectTestCase.java index c9609119c9..a2bfc0ca8a 100644 --- a/java/sca/itest/jms/format-jmsobject/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSObjectTestCase.java +++ b/java/sca/itest/jms/format-jmsobject/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSObjectTestCase.java @@ -48,7 +48,7 @@ public class FormatJMSObjectTestCase { assertEquals("Hello1 Fred Hello1 Bloggs Hello2 null Hello3 Fred Hello4 Fred Bloggs Hello5 Fred Bloggs Hello6 Fred Bloggs Hello7 Fred Bloggs",
helloWorldService.getGreetingsWrapSingle("Fred", "Bloggs"));
- assertEquals("Hello1 Fred Hello1 Bloggs Hello2 null Hello3 Fred Hello4 Fred Bloggs Hello5 Fred Bloggs Hello6 Fred Bloggs Hello7 Fred Bloggs foo java.lang.RuntimeException: bla",
+ assertEquals("Hello1 Fred Hello1 Bloggs Hello2 null Hello3 Fred Hello4 Fred Bloggs Hello5 Fred Bloggs Hello6 Fred Bloggs Hello7 Fred Bloggs foo bla",
helloWorldService.getGreetingsDontWrapSingle("Fred", "Bloggs"));
}
diff --git a/java/sca/itest/properties/src/main/resources/ConstructorPropertyInjection.composite b/java/sca/itest/properties/src/main/resources/ConstructorPropertyInjection.composite index af65f887c0..7e3b2b35f0 100644 --- a/java/sca/itest/properties/src/main/resources/ConstructorPropertyInjection.composite +++ b/java/sca/itest/properties/src/main/resources/ConstructorPropertyInjection.composite @@ -17,7 +17,7 @@ * specific language governing permissions and limitations * under the License. --> -<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" name="ConstructorPropertyInjection"> +<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" targetNamespace="http://foo" name="ConstructorPropertyInjection"> <component name="Foo1Component"> <implementation.java class="org.apache.tuscany.sca.itest.cdi.Foo1" /> diff --git a/java/sca/itest/properties/src/main/resources/OuterPropertyTest.composite b/java/sca/itest/properties/src/main/resources/OuterPropertyTest.composite index 95ee1157bf..fd181bfcaa 100644 --- a/java/sca/itest/properties/src/main/resources/OuterPropertyTest.composite +++ b/java/sca/itest/properties/src/main/resources/OuterPropertyTest.composite @@ -26,7 +26,7 @@ <implementation.composite name="foo:PropertyTest" />
<property name="number">125</property>
<property name="complex" type="foo:MyComplexType">
- <foo:MyComplexValue xsi:type="foo:MyComplexType">
+ <value xsi:type="foo:MyComplexType">
<foo:a>Overriden A</foo:a>
<foo:b>Overriden B</foo:b>
<foo:c>Overriden C</foo:c>
@@ -35,7 +35,7 @@ <foo:y>Overriden Y</foo:y>
<foo:z>Overriden Z</foo:z>
</foo:x>
- </foo:MyComplexValue>
+ </value>
</property>
</component>
</composite>
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java index 59ab8d36fc..b682c2870e 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java @@ -21,7 +21,6 @@ package org.apache.tuscany.sca.assembly; import java.io.Serializable; import java.util.List; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.policy.PolicySubject; @@ -113,14 +112,6 @@ public interface Endpoint extends Base, PolicySubject, Cloneable, Serializable { List<EndpointReference> getCallbackEndpointReferences(); /** - * Set the extension point registry against the endpoint after it is deserialized as - * the registry needs to be re-attached - * - * @param registry - */ - void setExtensionPointRegistry(ExtensionPointRegistry registry); - - /** * Returns true if this endpoint represents a serivce that is not * running in this JVM * @@ -143,4 +134,11 @@ public interface Endpoint extends Base, PolicySubject, Cloneable, Serializable { * @throws CloneNotSupportedException */ Object clone() throws CloneNotSupportedException; + + /* + String getDomainURI(); + String getNodeURI(); + void setDomainURI(String domainURI); + void setNodeURI(String nodeURI); + */ } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java index 7b547e70de..a3e4ef133d 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java @@ -20,7 +20,6 @@ package org.apache.tuscany.sca.assembly; import java.io.Serializable; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.policy.PolicySubject; @@ -164,14 +163,6 @@ public interface EndpointReference extends Base, PolicySubject, Cloneable, Seria void setRemote(boolean remote); /** - * Set the extension point registry against the endpoint after it is deserialized as - * the registry needs to be re-attached - * - * @param registry - */ - void setExtensionPointRegistry(ExtensionPointRegistry registry); - - /** * Rather than relying on combinations of unresolved flags and * other data we maintain a status enumeration * diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java index 4b1d9e437d..a22b70f609 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java @@ -188,7 +188,7 @@ public class EndpointImpl implements Endpoint { this.uri = null; } - public void setExtensionPointRegistry(ExtensionPointRegistry registry) { + protected void setExtensionPointRegistry(ExtensionPointRegistry registry) { this.registry = registry; } diff --git a/java/sca/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java b/java/sca/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java index 5ba07f5e22..523b6237e2 100644 --- a/java/sca/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java +++ b/java/sca/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java @@ -61,7 +61,7 @@ import org.apache.tuscany.sca.invocation.InvocationChain; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; import org.apache.tuscany.sca.invocation.MessageFactory; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.Invocable; /** * A resource collection binding listener, implemented as a Servlet and @@ -81,7 +81,7 @@ class AtomBindingListenerServlet extends HttpServlet { private static final String CONTENTLOCATION = "Content-Location"; private static final SimpleDateFormat dateFormat = new SimpleDateFormat( "EEE, dd MMM yyyy HH:mm:ss Z" ); // RFC 822 date time - private RuntimeWire wire; + private Invocable wire; private Invoker getFeedInvoker; private Invoker getAllInvoker; private Invoker queryInvoker; @@ -106,7 +106,7 @@ class AtomBindingListenerServlet extends HttpServlet { * @param messageFactory * @param feedType */ - AtomBindingListenerServlet(RuntimeWire wire, MessageFactory messageFactory, Mediator mediator, String title, String description) { + AtomBindingListenerServlet(Invocable wire, MessageFactory messageFactory, Mediator mediator, String title, String description) { this.wire = wire; this.messageFactory = messageFactory; this.mediator = mediator; diff --git a/java/sca/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingProviderFactory.java b/java/sca/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingProviderFactory.java index 6196a727ac..f8c6d8b3a5 100644 --- a/java/sca/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingProviderFactory.java +++ b/java/sca/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingProviderFactory.java @@ -19,8 +19,6 @@ package org.apache.tuscany.sca.binding.atom.provider; -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.binding.atom.AtomBinding; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.FactoryExtensionPoint; @@ -32,6 +30,8 @@ import org.apache.tuscany.sca.invocation.MessageFactory; import org.apache.tuscany.sca.provider.BindingProviderFactory; import org.apache.tuscany.sca.provider.ReferenceBindingProvider; import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * Implementation of a Binding provider factory for the Atom binding. @@ -52,11 +52,11 @@ public class AtomBindingProviderFactory implements BindingProviderFactory<AtomBi this.mediator = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class).getUtility(Mediator.class); } - public ReferenceBindingProvider createReferenceBindingProvider(EndpointReference endpointReference) { + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) { return new AtomReferenceBindingProvider(endpointReference, mediator); } - public ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint) { + public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) { return new AtomServiceBindingProvider(endpoint, messageFactory, mediator, servletHost); } diff --git a/java/sca/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomServiceBindingProvider.java b/java/sca/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomServiceBindingProvider.java index 697a6140da..d7d2b083db 100644 --- a/java/sca/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomServiceBindingProvider.java +++ b/java/sca/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomServiceBindingProvider.java @@ -19,18 +19,16 @@ package org.apache.tuscany.sca.binding.atom.provider; -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.Service; import org.apache.tuscany.sca.binding.atom.AtomBinding; import org.apache.tuscany.sca.databinding.Mediator; import org.apache.tuscany.sca.host.http.ServletHost; import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract; import org.apache.tuscany.sca.invocation.MessageFactory; import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.Invocable; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; /** * Implementation of the Atom binding provider. @@ -40,7 +38,7 @@ import org.apache.tuscany.sca.runtime.RuntimeWire; class AtomServiceBindingProvider implements ServiceBindingProvider { private MessageFactory messageFactory; - private Endpoint endpoint; + private RuntimeEndpoint endpoint; private RuntimeComponent component; private RuntimeComponentService service; @@ -52,7 +50,7 @@ class AtomServiceBindingProvider implements ServiceBindingProvider { private String servletMapping; private String bindingURI; - AtomServiceBindingProvider(Endpoint endpoint, + AtomServiceBindingProvider(RuntimeEndpoint endpoint, MessageFactory messageFactory, Mediator mediator, ServletHost servletHost) { @@ -66,16 +64,7 @@ class AtomServiceBindingProvider implements ServiceBindingProvider { this.mediator = mediator; // TUSCANY-3166 - this.serviceContract = service.getInterfaceContract(); - if (this.serviceContract instanceof WSDLInterfaceContract) { - for (Service componentService : component.getImplementation().getServices()) { - if (componentService.getName().equals(service.getName())) { - this.serviceContract = (InterfaceContract) componentService.getInterfaceContract(); - break; - } - } - - } + this.serviceContract = endpoint.getServiceInterfaceContract(); } public InterfaceContract getBindingInterfaceContract() { @@ -87,8 +76,7 @@ class AtomServiceBindingProvider implements ServiceBindingProvider { } public void start() { - RuntimeComponentService componentService = (RuntimeComponentService)service; - RuntimeWire wire = componentService.getRuntimeWire(binding); + Invocable wire = (RuntimeEndpoint) endpoint; AtomBindingListenerServlet servlet = new AtomBindingListenerServlet(wire, messageFactory, mediator, binding.getTitle(), binding.getDescription()); diff --git a/java/sca/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingProviderFactory.java b/java/sca/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingProviderFactory.java index f2647bdd2e..e94ac8bce1 100644 --- a/java/sca/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingProviderFactory.java +++ b/java/sca/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingProviderFactory.java @@ -18,8 +18,6 @@ */ package org.apache.tuscany.sca.binding.ejb.provider; -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.binding.ejb.EJBBinding; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.provider.BindingProviderFactory; @@ -27,6 +25,8 @@ import org.apache.tuscany.sca.provider.ReferenceBindingProvider; import org.apache.tuscany.sca.provider.ServiceBindingProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * A factory from creating the EJB binding provider. @@ -39,13 +39,13 @@ public class EJBBindingProviderFactory implements BindingProviderFactory<EJBBind // empty constructor } - public ReferenceBindingProvider createReferenceBindingProvider(EndpointReference endpointReference) { + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) { return new EJBBindingReferenceBindingProvider((RuntimeComponent)endpointReference.getComponent(), (RuntimeComponentReference)endpointReference.getReference(), (EJBBinding)endpointReference.getBinding()); } - public ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint) { + public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) { // Service Binding not supported for EJB Binding return null; } diff --git a/java/sca/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingProviderFactory.java b/java/sca/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingProviderFactory.java index 53383af35e..ae1725a3e6 100644 --- a/java/sca/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingProviderFactory.java +++ b/java/sca/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingProviderFactory.java @@ -19,8 +19,6 @@ package org.apache.tuscany.sca.binding.http.provider; -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.binding.http.HTTPBinding; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.FactoryExtensionPoint; @@ -30,6 +28,8 @@ import org.apache.tuscany.sca.invocation.MessageFactory; import org.apache.tuscany.sca.provider.BindingProviderFactory; import org.apache.tuscany.sca.provider.ReferenceBindingProvider; import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** @@ -50,12 +50,12 @@ public class HTTPBindingProviderFactory implements BindingProviderFactory<HTTPBi messageFactory = modelFactories.getFactory(MessageFactory.class); } - public ReferenceBindingProvider createReferenceBindingProvider(EndpointReference endpointReference) { + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) { // Binding HTTP is currently NOT supporting References return null; } - public ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint) { + public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) { return new HTTPServiceBindingProvider(endpoint, extensionPoints, messageFactory, servletHost); } diff --git a/java/sca/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java b/java/sca/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java index 8342dd64c8..6b6bb66914 100644 --- a/java/sca/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java +++ b/java/sca/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java @@ -21,7 +21,6 @@ package org.apache.tuscany.sca.binding.http.provider; import javax.servlet.Servlet; -import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.binding.http.HTTPBinding; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.host.http.ServletHost; @@ -31,25 +30,25 @@ import org.apache.tuscany.sca.invocation.InvocationChain; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.MessageFactory; import org.apache.tuscany.sca.invocation.Phase; +import org.apache.tuscany.sca.provider.EndpointProvider; import org.apache.tuscany.sca.provider.OperationSelectorProvider; import org.apache.tuscany.sca.provider.OperationSelectorProviderFactory; import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint; -import org.apache.tuscany.sca.provider.ServiceBindingProviderRRB; import org.apache.tuscany.sca.provider.WireFormatProvider; import org.apache.tuscany.sca.provider.WireFormatProviderFactory; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; /** * Implementation of an HTTP binding provider. * * @version $Rev$ $Date$ */ -public class HTTPServiceBindingProvider implements ServiceBindingProviderRRB { +public class HTTPServiceBindingProvider implements EndpointProvider { private ExtensionPointRegistry extensionPoints; - private Endpoint endpoint; + private RuntimeEndpoint endpoint; private RuntimeComponent component; private RuntimeComponentService service; private InterfaceContract serviceContract; @@ -63,7 +62,7 @@ public class HTTPServiceBindingProvider implements ServiceBindingProviderRRB { private String servletMapping; private HTTPBindingListenerServlet bindingListenerServlet; - public HTTPServiceBindingProvider(Endpoint endpoint, + public HTTPServiceBindingProvider(RuntimeEndpoint endpoint, ExtensionPointRegistry extensionPoints, MessageFactory messageFactory, ServletHost servletHost) { @@ -86,7 +85,7 @@ public class HTTPServiceBindingProvider implements ServiceBindingProviderRRB { // Configure the interceptors for operation selection OperationSelectorProviderFactory osProviderFactory = (OperationSelectorProviderFactory) providerFactories.getProviderFactory(binding.getOperationSelector().getClass()); if (osProviderFactory != null) { - this.osProvider = osProviderFactory.createServiceOperationSelectorProvider(component, service, binding); + this.osProvider = osProviderFactory.createServiceOperationSelectorProvider(endpoint); } } @@ -94,7 +93,7 @@ public class HTTPServiceBindingProvider implements ServiceBindingProviderRRB { // Configure the interceptors for wire format WireFormatProviderFactory wfProviderFactory = (WireFormatProviderFactory) providerFactories.getProviderFactory(binding.getRequestWireFormat().getClass()); if (wfProviderFactory != null) { - this.wfProvider = wfProviderFactory.createServiceWireFormatProvider(component, service, binding); + this.wfProvider = wfProviderFactory.createServiceWireFormatProvider(endpoint); } } @@ -116,11 +115,9 @@ public class HTTPServiceBindingProvider implements ServiceBindingProviderRRB { public void start() { // Get the invokers for the supported operations - RuntimeComponentService componentService = (RuntimeComponentService) service; - RuntimeWire wire = componentService.getRuntimeWire(binding); Servlet servlet = null; bindingListenerServlet = new HTTPBindingListenerServlet(binding, messageFactory ); - for (InvocationChain invocationChain : wire.getInvocationChains()) { + for (InvocationChain invocationChain : endpoint.getInvocationChains()) { Operation operation = invocationChain.getTargetOperation(); String operationName = operation.getName(); if (operationName.equals("get")) { @@ -195,9 +192,9 @@ public class HTTPServiceBindingProvider implements ServiceBindingProviderRRB { * Add specific http interceptor to invocation chain * @param runtimeWire */ - public void configureBindingChain(RuntimeWire runtimeWire) { + public void configure() { - InvocationChain bindingChain = runtimeWire.getBindingInvocationChain(); + InvocationChain bindingChain = endpoint.getBindingInvocationChain(); if(osProvider != null) { bindingChain.addInterceptor(Phase.SERVICE_BINDING_OPERATION_SELECTOR, osProvider.createInterceptor()); diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderReferenceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderReferenceInterceptor.java index 6edd555c4b..b067b6ed12 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderReferenceInterceptor.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderReferenceInterceptor.java @@ -40,9 +40,8 @@ import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * @@ -51,7 +50,7 @@ import org.apache.tuscany.sca.runtime.RuntimeWire; public class HeaderReferenceInterceptor implements Interceptor { private Invoker next; - private RuntimeWire runtimeWire; + private RuntimeEndpointReference runtimeWire; private JMSResourceFactory jmsResourceFactory; private JMSBinding jmsBinding; private JMSMessageProcessor requestMessageProcessor; @@ -60,7 +59,7 @@ public class HeaderReferenceInterceptor implements Interceptor { private WireFormat requestWireFormat; private WireFormat responseWireFormat; - public HeaderReferenceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire, ExtensionPointRegistry extensions) { + public HeaderReferenceInterceptor(ExtensionPointRegistry extensions, JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeEndpointReference runtimeWire) { super(); this.jmsBinding = jmsBinding; this.runtimeWire = runtimeWire; @@ -85,7 +84,7 @@ public class HeaderReferenceInterceptor implements Interceptor { Operation operation = tuscanyMsg.getOperation(); String operationName = operation.getName(); - RuntimeComponentReference reference = (RuntimeComponentReference)runtimeWire.getEndpointReference().getReference(); + RuntimeEndpointReference reference = runtimeWire; // I think the OASIS spec suggests we do not need to do anything with // @nativeOperation here on the reference side. @@ -145,11 +144,10 @@ public class HeaderReferenceInterceptor implements Interceptor { } - protected String getCallbackDestinationName(RuntimeComponentReference reference) { - RuntimeComponentService s = (RuntimeComponentService)reference.getCallbackService(); - JMSBinding b = s.getBinding(JMSBinding.class); - if (b != null) { - JMSBindingServiceBindingProvider bp = (JMSBindingServiceBindingProvider)s.getBindingProvider(b); + protected String getCallbackDestinationName(RuntimeEndpointReference reference) { + RuntimeEndpoint endpoint = (RuntimeEndpoint) reference.getCallbackEndpoint(); + if (endpoint != null) { + JMSBindingServiceBindingProvider bp = (JMSBindingServiceBindingProvider)endpoint.getBindingProvider(); return bp.getDestinationName(); } return null; diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListenerFactory.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListenerFactory.java index a4a7ff5e5d..bb4b30d190 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListenerFactory.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListenerFactory.java @@ -41,8 +41,8 @@ public class DefaultJMSServiceListenerFactory implements JMSServiceListenerFacto JMSResourceFactory rf = ((JMSBindingServiceBindingProvider)jmsSLD).getResourceFactory();
- MessageListener listener = new DefaultServiceInvoker(jmsSLD.getJmsBinding(), jmsSLD.getService(), jmsSLD.getTargetBinding(), jmsSLD.getMessageFactory(), rf);
- RuntimeComponentService service = jmsSLD.getService();
+ RuntimeComponentService service = (RuntimeComponentService) jmsSLD.getEndpoint().getService();
+ MessageListener listener = new DefaultServiceInvoker(jmsSLD.getEndpoint(), jmsSLD.getTargetBinding(), jmsSLD.getMessageFactory(), rf);
// return new ASFListener(listener, service.getName(), service.isCallback(), jmsSLD.getJmsBinding(), workScheduler, rf);
// TODO: 2.x migration, service.isCallback()
diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultServiceInvoker.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultServiceInvoker.java index 02f4f1bf1b..0e1ee1bfd0 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultServiceInvoker.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultServiceInvoker.java @@ -28,11 +28,13 @@ import javax.jms.MessageListener; import javax.naming.NamingException;
import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.binding.jms.JMSBinding;
import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
import org.apache.tuscany.sca.invocation.MessageFactory;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
/**
* TODO RRB experiement
@@ -44,16 +46,18 @@ public class DefaultServiceInvoker implements MessageListener { private static final Logger logger = Logger.getLogger(DefaultServiceInvoker.class.getName());
+ private RuntimeEndpoint endpoint;
private JMSBinding jmsBinding;
private Binding targetBinding;
private JMSResourceFactory jmsResourceFactory;
private RuntimeComponentService service;
private MessageFactory messageFactory;
- public DefaultServiceInvoker(JMSBinding jmsBinding, RuntimeComponentService service, Binding targetBinding, MessageFactory messageFactory, JMSResourceFactory rf) throws NamingException {
- this.jmsBinding = jmsBinding;
+ public DefaultServiceInvoker(RuntimeEndpoint endpoint, Binding targetBinding, MessageFactory messageFactory, JMSResourceFactory rf) throws NamingException {
+ this.endpoint = endpoint;
+ this.jmsBinding = (JMSBinding) endpoint.getBinding();
this.jmsResourceFactory = rf;
- this.service = service;
+ this.service = (RuntimeComponentService) endpoint.getService();
this.targetBinding = targetBinding;
this.messageFactory = messageFactory;
@@ -86,8 +90,17 @@ public class DefaultServiceInvoker implements MessageListener { // call the runtime wire - the response is handled by the
// transport interceptor
- service.getRuntimeWire(targetBinding).invoke(tuscanyMsg);
+ getEndpoint(targetBinding).invoke(tuscanyMsg);
- }
+ }
+
+ private RuntimeEndpoint getEndpoint(Binding targetBinding) {
+ for(Endpoint ep: service.getEndpoints()) {
+ if(ep.getBinding() == targetBinding) {
+ return (RuntimeEndpoint) ep;
+ }
+ }
+ return endpoint;
+ }
}
diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerDetails.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerDetails.java index 2942f93781..c183a720e2 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerDetails.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerDetails.java @@ -22,18 +22,15 @@ package org.apache.tuscany.sca.binding.jms.host; import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.binding.jms.JMSBinding;
import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
public interface JMSServiceListenerDetails {
JMSBinding getJmsBinding();
Binding getTargetBinding();
-
- RuntimeComponentService getService();
-
- RuntimeComponent getComponent();
+
+ RuntimeEndpoint getEndpoint();
MessageFactory getMessageFactory();
diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultProviderFactory.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultProviderFactory.java index 8a24c2c097..61a2a076de 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultProviderFactory.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultProviderFactory.java @@ -19,14 +19,12 @@ package org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault.runtime; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.operationselector.OperationSelectorJMSDefault; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.provider.OperationSelectorProvider; import org.apache.tuscany.sca.provider.OperationSelectorProviderFactory; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * @version $Rev$ $Date$ @@ -41,18 +39,14 @@ public class OperationSelectorJMSDefaultProviderFactory implements OperationSele /** */ - public OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding) { + public OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeEndpointReference endpointReference) { return null; } /** */ - public OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeComponent component, - RuntimeComponentService service, - Binding binding) { - return new OperationSelectorJMSDefaultServiceProvider(registry, component, service, binding); + public OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeEndpoint endpoint) { + return new OperationSelectorJMSDefaultServiceProvider(registry, endpoint); } /** diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceInterceptor.java index d9ba87931a..23d012b616 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceInterceptor.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceInterceptor.java @@ -45,7 +45,7 @@ import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; /** * Policy handler to handle PolicySet related to Logging with the QName @@ -58,7 +58,7 @@ public class OperationSelectorJMSDefaultServiceInterceptor implements Intercepto private static final String ON_MESSAGE_METHOD_NAME = "onMessage"; private Invoker next; - private RuntimeWire runtimeWire; + private RuntimeEndpoint endpint; private JMSResourceFactory jmsResourceFactory; private JMSBinding jmsBinding; private JMSMessageProcessor requestMessageProcessor; @@ -67,15 +67,14 @@ public class OperationSelectorJMSDefaultServiceInterceptor implements Intercepto private List<Operation> serviceOperations; - public OperationSelectorJMSDefaultServiceInterceptor(ExtensionPointRegistry registry, JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, - RuntimeWire runtimeWire) { + public OperationSelectorJMSDefaultServiceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpoint endpoint) { super(); - this.jmsBinding = jmsBinding; - this.runtimeWire = runtimeWire; + this.endpint = endpoint; + this.jmsBinding = (JMSBinding) endpoint.getBinding(); this.jmsResourceFactory = jmsResourceFactory; this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding); this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding); - this.service = (RuntimeComponentService)runtimeWire.getEndpoint().getService(); + this.service = (RuntimeComponentService)endpoint.getService(); this.serviceOperations = service.getInterfaceContract().getInterface().getOperations(); } diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceProvider.java index 492882a303..da120ac6c1 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceProvider.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceProvider.java @@ -19,38 +19,29 @@ package org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault.runtime; -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; import org.apache.tuscany.sca.provider.OperationSelectorProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; /** * @version $Rev$ $Date$ */ public class OperationSelectorJMSDefaultServiceProvider implements OperationSelectorProvider { - private RuntimeComponent component; - private RuntimeComponentService service; - private Binding binding; + private RuntimeEndpoint endpoint; private ExtensionPointRegistry registry; - - public OperationSelectorJMSDefaultServiceProvider(ExtensionPointRegistry registry, RuntimeComponent component, RuntimeComponentService service, Binding binding) { + + public OperationSelectorJMSDefaultServiceProvider(ExtensionPointRegistry registry, RuntimeEndpoint endpoint) { super(); - this.component = component; - this.service = service; - this.binding = binding; + this.endpoint = endpoint; this.registry = registry; } /** */ public Interceptor createInterceptor() { - return new OperationSelectorJMSDefaultServiceInterceptor(registry, (JMSBinding)binding, - null, - service.getRuntimeWire(binding)); + return new OperationSelectorJMSDefaultServiceInterceptor(registry, null, endpoint); } /** diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropProviderFactory.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropProviderFactory.java index a71c5d8e5e..4352f5d416 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropProviderFactory.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropProviderFactory.java @@ -19,14 +19,12 @@ package org.apache.tuscany.sca.binding.jms.operationselector.jmsuserprop.runtime; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.operationselector.OperationSelectorJMSUserProp; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.provider.OperationSelectorProvider; import org.apache.tuscany.sca.provider.OperationSelectorProviderFactory; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; public class OperationSelectorJMSUserPropProviderFactory implements OperationSelectorProviderFactory<OperationSelectorJMSUserProp> { private ExtensionPointRegistry registry; @@ -38,18 +36,14 @@ public class OperationSelectorJMSUserPropProviderFactory implements OperationSel /** */ - public OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding) { + public OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeEndpointReference endpointReference) { return null; } /** */ - public OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeComponent component, - RuntimeComponentService service, - Binding binding) { - return new OperationSelectorJMSUserPropServiceProvider(component, service, binding); + public OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeEndpoint endpoint) { + return new OperationSelectorJMSUserPropServiceProvider(endpoint); } /** diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceInterceptor.java index 7886c2d138..343aa8d52a 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceInterceptor.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceInterceptor.java @@ -31,7 +31,7 @@ import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; /** * Interceptor for user property based operation selection @@ -42,18 +42,18 @@ import org.apache.tuscany.sca.runtime.RuntimeWire; public class OperationSelectorJMSUserPropServiceInterceptor implements Interceptor { private Invoker next; - private RuntimeWire runtimeWire; + private RuntimeEndpoint endpoint; private JMSBinding jmsBinding; private OperationSelectorJMSUserProp operationSelector; private RuntimeComponentService service; private List<Operation> serviceOperations; - public OperationSelectorJMSUserPropServiceInterceptor(JMSBinding jmsBinding, RuntimeWire runtimeWire) { + public OperationSelectorJMSUserPropServiceInterceptor(RuntimeEndpoint endpoint) { super(); - this.jmsBinding = jmsBinding; + this.jmsBinding = (JMSBinding) endpoint.getBinding(); this.operationSelector = (OperationSelectorJMSUserProp)jmsBinding.getOperationSelector(); - this.runtimeWire = runtimeWire; - this.service = (RuntimeComponentService) runtimeWire.getEndpoint().getService(); + this.endpoint = endpoint; + this.service = (RuntimeComponentService) endpoint.getService(); this.serviceOperations = service.getInterfaceContract().getInterface().getOperations(); } diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceProvider.java index 850a3035ab..a151688c36 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceProvider.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceProvider.java @@ -19,30 +19,23 @@ package org.apache.tuscany.sca.binding.jms.operationselector.jmsuserprop.runtime; -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; import org.apache.tuscany.sca.provider.OperationSelectorProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; public class OperationSelectorJMSUserPropServiceProvider implements OperationSelectorProvider { - private RuntimeComponent component; - private RuntimeComponentService service; - private Binding binding; + private RuntimeEndpoint endpoint; - public OperationSelectorJMSUserPropServiceProvider(RuntimeComponent component, RuntimeComponentService service, Binding binding) { + public OperationSelectorJMSUserPropServiceProvider(RuntimeEndpoint endpoint) { super(); - this.component = component; - this.service = service; - this.binding = binding; + this.endpoint = endpoint; } /** */ public Interceptor createInterceptor() { - return new OperationSelectorJMSUserPropServiceInterceptor((JMSBinding)binding, service.getRuntimeWire(binding)); + return new OperationSelectorJMSUserPropServiceInterceptor(endpoint); } /** diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.java index c7a00de86e..15bd8713f2 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.java @@ -19,8 +19,6 @@ package org.apache.tuscany.sca.binding.jms.provider; -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.host.DefaultJMSHostExtensionPoint; import org.apache.tuscany.sca.binding.jms.host.JMSHostExtensionPoint; @@ -29,9 +27,8 @@ import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.provider.BindingProviderFactory; import org.apache.tuscany.sca.provider.ReferenceBindingProvider; import org.apache.tuscany.sca.provider.ServiceBindingProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * A factory from creating the JMS binding provider. @@ -61,15 +58,15 @@ public class JMSBindingProviderFactory implements BindingProviderFactory<JMSBind serviceListenerFactory = jmsHostExtensionPoint.getJMSServiceListenerFactory(); } - public ReferenceBindingProvider createReferenceBindingProvider(EndpointReference endpointReference) { + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) { JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory((JMSBinding)endpointReference.getBinding()); - return new JMSBindingReferenceBindingProvider((RuntimeComponent)endpointReference.getComponent(), (RuntimeComponentReference) endpointReference.getReference(), (JMSBinding)endpointReference.getBinding(), extensionPoints, jmsRF); + return new JMSBindingReferenceBindingProvider(endpointReference, extensionPoints, jmsRF); } - public ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint) { + public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) { JMSBinding binding = (JMSBinding)endpoint.getBinding(); JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory(binding); - return new JMSBindingServiceBindingProvider(extensionPoints, (RuntimeComponent)endpoint.getComponent(), (RuntimeComponentService)endpoint.getService(), binding, binding, serviceListenerFactory, extensionPoints, jmsRF); + return new JMSBindingServiceBindingProvider(extensionPoints, endpoint, serviceListenerFactory, extensionPoints, jmsRF); } public Class<JMSBinding> getModelType() { diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java index da3bd6ab60..8053ba69e4 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java @@ -31,21 +31,22 @@ import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.InvocationChain; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Phase; +import org.apache.tuscany.sca.provider.EndpointReferenceProvider; import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint; -import org.apache.tuscany.sca.provider.ReferenceBindingProviderRRB; import org.apache.tuscany.sca.provider.WireFormatProvider; import org.apache.tuscany.sca.provider.WireFormatProviderFactory; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * Implementation of the JMS reference binding provider. * * @version $Rev$ $Date$ */ -public class JMSBindingReferenceBindingProvider implements ReferenceBindingProviderRRB { +public class JMSBindingReferenceBindingProvider implements EndpointReferenceProvider { + private RuntimeEndpointReference endpointReference; private RuntimeComponentReference reference; private JMSBinding jmsBinding; private JMSResourceFactory jmsResourceFactory; @@ -61,11 +62,12 @@ public class JMSBindingReferenceBindingProvider implements ReferenceBindingProvi private WireFormatProviderFactory responseWireFormatProviderFactory; private WireFormatProvider responseWireFormatProvider; - public JMSBindingReferenceBindingProvider(RuntimeComponent component, RuntimeComponentReference reference, JMSBinding binding, ExtensionPointRegistry extensions, JMSResourceFactory jmsResourceFactory) { - this.reference = reference; - this.jmsBinding = binding; + public JMSBindingReferenceBindingProvider(RuntimeEndpointReference endpointReference, ExtensionPointRegistry extensions, JMSResourceFactory jmsResourceFactory) { + this.endpointReference = endpointReference; + this.reference = (RuntimeComponentReference) endpointReference.getReference(); + this.jmsBinding = (JMSBinding) endpointReference.getBinding(); this.extensions = extensions; - this.component = component; + this.component = (RuntimeComponent) endpointReference.getComponent(); this.jmsResourceFactory = jmsResourceFactory; // Get the factories/providers for operation selection @@ -75,13 +77,13 @@ public class JMSBindingReferenceBindingProvider implements ReferenceBindingProvi this.requestWireFormatProviderFactory = (WireFormatProviderFactory)providerFactories.getProviderFactory(jmsBinding.getRequestWireFormat().getClass()); if (this.requestWireFormatProviderFactory != null){ - this.requestWireFormatProvider = requestWireFormatProviderFactory.createReferenceWireFormatProvider(component, reference, jmsBinding); + this.requestWireFormatProvider = requestWireFormatProviderFactory.createReferenceWireFormatProvider(endpointReference); } this.responseWireFormatProviderFactory = (WireFormatProviderFactory)providerFactories.getProviderFactory(jmsBinding.getResponseWireFormat().getClass()); if (this.responseWireFormatProviderFactory != null){ - this.responseWireFormatProvider = responseWireFormatProviderFactory.createReferenceWireFormatProvider(component, reference, jmsBinding); + this.responseWireFormatProvider = responseWireFormatProviderFactory.createReferenceWireFormatProvider(endpointReference); } // create an interface contract that reflects both request and response @@ -105,7 +107,7 @@ public class JMSBindingReferenceBindingProvider implements ReferenceBindingProvi } Invoker invoker = null; - invoker = new RRBJMSBindingInvoker(jmsBinding, operation, jmsResourceFactory, reference); + invoker = new RRBJMSBindingInvoker(operation, jmsResourceFactory, endpointReference); return invoker; } @@ -135,15 +137,15 @@ public class JMSBindingReferenceBindingProvider implements ReferenceBindingProvi * set up the reference binding wire with the right set of jms reference * interceptors */ - public void configureBindingChain(RuntimeWire runtimeWire) { + public void configure() { - InvocationChain bindingChain = runtimeWire.getBindingInvocationChain(); + InvocationChain bindingChain = endpointReference.getBindingInvocationChain(); // add transport interceptor bindingChain.addInterceptor(Phase.REFERENCE_BINDING_TRANSPORT, new TransportReferenceInterceptor(jmsBinding, jmsResourceFactory, - runtimeWire) ); + endpointReference) ); // add request wire format bindingChain.addInterceptor(requestWireFormatProvider.getPhase(), @@ -158,9 +160,10 @@ public class JMSBindingReferenceBindingProvider implements ReferenceBindingProvi // add the header processor that comes after the wire formatter but before the // policy interceptors bindingChain.addInterceptor(Phase.REFERENCE_BINDING_WIREFORMAT, - new HeaderReferenceInterceptor(jmsBinding, + new HeaderReferenceInterceptor(extensions, + jmsBinding, jmsResourceFactory, - runtimeWire, extensions) ); + endpointReference) ); } } diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java index e18d6ca370..225d514045 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java @@ -36,24 +36,26 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.invocation.InvocationChain; import org.apache.tuscany.sca.invocation.MessageFactory; import org.apache.tuscany.sca.invocation.Phase; +import org.apache.tuscany.sca.provider.EndpointProvider; import org.apache.tuscany.sca.provider.OperationSelectorProvider; import org.apache.tuscany.sca.provider.OperationSelectorProviderFactory; import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint; -import org.apache.tuscany.sca.provider.ServiceBindingProviderRRB; import org.apache.tuscany.sca.provider.WireFormatProvider; import org.apache.tuscany.sca.provider.WireFormatProviderFactory; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; /** * Implementation of the JMS service binding provider. * * @version $Rev$ $Date$ */ -public class JMSBindingServiceBindingProvider implements ServiceBindingProviderRRB, JMSServiceListenerDetails { +public class JMSBindingServiceBindingProvider implements EndpointProvider, JMSServiceListenerDetails { private static final Logger logger = Logger.getLogger(JMSBindingServiceBindingProvider.class.getName()); + private ExtensionPointRegistry registry; + private RuntimeEndpoint endpoint; private RuntimeComponentService service; private Binding targetBinding; private JMSBinding jmsBinding; @@ -78,14 +80,13 @@ public class JMSBindingServiceBindingProvider implements ServiceBindingProviderR private WireFormatProviderFactory responseWireFormatProviderFactory; private WireFormatProvider responseWireFormatProvider; - private ExtensionPointRegistry registry; - - public JMSBindingServiceBindingProvider(ExtensionPointRegistry registry, RuntimeComponent component, RuntimeComponentService service, Binding targetBinding, JMSBinding binding, JMSServiceListenerFactory serviceListenerFactory, ExtensionPointRegistry extensionPoints, JMSResourceFactory jmsResourceFactory) { - this.component = component; - this.service = service; - this.jmsBinding = binding; + public JMSBindingServiceBindingProvider(ExtensionPointRegistry registry, RuntimeEndpoint endpoint, JMSServiceListenerFactory serviceListenerFactory, ExtensionPointRegistry extensionPoints, JMSResourceFactory jmsResourceFactory) { + this.endpoint = endpoint; + this.component = (RuntimeComponent) endpoint.getComponent(); + this.service = (RuntimeComponentService) endpoint.getService(); + this.jmsBinding = (JMSBinding) endpoint.getBinding(); this.serviceListenerFactory = serviceListenerFactory; - this.targetBinding = targetBinding; + this.targetBinding = jmsBinding; this.jmsResourceFactory = jmsResourceFactory; this.registry = registry; @@ -109,20 +110,20 @@ public class JMSBindingServiceBindingProvider implements ServiceBindingProviderR this.operationSelectorProviderFactory = (OperationSelectorProviderFactory)providerFactories.getProviderFactory(jmsBinding.getOperationSelector().getClass()); if (this.operationSelectorProviderFactory != null){ - this.operationSelectorProvider = operationSelectorProviderFactory.createServiceOperationSelectorProvider(component, service, jmsBinding); + this.operationSelectorProvider = operationSelectorProviderFactory.createServiceOperationSelectorProvider(endpoint); } // Get the factories/providers for wire format this.requestWireFormatProviderFactory = (WireFormatProviderFactory)providerFactories.getProviderFactory(jmsBinding.getRequestWireFormat().getClass()); if (this.requestWireFormatProviderFactory != null){ - this.requestWireFormatProvider = requestWireFormatProviderFactory.createServiceWireFormatProvider(component, service, jmsBinding); + this.requestWireFormatProvider = requestWireFormatProviderFactory.createServiceWireFormatProvider(endpoint); } this.responseWireFormatProviderFactory = (WireFormatProviderFactory)providerFactories.getProviderFactory(jmsBinding.getResponseWireFormat().getClass()); if (this.responseWireFormatProviderFactory != null){ - this.responseWireFormatProvider = responseWireFormatProviderFactory.createServiceWireFormatProvider(component, service, jmsBinding); + this.responseWireFormatProvider = responseWireFormatProviderFactory.createServiceWireFormatProvider(endpoint); } // create an interface contract that reflects both request and response @@ -171,15 +172,15 @@ public class JMSBindingServiceBindingProvider implements ServiceBindingProviderR /* * Adds JMS specific interceptors to the binding chain */ - public void configureBindingChain(RuntimeWire runtimeWire) { + public void configure() { - InvocationChain bindingChain = runtimeWire.getBindingInvocationChain(); + InvocationChain bindingChain = endpoint.getBindingInvocationChain(); // add transport interceptor bindingChain.addInterceptor(Phase.SERVICE_BINDING_TRANSPORT, new TransportServiceInterceptor(registry, jmsBinding, jmsResourceFactory, - runtimeWire) ); + endpoint) ); // add operation selector interceptor bindingChain.addInterceptor(operationSelectorProvider.getPhase(), @@ -187,11 +188,11 @@ public class JMSBindingServiceBindingProvider implements ServiceBindingProviderR // add operationProperties interceptor after operation selector bindingChain.addInterceptor(Phase.SERVICE_BINDING_OPERATION_SELECTOR, - new OperationPropertiesInterceptor(jmsBinding, runtimeWire)); + new OperationPropertiesInterceptor(jmsBinding, endpoint)); // add callback destination interceptor after operation selector bindingChain.addInterceptor(Phase.SERVICE_BINDING_WIREFORMAT, - new CallbackDestinationInterceptor(runtimeWire)); + new CallbackDestinationInterceptor(endpoint)); // add request wire format bindingChain.addInterceptor(requestWireFormatProvider.getPhase(), @@ -228,4 +229,8 @@ public class JMSBindingServiceBindingProvider implements ServiceBindingProviderR return jmsResourceFactory; } + public RuntimeEndpoint getEndpoint() { + return endpoint; + } + } diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java index 84938558bf..8615c128c1 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java @@ -33,8 +33,7 @@ import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.interfacedef.util.FaultException; import org.apache.tuscany.sca.invocation.DataExchangeSemantics; import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; import org.oasisopen.sca.ServiceRuntimeException; /** @@ -51,18 +50,16 @@ public class RRBJMSBindingInvoker implements Invoker, DataExchangeSemantics { protected JMSResourceFactory jmsResourceFactory; protected Destination bindingRequestDest; protected Destination bindingReplyDest; - protected RuntimeComponentReference reference; - protected RuntimeWire runtimeWire; + protected RuntimeEndpointReference endpointReference; - public RRBJMSBindingInvoker(JMSBinding jmsBinding, Operation operation, JMSResourceFactory jmsResourceFactory, RuntimeComponentReference reference) { + public RRBJMSBindingInvoker(Operation operation, JMSResourceFactory jmsResourceFactory, RuntimeEndpointReference epr) { this.operation = operation; operationName = operation.getName(); - this.jmsBinding = jmsBinding; + this.endpointReference = epr; + this.jmsBinding = (JMSBinding) epr.getBinding(); this.jmsResourceFactory = jmsResourceFactory; - this.reference = reference; - this.runtimeWire = reference.getRuntimeWire(jmsBinding); try { // If this is a callback reference, the destination is determined dynamically based on @@ -200,7 +197,7 @@ public class RRBJMSBindingInvoker implements Invoker, DataExchangeSemantics { context.setReplyToDestination(getReplyToDestination(session)); try { - tuscanyMsg = runtimeWire.getBindingInvocationChain().getHeadInvoker().invoke(tuscanyMsg); + tuscanyMsg = endpointReference.getBindingInvocationChain().getHeadInvoker().invoke(tuscanyMsg); } catch (ServiceRuntimeException e) { if (e.getCause() instanceof InvocationTargetException) { if ((e.getCause().getCause() instanceof RuntimeException)) { diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java index fd74ae952a..265440a992 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java @@ -31,8 +31,7 @@ import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * Policy handler to handle PolicySet related to Logging with the QName @@ -43,11 +42,11 @@ import org.apache.tuscany.sca.runtime.RuntimeWire; public class TransportReferenceInterceptor implements Interceptor { private Invoker next; - private RuntimeWire runtimeWire; + private RuntimeEndpointReference runtimeWire; private JMSResourceFactory jmsResourceFactory; private JMSBinding jmsBinding; - public TransportReferenceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) { + public TransportReferenceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeEndpointReference runtimeWire) { super(); this.jmsBinding = jmsBinding; this.runtimeWire = runtimeWire; diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java index 9735677662..6a32339c5d 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java @@ -40,7 +40,7 @@ import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; /** * @@ -50,7 +50,7 @@ public class TransportServiceInterceptor implements Interceptor { private static final Logger logger = Logger.getLogger(TransportServiceInterceptor.class.getName()); private Invoker next; - private RuntimeWire runtimeWire; + private RuntimeEndpoint endpoint; private JMSResourceFactory jmsResourceFactory; private JMSBinding jmsBinding; private JMSMessageProcessor requestMessageProcessor; @@ -59,14 +59,14 @@ public class TransportServiceInterceptor implements Interceptor { private String correlationScheme; - public TransportServiceInterceptor(ExtensionPointRegistry registry, JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) { + public TransportServiceInterceptor(ExtensionPointRegistry registry, JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeEndpoint endpoint) { super(); this.jmsBinding = jmsBinding; - this.runtimeWire = runtimeWire; + this.endpoint = endpoint; this.jmsResourceFactory = jmsResourceFactory; this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding); this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding); - this.service = (RuntimeComponentService)runtimeWire.getEndpoint().getService(); + this.service = (RuntimeComponentService)endpoint.getService(); this.correlationScheme = jmsBinding.getCorrelationScheme(); } diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/CallbackDestinationInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/CallbackDestinationInterceptor.java index 831d1246f8..2245f61ee7 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/CallbackDestinationInterceptor.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/CallbackDestinationInterceptor.java @@ -30,15 +30,15 @@ import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; public class CallbackDestinationInterceptor implements Interceptor { private Invoker next; private RuntimeComponentService service; - public CallbackDestinationInterceptor(RuntimeWire runtimeWire) { + public CallbackDestinationInterceptor(RuntimeEndpoint endpoint) { super(); - this.service = (RuntimeComponentService) runtimeWire.getEndpoint().getService(); + this.service = (RuntimeComponentService) endpoint.getService(); } public Invoker getNext() { diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/OperationPropertiesInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/OperationPropertiesInterceptor.java index 9536de2bfa..bf046b473e 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/OperationPropertiesInterceptor.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/OperationPropertiesInterceptor.java @@ -26,7 +26,7 @@ import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; public class OperationPropertiesInterceptor implements Interceptor { private Invoker next; @@ -34,10 +34,10 @@ public class OperationPropertiesInterceptor implements Interceptor { private RuntimeComponentService service; private List<Operation> serviceOperations; - public OperationPropertiesInterceptor(JMSBinding jmsBinding, RuntimeWire runtimeWire) { + public OperationPropertiesInterceptor(JMSBinding jmsBinding, RuntimeEndpoint endpoint) { super(); this.jmsBinding = jmsBinding; - this.service = (RuntimeComponentService) runtimeWire.getEndpoint().getService(); + this.service = (RuntimeComponentService) endpoint.getService(); this.serviceOperations = service.getInterfaceContract().getInterface().getOperations(); } diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesProviderFactory.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesProviderFactory.java index 374c6d9f66..7675698cc7 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesProviderFactory.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesProviderFactory.java @@ -19,14 +19,12 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.runtime; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytes; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.provider.WireFormatProvider; import org.apache.tuscany.sca.provider.WireFormatProviderFactory; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * @version $Rev$ $Date$ @@ -41,18 +39,14 @@ public class WireFormatJMSBytesProviderFactory implements WireFormatProviderFact /** */ - public WireFormatProvider createReferenceWireFormatProvider(RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding) { - return new WireFormatJMSBytesReferenceProvider(registry, component, reference, binding); + public WireFormatProvider createReferenceWireFormatProvider(RuntimeEndpointReference endpointReference) { + return new WireFormatJMSBytesReferenceProvider(registry, endpointReference); } /** */ - public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component, - RuntimeComponentService service, - Binding binding) { - return new WireFormatJMSBytesServiceProvider(registry, component, service, binding); + public WireFormatProvider createServiceWireFormatProvider(RuntimeEndpoint endpoint) { + return new WireFormatJMSBytesServiceProvider(registry, endpoint); } /** diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceInterceptor.java index 82e29b542e..4620063076 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceInterceptor.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceInterceptor.java @@ -35,7 +35,7 @@ import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * @@ -44,16 +44,16 @@ import org.apache.tuscany.sca.runtime.RuntimeWire; public class WireFormatJMSBytesReferenceInterceptor implements Interceptor { private Invoker next; - private RuntimeWire runtimeWire; + private RuntimeEndpointReference endpointReference; private JMSResourceFactory jmsResourceFactory; private JMSBinding jmsBinding; private JMSMessageProcessor requestMessageProcessor; private JMSMessageProcessor responseMessageProcessor; - public WireFormatJMSBytesReferenceInterceptor(ExtensionPointRegistry registry, JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) { + public WireFormatJMSBytesReferenceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpointReference endpointReference) { super(); - this.jmsBinding = jmsBinding; - this.runtimeWire = runtimeWire; + this.endpointReference = endpointReference; + this.jmsBinding = (JMSBinding) endpointReference.getBinding(); this.jmsResourceFactory = jmsResourceFactory; this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding); this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding); diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceProvider.java index 83c01abe6e..3d2c8ec18c 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceProvider.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceProvider.java @@ -19,7 +19,6 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.runtime; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytes; @@ -28,28 +27,23 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; import org.apache.tuscany.sca.provider.WireFormatProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * @version $Rev$ $Date$ */ public class WireFormatJMSBytesReferenceProvider implements WireFormatProvider { private ExtensionPointRegistry registry; - private RuntimeComponent component; - private RuntimeComponentReference reference; + private RuntimeEndpointReference endpointReference; private JMSBinding binding; private InterfaceContract interfaceContract; public WireFormatJMSBytesReferenceProvider(ExtensionPointRegistry registry, - RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding) { + RuntimeEndpointReference endpointReference) { super(); this.registry = registry; - this.component = component; - this.reference = reference; - this.binding = (JMSBinding)binding; + this.endpointReference = endpointReference; + this.binding = (JMSBinding) endpointReference.getBinding(); // configure the reference based on this wire format @@ -65,7 +59,7 @@ public class WireFormatJMSBytesReferenceProvider implements WireFormatProvider { // just point to the reference interface contract so no // databinding transformation takes place - interfaceContract = reference.getReference().getInterfaceContract(); + interfaceContract = endpointReference.getReference().getReference().getInterfaceContract(); } public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){ @@ -85,9 +79,7 @@ public class WireFormatJMSBytesReferenceProvider implements WireFormatProvider { } public Interceptor createInterceptor() { - return new WireFormatJMSBytesReferenceInterceptor(registry, binding, - null, - reference.getRuntimeWire(binding)); + return new WireFormatJMSBytesReferenceInterceptor(registry, null, endpointReference); } public String getPhase() { diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceInterceptor.java index 6f358171ff..7bc5d49631 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceInterceptor.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceInterceptor.java @@ -31,7 +31,7 @@ import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; /** * Policy handler to handle PolicySet related to Logging with the QName @@ -41,16 +41,16 @@ import org.apache.tuscany.sca.runtime.RuntimeWire; */ public class WireFormatJMSBytesServiceInterceptor implements Interceptor { private Invoker next; - private RuntimeWire runtimeWire; + private RuntimeEndpoint endpoint; private JMSResourceFactory jmsResourceFactory; private JMSBinding jmsBinding; private JMSMessageProcessor requestMessageProcessor; private JMSMessageProcessor responseMessageProcessor; - public WireFormatJMSBytesServiceInterceptor(ExtensionPointRegistry registry, JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) { + public WireFormatJMSBytesServiceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpoint endpoint) { super(); - this.jmsBinding = jmsBinding; - this.runtimeWire = runtimeWire; + this.endpoint = endpoint; + this.jmsBinding = (JMSBinding) endpoint.getBinding(); this.jmsResourceFactory = jmsResourceFactory; this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding); this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding); diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceProvider.java index 662362b842..ef3530640f 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceProvider.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceProvider.java @@ -19,7 +19,6 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.runtime; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytes; @@ -28,28 +27,23 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; import org.apache.tuscany.sca.provider.WireFormatProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; /** * @version $Rev$ $Date$ */ public class WireFormatJMSBytesServiceProvider implements WireFormatProvider { private ExtensionPointRegistry registry; - private RuntimeComponent component; - private RuntimeComponentService service; + private RuntimeEndpoint endpoint; private JMSBinding binding; private InterfaceContract interfaceContract; public WireFormatJMSBytesServiceProvider(ExtensionPointRegistry registry, - RuntimeComponent component, - RuntimeComponentService service, - Binding binding) { + RuntimeEndpoint endpoint) { super(); this.registry = registry; - this.component = component; - this.service = service; - this.binding = (JMSBinding)binding; + this.endpoint = endpoint; + this.binding = (JMSBinding) endpoint.getBinding(); // configure the service based on this wire format @@ -65,7 +59,7 @@ public class WireFormatJMSBytesServiceProvider implements WireFormatProvider { // just point to the reference interface contract so no // databinding transformation takes place - interfaceContract = service.getService().getInterfaceContract(); + interfaceContract = endpoint.getService().getService().getInterfaceContract(); } public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){ @@ -87,9 +81,7 @@ public class WireFormatJMSBytesServiceProvider implements WireFormatProvider { /** */ public Interceptor createInterceptor() { - return new WireFormatJMSBytesServiceInterceptor(registry, (JMSBinding)binding, - null, - service.getRuntimeWire(binding)); + return new WireFormatJMSBytesServiceInterceptor(registry, null, endpoint); } /** diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLProviderFactory.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLProviderFactory.java index 1f28a02328..a791c5f0b9 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLProviderFactory.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLProviderFactory.java @@ -19,7 +19,6 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytesxml.runtime; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory; import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactoryExtensionPoint; @@ -27,9 +26,8 @@ import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytes; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.provider.WireFormatProvider; import org.apache.tuscany.sca.provider.WireFormatProviderFactory; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; public class WireFormatJMSBytesXMLProviderFactory implements WireFormatProviderFactory<WireFormatJMSBytes> { @@ -44,19 +42,15 @@ public class WireFormatJMSBytesXMLProviderFactory implements WireFormatProviderF /** */ - public WireFormatProvider createReferenceWireFormatProvider(RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding) { - return new WireFormatJMSBytesXMLReferenceProvider(registry, component, reference, binding); + public WireFormatProvider createReferenceWireFormatProvider(RuntimeEndpointReference endpointReference) { + return new WireFormatJMSBytesXMLReferenceProvider(registry, endpointReference); } /** */ - public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component, - RuntimeComponentService service, - Binding binding) { - JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory((JMSBinding)binding); - return new WireFormatJMSBytesXMLServiceProvider(registry, component, service, binding, jmsRF); + public WireFormatProvider createServiceWireFormatProvider(RuntimeEndpoint endpoint) { + JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory((JMSBinding)endpoint.getBinding()); + return new WireFormatJMSBytesXMLServiceProvider(registry, endpoint, jmsRF); } /** diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceInterceptor.java index 0032fd8e73..701a32e236 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceInterceptor.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceInterceptor.java @@ -36,22 +36,22 @@ import org.apache.tuscany.sca.interfacedef.util.FaultException; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; public class WireFormatJMSBytesXMLReferenceInterceptor implements Interceptor { private Invoker next; - private RuntimeWire runtimeWire; + private RuntimeEndpointReference endpointReference; private JMSResourceFactory jmsResourceFactory; private JMSBinding jmsBinding; private JMSMessageProcessor requestMessageProcessor; private JMSMessageProcessor responseMessageProcessor; - public WireFormatJMSBytesXMLReferenceInterceptor(ExtensionPointRegistry registry, JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) { + public WireFormatJMSBytesXMLReferenceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpointReference endpointReference) { super(); - this.jmsBinding = jmsBinding; - this.runtimeWire = runtimeWire; + this.jmsBinding = (JMSBinding) endpointReference.getBinding(); + this.endpointReference = endpointReference; this.jmsResourceFactory = jmsResourceFactory; this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding); this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding); diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceProvider.java index 918e201b31..e56d35a8ed 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceProvider.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceProvider.java @@ -20,7 +20,6 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytesxml.runtime; import org.apache.axiom.om.OMElement; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytesXML; @@ -32,25 +31,20 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; import org.apache.tuscany.sca.provider.WireFormatProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; public class WireFormatJMSBytesXMLReferenceProvider implements WireFormatProvider { private ExtensionPointRegistry registry; - private RuntimeComponent component; - private RuntimeComponentReference reference; + private RuntimeEndpointReference endpointReference; private JMSBinding binding; private InterfaceContract interfaceContract; public WireFormatJMSBytesXMLReferenceProvider(ExtensionPointRegistry registry, - RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding) { + RuntimeEndpointReference endpointReference) { super(); this.registry = registry; - this.component = component; - this.reference = reference; - this.binding = (JMSBinding)binding; + this.endpointReference = endpointReference; + this.binding = (JMSBinding)endpointReference.getBinding(); // configure the reference based on this wire format @@ -71,7 +65,7 @@ public class WireFormatJMSBytesXMLReferenceProvider implements WireFormatProvide // as required WebServiceBindingFactory wsFactory = registry.getExtensionPoint(WebServiceBindingFactory.class); WebServiceBinding wsBinding = wsFactory.createWebServiceBinding(); - BindingWSDLGenerator.generateWSDL(component, reference, wsBinding, registry, null); + BindingWSDLGenerator.generateWSDL(endpointReference.getComponent(), endpointReference.getContract(), wsBinding, registry, null); interfaceContract = wsBinding.getBindingInterfaceContract(); interfaceContract.getInterface().resetDataBinding(OMElement.class.getName()); } @@ -93,9 +87,7 @@ public class WireFormatJMSBytesXMLReferenceProvider implements WireFormatProvide } public Interceptor createInterceptor() { - return new WireFormatJMSBytesXMLReferenceInterceptor(registry, binding, - null, - reference.getRuntimeWire(binding)); + return new WireFormatJMSBytesXMLReferenceInterceptor(registry, null, endpointReference); } public String getPhase() { diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceInterceptor.java index 6f66e739cc..c1e97a93d0 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceInterceptor.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceInterceptor.java @@ -31,20 +31,20 @@ import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; public class WireFormatJMSBytesXMLServiceInterceptor implements Interceptor { private Invoker next; - private RuntimeWire runtimeWire; + private RuntimeEndpoint endpoint; private JMSResourceFactory jmsResourceFactory; private JMSBinding jmsBinding; private JMSMessageProcessor requestMessageProcessor; private JMSMessageProcessor responseMessageProcessor; - public WireFormatJMSBytesXMLServiceInterceptor(ExtensionPointRegistry registry, JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) { + public WireFormatJMSBytesXMLServiceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpoint endpoint) { super(); - this.jmsBinding = jmsBinding; - this.runtimeWire = runtimeWire; + this.jmsBinding = (JMSBinding) endpoint.getBinding(); + this.endpoint = endpoint; this.jmsResourceFactory = jmsResourceFactory; this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding); this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding); diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java index eef29a2937..00aaee39d5 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java @@ -20,7 +20,6 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytesxml.runtime; import org.apache.axiom.om.OMElement; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory; @@ -33,27 +32,22 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; import org.apache.tuscany.sca.provider.WireFormatProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; public class WireFormatJMSBytesXMLServiceProvider implements WireFormatProvider { private ExtensionPointRegistry registry; - private RuntimeComponent component; - private RuntimeComponentService service; + private RuntimeEndpoint endpoint; private JMSBinding binding; private JMSResourceFactory jmsResourceFactory; private InterfaceContract interfaceContract; public WireFormatJMSBytesXMLServiceProvider(ExtensionPointRegistry registry, - RuntimeComponent component, - RuntimeComponentService service, - Binding binding, - JMSResourceFactory jmsResourceFactory) { + RuntimeEndpoint endpoint, + JMSResourceFactory jmsResourceFactory) { super(); this.registry = registry; - this.component = component; - this.service = service; - this.binding = (JMSBinding)binding; + this.endpoint = endpoint; + this.binding = (JMSBinding)endpoint.getBinding(); this.jmsResourceFactory = jmsResourceFactory; // configure the service based on this wire format @@ -75,7 +69,7 @@ public class WireFormatJMSBytesXMLServiceProvider implements WireFormatProvider // as required WebServiceBindingFactory wsFactory = registry.getExtensionPoint(WebServiceBindingFactory.class); WebServiceBinding wsBinding = wsFactory.createWebServiceBinding(); - BindingWSDLGenerator.generateWSDL(component, service, wsBinding, registry, null); + BindingWSDLGenerator.generateWSDL(endpoint.getComponent(), endpoint.getService(), wsBinding, registry, null); interfaceContract = wsBinding.getBindingInterfaceContract(); interfaceContract.getInterface().resetDataBinding(OMElement.class.getName()); } @@ -99,9 +93,7 @@ public class WireFormatJMSBytesXMLServiceProvider implements WireFormatProvider /** */ public Interceptor createInterceptor() { - return new WireFormatJMSBytesXMLServiceInterceptor(registry, (JMSBinding)binding, - jmsResourceFactory, - service.getRuntimeWire(binding)); + return new WireFormatJMSBytesXMLServiceInterceptor(registry, jmsResourceFactory, endpoint); } /** diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultProviderFactory.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultProviderFactory.java index 98ca94e407..adf8c03c10 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultProviderFactory.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultProviderFactory.java @@ -19,7 +19,6 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmsdefault.runtime; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory; import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactoryExtensionPoint; @@ -27,9 +26,8 @@ import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSDefault; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.provider.WireFormatProvider; import org.apache.tuscany.sca.provider.WireFormatProviderFactory; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * @version $Rev$ $Date$ @@ -46,16 +44,15 @@ public class WireFormatJMSDefaultProviderFactory implements WireFormatProviderFa /** */ - public WireFormatProvider createReferenceWireFormatProvider(RuntimeComponent component, RuntimeComponentReference reference, - Binding binding) { - return new WireFormatJMSDefaultReferenceProvider(registry, component, reference, binding); + public WireFormatProvider createReferenceWireFormatProvider(RuntimeEndpointReference endpointReference) { + return new WireFormatJMSDefaultReferenceProvider(registry, endpointReference); } /** */ - public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component, RuntimeComponentService service, Binding binding) { - JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory((JMSBinding) binding); - return new WireFormatJMSDefaultServiceProvider(registry, component, service, binding, jmsRF); + public WireFormatProvider createServiceWireFormatProvider(RuntimeEndpoint endpoint) { + JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory((JMSBinding) endpoint.getBinding()); + return new WireFormatJMSDefaultServiceProvider(registry, endpoint, jmsRF); } /** diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceInterceptor.java index efe0095509..499784095a 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceInterceptor.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceInterceptor.java @@ -40,7 +40,7 @@ import org.apache.tuscany.sca.interfacedef.util.FaultException; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * @@ -49,7 +49,7 @@ import org.apache.tuscany.sca.runtime.RuntimeWire; public class WireFormatJMSDefaultReferenceInterceptor implements Interceptor { private Invoker next; - private RuntimeWire runtimeWire; + private RuntimeEndpointReference endpointReference; private JMSResourceFactory jmsResourceFactory; private JMSBinding jmsBinding; private DefaultMessageProcessor requestMessageProcessor; @@ -57,11 +57,11 @@ public class WireFormatJMSDefaultReferenceInterceptor implements Interceptor { private HashMap<String, Boolean> inputWrapperMap; private HashMap<String, OMElement> outputWrapperMap; - public WireFormatJMSDefaultReferenceInterceptor(ExtensionPointRegistry registry, JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire, HashMap<String, Boolean> inputWrapperMap, + public WireFormatJMSDefaultReferenceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpointReference endpointReference, HashMap<String, Boolean> inputWrapperMap, HashMap<String, OMElement> outputWrapperMap) { super(); - this.jmsBinding = jmsBinding; - this.runtimeWire = runtimeWire; + this.jmsBinding = (JMSBinding) endpointReference.getBinding(); + this.endpointReference = endpointReference; this.jmsResourceFactory = jmsResourceFactory; // Note the default processor doesn't follow the normal processor pattern // as it has to handle both text and bytes messages diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceProvider.java index 15d86f9299..2732241b61 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceProvider.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceProvider.java @@ -26,7 +26,7 @@ import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMFactory; import org.apache.axiom.om.OMNamespace; -import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.ComponentReference; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSDefault; @@ -41,27 +41,25 @@ import org.apache.tuscany.sca.interfacedef.util.ElementInfo; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; import org.apache.tuscany.sca.provider.WireFormatProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * @version $Rev$ $Date$ */ public class WireFormatJMSDefaultReferenceProvider implements WireFormatProvider { private ExtensionPointRegistry registry; - private RuntimeComponent component; - private RuntimeComponentReference reference; + private RuntimeEndpointReference endpointReference; + private ComponentReference reference; private JMSBinding binding; private InterfaceContract interfaceContract; private HashMap<String, Boolean> inputWrapperMap; private HashMap<String, OMElement> outputWrapperMap; - public WireFormatJMSDefaultReferenceProvider(ExtensionPointRegistry registry, RuntimeComponent component, RuntimeComponentReference reference, Binding binding) { + public WireFormatJMSDefaultReferenceProvider(ExtensionPointRegistry registry, RuntimeEndpointReference endpointReference) { super(); this.registry = registry; - this.component = component; - this.reference = reference; - this.binding = (JMSBinding) binding; + this.endpointReference = endpointReference; + this.binding = (JMSBinding) endpointReference.getBinding(); this.inputWrapperMap = new HashMap<String, Boolean>(); this.outputWrapperMap = new HashMap<String, OMElement>(); @@ -78,6 +76,7 @@ public class WireFormatJMSDefaultReferenceProvider implements WireFormatProvider this.binding.setResponseMessageProcessorName(JMSBindingConstants.DEFAULT_MP_CLASSNAME); } + this.reference = endpointReference.getReference(); // TODO - can be null if it's a $self$ reference. Need to decide if // that's valid if (reference.getReference() == null){ @@ -96,7 +95,7 @@ public class WireFormatJMSDefaultReferenceProvider implements WireFormatProvider if (reference.getInterfaceContract() != null && !isAsIs()) { WebServiceBindingFactory wsFactory = registry.getExtensionPoint(WebServiceBindingFactory.class); WebServiceBinding wsBinding = wsFactory.createWebServiceBinding(); - BindingWSDLGenerator.generateWSDL(component, reference, wsBinding, registry, null); + BindingWSDLGenerator.generateWSDL(endpointReference.getComponent(), reference, wsBinding, registry, null); interfaceContract = wsBinding.getBindingInterfaceContract(); interfaceContract.getInterface().resetDataBinding(OMElement.class.getName()); @@ -189,7 +188,7 @@ public class WireFormatJMSDefaultReferenceProvider implements WireFormatProvider } public Interceptor createInterceptor() { - return new WireFormatJMSDefaultReferenceInterceptor(registry, (JMSBinding) binding, null, reference.getRuntimeWire(binding), inputWrapperMap, outputWrapperMap); + return new WireFormatJMSDefaultReferenceInterceptor(registry, null, endpointReference, inputWrapperMap, outputWrapperMap); } public String getPhase() { diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceInterceptor.java index 79b277ca57..d6ca95a79e 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceInterceptor.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceInterceptor.java @@ -36,7 +36,7 @@ import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; /** * Policy handler to handle PolicySet related to Logging with the QName {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy @@ -45,7 +45,7 @@ import org.apache.tuscany.sca.runtime.RuntimeWire; */ public class WireFormatJMSDefaultServiceInterceptor implements Interceptor { private Invoker next; - private RuntimeWire runtimeWire; + private RuntimeEndpoint endpoint; private JMSResourceFactory jmsResourceFactory; private JMSBinding jmsBinding; private DefaultMessageProcessor requestMessageProcessor; @@ -53,11 +53,11 @@ public class WireFormatJMSDefaultServiceInterceptor implements Interceptor { private HashMap<String,OMElement> inputWrapperMap; private HashMap<String, Boolean> outputWrapperMap; - public WireFormatJMSDefaultServiceInterceptor(ExtensionPointRegistry registry, JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire, HashMap<String, OMElement> inputWrapperMap, + public WireFormatJMSDefaultServiceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpoint endpoint, HashMap<String, OMElement> inputWrapperMap, HashMap<String, Boolean> outputWrapperMap) { super(); - this.jmsBinding = jmsBinding; - this.runtimeWire = runtimeWire; + this.jmsBinding = (JMSBinding) endpoint.getBinding(); + this.endpoint = endpoint; this.jmsResourceFactory = jmsResourceFactory; // Note the default processor doesn't follow the normal processor pattern // as it has to handle both text and bytes messages diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceProvider.java index 5b6bb57efc..85c775136c 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceProvider.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceProvider.java @@ -26,7 +26,7 @@ import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMFactory; import org.apache.axiom.om.OMNamespace; -import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.ComponentService; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory; @@ -42,27 +42,26 @@ import org.apache.tuscany.sca.interfacedef.util.ElementInfo; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; import org.apache.tuscany.sca.provider.WireFormatProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; /** * @version $Rev$ $Date$ */ public class WireFormatJMSDefaultServiceProvider implements WireFormatProvider { private ExtensionPointRegistry registry; - private RuntimeComponent component; - private RuntimeComponentService service; + private RuntimeEndpoint endpoint; + private ComponentService service; private JMSBinding binding; private JMSResourceFactory jmsResourceFactory; private InterfaceContract interfaceContract; private HashMap<String, OMElement> inputWrapperMap; private HashMap<String, Boolean> outputWrapperMap; - public WireFormatJMSDefaultServiceProvider(ExtensionPointRegistry registry, RuntimeComponent component, RuntimeComponentService service, Binding binding, JMSResourceFactory jmsResourceFactory) { + public WireFormatJMSDefaultServiceProvider(ExtensionPointRegistry registry, RuntimeEndpoint endpoint, JMSResourceFactory jmsResourceFactory) { super(); - this.component = component; - this.service = service; - this.binding = (JMSBinding) binding; + this.endpoint = endpoint; + this.binding = (JMSBinding) endpoint.getBinding(); + this.service = endpoint.getService(); this.jmsResourceFactory = jmsResourceFactory; this.inputWrapperMap = new HashMap<String, OMElement>(); @@ -92,7 +91,7 @@ public class WireFormatJMSDefaultServiceProvider implements WireFormatProvider { if (service.getInterfaceContract() != null && !isAsIs()) { WebServiceBindingFactory wsFactory = registry.getExtensionPoint(WebServiceBindingFactory.class); WebServiceBinding wsBinding = wsFactory.createWebServiceBinding(); - BindingWSDLGenerator.generateWSDL(component, service, wsBinding, registry, null); + BindingWSDLGenerator.generateWSDL(endpoint.getComponent(), service, wsBinding, registry, null); interfaceContract = wsBinding.getBindingInterfaceContract(); interfaceContract.getInterface().resetDataBinding(OMElement.class.getName()); @@ -181,7 +180,7 @@ public class WireFormatJMSDefaultServiceProvider implements WireFormatProvider { public Interceptor createInterceptor() { - return new WireFormatJMSDefaultServiceInterceptor(registry, binding, jmsResourceFactory, service.getRuntimeWire(binding), this.inputWrapperMap, this.outputWrapperMap); + return new WireFormatJMSDefaultServiceInterceptor(registry, jmsResourceFactory, endpoint, this.inputWrapperMap, this.outputWrapperMap); } public String getPhase() { diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectProviderFactory.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectProviderFactory.java index 47c6e42ad1..1e445f1b11 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectProviderFactory.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectProviderFactory.java @@ -19,14 +19,12 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.runtime; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSObject; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.provider.WireFormatProvider; import org.apache.tuscany.sca.provider.WireFormatProviderFactory; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * @version $Rev$ $Date$ @@ -41,18 +39,14 @@ public class WireFormatJMSObjectProviderFactory implements WireFormatProviderFac /** */ - public WireFormatProvider createReferenceWireFormatProvider(RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding) { - return new WireFormatJMSObjectReferenceProvider(registry, component, reference, binding); + public WireFormatProvider createReferenceWireFormatProvider(RuntimeEndpointReference endpointReference) { + return new WireFormatJMSObjectReferenceProvider(registry, endpointReference); } /** */ - public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component, - RuntimeComponentService service, - Binding binding) { - return new WireFormatJMSObjectServiceProvider(registry, component, service, binding); + public WireFormatProvider createServiceWireFormatProvider(RuntimeEndpoint endpoint) { + return new WireFormatJMSObjectServiceProvider(registry, endpoint); } /** diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceInterceptor.java index d22dd2b3c0..ec110ea0d2 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceInterceptor.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceInterceptor.java @@ -37,7 +37,7 @@ import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * @@ -46,7 +46,7 @@ import org.apache.tuscany.sca.runtime.RuntimeWire; public class WireFormatJMSObjectReferenceInterceptor implements Interceptor { private Invoker next; - private RuntimeWire runtimeWire; + private RuntimeEndpointReference endpointReference; private JMSResourceFactory jmsResourceFactory; private JMSBinding jmsBinding; private JMSMessageProcessor requestMessageProcessor; @@ -54,10 +54,10 @@ public class WireFormatJMSObjectReferenceInterceptor implements Interceptor { private HashMap<String, String> singleArgMap; - public WireFormatJMSObjectReferenceInterceptor(ExtensionPointRegistry registry, JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire, HashMap<String, String> hashMap) { + public WireFormatJMSObjectReferenceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpointReference endpointReference, HashMap<String, String> hashMap) { super(); - this.jmsBinding = jmsBinding; - this.runtimeWire = runtimeWire; + this.jmsBinding = (JMSBinding) endpointReference.getBinding(); + this.endpointReference = endpointReference; this.jmsResourceFactory = jmsResourceFactory; this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding); this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding); diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java index 6cc9b6cacb..44e59a0226 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java @@ -22,7 +22,7 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.runtime; import java.util.HashMap; import java.util.List; -import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.ComponentReference; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSObject; @@ -32,32 +32,28 @@ import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; import org.apache.tuscany.sca.provider.WireFormatProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * @version $Rev$ $Date$ */ public class WireFormatJMSObjectReferenceProvider implements WireFormatProvider { private ExtensionPointRegistry registry; - private RuntimeComponent component; - private RuntimeComponentReference reference; + private RuntimeEndpointReference endpointReference; private JMSBinding binding; private InterfaceContract interfaceContract; private HashMap<String,String> singleArgMap; //map of one arg operations, leave empty if wrapSingleInput is true public WireFormatJMSObjectReferenceProvider(ExtensionPointRegistry registry, - RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding) { + RuntimeEndpointReference endpointReference) { super(); this.registry = registry; - this.component = component; - this.reference = reference; - this.binding = (JMSBinding)binding; + this.endpointReference = endpointReference; + this.binding = (JMSBinding)endpointReference.getBinding(); this.singleArgMap = new HashMap<String,String>(); + ComponentReference reference = endpointReference.getReference(); // configure the reference based on this wire format @@ -104,9 +100,7 @@ public class WireFormatJMSObjectReferenceProvider implements WireFormatProvider } public Interceptor createInterceptor() { - return new WireFormatJMSObjectReferenceInterceptor(registry, binding, - null, - reference.getRuntimeWire(binding), this.singleArgMap); + return new WireFormatJMSObjectReferenceInterceptor(registry, null, endpointReference, this.singleArgMap); } public String getPhase() { diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceInterceptor.java index 32a0ff76ff..2adf8120c6 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceInterceptor.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceInterceptor.java @@ -34,7 +34,7 @@ import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; /** * Policy handler to handle PolicySet related to Logging with the QName @@ -44,7 +44,7 @@ import org.apache.tuscany.sca.runtime.RuntimeWire; */ public class WireFormatJMSObjectServiceInterceptor implements Interceptor { private Invoker next; - private RuntimeWire runtimeWire; + private RuntimeEndpoint endpoint; private JMSResourceFactory jmsResourceFactory; private JMSBinding jmsBinding; private JMSMessageProcessor requestMessageProcessor; @@ -52,11 +52,11 @@ public class WireFormatJMSObjectServiceInterceptor implements Interceptor { private HashMap<String,Class<?>> singleArgMap; private boolean wrapSingle; - public WireFormatJMSObjectServiceInterceptor(ExtensionPointRegistry registry, JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, - RuntimeWire runtimeWire, HashMap<String, Class<?>> singleArgMap, boolean wrapSingle) { + public WireFormatJMSObjectServiceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, + RuntimeEndpoint endpoint, HashMap<String, Class<?>> singleArgMap, boolean wrapSingle) { super(); - this.jmsBinding = jmsBinding; - this.runtimeWire = runtimeWire; + this.jmsBinding = (JMSBinding) endpoint.getBinding(); + this.endpoint = endpoint; this.jmsResourceFactory = jmsResourceFactory; this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding); this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding); diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java index 6bf1f1affb..2e50f27a47 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java @@ -23,7 +23,7 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.runtime; import java.util.HashMap; import java.util.List; -import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.ComponentService; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSObject; @@ -33,32 +33,27 @@ import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; import org.apache.tuscany.sca.provider.WireFormatProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; /** * @version $Rev$ $Date$ */ public class WireFormatJMSObjectServiceProvider implements WireFormatProvider { private ExtensionPointRegistry registry; - private RuntimeComponent component; - private RuntimeComponentService service; + private RuntimeEndpoint endpoint; private JMSBinding binding; private InterfaceContract interfaceContract; private HashMap<String,Class<?>> singleArgMap; private boolean wrapSingle = true; - public WireFormatJMSObjectServiceProvider(ExtensionPointRegistry registry, - RuntimeComponent component, - RuntimeComponentService service, - Binding binding) { + public WireFormatJMSObjectServiceProvider(ExtensionPointRegistry registry, RuntimeEndpoint endpoint) { super(); this.registry = registry; - this.component = component; - this.service = service; - this.binding = (JMSBinding)binding; + this.endpoint = endpoint; + this.binding = (JMSBinding)endpoint.getBinding(); this.singleArgMap = new HashMap<String,Class<?>>(); + ComponentService service = endpoint.getService(); // configure the service based on this wire format // currently maintaining the message processor structure which @@ -108,9 +103,8 @@ public class WireFormatJMSObjectServiceProvider implements WireFormatProvider { /** */ public Interceptor createInterceptor() { - - return new WireFormatJMSObjectServiceInterceptor(registry, (JMSBinding)binding, null,service.getRuntimeWire(binding), - this.singleArgMap, wrapSingle ); + + return new WireFormatJMSObjectServiceInterceptor(registry, null, endpoint, this.singleArgMap, wrapSingle); } /** diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextProviderFactory.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextProviderFactory.java index 76181c6ba1..e3522616c0 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextProviderFactory.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextProviderFactory.java @@ -19,14 +19,12 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmstext.runtime; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSText; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.provider.WireFormatProvider; import org.apache.tuscany.sca.provider.WireFormatProviderFactory; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * @version $Rev$ $Date$ @@ -41,18 +39,14 @@ public class WireFormatJMSTextProviderFactory implements WireFormatProviderFacto /** */ - public WireFormatProvider createReferenceWireFormatProvider(RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding) { - return new WireFormatJMSTextReferenceProvider(registry, component, reference, binding); + public WireFormatProvider createReferenceWireFormatProvider(RuntimeEndpointReference endpointReference) { + return new WireFormatJMSTextReferenceProvider(registry, endpointReference); } /** */ - public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component, - RuntimeComponentService service, - Binding binding) { - return new WireFormatJMSTextServiceProvider(registry, component, service, binding); + public WireFormatProvider createServiceWireFormatProvider(RuntimeEndpoint endpoint) { + return new WireFormatJMSTextServiceProvider(registry, endpoint); } /** diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceInterceptor.java index 9cc700940c..fd512f7d27 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceInterceptor.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceInterceptor.java @@ -35,7 +35,7 @@ import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * @@ -44,16 +44,16 @@ import org.apache.tuscany.sca.runtime.RuntimeWire; public class WireFormatJMSTextReferenceInterceptor implements Interceptor { private Invoker next; - private RuntimeWire runtimeWire; + private RuntimeEndpointReference endpointReference; private JMSResourceFactory jmsResourceFactory; private JMSBinding jmsBinding; private JMSMessageProcessor requestMessageProcessor; private JMSMessageProcessor responseMessageProcessor; - public WireFormatJMSTextReferenceInterceptor(ExtensionPointRegistry registry, JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) { + public WireFormatJMSTextReferenceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpointReference endpointReference) { super(); - this.jmsBinding = jmsBinding; - this.runtimeWire = runtimeWire; + this.jmsBinding = (JMSBinding) endpointReference.getBinding(); + this.endpointReference = endpointReference; this.jmsResourceFactory = jmsResourceFactory; this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding); this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding); diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceProvider.java index 6bfe165def..5baffd48dd 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceProvider.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceProvider.java @@ -20,7 +20,6 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmstext.runtime; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSText; @@ -29,28 +28,23 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; import org.apache.tuscany.sca.provider.WireFormatProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * @version $Rev$ $Date$ */ public class WireFormatJMSTextReferenceProvider implements WireFormatProvider { private ExtensionPointRegistry registry; - private RuntimeComponent component; - private RuntimeComponentReference reference; + private RuntimeEndpointReference endpointReference; private JMSBinding binding; private InterfaceContract interfaceContract; public WireFormatJMSTextReferenceProvider(ExtensionPointRegistry registry, - RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding) { + RuntimeEndpointReference endpointReference) { super(); this.registry = registry; - this.component = component; - this.reference = reference; - this.binding = (JMSBinding)binding; + this.endpointReference = endpointReference; + this.binding = (JMSBinding)endpointReference.getBinding(); // configure the reference based on this wire format @@ -74,7 +68,7 @@ public class WireFormatJMSTextReferenceProvider implements WireFormatProvider { // just point to the reference interface contract so no // databinding transformation takes place - interfaceContract = reference.getReference().getInterfaceContract(); + interfaceContract = endpointReference.getReference().getReference().getInterfaceContract(); } public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){ @@ -94,9 +88,7 @@ public class WireFormatJMSTextReferenceProvider implements WireFormatProvider { } public Interceptor createInterceptor() { - return new WireFormatJMSTextReferenceInterceptor(registry, binding, - null, - reference.getRuntimeWire(binding)); + return new WireFormatJMSTextReferenceInterceptor(registry, null, endpointReference); } public String getPhase() { diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceInterceptor.java index ab2d025af5..dc3b97e261 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceInterceptor.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceInterceptor.java @@ -31,7 +31,7 @@ import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; /** * Policy handler to handle PolicySet related to Logging with the QName @@ -41,16 +41,16 @@ import org.apache.tuscany.sca.runtime.RuntimeWire; */ public class WireFormatJMSTextServiceInterceptor implements Interceptor { private Invoker next; - private RuntimeWire runtimeWire; + private RuntimeEndpoint endpoint; private JMSResourceFactory jmsResourceFactory; private JMSBinding jmsBinding; private JMSMessageProcessor requestMessageProcessor; private JMSMessageProcessor responseMessageProcessor; - public WireFormatJMSTextServiceInterceptor(ExtensionPointRegistry registry, JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) { + public WireFormatJMSTextServiceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpoint endpoint) { super(); - this.jmsBinding = jmsBinding; - this.runtimeWire = runtimeWire; + this.jmsBinding = (JMSBinding) endpoint.getBinding(); + this.endpoint = endpoint; this.jmsResourceFactory = jmsResourceFactory; this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding); this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding); diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceProvider.java index 40462bf525..f4ee1226c5 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceProvider.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceProvider.java @@ -19,7 +19,6 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmstext.runtime; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSText; @@ -28,28 +27,23 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; import org.apache.tuscany.sca.provider.WireFormatProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; /** * @version $Rev$ $Date$ */ public class WireFormatJMSTextServiceProvider implements WireFormatProvider { private ExtensionPointRegistry registry; - private RuntimeComponent component; - private RuntimeComponentService service; + private RuntimeEndpoint endpoint; private JMSBinding binding; private InterfaceContract interfaceContract; public WireFormatJMSTextServiceProvider(ExtensionPointRegistry registry, - RuntimeComponent component, - RuntimeComponentService service, - Binding binding) { + RuntimeEndpoint endpoint) { super(); this.registry = registry; - this.component = component; - this.service = service; - this.binding = (JMSBinding)binding; + this.endpoint = endpoint; + this.binding = (JMSBinding)endpoint.getBinding(); // configure the service based on this wire format @@ -72,7 +66,7 @@ public class WireFormatJMSTextServiceProvider implements WireFormatProvider { // just point to the reference interface contract so no // databinding transformation takes place - interfaceContract = service.getService().getInterfaceContract(); + interfaceContract = endpoint.getService().getService().getInterfaceContract(); } public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){ @@ -94,9 +88,7 @@ public class WireFormatJMSTextServiceProvider implements WireFormatProvider { /** */ public Interceptor createInterceptor() { - return new WireFormatJMSTextServiceInterceptor(registry, (JMSBinding)binding, - null, - service.getRuntimeWire(binding)); + return new WireFormatJMSTextServiceInterceptor(registry, null, endpoint); } /** diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLProviderFactory.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLProviderFactory.java index 3fe0e66722..fb119078d1 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLProviderFactory.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLProviderFactory.java @@ -19,7 +19,6 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.runtime; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory; import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactoryExtensionPoint; @@ -27,9 +26,8 @@ import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSTextXML; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.provider.WireFormatProvider; import org.apache.tuscany.sca.provider.WireFormatProviderFactory; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * @version $Rev$ $Date$ @@ -46,19 +44,15 @@ public class WireFormatJMSTextXMLProviderFactory implements WireFormatProviderFa /** */ - public WireFormatProvider createReferenceWireFormatProvider(RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding) { - return new WireFormatJMSTextXMLReferenceProvider(registry, component, reference, binding); + public WireFormatProvider createReferenceWireFormatProvider(RuntimeEndpointReference endpointReference) { + return new WireFormatJMSTextXMLReferenceProvider(registry, endpointReference); } /** */ - public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component, - RuntimeComponentService service, - Binding binding) { - JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory((JMSBinding)binding); - return new WireFormatJMSTextXMLServiceProvider(registry, component, service, binding, jmsRF); + public WireFormatProvider createServiceWireFormatProvider(RuntimeEndpoint endpoint) { + JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory((JMSBinding)endpoint.getBinding()); + return new WireFormatJMSTextXMLServiceProvider(registry, endpoint, jmsRF); } /** diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceInterceptor.java index 5c3675eb19..4d62022196 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceInterceptor.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceInterceptor.java @@ -38,7 +38,7 @@ import org.apache.tuscany.sca.interfacedef.util.FaultException; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; import org.w3c.dom.Node; /** @@ -48,16 +48,17 @@ import org.w3c.dom.Node; public class WireFormatJMSTextXMLReferenceInterceptor implements Interceptor { private Invoker next; - private RuntimeWire runtimeWire; + private RuntimeEndpointReference endpointReference; private JMSResourceFactory jmsResourceFactory; private JMSBinding jmsBinding; private JMSMessageProcessor requestMessageProcessor; private JMSMessageProcessor responseMessageProcessor; - public WireFormatJMSTextXMLReferenceInterceptor(ExtensionPointRegistry registry, JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) { + + public WireFormatJMSTextXMLReferenceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpointReference endpointReference) { super(); - this.jmsBinding = jmsBinding; - this.runtimeWire = runtimeWire; + this.jmsBinding = (JMSBinding) endpointReference.getBinding(); + this.endpointReference = endpointReference; this.jmsResourceFactory = jmsResourceFactory; this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding); this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding); diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.java index e1185832d0..957994a146 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.java @@ -19,7 +19,6 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.runtime; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSTextXML; @@ -32,28 +31,23 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; import org.apache.tuscany.sca.provider.WireFormatProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * @version $Rev$ $Date$ */ public class WireFormatJMSTextXMLReferenceProvider implements WireFormatProvider { private ExtensionPointRegistry registry; - private RuntimeComponent component; - private RuntimeComponentReference reference; + private RuntimeEndpointReference endpointReference; private JMSBinding binding; private InterfaceContract interfaceContract; public WireFormatJMSTextXMLReferenceProvider(ExtensionPointRegistry registry, - RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding) { + RuntimeEndpointReference endpointReference) { super(); this.registry = registry; - this.component = component; - this.reference = reference; - this.binding = (JMSBinding)binding; + this.endpointReference = endpointReference; + this.binding = (JMSBinding)endpointReference.getBinding(); // configure the reference based on this wire format @@ -75,13 +69,13 @@ public class WireFormatJMSTextXMLReferenceProvider implements WireFormatProvider // as required WebServiceBindingFactory wsFactory = registry.getExtensionPoint(WebServiceBindingFactory.class); WebServiceBinding wsBinding = wsFactory.createWebServiceBinding(); - BindingWSDLGenerator.generateWSDL(component, reference, wsBinding, registry, null); + BindingWSDLGenerator.generateWSDL(endpointReference.getComponent(), endpointReference.getReference(), wsBinding, registry, null); interfaceContract = wsBinding.getBindingInterfaceContract(); interfaceContract.getInterface().resetDataBinding(DOMDataBinding.NAME); } protected boolean isOnMessage() { - InterfaceContract ic = reference.getInterfaceContract(); + InterfaceContract ic = endpointReference.getReference().getInterfaceContract(); if (ic.getInterface().getOperations().size() != 1) { return false; } @@ -105,7 +99,7 @@ public class WireFormatJMSTextXMLReferenceProvider implements WireFormatProvider } public Interceptor createInterceptor() { - return new WireFormatJMSTextXMLReferenceInterceptor(registry, (JMSBinding)binding, null, reference.getRuntimeWire(binding)); + return new WireFormatJMSTextXMLReferenceInterceptor(registry, null, endpointReference); } public String getPhase() { diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceInterceptor.java index 8c529eddc2..a5fda4be56 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceInterceptor.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceInterceptor.java @@ -31,7 +31,7 @@ import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; /** * Policy handler to handle PolicySet related to Logging with the QName @@ -41,16 +41,16 @@ import org.apache.tuscany.sca.runtime.RuntimeWire; */ public class WireFormatJMSTextXMLServiceInterceptor implements Interceptor { private Invoker next; - private RuntimeWire runtimeWire; + private RuntimeEndpoint endpoint; private JMSResourceFactory jmsResourceFactory; private JMSBinding jmsBinding; private JMSMessageProcessor requestMessageProcessor; private JMSMessageProcessor responseMessageProcessor; - public WireFormatJMSTextXMLServiceInterceptor(ExtensionPointRegistry registry, JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) { + public WireFormatJMSTextXMLServiceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpoint endpoint) { super(); - this.jmsBinding = jmsBinding; - this.runtimeWire = runtimeWire; + this.jmsBinding = (JMSBinding) endpoint.getBinding(); + this.endpoint = endpoint; this.jmsResourceFactory = jmsResourceFactory; this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding); this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding); diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java index a9d49c1742..c56a9e0e50 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java @@ -19,7 +19,6 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.runtime; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory; @@ -33,29 +32,24 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; import org.apache.tuscany.sca.provider.WireFormatProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; /** * @version $Rev$ $Date$ */ public class WireFormatJMSTextXMLServiceProvider implements WireFormatProvider { private ExtensionPointRegistry registry; - private RuntimeComponent component; - private RuntimeComponentService service; + private RuntimeEndpoint endpoint; private JMSBinding binding; private JMSResourceFactory jmsResourceFactory; private InterfaceContract interfaceContract; public WireFormatJMSTextXMLServiceProvider(ExtensionPointRegistry registry, - RuntimeComponent component, - RuntimeComponentService service, - Binding binding, + RuntimeEndpoint endpoint, JMSResourceFactory jmsResourceFactory) { super(); - this.component = component; - this.service = service; - this.binding = (JMSBinding)binding; + this.endpoint = endpoint; + this.binding = (JMSBinding)endpoint.getBinding(); this.jmsResourceFactory = jmsResourceFactory; this.registry = registry; @@ -78,7 +72,7 @@ public class WireFormatJMSTextXMLServiceProvider implements WireFormatProvider { // as required WebServiceBindingFactory wsFactory = registry.getExtensionPoint(WebServiceBindingFactory.class); WebServiceBinding wsBinding = wsFactory.createWebServiceBinding(); - BindingWSDLGenerator.generateWSDL(component, service, wsBinding, registry, null); + BindingWSDLGenerator.generateWSDL(endpoint.getComponent(), endpoint.getService(), wsBinding, registry, null); interfaceContract = wsBinding.getBindingInterfaceContract(); interfaceContract.getInterface().resetDataBinding(DOMDataBinding.NAME); } @@ -100,9 +94,7 @@ public class WireFormatJMSTextXMLServiceProvider implements WireFormatProvider { } public Interceptor createInterceptor() { - return new WireFormatJMSTextXMLServiceInterceptor(registry, (JMSBinding)binding, - jmsResourceFactory, - service.getRuntimeWire(binding)); + return new WireFormatJMSTextXMLServiceInterceptor(registry, jmsResourceFactory, endpoint); } public String getPhase() { diff --git a/java/sca/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPBindingProviderFactory.java b/java/sca/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPBindingProviderFactory.java index 90daedb647..fa5afa0189 100644 --- a/java/sca/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPBindingProviderFactory.java +++ b/java/sca/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPBindingProviderFactory.java @@ -21,8 +21,6 @@ package org.apache.tuscany.sca.binding.jsonp.runtime; import java.util.List; -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.binding.jsonp.JSONPBinding; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.host.http.ServletHost; @@ -30,6 +28,8 @@ import org.apache.tuscany.sca.host.http.ServletHostExtensionPoint; import org.apache.tuscany.sca.provider.BindingProviderFactory; import org.apache.tuscany.sca.provider.ReferenceBindingProvider; import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; public class JSONPBindingProviderFactory implements BindingProviderFactory<JSONPBinding> { @@ -47,11 +47,11 @@ public class JSONPBindingProviderFactory implements BindingProviderFactory<JSONP return JSONPBinding.class; } - public ReferenceBindingProvider createReferenceBindingProvider(EndpointReference endpoint) { + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpoint) { return new JSONPReferenceBindingProvider(endpoint); } - public ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint) { + public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) { return new JSONPServiceBindingProvider(endpoint, servletHost); } diff --git a/java/sca/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServiceBindingProvider.java b/java/sca/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServiceBindingProvider.java index 4257cc72e2..4e3f7321af 100644 --- a/java/sca/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServiceBindingProvider.java +++ b/java/sca/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServiceBindingProvider.java @@ -20,31 +20,28 @@ package org.apache.tuscany.sca.binding.jsonp.runtime; import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.host.http.ServletHost; import org.apache.tuscany.sca.interfacedef.Interface; import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.provider.ServiceBindingProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; public class JSONPServiceBindingProvider implements ServiceBindingProvider { - private Endpoint endpoint; + private RuntimeEndpoint endpoint; private ServletHost servletHost; - public JSONPServiceBindingProvider(Endpoint endpoint, ServletHost servletHost) { + public JSONPServiceBindingProvider(RuntimeEndpoint endpoint, ServletHost servletHost) { this.endpoint = endpoint; this.servletHost = servletHost; } public void start() { ComponentService service = endpoint.getService(); - RuntimeWire wire = ((RuntimeComponentService)service).getRuntimeWire(endpoint.getBinding()); Interface serviceInterface = service.getInterfaceContract().getInterface(); for (Operation op : serviceInterface.getOperations()) { - JSONPServlet servlet = new JSONPServlet(wire, op); + JSONPServlet servlet = new JSONPServlet(endpoint, op); String path = endpoint.getBinding().getURI() + "/" + op.getName(); servletHost.addServletMapping(path, servlet); } diff --git a/java/sca/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServlet.java b/java/sca/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServlet.java index edacc2d374..b782875948 100644 --- a/java/sca/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServlet.java +++ b/java/sca/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServlet.java @@ -36,7 +36,7 @@ import javax.servlet.http.HttpServletRequest; import org.apache.tuscany.sca.interfacedef.DataType; import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; import org.codehaus.jackson.JsonParseException; import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.ObjectMapper; @@ -44,11 +44,11 @@ import org.codehaus.jackson.map.ObjectMapper; public class JSONPServlet extends GenericServlet { private static final long serialVersionUID = 1L; - protected transient RuntimeWire wire; + protected transient RuntimeEndpoint wire; protected transient Operation operation; protected transient ObjectMapper mapper; - public JSONPServlet(RuntimeWire wire, Operation operation) { + public JSONPServlet(RuntimeEndpoint wire, Operation operation) { this.wire = wire; this.operation = operation; this.mapper = new ObjectMapper(); diff --git a/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingProviderFactory.java b/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingProviderFactory.java index 4059d5a1f0..2a1fa8ba6b 100644 --- a/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingProviderFactory.java +++ b/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingProviderFactory.java @@ -19,8 +19,6 @@ package org.apache.tuscany.sca.binding.jsonrpc.provider; -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBinding; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.FactoryExtensionPoint; @@ -30,6 +28,8 @@ import org.apache.tuscany.sca.invocation.MessageFactory; import org.apache.tuscany.sca.provider.BindingProviderFactory; import org.apache.tuscany.sca.provider.ReferenceBindingProvider; import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * JSON-RPC Provider Factory @@ -49,12 +49,12 @@ public class JSONRPCBindingProviderFactory implements BindingProviderFactory<JSO messageFactory = modelFactories.getFactory(MessageFactory.class); } - public ReferenceBindingProvider createReferenceBindingProvider(EndpointReference endpointReference) { + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) { return new JSONRPCReferenceBindingProvider(endpointReference); } - public ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint) { + public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) { return new JSONRPCServiceBindingProvider(endpoint, messageFactory, servletHost); } diff --git a/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java b/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java index dca4965378..1ab46aaff6 100644 --- a/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java +++ b/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java @@ -22,9 +22,7 @@ package org.apache.tuscany.sca.binding.jsonrpc.provider; import java.util.ArrayList; import java.util.List; -import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBinding; -import org.apache.tuscany.sca.databinding.json.JSONDataBinding; import org.apache.tuscany.sca.host.http.ServletHost; import org.apache.tuscany.sca.interfacedef.Interface; import org.apache.tuscany.sca.interfacedef.InterfaceContract; @@ -33,6 +31,7 @@ import org.apache.tuscany.sca.invocation.MessageFactory; import org.apache.tuscany.sca.provider.ServiceBindingProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; /** @@ -43,7 +42,7 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentService; public class JSONRPCServiceBindingProvider implements ServiceBindingProvider { private MessageFactory messageFactory; - private Endpoint endpoint; + private RuntimeEndpoint endpoint; private RuntimeComponent component; private RuntimeComponentService service; private InterfaceContract serviceContract; @@ -51,7 +50,7 @@ public class JSONRPCServiceBindingProvider implements ServiceBindingProvider { private ServletHost servletHost; private List<String> servletMappings = new ArrayList<String>(); - public JSONRPCServiceBindingProvider(Endpoint endpoint, + public JSONRPCServiceBindingProvider(RuntimeEndpoint endpoint, MessageFactory messageFactory, ServletHost servletHost) { this.endpoint = endpoint; @@ -72,7 +71,7 @@ public class JSONRPCServiceBindingProvider implements ServiceBindingProvider { } public InterfaceContract getBindingInterfaceContract() { - return service.getInterfaceContract(); + return serviceContract; } public boolean supportsOneWayInvocation() { @@ -81,7 +80,7 @@ public class JSONRPCServiceBindingProvider implements ServiceBindingProvider { public void start() { // Set default databinding to json - serviceContract.getInterface().resetDataBinding(JSONDataBinding.NAME); + // serviceContract.getInterface().resetDataBinding(JSONDataBinding.NAME); // Determine the service business interface Class<?> serviceInterface = getTargetJavaClass(serviceContract.getInterface()); @@ -91,7 +90,7 @@ public class JSONRPCServiceBindingProvider implements ServiceBindingProvider { // Create and register a Servlet for this service JSONRPCServiceServlet serviceServlet = - new JSONRPCServiceServlet(messageFactory, binding, service, serviceContract, serviceInterface, proxy); + new JSONRPCServiceServlet(messageFactory, endpoint, serviceInterface, proxy); String mapping = binding.getURI(); if (!mapping.endsWith("/")) { mapping += "/"; diff --git a/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java b/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java index 71d335acc8..9034e24485 100644 --- a/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java +++ b/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java @@ -32,12 +32,10 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Message; import org.apache.tuscany.sca.invocation.MessageFactory; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; import org.jabsorb.JSONRPCBridge; import org.jabsorb.JSONRPCResult; import org.jabsorb.JSONRPCServlet; @@ -61,21 +59,17 @@ public class JSONRPCServiceServlet extends JSONRPCServlet { transient Binding binding; transient String serviceName; transient Object serviceInstance; - transient RuntimeComponentService componentService; - transient InterfaceContract serviceContract; + transient RuntimeEndpoint endpoint; transient Class<?> serviceInterface; public JSONRPCServiceServlet(MessageFactory messageFactory, - Binding binding, - RuntimeComponentService componentService, - InterfaceContract serviceContract, + RuntimeEndpoint endpoint, Class<?> serviceInterface, Object serviceInstance) { + this.endpoint = endpoint; this.messageFactory = messageFactory; - this.binding = binding; + this.binding = endpoint.getBinding(); this.serviceName = binding.getName(); - this.componentService = componentService; - this.serviceContract = serviceContract; this.serviceInterface = serviceInterface; this.serviceInstance = serviceInstance; } @@ -238,7 +232,6 @@ public class JSONRPCServiceServlet extends JSONRPCServlet { } // invoke the request - RuntimeWire wire = componentService.getRuntimeWire(binding, serviceContract); Operation jsonOperation = findOperation(method); Object result = null; @@ -254,7 +247,7 @@ public class JSONRPCServiceServlet extends JSONRPCServlet { //result = wire.invoke(jsonOperation, args); Message responseMessage = null; try { - responseMessage = wire.getInvocationChain(jsonOperation).getHeadInvoker().invoke(requestMessage); + responseMessage = endpoint.getInvocationChain(jsonOperation).getHeadInvoker().invoke(requestMessage); } catch (RuntimeException re) { if (re.getCause() instanceof javax.security.auth.login.LoginException) { throw re; @@ -297,7 +290,7 @@ public class JSONRPCServiceServlet extends JSONRPCServlet { method = method.substring(method.lastIndexOf(".") + 1); } - List<Operation> operations = serviceContract.getInterface().getOperations(); + List<Operation> operations = endpoint.getServiceInterfaceContract().getInterface().getOperations(); //componentService.getBindingProvider(binding).getBindingInterfaceContract().getInterface().getOperations(); diff --git a/java/sca/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingProviderFactory.java b/java/sca/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingProviderFactory.java index 113577b5ee..d812a943ce 100644 --- a/java/sca/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingProviderFactory.java +++ b/java/sca/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingProviderFactory.java @@ -19,8 +19,6 @@ package org.apache.tuscany.sca.binding.rmi.provider; -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.binding.rmi.RMIBinding; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.host.rmi.ExtensibleRMIHost; @@ -32,6 +30,8 @@ import org.apache.tuscany.sca.provider.ServiceBindingProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * RMI Binding Provider Factory @@ -47,12 +47,12 @@ public class RMIBindingProviderFactory implements BindingProviderFactory<RMIBind this.rmiHost = new ExtensibleRMIHost(rmiHosts); } - public ReferenceBindingProvider createReferenceBindingProvider(EndpointReference endpointReference) { + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) { return new RMIReferenceBindingProvider(endpointReference, rmiHost); } - public ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint) { + public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) { return new RMIServiceBindingProvider(endpoint, rmiHost); } diff --git a/java/sca/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIServiceBindingProvider.java b/java/sca/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIServiceBindingProvider.java index d185780ed8..2dbdbea67b 100644 --- a/java/sca/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIServiceBindingProvider.java +++ b/java/sca/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIServiceBindingProvider.java @@ -32,8 +32,6 @@ import net.sf.cglib.proxy.Enhancer; import net.sf.cglib.proxy.MethodInterceptor; import net.sf.cglib.proxy.MethodProxy; -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.SCABinding; import org.apache.tuscany.sca.binding.rmi.RMIBinding; import org.apache.tuscany.sca.common.java.classloader.ClassLoaderDelegate; import org.apache.tuscany.sca.host.rmi.RMIHost; @@ -46,7 +44,7 @@ import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil; import org.apache.tuscany.sca.provider.ServiceBindingProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; import org.oasisopen.sca.ServiceRuntimeException; /** @@ -60,10 +58,11 @@ public class RMIServiceBindingProvider implements ServiceBindingProvider { private RuntimeComponentService service; private RMIBinding binding; private RMIHost rmiHost; - private RuntimeWire wire; + private RuntimeEndpoint endpoint; private Remote rmiProxy; - public RMIServiceBindingProvider(Endpoint endpoint, RMIHost rmiHost) { + public RMIServiceBindingProvider(RuntimeEndpoint endpoint, RMIHost rmiHost) { + this.endpoint = endpoint; this.component = (RuntimeComponent)endpoint.getComponent(); this.service = (RuntimeComponentService)endpoint.getService(); this.binding = (RMIBinding)endpoint.getBinding(); @@ -71,23 +70,6 @@ public class RMIServiceBindingProvider implements ServiceBindingProvider { } public void start() { - // URI uri = URI.create(component.getURI() + "/" + binding.getName()); - // binding.setURI(uri.toString()); - - wire = service.getRuntimeWire(binding); - - // TODO - must be a better way to do this, which is copied from the Axis2ServiceProvider - // TODO - EPR - if there is no wire then find the wire for the SCA binding - // because this WS endpoint is providing remote support for the - // SCA binding - if (wire == null){ - for(RuntimeWire tmpWire : service.getRuntimeWires()){ - if (tmpWire.getEndpoint().getBinding() instanceof SCABinding){ - wire = tmpWire; - break; - } - } - } Interface serviceInterface = service.getInterfaceContract().getInterface(); @@ -162,7 +144,7 @@ public class RMIServiceBindingProvider implements ServiceBindingProvider { } private Object invokeTarget(Operation op, Object[] args) throws InvocationTargetException { - return wire.invoke(op, args); + return endpoint.invoke(op, args); } private Class<?> getTargetJavaClass(Interface targetInterface) { diff --git a/java/sca/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCABindingProviderFactory.java b/java/sca/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCABindingProviderFactory.java index 4e3f6d82e7..5c7cd495e8 100644 --- a/java/sca/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCABindingProviderFactory.java +++ b/java/sca/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCABindingProviderFactory.java @@ -20,8 +20,6 @@ package org.apache.tuscany.sca.binding.sca.axis2.impl; import org.apache.tuscany.sca.assembly.DistributedSCABinding; -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.provider.BindingProviderFactory; import org.apache.tuscany.sca.provider.ReferenceBindingProvider; @@ -29,6 +27,8 @@ import org.apache.tuscany.sca.provider.ServiceBindingProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * The factory for the Axis2 based implementation of the distributed sca binding @@ -43,11 +43,11 @@ public class Axis2SCABindingProviderFactory implements BindingProviderFactory<Di this.extensionPoints = extensionPoints; } - public ReferenceBindingProvider createReferenceBindingProvider(EndpointReference endpointReference) { + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) { return new Axis2SCAReferenceBindingProvider(endpointReference, extensionPoints); } - public ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint) { + public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) { return new Axis2SCAServiceBindingProvider(endpoint, extensionPoints); } diff --git a/java/sca/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java b/java/sca/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java index 77ec50b097..f13c91e09c 100644 --- a/java/sca/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java +++ b/java/sca/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java @@ -39,6 +39,7 @@ import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint; import org.apache.tuscany.sca.provider.ReferenceBindingProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * The reference binding provider for the remote sca binding implementation. Relies on the @@ -78,9 +79,9 @@ public class Axis2SCAReferenceBindingProvider implements ReferenceBindingProvide contract.getInterface().resetDataBinding(OMElement.class.getName()); // create a copy of the endpoint reference but with the web service binding in - EndpointReference epr = null; + RuntimeEndpointReference epr = null; try { - epr = (EndpointReference)endpointReference.clone(); + epr = (RuntimeEndpointReference)endpointReference.clone(); } catch (Exception ex){ // we know we can clone endpoint references } diff --git a/java/sca/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAServiceBindingProvider.java b/java/sca/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAServiceBindingProvider.java index b6b98b6b5f..05cdc20f40 100644 --- a/java/sca/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAServiceBindingProvider.java +++ b/java/sca/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAServiceBindingProvider.java @@ -44,6 +44,7 @@ import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint; import org.apache.tuscany.sca.provider.ServiceBindingProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; /** * The service binding provider for the remote sca binding implementation. Relies on the @@ -115,9 +116,9 @@ public class Axis2SCAServiceBindingProvider implements ServiceBindingProvider { contract.getInterface().resetDataBinding(OMElement.class.getName()); // create a copy of the endpoint but with the web service binding in - Endpoint ep = null; + RuntimeEndpoint ep = null; try { - ep = (Endpoint)endpoint.clone(); + ep = (RuntimeEndpoint)endpoint.clone(); } catch (Exception ex){ // we know we can clone endpoint references } diff --git a/java/sca/modules/binding-sca-runtime-rmi/src/main/java/org/apache/tuscany/sca/binding/sca/rmi/RMISCABindingProviderFactory.java b/java/sca/modules/binding-sca-runtime-rmi/src/main/java/org/apache/tuscany/sca/binding/sca/rmi/RMISCABindingProviderFactory.java index 6ac5eef4e7..e1f700fa51 100644 --- a/java/sca/modules/binding-sca-runtime-rmi/src/main/java/org/apache/tuscany/sca/binding/sca/rmi/RMISCABindingProviderFactory.java +++ b/java/sca/modules/binding-sca-runtime-rmi/src/main/java/org/apache/tuscany/sca/binding/sca/rmi/RMISCABindingProviderFactory.java @@ -20,12 +20,12 @@ package org.apache.tuscany.sca.binding.sca.rmi;
import org.apache.tuscany.sca.assembly.DistributedSCABinding;
-import org.apache.tuscany.sca.assembly.Endpoint;
-import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.provider.BindingProviderFactory;
import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
/**
* The factory for the RMI based implementation of the distributed sca binding
@@ -38,11 +38,11 @@ public class RMISCABindingProviderFactory implements BindingProviderFactory<Dist this.extensionPoints = extensionPoints;
}
- public ReferenceBindingProvider createReferenceBindingProvider(EndpointReference endpointReference) {
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) {
return new RMISCAReferenceBindingProvider(endpointReference, extensionPoints);
}
- public ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint) {
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
return new RMISCAServiceBindingProvider(endpoint, extensionPoints);
}
diff --git a/java/sca/modules/binding-sca-runtime-rmi/src/main/java/org/apache/tuscany/sca/binding/sca/rmi/RMISCAReferenceBindingProvider.java b/java/sca/modules/binding-sca-runtime-rmi/src/main/java/org/apache/tuscany/sca/binding/sca/rmi/RMISCAReferenceBindingProvider.java index 6773b3b1d2..154aca8f53 100644 --- a/java/sca/modules/binding-sca-runtime-rmi/src/main/java/org/apache/tuscany/sca/binding/sca/rmi/RMISCAReferenceBindingProvider.java +++ b/java/sca/modules/binding-sca-runtime-rmi/src/main/java/org/apache/tuscany/sca/binding/sca/rmi/RMISCAReferenceBindingProvider.java @@ -34,6 +34,7 @@ import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.provider.BindingProviderFactory;
import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
/**
* The reference binding provider for the remote sca binding implementation. Relies on the
@@ -60,9 +61,9 @@ public class RMISCAReferenceBindingProvider implements ReferenceBindingProvider rmiBinding.setURI(this.binding.getURI());
// create a copy of the endpoint reference but with the RMI binding in
- EndpointReference epr = null;
+ RuntimeEndpointReference epr = null;
try {
- epr = (EndpointReference)endpointReference.clone();
+ epr = (RuntimeEndpointReference)endpointReference.clone();
} catch (Exception ex){
// we know we can clone endpoint references
}
@@ -72,6 +73,8 @@ public class RMISCAReferenceBindingProvider implements ReferenceBindingProvider ProviderFactoryExtensionPoint providerFactories = extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
BindingProviderFactory<?> providerFactory = (BindingProviderFactory<?>)providerFactories.getProviderFactory(RMIBinding.class);
referenceBindingProvider = providerFactory.createReferenceBindingProvider(epr);
+ // Set the reference binding provider so that it can be used to start/stop
+ ((RuntimeEndpointReference) endpointReference).setBindingProvider(referenceBindingProvider);
logger.info("Reference using RMI SCA Binding: " + rmiBinding.getURI());
}
diff --git a/java/sca/modules/binding-sca-runtime-rmi/src/main/java/org/apache/tuscany/sca/binding/sca/rmi/RMISCAServiceBindingProvider.java b/java/sca/modules/binding-sca-runtime-rmi/src/main/java/org/apache/tuscany/sca/binding/sca/rmi/RMISCAServiceBindingProvider.java index f3e60be83d..f230926183 100644 --- a/java/sca/modules/binding-sca-runtime-rmi/src/main/java/org/apache/tuscany/sca/binding/sca/rmi/RMISCAServiceBindingProvider.java +++ b/java/sca/modules/binding-sca-runtime-rmi/src/main/java/org/apache/tuscany/sca/binding/sca/rmi/RMISCAServiceBindingProvider.java @@ -37,6 +37,7 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.provider.BindingProviderFactory;
import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
/**
* The service binding provider for the remote sca binding implementation. Relies on the
@@ -88,9 +89,9 @@ public class RMISCAServiceBindingProvider implements ServiceBindingProvider { rmiBinding.setURI(this.binding.getURI());
// create a copy of the endpoint but with the web service binding in
- Endpoint ep = null;
+ RuntimeEndpoint ep = null;
try {
- ep = (Endpoint)endpoint.clone();
+ ep = (RuntimeEndpoint)endpoint.clone();
} catch (Exception ex){
// we know we can clone endpoint references
}
@@ -100,6 +101,9 @@ public class RMISCAServiceBindingProvider implements ServiceBindingProvider { BindingProviderFactory<?> providerFactory = (BindingProviderFactory<?>) providerFactories.getProviderFactory(RMIBinding.class);
serviceBindingProvider = providerFactory.createServiceBindingProvider(ep);
+ // Set the service binding provider so that it can be used to start/stop
+ ((RuntimeEndpoint) endpoint).setBindingProvider(serviceBindingProvider);
+
logger.info("Service using RMI SCA Binding: " + rmiBinding.getURI());
}
diff --git a/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCABindingProviderFactory.java b/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCABindingProviderFactory.java index 110d15a1cf..c3bf2506cc 100644 --- a/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCABindingProviderFactory.java +++ b/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCABindingProviderFactory.java @@ -19,8 +19,6 @@ package org.apache.tuscany.sca.binding.sca.provider; -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.assembly.SCABinding; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.provider.BindingProviderFactory; @@ -29,6 +27,8 @@ import org.apache.tuscany.sca.provider.ServiceBindingProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * The factory for creating SCA Binding providers @@ -44,12 +44,12 @@ public class RuntimeSCABindingProviderFactory implements BindingProviderFactory< } - public ReferenceBindingProvider createReferenceBindingProvider(EndpointReference endpointReference) { + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) { return new RuntimeSCAReferenceBindingProvider(extensionPoints, endpointReference); } - public ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint) { + public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) { return new RuntimeSCAServiceBindingProvider(extensionPoints, endpoint); } diff --git a/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java b/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java index 2679b88dd1..f72c58287d 100644 --- a/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java +++ b/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java @@ -19,13 +19,10 @@ package org.apache.tuscany.sca.binding.sca.provider; -import java.net.URI; import java.util.logging.Logger; import org.apache.tuscany.sca.assembly.DistributedSCABinding; import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; -import org.apache.tuscany.sca.assembly.OptimizableBinding; import org.apache.tuscany.sca.assembly.SCABinding; import org.apache.tuscany.sca.assembly.SCABindingFactory; import org.apache.tuscany.sca.core.ExtensionPointRegistry; @@ -40,7 +37,8 @@ import org.apache.tuscany.sca.provider.ReferenceBindingProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; import org.oasisopen.sca.ServiceUnavailableException; /** @@ -56,7 +54,7 @@ public class RuntimeSCAReferenceBindingProvider implements ReferenceBindingProvi private static final Logger logger = Logger.getLogger(RuntimeSCAReferenceBindingProvider.class.getName()); - private EndpointReference endpointReference; + private RuntimeEndpointReference endpointReference; private RuntimeComponent component; private RuntimeComponentReference reference; private SCABinding binding; @@ -67,7 +65,7 @@ public class RuntimeSCAReferenceBindingProvider implements ReferenceBindingProvi private SCABindingFactory scaBindingFactory; public RuntimeSCAReferenceBindingProvider(ExtensionPointRegistry extensionPoints, - EndpointReference endpointReference) { + RuntimeEndpointReference endpointReference) { this.endpointReference = endpointReference; this.component = (RuntimeComponent)endpointReference.getComponent(); this.reference = (RuntimeComponentReference)endpointReference.getReference(); @@ -143,9 +141,9 @@ public class RuntimeSCAReferenceBindingProvider implements ReferenceBindingProvi distributedBinding.setSCABinding(binding); // create a copy of the endpoint reference and change the binding - EndpointReference epr = null; + RuntimeEndpointReference epr = null; try { - epr = (EndpointReference)endpointReference.clone(); + epr = (RuntimeEndpointReference)endpointReference.clone(); } catch (Exception ex) { // we know we can clone endpoint references } @@ -163,10 +161,13 @@ public class RuntimeSCAReferenceBindingProvider implements ReferenceBindingProvi if (isTargetRemote()) { return getDistributedProvider().getBindingInterfaceContract(); } else { - if (reference.getReference() != null) { - return reference.getReference().getInterfaceContract(); + // Check if there is a target + RuntimeEndpoint endpoint = (RuntimeEndpoint)endpointReference.getTargetEndpoint(); + if (endpoint != null) { + // Use the target binding interface contract + return endpoint.getBindingInterfaceContract(); } else { - return reference.getInterfaceContract(); + return endpointReference.getReferenceInterfaceContract(); } } } @@ -179,14 +180,12 @@ public class RuntimeSCAReferenceBindingProvider implements ReferenceBindingProvi } } - private Invoker getInvoker(RuntimeWire wire, Operation operation) { - Endpoint target = wire.getEndpoint(); + private Invoker getInvoker(RuntimeEndpointReference epr, Operation operation) { + Endpoint target = epr.getTargetEndpoint(); if (target != null) { RuntimeComponentService service = (RuntimeComponentService)target.getService(); if (service != null) { // not a callback wire - SCABinding scaBinding = service.getBinding(SCABinding.class); - InvocationChain chain = - service.getInvocationChain(scaBinding, wire.getEndpointReference().getInterfaceContract(), operation); + InvocationChain chain = ((RuntimeEndpoint) target).getInvocationChain(operation); return chain == null ? null : new SCABindingInvoker(chain); } } @@ -197,8 +196,7 @@ public class RuntimeSCAReferenceBindingProvider implements ReferenceBindingProvi if (isTargetRemote()) { return getDistributedProvider().createInvoker(operation); } else { - RuntimeWire wire = reference.getRuntimeWire(binding); - Invoker invoker = getInvoker(wire, operation); + Invoker invoker = getInvoker(endpointReference, operation); if (invoker == null) { throw new ServiceUnavailableException("Unable to create SCA binding invoker for local target " + component.getName() + " reference " diff --git a/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java b/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java index 220b431e9d..bbf785d578 100644 --- a/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java +++ b/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java @@ -24,7 +24,6 @@ import java.util.Collection; import org.apache.tuscany.sca.assembly.DistributedSCABinding; import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.assembly.SCABinding; import org.apache.tuscany.sca.assembly.SCABindingFactory; import org.apache.tuscany.sca.core.ExtensionPointRegistry; @@ -38,6 +37,7 @@ import org.apache.tuscany.sca.runtime.DomainRegistryFactory; import org.apache.tuscany.sca.runtime.EndpointRegistry; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; /** * The sca service binding provider mediates between the twin requirements of @@ -59,7 +59,7 @@ public class RuntimeSCAServiceBindingProvider implements ServiceBindingProvider private DistributedSCABinding distributedBinding; - public RuntimeSCAServiceBindingProvider(ExtensionPointRegistry extensionPoints, Endpoint endpoint) { + public RuntimeSCAServiceBindingProvider(ExtensionPointRegistry extensionPoints, RuntimeEndpoint endpoint) { this.component = (RuntimeComponent)endpoint.getComponent(); this.service = (RuntimeComponentService)endpoint.getService(); this.binding = (SCABinding)endpoint.getBinding(); @@ -87,9 +87,9 @@ public class RuntimeSCAServiceBindingProvider implements ServiceBindingProvider distributedBinding.setSCABinding(binding); // create a copy of the endpoint and change the binding - Endpoint ep = null; + RuntimeEndpoint ep = null; try { - ep = (Endpoint)endpoint.clone(); + ep = (RuntimeEndpoint)endpoint.clone(); } catch (Exception ex) { // we know we can clone endpoint } diff --git a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java index a04e0d54e5..0e847cf982 100644 --- a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java +++ b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java @@ -20,8 +20,6 @@ package org.apache.tuscany.sca.binding.ws.axis2; import java.util.List; -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.binding.ws.WebServiceBinding; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.FactoryExtensionPoint; @@ -34,6 +32,8 @@ import org.apache.tuscany.sca.provider.ServiceBindingProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * Axis2BindingProviderFactory @@ -57,11 +57,11 @@ public class Axis2BindingProviderFactory implements BindingProviderFactory<WebSe dataBindings = extensionPoints.getExtensionPoint(DataBindingExtensionPoint.class); } - public ReferenceBindingProvider createReferenceBindingProvider(EndpointReference endpointReference) { + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) { return new Axis2ReferenceBindingProvider(endpointReference, modelFactories, dataBindings); } - public ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint) { + public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) { return new Axis2ServiceBindingProvider(endpoint, servletHost, modelFactories, dataBindings); } diff --git a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java index b6aac923a0..a0dea01cd2 100644 --- a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java +++ b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java @@ -19,7 +19,6 @@ package org.apache.tuscany.sca.binding.ws.axis2; import org.apache.axiom.om.OMElement; -import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.binding.ws.WebServiceBinding; import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint; @@ -29,6 +28,7 @@ import org.apache.tuscany.sca.invocation.MessageFactory; import org.apache.tuscany.sca.provider.ServiceBindingProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; import org.oasisopen.sca.ServiceRuntimeException; public class Axis2ServiceBindingProvider implements ServiceBindingProvider { @@ -39,7 +39,7 @@ public class Axis2ServiceBindingProvider implements ServiceBindingProvider { private Axis2ServiceProvider axisProvider; - public Axis2ServiceBindingProvider(Endpoint endpoint, + public Axis2ServiceBindingProvider(RuntimeEndpoint endpoint, ServletHost servletHost, FactoryExtensionPoint modelFactories, DataBindingExtensionPoint dataBindings) { @@ -62,7 +62,7 @@ public class Axis2ServiceBindingProvider implements ServiceBindingProvider { InterfaceContract contract = wsBinding.getBindingInterfaceContract(); contract.getInterface().resetDataBinding(OMElement.class.getName()); - axisProvider = new Axis2ServiceProvider(component, service, wsBinding, servletHost, messageFactory, modelFactories); + axisProvider = new Axis2ServiceProvider(endpoint, component, service, wsBinding, servletHost, messageFactory, modelFactories); } public void start() { diff --git a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java index 1ee885b004..90cc3cd31a 100644 --- a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java +++ b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java @@ -77,7 +77,6 @@ import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.assembly.EndpointReference; -import org.apache.tuscany.sca.assembly.SCABinding; import org.apache.tuscany.sca.binding.ws.WebServiceBinding; import org.apache.tuscany.sca.binding.ws.axis2.Axis2ServiceClient.URIResolverImpl; import org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token.Axis2TokenAuthenticationPolicy; @@ -98,8 +97,7 @@ import org.apache.tuscany.sca.policy.PolicySet; import org.apache.tuscany.sca.policy.PolicySubject; import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy; import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; import org.apache.tuscany.sca.xsd.XSDefinition; import org.apache.ws.commons.schema.XmlSchema; import org.apache.ws.commons.schema.XmlSchemaExternal; @@ -117,6 +115,7 @@ public class Axis2ServiceProvider { private static final Logger logger = Logger.getLogger(Axis2ServiceProvider.class.getName()); + private RuntimeEndpoint endpoint; private RuntimeComponent component; private AbstractContract contract; private WebServiceBinding wsBinding; @@ -159,13 +158,14 @@ public class Axis2ServiceProvider { public static final List<QName> XSD_QNAME_LIST = Arrays.asList(new QName[] {Q_ELEM_XSD_1999, Q_ELEM_XSD_2000, Q_ELEM_XSD_2001}); - public Axis2ServiceProvider(RuntimeComponent component, + public Axis2ServiceProvider(RuntimeEndpoint endpoint, + RuntimeComponent component, AbstractContract contract, WebServiceBinding wsBinding, ServletHost servletHost, MessageFactory messageFactory, final FactoryExtensionPoint modelFactories) { - + this.endpoint = endpoint; this.component = component; this.contract = contract; this.wsBinding = wsBinding; @@ -696,27 +696,11 @@ public class Axis2ServiceProvider { from.setCallbackEndpoint(callbackEndpoint); } - // find the runtime wire and invoke it with the message - RuntimeWire wire = ((RuntimeComponentService)contract).getRuntimeWire(getBinding()); - - // TODO - EPR - if there is no wire then find the wire for the SCA binding - // because this WS endpoint is providing remote support for the - // SCA binding - if (wire == null){ - for(RuntimeWire tmpWire : ((RuntimeComponentService)contract).getRuntimeWires()){ - if (tmpWire.getEndpoint().getBinding() instanceof SCABinding){ - wire = tmpWire; - break; - } - } + Message response = endpoint.invoke(op, msg); + if(response.isFault()) { + throw new InvocationTargetException((Throwable) response.getBody()); } - Object response = wire.invoke(op, msg); - - return response; - } - - public boolean isConversational() { - return wsBinding.getBindingInterfaceContract().getInterface().isConversational(); + return response.getBody(); } /** diff --git a/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java b/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java index 446651c918..5a6f9739ef 100644 --- a/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java +++ b/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java @@ -21,7 +21,6 @@ package org.apache.tuscany.sca.core.databinding.wire; import java.util.List; -import org.apache.tuscany.sca.assembly.ComponentReference; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.databinding.Mediator; @@ -31,7 +30,8 @@ import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.InvocationChain; import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; import org.apache.tuscany.sca.runtime.RuntimeWireProcessor; /** @@ -123,9 +123,32 @@ public class DataBindingRuntimeWireProcessor implements RuntimeWireProcessor { return isTransformationRequired(sourceOperation, targetOperation); } - public void process(RuntimeWire wire) { - InterfaceContract sourceContract = wire.getEndpointReference().getInterfaceContract(); - InterfaceContract targetContract = wire.getEndpoint().getInterfaceContract(); + /** + * FIXME: TUSCANY-2586, temporary work around till the JIRA is fixed to prevent + * the PassByValueInterceptor being used for services when the binding protocol + * doesn't need the copies done. + */ + protected boolean isOnMessage(Operation op) { + return "onMessage".equals(op.getName()); + } + + /** + * Pass-by-value copies are required if the interfaces are remotable unless the + * implementation uses the @AllowsPassByReference annotation. + */ + protected boolean isRemotable(InvocationChain chain, Operation sourceOperation, Operation targetOperation) { + if (!sourceOperation.getInterface().isRemotable()) { + return false; + } + if (!targetOperation.getInterface().isRemotable()) { + return false; + } + return true; + } + + public void process(RuntimeEndpoint endpoint) { + InterfaceContract sourceContract = endpoint.getBindingInterfaceContract(); + InterfaceContract targetContract = endpoint.getServiceInterfaceContract(); if (targetContract == null) { targetContract = sourceContract; } @@ -133,7 +156,7 @@ public class DataBindingRuntimeWireProcessor implements RuntimeWireProcessor { if (!sourceContract.getInterface().isRemotable()) { return; } - List<InvocationChain> chains = wire.getInvocationChains(); + List<InvocationChain> chains = endpoint.getInvocationChains(); for (InvocationChain chain : chains) { Operation sourceOperation = chain.getSourceOperation(); Operation targetOperation = chain.getTargetOperation(); @@ -143,7 +166,7 @@ public class DataBindingRuntimeWireProcessor implements RuntimeWireProcessor { // Add the interceptor to the source side because multiple // references can be wired to the same service interceptor = - new DataTransformationInterceptor(wire, sourceOperation, targetOperation, mediator); + new DataTransformationInterceptor(endpoint, sourceOperation, targetOperation, mediator); } else { // assume pass-by-values copies are required if interfaces are remotable and there is no data binding // transformation, i.e. a transformation will result in a copy so another pass-by-value copy is unnecessary @@ -153,36 +176,48 @@ public class DataBindingRuntimeWireProcessor implements RuntimeWireProcessor { } } if (interceptor != null) { - String phase = - (wire.getEndpointReference().getReference() instanceof ComponentReference) ? Phase.REFERENCE_INTERFACE - : Phase.SERVICE_INTERFACE; + String phase = Phase.SERVICE_INTERFACE; chain.addInterceptor(phase, interceptor); } } } - /** - * FIXME: TUSCANY-2586, temporary work around till the JIRA is fixed to prevent - * the PassByValueInterceptor being used for services when the binding protocol - * doesn't need the copies done. - */ - protected boolean isOnMessage(Operation op) { - return "onMessage".equals(op.getName()); - } + public void process(RuntimeEndpointReference endpointReference) { + InterfaceContract sourceContract = endpointReference.getReferenceInterfaceContract(); + InterfaceContract targetContract = endpointReference.getBindingInterfaceContract(); + if (targetContract == null) { + targetContract = sourceContract; + } - /** - * Pass-by-value copies are required if the interfaces are remotable unless the - * implementation uses the @AllowsPassByReference annotation. - */ - protected boolean isRemotable(InvocationChain chain, Operation sourceOperation, Operation targetOperation) { - if (!sourceOperation.getInterface().isRemotable()) { - return false; + if (!sourceContract.getInterface().isRemotable()) { + return; } - if (!targetOperation.getInterface().isRemotable()) { - return false; + List<InvocationChain> chains = endpointReference.getInvocationChains(); + for (InvocationChain chain : chains) { + Operation sourceOperation = chain.getSourceOperation(); + Operation targetOperation = chain.getTargetOperation(); + + Interceptor interceptor = null; + if (isTransformationRequired(sourceContract, sourceOperation, targetContract, targetOperation)) { + // Add the interceptor to the source side because multiple + // references can be wired to the same service + interceptor = + new DataTransformationInterceptor(endpointReference, sourceOperation, targetOperation, mediator); + } else { + // assume pass-by-values copies are required if interfaces are remotable and there is no data binding + // transformation, i.e. a transformation will result in a copy so another pass-by-value copy is unnecessary + if (!isOnMessage(targetOperation) && isRemotable(chain, sourceOperation, targetOperation)) { + interceptor = + new PassByValueInterceptor(mediator, chain, targetOperation); + } + } + if (interceptor != null) { + String phase = Phase.REFERENCE_INTERFACE; + chain.addInterceptor(phase, interceptor); + } } - return true; + } } diff --git a/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataTransformationInterceptor.java b/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataTransformationInterceptor.java index 679897b59b..17efe33321 100644 --- a/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataTransformationInterceptor.java +++ b/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataTransformationInterceptor.java @@ -19,21 +19,16 @@ package org.apache.tuscany.sca.core.databinding.wire; -import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.Map; import org.apache.tuscany.sca.databinding.Mediator; import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl; -import org.apache.tuscany.sca.interfacedef.util.FaultException; -import org.apache.tuscany.sca.interfacedef.util.XMLType; import org.apache.tuscany.sca.invocation.DataExchangeSemantics; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.RuntimeWire; -import org.oasisopen.sca.ServiceRuntimeException; +import org.apache.tuscany.sca.runtime.Invocable; /** * An interceptor to transform data across databindings on the wire @@ -46,10 +41,10 @@ public class DataTransformationInterceptor implements Interceptor, DataExchangeS private Operation sourceOperation; private Operation targetOperation; - private RuntimeWire wire; + private Invocable invocable; private Mediator mediator; - public DataTransformationInterceptor(RuntimeWire wire, + public DataTransformationInterceptor(Invocable invocable, Operation sourceOperation, Operation targetOperation, Mediator mediator) { @@ -57,7 +52,7 @@ public class DataTransformationInterceptor implements Interceptor, DataExchangeS this.sourceOperation = sourceOperation; this.targetOperation = targetOperation; this.mediator = mediator; - this.wire = wire; + this.invocable = invocable; } public Invoker getNext() { @@ -66,7 +61,7 @@ public class DataTransformationInterceptor implements Interceptor, DataExchangeS public Message invoke(Message msg) { Map<String, Object> metadata = new HashMap<String, Object>(); - metadata.put("wire", wire); + metadata.put(Invocable.class.getName(), invocable); Object input = mediator.mediateInput(msg.getBody(), sourceOperation, targetOperation, metadata); msg.setBody(input); Message resultMsg = next.invoke(msg); @@ -76,7 +71,6 @@ public class DataTransformationInterceptor implements Interceptor, DataExchangeS return resultMsg; } - if (resultMsg.isFault()) { Object transformedFault = null; if ((result instanceof Exception) && !(result instanceof RuntimeException)) { diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java index a805985a11..a55de8f20e 100644 --- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java @@ -33,7 +33,24 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentContext; * * @version $Rev$ $Date$ */ -public abstract class CompositeContext { +public class CompositeContext { + protected ExtensionPointRegistry extensionPointRegistry; + protected EndpointRegistry endpointRegistry; + protected ComponentContextFactory componentContextFactory; + protected Composite domainComposite; + + public CompositeContext(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry, Composite domainComposite) { + this.extensionPointRegistry = registry; + this.endpointRegistry = endpointRegistry; + ContextFactoryExtensionPoint contextFactories = registry.getExtensionPoint(ContextFactoryExtensionPoint.class); + this.componentContextFactory = contextFactories.getFactory(ComponentContextFactory.class); + this.domainComposite = domainComposite; + } + + public CompositeContext(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry) { + this(registry, endpointRegistry, null); + } + /** * @return */ @@ -62,30 +79,37 @@ public abstract class CompositeContext { return null; } - /** - * Attach a component context to the component - * @param runtimeComponent - */ - public abstract void bindComponent(RuntimeComponent runtimeComponent); - + public void bindComponent(RuntimeComponent runtimeComponent) { + RuntimeComponentContext componentContext = + (RuntimeComponentContext)componentContextFactory.createComponentContext(this, runtimeComponent); + runtimeComponent.setComponentContext(componentContext); + } /** * * @param endpointReference */ - public abstract void bindEndpointReference(EndpointReference endpointReference); + public void bindEndpointReference(EndpointReference endpointReference) { + + } /** * Get the ExtensionPointRegistry for this node * @return The ExtensionPointRegistry */ - public abstract ExtensionPointRegistry getExtensionPointRegistry(); + public ExtensionPointRegistry getExtensionPointRegistry() { + return extensionPointRegistry; + } /** * Get the EndpointRegistry * @return The EndpointRegistry for this node */ - public abstract EndpointRegistry getEndpointRegistry(); + public EndpointRegistry getEndpointRegistry() { + return endpointRegistry; + } - public abstract Composite getDomainComposite(); + public Composite getDomainComposite() { + return domainComposite; + } } diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BasePolicyProvider.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BasePolicyProvider.java index 785ac70271..8f93476c85 100644 --- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BasePolicyProvider.java +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BasePolicyProvider.java @@ -32,9 +32,10 @@ import org.apache.tuscany.sca.invocation.PhasedInterceptor; import org.apache.tuscany.sca.policy.PolicyExpression; import org.apache.tuscany.sca.policy.PolicySet; import org.apache.tuscany.sca.policy.PolicySubject; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * Abstract base class for policy providers @@ -129,30 +130,26 @@ public abstract class BasePolicyProvider<T> implements PolicyProvider { return null; } - private InvocationChain getInvocationChain() { - if (subject instanceof Endpoint) { - Endpoint endpoint = (Endpoint)subject; - RuntimeComponentService service = (RuntimeComponentService)endpoint.getService(); - RuntimeWire wire = service.getRuntimeWire(endpoint.getBinding()); - List<InvocationChain> chains = wire.getInvocationChains(); + protected InvocationChain getInvocationChain() { + if (subject instanceof RuntimeEndpoint) { + RuntimeEndpoint endpoint = (RuntimeEndpoint)subject; + List<InvocationChain> chains = endpoint.getInvocationChains(); for (InvocationChain chain : chains) { configure(chain, chain.getTargetOperation()); } - } else if (subject instanceof EndpointReference) { - EndpointReference endpointReference = (EndpointReference)subject; - RuntimeComponentReference reference = (RuntimeComponentReference)endpointReference.getReference(); - RuntimeWire wire = reference.getRuntimeWire(endpointReference.getBinding()); - List<InvocationChain> chains = wire.getInvocationChains(); + } else if (subject instanceof RuntimeEndpointReference) { + RuntimeEndpointReference endpointReference = (RuntimeEndpointReference)subject; + List<InvocationChain> chains = endpointReference.getInvocationChains(); for (InvocationChain chain : chains) { configure(chain, chain.getSourceOperation()); } - } else if (subject instanceof Component) { - Component component = (Component)subject; + } else if (subject instanceof RuntimeComponent) { + RuntimeComponent component = (RuntimeComponent)subject; for (ComponentService s : component.getServices()) { RuntimeComponentService service = (RuntimeComponentService)s; - for (RuntimeWire wire : service.getRuntimeWires()) { - List<InvocationChain> chains = wire.getInvocationChains(); + for (Endpoint ep : service.getEndpoints()) { + List<InvocationChain> chains = ((RuntimeEndpoint)ep).getInvocationChains(); for (InvocationChain chain : chains) { configure(chain, chain.getTargetOperation()); } diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderRRB.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingPolicyProvider.java index 6e7f2bd554..5f2e6bd315 100644 --- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderRRB.java +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingPolicyProvider.java @@ -27,7 +27,7 @@ import org.apache.tuscany.sca.invocation.PhasedInterceptor; * binding function * @version $Rev$ $Date$ */ -public interface PolicyProviderRRB extends PolicyProvider { +public interface BindingPolicyProvider extends PolicyProvider { /** * Create a binding interceptor * @return An interceptor that realize the policySet diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java index 0e94a28d98..5fa8454b95 100644 --- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java @@ -20,8 +20,8 @@ package org.apache.tuscany.sca.provider; import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * A factory for creating the runtime artifacts that represent bindings. @@ -36,7 +36,7 @@ public interface BindingProviderFactory<M extends Binding> extends ProviderFacto * @param endpointReference defines the component/reference/binding against which to create the provider * @return The binding provider */ - ReferenceBindingProvider createReferenceBindingProvider(EndpointReference endpointReference); + ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference); /** * Creates a new service binding provider for the given component and @@ -45,6 +45,6 @@ public interface BindingProviderFactory<M extends Binding> extends ProviderFacto * @param endpoint defines the component/service/binding against which to create the provider * @return The binding provider */ - ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint); + ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint); } diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java index 2ee058a14d..8621baca2e 100644 --- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java @@ -26,7 +26,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.assembly.Implementation; @@ -34,8 +33,8 @@ import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.extensibility.ServiceDeclaration; import org.apache.tuscany.sca.extensibility.ServiceDiscovery; import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * Default implementation of a provider factory extension point. @@ -237,12 +236,12 @@ public class DefaultProviderFactoryExtensionPoint implements ProviderFactoryExte } @SuppressWarnings("unchecked") - public ReferenceBindingProvider createReferenceBindingProvider(EndpointReference endpointReference) { + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) { return getFactory().createReferenceBindingProvider(endpointReference); } @SuppressWarnings("unchecked") - public ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint) { + public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) { return getFactory().createServiceBindingProvider(endpoint); } @@ -409,16 +408,12 @@ public class DefaultProviderFactoryExtensionPoint implements ProviderFactoryExte return factory; } - public WireFormatProvider createReferenceWireFormatProvider(RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding){ - return getFactory().createReferenceWireFormatProvider(component, reference, binding); + public WireFormatProvider createReferenceWireFormatProvider(RuntimeEndpointReference endpointReference){ + return getFactory().createReferenceWireFormatProvider(endpointReference); } - public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component, - RuntimeComponentService service, - Binding binding){ - return getFactory().createServiceWireFormatProvider(component, service, binding); + public WireFormatProvider createServiceWireFormatProvider(RuntimeEndpoint endpoint){ + return getFactory().createServiceWireFormatProvider(endpoint); } public Class<?> getModelType() { @@ -470,16 +465,12 @@ public class DefaultProviderFactoryExtensionPoint implements ProviderFactoryExte return factory; } - public OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding){ - return getFactory().createReferenceOperationSelectorProvider(component, reference, binding); + public OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeEndpointReference endpointReference){ + return getFactory().createReferenceOperationSelectorProvider(endpointReference); } - public OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeComponent component, - RuntimeComponentService service, - Binding binding){ - return getFactory().createServiceOperationSelectorProvider(component, service, binding); + public OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeEndpoint endpoint){ + return getFactory().createServiceOperationSelectorProvider(endpoint); } public Class<?> getModelType() { diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProviderRRB.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointProvider.java index 3ea9d0ac3c..2672c31304 100644 --- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProviderRRB.java +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointProvider.java @@ -19,7 +19,6 @@ package org.apache.tuscany.sca.provider; -import org.apache.tuscany.sca.runtime.RuntimeWire; /** * TODO RRB experiment @@ -28,8 +27,9 @@ import org.apache.tuscany.sca.runtime.RuntimeWire; * * @version $Rev$ $Date$ */ -public interface ReferenceBindingProviderRRB extends ReferenceBindingProvider { - - void configureBindingChain(RuntimeWire runtimeWire); - +public interface EndpointProvider extends ServiceBindingProvider { + /** + * Configure the binding invocation chain + */ + void configure(); } diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProviderRRB.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointReferenceProvider.java index 278bb23e0a..6430fe4d34 100644 --- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProviderRRB.java +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointReferenceProvider.java @@ -19,7 +19,6 @@ package org.apache.tuscany.sca.provider; -import org.apache.tuscany.sca.runtime.RuntimeWire; /** * TODO RRB experiment @@ -28,8 +27,10 @@ import org.apache.tuscany.sca.runtime.RuntimeWire; * * @version $Rev$ $Date$ */ -public interface ServiceBindingProviderRRB extends ServiceBindingProvider { - - void configureBindingChain(RuntimeWire runtimeWire); +public interface EndpointReferenceProvider extends ReferenceBindingProvider { + /** + * Configure the binding invocation chain + */ + void configure(); } diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.java index 183b38cb33..4aca3e04e0 100644 --- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.java +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.java @@ -19,11 +19,9 @@ package org.apache.tuscany.sca.provider; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.assembly.OperationSelector; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * @version $Rev$ $Date$ @@ -31,23 +29,15 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentService; public interface OperationSelectorProviderFactory<M extends OperationSelector> extends ProviderFactory<M> { /** * Create wire format provider for a given reference binding - * @param component - * @param reference - * @param binding + * @param endpointReference TODO * @return */ - OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding); + OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeEndpointReference endpointReference); /** * Create policy provider for a given service binding - * @param component - * @param service - * @param binding + * @param endpoint TODO * @return */ - OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeComponent component, - RuntimeComponentService service, - Binding binding); + OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeEndpoint endpoint); } diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProviderFactory.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProviderFactory.java index fd748df6ca..1033ce8951 100644 --- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProviderFactory.java +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProviderFactory.java @@ -19,11 +19,9 @@ package org.apache.tuscany.sca.provider; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.assembly.WireFormat; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * @version $Rev$ $Date$ @@ -31,23 +29,15 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentService; public interface WireFormatProviderFactory<M extends WireFormat> extends ProviderFactory<M> { /** * Create wire format provider for a given reference binding - * @param component - * @param reference - * @param binding + * @param endpointReference The endpoint reference * @return */ - WireFormatProvider createReferenceWireFormatProvider(RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding); + WireFormatProvider createReferenceWireFormatProvider(RuntimeEndpointReference endpointReference); /** * Create policy provider for a given service binding - * @param component - * @param service - * @param binding + * @param endpoint TODO * @return */ - WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component, - RuntimeComponentService service, - Binding binding); + WireFormatProvider createServiceWireFormatProvider(RuntimeEndpoint endpoint); } diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Invocable.java index c0150c6138..4e0128c49a 100644 --- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Invocable.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.runtime; @@ -22,39 +22,64 @@ package org.apache.tuscany.sca.runtime; import java.lang.reflect.InvocationTargetException; import java.util.List; -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.Contract; +import org.apache.tuscany.sca.context.CompositeContext; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.InvocationChain; import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.provider.PolicyProvider; /** - * The runtime wire interface that connects a component reference to a - * component service (or an external service) over the selected binding - * - * @version $Rev$ $Date$ + * The abstraction of an invocable model that contains invocation chains */ -public interface RuntimeWire extends Cloneable { +public interface Invocable { /** - * return the endpoint reference that configured this wire - * - * @return the endpoint reference that configured this wire + * Bind the invocable to the composite context + * @param context + */ + void bind(CompositeContext context); + + /** + * Bind the invocable to the extension point registry and endpoint registry. This is typically + * called after the endpoint or endpoint reference is deserialized + * @param registry + * @param endpointRegistry + */ + void bind(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry); + + /** + * Get the associated composite context + * @return */ - EndpointReference getEndpointReference(); + CompositeContext getCompositeContext(); /** - * return the endpoint that configured this wire - * - * @return the endpoint that configured this wire + * Unbind the invocable from the composite context */ - Endpoint getEndpoint(); + void unbind(); /** - * Force the invocation chains to be rebuilt + * Get the component + * @return */ - void rebuild(); + Component getComponent(); /** + * Get the service or reference (contract) + * @return + */ + Contract getContract(); + + /** + * Get the binding + * @return + */ + Binding getBinding(); + + /** * Returns the invocation chains for service operations associated with the * wire * @@ -72,7 +97,7 @@ public interface RuntimeWire extends Cloneable { /** * Get the invocation chain for the binding-specific handling - * @return + * @return The binding invocation chain */ InvocationChain getBindingInvocationChain(); @@ -80,11 +105,10 @@ public interface RuntimeWire extends Cloneable { * This invoke method assumes that the binding invocation chain is in force * and that there will be an operation selector element there to * determine which operation to call - * @param msg The message - * @return The result - * @throws InvocationTargetException + * @param msg The request message + * @return The response message */ - Object invoke(Message msg) throws InvocationTargetException; + Message invoke(Message msg); /** * Invoke an operation with given arguments @@ -98,17 +122,15 @@ public interface RuntimeWire extends Cloneable { /** * Invoke an operation with a context message * @param operation The operation - * @param msg The message - * @return The result + * @param msg The request message + * @return The response message * @throws InvocationTargetException */ - Object invoke(Operation operation, Message msg) throws InvocationTargetException; + Message invoke(Operation operation, Message msg); /** - * @return a clone of the runtime wire - * @throws CloneNotSupportedException + * Get a list of policy providers + * @return */ - Object clone() throws CloneNotSupportedException; - - boolean isOutOfDate(); + List<PolicyProvider> getPolicyProviders(); } diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.java index 5f9ff4fa7e..861ca2d6f9 100644 --- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.java +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.java @@ -20,7 +20,6 @@ package org.apache.tuscany.sca.runtime; import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.context.CompositeContext; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.oasisopen.sca.ComponentContext; @@ -40,27 +39,12 @@ public interface RuntimeComponentContext extends ComponentContext { * Get the CallableReference for a given component reference * @param <B> * @param businessInterface The business interface - * @param reference The reference to be wired * @param endpointReference The endpointReference to be used * @return A service reference representing the wire */ <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, - RuntimeComponentReference reference, - EndpointReference endpointReference); + RuntimeEndpointReference endpointReference); - /** - * Bind the reference to a target component/componentService - * @param <B> - * @param businessInterface The business interface - * @param reference The reference to be wired - * @param component The target component - * @param service The target component service - * @return A service reference representing the wire - */ - <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, - RuntimeComponentReference reference, - RuntimeComponent component, - RuntimeComponentService service); /** * Create a CallableReference for the given component service @@ -70,9 +54,7 @@ public interface RuntimeComponentContext extends ComponentContext { * @param service * @return */ - <B> ServiceReference<B> getCallableReference(Class<B> businessInterface, - RuntimeComponent component, - RuntimeComponentService service); + <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, RuntimeEndpoint endpoint); /** * @param <B> @@ -81,7 +63,8 @@ public interface RuntimeComponentContext extends ComponentContext { * @return */ <B> ServiceReference<B> createSelfReference(Class<B> businessInterface, ComponentService service); - + ExtensionPointRegistry getExtensionPointRegistry(); + CompositeContext getCompositeContext(); } diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentReference.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentReference.java index 0105abd6e4..c0f393c827 100644 --- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentReference.java +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentReference.java @@ -19,15 +19,7 @@ package org.apache.tuscany.sca.runtime; -import java.util.List; - -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.EndpointReference; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.provider.PolicyProvider; -import org.apache.tuscany.sca.provider.ReferenceBindingProvider; /** * The runtime component reference. Provides the bridge between the @@ -37,69 +29,6 @@ import org.apache.tuscany.sca.provider.ReferenceBindingProvider; * @version $Rev$ $Date$ */ public interface RuntimeComponentReference extends ComponentReference { - - /** - * Get a list of runtime wires to the reference - * - * @return The list of wires - */ - List<RuntimeWire> getRuntimeWires(); - - /** - * Get the runtime wire for the given binding - * @param binding The assembly model binding - * @return The runtime wire - */ - RuntimeWire getRuntimeWire(Binding binding); - - /** - * Get the runtime wire for the given endpoint reference - * @param endpointReference The assembly model endpoint reference - * @return The runtime wire - */ - RuntimeWire getRuntimeWire(EndpointReference endpointReference); - - /** - * Returns the reference binding provider associated with this - * component reference and the given binding. - * - * @param binding The assembly model binding - * @return The runtime reference binding provider - */ - ReferenceBindingProvider getBindingProvider(Binding binding); - - /** - * Sets the reference binding provider associated with this - * component reference and the given binding. - * - * @param binding The assembly model binding - * @param bindingProvider The runtime reference binding provider - */ - void setBindingProvider(Binding binding, ReferenceBindingProvider bindingProvider); - - - /** - * Add a policy provider for the given binding to the reference - * @param binding The assembly model binding - * @param policyProvider The policy handler - */ - void addPolicyProvider(Binding binding, PolicyProvider policyProvider); - - /** - * Get a list of policy providers for the given binding - * @param binding The assembly model binding - * @return A list of policy providers for the given binding - */ - List<PolicyProvider> getPolicyProviders(Binding binding); - - /** - * Get the invoker for the given binding and operation - * @param binding The assembly model binding - * @param operation The assembly model operation - * @return The runtime Invoker - */ - Invoker getInvoker(Binding binding, Operation operation); - /** * Set the owning component * @param component diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java index 982724d798..28dd97756a 100644 --- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java @@ -19,16 +19,7 @@ package org.apache.tuscany.sca.runtime; -import java.util.List; - -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.InvocationChain; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.provider.PolicyProvider; -import org.apache.tuscany.sca.provider.ServiceBindingProvider; /** * The runtime component service. Provides the bridge between the @@ -38,101 +29,4 @@ import org.apache.tuscany.sca.provider.ServiceBindingProvider; * @version $Rev$ $Date$ */ public interface RuntimeComponentService extends ComponentService { - - /** - * Get a list of runtime wires to the service - * - * @return The list of wires - */ - List<RuntimeWire> getRuntimeWires(); - /** - * Get the runtime wire for the given binding - * @param binding The assembly model binding - * @return The runtime wire - */ - RuntimeWire getRuntimeWire(Binding binding); - - /** - * Get the callback wires associated with this service - * - * @return The list of runtime callback wires - */ - List<RuntimeWire> getCallbackWires(); - - /** - * Returns the service binding provider associated with this - * component service and the given binding. - * - * @param binding The assembly model binding - * @return The runtime service binding provider - */ - ServiceBindingProvider getBindingProvider(Binding binding); - - /** - * Returns the service binding provider associated with this - * component service and the given binding. - * - * @param binding - * @param interfaceContract - * @return - */ - RuntimeWire getRuntimeWire(Binding binding, InterfaceContract interfaceContract); - - /** - * Sets the service binding provider associated with this - * component service and the given binding. - * - * @param binding The assembly model binding - * @param bindingProvider The runtime service binding provider - */ - void setBindingProvider(Binding binding, ServiceBindingProvider bindingProvider); - - /** - * Get the invoker for the given binding and operation - * @param binding The assembly model binding - * @param operation The assembly model operation - * @return The runtime invoker - */ - Invoker getInvoker(Binding binding, Operation operation); - - /** - * Get the invoker for the given binding and operation - * @param binding The assembly model binding - * @param interfaceContract the client interface contract - * @param operation The assembly model operation - * @return The runtime invoker - */ - Invoker getInvoker(Binding binding, InterfaceContract interfaceContract, Operation operation); - - /** - * Get the invocation chain for the given binding and operation - * @param binding The assembly model binding - * @param operation The assembly model operation - * @return The runtime invocation chain - */ - InvocationChain getInvocationChain(Binding binding, Operation operation); - - /** - * Get the invocation chain for the given binding and operation - * @param binding The assembly model binding - * @param operation The assembly model operation - * @param interfaceContract the client interface contract - * @return The runtime invocation chain - */ - InvocationChain getInvocationChain(Binding binding, InterfaceContract interfaceContract, Operation operation); - - /** - * Add a policy provider for the given binding to the service - * @param binding The assembly model binding - * @param policyProvider The policy handler - */ - void addPolicyProvider(Binding binding, PolicyProvider policyProvider); - - /** - * Get a list of policy providers for the given binding - * @param binding The assembly model binding - * @return A list of policy providers for the given binding - */ - List<PolicyProvider> getPolicyProviders(Binding binding); - } diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpoint.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpoint.java index 7000da9093..2a4cf4fc84 100644 --- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpoint.java +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpoint.java @@ -20,70 +20,15 @@ package org.apache.tuscany.sca.runtime; import java.io.Serializable; -import java.lang.reflect.InvocationTargetException; -import java.util.List; import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.InvocationChain; -import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.provider.ServiceBindingProvider; /** * The runtime representation of a service endpoint */ -public interface RuntimeEndpoint extends Endpoint, Serializable { - /** - * Returns the invocation chains for service operations associated with the - * wire - * - * @return the invocation chains for service operations associated with the - * wire - */ - List<InvocationChain> getInvocationChains(); - - /** - * Lookup the invocation chain by operation - * @param operation The operation - * @return The invocation chain for the given operation - */ - InvocationChain getInvocationChain(Operation operation); - - /** - * Get the invocation chain for the binding-specific handling - * @return The binding invocation chain - */ - InvocationChain getBindingInvocationChain(); - - /** - * This invoke method assumes that the binding invocation chain is in force - * and that there will be an operation selector element there to - * determine which operation to call - * @param msg The message - * @return The result - * @throws InvocationTargetException - */ - Object invoke(Message msg) throws InvocationTargetException; - - /** - * Invoke an operation with given arguments - * @param operation The operation - * @param args The arguments - * @return The result - * @throws InvocationTargetException - */ - Object invoke(Operation operation, Object[] args) throws InvocationTargetException; - - /** - * Invoke an operation with a context message - * @param operation The operation - * @param msg The message - * @return The result - * @throws InvocationTargetException - */ - Object invoke(Operation operation, Message msg) throws InvocationTargetException; - +public interface RuntimeEndpoint extends Endpoint, Invocable, Serializable { /** * Attach the service binding provider * @param provider @@ -95,10 +40,19 @@ public interface RuntimeEndpoint extends Endpoint, Serializable { * @return */ ServiceBindingProvider getBindingProvider(); - + /** - * Get a list of policy providers - * @return + * Get the interface contract for the binding. This represents the data types that the binding + * protocol stack can process. + * @return The binding interface contract + */ + InterfaceContract getBindingInterfaceContract(); + + /** + * Get the interface contract of the service of the target component type, i.e., the + * componentType.service.interfaceContract. This represents the data types that the implementation + * code can process. + * @return The target component type service interface contract */ - List<PolicyProvider> getPolicyProviders(); + InterfaceContract getServiceInterfaceContract(); } diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpointReference.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpointReference.java index 86c808c0fb..d6f8431d48 100644 --- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpointReference.java +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpointReference.java @@ -20,70 +20,15 @@ package org.apache.tuscany.sca.runtime; import java.io.Serializable; -import java.lang.reflect.InvocationTargetException; -import java.util.List; import org.apache.tuscany.sca.assembly.EndpointReference; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.InvocationChain; -import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.provider.ReferenceBindingProvider; /** * The runtime representation of an endpoint reference */ -public interface RuntimeEndpointReference extends EndpointReference, Serializable { - /** - * Returns the invocation chains for service operations associated with the - * wire - * - * @return the invocation chains for service operations associated with the - * wire - */ - List<InvocationChain> getInvocationChains(); - - /** - * Lookup the invocation chain by operation - * @param operation The operation - * @return The invocation chain for the given operation - */ - InvocationChain getInvocationChain(Operation operation); - - /** - * Get the invocation chain for the binding-specific handling - * @return The binding invocation chain - */ - InvocationChain getBindingInvocationChain(); - - /** - * This invoke method assumes that the binding invocation chain is in force - * and that there will be an operation selector element there to - * determine which operation to call - * @param msg The message - * @return The result - * @throws InvocationTargetException - */ - Object invoke(Message msg) throws InvocationTargetException; - - /** - * Invoke an operation with given arguments - * @param operation The operation - * @param args The arguments - * @return The result - * @throws InvocationTargetException - */ - Object invoke(Operation operation, Object[] args) throws InvocationTargetException; - - /** - * Invoke an operation with a context message - * @param operation The operation - * @param msg The message - * @return The result - * @throws InvocationTargetException - */ - Object invoke(Operation operation, Message msg) throws InvocationTargetException; - +public interface RuntimeEndpointReference extends EndpointReference, Invocable, Serializable { /** * Set the reference binding provider for the endpoint reference * @param provider The binding provider @@ -95,10 +40,21 @@ public interface RuntimeEndpointReference extends EndpointReference, Serializabl * @return The binding provider */ ReferenceBindingProvider getBindingProvider(); - /** - * Get the list of policy providers for the endpoint reference - * @return A list of policy providers for the endpoint reference + * Get the interface contract for the binding. This represents the data types that the binding + * protocol stack can process. + * @return The binding interface contract */ - List<PolicyProvider> getPolicyProviders(); + InterfaceContract getBindingInterfaceContract(); + + /** + * Get the interface contract of the reference of the source component type, i.e., the + * componentType.reference.interfaceContract. This represents the data types that the + * implementation code uses to make the outbound call. + * @return The source component type reference interface contract + */ + InterfaceContract getReferenceInterfaceContract(); + boolean isOutOfDate(); + void rebuild(); + } diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessor.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessor.java index fbb7aae467..06db5b10af 100644 --- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessor.java +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessor.java @@ -24,12 +24,15 @@ package org.apache.tuscany.sca.runtime; * @version $Rev$ $Date$ */ public interface RuntimeWireProcessor { - /** - * Process the runtime wire to add interceptors - * - * @param wire + * Configure the runtime endpoint + * @param endpoint */ - void process(RuntimeWire wire); - + void process(RuntimeEndpoint endpoint); + + /** + * Configure the runtime endpoint reference + * @param endpointReference + */ + void process(RuntimeEndpointReference endpointReference); } diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java index f8e3a70ad2..9811667b17 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java @@ -21,12 +21,10 @@ package org.apache.tuscany.sca.core.assembly.impl; import java.security.AccessController; import java.security.PrivilegedAction; -import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.assembly.Component; import org.apache.tuscany.sca.assembly.ComponentReference; import org.apache.tuscany.sca.assembly.ComponentService; @@ -34,20 +32,15 @@ import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.Reference; 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.UtilityExtensionPoint; -import org.apache.tuscany.sca.core.invocation.ExtensibleWireProcessor; import org.apache.tuscany.sca.core.scope.ScopeContainer; import org.apache.tuscany.sca.core.scope.ScopeRegistry; import org.apache.tuscany.sca.core.scope.ScopedRuntimeComponent; import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.invocation.MessageFactory; -import org.apache.tuscany.sca.provider.BindingProviderFactory; import org.apache.tuscany.sca.provider.ImplementationProvider; import org.apache.tuscany.sca.provider.ImplementationProviderFactory; import org.apache.tuscany.sca.provider.PolicyProvider; @@ -61,10 +54,8 @@ import org.apache.tuscany.sca.runtime.EndpointRegistry; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; -import org.apache.tuscany.sca.runtime.RuntimeWireProcessor; -import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint; -import org.apache.tuscany.sca.work.WorkScheduler; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * @version $Rev$ $Date$ @@ -72,25 +63,15 @@ import org.apache.tuscany.sca.work.WorkScheduler; public class CompositeActivatorImpl implements CompositeActivator { final Logger logger = Logger.getLogger(CompositeActivatorImpl.class.getName()); - private final ExtensionPointRegistry extensionPoints; private final AssemblyFactory assemblyFactory; - private final MessageFactory messageFactory; - private final InterfaceContractMapper interfaceContractMapper; private final ScopeRegistry scopeRegistry; - private final WorkScheduler workScheduler; - private final RuntimeWireProcessor wireProcessor; private final ProviderFactoryExtensionPoint providerFactories; public CompositeActivatorImpl(ExtensionPointRegistry extensionPoints) { - this.extensionPoints = extensionPoints; UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); FactoryExtensionPoint factories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class); this.assemblyFactory = factories.getFactory(AssemblyFactory.class); - this.messageFactory = factories.getFactory(MessageFactory.class); - this.interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class); this.scopeRegistry = utilities.getUtility(ScopeRegistry.class); - this.workScheduler = utilities.getUtility(WorkScheduler.class); - this.wireProcessor = new ExtensibleWireProcessor(extensionPoints.getExtensionPoint(RuntimeWireProcessorExtensionPoint.class)); this.providerFactories = extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class); } @@ -251,77 +232,10 @@ public class CompositeActivatorImpl implements CompositeActivator { logger.fine("Activating component service: " + component.getURI() + "#" + service.getName()); } - for (Endpoint endpoint : service.getEndpoints()) { - addServiceBindingProvider(endpoint, component, service, endpoint.getBinding()); - } - addServiceWires(compositeContext, component, service); - } - - public void deactivate(RuntimeComponent component, RuntimeComponentService service) { - if (logger.isLoggable(Level.FINE)) { - logger.fine("Deactivating component service: " + component.getURI() + "#" + service.getName()); - } - removeServiceWires(service); - for (Binding binding : service.getBindings()) { - removeServiceBindingProvider(component, service, binding); - } - } - - private ServiceBindingProvider addServiceBindingProvider( - Endpoint endpoint, - RuntimeComponent component, RuntimeComponentService service, - Binding binding) { - BindingProviderFactory providerFactory = (BindingProviderFactory) providerFactories - .getProviderFactory(binding.getClass()); - if (providerFactory != null) { - @SuppressWarnings("unchecked") - ServiceBindingProvider bindingProvider = providerFactory - .createServiceBindingProvider(endpoint); - if (bindingProvider != null) { - ((RuntimeComponentService) service).setBindingProvider(binding, - bindingProvider); - } - for (PolicyProviderFactory f : providerFactories.getPolicyProviderFactories()) { - PolicyProvider policyProvider = f.createServicePolicyProvider(endpoint); - if (policyProvider != null) { - service.addPolicyProvider(binding, policyProvider); - } - } - return bindingProvider; - } else { - throw new IllegalStateException( - "Provider factory not found for binding: " - + binding.getType()); - } - } - - private void removeServiceBindingProvider(RuntimeComponent component, - RuntimeComponentService service, Binding binding) { - service.setBindingProvider(binding, null); - for (Binding b : service.getBindings()) { - List<PolicyProvider> pps = service.getPolicyProviders(b); - if (pps != null) { - pps.clear(); - } - } - } - - private void addServiceWires(CompositeContext compositeContext, Component serviceComponent, ComponentService service) { - if (!(service instanceof RuntimeComponentService)) { - return; - } - - RuntimeComponentService runtimeService = (RuntimeComponentService)service; - // Add a wire for each service Endpoint - for ( Endpoint endpoint : runtimeService.getEndpoints()){ - - // fluff up a fake endpoint reference as we are on the service side - // so we need to represent the reference that will call us - EndpointReference endpointReference = assemblyFactory.createEndpointReference(); - endpointReference.setBinding(endpoint.getBinding()); - endpointReference.setTargetEndpoint(endpoint); - endpointReference.setStatus(EndpointReference.WIRED_TARGET_FOUND_AND_MATCHED); + for ( Endpoint endpoint : service.getEndpoints()){ + RuntimeEndpoint ep = (RuntimeEndpoint) endpoint; + ep.bind(compositeContext); // create the interface contract for the binding and service ends of the wire // that are created as forward only contracts @@ -331,45 +245,18 @@ public class CompositeActivatorImpl implements CompositeActivator { targetService = service; } endpoint.setInterfaceContract(targetService.getInterfaceContract().makeUnidirectional(false)); - endpointReference.setInterfaceContract(getServiceBindingInterfaceContract(service, endpoint.getBinding())); - - // create the wire - RuntimeWire wire = new RuntimeWireImpl(compositeContext, - false, - endpointReference, - endpoint, - interfaceContractMapper, - workScheduler, - wireProcessor, - messageFactory); - - // TODO - EPR - TUSCANY-3187 - keep and eye on this as to code - // has been reported to be working without this fix in some - // environments - //runtimeService.getRuntimeWires().add(wire); - ((RuntimeComponentService)endpoint.getService()).getRuntimeWires().add(wire); } } - private void removeServiceWires(ComponentService service) { - if (!(service instanceof RuntimeComponentService)) { - return; + public void deactivate(RuntimeComponent component, RuntimeComponentService service) { + if (logger.isLoggable(Level.FINE)) { + logger.fine("Deactivating component service: " + component.getURI() + "#" + service.getName()); } - RuntimeComponentService runtimeService = (RuntimeComponentService)service; - runtimeService.getRuntimeWires().clear(); - } - - private InterfaceContract getServiceBindingInterfaceContract(ComponentService service, Binding binding) { - InterfaceContract interfaceContract = service.getInterfaceContract(); - - ServiceBindingProvider provider = ((RuntimeComponentService)service).getBindingProvider(binding); - if (provider != null) { - InterfaceContract bindingContract = provider.getBindingInterfaceContract(); - if (bindingContract != null) { - interfaceContract = bindingContract; + for(Endpoint ep: service.getEndpoints()) { + if(ep instanceof RuntimeEndpoint) { + ((RuntimeEndpoint) ep).unbind(); } } - return interfaceContract.makeUnidirectional(false); } // Reference activation/deactivation @@ -383,34 +270,19 @@ public class CompositeActivatorImpl implements CompositeActivator { // reference is asked to return it's runtime wires. If there are none the reference // asks the component context to start the reference which creates the wires reference.setComponent(component); + for(EndpointReference epr: reference.getEndpointReferences()) { + addReferenceWire(compositeContext, epr); + } + + // TODO reference wires are added at component start for some reason } public void deactivate(RuntimeComponent component, RuntimeComponentReference reference) { if (logger.isLoggable(Level.FINE)) { logger.fine("Deactivating component reference: " + component.getURI() + "#" + reference.getName()); } - removeReferenceWires(reference); - for (EndpointReference endpointReference : reference.getEndpointReferences()) { - if (endpointReference.getBinding() != null){ - removeReferenceBindingProvider(component, reference, endpointReference.getBinding()); - } - } - } - - private void removeReferenceBindingProvider(RuntimeComponent component, - RuntimeComponentReference reference, Binding binding) { - reference.setBindingProvider(binding, null); - for (Binding b : reference.getBindings()) { - List<PolicyProvider> pps = reference.getPolicyProviders(b); - if (pps != null) { - pps.clear(); - } - } - } - - private void removeReferenceWires(ComponentReference reference) { - if (!(reference instanceof RuntimeComponentReference)) { - return; + for(EndpointReference endpointReference: reference.getEndpointReferences()) { + ((RuntimeEndpointReference) endpointReference).unbind(); } } @@ -476,14 +348,14 @@ public class CompositeActivatorImpl implements CompositeActivator { if (logger.isLoggable(Level.FINE)) { logger.fine("Starting component service: " + component.getURI() + "#" + service.getName()); } - RuntimeComponentService runtimeService = (RuntimeComponentService)service; for (Endpoint endpoint : service.getEndpoints()) { + RuntimeEndpoint ep = (RuntimeEndpoint) endpoint; // FIXME: Should the policy providers be started before the endpoint is started? - for (PolicyProvider policyProvider : runtimeService.getPolicyProviders(endpoint.getBinding())) { + for (PolicyProvider policyProvider : ep.getPolicyProviders()) { policyProvider.start(); } - final ServiceBindingProvider bindingProvider = runtimeService.getBindingProvider(endpoint.getBinding()); + final ServiceBindingProvider bindingProvider = ep.getBindingProvider(); if (bindingProvider != null) { // bindingProvider.start(); // Allow bindings to add shutdown hooks. Requires RuntimePermission shutdownHooks in policy. @@ -513,8 +385,9 @@ public class CompositeActivatorImpl implements CompositeActivator { logger.fine("Stopping component service: " + component.getURI() + "#" + service.getName()); } for (Endpoint endpoint : service.getEndpoints()) { + RuntimeEndpoint ep = (RuntimeEndpoint) endpoint; compositeContext.getEndpointRegistry().removeEndpoint(endpoint); - final ServiceBindingProvider bindingProvider = ((RuntimeComponentService)service).getBindingProvider(endpoint.getBinding()); + final ServiceBindingProvider bindingProvider = ep.getBindingProvider(); if (bindingProvider != null) { // Allow bindings to read properties. Requires PropertyPermission read in security policy. AccessController.doPrivileged(new PrivilegedAction<Object>() { @@ -524,8 +397,7 @@ public class CompositeActivatorImpl implements CompositeActivator { } }); } - for (PolicyProvider policyProvider : ((RuntimeComponentService)service).getPolicyProviders(endpoint - .getBinding())) { + for (PolicyProvider policyProvider : ep.getPolicyProviders()) { policyProvider.stop(); } } @@ -534,11 +406,11 @@ public class CompositeActivatorImpl implements CompositeActivator { if (logger.isLoggable(Level.FINE)) { logger.fine("Stopping component reference: " + component.getURI() + "#" + reference.getName()); } - RuntimeComponentReference runtimeRef = ((RuntimeComponentReference)reference); for (EndpointReference endpointReference : reference.getEndpointReferences()) { + RuntimeEndpointReference epr = (RuntimeEndpointReference) endpointReference; compositeContext.getEndpointRegistry().removeEndpointReference(endpointReference); - final ReferenceBindingProvider bindingProvider = runtimeRef.getBindingProvider(endpointReference.getBinding()); + final ReferenceBindingProvider bindingProvider = epr.getBindingProvider(); if (bindingProvider != null) { // Allow bindings to read properties. Requires PropertyPermission read in security policy. AccessController.doPrivileged(new PrivilegedAction<Object>() { @@ -548,8 +420,7 @@ public class CompositeActivatorImpl implements CompositeActivator { } }); } - for (PolicyProvider policyProvider : ((RuntimeComponentReference)reference) - .getPolicyProviders(endpointReference.getBinding())) { + for (PolicyProvider policyProvider : epr.getPolicyProviders()) { policyProvider.stop(); } @@ -607,8 +478,8 @@ public class CompositeActivatorImpl implements CompositeActivator { // current composite). Endpoint reference resolution takes place when the wire // is first used (when the chains are created) for (EndpointReference endpointReference : componentReference.getEndpointReferences()){ - addReferenceWire(compositeContext, component, componentReference, endpointReference); - component.getComponentContext().getCompositeContext().getEndpointRegistry().addEndpointReference(endpointReference); + // addReferenceWire(compositeContext, endpointReference); + compositeContext.getEndpointRegistry().addEndpointReference(endpointReference); } } @@ -622,67 +493,39 @@ public class CompositeActivatorImpl implements CompositeActivator { RuntimeComponent runtimeComponent = (RuntimeComponent) component; EndpointRegistry endpointRegistry = runtimeComponent.getComponentContext().getCompositeContext().getEndpointRegistry(); for ( EndpointReference endpointReference : runtimeRef.getEndpointReferences()){ + RuntimeEndpointReference epr = (RuntimeEndpointReference) endpointReference; endpointRegistry.removeEndpointReference(endpointReference); - ReferenceBindingProvider bindingProvider = runtimeRef.getBindingProvider(endpointReference.getBinding()); + ReferenceBindingProvider bindingProvider = epr.getBindingProvider(); if (bindingProvider != null) { bindingProvider.stop(); } - for (PolicyProvider policyProvider : ((RuntimeComponentReference)reference) - .getPolicyProviders(endpointReference.getBinding())) { + for (PolicyProvider policyProvider : epr.getPolicyProviders()) { policyProvider.stop(); } } } - private void addReferenceWire(CompositeContext compositeContext, Component component, ComponentReference reference, EndpointReference endpointReference) { - RuntimeComponentReference runtimeRef = (RuntimeComponentReference)reference; - - // Use the interface contract of the reference on the component type and if there - // isn't one then use the one from the reference itself - Reference componentTypeRef = reference.getReference(); + private void addReferenceWire(CompositeContext compositeContext, EndpointReference endpointReference) { + RuntimeEndpointReference epr = (RuntimeEndpointReference) endpointReference; + // create the wire + // null endpoint passed in here as the endpoint reference may + // not be resolved yet + epr.bind(compositeContext); - InterfaceContract sourceContract; - if (componentTypeRef == null || componentTypeRef.getInterfaceContract() == null) { - sourceContract = reference.getInterfaceContract(); - } else { - sourceContract = componentTypeRef.getInterfaceContract(); - } + ComponentReference reference = endpointReference.getReference(); + InterfaceContract sourceContract = epr.getReferenceInterfaceContract(); // TODO - EPR - interface contract seems to be null in the implementation.web // case. Not introspecting the CT properly? if (sourceContract == null){ // TODO - Can't do this with move of matching to wire // take the contract from the service to which the reference is connected - sourceContract = endpointReference.getTargetEndpoint().getInterfaceContract(); + sourceContract = ((RuntimeEndpoint) endpointReference.getTargetEndpoint()).getServiceInterfaceContract(); reference.setInterfaceContract(sourceContract); } endpointReference.setInterfaceContract(sourceContract.makeUnidirectional(false)); - - // create the wire - // null endpoint passed in here as the endpoint reference may - // not be resolved yet - RuntimeWire wire = new RuntimeWireImpl(compositeContext, - true, - endpointReference, - null, - interfaceContractMapper, - workScheduler, - wireProcessor, - messageFactory); - runtimeRef.getRuntimeWires().add(wire); - } - private InterfaceContract getInterfaceContract(ComponentReference reference, Binding binding) { - InterfaceContract interfaceContract = reference.getInterfaceContract(); - ReferenceBindingProvider provider = ((RuntimeComponentReference)reference).getBindingProvider(binding); - if (provider != null) { - InterfaceContract bindingContract = provider.getBindingInterfaceContract(); - if (bindingContract != null) { - interfaceContract = bindingContract; - } - } - return interfaceContract.makeUnidirectional(false); - } + } diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java index 82f8ebabea..fb0f327720 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java @@ -36,6 +36,7 @@ import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtens import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.runtime.EndpointSerializer; +import org.oasisopen.sca.ServiceRuntimeException; public class EndpointSerializerImpl implements EndpointSerializer { private ExtensionPointRegistry registry; @@ -91,8 +92,10 @@ public class EndpointSerializerImpl implements EndpointSerializer { endpointReference.setReference(result.getReference()); endpointReference.setBinding(result.getBinding()); endpointReference.setInterfaceContract(result.getReference().getInterfaceContract()); + endpointReference.setTargetEndpoint(result.getTargetEndpoint()); + endpointReference.setCallbackEndpoint(result.getCallbackEndpoint()); } catch (Exception e) { - throw new IOException(e.getMessage()); + throw new ServiceRuntimeException(e); } } @@ -105,7 +108,7 @@ public class EndpointSerializerImpl implements EndpointSerializer { writer.close(); return sw.toString(); } catch (Exception e) { - throw new IOException(e.getMessage()); + throw new ServiceRuntimeException(e); } } }
\ No newline at end of file diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentReferenceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentReferenceImpl.java index 3fdc35a720..2eea60ccea 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentReferenceImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentReferenceImpl.java @@ -19,22 +19,9 @@ package org.apache.tuscany.sca.core.assembly.impl; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.assembly.impl.ComponentReferenceImpl; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.InvocationChain; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.provider.PolicyProvider; -import org.apache.tuscany.sca.provider.ReferenceBindingProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeWire; /** * Implementation of a Component Reference. @@ -42,10 +29,6 @@ import org.apache.tuscany.sca.runtime.RuntimeWire; * @version $Rev$ $Date$ */ public class RuntimeComponentReferenceImpl extends ComponentReferenceImpl implements RuntimeComponentReference { - private ArrayList<RuntimeWire> wires; - private HashMap<Binding, ReferenceBindingProvider> bindingProviders = - new HashMap<Binding, ReferenceBindingProvider>(); - private HashMap<Binding, List<PolicyProvider>> policyProviders = new HashMap<Binding, List<PolicyProvider>>(); private RuntimeComponent component; @@ -53,52 +36,6 @@ public class RuntimeComponentReferenceImpl extends ComponentReferenceImpl implem super(); } - public synchronized List<RuntimeWire> getRuntimeWires() { - if (wires == null) { - wires = new ArrayList<RuntimeWire>(); - component.getComponentContext().start(this); - } - return wires; - } - - // TODO - EPR - shouldn't rely on this anymore - public RuntimeWire getRuntimeWire(Binding binding) { - for (RuntimeWire wire : getRuntimeWires()) { - if (wire.getEndpointReference().getBinding() == binding) { - return wire; - } - } - - return null; - } - - public RuntimeWire getRuntimeWire(EndpointReference endpointReference) { - for (RuntimeWire wire : getRuntimeWires()) { - if (wire.getEndpointReference() == endpointReference) { - return wire; - } - } - - return null; - } - - public ReferenceBindingProvider getBindingProvider(Binding binding) { - return bindingProviders.get(binding); - } - - public void setBindingProvider(Binding binding, ReferenceBindingProvider bindingProvider) { - bindingProviders.put(binding, bindingProvider); - } - - public Invoker getInvoker(Binding binding, Operation operation) { - RuntimeWire wire = getRuntimeWire(binding); - if (wire == null) { - return null; - } - InvocationChain chain = wire.getInvocationChain(operation); - return chain == null ? null : chain.getHeadInvoker(); - } - /** * @return the component */ @@ -119,30 +56,9 @@ public class RuntimeComponentReferenceImpl extends ComponentReferenceImpl implem @Override public Object clone() throws CloneNotSupportedException { RuntimeComponentReferenceImpl ref = (RuntimeComponentReferenceImpl)super.clone(); - ref.wires = null; - ref.bindingProviders = new HashMap<Binding, ReferenceBindingProvider>(); - ref.policyProviders = new HashMap<Binding, List<PolicyProvider>>(); return ref; } - public void addPolicyProvider(Binding binding, PolicyProvider policyProvider) { - List<PolicyProvider> providers = policyProviders.get(binding); - if (providers == null) { - providers = new ArrayList<PolicyProvider>(); - policyProviders.put(binding, providers); - } - providers.add(policyProvider); - } - - public List<PolicyProvider> getPolicyProviders(Binding binding) { - List<PolicyProvider> providers = policyProviders.get(binding); - if (providers == null) { - return Collections.emptyList(); - } else { - return providers; - } - } - @Override public String toString() { return getName(); diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentServiceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentServiceImpl.java index ffa488b7bd..bc7e6df878 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentServiceImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentServiceImpl.java @@ -19,22 +19,8 @@ package org.apache.tuscany.sca.core.assembly.impl; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; - -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.assembly.impl.ComponentServiceImpl; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.InvocationChain; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.provider.PolicyProvider; -import org.apache.tuscany.sca.provider.ServiceBindingProvider; import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; -import org.oasisopen.sca.ServiceRuntimeException; /** * Implementation of a Component Service. @@ -42,126 +28,11 @@ import org.oasisopen.sca.ServiceRuntimeException; * @version $Rev$ $Date$ */ public class RuntimeComponentServiceImpl extends ComponentServiceImpl implements RuntimeComponentService { - private ArrayList<RuntimeWire> wires = new ArrayList<RuntimeWire>(); - private ArrayList<RuntimeWire> callbackWires = new ArrayList<RuntimeWire>(); - private HashMap<Binding, ServiceBindingProvider> bindingProviders = new HashMap<Binding, ServiceBindingProvider>(); - private HashMap<Binding, List<PolicyProvider>> policyProviders = new HashMap<Binding, List<PolicyProvider>>(); public RuntimeComponentServiceImpl() { super(); } - public List<RuntimeWire> getRuntimeWires() { - return wires; - } - - public RuntimeWire getRuntimeWire(Binding binding) { - for (RuntimeWire wire : wires) { - if (wire.getEndpoint().getBinding() == binding) { - return wire; - } - } - return null; - } - - public RuntimeWire getRuntimeWire(Binding binding, InterfaceContract interfaceContract) { - RuntimeWire wire = getRuntimeWire(binding); - if (wire == null) { - return null; - } - if (interfaceContract != null && interfaceContract != wire.getEndpointReference().getInterfaceContract()) { - try { - // FIXME: [rfeng] We could avoid clone() using a better comparison of the two interface contracts - wire = (RuntimeWire)wire.clone(); - wire.getEndpointReference().setInterfaceContract(interfaceContract); - wire.rebuild(); - } catch (CloneNotSupportedException e) { - throw new ServiceRuntimeException(e); - } - } - - return wire; - } - - public List<RuntimeWire> getCallbackWires() { - return callbackWires; - } - - public ServiceBindingProvider getBindingProvider(Binding binding) { - return bindingProviders.get(binding); - } - - public void setBindingProvider(Binding binding, ServiceBindingProvider bindingProvider) { - bindingProviders.put(binding, bindingProvider); - } - - public Invoker getInvoker(Binding binding, Operation operation) { - return getInvoker(binding, null, operation); - } - - public Invoker getInvoker(Binding binding, InterfaceContract interfaceContract, Operation operation) { - InvocationChain chain = getInvocationChain(binding, interfaceContract, operation); - if (chain != null) { - return chain.getHeadInvoker(); - } else { - return null; - } - } - - public InvocationChain getInvocationChain(Binding binding, InterfaceContract interfaceContract, Operation operation) { - RuntimeWire wire = getRuntimeWire(binding); - if (wire == null) { - return null; - } - if (interfaceContract != null && interfaceContract != wire.getEndpointReference().getInterfaceContract()) { - try { - // FIXME: [rfeng] We could avoid clone() using a better comparison of the two interface contracts - wire = (RuntimeWire)wire.clone(); - wire.getEndpointReference().setInterfaceContract(interfaceContract); - wire.rebuild(); - } catch (CloneNotSupportedException e) { - throw new ServiceRuntimeException(e); - } - } - return wire.getInvocationChain(operation); - } - - public InvocationChain getInvocationChain(Binding binding, Operation operation) { - return getInvocationChain(binding, null, operation); - } - - /** - * @see org.apache.tuscany.sca.assembly.impl.ComponentServiceImpl#clone() - */ - @SuppressWarnings("unchecked") - @Override - public Object clone() throws CloneNotSupportedException { - RuntimeComponentServiceImpl clone = (RuntimeComponentServiceImpl)super.clone(); - clone.bindingProviders = (HashMap<Binding, ServiceBindingProvider>)bindingProviders.clone(); - clone.wires = (ArrayList<RuntimeWire>)wires.clone(); - clone.callbackWires = (ArrayList<RuntimeWire>)callbackWires.clone(); - clone.policyProviders = (HashMap<Binding, List<PolicyProvider>>)policyProviders.clone(); - return clone; - } - - public void addPolicyProvider(Binding binding, PolicyProvider policyProvider) { - List<PolicyProvider> providers = policyProviders.get(binding); - if (providers == null) { - providers = new ArrayList<PolicyProvider>(); - policyProviders.put(binding, providers); - } - providers.add(policyProvider); - } - - public List<PolicyProvider> getPolicyProviders(Binding binding) { - List<PolicyProvider> providers = policyProviders.get(binding); - if (providers == null) { - return Collections.emptyList(); - } else { - return providers; - } - } - @Override public String toString() { return getName(); diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java index 357d19091b..2f60b2d126 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java @@ -23,20 +23,82 @@ import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.ComponentReference; +import org.apache.tuscany.sca.assembly.ComponentService; +import org.apache.tuscany.sca.assembly.CompositeReference; +import org.apache.tuscany.sca.assembly.CompositeService; +import org.apache.tuscany.sca.assembly.Contract; +import org.apache.tuscany.sca.assembly.Service; import org.apache.tuscany.sca.assembly.impl.EndpointImpl; +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.UtilityExtensionPoint; +import org.apache.tuscany.sca.core.invocation.ExtensibleWireProcessor; +import org.apache.tuscany.sca.core.invocation.NonBlockingInterceptor; +import org.apache.tuscany.sca.core.invocation.RuntimeInvoker; +import org.apache.tuscany.sca.core.invocation.impl.InvocationChainImpl; +import org.apache.tuscany.sca.core.invocation.impl.PhaseManager; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.InvocationChain; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.invocation.MessageFactory; +import org.apache.tuscany.sca.invocation.Phase; +import org.apache.tuscany.sca.provider.BindingPolicyProvider; +import org.apache.tuscany.sca.provider.BindingProviderFactory; +import org.apache.tuscany.sca.provider.EndpointProvider; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.provider.PolicyProviderFactory; +import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint; +import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.EndpointRegistry; import org.apache.tuscany.sca.runtime.EndpointSerializer; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeWireProcessor; +import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint; +import org.apache.tuscany.sca.work.WorkScheduler; +import org.oasisopen.sca.ServiceRuntimeException; /** * Runtime model for Endpoint that supports java serialization */ -public class RuntimeEndpointImpl extends EndpointImpl implements Externalizable { - private EndpointSerializer serializer; - private String bindingURI; +public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint, Externalizable { + private transient CompositeContext compositeContext; + private transient EndpointRegistry endpointRegistry; + private transient RuntimeWireProcessor wireProcessor; + private transient InterfaceContractMapper interfaceContractMapper; + private transient WorkScheduler workScheduler; + private transient PhaseManager phaseManager; + private transient MessageFactory messageFactory; + private transient RuntimeInvoker invoker; + private transient ProviderFactoryExtensionPoint providerFactories; + + private transient List<InvocationChain> chains; + private transient final Map<Operation, InvocationChain> invocationChainMap = + new ConcurrentHashMap<Operation, InvocationChain>(); + private transient InvocationChain bindingInvocationChain; + + private transient ServiceBindingProvider bindingProvider; + private transient List<PolicyProvider> policyProviders; + private transient EndpointSerializer serializer; private String xml; + protected InterfaceContract bindingInterfaceContract; + protected InterfaceContract serviceInterfaceContract; /** * No-arg constructor for Java serilization */ @@ -48,6 +110,355 @@ public class RuntimeEndpointImpl extends EndpointImpl implements Externalizable super(registry); } + public void bind(CompositeContext compositeContext) { + this.compositeContext = compositeContext; + bind(compositeContext.getExtensionPointRegistry(), compositeContext.getEndpointRegistry()); + } + + public void bind(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry) { + if (compositeContext == null) { + compositeContext = new CompositeContext(registry, endpointRegistry); + } + this.registry = registry; + this.endpointRegistry = endpointRegistry; + UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class); + this.interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class); + this.workScheduler = utilities.getUtility(WorkScheduler.class); + this.wireProcessor = + new ExtensibleWireProcessor(registry.getExtensionPoint(RuntimeWireProcessorExtensionPoint.class)); + + this.messageFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(MessageFactory.class); + this.invoker = new RuntimeInvoker(this.messageFactory, this); + + this.phaseManager = utilities.getUtility(PhaseManager.class); + this.serializer = utilities.getUtility(EndpointSerializer.class); + this.providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class); + } + + public void unbind() { + compositeContext = null; + bindingInvocationChain = null; + chains = null; + bindingProvider = null; + policyProviders = null; + invocationChainMap.clear(); + } + + public synchronized List<InvocationChain> getInvocationChains() { + if (chains == null) { + initInvocationChains(); + } + return chains; + } + + public synchronized InvocationChain getBindingInvocationChain() { + if (bindingInvocationChain == null) { + bindingInvocationChain = new InvocationChainImpl(null, null, false, phaseManager); + initServiceBindingInvocationChains(); + } + return bindingInvocationChain; + } + + public InvocationChain getInvocationChain(Operation operation) { + InvocationChain cached = invocationChainMap.get(operation); + if (cached == null) { + for (InvocationChain chain : getInvocationChains()) { + Operation op = chain.getTargetOperation(); + + if (interfaceContractMapper.isCompatible(operation, op, op.getInterface().isRemotable())) { + invocationChainMap.put(operation, chain); + return chain; + } + } + invocationChainMap.put(operation, null); + return null; + } else { + return cached; + } + } + + public Message invoke(Message msg) { + return invoker.invokeBinding(msg); + } + + public Object invoke(Operation operation, Object[] args) throws InvocationTargetException { + return invoker.invoke(operation, args); + } + + public Message invoke(Operation operation, Message msg) { + return invoker.invoke(operation, msg); + } + + /** + * Navigate the component/componentType inheritence chain to find the leaf contract + * @param contract + * @return + */ + private Contract getLeafContract(Contract contract) { + Contract prev = null; + Contract current = contract; + while (current != null) { + prev = current; + if (current instanceof ComponentReference) { + current = ((ComponentReference)current).getReference(); + } else if (current instanceof CompositeReference) { + current = ((CompositeReference)current).getPromotedReferences().get(0); + } else if (current instanceof ComponentService) { + current = ((ComponentService)current).getService(); + } else if (current instanceof CompositeService) { + current = ((CompositeService)current).getPromotedService(); + } else { + break; + } + if (current == null) { + return prev; + } + } + return current; + } + + /** + * Initialize the invocation chains + */ + private void initInvocationChains() { + chains = new ArrayList<InvocationChain>(); + InterfaceContract sourceContract = getBindingInterfaceContract(); + + // It's the service wire + RuntimeComponentService service = (RuntimeComponentService)getService(); + RuntimeComponent serviceComponent = (RuntimeComponent)getComponent(); + + //InterfaceContract targetContract = getInterfaceContract(); + // TODO - EPR - why is this looking at the component types. The endpoint should have the right interface contract by this time + InterfaceContract targetContract = getServiceInterfaceContract(); + setInterfaceContract(targetContract); + for (Operation operation : sourceContract.getInterface().getOperations()) { + Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation); + if (targetOperation == null) { + throw new ServiceRuntimeException("No matching operation for " + operation.getName() + + " is found in service " + + serviceComponent.getURI() + + "#" + + service.getName()); + } + InvocationChain chain = new InvocationChainImpl(operation, targetOperation, false, phaseManager); + if (operation.isNonBlocking()) { + addNonBlockingInterceptor(chain); + } + addServiceBindingInterceptor(chain, operation); + addImplementationInterceptor(serviceComponent, service, chain, targetOperation); + chains.add(chain); + } + + wireProcessor.process(this); + } + + private void initServiceBindingInvocationChains() { + + // add the binding interceptors to the service binding wire + ServiceBindingProvider provider = getBindingProvider(); + if ((provider != null) && (provider instanceof EndpointProvider)) { + ((EndpointProvider)provider).configure(); + } + + // add the policy interceptors to the service binding wire + List<PolicyProvider> pps = getPolicyProviders(); + if (pps != null) { + for (PolicyProvider p : pps) { + if (p instanceof BindingPolicyProvider) { + Interceptor interceptor = ((BindingPolicyProvider)p).createBindingInterceptor(); + if (interceptor != null) { + bindingInvocationChain.addInterceptor(interceptor); + } + } + } + } + + // TODO - add something on the end of the wire to invoke the + // invocation chain. Need to split out the runtime + // wire invoker into conversation, callback interceptors etc + bindingInvocationChain.addInvoker(invoker); + + } + + /** + * Add the interceptor for a binding + * + * @param reference + * @param binding + * @param chain + * @param operation + */ + private void addServiceBindingInterceptor(InvocationChain chain, Operation operation) { + List<PolicyProvider> pps = getPolicyProviders(); + if (pps != null) { + for (PolicyProvider p : pps) { + Interceptor interceptor = p.createInterceptor(operation); + if (interceptor != null) { + chain.addInterceptor(p.createInterceptor(operation)); + } + } + } + } + + /** + * Add a non-blocking interceptor if the service binding needs it + * + * @param service + * @param binding + * @param chain + */ + private void addNonBlockingInterceptor(InvocationChain chain) { + ServiceBindingProvider provider = getBindingProvider(); + if (provider != null) { + if (!provider.supportsOneWayInvocation()) { + chain.addInterceptor(Phase.SERVICE, new NonBlockingInterceptor(workScheduler)); + } + } + } + + /** + * Add the interceptor for a component implementation + * + * @param component + * @param service + * @param chain + * @param operation + */ + private void addImplementationInterceptor(Component component, + ComponentService service, + InvocationChain chain, + Operation operation) { + + if (service.getService() instanceof CompositeService) { + CompositeService compositeService = (CompositeService)service.getService(); + component = getPromotedComponent(compositeService); + service = getPromotedComponentService(compositeService); + } + + ImplementationProvider provider = ((RuntimeComponent)component).getImplementationProvider(); + + if (provider != null) { + Invoker invoker = null; + invoker = provider.createInvoker((RuntimeComponentService)service, operation); + chain.addInvoker(invoker); + } + // TODO - EPR - don't we need to get the policy from the right level in the + // model rather than the leafmost level + List<PolicyProvider> pps = ((RuntimeComponent)component).getPolicyProviders(); + if (pps != null) { + for (PolicyProvider p : pps) { + Interceptor interceptor = p.createInterceptor(operation); + if (interceptor != null) { + chain.addInterceptor(p.createInterceptor(operation)); + } + } + } + } + + /** + * @see java.lang.Object#clone() + */ + @Override + public Object clone() throws CloneNotSupportedException { + RuntimeEndpointImpl copy = (RuntimeEndpointImpl)super.clone(); + copy.invoker = new RuntimeInvoker(copy.messageFactory, copy); + return copy; + } + + /** + * Follow a service promotion chain down to the inner most (non composite) + * component service. + * + * @param topCompositeService + * @return + */ + private ComponentService getPromotedComponentService(CompositeService compositeService) { + ComponentService componentService = compositeService.getPromotedService(); + if (componentService != null) { + Service service = componentService.getService(); + if (componentService.getName() != null && service instanceof CompositeService) { + + // Continue to follow the service promotion chain + return getPromotedComponentService((CompositeService)service); + + } else { + + // Found a non-composite service + return componentService; + } + } else { + + // No promoted service + return null; + } + } + + /** + * Follow a service promotion chain down to the innermost (non-composite) component. + * + * @param compositeService + * @return + */ + private Component getPromotedComponent(CompositeService compositeService) { + ComponentService componentService = compositeService.getPromotedService(); + if (componentService != null) { + Service service = componentService.getService(); + if (componentService.getName() != null && service instanceof CompositeService) { + + // Continue to follow the service promotion chain + return getPromotedComponent((CompositeService)service); + + } else { + + // Found a non-composite service + return compositeService.getPromotedComponent(); + } + } else { + + // No promoted service + return null; + } + } + + public ServiceBindingProvider getBindingProvider() { + if (bindingProvider == null) { + BindingProviderFactory factory = + (BindingProviderFactory)providerFactories.getProviderFactory(getBinding().getClass()); + if (factory == null) { + throw new ServiceRuntimeException("No provider factory is registered for binding " + getBinding() + .getType()); + } + this.bindingProvider = factory.createServiceBindingProvider(this); + } + return bindingProvider; + } + + public synchronized List<PolicyProvider> getPolicyProviders() { + if (policyProviders == null) { + policyProviders = new ArrayList<PolicyProvider>(); + for (PolicyProviderFactory factory : providerFactories.getPolicyProviderFactories()) { + PolicyProvider provider = factory.createServicePolicyProvider(this); + if (provider != null) { + policyProviders.add(provider); + } + } + } + return policyProviders; + } + + public void setBindingProvider(ServiceBindingProvider provider) { + this.bindingProvider = provider; + } + + public Contract getContract() { + return service; + } + + public CompositeContext getCompositeContext() { + return compositeContext; + } + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { this.uri = in.readUTF(); this.xml = in.readUTF(); @@ -88,14 +499,35 @@ public class RuntimeEndpointImpl extends EndpointImpl implements Externalizable } super.resolve(); } + + public InterfaceContract getBindingInterfaceContract() { + resolve(); + if (bindingInterfaceContract != null) { + return bindingInterfaceContract; + } + bindingInterfaceContract = getBindingProvider().getBindingInterfaceContract(); + if (bindingInterfaceContract == null && service != null) { + bindingInterfaceContract = service.getInterfaceContract(); + } + if (bindingInterfaceContract == null) { + bindingInterfaceContract = getInterfaceContract(); + } + return bindingInterfaceContract; + } - @Override - public void setExtensionPointRegistry(ExtensionPointRegistry registry) { - if (this.registry != registry) { - super.setExtensionPointRegistry(registry); - serializer = null; + public InterfaceContract getServiceInterfaceContract() { + resolve(); + if (serviceInterfaceContract != null) { + return serviceInterfaceContract; + } + if (service == null) { + return getInterfaceContract(); + } + serviceInterfaceContract = getLeafContract(service).getInterfaceContract(); + if (serviceInterfaceContract == null) { + serviceInterfaceContract = getInterfaceContract(); } - // resolve(); + return serviceInterfaceContract; } } diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java index 2b1c85b95a..2132139530 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java @@ -23,19 +23,85 @@ import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; +import java.lang.reflect.InvocationTargetException; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import org.apache.tuscany.sca.assembly.ComponentReference; +import org.apache.tuscany.sca.assembly.ComponentService; +import org.apache.tuscany.sca.assembly.CompositeReference; +import org.apache.tuscany.sca.assembly.CompositeService; +import org.apache.tuscany.sca.assembly.Contract; +import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.assembly.impl.EndpointReferenceImpl; +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.UtilityExtensionPoint; +import org.apache.tuscany.sca.core.invocation.ExtensibleWireProcessor; +import org.apache.tuscany.sca.core.invocation.NonBlockingInterceptor; +import org.apache.tuscany.sca.core.invocation.RuntimeInvoker; +import org.apache.tuscany.sca.core.invocation.impl.InvocationChainImpl; +import org.apache.tuscany.sca.core.invocation.impl.PhaseManager; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.InvocationChain; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.invocation.MessageFactory; +import org.apache.tuscany.sca.invocation.Phase; +import org.apache.tuscany.sca.provider.BindingPolicyProvider; +import org.apache.tuscany.sca.provider.BindingProviderFactory; +import org.apache.tuscany.sca.provider.EndpointReferenceProvider; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.provider.PolicyProviderFactory; +import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint; +import org.apache.tuscany.sca.provider.ReferenceBindingProvider; +import org.apache.tuscany.sca.runtime.EndpointReferenceBinder; +import org.apache.tuscany.sca.runtime.EndpointRegistry; import org.apache.tuscany.sca.runtime.EndpointSerializer; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; +import org.apache.tuscany.sca.runtime.RuntimeWireProcessor; +import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint; +import org.apache.tuscany.sca.work.WorkScheduler; +import org.oasisopen.sca.SCARuntimeException; +import org.oasisopen.sca.ServiceRuntimeException; /** * Runtime model for Endpoint that supports java serialization */ -public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implements Externalizable { - private EndpointSerializer serializer; +public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implements RuntimeEndpointReference, Externalizable { + private transient CompositeContext compositeContext; + private transient RuntimeWireProcessor wireProcessor; + private transient InterfaceContractMapper interfaceContractMapper; + private transient WorkScheduler workScheduler; + private transient PhaseManager phaseManager; + private transient MessageFactory messageFactory; + private transient RuntimeInvoker invoker; + private transient EndpointRegistry endpointRegistry; + + private transient List<InvocationChain> chains; + private transient final Map<Operation, InvocationChain> invocationChainMap = + new ConcurrentHashMap<Operation, InvocationChain>(); + private transient InvocationChain bindingInvocationChain; + + private transient EndpointReferenceBinder eprBinder; + private transient ReferenceBindingProvider bindingProvider; + private transient ProviderFactoryExtensionPoint providerFactories; + private transient List<PolicyProvider> policyProviders; + private transient EndpointSerializer serializer; private String xml; + protected InterfaceContract bindingInterfaceContract; + protected InterfaceContract referenceInterfaceContract; /** * No-arg constructor for Java serilization */ @@ -47,6 +113,318 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen super(registry); } + public void bind(CompositeContext compositeContext) { + this.compositeContext = compositeContext; + bind(compositeContext.getExtensionPointRegistry(), compositeContext.getEndpointRegistry()); + } + + public void bind(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry) { + if (compositeContext == null) { + compositeContext = new CompositeContext(registry, endpointRegistry); + } + this.registry = registry; + this.endpointRegistry = endpointRegistry; + UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class); + this.eprBinder = utilities.getUtility(EndpointReferenceBinder.class); + this.interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class); + this.workScheduler = utilities.getUtility(WorkScheduler.class); + this.wireProcessor = + new ExtensibleWireProcessor(registry.getExtensionPoint(RuntimeWireProcessorExtensionPoint.class)); + + this.messageFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(MessageFactory.class); + this.invoker = new RuntimeInvoker(this.messageFactory, this); + + this.phaseManager = utilities.getUtility(PhaseManager.class); + this.serializer = utilities.getUtility(EndpointSerializer.class); + this.providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class); + } + + public synchronized List<InvocationChain> getInvocationChains() { + if (chains == null) { + initInvocationChains(); + } + return chains; + } + + public synchronized InvocationChain getBindingInvocationChain() { + if (bindingInvocationChain == null) { + bindingInvocationChain = new InvocationChainImpl(null, null, true, phaseManager); + initReferenceBindingInvocationChains(); + } + return bindingInvocationChain; + } + + public InvocationChain getInvocationChain(Operation operation) { + InvocationChain cached = invocationChainMap.get(operation); + if (cached == null) { + for (InvocationChain chain : getInvocationChains()) { + Operation op = chain.getSourceOperation(); + if (interfaceContractMapper.isCompatible(operation, op, op.getInterface().isRemotable())) { + invocationChainMap.put(operation, chain); + return chain; + } + } + invocationChainMap.put(operation, null); + return null; + } else { + return cached; + } + } + + public Message invoke(Message msg) { + return invoker.invoke(msg); + } + + public Object invoke(Operation operation, Object[] args) throws InvocationTargetException { + return invoker.invoke(operation, args); + } + + public Message invoke(Operation operation, Message msg) { + return invoker.invoke(operation, msg); + } + + /** + * Navigate the component/componentType inheritence chain to find the leaf contract + * @param contract + * @return + */ + private Contract getLeafContract(Contract contract) { + Contract prev = null; + Contract current = contract; + while (current != null) { + prev = current; + if (current instanceof ComponentReference) { + current = ((ComponentReference)current).getReference(); + } else if (current instanceof CompositeReference) { + current = ((CompositeReference)current).getPromotedReferences().get(0); + } else if (current instanceof ComponentService) { + current = ((ComponentService)current).getService(); + } else if (current instanceof CompositeService) { + current = ((CompositeService)current).getPromotedService(); + } else { + break; + } + if (current == null) { + return prev; + } + } + return current; + } + + /** + * Initialize the invocation chains + */ + private void initInvocationChains() { + chains = new ArrayList<InvocationChain>(); + InterfaceContract sourceContract = getReferenceInterfaceContract(); + // TODO - EPR why is this looking at the component types. The endpoint reference should have the right interface contract by this time + //InterfaceContract sourceContract = getLeafInterfaceContract(endpointReference); + + // It's the reference wire + resolveEndpointReference(); + + InterfaceContract targetContract = getBindingInterfaceContract(); + // TODO - EPR why is this looking at the component types. The endpoint should have the right interface contract by this time + //InterfaceContract targetContract = getLeafInterfaceContract(endpoint); + + RuntimeComponentReference reference = (RuntimeComponentReference)getReference(); + for (Operation operation : sourceContract.getInterface().getOperations()) { + Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation); + if (targetOperation == null) { + throw new ServiceRuntimeException("No matching operation for " + operation.getName() + + " is found in reference " + + getComponent().getURI() + + "#" + + reference.getName()); + } + InvocationChain chain = new InvocationChainImpl(operation, targetOperation, true, phaseManager); + if (operation.isNonBlocking()) { + addNonBlockingInterceptor(chain); + } + chains.add(chain); + addReferenceBindingInterceptor(chain, operation); + } + + wireProcessor.process(this); + } + + /** + * This code used to be in the activator but has moved here as + * the endpoint reference may not now be resolved until the wire + * is first used + */ + private void resolveEndpointReference() { + boolean ok = eprBinder.bind(endpointRegistry, this); + if (!ok) { + throw new SCARuntimeException("Unable to bind " + this); + } + + // set the endpoint based on the resolved endpoint + Endpoint endpoint = getTargetEndpoint(); + + // start the binding provider + final ReferenceBindingProvider bindingProvider = getBindingProvider(); + + if (bindingProvider != null) { + // Allow bindings to add shutdown hooks. Requires RuntimePermission shutdownHooks in policy. + AccessController.doPrivileged(new PrivilegedAction<Object>() { + public Object run() { + bindingProvider.start(); + return null; + } + }); + } + for (PolicyProvider policyProvider : getPolicyProviders()) { + policyProvider.start(); + } + + InterfaceContract bindingContract = getBindingInterfaceContract(); + endpoint.setInterfaceContract(bindingContract); + } + + + private void initReferenceBindingInvocationChains() { + + // add the binding interceptors to the reference binding wire + ReferenceBindingProvider provider = getBindingProvider(); + if ((provider != null) && (provider instanceof EndpointReferenceProvider)) { + ((EndpointReferenceProvider)provider).configure(); + } + + // add the policy interceptors to the service binding wire + // find out which policies are active + for (PolicyProvider p : getPolicyProviders()) { + if (p instanceof BindingPolicyProvider) { + Interceptor interceptor = ((BindingPolicyProvider)p).createBindingInterceptor(); + if (interceptor != null) { + bindingInvocationChain.addInterceptor(interceptor); + } + } + } + } + + public void rebuild() { + // TODO - can we use the idea of setTarget to rebuild the wire? + // used at the moment by binding.sca when it resets the + // source interface contract for local wires + this.chains = null; + + setStatus(EndpointReference.NOT_CONFIGURED); + + // TODO - cheating here as I fixed the RuntimeComponentService code + // to call this when it resets the interface contract + //endpointReference.setInterfaceContract(epr.getInterfaceContract()); + } + + /** + * Add the interceptor for a reference binding + * + * @param reference + * @param binding + * @param chain + * @param operation + */ + private void addReferenceBindingInterceptor(InvocationChain chain, Operation operation) { + ReferenceBindingProvider provider = getBindingProvider(); + if (provider != null) { + Invoker invoker = provider.createInvoker(operation); + if (invoker != null) { + chain.addInvoker(invoker); + } + } + List<PolicyProvider> pps = getPolicyProviders(); + if (pps != null) { + for (PolicyProvider p : pps) { + Interceptor interceptor = p.createInterceptor(operation); + if (interceptor != null) { + chain.addInterceptor(p.createInterceptor(operation)); + } + } + } + } + + /** + * Add a non-blocking interceptor if the reference binding needs it + * + * @param reference + * @param binding + * @param chain + */ + private void addNonBlockingInterceptor(InvocationChain chain) { + ReferenceBindingProvider provider = getBindingProvider(); + if (provider != null) { + boolean supportsOneWayInvocation = provider.supportsOneWayInvocation(); + if (!supportsOneWayInvocation) { + chain.addInterceptor(Phase.REFERENCE, new NonBlockingInterceptor(workScheduler)); + } + } + } + + /** + * @see java.lang.Object#clone() + */ + @Override + public Object clone() throws CloneNotSupportedException { + RuntimeEndpointReferenceImpl copy = (RuntimeEndpointReferenceImpl)super.clone(); + copy.invoker = new RuntimeInvoker(copy.messageFactory, copy); + return copy; + } + + public boolean isOutOfDate() { + return eprBinder.isOutOfDate(endpointRegistry, this); + } + + public ReferenceBindingProvider getBindingProvider() { + // For the case that binding.sca is implemented by another binding + if (binding == null) { + return null; + } + if (bindingProvider == null) { + BindingProviderFactory factory = + (BindingProviderFactory)providerFactories.getProviderFactory(getBinding().getClass()); + if (factory == null) { + throw new ServiceRuntimeException("No provider factory is registered for binding " + getBinding() + .getType()); + } + this.bindingProvider = factory.createReferenceBindingProvider(this); + } + return bindingProvider; + } + + public void setBindingProvider(ReferenceBindingProvider bindingProvider) { + this.bindingProvider = bindingProvider; + } + + public synchronized List<PolicyProvider> getPolicyProviders() { + if (policyProviders == null) { + policyProviders = new ArrayList<PolicyProvider>(); + for (PolicyProviderFactory factory : providerFactories.getPolicyProviderFactories()) { + PolicyProvider provider = factory.createReferencePolicyProvider(this); + if (provider != null) { + policyProviders.add(provider); + } + } + } + return policyProviders; + } + + public void unbind() { + bindingInvocationChain = null; + chains = null; + bindingProvider = null; + policyProviders = null; + invocationChainMap.clear(); + } + + public Contract getContract() { + resolve(); + return reference; + } + + public CompositeContext getCompositeContext() { + return compositeContext; + } + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { this.uri = in.readUTF(); this.xml = in.readUTF(); @@ -80,7 +458,9 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen protected void resolve() { if (component == null && xml != null) { try { + bind(CompositeContext.getCurrentCompositeContext()); getSerializer().read(this, xml); + eprBinder.bind(endpointRegistry, this); } catch (IOException e) { throw new IllegalStateException(e); } @@ -88,13 +468,35 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen super.resolve(); } - @Override - public void setExtensionPointRegistry(ExtensionPointRegistry registry) { - if (this.registry != registry) { - super.setExtensionPointRegistry(registry); - serializer = null; + public InterfaceContract getBindingInterfaceContract() { + resolve(); + if (bindingInterfaceContract != null) { + return bindingInterfaceContract; + } + bindingInterfaceContract = getBindingProvider().getBindingInterfaceContract(); + if (bindingInterfaceContract == null && reference != null) { + bindingInterfaceContract = reference.getInterfaceContract(); + } + if (bindingInterfaceContract == null) { + bindingInterfaceContract = getInterfaceContract(); } - // resolve(); + return bindingInterfaceContract; } + public InterfaceContract getReferenceInterfaceContract() { + resolve(); + if (referenceInterfaceContract != null) { + return referenceInterfaceContract; + } + if (reference == null) { + return getInterfaceContract(); + } + referenceInterfaceContract = getLeafContract(reference).getInterfaceContract(); + if (referenceInterfaceContract == null) { + referenceInterfaceContract = getInterfaceContract(); + } + return referenceInterfaceContract; + } + + } diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java deleted file mode 100644 index f3f559a25e..0000000000 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java +++ /dev/null @@ -1,800 +0,0 @@ -/* - * 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.tuscany.sca.core.assembly.impl; - -import java.lang.reflect.InvocationTargetException; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.CompositeReference; -import org.apache.tuscany.sca.assembly.CompositeService; -import org.apache.tuscany.sca.assembly.Contract; -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; -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.UtilityExtensionPoint; -import org.apache.tuscany.sca.core.invocation.ExtensibleWireProcessor; -import org.apache.tuscany.sca.core.invocation.NonBlockingInterceptor; -import org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker; -import org.apache.tuscany.sca.core.invocation.impl.InvocationChainImpl; -import org.apache.tuscany.sca.core.invocation.impl.PhaseManager; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.InvocationChain; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.invocation.MessageFactory; -import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.provider.BindingProviderFactory; -import org.apache.tuscany.sca.provider.ImplementationProvider; -import org.apache.tuscany.sca.provider.PolicyProvider; -import org.apache.tuscany.sca.provider.PolicyProviderFactory; -import org.apache.tuscany.sca.provider.PolicyProviderRRB; -import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint; -import org.apache.tuscany.sca.provider.ReferenceBindingProvider; -import org.apache.tuscany.sca.provider.ReferenceBindingProviderRRB; -import org.apache.tuscany.sca.provider.ServiceBindingProvider; -import org.apache.tuscany.sca.provider.ServiceBindingProviderRRB; -import org.apache.tuscany.sca.runtime.EndpointReferenceBinder; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; -import org.apache.tuscany.sca.runtime.RuntimeWireProcessor; -import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint; -import org.apache.tuscany.sca.work.WorkScheduler; -import org.oasisopen.sca.SCARuntimeException; -import org.oasisopen.sca.ServiceRuntimeException; - -/** - * @version $Rev$ $Date$ - */ -public class RuntimeWireImpl implements RuntimeWire { - - private CompositeContext compositeContext; - private ExtensionPointRegistry extensionPoints; - - private Boolean isReferenceWire = false; - private EndpointReference endpointReference; - private Endpoint endpoint; - - private transient RuntimeWireProcessor wireProcessor; - private transient InterfaceContractMapper interfaceContractMapper; - private transient WorkScheduler workScheduler; - private transient PhaseManager phaseManager; - private transient MessageFactory messageFactory; - private transient RuntimeWireInvoker invoker; - - // the following is a very simple cache that avoids re-cloning a wire - // when consecutive callbacks to the same endpoint are made - private Endpoint lastCallback; - private RuntimeWire cachedWire; - private boolean wireReserved; - private RuntimeWireImpl clonedFrom; - - private List<InvocationChain> chains; - private transient final Map<Operation, InvocationChain> invocationChainMap = - new ConcurrentHashMap<Operation, InvocationChain>(); - private InvocationChain bindingInvocationChain; - - private EndpointReferenceBinder eprBinder; - private final ProviderFactoryExtensionPoint providerFactories; - - /** - * @param source - * @param target - * @param interfaceContractMapper - * @param workScheduler - * @param wireProcessor - * @param messageFactory - * @param conversationManager - */ - public RuntimeWireImpl(CompositeContext compositeContext, - boolean isReferenceWire, - EndpointReference endpointReference, - Endpoint endpoint, - InterfaceContractMapper interfaceContractMapper, - WorkScheduler workScheduler, - RuntimeWireProcessor wireProcessor, - MessageFactory messageFactory) { - super(); - this.compositeContext = compositeContext; - this.extensionPoints = compositeContext.getExtensionPointRegistry(); - this.isReferenceWire = isReferenceWire; - this.endpointReference = endpointReference; - this.endpoint = endpoint; - this.interfaceContractMapper = interfaceContractMapper; - this.workScheduler = workScheduler; - this.wireProcessor = wireProcessor; - this.messageFactory = messageFactory; - this.invoker = new RuntimeWireInvoker(this.messageFactory, this); - - UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); - this.eprBinder = utilities.getUtility(EndpointReferenceBinder.class); - this.phaseManager = utilities.getUtility(PhaseManager.class); - this.providerFactories = extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class); - } - - public RuntimeWireImpl(CompositeContext compositeContext, - boolean isReferenceWire, - EndpointReference endpointReference, - Endpoint endpoint) { - super(); - this.compositeContext = compositeContext; - this.extensionPoints = compositeContext.getExtensionPointRegistry(); - this.isReferenceWire = isReferenceWire; - this.endpointReference = endpointReference; - this.endpoint = endpoint; - - UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); - this.interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class); - this.workScheduler = utilities.getUtility(WorkScheduler.class); - this.wireProcessor = new ExtensibleWireProcessor(extensionPoints.getExtensionPoint(RuntimeWireProcessorExtensionPoint.class)); - FactoryExtensionPoint factories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class); - this.messageFactory = factories.getFactory(MessageFactory.class); - this.invoker = new RuntimeWireInvoker(this.messageFactory, this); - - this.eprBinder = utilities.getUtility(EndpointReferenceBinder.class); - this.phaseManager = utilities.getUtility(PhaseManager.class); - this.providerFactories = extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class); - } - - public synchronized List<InvocationChain> getInvocationChains() { - if (chains == null) { - initInvocationChains(); - } - return chains; - } - - public synchronized InvocationChain getBindingInvocationChain() { - if (bindingInvocationChain == null) { - bindingInvocationChain = new InvocationChainImpl(null, null, isReferenceWire, phaseManager); - if (isReferenceWire) { - initReferenceBindingInvocationChains(); - } else { - initServiceBindingInvocationChains(); - } - } - return bindingInvocationChain; - } - - public InvocationChain getInvocationChain(Operation operation) { - InvocationChain cached = invocationChainMap.get(operation); - if (cached == null) { - for (InvocationChain chain : getInvocationChains()) { - Operation op = null; - if (isReferenceWire) { - // Reference chain - op = chain.getSourceOperation(); - } else { - // Service chain - op = chain.getTargetOperation(); - } - if (interfaceContractMapper.isCompatible(operation, op, op.getInterface().isRemotable())) { - invocationChainMap.put(operation, chain); - return chain; - } - } - invocationChainMap.put(operation, null); - return null; - } else { - return cached; - } - } - - public Object invoke(Message msg) throws InvocationTargetException { - return getBindingInvocationChain().getHeadInvoker().invoke(msg); - } - - public Object invoke(Operation operation, Object[] args) throws InvocationTargetException { - Message msg = messageFactory.createMessage(); - msg.setBody(args); - return invoker.invoke(operation, msg); - } - - public Object invoke(Operation operation, Message msg) throws InvocationTargetException { - return invoker.invoke(operation, msg); - } - - /** - * Navigate the component/componentType inheritence chain to find the leaf contract - * @param contract - * @return - */ - private Contract getLeafContract(Contract contract) { - Contract prev = null; - Contract current = contract; - while (current != null) { - prev = current; - if (current instanceof ComponentReference) { - current = ((ComponentReference)current).getReference(); - } else if (current instanceof CompositeReference) { - current = ((CompositeReference)current).getPromotedReferences().get(0); - } else if (current instanceof ComponentService) { - current = ((ComponentService)current).getService(); - } else if (current instanceof CompositeService) { - current = ((CompositeService)current).getPromotedService(); - } else { - break; - } - if (current == null) { - return prev; - } - } - return current; - } - - private InterfaceContract getLeafInterfaceContract(EndpointReference epr) { - ComponentReference reference = epr.getReference(); - if (reference == null) { - return epr.getInterfaceContract(); - } - InterfaceContract interfaceContract = getLeafContract(reference).getInterfaceContract(); - if (interfaceContract == null) { - interfaceContract = epr.getInterfaceContract(); - } - return interfaceContract; - } - - private InterfaceContract getLeafInterfaceContract(Endpoint ep) { - ComponentService service = ep.getService(); - if (service == null) { - return ep.getInterfaceContract(); - } - InterfaceContract interfaceContract = getLeafContract(service).getInterfaceContract(); - if (interfaceContract == null) { - interfaceContract = ep.getInterfaceContract(); - } - return interfaceContract; - } - - /** - * Initialize the invocation chains - */ - private void initInvocationChains() { - chains = new ArrayList<InvocationChain>(); - InterfaceContract sourceContract = endpointReference.getInterfaceContract(); - // TODO - EPR why is this looking at the component types. The endpoint reference should have the right interface contract by this time - //InterfaceContract sourceContract = getLeafInterfaceContract(endpointReference); - - if (isReferenceWire) { - // It's the reference wire - resolveEndpointReference(); - - InterfaceContract targetContract = endpoint.getInterfaceContract(); - // TODO - EPR why is this looking at the component types. The endpoint should have the right interface contract by this time - //InterfaceContract targetContract = getLeafInterfaceContract(endpoint); - - RuntimeComponentReference reference = (RuntimeComponentReference)endpointReference.getReference(); - Binding refBinding = endpointReference.getBinding(); - for (Operation operation : sourceContract.getInterface().getOperations()) { - Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation); - if (targetOperation == null) { - throw new ServiceRuntimeException("No matching operation for " + operation.getName() - + " is found in reference " - + endpointReference.getComponent().getURI() - + "#" - + reference.getName()); - } - InvocationChain chain = new InvocationChainImpl(operation, targetOperation, true, phaseManager); - if (operation.isNonBlocking()) { - addNonBlockingInterceptor(reference, refBinding, chain); - } - chains.add(chain); - addReferenceBindingInterceptor(reference, refBinding, chain, operation); - } - - } else { - // It's the service wire - RuntimeComponentService service = (RuntimeComponentService)endpoint.getService(); - RuntimeComponent serviceComponent = (RuntimeComponent)endpoint.getComponent(); - Binding serviceBinding = endpoint.getBinding(); - //InterfaceContract targetContract = endpoint.getInterfaceContract(); - // TODO - EPR - why is this looking at the component types. The endpoint should have the right interface contract by this time - InterfaceContract targetContract = getLeafInterfaceContract(endpoint); - endpoint.setInterfaceContract(targetContract); - for (Operation operation : sourceContract.getInterface().getOperations()) { - Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation); - if (targetOperation == null) { - throw new ServiceRuntimeException("No matching operation for " + operation.getName() - + " is found in service " - + serviceComponent.getURI() - + "#" - + service.getName()); - } - InvocationChain chain = new InvocationChainImpl(operation, targetOperation, false, phaseManager); - if (operation.isNonBlocking()) { - addNonBlockingInterceptor(service, serviceBinding, chain); - } - addServiceBindingInterceptor(service, serviceBinding, chain, operation); - addImplementationInterceptor(serviceComponent, service, chain, targetOperation); - chains.add(chain); - } - - } - wireProcessor.process(this); - } - - - /** - * This code used to be in the activator but has moved here as - * the endpoint reference may not now be resolved until the wire - * is first used - */ - private void resolveEndpointReference(){ - boolean ok = eprBinder.bind(compositeContext.getEndpointRegistry(), endpointReference); - - if (!ok) { - throw new SCARuntimeException("Unable to bind " + endpointReference); - } - - // set the endpoint based on the resolved endpoint - endpoint = endpointReference.getTargetEndpoint(); - - RuntimeComponentReference runtimeRef = (RuntimeComponentReference)endpointReference.getReference(); - - if (runtimeRef.getBindingProvider(endpointReference.getBinding()) == null) { - addReferenceBindingProvider(endpointReference, - (RuntimeComponent)endpointReference.getComponent(), - runtimeRef, - endpointReference.getBinding()); - } - - // start the binding provider - final ReferenceBindingProvider bindingProvider = runtimeRef.getBindingProvider(endpointReference.getBinding()); - - if (bindingProvider != null) { - // Allow bindings to add shutdown hooks. Requires RuntimePermission shutdownHooks in policy. - AccessController.doPrivileged(new PrivilegedAction<Object>() { - public Object run() { - bindingProvider.start(); - return null; - } - }); - } - for (PolicyProvider policyProvider : runtimeRef.getPolicyProviders(endpointReference.getBinding())) { - policyProvider.start(); - } - - InterfaceContract bindingContract = getInterfaceContract(endpointReference.getReference(), endpointReference.getBinding()); - Endpoint endpoint = endpointReference.getTargetEndpoint(); - endpoint.setInterfaceContract(bindingContract); - } - - private ReferenceBindingProvider addReferenceBindingProvider( - EndpointReference endpointReference, - RuntimeComponent component, RuntimeComponentReference reference, - Binding binding) { - BindingProviderFactory providerFactory = (BindingProviderFactory) providerFactories - .getProviderFactory(binding.getClass()); - if (providerFactory != null) { - @SuppressWarnings("unchecked") - ReferenceBindingProvider bindingProvider = providerFactory - .createReferenceBindingProvider(endpointReference); - if (bindingProvider != null) { - ((RuntimeComponentReference) reference).setBindingProvider( - binding, bindingProvider); - } - for (PolicyProviderFactory f : providerFactories - .getPolicyProviderFactories()) { - PolicyProvider policyProvider = f - .createReferencePolicyProvider(endpointReference); - if (policyProvider != null) { - reference.addPolicyProvider(binding, policyProvider); - } - } - - return bindingProvider; - } else { - throw new IllegalStateException( - "Provider factory not found for binding: " - + binding.getType()); - } - } - - private InterfaceContract getInterfaceContract(ComponentReference reference, Binding binding) { - InterfaceContract interfaceContract = reference.getInterfaceContract(); - if (interfaceContract == null) { - interfaceContract = endpoint.getInterfaceContract(); - } - ReferenceBindingProvider provider = ((RuntimeComponentReference)reference).getBindingProvider(binding); - if (provider != null) { - InterfaceContract bindingContract = provider.getBindingInterfaceContract(); - if (bindingContract != null) { - interfaceContract = bindingContract; - } - } - return interfaceContract.makeUnidirectional(false); - } - - private void initReferenceBindingInvocationChains() { - RuntimeComponentReference reference = (RuntimeComponentReference)endpointReference.getReference(); - Binding referenceBinding = endpointReference.getBinding(); - - // add the binding interceptors to the reference binding wire - ReferenceBindingProvider provider = reference.getBindingProvider(referenceBinding); - if ((provider != null) && (provider instanceof ReferenceBindingProviderRRB)) { - ((ReferenceBindingProviderRRB)provider).configureBindingChain(this); - } - - // add the policy interceptors to the service binding wire - // find out which policies are active - List<PolicyProvider> pps = ((RuntimeComponentReference)reference).getPolicyProviders(referenceBinding); - if (pps != null) { - for (PolicyProvider p : pps) { - if (p instanceof PolicyProviderRRB) { - Interceptor interceptor = ((PolicyProviderRRB)p).createBindingInterceptor(); - if (interceptor != null) { - bindingInvocationChain.addInterceptor(interceptor); - } - } - } - } - } - - private void initServiceBindingInvocationChains() { - RuntimeComponentService service = (RuntimeComponentService)endpoint.getService(); - Binding serviceBinding = endpoint.getBinding(); - - // add the binding interceptors to the service binding wire - ServiceBindingProvider provider = service.getBindingProvider(serviceBinding); - if ((provider != null) && (provider instanceof ServiceBindingProviderRRB)) { - ((ServiceBindingProviderRRB)provider).configureBindingChain(this); - } - - // add the policy interceptors to the service binding wire - List<PolicyProvider> pps = ((RuntimeComponentService)service).getPolicyProviders(serviceBinding); - if (pps != null) { - for (PolicyProvider p : pps) { - if (p instanceof PolicyProviderRRB) { - Interceptor interceptor = ((PolicyProviderRRB)p).createBindingInterceptor(); - if (interceptor != null) { - bindingInvocationChain.addInterceptor(interceptor); - } - } - } - } - - // TODO - add something on the end of the wire to invoke the - // invocation chain. Need to split out the runtime - // wire invoker into conversation, callback interceptors etc - bindingInvocationChain.addInvoker(invoker); - - } - - // =============================================================== - // TODO - EPR remove when we convert fully over to EndpointReference2 - - // TODO - remove. Just here during development -/* - static EndpointReference epr; - - public EndpointReference getSource() { - // TODO - EPR convert this into method that returns EndpointReference2 - - // convert the source info into old endpoint reference format - epr = - new EndpointReferenceImpl((RuntimeComponent)endpointReference.getComponent(), endpointReference - .getReference(), endpointReference.getBinding(), endpointReference.getInterfaceContract()); - - if (endpointReference.getCallbackEndpoint() != null) { - // convert the source callback endpoint into old endpoint reference format - EndpointReference cepr; - cepr = - new EndpointReferenceImpl((RuntimeComponent)endpointReference.getComponent(), endpointReference - .getCallbackEndpoint().getService(), endpointReference.getCallbackEndpoint().getBinding(), - endpointReference.getCallbackEndpoint().getInterfaceContract()); - epr.setCallbackEndpoint(cepr); - } - - // TODO - somtimes used to reset the interface contract so we - // copy it back in in the rebuild method below - return epr; - } - - public EndpointReference getTarget() { - // TODO - EPR convert this into method that returns Endpoint2 - - Endpoint2 endpoint = this.endpoint != null ? this.endpoint : endpointReference.getTargetEndpoint(); - - // convert the target info into old endpoint reference format - EndpointReference epr = - new EndpointReferenceImpl((RuntimeComponent)endpoint.getComponent(), endpoint.getService(), endpoint - .getBinding(), endpoint.getInterfaceContract()); - return epr; - } - - public void setTarget(EndpointReference target) { - // TODO - can we use the idea of setTarget to rebuild the wire? - - } -*/ - - // =================================================================== - - public void rebuild() { - // TODO - can we use the idea of setTarget to rebuild the wire? - // used at the moment by binding.sca when it resets the - // source interface contract for local wires - this.chains = null; - - this.endpointReference.setStatus(EndpointReference.NOT_CONFIGURED); - - // TODO - cheating here as I fixed the RuntimeComponentService code - // to call this when it resets the interface contract - //endpointReference.setInterfaceContract(epr.getInterfaceContract()); - } - - public EndpointReference getEndpointReference() { - return endpointReference; - } - - public Endpoint getEndpoint() { - return endpoint; - } - - /** - * Add the interceptor for a reference binding - * - * @param reference - * @param binding - * @param chain - * @param operation - */ - private void addReferenceBindingInterceptor(ComponentReference reference, - Binding binding, - InvocationChain chain, - Operation operation) { - ReferenceBindingProvider provider = ((RuntimeComponentReference)reference).getBindingProvider(binding); - if (provider != null) { - Invoker invoker = provider.createInvoker(operation); - if (invoker != null) { - chain.addInvoker(invoker); - } - } - List<PolicyProvider> pps = ((RuntimeComponentReference)reference).getPolicyProviders(binding); - if (pps != null) { - for (PolicyProvider p : pps) { - Interceptor interceptor = p.createInterceptor(operation); - if (interceptor != null) { - chain.addInterceptor(p.createInterceptor(operation)); - } - } - } - } - - /** - * Add the interceptor for a binding - * - * @param reference - * @param binding - * @param chain - * @param operation - */ - private void addServiceBindingInterceptor(ComponentService service, - Binding binding, - InvocationChain chain, - Operation operation) { - List<PolicyProvider> pps = ((RuntimeComponentService)service).getPolicyProviders(binding); - if (pps != null) { - for (PolicyProvider p : pps) { - Interceptor interceptor = p.createInterceptor(operation); - if (interceptor != null) { - chain.addInterceptor(p.createInterceptor(operation)); - } - } - } - } - - /** - * Add a non-blocking interceptor if the reference binding needs it - * - * @param reference - * @param binding - * @param chain - */ - private void addNonBlockingInterceptor(ComponentReference reference, Binding binding, InvocationChain chain) { - ReferenceBindingProvider provider = ((RuntimeComponentReference)reference).getBindingProvider(binding); - if (provider != null) { - boolean supportsOneWayInvocation = provider.supportsOneWayInvocation(); - if (!supportsOneWayInvocation) { - chain.addInterceptor(Phase.REFERENCE, new NonBlockingInterceptor(workScheduler)); - } - } - } - - /** - * Add a non-blocking interceptor if the service binding needs it - * - * @param service - * @param binding - * @param chain - */ - private void addNonBlockingInterceptor(ComponentService service, Binding binding, InvocationChain chain) { - ServiceBindingProvider provider = ((RuntimeComponentService)service).getBindingProvider(binding); - if (provider != null) { - if (!provider.supportsOneWayInvocation()) { - chain.addInterceptor(Phase.SERVICE, new NonBlockingInterceptor(workScheduler)); - } - } - } - - /** - * Add the interceptor for a component implementation - * - * @param component - * @param service - * @param chain - * @param operation - */ - private void addImplementationInterceptor(Component component, - ComponentService service, - InvocationChain chain, - Operation operation) { - - - - if (service.getService() instanceof CompositeService){ - CompositeService compositeService = (CompositeService)service.getService(); - component = getPromotedComponent(compositeService); - service = getPromotedComponentService(compositeService); - } - - ImplementationProvider provider = ((RuntimeComponent)component).getImplementationProvider(); - - if (provider != null) { - Invoker invoker = null; - invoker = provider.createInvoker((RuntimeComponentService)service, operation); - chain.addInvoker(invoker); - } - // TODO - EPR - don't we need to get the policy from the right level in the - // model rather than the leafmost level - List<PolicyProvider> pps = ((RuntimeComponent)component).getPolicyProviders(); - if (pps != null) { - for (PolicyProvider p : pps) { - Interceptor interceptor = p.createInterceptor(operation); - if (interceptor != null) { - chain.addInterceptor(p.createInterceptor(operation)); - } - } - } - } - - /** - * @see java.lang.Object#clone() - */ - @Override - public Object clone() throws CloneNotSupportedException { - RuntimeWireImpl copy = (RuntimeWireImpl)super.clone(); - copy.endpointReference = (EndpointReference)endpointReference.clone(); - copy.endpoint = copy.endpointReference.getTargetEndpoint(); - copy.invoker = new RuntimeWireInvoker(copy.messageFactory, copy); - copy.cachedWire = null; // TUSCANY-2630 - return copy; - } - - public synchronized RuntimeWire lookupCache(Endpoint callback) { - if (lastCallback != null && - callback.getURI().equals(lastCallback.getURI()) && - !wireReserved) { - wireReserved = true; - return cachedWire; - } else { - return null; - } - } - - public synchronized void addToCache(Endpoint callback, RuntimeWire clonedWire) { - ((RuntimeWireImpl)clonedWire).setClonedFrom(this); - lastCallback = callback; - cachedWire = clonedWire; - wireReserved = true; - } - - public synchronized void releaseClonedWire(RuntimeWire wire) { - if (cachedWire == wire) { - wireReserved = false; - } - } - - public synchronized void releaseWire() { - clonedFrom.releaseClonedWire(this); - } - - private void setClonedFrom(RuntimeWireImpl wire) { - clonedFrom = wire; - } - - public ExtensionPointRegistry getExtensionPoints() { - return extensionPoints; - } - - /** - * Follow a service promotion chain down to the inner most (non composite) - * component service. - * - * @param topCompositeService - * @return - */ - private ComponentService getPromotedComponentService(CompositeService compositeService) { - ComponentService componentService = compositeService.getPromotedService(); - if (componentService != null) { - Service service = componentService.getService(); - if (componentService.getName() != null && service instanceof CompositeService) { - - // Continue to follow the service promotion chain - return getPromotedComponentService((CompositeService)service); - - } else { - - // Found a non-composite service - return componentService; - } - } else { - - // No promoted service - return null; - } - } - - /** - * Follow a service promotion chain down to the innermost (non-composite) component. - * - * @param compositeService - * @return - */ - private Component getPromotedComponent(CompositeService compositeService) { - ComponentService componentService = compositeService.getPromotedService(); - if (componentService != null) { - Service service = componentService.getService(); - if (componentService.getName() != null && service instanceof CompositeService) { - - // Continue to follow the service promotion chain - return getPromotedComponent((CompositeService)service); - - } else { - - // Found a non-composite service - return compositeService.getPromotedComponent(); - } - } else { - - // No promoted service - return null; - } - } - - public boolean isOutOfDate() { - return eprBinder.isOutOfDate(compositeContext.getEndpointRegistry(), getEndpointReference()); - } -} diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ServiceReferenceExt.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ServiceReferenceExt.java index 9b60415132..5206f0945e 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ServiceReferenceExt.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ServiceReferenceExt.java @@ -21,40 +21,21 @@ package org.apache.tuscany.sca.core.context; import java.io.Externalizable; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.sca.assembly.EndpointReference; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; import org.oasisopen.sca.ServiceReference; /** * Extended ServiceReference */ public interface ServiceReferenceExt<B> extends ServiceReference<B>, Externalizable { - /** - * Return the wire that sits behind this service reference - * @return wire - */ - RuntimeWire getRuntimeWire(); /** * Return the EndpointReference that sits behind this service reference * @return endpoint reference */ - EndpointReference getEndpointReference(); - - // TODO - EPR - the the following still required? - /** - * TBD - * - * @param callbackID - */ - void attachCallbackID(Object callbackID); + RuntimeEndpointReference getEndpointReference(); + + B getProxy(); + void setProxy(B proxy); - /** - * TBD - * - * @return - */ - XMLStreamReader getXMLReader(); } diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java index 5218a7fd01..542a80f926 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java @@ -18,22 +18,19 @@ */ package org.apache.tuscany.sca.core.context.impl; - import java.util.List; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.context.CompositeContext; import org.apache.tuscany.sca.context.ThreadMessageContext; -import org.apache.tuscany.sca.core.assembly.impl.RuntimeWireImpl; -import org.apache.tuscany.sca.core.invocation.ProxyFactory; import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; +import org.oasisopen.sca.ServiceRuntimeException; public class CallbackServiceReferenceImpl<B> extends ServiceReferenceImpl<B> { - private RuntimeWire wire; - private List<RuntimeWire> wires; + private RuntimeEndpointReference callbackEPR; + private List<? extends EndpointReference> callbackEPRs; private Endpoint resolvedEndpoint; /* @@ -42,57 +39,65 @@ public class CallbackServiceReferenceImpl<B> extends ServiceReferenceImpl<B> { public CallbackServiceReferenceImpl() { super(); } - - public CallbackServiceReferenceImpl(Class<B> interfaze, List<RuntimeWire> wires, ProxyFactory proxyFactory) { - super(interfaze, null, proxyFactory); - this.wires = wires; - init(); + + public CallbackServiceReferenceImpl(Class<B> interfaze, + List<? extends EndpointReference> callbackEPRs) { + super(interfaze, null, getCompositeContext(callbackEPRs)); + this.callbackEPRs = callbackEPRs; + init(); + } + + private static CompositeContext getCompositeContext(List<? extends EndpointReference> callbackEPRs) { + if(!callbackEPRs.isEmpty()) { + RuntimeEndpointReference epr = (RuntimeEndpointReference) callbackEPRs.get(0); + return epr.getCompositeContext(); + } + return null; } public void init() { Message msgContext = ThreadMessageContext.getMessageContext(); - wire = selectCallbackWire(msgContext); - if (wire == null) { - //FIXME: need better exception - throw new RuntimeException("No callback binding found for " + msgContext.getTo().toString()); + callbackEPR = selectCallbackEPR(msgContext); + if (callbackEPR == null) { + throw new ServiceRuntimeException("No callback binding found for " + msgContext.getTo().toString()); } resolvedEndpoint = msgContext.getFrom().getCallbackEndpoint(); } @Override - protected Object createProxy() throws Exception { + protected B createProxy() throws Exception { return proxyFactory.createCallbackProxy(this); - } + } - public RuntimeWire getCallbackWire() { + public RuntimeEndpointReference getCallbackEPR() { if (resolvedEndpoint == null) { return null; } else { - return cloneAndBind(wire); - } + return cloneAndBind(callbackEPR); + } } public Endpoint getResolvedEndpoint() { - return resolvedEndpoint; - } + return resolvedEndpoint; + } - private RuntimeWire selectCallbackWire(Message msgContext) { + private RuntimeEndpointReference selectCallbackEPR(Message msgContext) { // look for callback binding with same name as service binding Endpoint to = msgContext.getTo(); if (to == null) { //FIXME: need better exception - throw new RuntimeException("Destination for forward call is not available"); + throw new ServiceRuntimeException("Destination for forward call is not available"); } - for (RuntimeWire wire : wires) { - if (wire.getEndpointReference().getBinding().getName().equals(to.getBinding().getName())) { - return wire; + for (EndpointReference epr : callbackEPRs) { + if (epr.getBinding().getName().equals(to.getBinding().getName())) { + return (RuntimeEndpointReference) epr; } } // if no match, look for callback binding with same type as service binding - for (RuntimeWire wire : wires) { - if (wire.getEndpointReference().getBinding().getClass() == to.getBinding().getClass()) { - return wire; + for (EndpointReference epr : callbackEPRs) { + if (epr.getBinding().getType().equals(to.getBinding().getType())) { + return (RuntimeEndpointReference) epr; } } @@ -100,55 +105,20 @@ public class CallbackServiceReferenceImpl<B> extends ServiceReferenceImpl<B> { return null; } - private RuntimeWire cloneAndBind(RuntimeWire wire) { - RuntimeWire boundWire = null; + private RuntimeEndpointReference cloneAndBind(RuntimeEndpointReference endpointReference) { if (resolvedEndpoint != null) { - boundWire = ((RuntimeWireImpl)wire).lookupCache(resolvedEndpoint); - if (boundWire != null) { - return boundWire; - } + try { - // TODO - EPR - is this correct? - - // Fluff up a new response wire based on the callback endpoint - RuntimeComponentReference ref = - bind((RuntimeComponentReference)wire.getEndpointReference().getReference(), - resolvedEndpoint); - - boundWire = ref.getRuntimeWires().get(0); - - Binding binding = wire.getEndpointReference().getBinding(); - - ((RuntimeWireImpl)wire).addToCache(resolvedEndpoint, boundWire); + RuntimeEndpointReference epr = (RuntimeEndpointReference)endpointReference.clone(); + epr.setTargetEndpoint(resolvedEndpoint); + return epr; } catch (CloneNotSupportedException e) { // will not happen + throw new ServiceRuntimeException(e); } + } else { + return null; } - return boundWire; } - private RuntimeComponentReference bind(RuntimeComponentReference reference, - Endpoint callbackEndpoint) throws CloneNotSupportedException { - - // clone the callback reference ready to configure it for this callback endpoint - RuntimeComponentReference ref = (RuntimeComponentReference)reference.clone(); - ref.getTargets().clear(); - ref.getBindings().clear(); - ref.getEndpointReferences().clear(); - - // no access to the assembly factory so clone an existing epr - EndpointReference callbackEndpointReference = (EndpointReference)reference.getEndpointReferences().get(0).clone(); - - callbackEndpointReference.setReference(ref); - callbackEndpointReference.setTargetEndpoint(callbackEndpoint); - callbackEndpointReference.setUnresolved(true); - - // TODO - should really use incoming callback info but awaiting - // decision from OASIS on what will happen with callbacks - // The callback endpoint will be resolved with the registry - // when the wire chains are created - ref.getEndpointReferences().add(callbackEndpointReference); - - return ref; - } } diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java index 4e71181747..115a4d31dd 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java @@ -23,7 +23,6 @@ import java.util.Collection; import java.util.List; import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.assembly.Component; import org.apache.tuscany.sca.assembly.ComponentProperty; import org.apache.tuscany.sca.assembly.ComponentReference; @@ -31,8 +30,8 @@ import org.apache.tuscany.sca.assembly.ComponentService; import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.assembly.Multiplicity; -import org.apache.tuscany.sca.assembly.OptimizableBinding; import org.apache.tuscany.sca.assembly.Reference; +import org.apache.tuscany.sca.assembly.SCABinding; import org.apache.tuscany.sca.assembly.Service; import org.apache.tuscany.sca.context.CompositeContext; import org.apache.tuscany.sca.context.ContextFactoryExtensionPoint; @@ -49,16 +48,14 @@ 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.monitor.Monitor; -import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.runtime.CompositeActivator; import org.apache.tuscany.sca.runtime.EndpointReferenceBinder; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentContext; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; import org.oasisopen.sca.RequestContext; -import org.oasisopen.sca.SCARuntimeException; import org.oasisopen.sca.ServiceReference; import org.oasisopen.sca.ServiceRuntimeException; @@ -78,28 +75,27 @@ public class ComponentContextImpl implements RuntimeComponentContext { private final JavaInterfaceFactory javaInterfaceFactory; private final PropertyValueFactory propertyFactory; private final EndpointReferenceBinder eprBinder; - private final Monitor monitor; - - public ComponentContextImpl(ExtensionPointRegistry registry, CompositeContext compositeContext, RuntimeComponent component) { + + public ComponentContextImpl(ExtensionPointRegistry registry, + CompositeContext compositeContext, + RuntimeComponent component) { this.component = component; FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class); this.assemblyFactory = factories.getFactory(AssemblyFactory.class); this.javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class); - + UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class); this.compositeContext = compositeContext; - + this.compositeActivator = utilities.getUtility(CompositeActivator.class); - + this.requestContextFactory = registry.getExtensionPoint(ContextFactoryExtensionPoint.class).getFactory(RequestContextFactory.class); this.proxyFactory = new ExtensibleProxyFactory(registry.getExtensionPoint(ProxyFactoryExtensionPoint.class)); this.propertyFactory = factories.getFactory(PropertyValueFactory.class); - + this.eprBinder = utilities.getUtility(EndpointReferenceBinder.class); - MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class); - this.monitor = monitorFactory.createMonitor(); } public String getURI() { @@ -116,31 +112,64 @@ public class ComponentContextImpl implements RuntimeComponentContext { } public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName) { - try { - for (ComponentReference ref : component.getReferences()) { - if (referenceName.equals(ref.getName())) { - /* ******************** Contribution for issue TUSCANY-2281 ******************** */ - Multiplicity multiplicity = ref.getMultiplicity(); - if (multiplicity == Multiplicity.ZERO_N || multiplicity == Multiplicity.ONE_N) { - throw new IllegalArgumentException("Reference " + referenceName - + " has multiplicity " - + multiplicity); - } - /* ******************** Contribution for issue TUSCANY-2281 ******************** */ - return getServiceReference(businessInterface, (RuntimeComponentReference)ref, null); + for (ComponentReference ref : component.getReferences()) { + if (referenceName.equals(ref.getName())) { + Multiplicity multiplicity = ref.getMultiplicity(); + if (multiplicity == Multiplicity.ZERO_N || multiplicity == Multiplicity.ONE_N) { + throw new ServiceRuntimeException("Reference " + referenceName + + " has multiplicity " + + multiplicity); } + return getServiceReference(businessInterface, (RuntimeEndpointReference)getEndpointReference(ref)); } - throw new ServiceRuntimeException("Reference not found: " + referenceName); - } catch (ServiceRuntimeException e) { - throw e; - } catch (Exception e) { - if (e instanceof RuntimeException) { - throw (RuntimeException)e; + } + throw new ServiceRuntimeException("Reference not found: " + referenceName); + + } + + /** + * Select an endpoint reference from the component reference + * @param ref + * @return + */ + private EndpointReference getEndpointReference(ComponentReference ref) { + List<EndpointReference> eprs = ref.getEndpointReferences(); + if (eprs.size() == 1) { + // Return 1st one + return eprs.get(0); + } else { + for (EndpointReference epr : eprs) { + // Try to see if there is an EPR using binding.sca + if (epr.getBinding().getType().equals(SCABinding.TYPE)) { + return epr; + } } - throw new ServiceRuntimeException(e.getMessage(), e); + return eprs.get(0); } } + + /** + * Select an endpoint reference from the component reference + * @param ref + * @return + */ + private Endpoint getEndpoint(ComponentService service) { + List<Endpoint> eps = service.getEndpoints(); + if (eps.size() == 1) { + // Return 1st one + return eps.get(0); + } else { + for (Endpoint ep : eps) { + // Try to see if there is an EPR using binding.sca + if (ep.getBinding().getType().equals(SCABinding.TYPE)) { + return ep; + } + } + return eps.get(0); + } + } + /** * Gets the value for the specified property with the specified type. @@ -190,7 +219,6 @@ public class ComponentContextImpl implements RuntimeComponentContext { return targetService; } - public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface) { ComponentService service = getSingleService(component); try { @@ -223,10 +251,10 @@ public class ComponentContextImpl implements RuntimeComponentContext { */ public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface, ComponentService service) { try { - RuntimeComponentReference ref = - (RuntimeComponentReference)createSelfReference(component, service, businessInterface); + RuntimeEndpointReference ref = + (RuntimeEndpointReference)createSelfReference(component, service, businessInterface); ref.setComponent(component); - return getServiceReference(businessInterface, ref, null); + return getServiceReference(businessInterface, ref); } catch (Exception e) { throw new ServiceRuntimeException(e); } @@ -248,18 +276,17 @@ public class ComponentContextImpl implements RuntimeComponentContext { * @throws InvalidInterfaceException */ public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, - RuntimeComponentReference reference, - EndpointReference endpointReference) { + RuntimeEndpointReference endpointReference) { try { - RuntimeComponentReference ref = (RuntimeComponentReference)reference; - InterfaceContract interfaceContract = reference.getInterfaceContract(); - Reference componentTypeReference = reference.getReference(); + RuntimeComponentReference ref = (RuntimeComponentReference)endpointReference.getReference(); + InterfaceContract interfaceContract = ref.getInterfaceContract(); + Reference componentTypeReference = ref.getReference(); if (componentTypeReference != null && componentTypeReference.getInterfaceContract() != null) { interfaceContract = componentTypeReference.getInterfaceContract(); } InterfaceContract refInterfaceContract = getInterfaceContract(interfaceContract, businessInterface); if (refInterfaceContract != interfaceContract) { - ref = (RuntimeComponentReference)reference.clone(); + ref = (RuntimeComponentReference)ref.clone(); if (interfaceContract != null) { ref.setInterfaceContract(interfaceContract); } else { @@ -267,71 +294,24 @@ public class ComponentContextImpl implements RuntimeComponentContext { } } ref.setComponent(component); - return new ServiceReferenceImpl<B>(businessInterface, component, ref, endpointReference, proxyFactory, - component.getComponentContext().getCompositeContext()); + return new ServiceReferenceImpl<B>(businessInterface, endpointReference, component + .getComponentContext().getCompositeContext()); } catch (Exception e) { throw new ServiceRuntimeException(e); } } - /** - * Bind a component reference to a component service - * @param <B> - * @param businessInterface - * @param reference - * @param service - * @return - * @throws CloneNotSupportedException - * @throws InvalidInterfaceException - */ public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, - RuntimeComponentReference reference, - RuntimeComponent component, - RuntimeComponentService service) { - try { - RuntimeComponentReference ref = (RuntimeComponentReference)reference.clone(); - InterfaceContract interfaceContract = reference.getInterfaceContract(); - Reference componentTypeReference = reference.getReference(); - if (componentTypeReference != null && componentTypeReference.getInterfaceContract() != null) { - interfaceContract = componentTypeReference.getInterfaceContract(); - } - InterfaceContract refInterfaceContract = getInterfaceContract(interfaceContract, businessInterface); - if (refInterfaceContract != interfaceContract) { - ref = (RuntimeComponentReference)reference.clone(); - ref.setInterfaceContract(interfaceContract); - } - ref.getTargets().add(service); - ref.getBindings().clear(); - for (Binding binding : service.getBindings()) { - if (binding instanceof OptimizableBinding) { - OptimizableBinding optimizableBinding = (OptimizableBinding)((OptimizableBinding)binding).clone(); - optimizableBinding.setTargetBinding(binding); - optimizableBinding.setTargetComponent(component); - optimizableBinding.setTargetComponentService(service); - ref.getBindings().add(optimizableBinding); - } else { - ref.getBindings().add(binding); - } - } - return new ServiceReferenceImpl<B>(businessInterface, component, ref, null, proxyFactory, compositeContext); - } catch (Exception e) { - throw new ServiceRuntimeException(e); - } - } - - public <B> ServiceReference<B> getCallableReference(Class<B> businessInterface, - RuntimeComponent component, - RuntimeComponentService service) { + RuntimeEndpoint endpoint) { try { if (businessInterface == null) { - InterfaceContract contract = service.getInterfaceContract(); + InterfaceContract contract = endpoint.getInterfaceContract(); businessInterface = (Class<B>)((JavaInterface)contract.getInterface()).getJavaClass(); } - RuntimeComponentReference ref = - (RuntimeComponentReference)createSelfReference(component, service, businessInterface); + RuntimeEndpointReference ref = + (RuntimeEndpointReference)createSelfReference(component, endpoint.getService(), businessInterface); ref.setComponent(component); - return new ServiceReferenceImpl<B>(businessInterface, component, ref, null, proxyFactory, - compositeContext); + return new ServiceReferenceImpl<B>(businessInterface, ref, compositeContext); } catch (Exception e) { throw new ServiceRuntimeException(e); } @@ -344,13 +324,16 @@ public class ComponentContextImpl implements RuntimeComponentContext { * @throws CloneNotSupportedException * @throws InvalidInterfaceException */ - private ComponentReference createSelfReference(Component component, - ComponentService service, - Class<?> businessInterface) throws CloneNotSupportedException, + private EndpointReference createSelfReference(Component component, + ComponentService service, + Class<?> businessInterface) throws CloneNotSupportedException, InvalidInterfaceException { ComponentReference componentReference = assemblyFactory.createComponentReference(); componentReference.setName("$self$." + service.getName()); + + Endpoint endpoint = getEndpoint(service); + /* for (Binding binding : service.getBindings()) { if (binding instanceof OptimizableBinding) { OptimizableBinding optimizableBinding = (OptimizableBinding)((OptimizableBinding)binding).clone(); @@ -362,11 +345,13 @@ public class ComponentContextImpl implements RuntimeComponentContext { componentReference.getBindings().add(binding); } } + */ componentReference.setCallback(service.getCallback()); componentReference.getTargets().add(service); componentReference.getPolicySets().addAll(service.getPolicySets()); componentReference.getRequiredIntents().addAll(service.getRequiredIntents()); + componentReference.getBindings().add(endpoint.getBinding()); InterfaceContract interfaceContract = service.getInterfaceContract(); Service componentTypeService = service.getService(); @@ -377,32 +362,31 @@ public class ComponentContextImpl implements RuntimeComponentContext { componentReference.setInterfaceContract(interfaceContract); componentReference.setMultiplicity(Multiplicity.ONE_ONE); // component.getReferences().add(componentReference); - + // create endpoint reference - EndpointReference endpointReference = assemblyFactory - .createEndpointReference(); + EndpointReference endpointReference = assemblyFactory.createEndpointReference(); endpointReference.setComponent(component); endpointReference.setReference(componentReference); + endpointReference.setBinding(endpoint.getBinding()); endpointReference.setUnresolved(false); + endpointReference.setInterfaceContract(interfaceContract); endpointReference.setStatus(EndpointReference.WIRED_TARGET_FOUND_READY_FOR_MATCHING); - // create endpoint. - Endpoint endpoint = assemblyFactory.createEndpoint(); - endpoint.setComponent(component); - endpoint.setService(service); - endpoint.setUnresolved(true); endpointReference.setTargetEndpoint(endpoint); - + componentReference.getEndpointReferences().add(endpointReference); - + ((RuntimeComponentReference)componentReference).setComponent((RuntimeComponent)component); + ((RuntimeEndpointReference) endpointReference).bind(compositeContext); + + /* // do binding matching boolean ok = eprBinder.bind(compositeContext.getEndpointRegistry(), endpointReference); - + if (!ok) { throw new SCARuntimeException("Unable to bind " + endpointReference); } - - return componentReference; + */ + return endpointReference; } /** @@ -446,7 +430,6 @@ public class ComponentContextImpl implements RuntimeComponentContext { compositeActivator.start(compositeContext, component, reference); } - /* ******************** Contribution for issue TUSCANY-2281 ******************** */ /** @@ -470,8 +453,8 @@ public class ComponentContextImpl implements RuntimeComponentContext { if (referenceName.equals(ref.getName())) { ArrayList<ServiceReference<B>> serviceRefs = new ArrayList<ServiceReference<B>>(); for (EndpointReference endpointReference : ref.getEndpointReferences()) { - serviceRefs - .add(getServiceReference(businessInterface, (RuntimeComponentReference)ref, endpointReference)); + RuntimeEndpointReference epr = (RuntimeEndpointReference)endpointReference; + serviceRefs.add(getServiceReference(businessInterface, epr)); } return serviceRefs; } @@ -483,6 +466,7 @@ public class ComponentContextImpl implements RuntimeComponentContext { throw new ServiceRuntimeException(e.getMessage(), e); } } + /* ******************** Contribution for issue TUSCANY-2281 ******************** */ public CompositeContext getCompositeContext() { diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java index dbd243a70b..c6a6ecd9c0 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java @@ -23,6 +23,7 @@ import java.util.List; import javax.security.auth.Subject; import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.context.ThreadMessageContext; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory; @@ -33,7 +34,7 @@ import org.apache.tuscany.sca.invocation.Message; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; import org.oasisopen.sca.RequestContext; import org.oasisopen.sca.ServiceReference; @@ -68,12 +69,11 @@ public class RequestContextImpl implements RequestContext { public <B> ServiceReference<B> getServiceReference() { Message msgContext = ThreadMessageContext.getMessageContext(); // FIXME: [rfeng] Is this the service reference matching the caller side? - Endpoint to = msgContext.getTo(); - RuntimeComponentService service = (RuntimeComponentService) to.getService(); + RuntimeEndpoint to = (RuntimeEndpoint) msgContext.getTo(); RuntimeComponent component = (RuntimeComponent) to.getComponent(); - ServiceReference<B> callableReference = component.getComponentContext().getCallableReference(null, component, service); - + ServiceReference<B> callableReference = component.getComponentContext().getServiceReference(null, to); + return callableReference; } @@ -96,9 +96,9 @@ public class RequestContextImpl implements RequestContext { } JavaInterface javaInterface = (JavaInterface) callbackReference.getInterfaceContract().getInterface(); Class<CB> javaClass = (Class<CB>)javaInterface.getJavaClass(); - List<RuntimeWire> wires = callbackReference.getRuntimeWires(); + List<EndpointReference> wires = callbackReference.getEndpointReferences(); ProxyFactory proxyFactory = new ExtensibleProxyFactory(proxyFactoryExtensionPoint); - ServiceReferenceImpl ref = new CallbackServiceReferenceImpl(javaClass, wires, proxyFactory); + ServiceReferenceImpl ref = new CallbackServiceReferenceImpl(javaClass, wires); return ref; } diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java index 23126b5123..5edf357e60 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java @@ -21,17 +21,13 @@ package org.apache.tuscany.sca.core.context.impl; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; -import java.io.Reader; -import java.io.StringReader; import java.io.StringWriter; import java.security.AccessController; import java.security.PrivilegedAction; -import java.util.UUID; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLOutputFactory; import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; import org.apache.tuscany.sca.assembly.AssemblyFactory; @@ -44,7 +40,6 @@ import org.apache.tuscany.sca.assembly.builder.BindingBuilder; import org.apache.tuscany.sca.assembly.builder.BuilderContext; import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint; import org.apache.tuscany.sca.context.CompositeContext; -import org.apache.tuscany.sca.contribution.processor.ContributionReadException; import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; import org.apache.tuscany.sca.contribution.processor.ProcessorContext; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; @@ -52,19 +47,19 @@ import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtens import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory; -import org.apache.tuscany.sca.core.assembly.impl.ReferenceParametersImpl; import org.apache.tuscany.sca.core.context.ServiceReferenceExt; import org.apache.tuscany.sca.core.factory.ObjectCreationException; 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.interfacedef.Interface; +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.runtime.ReferenceParameters; +import org.apache.tuscany.sca.runtime.Invocable; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; import org.oasisopen.sca.ServiceRuntimeException; /** @@ -78,27 +73,25 @@ public class ServiceReferenceImpl<B> implements ServiceReferenceExt<B> { protected transient ProxyFactory proxyFactory; protected transient Class<B> businessInterface; - protected transient Object proxy; + protected transient B proxy; protected Object callbackID; // The callbackID should be serializable - protected transient RuntimeComponent component; - protected transient RuntimeComponentReference reference; - protected transient EndpointReference endpointReference; + protected transient RuntimeEndpointReference endpointReference; - protected String scdl; - - private transient XMLStreamReader xmlReader; +// protected String scdl; +// +// private transient XMLStreamReader xmlReader; protected transient CompositeContext compositeContext; - private ExtensionPointRegistry registry; - private FactoryExtensionPoint modelFactories; + protected ExtensionPointRegistry registry; + protected FactoryExtensionPoint modelFactories; protected RuntimeAssemblyFactory assemblyFactory; - private StAXArtifactProcessorExtensionPoint staxProcessors; - private StAXArtifactProcessor<EndpointReference> staxProcessor; - private XMLInputFactory xmlInputFactory; - private XMLOutputFactory xmlOutputFactory; - private BuilderExtensionPoint builders; + protected StAXArtifactProcessorExtensionPoint staxProcessors; + protected StAXArtifactProcessor<EndpointReference> staxProcessor; + protected XMLInputFactory xmlInputFactory; + protected XMLOutputFactory xmlOutputFactory; + protected BuilderExtensionPoint builders; /* * Public constructor for Externalizable serialization/deserialization @@ -107,56 +100,24 @@ public class ServiceReferenceImpl<B> implements ServiceReferenceExt<B> { super(); } - /* - * Public constructor for use by XMLStreamReader2CallableReference - */ - // TODO - EPR - Is this required - public ServiceReferenceImpl(XMLStreamReader xmlReader) throws Exception { - this.xmlReader = xmlReader; - resolve(); - } - - protected ServiceReferenceImpl(Class<B> businessInterface, - RuntimeComponent component, - RuntimeComponentReference reference, - EndpointReference endpointReference, - ProxyFactory proxyFactory, - CompositeContext compositeContext) { - this.proxyFactory = proxyFactory; + public ServiceReferenceImpl(Class<B> businessInterface, + Invocable endpointReference, + CompositeContext compositeContext) { this.businessInterface = businessInterface; - this.component = component; - this.reference = reference; - this.endpointReference = endpointReference; - this.compositeContext = compositeContext; - - getExtensions(); - - // FIXME: The SCA Specification is not clear how we should handle multiplicity - // for CallableReference - if (this.endpointReference == null) { - - // TODO - EPR - If no endpoint reference specified assume the first one - // This will happen when a self reference is created in which case the - // the reference should only have one endpointReference so use that - if (this.reference.getEndpointReferences().size() == 0){ - throw new ServiceRuntimeException("The reference " + reference.getName() + " in component " + - component.getName() + " has no endpoint references"); - } - - if (this.reference.getEndpointReferences().size() > 1){ - throw new ServiceRuntimeException("The reference " + reference.getName() + " in component " + - component.getName() + " has more than one endpoint reference"); - } - - this.endpointReference = this.reference.getEndpointReferences().get(0); + this.endpointReference = (RuntimeEndpointReference) endpointReference; + if (compositeContext == null) { + compositeContext = endpointReference.getCompositeContext(); } - - // FIXME: Should we normalize the componentName/serviceName URI into an absolute SCA URI in the SCA binding? - // sca:component1/component11/component112/service1? - initCallbackID(); + bind(compositeContext); } - private void getExtensions() { + public ServiceReferenceImpl(Class<B> businessInterface, + Invocable endpointReference) { + this(businessInterface, endpointReference, null); + } + + protected void bind(CompositeContext context) { + this.compositeContext = context; this.registry = compositeContext.getExtensionPointRegistry(); this.modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class); this.assemblyFactory = (RuntimeAssemblyFactory)modelFactories.getFactory(AssemblyFactory.class); @@ -165,68 +126,29 @@ public class ServiceReferenceImpl<B> implements ServiceReferenceExt<B> { this.staxProcessors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); this.staxProcessor = staxProcessors.getProcessor(EndpointReference.class); this.builders = registry.getExtensionPoint(BuilderExtensionPoint.class); + this.proxyFactory = new ExtensibleProxyFactory(registry.getExtensionPoint(ProxyFactoryExtensionPoint.class)); } - public ServiceReferenceImpl(Class<B> businessInterface, RuntimeWire wire, ProxyFactory proxyFactory) { - this.proxyFactory = proxyFactory; - this.businessInterface = businessInterface; - //ExtensionPointRegistry registry = ((RuntimeWireImpl)wire).getExtensionPoints(); - //this.modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class); - //this.assemblyFactory = (RuntimeAssemblyFactory)modelFactories.getFactory(AssemblyFactory.class); - bind(wire); - } - - public RuntimeWire getRuntimeWire() { - try { - resolve(); - if (endpointReference != null){ - return reference.getRuntimeWire(endpointReference); - } else { - return null; - } - } catch (Exception e) { - throw new ServiceRuntimeException(e); - } - } - - public EndpointReference getEndpointReference() { + public RuntimeEndpointReference getEndpointReference() { return endpointReference; } - protected void bind(RuntimeWire wire) { - if (wire != null) { - this.component = (RuntimeComponent)wire.getEndpointReference().getComponent(); - this.reference = (RuntimeComponentReference)wire.getEndpointReference().getReference(); - this.endpointReference = wire.getEndpointReference(); - this.compositeContext = component.getComponentContext().getCompositeContext(); - initCallbackID(); - } - } - - protected void initCallbackID() { - if (reference.getInterfaceContract() != null) { - if (reference.getInterfaceContract().getCallbackInterface() != null) { - this.callbackID = createCallbackID(); - } - } - } - public B getProxy() throws ObjectCreationException { try { if (proxy == null) { proxy = createProxy(); } - return businessInterface.cast(proxy); + return proxy; } catch (Exception e) { throw new ObjectCreationException(e); } } - public void setProxy(Object proxy) { + public void setProxy(B proxy) { this.proxy = proxy; } - protected Object createProxy() throws Exception { + protected B createProxy() throws Exception { return proxyFactory.createProxy(this); } @@ -248,24 +170,6 @@ public class ServiceReferenceImpl<B> implements ServiceReferenceExt<B> { } } - public boolean isConversational() { - try { - resolve(); - return reference == null ? false : reference.getInterfaceContract().getInterface().isConversational(); - } catch (Exception e) { - throw new ServiceRuntimeException(e); - } - } - - public Object getCallbackID() { - try { - resolve(); - return callbackID; - } catch (Exception e) { - throw new ServiceRuntimeException(e); - } - } - /** * Follow a service promotion chain down to the inner most (non composite) * component service. @@ -295,21 +199,23 @@ public class ServiceReferenceImpl<B> implements ServiceReferenceExt<B> { } // ============ WRITE AND READ THE REFERENCE TO EXTERNAL XML ======================== - + /** * write the reference to a stream * * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput) */ public void writeExternal(ObjectOutput out) throws IOException { + out.writeObject(endpointReference); + /* try { String xml = null; - if (scdl == null){ + if (scdl == null) { xml = toXMLString(); } else { xml = scdl; } - + if (xml == null) { out.writeBoolean(false); } else { @@ -320,73 +226,128 @@ public class ServiceReferenceImpl<B> implements ServiceReferenceExt<B> { // e.printStackTrace(); throw new IOException(e.toString()); } - } - + */ + } + /** * write the endpoint reference into an xml string */ - public String toXMLString() throws IOException, XMLStreamException, ContributionWriteException{ + public String toXMLString() throws IOException, XMLStreamException, ContributionWriteException { StringWriter writer = new StringWriter(); XMLStreamWriter streamWriter = xmlOutputFactory.createXMLStreamWriter(writer); staxProcessor.write(endpointReference, streamWriter, new ProcessorContext(registry)); return writer.toString(); - } - + } + /** * Read the reference from a stream * * @see java.io.Externalizable#readExternal(java.io.ObjectInput) */ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + this.endpointReference = (RuntimeEndpointReference) in.readObject(); + // Force resolve + endpointReference.getComponent(); + bind(endpointReference.getCompositeContext()); + + RuntimeComponentReference reference = (RuntimeComponentReference)endpointReference.getReference(); + reference.setComponent((RuntimeComponent)endpointReference.getComponent()); + + Interface i = reference.getInterfaceContract().getInterface(); + if (i instanceof JavaInterface) { + JavaInterface javaInterface = (JavaInterface)i; + if (javaInterface.isUnresolved()) { + // Allow privileged access to get ClassLoader. Requires RuntimePermission in + // security policy. + ClassLoader classLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { + public ClassLoader run() { + return Thread.currentThread().getContextClassLoader(); + } + }); + + javaInterface.setJavaClass(classLoader.loadClass(javaInterface.getName())); + JavaInterfaceFactory javaInterfaceFactory = getJavaInterfaceFactory(compositeContext); + + try { + javaInterfaceFactory.createJavaInterface(javaInterface, javaInterface.getJavaClass()); + } catch (InvalidInterfaceException e) { + throw new ServiceRuntimeException(e); + } + //FIXME: If the interface needs XSDs to be loaded (e.g., for static SDO), + // this needs to be done here. We usually search for XSDs in the current + // contribution at resolve time. Is it possible to locate the current + // contribution at runtime? + } + this.businessInterface = (Class<B>)javaInterface.getJavaClass(); + } + + Binding binding = endpointReference.getBinding(); + if (binding != null) { + BindingBuilder bindingBuilder = builders.getBindingBuilder(binding.getType()); + if (bindingBuilder != null) { + org.apache.tuscany.sca.assembly.builder.BuilderContext context = new BuilderContext(registry); + bindingBuilder.build(endpointReference.getComponent(), reference, endpointReference.getBinding(), context); + } + } + + this.proxyFactory = getProxyFactory(this.compositeContext); + + /* + endpointReference.bind(CompositeContext.getCurrentCompositeContext()); + endpointReference.rebuild(); + */ + /* final boolean hasSCDL = in.readBoolean(); if (hasSCDL) { this.scdl = in.readUTF(); } else { this.scdl = null; } - } - + */ + } + /** * Read xml string into the endpoint reference */ + /* public void fromXMLString() throws IOException, XMLStreamException, ContributionReadException { - + XMLStreamReader streamReader = xmlReader; - - if (scdl != null ){ + + if (scdl != null) { Reader reader = new StringReader(scdl); - - if (xmlInputFactory == null){ + + if (xmlInputFactory == null) { // this is a reference being read from a external stream // so set up enough of the reference in order to resolved the // xml being read - this.compositeContext = CompositeContext.getCurrentCompositeContext(); - getExtensions(); + bind(CompositeContext.getCurrentCompositeContext()); } - + streamReader = xmlInputFactory.createXMLStreamReader(reader); } - - endpointReference = staxProcessor.read(streamReader, new ProcessorContext(registry)); - + + endpointReference = (RuntimeEndpointReference) staxProcessor.read(streamReader, new ProcessorContext(registry)); + // ok to GC xmlReader = null; scdl = null; } - + */ + /** * @throws IOException */ private synchronized void resolve() throws Exception { - if ((scdl != null || xmlReader != null) && component == null && reference == null) { + /* + if ((scdl != null || xmlReader != null) && endpointReference == null) { fromXMLString(); - - this.component = (RuntimeComponent)endpointReference.getComponent(); - compositeContext.bindComponent(this.component); - - this.reference = (RuntimeComponentReference)endpointReference.getReference(); - this.reference.setComponent(this.component); - + + compositeContext.bindComponent((RuntimeComponent) endpointReference.getComponent()); + + RuntimeComponentReference reference = (RuntimeComponentReference)endpointReference.getReference(); + reference.setComponent((RuntimeComponent)endpointReference.getComponent()); + ReferenceParameters parameters = null; for (Object ext : reference.getExtensions()) { if (ext instanceof ReferenceParameters) { @@ -394,7 +355,7 @@ public class ServiceReferenceImpl<B> implements ServiceReferenceExt<B> { break; } } - + if (parameters != null) { this.callbackID = parameters.getCallbackID(); } @@ -410,10 +371,10 @@ public class ServiceReferenceImpl<B> implements ServiceReferenceExt<B> { return Thread.currentThread().getContextClassLoader(); } }); - + javaInterface.setJavaClass(classLoader.loadClass(javaInterface.getName())); JavaInterfaceFactory javaInterfaceFactory = getJavaInterfaceFactory(compositeContext); - + javaInterfaceFactory.createJavaInterface(javaInterface, javaInterface.getJavaClass()); //FIXME: If the interface needs XSDs to be loaded (e.g., for static SDO), // this needs to be done here. We usually search for XSDs in the current @@ -422,23 +383,24 @@ public class ServiceReferenceImpl<B> implements ServiceReferenceExt<B> { } this.businessInterface = (Class<B>)javaInterface.getJavaClass(); } - + Binding binding = endpointReference.getBinding(); if (binding != null) { BindingBuilder bindingBuilder = builders.getBindingBuilder(binding.getType()); if (bindingBuilder != null) { BuilderContext context = new BuilderContext(registry); - bindingBuilder.build(component, reference, endpointReference.getBinding(), context); + bindingBuilder.build(endpointReference.getComponent(), reference, endpointReference.getBinding(), context); } } - this.proxyFactory = getProxyFactory(this.compositeContext); + this.proxyFactory = getProxyFactory(this.compositeContext); } else if (compositeContext == null) { this.compositeContext = CompositeContext.getCurrentCompositeContext(); if (this.compositeContext != null) { this.proxyFactory = getProxyFactory(this.compositeContext); } - } + } + */ } private JavaInterfaceFactory getJavaInterfaceFactory(CompositeContext compositeContext) { @@ -447,35 +409,19 @@ public class ServiceReferenceImpl<B> implements ServiceReferenceExt<B> { JavaInterfaceFactory javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class); return javaInterfaceFactory; } - + private ProxyFactory getProxyFactory(CompositeContext compositeContext) { ExtensionPointRegistry extensionPointRegistry = compositeContext.getExtensionPointRegistry(); - ProxyFactoryExtensionPoint proxyFactories = extensionPointRegistry.getExtensionPoint(ProxyFactoryExtensionPoint.class); + ProxyFactoryExtensionPoint proxyFactories = + extensionPointRegistry.getExtensionPoint(ProxyFactoryExtensionPoint.class); return new ExtensibleProxyFactory(proxyFactories); } - - // ================================================================================== - - /** - * Create a callback id - * - * @return the callback id - */ - private String createCallbackID() { - return UUID.randomUUID().toString(); - } - - public void attachCallbackID(Object callbackID) { - this.callbackID = callbackID; - } - protected ReferenceParameters getReferenceParameters() { - ReferenceParameters parameters = new ReferenceParametersImpl(); - parameters.setCallbackID(callbackID); - return parameters; - } + // ================================================================================== + /* public XMLStreamReader getXMLReader() { return xmlReader; } + */ } diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallableReferenceObjectFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallableReferenceObjectFactory.java index d4fe266d44..2323973938 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallableReferenceObjectFactory.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallableReferenceObjectFactory.java @@ -18,11 +18,10 @@ */ package org.apache.tuscany.sca.core.invocation; -import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.core.factory.ObjectCreationException; import org.apache.tuscany.sca.core.factory.ObjectFactory; import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; import org.oasisopen.sca.ServiceReference; /** @@ -32,9 +31,7 @@ import org.oasisopen.sca.ServiceReference; */ public class CallableReferenceObjectFactory implements ObjectFactory<ServiceReference<?>> { private Class<?> businessInterface; - private RuntimeComponent component; - private RuntimeComponentReference reference; - private EndpointReference endpointReference; + private RuntimeEndpointReference endpointReference; /** * Constructor. @@ -47,17 +44,14 @@ public class CallableReferenceObjectFactory implements ObjectFactory<ServiceRefe * @param binding the binding for the reference */ public CallableReferenceObjectFactory(Class<?> businessInterface, - RuntimeComponent component, - RuntimeComponentReference reference, - EndpointReference endpointReference) { + RuntimeEndpointReference endpointReference) { this.businessInterface = businessInterface; - this.component = component; - this.reference = reference; this.endpointReference = endpointReference; } public ServiceReference<?> getInstance() throws ObjectCreationException { - return component.getComponentContext().getServiceReference(businessInterface, reference, endpointReference); + RuntimeComponent component = (RuntimeComponent) endpointReference.getComponent(); + return component.getComponentContext().getServiceReference(businessInterface, endpointReference); } } diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackReferenceObjectFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackReferenceObjectFactory.java index 021d588cb4..0c77ee75f6 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackReferenceObjectFactory.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackReferenceObjectFactory.java @@ -20,11 +20,10 @@ package org.apache.tuscany.sca.core.invocation; import java.util.List; +import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.core.context.impl.CallbackServiceReferenceImpl; -import org.apache.tuscany.sca.core.context.impl.ServiceReferenceImpl; import org.apache.tuscany.sca.core.factory.ObjectCreationException; import org.apache.tuscany.sca.core.factory.ObjectFactory; -import org.apache.tuscany.sca.runtime.RuntimeWire; import org.oasisopen.sca.ServiceReference; /** @@ -35,16 +34,16 @@ import org.oasisopen.sca.ServiceReference; public class CallbackReferenceObjectFactory implements ObjectFactory<ServiceReference<?>> { private Class<?> businessInterface; private ProxyFactory proxyFactory; - private List<RuntimeWire> wires; + private List<EndpointReference> wires; - public CallbackReferenceObjectFactory(Class<?> interfaze, ProxyFactory proxyFactory, List<RuntimeWire> wires) { + public CallbackReferenceObjectFactory(Class<?> interfaze, ProxyFactory proxyFactory, List<EndpointReference> wires) { this.businessInterface = interfaze; this.proxyFactory = proxyFactory; this.wires = wires; } public ServiceReference<?> getInstance() throws ObjectCreationException { - return new CallbackServiceReferenceImpl(businessInterface, wires, proxyFactory); + return new CallbackServiceReferenceImpl(businessInterface, wires); } } diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java index 2b37c30451..90d7374145 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java @@ -22,7 +22,7 @@ import java.util.List; import org.apache.tuscany.sca.core.factory.ObjectCreationException; import org.apache.tuscany.sca.core.factory.ObjectFactory; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.Invocable; /** * Returns proxy instance for a wire callback @@ -32,9 +32,9 @@ import org.apache.tuscany.sca.runtime.RuntimeWire; public class CallbackWireObjectFactory<B> implements ObjectFactory<B> { private Class<B> businessInterface; private ProxyFactory proxyFactory; - private List<RuntimeWire> wires; + private List<Invocable> wires; - public CallbackWireObjectFactory(Class<B> interfaze, ProxyFactory proxyFactory, List<RuntimeWire> wires) { + public CallbackWireObjectFactory(Class<B> interfaze, ProxyFactory proxyFactory, List<Invocable> wires) { this.businessInterface = interfaze; this.proxyFactory = proxyFactory; this.wires = wires; diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java index 11edc283a4..f04573dd71 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java @@ -28,12 +28,13 @@ import net.sf.cglib.proxy.Factory; import net.sf.cglib.proxy.MethodInterceptor; import net.sf.cglib.proxy.MethodProxy; +import org.apache.tuscany.sca.core.context.ServiceReferenceExt; import org.apache.tuscany.sca.core.context.impl.ServiceReferenceImpl; import org.apache.tuscany.sca.core.invocation.impl.JDKCallbackInvocationHandler; import org.apache.tuscany.sca.core.invocation.impl.JDKInvocationHandler; import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; import org.apache.tuscany.sca.invocation.MessageFactory; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.Invocable; import org.oasisopen.sca.ServiceReference; /** @@ -49,8 +50,8 @@ public class CglibProxyFactory implements ProxyFactory { } - public <T> T createProxy(Class<T> interfaze, RuntimeWire wire) throws ProxyCreationException { - ServiceReference<T> serviceReference = new ServiceReferenceImpl(interfaze, wire, this); + public <T> T createProxy(Class<T> interfaze, Invocable wire) throws ProxyCreationException { + ServiceReference<T> serviceReference = new ServiceReferenceImpl(interfaze, wire, null); return createProxy(serviceReference); } @@ -72,8 +73,8 @@ public class CglibProxyFactory implements ProxyFactory { * create the callback proxy with cglib. use the same * JDKCallbackInvocationHandler as JDKProxyService. */ - public <T> T createCallbackProxy(Class<T> interfaze, final List<RuntimeWire> wires) throws ProxyCreationException { - ServiceReferenceImpl<T> callbackReference = new ServiceReferenceImpl(interfaze, wires.get(0), this); + public <T> T createCallbackProxy(Class<T> interfaze, final List<? extends Invocable> wires) throws ProxyCreationException { + ServiceReferenceImpl<T> callbackReference = new ServiceReferenceImpl(interfaze, wires.get(0), null); return callbackReference != null ? createCallbackProxy(callbackReference) : null; } @@ -81,14 +82,15 @@ public class CglibProxyFactory implements ProxyFactory { * create the callback proxy with cglib. use the same * JDKCallbackInvocationHandler as JDKProxyService. */ - public <T> T createCallbackProxy(ServiceReferenceImpl<T> callbackReference) throws ProxyCreationException { + public <T> T createCallbackProxy(ServiceReference<T> callbackReference) throws ProxyCreationException { Enhancer enhancer = new Enhancer(); Class<T> interfaze = callbackReference.getBusinessInterface(); enhancer.setSuperclass(interfaze); enhancer.setCallback(new CglibMethodInterceptor<T>(callbackReference)); - Object proxy = enhancer.create(); - callbackReference.setProxy(proxy); - return interfaze.cast(proxy); + Object object = enhancer.create(); + T proxy = interfaze.cast(object); + ((ServiceReferenceExt<T>)callbackReference).setProxy(proxy); + return proxy; } @SuppressWarnings("unchecked") @@ -124,18 +126,6 @@ public class CglibProxyFactory implements ProxyFactory { invocationHandler = new JDKCallbackInvocationHandler(messageFactory, callbackReference); } - /* - public CglibMethodInterceptor(Class<T> interfaze, RuntimeWire wire) { - ServiceReference<T> serviceRef = new ServiceReferenceImpl<T>(interfaze, wire, CglibProxyFactory.this); - invocationHandler = new JDKInvocationHandler(messageFactory, serviceRef); - } - - public CglibMethodInterceptor(Class<T> interfaze, List<RuntimeWire> wires) { - CallbackReferenceImpl ref = new CallbackReferenceImpl(interfaze, CglibProxyFactory.this, wires); - invocationHandler = new JDKCallbackInvocationHandler(messageFactory, ref); - } - */ - /** * @see net.sf.cglib.proxy.MethodInterceptor#intercept(java.lang.Object, java.lang.reflect.Method, java.lang.Object[], net.sf.cglib.proxy.MethodProxy) */ diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleProxyFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleProxyFactory.java index fbdfe8a8e6..7f476b2fa5 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleProxyFactory.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleProxyFactory.java @@ -21,8 +21,7 @@ package org.apache.tuscany.sca.core.invocation; import java.util.List; -import org.apache.tuscany.sca.core.context.impl.ServiceReferenceImpl; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.Invocable; import org.oasisopen.sca.ServiceReference; /** @@ -58,7 +57,7 @@ public class ExtensibleProxyFactory implements ProxyFactory { * @see org.apache.tuscany.sca.core.invocation.ProxyFactory#createCallbackProxy(java.lang.Class, * java.util.List) */ - public <T> T createCallbackProxy(Class<T> interfaze, List<RuntimeWire> wires) throws ProxyCreationException { + public <T> T createCallbackProxy(Class<T> interfaze, List<? extends Invocable> wires) throws ProxyCreationException { ProxyFactory interfaceFactory = proxyFactories.getInterfaceProxyFactory(); ProxyFactory classFactory = proxyFactories.getClassProxyFactory(); if (interfaze.isInterface()) { @@ -78,7 +77,7 @@ public class ExtensibleProxyFactory implements ProxyFactory { } } - public <T> T createCallbackProxy(ServiceReferenceImpl<T> callbackReference) throws ProxyCreationException { + public <T> T createCallbackProxy(ServiceReference<T> callbackReference) throws ProxyCreationException { ProxyFactory interfaceFactory = proxyFactories.getInterfaceProxyFactory(); ProxyFactory classFactory = proxyFactories.getClassProxyFactory(); if (callbackReference.getBusinessInterface().isInterface()) { @@ -90,9 +89,9 @@ public class ExtensibleProxyFactory implements ProxyFactory { /** * @see org.apache.tuscany.sca.core.invocation.ProxyFactory#createProxy(java.lang.Class, - * org.apache.tuscany.sca.runtime.RuntimeWire) + * org.apache.tuscany.sca.runtime.Invocable) */ - public <T> T createProxy(Class<T> interfaze, RuntimeWire wire) throws ProxyCreationException { + public <T> T createProxy(Class<T> interfaze, Invocable wire) throws ProxyCreationException { ProxyFactory interfaceFactory = proxyFactories.getInterfaceProxyFactory(); ProxyFactory classFactory = proxyFactories.getClassProxyFactory(); if (interfaze.isInterface()) { diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.java index 934f2f7aa0..08019ec3e2 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.java @@ -18,7 +18,8 @@ */ package org.apache.tuscany.sca.core.invocation; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; import org.apache.tuscany.sca.runtime.RuntimeWireProcessor; import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint; @@ -28,16 +29,22 @@ import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint; * @version $Rev$ $Date$ */ public class ExtensibleWireProcessor implements RuntimeWireProcessor { - + private RuntimeWireProcessorExtensionPoint processors; public ExtensibleWireProcessor(RuntimeWireProcessorExtensionPoint processors) { this.processors = processors; } - - public void process(RuntimeWire wire) { + + public void process(RuntimeEndpoint endpoint) { + for (RuntimeWireProcessor processor : processors.getWireProcessors()) { + processor.process(endpoint); + } + } + + public void process(RuntimeEndpointReference endpointReference) { for (RuntimeWireProcessor processor : processors.getWireProcessors()) { - processor.process(wire); + processor.process(endpointReference); } } diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java index ec2f0a0664..6435efe4d6 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java @@ -18,9 +18,7 @@ */ package org.apache.tuscany.sca.core.invocation; -import java.util.LinkedList; import java.util.List; -import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; @@ -31,7 +29,6 @@ import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.RuntimeWire; import org.apache.tuscany.sca.work.WorkScheduler; import org.oasisopen.sca.ServiceRuntimeException; @@ -123,7 +120,7 @@ public class NonBlockingInterceptor implements Interceptor { */ private static class ImmutableMessage implements Message { - public Object getBody() { + public <T> T getBody() { return null; } @@ -133,10 +130,6 @@ public class NonBlockingInterceptor implements Interceptor { } } - public void setCallbackWires(LinkedList<RuntimeWire> wires) { - - } - public Object getMessageID() { return null; } @@ -176,17 +169,6 @@ public class NonBlockingInterceptor implements Interceptor { public void setOperation(Operation op) { throw new UnsupportedOperationException(); } - - /** - * @see org.apache.tuscany.sca.invocation.Message#getReplyTo() - */ - public EndpointReference getReplyTo() { - return null; - } - - public Map<String, Object> getQoSContext() { - return null; - } public List<Object> getHeaders() { return null; diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java index d75ff309ff..fbf703bad0 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java @@ -20,8 +20,7 @@ package org.apache.tuscany.sca.core.invocation; import java.util.List; -import org.apache.tuscany.sca.core.context.impl.ServiceReferenceImpl; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.Invocable; import org.oasisopen.sca.ServiceReference; /** @@ -36,11 +35,11 @@ public interface ProxyFactory { * Creates a Java proxy for the given wire * * @param interfaze the interface the proxy implements - * @param wire the wire to proxy + * @param invocable the wire to proxy * @return the proxy * @throws ProxyCreationException */ - <T> T createProxy(Class<T> interfaze, RuntimeWire wire) throws ProxyCreationException; + <T> T createProxy(Class<T> interfaze, Invocable invocable) throws ProxyCreationException; /** * Creates a Java proxy for the given CallableReference @@ -58,7 +57,7 @@ public interface ProxyFactory { * @return the proxy * @throws ProxyCreationException */ - <T> T createCallbackProxy(Class<T> interfaze, List<RuntimeWire> wires) throws ProxyCreationException; + <T> T createCallbackProxy(Class<T> interfaze, List<? extends Invocable> invocables) throws ProxyCreationException; /** * Creates a Java proxy for the given callback reference @@ -67,7 +66,7 @@ public interface ProxyFactory { * @return the proxy * @throws ProxyCreationException */ - <T> T createCallbackProxy(ServiceReferenceImpl<T> callbackReference) throws ProxyCreationException; + <T> T createCallbackProxy(ServiceReference<T> callbackReference) throws ProxyCreationException; /** * Cast a proxy to a CallableReference. diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java new file mode 100644 index 0000000000..0751fd631b --- /dev/null +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java @@ -0,0 +1,97 @@ +/* + * 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.tuscany.sca.core.invocation; + +import java.lang.reflect.InvocationTargetException; + +import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.context.ThreadMessageContext; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.InvocationChain; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.invocation.MessageFactory; +import org.apache.tuscany.sca.runtime.Invocable; + +/** + * Invoker for a endpoint or endpoint reference + * @version $Rev$ $Date$ + */ +public class RuntimeInvoker implements Invoker { + protected MessageFactory messageFactory; + protected Invocable invocable; + + public RuntimeInvoker(MessageFactory messageFactory, Invocable invocable) { + this.messageFactory = messageFactory; + this.invocable = invocable; + } + + public Message invokeBinding(Message msg) { + Message context = ThreadMessageContext.setMessageContext(msg); + try { + return invocable.getBindingInvocationChain().getHeadInvoker().invoke(msg); + } finally { + ThreadMessageContext.setMessageContext(context); + } + } + + public Message invoke(Message msg) { + return invoke(msg.getOperation(), msg); + } + + public Object invoke(Operation operation, Object[] args) throws InvocationTargetException { + Message msg = messageFactory.createMessage(); + msg.setBody(args); + Message resp = invoke(operation, msg); + Object body = resp.getBody(); + if (resp.isFault()) { + throw new InvocationTargetException((Throwable)body); + } + return body; + } + + + public Message invoke(Operation operation, Message msg) { + InvocationChain chain = invocable.getInvocationChain(operation); + return invoke(chain, msg); + } + + public Message invoke(InvocationChain chain, Message msg) { + + if (invocable instanceof Endpoint) { + msg.setTo((Endpoint)invocable); + } else if (invocable instanceof EndpointReference) { + msg.setFrom((EndpointReference)invocable); + } + + Invoker headInvoker = chain.getHeadInvoker(); + Operation operation = chain.getTargetOperation(); + msg.setOperation(operation); + + Message msgContext = ThreadMessageContext.setMessageContext(msg); + try { + return headInvoker.invoke(msg); + } finally { + ThreadMessageContext.setMessageContext(msgContext); + } + } + +} diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java deleted file mode 100644 index 43726b85dd..0000000000 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java +++ /dev/null @@ -1,268 +0,0 @@ -/* - * 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.tuscany.sca.core.invocation; - -import java.lang.reflect.InvocationTargetException; - -import org.apache.tuscany.sca.assembly.EndpointReference; -import org.apache.tuscany.sca.context.ThreadMessageContext; -import org.apache.tuscany.sca.core.factory.InstanceWrapper; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.InvocationChain; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.invocation.MessageFactory; -import org.apache.tuscany.sca.runtime.RuntimeWire; -import org.oasisopen.sca.ServiceRuntimeException; - -/** - * @version $Rev$ $Date$ - */ -public class RuntimeWireInvoker implements Invoker{ - protected MessageFactory messageFactory; - protected Object conversationID; - protected Object callbackID; - protected Object callbackObject; - protected RuntimeWire wire; - - public RuntimeWireInvoker(MessageFactory messageFactory, RuntimeWire wire) { - this.messageFactory = messageFactory; - this.wire = wire; - //init(wire); - } - - /* TODO - EPR - not required for OASIS - protected void init(RuntimeWire wire) { - if (wire != null) { - - ReferenceParameters parameters = wire.getSource().getReferenceParameters(); - this.callbackID = parameters.getCallbackID(); - this.callbackObject = parameters.getCallbackReference(); - this.conversationID = parameters.getConversationID(); - InterfaceContract contract = wire.getSource().getInterfaceContract(); - this.conversational = contract.getInterface().isConversational(); - } - } - */ - - /* - * TODO - Introduced to allow the RuntimeWireInvoker to sit on the end of the - * service binding chain. Runtime wire invoke needs splitting up into - * separate conversation, callback interceptors etc. - */ - public Message invoke(Message msg) { - - try { - Object response = invoke(msg.getOperation(),msg); - // Hack to put the response back in a message. - // shouldn't take it out of the response message in the first place - msg.setBody(response); - } catch (InvocationTargetException e) { -// throw new ServiceRuntimeException(e); - } - - return msg; - } - - public Object invoke(Operation operation, Message msg) throws InvocationTargetException { - return invoke(wire, operation, msg); - } - - public Object invoke(RuntimeWire wire, Operation operation, Message msg) throws InvocationTargetException { - RuntimeWire runtimeWire = wire == null ? this.wire : wire; - InvocationChain chain = runtimeWire.getInvocationChain(operation); - return invoke(chain, msg, runtimeWire); - } - - protected Object invoke(InvocationChain chain, Message msg, RuntimeWire wire) throws InvocationTargetException { - EndpointReference from = msg.getFrom(); - EndpointReference epFrom = wire.getEndpointReference(); - if (from != null) { - from.setComponent(epFrom.getComponent()); - from.setReference(epFrom.getReference()); - from.setBinding(epFrom.getBinding()); - from.setInterfaceContract(epFrom.getInterfaceContract()); - from.setTargetEndpoint(epFrom.getTargetEndpoint()); - //from.setCallbackEndpoint(epFrom.getCallbackEndpoint()); - - // TODO - EPR - what's going on here? - //from.mergeEndpoint(epFrom); - } else { - msg.setFrom(epFrom); - } - msg.setTo(wire.getEndpoint()); - - Invoker headInvoker = chain.getHeadInvoker(); - Operation operation = chain.getTargetOperation(); - msg.setOperation(operation); - - Message msgContext = ThreadMessageContext.getMessageContext(); - // TODO - EPR - no required for OASIS - //Object currentConversationID = msgContext.getFrom().getReferenceParameters().getConversationID(); - - ThreadMessageContext.setMessageContext(msg); - try { - // TODO - EPR - no required for OASIS - //conversationPreinvoke(msg); - // handleCallback(msg, currentConversationID); - // dispatch the wire down the chain and get the response - Message resp = headInvoker.invoke(msg); - Object body = resp.getBody(); - if (resp.isFault()) { - throw new InvocationTargetException((Throwable)body); - } - return body; - } catch (InvocationTargetException e) { - throw e; - } catch (Throwable e) { - throw new ServiceRuntimeException(e); - } finally { - try { - // TODO - EPR - no required for OASIS - //conversationPostInvoke(msg); - //} catch (TargetDestructionException e) { - // throw new ServiceRuntimeException(e); - } finally { - ThreadMessageContext.setMessageContext(msgContext); - } - } - } - - /** - * @param msgContext - */ - /* TODO - EPR - no required for OASIS - protected EndpointReference getCallbackEndpoint(Message msgContext) { - EndpointReference from = msgContext.getFrom(); - return from == null ? null : from.getReferenceParameters().getCallbackReference(); - } - */ - - /** - * Pre-invoke for the conversation handling - * @param msg - * @throws TargetResolutionException - */ - /* TODO - EPR - no required for OASIS - private void conversationPreinvoke(Message msg) { - if (conversational) { - ReferenceParameters parameters = msg.getFrom().getReferenceParameters(); - // in some cases the ConversationID that should be used comes in with the - // message, e.g. when ws binding is in use. - Object convID = parameters.getConversationID(); - if (convID != null) { - conversationID = convID; - } - conversation = conversationManager.getConversation(conversationID); - - if (conversation == null || conversation.getState() == ConversationState.ENDED) { - conversation = conversationManager.startConversation(conversationID); - conversation.initializeConversationAttributes(wire.getTarget().getComponent()); - } else if (conversation.conversationalAttributesInitialized() == false) { - conversation.initializeConversationAttributes(wire.getTarget().getComponent()); - } else if (conversation.isExpired()){ - throw new ConversationEndedException("Conversation has expired."); - } - - conversation.updateLastReferencedTime(); - - parameters.setConversationID(conversation.getConversationID()); - } - } - */ - - /** - * Post-invoke for the conversation handling - * @param wire - * @param operation - * @throws TargetDestructionException - */ - /* TODO - EPR - no required for OASIS - @SuppressWarnings("unchecked") - private void conversationPostInvoke(Message msg) throws TargetDestructionException { - if (conversational) { - Operation operation = msg.getOperation(); - ConversationSequence sequence = operation.getConversationSequence(); - if (sequence == ConversationSequence.CONVERSATION_END) { - // in some cases the ConversationID that should be used comes in with the - // message, e.g. when ws binding is in use. - Object convID = msg.getFrom().getReferenceParameters().getConversationID(); - if (convID != null) { - conversationID = convID; - } - conversation = conversationManager.getConversation(conversationID); - - // remove conversation id from scope container - ScopeContainer scopeContainer = getConversationalScopeContainer(msg); - - if (scopeContainer != null) { - scopeContainer.remove(conversation.getConversationID()); - } - - conversation.end(); - } - } - } - - @SuppressWarnings("unchecked") - private ScopeContainer getConversationalScopeContainer(Message msg) { - ScopeContainer scopeContainer = null; - - RuntimeComponent component = (RuntimeComponent) msg.getTo().getComponent(); - - if (component instanceof ScopedRuntimeComponent) { - ScopedRuntimeComponent scopedRuntimeComponent = (ScopedRuntimeComponent)component; - ScopeContainer container = scopedRuntimeComponent.getScopeContainer(); - - if ((container != null) && (container.getScope() == Scope.CONVERSATION)) { - scopeContainer = container; - } - } - - return scopeContainer; - } - */ - - - /** - * Minimal wrapper for a callback object contained in a ServiceReference - */ - private static class CallbackObjectWrapper<T> implements InstanceWrapper<T> { - - private T instance; - - private CallbackObjectWrapper(T instance) { - this.instance = instance; - } - - public T getInstance() { - return instance; - } - - public void start() { - // do nothing - } - - public void stop() { - // do nothing - } - } - -} diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.java index 2fc3d6c7eb..26b3590d14 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.java @@ -22,7 +22,7 @@ import org.apache.tuscany.sca.core.context.impl.ServiceReferenceImpl; import org.apache.tuscany.sca.core.factory.ObjectCreationException; import org.apache.tuscany.sca.core.factory.ObjectFactory; import org.apache.tuscany.sca.core.invocation.impl.NoMethodForOperationException; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.Invocable; /** * Uses a wire to return an object instance @@ -31,7 +31,7 @@ import org.apache.tuscany.sca.runtime.RuntimeWire; */ public class WireObjectFactory<T> implements ObjectFactory<T> { private Class<T> interfaze; - private RuntimeWire wire; + private Invocable wire; private ProxyFactory proxyService; /** @@ -42,14 +42,14 @@ public class WireObjectFactory<T> implements ObjectFactory<T> { * @param proxyService the wire service to create the proxy * @throws NoMethodForOperationException */ - public WireObjectFactory(Class<T> interfaze, RuntimeWire wire, ProxyFactory proxyService) { + public WireObjectFactory(Class<T> interfaze, Invocable wire, ProxyFactory proxyService) { this.interfaze = interfaze; this.wire = wire; this.proxyService = proxyService; } public T getInstance() throws ObjectCreationException { - return new ServiceReferenceImpl<T>(interfaze, wire, proxyService).getProxy(); + return new ServiceReferenceImpl<T>(interfaze, wire, null).getProxy(); } } diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java index e64b9f3068..168af952db 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java @@ -21,13 +21,11 @@ package org.apache.tuscany.sca.core.invocation.impl; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; - -import org.apache.tuscany.sca.core.assembly.impl.RuntimeWireImpl; import org.apache.tuscany.sca.core.context.impl.CallbackServiceReferenceImpl; -import org.apache.tuscany.sca.core.context.impl.ServiceReferenceImpl; import org.apache.tuscany.sca.invocation.InvocationChain; import org.apache.tuscany.sca.invocation.MessageFactory; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; +import org.oasisopen.sca.ServiceReference; import org.oasisopen.sca.ServiceRuntimeException; /** @@ -39,7 +37,7 @@ import org.oasisopen.sca.ServiceRuntimeException; public class JDKCallbackInvocationHandler extends JDKInvocationHandler { private static final long serialVersionUID = -3350283555825935609L; - public JDKCallbackInvocationHandler(MessageFactory messageFactory, ServiceReferenceImpl ref) { + public JDKCallbackInvocationHandler(MessageFactory messageFactory, ServiceReference<?> ref) { super(messageFactory, ref); this.fixedWire = false; } @@ -53,7 +51,7 @@ public class JDKCallbackInvocationHandler extends JDKInvocationHandler { } // obtain a dedicated wire to be used for this callback invocation - RuntimeWire wire = ((CallbackServiceReferenceImpl)callableReference).getCallbackWire(); + RuntimeEndpointReference wire = ((CallbackServiceReferenceImpl)callableReference).getCallbackEPR(); if (wire == null) { //FIXME: need better exception throw new ServiceRuntimeException("No callback wire found"); @@ -67,13 +65,12 @@ public class JDKCallbackInvocationHandler extends JDKInvocationHandler { } try { - return invoke(chain, args, wire, wire.getEndpointReference()); + return invoke(chain, args, wire); } catch (InvocationTargetException e) { Throwable t = e.getCause(); - throw e; + throw t; } finally { // allow the cloned wire to be reused by subsequent callbacks - ((RuntimeWireImpl)wire).releaseWire(); } } diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java index 08521d1b88..0049214e4a 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java @@ -28,11 +28,8 @@ import java.util.List; import java.util.Map; import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.context.ThreadMessageContext; import org.apache.tuscany.sca.core.context.ServiceReferenceExt; -import org.apache.tuscany.sca.core.factory.InstanceWrapper; -import org.apache.tuscany.sca.core.scope.TargetResolutionException; import org.apache.tuscany.sca.interfacedef.DataType; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.interfacedef.java.JavaOperation; @@ -40,7 +37,8 @@ import org.apache.tuscany.sca.invocation.InvocationChain; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; import org.apache.tuscany.sca.invocation.MessageFactory; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.Invocable; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; import org.oasisopen.sca.ServiceReference; import org.oasisopen.sca.ServiceRuntimeException; @@ -52,9 +50,8 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable { protected boolean conversational; protected MessageFactory messageFactory; - protected EndpointReference source; protected Endpoint target; - protected RuntimeWire wire; + protected RuntimeEndpointReference source; protected ServiceReferenceExt<?> callableReference; protected Class<?> businessInterface; @@ -62,11 +59,10 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable { protected transient Map<Method, InvocationChain> chains = new IdentityHashMap<Method, InvocationChain>(); - public JDKInvocationHandler(MessageFactory messageFactory, Class<?> businessInterface, RuntimeWire wire) { + public JDKInvocationHandler(MessageFactory messageFactory, Class<?> businessInterface, RuntimeEndpointReference source) { this.messageFactory = messageFactory; - this.wire = wire; + this.source = source; this.businessInterface = businessInterface; - init(this.wire); } public JDKInvocationHandler(MessageFactory messageFactory, ServiceReference<?> callableReference) { @@ -74,49 +70,40 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable { this.callableReference = (ServiceReferenceExt<?>)callableReference; if (callableReference != null) { this.businessInterface = callableReference.getBusinessInterface(); - this.wire = ((ServiceReferenceExt<?>)callableReference).getRuntimeWire(); - if (wire != null) { - init(wire); - } + this.source = (RuntimeEndpointReference) this.callableReference.getEndpointReference(); } } - protected void init(RuntimeWire wire) { - } public Class<?> getBusinessInterface() { return businessInterface; } protected Object getCallbackID() { - return null; + return null; } public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (Object.class == method.getDeclaringClass()) { return invokeObjectMethod(method, args); } - if (wire == null) { - throw new ServiceRuntimeException("No runtime wire is available"); + if (source == null) { + throw new ServiceRuntimeException("No runtime source is available"); } - if (wire.isOutOfDate()) { - wire.rebuild(); + if (source.isOutOfDate()) { + source.rebuild(); chains.clear(); } - InvocationChain chain = getInvocationChain(method, wire); + InvocationChain chain = getInvocationChain(method, source); if (chain == null) { throw new IllegalArgumentException("No matching operation is found: " + method); } - - // The EndpointReference is not now resolved until the invocation chain - // is first created so reset the source here - source = wire.getEndpointReference(); - // send the invocation down the wire - Object result = invoke(chain, args, wire, source); + // send the invocation down the source + Object result = invoke(chain, args, source); return result; } @@ -200,12 +187,12 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable { } - protected synchronized InvocationChain getInvocationChain(Method method, RuntimeWire wire) { + protected synchronized InvocationChain getInvocationChain(Method method, Invocable source) { if (fixedWire && chains.containsKey(method)) { return chains.get(method); } InvocationChain found = null; - for (InvocationChain chain : wire.getInvocationChains()) { + for (InvocationChain chain : source.getInvocationChains()) { Operation operation = chain.getSourceOperation(); if (operation.isDynamic()) { operation.setName(method.getName()); @@ -226,14 +213,14 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable { this.target = endpoint; } - protected Object invoke(InvocationChain chain, Object[] args, RuntimeWire wire, EndpointReference source) + protected Object invoke(InvocationChain chain, Object[] args, RuntimeEndpointReference source) throws Throwable { Message msg = messageFactory.createMessage(); msg.setFrom(source); if (target != null) { msg.setTo(target); } else { - msg.setTo(wire.getEndpoint()); + msg.setTo(source.getTargetEndpoint()); } Invoker headInvoker = chain.getHeadInvoker(); Operation operation = chain.getTargetOperation(); @@ -241,12 +228,11 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable { msg.setBody(args); Message msgContext = ThreadMessageContext.getMessageContext(); - - handleCallback(msg, wire); + ThreadMessageContext.setMessageContext(msg); - boolean abnormalEndConversation = false; + try { - // dispatch the wire down the chain and get the response + // dispatch the source down the chain and get the response Message resp = headInvoker.invoke(msg); Object body = resp.getBody(); if (resp.isFault()) { @@ -254,29 +240,12 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable { } return body; } finally { - //conversationPostInvoke(msg, wire, abnormalEndConversation); + //conversationPostInvoke(msg, source, abnormalEndConversation); ThreadMessageContext.setMessageContext(msgContext); } } /** - * @param msg - * @param wire - * @param interfaze - * @throws TargetResolutionException - */ - private void handleCallback(Message msg, RuntimeWire wire) - throws TargetResolutionException { - - //ReferenceParameters parameters = msg.getFrom().getReferenceParameters(); - //parameters.setCallbackID(getCallbackID()); - - if (msg.getFrom() == null || msg.getFrom().getCallbackEndpoint() == null) { - return; - } - } - - /** * @return the callableReference */ public ServiceReference<?> getCallableReference() { @@ -290,29 +259,4 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable { this.callableReference = (ServiceReferenceExt<?>)callableReference; } - /** - * Minimal wrapper for a callback object contained in a ServiceReference - */ - private static class CallbackObjectWrapper<T> implements InstanceWrapper<T> { - - private T instance; - - private CallbackObjectWrapper(T instance) { - this.instance = instance; - } - - public T getInstance() { - return instance; - } - - public void start() { - // do nothing - } - - public void stop() { - // do nothing - } - - } - } diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKProxyFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKProxyFactory.java index 853e28fafa..13d4040b8e 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKProxyFactory.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKProxyFactory.java @@ -32,13 +32,14 @@ import javax.xml.ws.Response; import org.apache.tuscany.sca.common.java.collection.LRUCache; import org.apache.tuscany.sca.core.LifeCycleListener; +import org.apache.tuscany.sca.core.context.ServiceReferenceExt; import org.apache.tuscany.sca.core.context.impl.CallbackServiceReferenceImpl; import org.apache.tuscany.sca.core.context.impl.ServiceReferenceImpl; import org.apache.tuscany.sca.core.invocation.ProxyCreationException; import org.apache.tuscany.sca.core.invocation.ProxyFactory; import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; import org.apache.tuscany.sca.invocation.MessageFactory; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.Invocable; import org.oasisopen.sca.ServiceReference; @@ -60,8 +61,8 @@ public class JDKProxyFactory implements ProxyFactory, LifeCycleListener { * The original createProxy method assumes that the proxy doesn't want to * share conversation state so sets the conversation object to null */ - public <T> T createProxy(Class<T> interfaze, RuntimeWire wire) throws ProxyCreationException { - ServiceReference<T> serviceReference = new ServiceReferenceImpl(interfaze, wire, this); + public <T> T createProxy(Class<T> interfaze, Invocable wire) throws ProxyCreationException { + ServiceReference<T> serviceReference = new ServiceReferenceImpl<T>(interfaze, wire, null); return createProxy(serviceReference); } @@ -80,9 +81,9 @@ public class JDKProxyFactory implements ProxyFactory, LifeCycleListener { return interfaze.getClassLoader(); } }); - Object proxy = newProxyInstance(cl, new Class[] {interfaze}, handler); - ((ServiceReferenceImpl)callableReference).setProxy(proxy); - return interfaze.cast(proxy); + T proxy = interfaze.cast(newProxyInstance(cl, new Class[] {interfaze}, handler)); + ((ServiceReferenceExt<T>)callableReference).setProxy(proxy); + return proxy; } private boolean isAsync(Class<?> interfaze) { @@ -103,19 +104,19 @@ public class JDKProxyFactory implements ProxyFactory, LifeCycleListener { return false; } - public <T> T createCallbackProxy(Class<T> interfaze, List<RuntimeWire> wires) throws ProxyCreationException { - ServiceReferenceImpl<T> callbackReference = new CallbackServiceReferenceImpl(interfaze, wires, this); + public <T> T createCallbackProxy(Class<T> interfaze, List<? extends Invocable> wires) throws ProxyCreationException { + ServiceReferenceImpl<T> callbackReference = new CallbackServiceReferenceImpl(interfaze, wires); return callbackReference != null ? createCallbackProxy(callbackReference) : null; } - public <T> T createCallbackProxy(ServiceReferenceImpl<T> callbackReference) throws ProxyCreationException { + public <T> T createCallbackProxy(ServiceReference<T> callbackReference) throws ProxyCreationException { assert callbackReference != null; Class<T> interfaze = callbackReference.getBusinessInterface(); InvocationHandler handler = new JDKCallbackInvocationHandler(messageFactory, callbackReference); ClassLoader cl = interfaze.getClassLoader(); - Object proxy = newProxyInstance(cl, new Class[] {interfaze}, handler); - callbackReference.setProxy(proxy); - return interfaze.cast(proxy); + T proxy = interfaze.cast(newProxyInstance(cl, new Class[] {interfaze}, handler)); + ((ServiceReferenceExt<T>) callbackReference).setProxy(proxy); + return proxy; } public <B, R extends ServiceReference<B>> R cast(B target) throws IllegalArgumentException { diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java index bab83bad2d..da5abeb728 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java @@ -68,7 +68,7 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder { /** * Build a single endpoint reference * - * @param endpoint + * @param invocable * @param monitor */ public boolean bind(EndpointRegistry endpointRegistry, EndpointReference endpointReference) { diff --git a/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java b/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java index 1b761ca8bc..ef002d5230 100644 --- a/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java +++ b/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java @@ -51,6 +51,7 @@ import org.apache.tuscany.sca.endpoint.tribes.AbstractReplicatedMap.MapEntry; import org.apache.tuscany.sca.endpoint.tribes.MapStore.MapListener; import org.apache.tuscany.sca.runtime.EndpointListener; import org.apache.tuscany.sca.runtime.EndpointRegistry; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; /** * A replicated EndpointRegistry based on Apache Tomcat Tribes @@ -291,7 +292,7 @@ public class ReplicatedEndpointRegistry implements EndpointRegistry, LifeCycleLi endpoint.setRemote(true); } // if (!entry.isPrimary()) { - endpoint.setExtensionPointRegistry(registry); + ((RuntimeEndpoint) endpoint).bind(registry, this); // } foundEndpoints.add(endpoint); logger.fine("Found endpoint with matching service - " + endpoint); @@ -359,7 +360,7 @@ public class ReplicatedEndpointRegistry implements EndpointRegistry, LifeCycleLi logger.info(id + " Remote endpoint added: " + entry.getValue()); newEp.setRemote(true); } - newEp.setExtensionPointRegistry(registry); + ((RuntimeEndpoint) newEp).bind(registry, this); for (EndpointListener listener : listeners) { listener.endpointAdded(newEp); } @@ -384,7 +385,7 @@ public class ReplicatedEndpointRegistry implements EndpointRegistry, LifeCycleLi } Endpoint oldEp = (Endpoint)oldEntry.getValue(); Endpoint newEp = (Endpoint)newEntry.getValue(); - newEp.setExtensionPointRegistry(registry); + ((RuntimeEndpoint) newEp).bind(registry, this); for (EndpointListener listener : listeners) { listener.endpointUpdated(oldEp, newEp); } diff --git a/java/sca/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistryTestCase.java b/java/sca/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistryTestCase.java index a574ba9328..28158d55f5 100644 --- a/java/sca/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistryTestCase.java +++ b/java/sca/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistryTestCase.java @@ -23,6 +23,7 @@ import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
@@ -42,7 +43,7 @@ public class ReplicatedEndpointRegistryTestCase { Endpoint e1 = assemblyFactory.createEndpoint();
e1.setURI("e1uri");
- e1.setExtensionPointRegistry(extensionPoints);
+ ((RuntimeEndpoint) e1).bind(extensionPoints, ep1);
ep1.addEndpoint(e1);
Endpoint e1p = ep1.getEndpoint("e1uri");
diff --git a/java/sca/modules/endpoint-zookeeper/src/main/java/org/apache/tuscany/sca/endpoint/zookeeper/DistributedRegistry.java b/java/sca/modules/endpoint-zookeeper/src/main/java/org/apache/tuscany/sca/endpoint/zookeeper/DistributedRegistry.java index 22d1d4d00a..b6ec34fe1f 100644 --- a/java/sca/modules/endpoint-zookeeper/src/main/java/org/apache/tuscany/sca/endpoint/zookeeper/DistributedRegistry.java +++ b/java/sca/modules/endpoint-zookeeper/src/main/java/org/apache/tuscany/sca/endpoint/zookeeper/DistributedRegistry.java @@ -35,6 +35,7 @@ import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.LifeCycleListener; import org.apache.tuscany.sca.runtime.EndpointListener; import org.apache.tuscany.sca.runtime.EndpointRegistry; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; import org.apache.zookeeper.WatchedEvent; import org.apache.zookeeper.ZooKeeper; import org.oasisopen.sca.ServiceRuntimeException; @@ -187,7 +188,7 @@ public class DistributedRegistry extends AbstractDistributedMap<Endpoint> implem logger.fine("Matching against - " + endpoint); if (matches(targetEndpoint.getURI(), endpoint.getURI())) { // if (!entry.isPrimary()) { - endpoint.setExtensionPointRegistry(registry); + ((RuntimeEndpoint) endpoint).bind(registry, this); // } foundEndpoints.add(endpoint); logger.fine("Found endpoint with matching service - " + endpoint); @@ -241,7 +242,7 @@ public class DistributedRegistry extends AbstractDistributedMap<Endpoint> implem } public void entryAdded(Endpoint value) { - value.setExtensionPointRegistry(registry); + ((RuntimeEndpoint) value).bind(registry, this); for (EndpointListener listener : listeners) { listener.endpointAdded(value); } @@ -254,7 +255,7 @@ public class DistributedRegistry extends AbstractDistributedMap<Endpoint> implem } public void entryUpdated(Endpoint oldEp, Endpoint newEp) { - newEp.setExtensionPointRegistry(registry); + ((RuntimeEndpoint) newEp).bind(registry, this); for (EndpointListener listener : listeners) { listener.endpointUpdated(oldEp, newEp); } diff --git a/java/sca/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEExternalService.java b/java/sca/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEExternalService.java index 55bde26c08..dc73ab044a 100644 --- a/java/sca/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEExternalService.java +++ b/java/sca/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEExternalService.java @@ -26,7 +26,6 @@ import javax.xml.namespace.QName; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.ode.bpel.iapi.Endpoint; import org.apache.ode.bpel.iapi.Message; import org.apache.ode.bpel.iapi.MessageExchange; import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange; @@ -38,7 +37,7 @@ import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -89,10 +88,10 @@ public class ODEExternalService { // Fetching the reference based on the data held in the PRC / Endpoint String refName = channel.getEndpoint().serviceName.getLocalPart(); RuntimeComponentReference runtimeComponentReference = getReferenceByName( tuscanyRuntimeComponent, refName ); - RuntimeWire runtimeWire = getRuntimeWire( runtimeComponentReference, partnerRoleMessageExchange ); + RuntimeEndpointReference epr = getEndpointReference( runtimeComponentReference, partnerRoleMessageExchange ); // convert operations Operation operation = - findOperation(partnerRoleMessageExchange.getOperation().getName(), runtimeComponentReference); + findOperation(partnerRoleMessageExchange.getOperation().getName(), epr); /* This is how a request looks like (payload is wrapped with extra info) @@ -122,7 +121,7 @@ public class ODEExternalService { boolean success = false; try { - result = runtimeWire.invoke(operation, args); + result = epr.invoke(operation, args); success = true; } catch (Exception e) { e.printStackTrace(); @@ -194,7 +193,7 @@ public class ODEExternalService { * @param componentReference - the reference * @return - the RuntimeWire - null if it cannot be found */ - private RuntimeWire getRuntimeWire( RuntimeComponentReference componentReference, + private RuntimeEndpointReference getEndpointReference( RuntimeComponentReference componentReference, PartnerRoleMessageExchange mex) { if( componentReference.isForCallback() ) { // Where there is a callback, it is necessary to create a specialized wire, based on callback information @@ -205,42 +204,42 @@ public class ODEExternalService { Long processID = _server.getProcessIDFromMex(mex.getMessageExchangeId()); org.apache.tuscany.sca.assembly.EndpointReference callbackEPR = _server.getCallbackMetadata(processID, componentReference.getName()); - RuntimeWire wire = selectCallbackWire( callbackEPR.getTargetEndpoint(), componentReference ); + RuntimeEndpointReference wire = selectCallbackWire( callbackEPR.getTargetEndpoint(), componentReference ); wire = clone_bind( componentReference, callbackEPR.getCallbackEndpoint() ); return wire; } else { // No callback case... //TODO - fix the x..n multiplicity case, which needs to select the correct ONE of multiple // EndpointReferences here - return componentReference.getRuntimeWire(componentReference.getEndpointReferences().get(0)); + return (RuntimeEndpointReference) componentReference.getEndpointReferences().get(0); } // end if - } // end method getRuntimeWire + } // end method getEndpointReference - private RuntimeWire selectCallbackWire( org.apache.tuscany.sca.assembly.Endpoint endpoint, + private RuntimeEndpointReference selectCallbackWire( org.apache.tuscany.sca.assembly.Endpoint endpoint, RuntimeComponentReference componentReference) { // Look for callback binding with same name as service binding if (endpoint == null) { throw new RuntimeException("Destination for forward call is not available"); } - for (RuntimeWire wire : componentReference.getRuntimeWires()) { - if (wire.getEndpointReference().getBinding().getName().equals(endpoint.getBinding().getName())) { - return wire; + for (EndpointReference epr : componentReference.getEndpointReferences()) { + if (epr.getBinding().getName().equals(endpoint.getBinding().getName())) { + return (RuntimeEndpointReference) epr; } - } // end for + } // if no match, look for callback binding with same type as service binding - for (RuntimeWire wire : componentReference.getRuntimeWires()) { - if (wire.getEndpointReference().getBinding().getClass() == endpoint.getBinding().getClass()) { - return wire; + for (EndpointReference epr : componentReference.getEndpointReferences()) { + if (epr.getBinding().getType().equals(endpoint.getBinding().getType())) { + return (RuntimeEndpointReference) epr; } - } // end for + } // no suitable callback wire was found return null; } // end method selectCallbackWire - private RuntimeWire clone_bind(RuntimeComponentReference reference, + private RuntimeEndpointReference clone_bind(RuntimeComponentReference reference, org.apache.tuscany.sca.assembly.Endpoint callbackEndpoint) { try { @@ -258,9 +257,7 @@ public class ODEExternalService { // The callback endpoint will be resolved when the wire chains are created ref.getEndpointReferences().add(callbackEndpointReference); - RuntimeWire wire = ref.getRuntimeWires().get(0); - - return wire; + return (RuntimeEndpointReference) ref.getEndpointReferences().get(0); } catch ( CloneNotSupportedException e ) { return null; } // end try clone_bind @@ -274,16 +271,16 @@ public class ODEExternalService { * @param runtimeComponentReference * @return */ - private Operation findOperation(String operationName, RuntimeComponentReference runtimeComponentReference) { - Operation reseultOperation = null; - - for(Operation operation : runtimeComponentReference.getInterfaceContract().getInterface().getOperations()) { - if (operationName.equalsIgnoreCase(operation.getName())) { - reseultOperation = operation; - break; - } - } - return reseultOperation; + private Operation findOperation(String operationName, RuntimeEndpointReference epr) { + Operation reseultOperation = null; + + for (Operation operation : epr.getReferenceInterfaceContract().getInterface().getOperations()) { + if (operationName.equalsIgnoreCase(operation.getName())) { + reseultOperation = operation; + break; + } + } + return reseultOperation; } /** diff --git a/java/sca/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProvider.java b/java/sca/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProvider.java index 93409c837f..ef35f4cd66 100644 --- a/java/sca/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProvider.java +++ b/java/sca/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProvider.java @@ -28,11 +28,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.ode.dao.jpa.ProcessDAOImpl; import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.assembly.Service; import org.apache.tuscany.sca.databinding.xml.DOMDataBinding; import org.apache.tuscany.sca.extensibility.ClassLoaderContext; -import org.apache.tuscany.sca.extensibility.ServiceDiscovery; import org.apache.tuscany.sca.implementation.bpel.BPELImplementation; import org.apache.tuscany.sca.implementation.bpel.ode.EmbeddedODEServer; import org.apache.tuscany.sca.implementation.bpel.ode.ODEDeployment; @@ -42,6 +42,8 @@ import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.provider.ImplementationProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * BPEL Implementation provider @@ -86,16 +88,20 @@ public class BPELImplementationProvider implements ImplementationProvider { // contract and leave it to the Endpoints only service.getInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME); for( Endpoint endpoint : service.getEndpoints() ) { - if (endpoint.getInterfaceContract() != null) { - endpoint.getInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME); + RuntimeEndpoint ep = (RuntimeEndpoint) endpoint; + if (ep.getServiceInterfaceContract() != null) { + ep.getServiceInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME); } } // end for } // end for - for (Reference reference: component.getReferences()) { + for (Reference reference : component.getReferences()) { reference.getInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME); - /* for( EndpointReference epr : reference.getEndpointReferences() ) { - epr.getInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME); + for (EndpointReference endpointReference : reference.getEndpointReferences()) { + RuntimeEndpointReference epr = (RuntimeEndpointReference)endpointReference; + if (epr.getReferenceInterfaceContract() != null) { + epr.getReferenceInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME); + } } // end for */ } // end for diff --git a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java b/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java index ba71abd826..8189271ed5 100644 --- a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java +++ b/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java @@ -80,7 +80,9 @@ public class ReflectiveInstanceFactory<T> implements InstanceFactory<T> { try { injector.inject(instance); } catch (Exception e) { - destroyInvoker.invokeEvent(instance); + if (destroyInvoker != null) { + destroyInvoker.invokeEvent(instance); + } throw new ObjectCreationException("Exception invoking injector", e); } } diff --git a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.java b/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.java index 602dc5d31a..c652b95d73 100644 --- a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.java +++ b/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.java @@ -39,7 +39,8 @@ import org.apache.tuscany.sca.invocation.InvocationChain; import org.apache.tuscany.sca.invocation.Phase; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; import org.apache.tuscany.sca.runtime.RuntimeWireProcessor; /** @@ -69,16 +70,40 @@ public class JavaCallbackRuntimeWireProcessor implements RuntimeWireProcessor { this.javaInterfaceFactory = javaInterfaceFactory; } - public void process(RuntimeWire wire) { - addCallbackInterfaceInterceptors(wire); + + private boolean supportsCallbackInterface(Interface iface, JavaImplementation impl) { + if (iface instanceof JavaInterface) { + Class<?> ifaceClass = ((JavaInterface)iface).getJavaClass(); + if (ifaceClass.isAssignableFrom(impl.getJavaClass())) { + return true; + } + } + try { + Interface implType = javaInterfaceFactory.createJavaInterface(impl.getJavaClass()); + // Ignore the remotable/conversational testing + implType.setRemotable(iface.isRemotable()); + implType.setConversational(iface.isConversational()); + return interfaceContractMapper.isCompatible(iface, implType); + } catch (InvalidInterfaceException e) { + logger.log(Level.WARNING, e.getMessage(), e); + return false; + } } - private void addCallbackInterfaceInterceptors(RuntimeWire wire) { - Contract contract = wire.getEndpointReference().getReference(); + public void process(RuntimeEndpoint endpoint) { + // No operation + } + + public void process(RuntimeEndpointReference endpointReference) { + if(!(endpointReference instanceof RuntimeEndpointReference)) { + return; + } + RuntimeEndpointReference epr = (RuntimeEndpointReference) endpointReference; + Contract contract = epr.getReference(); if (!(contract instanceof RuntimeComponentReference)) { return; } - RuntimeComponent component = (RuntimeComponent) wire.getEndpointReference().getComponent(); + RuntimeComponent component = (RuntimeComponent) epr.getComponent(); if (component == null) { return; } @@ -87,34 +112,15 @@ public class JavaCallbackRuntimeWireProcessor implements RuntimeWireProcessor { return; } JavaImplementation javaImpl = (JavaImplementation)implementation; - Endpoint callbackEndpoint = wire.getEndpointReference().getCallbackEndpoint(); + Endpoint callbackEndpoint = epr.getCallbackEndpoint(); if (callbackEndpoint != null) { Interface iface = callbackEndpoint.getService().getInterfaceContract().getInterface(); if (!supportsCallbackInterface(iface, javaImpl)) { // callback to this impl is not possible, so ensure a callback object is set - for (InvocationChain chain : wire.getInvocationChains()) { + for (InvocationChain chain : epr.getInvocationChains()) { chain.addInterceptor(Phase.REFERENCE, new CallbackInterfaceInterceptor()); } } } } - - private boolean supportsCallbackInterface(Interface iface, JavaImplementation impl) { - if (iface instanceof JavaInterface) { - Class<?> ifaceClass = ((JavaInterface)iface).getJavaClass(); - if (ifaceClass.isAssignableFrom(impl.getJavaClass())) { - return true; - } - } - try { - Interface implType = javaInterfaceFactory.createJavaInterface(impl.getJavaClass()); - // Ignore the remotable/conversational testing - implType.setRemotable(iface.isRemotable()); - implType.setConversational(iface.isConversational()); - return interfaceContractMapper.isCompatible(iface, implType); - } catch (InvalidInterfaceException e) { - logger.log(Level.WARNING, e.getMessage(), e); - return false; - } - } } diff --git a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java b/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java index c398c3af04..f2d134f7a2 100644 --- a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java +++ b/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java @@ -33,6 +33,7 @@ import java.util.Map; import org.apache.tuscany.sca.assembly.ComponentProperty; import org.apache.tuscany.sca.assembly.ComponentReference; import org.apache.tuscany.sca.assembly.ComponentService; +import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.assembly.Multiplicity; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.context.ComponentContextFactory; @@ -60,7 +61,7 @@ import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; import org.oasisopen.sca.ServiceReference; /** @@ -140,14 +141,14 @@ public class JavaComponentContextProvider { void start() { if (!instanceFactoryProvider.getImplementation().getCallbackMembers().isEmpty()) { - Map<String, List<RuntimeWire>> callbackWires = new HashMap<String, List<RuntimeWire>>(); + Map<String, List<EndpointReference>> callbackWires = new HashMap<String, List<EndpointReference>>(); for (ComponentService service : component.getServices()) { RuntimeComponentReference callbackReference = (RuntimeComponentReference)service.getCallbackReference(); if (callbackReference != null) { - List<RuntimeWire> wires = callbackReference.getRuntimeWires(); + List<EndpointReference> wires = callbackReference.getEndpointReferences(); if (!wires.isEmpty()) { - callbackWires.put(wires.get(0).getEndpointReference().getInterfaceContract().getInterface().toString(), + callbackWires.put(wires.get(0).getInterfaceContract().getInterface().toString(), wires); } } @@ -155,7 +156,7 @@ public class JavaComponentContextProvider { for (Map.Entry<String, Collection<JavaElementImpl>> entry : instanceFactoryProvider.getImplementation() .getCallbackMembers().entrySet()) { - List<RuntimeWire> wires = callbackWires.get(entry.getKey()); + List<EndpointReference> wires = callbackWires.get(entry.getKey()); if (wires == null) { // this can happen when there are no client wires to a // component that has a callback @@ -196,10 +197,10 @@ public class JavaComponentContextProvider { } } ComponentReference componentReference = null; - List<RuntimeWire> wireList = null; + List<EndpointReference> wireList = null; for (ComponentReference reference : component.getReferences()) { if (reference.getName().equals(ref.getName())) { - wireList = ((RuntimeComponentReference)reference).getRuntimeWires(); + wireList = ((RuntimeComponentReference)reference).getEndpointReferences(); componentReference = reference; break; } @@ -215,11 +216,7 @@ public class JavaComponentContextProvider { // Type businessType = JavaIntrospectionHelper.getParameterType(callableRefType); Class<?> businessInterface = JavaIntrospectionHelper.getBusinessInterface(baseType, callableRefType); - factory = - new CallableReferenceObjectFactory(businessInterface, component, - (RuntimeComponentReference)wireList.get(i) - .getEndpointReference().getReference(), wireList.get(i) - .getEndpointReference()); + factory = new CallableReferenceObjectFactory(businessInterface, (RuntimeEndpointReference) wireList.get(i)); } else { factory = createObjectFactory(baseType, wireList.get(i)); } @@ -243,8 +240,7 @@ public class JavaComponentContextProvider { JavaIntrospectionHelper.getBusinessInterface(element.getType(), element .getGenericType()); factory = - new CallableReferenceObjectFactory(businessInterface, component, - (RuntimeComponentReference)componentReference, wireList.get(0).getEndpointReference()); + new CallableReferenceObjectFactory(businessInterface, (RuntimeEndpointReference) wireList.get(0)); } else { factory = createObjectFactory(element.getType(), wireList.get(0)); } @@ -312,7 +308,7 @@ public class JavaComponentContextProvider { } - private <B> ObjectFactory<B> createObjectFactory(Class<B> interfaze, RuntimeWire wire) { + private <B> ObjectFactory<B> createObjectFactory(Class<B> interfaze, EndpointReference wire) { // FIXME: [rfeng] Disable the optimization for new as it needs more discussions /* boolean conversational = wire.getSource().getInterfaceContract().getInterface().isConversational(); @@ -347,7 +343,7 @@ public class JavaComponentContextProvider { } } */ - return new WireObjectFactory<B>(interfaze, wire, proxyFactory); + return new WireObjectFactory<B>(interfaze, (RuntimeEndpointReference) wire, proxyFactory); } private ObjectFactory<?> createPropertyValueFactory(ComponentProperty property, diff --git a/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java b/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java index 9111a7d03c..78b1ea476f 100644 --- a/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java +++ b/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java @@ -33,6 +33,7 @@ import java.util.List; import org.apache.tuscany.sca.assembly.ComponentReference; import org.apache.tuscany.sca.assembly.ComponentService; +import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.assembly.Extensible; import org.apache.tuscany.sca.core.invocation.ProxyFactory; import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint; @@ -47,7 +48,7 @@ import org.apache.tuscany.sca.provider.ImplementationProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; import org.oasisopen.sca.ServiceRuntimeException; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; @@ -114,8 +115,8 @@ public class OSGiImplementationProvider implements ImplementationProvider { osgiProps.put(SERVICE_IMPORTED, "true"); osgiProps.put(SERVICE_IMPORTED_CONFIGS, new String[] {REMOTE_CONFIG_SCA}); - for (RuntimeWire wire : reference.getRuntimeWires()) { - final OSGiServiceFactory serviceFactory = new OSGiServiceFactory(javaInterface.getName(), wire); + for (EndpointReference epr : reference.getEndpointReferences()) { + final OSGiServiceFactory serviceFactory = new OSGiServiceFactory(javaInterface.getName(), epr); ServiceRegistration registration = AccessController.doPrivileged(new PrivilegedAction<ServiceRegistration>() { public ServiceRegistration run() { @@ -229,17 +230,17 @@ public class OSGiImplementationProvider implements ImplementationProvider { } public class OSGiServiceFactory implements ServiceFactory { - private RuntimeWire wire; + private RuntimeEndpointReference epr; private String interfaceName; /** * @param interfaceName - * @param wire + * @param epr */ - public OSGiServiceFactory(String interfaceName, RuntimeWire wire) { + public OSGiServiceFactory(String interfaceName, EndpointReference epr) { super(); this.interfaceName = interfaceName; - this.wire = wire; + this.epr = (RuntimeEndpointReference) epr; } public Object getService(Bundle bundle, ServiceRegistration registration) { @@ -253,7 +254,7 @@ public class OSGiImplementationProvider implements ImplementationProvider { if (!interfaceClass.isInterface()) { proxyService = proxyFactoryExtensionPoint.getClassProxyFactory(); } - Object proxy = proxyService.createProxy(interfaceClass, wire); + Object proxy = proxyService.createProxy(interfaceClass, epr); return proxy; } diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/CompositeContextImpl.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/CompositeContextImpl.java deleted file mode 100644 index 604bb502f9..0000000000 --- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/CompositeContextImpl.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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.tuscany.sca.node.impl; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.EndpointReference; -import org.apache.tuscany.sca.context.ComponentContextFactory; -import org.apache.tuscany.sca.context.CompositeContext; -import org.apache.tuscany.sca.context.ContextFactoryExtensionPoint; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.runtime.EndpointRegistry; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentContext; - -/** - * @version $Rev$ $Date$ - */ -public class CompositeContextImpl extends CompositeContext { - private final ExtensionPointRegistry extensionPointRegistry; - private final EndpointRegistry endpointRegistry; - private final ComponentContextFactory componentContextFactory; - private final Composite domainComposite; - - public CompositeContextImpl(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry, Composite domainComposite) { - this.extensionPointRegistry = registry; - this.endpointRegistry = endpointRegistry; - ContextFactoryExtensionPoint contextFactories = registry.getExtensionPoint(ContextFactoryExtensionPoint.class); - this.componentContextFactory = contextFactories.getFactory(ComponentContextFactory.class); - this.domainComposite = domainComposite; - } - - public ExtensionPointRegistry getExtensionPointRegistry() { - return extensionPointRegistry; - } - - public EndpointRegistry getEndpointRegistry() { - return endpointRegistry; - } - - public void bindComponent(RuntimeComponent runtimeComponent) { - RuntimeComponentContext componentContext = - (RuntimeComponentContext)componentContextFactory.createComponentContext(this, runtimeComponent); - runtimeComponent.setComponentContext(componentContext); - } - - public void bindEndpointReference(EndpointReference endpointReference) { - - } - - public Composite getDomainComposite() { - return domainComposite; - } - -} diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java index 4be947f125..65b55452cc 100644 --- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java +++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java @@ -20,13 +20,11 @@ package org.apache.tuscany.sca.node.impl; import java.io.ByteArrayOutputStream; -//import java.lang.management.ManagementFactory; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; -//import javax.management.MBeanServer; import javax.xml.stream.XMLOutputFactory; import org.apache.tuscany.sca.assembly.Component; @@ -135,7 +133,7 @@ public class NodeImpl implements Node, Client { domainComposite = manager.configureNode(configuration, contributions, context); this.compositeContext = - new CompositeContextImpl(manager.registry, endpointRegistry, domainComposite); + new CompositeContext(manager.registry, endpointRegistry, domainComposite); } finally { // Reset the thread context monitor manager.monitorFactory.setContextMonitor(tcm); diff --git a/java/sca/samples/helloworld-bpel/src/test/java/helloworld/BPELHelloWorldTestCase.java b/java/sca/samples/helloworld-bpel/src/test/java/helloworld/BPELHelloWorldTestCase.java index 12e40d334b..d311bad3c5 100644 --- a/java/sca/samples/helloworld-bpel/src/test/java/helloworld/BPELHelloWorldTestCase.java +++ b/java/sca/samples/helloworld-bpel/src/test/java/helloworld/BPELHelloWorldTestCase.java @@ -21,6 +21,8 @@ package helloworld; import junit.framework.Assert; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; import org.apache.tuscany.sca.node.Node; import org.apache.tuscany.sca.node.NodeFactory; import org.junit.AfterClass; @@ -42,8 +44,9 @@ public class BPELHelloWorldTestCase { */ @BeforeClass public static void setUp() throws Exception { - - node = NodeFactory.newInstance().createNode(); + // String location = ContributionLocationHelper.getContributionLocation(BPELClient.class); + String location = ContributionLocationHelper.getContributionLocation("helloworld.composite"); + node = NodeFactory.newInstance().createNode(new Contribution("c1", location)); node.start(); bpelService = node.getService(Hello.class, "BPELHelloWorldComponent"); |