summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.java')
-rw-r--r--java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.java60
1 files changed, 33 insertions, 27 deletions
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;
- }
- }
}