summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/implementation-java-runtime/src/main
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-11-13 21:49:15 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-11-13 21:49:15 +0000
commit4dcff7533534e4b634b349a1105c7862d1655405 (patch)
tree61674abfb88ba63870bec8576101dc3d222454fa /java/sca/modules/implementation-java-runtime/src/main
parentc6a1c369e49090b6b9a6f2448045740a368c7ca3 (diff)
Replace RuntimeWire with RuntimeEnpoint/RuntimeEndpointReference as the owner of invocaiton chains
(http://www.mail-archive.com/dev@tuscany.apache.org/msg07856.html) git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@836009 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/implementation-java-runtime/src/main')
-rw-r--r--java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java4
-rw-r--r--java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.java60
-rw-r--r--java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java28
3 files changed, 48 insertions, 44 deletions
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,