diff options
3 files changed, 27 insertions, 1 deletions
diff --git a/sandbox/event/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java b/sandbox/event/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java index e585b3d46f..84f476741d 100644 --- a/sandbox/event/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java +++ b/sandbox/event/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java @@ -34,6 +34,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.Consumer; import org.apache.tuscany.sca.assembly.Multiplicity; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.context.ComponentContextFactory; @@ -320,6 +321,14 @@ public class JavaComponentContextProvider { return new JavaImplementationInvoker(operation, method, component); } + // Method added to deal with Consumer invocation + Invoker createInvoker(Operation operation, Consumer consumer) throws NoSuchMethodException { + Class<?> implClass = instanceFactoryProvider.getImplementationClass(); + + Method method = JavaInterfaceUtil.findMethod(implClass, operation); + return new JavaImplementationInvoker(operation, method, component, consumer); + } + private static class OptimizedObjectFactory<T> implements ObjectFactory<T> { private ScopeContainer scopeContainer; diff --git a/sandbox/event/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java b/sandbox/event/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java index 25d538cff4..c6d288e7fd 100644 --- a/sandbox/event/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java +++ b/sandbox/event/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java @@ -21,6 +21,7 @@ package org.apache.tuscany.sca.implementation.java.invocation; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import org.apache.tuscany.sca.assembly.Consumer; import org.apache.tuscany.sca.core.context.InstanceWrapper; import org.apache.tuscany.sca.core.scope.Scope; import org.apache.tuscany.sca.core.scope.ScopeContainer; @@ -48,10 +49,21 @@ public class JavaImplementationInvoker implements Invoker, DataExchangeSemantics protected Operation operation; protected Method method; protected boolean allowsPBR; + protected Consumer consumer = null; @SuppressWarnings("unchecked") protected final ScopeContainer scopeContainer; + public JavaImplementationInvoker(Operation operation, Method method, + RuntimeComponent component, Consumer consumer) { + assert method != null : "Operation method cannot be null"; + this.method = method; + this.operation = operation; + this.scopeContainer = ((ScopedRuntimeComponent)component).getScopeContainer(); + this.allowsPBR = ((JavaImplementation)component.getImplementation()).isAllowsPassByReference(method); + this.consumer = consumer; + } + public JavaImplementationInvoker(Operation operation, Method method, RuntimeComponent component) { assert method != null : "Operation method cannot be null"; this.method = method; diff --git a/sandbox/event/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java b/sandbox/event/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java index e9eea607c9..e7eb2545f3 100644 --- a/sandbox/event/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java +++ b/sandbox/event/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java @@ -146,7 +146,12 @@ public class JavaImplementationProvider implements ScopedImplementationProvider public Invoker createInvoker(RuntimeComponentService service, Operation operation) { try { - return componentContextProvider.createInvoker(operation); + // Added separate processing for Consumers... Mike Edwards, 06/11/2008 + if( service.isConsumer() ){ + return componentContextProvider.createInvoker(operation, service.getConsumer() ); + } else { + return componentContextProvider.createInvoker(operation); + } // end if } catch (NoSuchMethodException e) { // It's possible that the instance being invoked is a user-specified // callback object that isn't an instance of the component implementation |