You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/07/11 06:24:44 UTC
svn commit: r555162 [2/2] - in /incubator/tuscany/java/sca: distribution/
modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/
modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/
modules/assembly/src/main/java/org/apache/...
Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivatorImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivatorImpl.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivatorImpl.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivatorImpl.java Tue Jul 10 21:24:38 2007
@@ -19,6 +19,8 @@
package org.apache.tuscany.sca.core.runtime;
+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;
@@ -46,7 +48,9 @@
import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider2;
import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider2;
import org.apache.tuscany.sca.runtime.EndpointReference;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
@@ -105,42 +109,27 @@
for (Component component : composite.getComponents()) {
for (ComponentService service : component.getServices()) {
- for (Binding binding : service.getBindings()) {
- BindingProviderFactory providerFactory = (BindingProviderFactory)providerFactories
- .getProviderFactory(binding.getClass());
- if (providerFactory != null) {
- ServiceBindingProvider bindingProvider = providerFactory
- .createServiceBindingProvider((RuntimeComponent)component,
- (RuntimeComponentService)service,
- binding);
- if (bindingProvider != null) {
- ((RuntimeComponentService)service).setBindingProvider(binding, bindingProvider);
- }
- } else {
- throw new IllegalStateException("Provider factory not found for class: " + binding.getClass()
- .getName());
- }
+ createServiceBindingProviders((RuntimeComponent)component,
+ (RuntimeComponentService)service,
+ service.getBindings());
+ if (service.getCallback() != null) {
+ createServiceBindingProviders((RuntimeComponent)component,
+ (RuntimeComponentService)service,
+ service.getCallback().getBindings());
}
}
+
for (ComponentReference reference : component.getReferences()) {
- for (Binding binding : reference.getBindings()) {
- BindingProviderFactory providerFactory = (BindingProviderFactory)providerFactories
- .getProviderFactory(binding.getClass());
- if (providerFactory != null) {
- ReferenceBindingProvider bindingProvider = providerFactory
- .createReferenceBindingProvider((RuntimeComponent)component,
- (RuntimeComponentReference)reference,
- binding);
- if (bindingProvider != null) {
- ((RuntimeComponentReference)reference).setBindingProvider(binding, bindingProvider);
- }
- } else {
- throw new IllegalStateException("Provider factory not found for class: " + binding.getClass()
- .getName());
- }
+ createReferenceBindingProviders((RuntimeComponent)component,
+ (RuntimeComponentReference)reference,
+ reference.getBindings());
+ if (reference.getCallback() != null) {
+ createReferenceBindingProviders((RuntimeComponent)component,
+ (RuntimeComponentReference)reference,
+ reference.getCallback().getBindings());
}
}
-
+
Implementation implementation = component.getImplementation();
if (implementation instanceof Composite) {
configureComposite((Composite)implementation);
@@ -162,6 +151,48 @@
}
}
+ private void createServiceBindingProviders(RuntimeComponent component,
+ RuntimeComponentService service,
+ List<Binding> bindings) {
+ for (Binding binding : bindings) {
+ BindingProviderFactory providerFactory = (BindingProviderFactory)providerFactories
+ .getProviderFactory(binding.getClass());
+ if (providerFactory != null) {
+ ServiceBindingProvider bindingProvider = providerFactory
+ .createServiceBindingProvider((RuntimeComponent)component,
+ (RuntimeComponentService)service,
+ binding);
+ if (bindingProvider != null) {
+ ((RuntimeComponentService)service).setBindingProvider(binding, bindingProvider);
+ }
+ } else {
+ throw new IllegalStateException("Provider factory not found for class: " +
+ binding.getClass().getName());
+ }
+ }
+ }
+
+ private void createReferenceBindingProviders(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ List<Binding> bindings) {
+ for (Binding binding : bindings) {
+ BindingProviderFactory providerFactory = (BindingProviderFactory)providerFactories
+ .getProviderFactory(binding.getClass());
+ if (providerFactory != null) {
+ ReferenceBindingProvider bindingProvider = providerFactory
+ .createReferenceBindingProvider((RuntimeComponent)component,
+ (RuntimeComponentReference)reference,
+ binding);
+ if (bindingProvider != null) {
+ ((RuntimeComponentReference)reference).setBindingProvider(binding, bindingProvider);
+ }
+ } else {
+ throw new IllegalStateException("Provider factory not found for class: " +
+ binding.getClass().getName());
+ }
+ }
+ }
+
/**
* Start a composite
*/
@@ -195,6 +226,15 @@
bindingProvider.start();
}
}
+ if (service.getCallback() != null) {
+ for (Binding binding : service.getCallback().getBindings()) {
+ ServiceBindingProvider bindingProvider = ((RuntimeComponentService)service)
+ .getBindingProvider(binding);
+ if (bindingProvider != null) {
+ bindingProvider.start();
+ }
+ }
+ }
}
for (ComponentReference reference : component.getReferences()) {
for (Binding binding : reference.getBindings()) {
@@ -204,6 +244,15 @@
bindingProvider.start();
}
}
+ if (reference.getCallback() != null) {
+ for (Binding binding : reference.getCallback().getBindings()) {
+ ReferenceBindingProvider bindingProvider = ((RuntimeComponentReference)reference)
+ .getBindingProvider(binding);
+ if (bindingProvider != null) {
+ bindingProvider.start();
+ }
+ }
+ }
}
Implementation implementation = component.getImplementation();
@@ -238,6 +287,15 @@
bindingProvider.stop();
}
}
+ if (service.getCallback() != null) {
+ for (Binding binding : service.getCallback().getBindings()) {
+ ServiceBindingProvider bindingProvider = ((RuntimeComponentService)service)
+ .getBindingProvider(binding);
+ if (bindingProvider != null) {
+ bindingProvider.stop();
+ }
+ }
+ }
}
for (ComponentReference reference : component.getReferences()) {
for (Binding binding : reference.getBindings()) {
@@ -247,6 +305,15 @@
bindingProvider.stop();
}
}
+ if (reference.getCallback() != null) {
+ for (Binding binding : reference.getCallback().getBindings()) {
+ ReferenceBindingProvider bindingProvider = ((RuntimeComponentReference)reference)
+ .getBindingProvider(binding);
+ if (bindingProvider != null) {
+ bindingProvider.stop();
+ }
+ }
+ }
}
Implementation implementation = component.getImplementation();
if (implementation instanceof Composite) {
@@ -285,13 +352,23 @@
// Create outbound wires for the component references
for (ComponentReference reference : component.getReferences()) {
for (Binding binding : reference.getBindings()) {
- createWires(component, reference, binding);
+ createWires(component, reference, binding, false);
+ }
+ if (reference.getCallback() != null) {
+ for (Binding binding : reference.getCallback().getBindings()) {
+ createWires(component, reference, binding, true);
+ }
}
}
// Create inbound wires for the component services
for (ComponentService service : component.getServices()) {
for (Binding binding : service.getBindings()) {
- createWires(component, service, binding);
+ createWires(component, service, binding, false);
+ }
+ if (service.getCallback() != null) {
+ for (Binding binding : service.getCallback().getBindings()) {
+ createWires(component, service, binding, true);
+ }
}
}
}
@@ -305,7 +382,8 @@
* @param binding
* @return
*/
- private InterfaceContract getInterfaceContract(ComponentReference reference, Binding binding) {
+ private InterfaceContract getInterfaceContract(ComponentReference reference, Binding binding,
+ boolean isCallback) {
InterfaceContract interfaceContract = reference.getInterfaceContract();
ReferenceBindingProvider provider = ((RuntimeComponentReference)reference).getBindingProvider(binding);
if (provider != null) {
@@ -314,7 +392,7 @@
interfaceContract = bindingContract;
}
}
- return interfaceContract;
+ return interfaceContract.makeUnidirectional(isCallback);
}
/**
@@ -324,18 +402,19 @@
* @param reference
* @param binding
*/
- private void createWires(Component component, ComponentReference reference, Binding binding) {
+ private void createWires(Component component, ComponentReference reference, Binding binding, boolean isCallback) {
if (!(reference instanceof RuntimeComponentReference)) {
return;
}
RuntimeComponentReference runtimeRef = (RuntimeComponentReference)reference;
- InterfaceContract bindingContract = getInterfaceContract(reference, binding);
+ InterfaceContract bindingContract = getInterfaceContract(reference, binding, isCallback);
if (!(binding instanceof SCABinding)) {
// Use the interface contract of the reference on the component type
Reference componentTypeRef = reference.getReference();
InterfaceContract sourceContract = componentTypeRef == null ? reference.getInterfaceContract()
- : componentTypeRef.getInterfaceContract();
+ : componentTypeRef.getInterfaceContract();
+ sourceContract = sourceContract.makeUnidirectional(isCallback);
// Component Reference --> External Service
EndpointReference wireSource = new EndpointReferenceImpl((RuntimeComponent)component,
@@ -345,28 +424,27 @@
EndpointReference wireTarget = new EndpointReferenceImpl(null, null, binding, bindingContract);
RuntimeWire wire = new RuntimeWireImpl(wireSource, wireTarget);
- for (Operation operation : sourceContract.getInterface().getOperations()) {
- Operation targetOperation = interfaceContractMapper.map(bindingContract.getInterface(), operation);
- InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
- if (operation.isNonBlocking()) {
- chain.addInterceptor(new NonBlockingInterceptor(workScheduler));
+ if (sourceContract.getInterface() != null) {
+ for (Operation operation : sourceContract.getInterface().getOperations()) {
+ Operation targetOperation = interfaceContractMapper.map(bindingContract.getInterface(), operation);
+ InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
+ if (operation.isNonBlocking()) {
+ addNonBlockingInterceptor(reference, binding, chain);
+ }
+ addBindingInterceptor(reference, binding, chain, operation);
+ wire.getInvocationChains().add(chain);
}
- addBindingInterceptor(component, reference, binding, chain, operation, false);
- wire.getInvocationChains().add(chain);
}
- if (sourceContract.getCallbackInterface() != null) {
- for (Operation operation : sourceContract.getCallbackInterface().getOperations()) {
- Operation targetOperation = interfaceContractMapper.map(bindingContract.getCallbackInterface(),
+ if (bindingContract.getCallbackInterface() != null && !(reference.getName().startsWith("$self$."))) {
+ for (Operation operation : bindingContract.getCallbackInterface().getOperations()) {
+ Operation targetOperation = interfaceContractMapper.map(sourceContract.getCallbackInterface(),
operation);
InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
- if (operation.isNonBlocking()) {
- chain.addInterceptor(new NonBlockingInterceptor(workScheduler));
- }
- addBindingInterceptor(component, reference, binding, chain, operation, true);
- wire.getCallbackInvocationChains().add(chain);
+ addImplementationInterceptor(component, null, chain, targetOperation, true);
+ wire.addCallbackInvocationChain(chain);
}
}
- runtimeRef.getRuntimeWires().add(wire);
+ runtimeRef.getRuntimeWires().add(wire);
wireProcessor.process(wire);
// TODO: For non-SCA binding, how do we deal with targets? For now, assuming targets only apply to SCABinding
return;
@@ -384,7 +462,8 @@
}
// FIXME: [rfeng] We might need a better way to get the impl interface contract
- InterfaceContract targetContract = service.getService().getInterfaceContract();
+ InterfaceContract targetContract =
+ service.getService().getInterfaceContract().makeUnidirectional(isCallback);
EndpointReference wireSource = new EndpointReferenceImpl((RuntimeComponent)component,
(RuntimeComponentReference)reference, binding,
@@ -396,33 +475,36 @@
RuntimeWire wire = new RuntimeWireImpl(wireSource, wireTarget);
- for (Operation operation : bindingContract.getInterface().getOperations()) {
- Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation);
- InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
- if (operation.isNonBlocking()) {
- chain.addInterceptor(new NonBlockingInterceptor(workScheduler));
- }
- addBindingInterceptor(component, reference, binding, chain, operation, false);
- if (target != null) {
- addImplementationInterceptor(target, service, chain, targetOperation, false);
+ if (bindingContract.getInterface() != null) {
+ for (Operation operation : bindingContract.getInterface().getOperations()) {
+ Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation);
+ InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
+ if (operation.isNonBlocking()) {
+ addNonBlockingInterceptor(reference, binding, chain);
+ }
+ addBindingInterceptor(reference, binding, chain, operation);
+ if (target != null) {
+ addImplementationInterceptor(target, service, chain, targetOperation, false);
+ }
+ wire.getInvocationChains().add(chain);
}
- wire.getInvocationChains().add(chain);
}
- if (bindingContract.getCallbackInterface() != null) {
- if (reference.getName().startsWith("$self$.")) {
- // No callback is needed
- continue;
- }
- for (Operation operation : bindingContract.getCallbackInterface().getOperations()) {
- Operation targetOperation = interfaceContractMapper.map(targetContract.getCallbackInterface(),
+ if (targetContract.getCallbackInterface() != null) {
+ for (Operation operation : targetContract.getCallbackInterface().getOperations()) {
+ Operation targetOperation = interfaceContractMapper.map(bindingContract.getCallbackInterface(),
operation);
InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
if (operation.isNonBlocking()) {
- chain.addInterceptor(new NonBlockingInterceptor(workScheduler));
+ addNonBlockingCallbackInterceptor(service, binding, chain);
}
- addBindingInterceptor(component, reference, binding, chain, operation, true);
- addImplementationInterceptor(component, null, chain, targetOperation, true);
- wire.getCallbackInvocationChains().add(chain);
+ if (target != null) {
+ addBindingCallbackInterceptor(service, binding, chain, operation);
+ }
+ // can't create callback implementation interceptor for self-reference
+ if (!reference.getName().startsWith("$self$.")) {
+ addImplementationInterceptor(component, null, chain, targetOperation, true);
+ }
+ wire.addCallbackInvocationChain(chain);
}
}
@@ -443,7 +525,7 @@
* @param binding
* @return
*/
- private InterfaceContract getInterfaceContract(ComponentService service, Binding binding) {
+ private InterfaceContract getInterfaceContract(ComponentService service, Binding binding, boolean isCallback) {
InterfaceContract interfaceContract = service.getInterfaceContract();
ServiceBindingProvider provider = ((RuntimeComponentService)service).getBindingProvider(binding);
@@ -453,7 +535,7 @@
interfaceContract = bindingContract;
}
}
- return interfaceContract;
+ return interfaceContract.makeUnidirectional(isCallback);
}
/**
@@ -463,16 +545,17 @@
* @param service
* @param binding
*/
- private void createWires(Component component, ComponentService service, Binding binding) {
+ private void createWires(Component component, ComponentService service, Binding binding, boolean isCallback) {
if (!(service instanceof RuntimeComponentService)) {
return;
}
RuntimeComponentService runtimeService = (RuntimeComponentService)service;
// FIXME: [rfeng] We might need a better way to get the impl interface contract
- InterfaceContract targetContract = service.getService().getInterfaceContract();
+ InterfaceContract targetContract = service.getService().getInterfaceContract().
+ makeUnidirectional(isCallback);
- InterfaceContract sourceContract = getInterfaceContract(service, binding);
+ InterfaceContract sourceContract = getInterfaceContract(service, binding, isCallback);
EndpointReference wireSource = new EndpointReferenceImpl(null, null, binding, sourceContract);
@@ -482,36 +565,30 @@
RuntimeWire wire = new RuntimeWireImpl(wireSource, wireTarget);
- for (Operation operation : sourceContract.getInterface().getOperations()) {
- Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation);
- InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
- /* lresende */
- if (operation.isNonBlocking()) {
- chain.addInterceptor(new NonBlockingInterceptor(workScheduler));
+ if (sourceContract.getInterface() != null) {
+ for (Operation operation : sourceContract.getInterface().getOperations()) {
+ Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation);
+ InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
+ addImplementationInterceptor(component, service, chain, targetOperation, false);
+ wire.getInvocationChains().add(chain);
}
+ runtimeService.getRuntimeWires().add(wire);
+ }
- addImplementationInterceptor(component, service, chain, targetOperation, false);
- wire.getInvocationChains().add(chain);
+ if (sourceContract.getCallbackInterface() != null) {
+ for (Operation operation : targetContract.getCallbackInterface().getOperations()) {
+ Operation targetOperation =
+ interfaceContractMapper.map(sourceContract.getCallbackInterface(), operation);
+ InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
+ if (operation.isNonBlocking()) {
+ addNonBlockingCallbackInterceptor(service, binding, chain);
+ }
+ addBindingCallbackInterceptor(service, binding, chain, operation);
+ wire.addCallbackInvocationChain(chain);
+ }
+ runtimeService.getCallbackWires().add(wire);
}
- // if (sourceContract.getCallbackInterface() != null) {
- // for (Operation operation :
- // sourceContract.getCallbackInterface().getOperations()) {
- // Operation targetOperation =
- // interfaceContractMapper.map(targetContract.getCallbackInterface(),
- // operation);
- // InvocationChain chain = new InvocationChainImpl(operation,
- // targetOperation);
- // if (operation.isNonBlocking()) {
- // chain.addInterceptor(new NonBlockingInterceptor(workScheduler,
- // workContext));
- // }
- // addImplementationInterceptor(component, service, chain, operation,
- // true);
- // wire.getCallbackInvocationChains().add(chain);
- // }
- // }
- runtimeService.getRuntimeWires().add(wire);
wireProcessor.process(wire);
}
@@ -544,22 +621,99 @@
/**
* Add the interceptor for a binding
*
- * @param component
* @param reference
* @param binding
* @param chain
* @param operation
- * @param isCallback
*/
- private void addBindingInterceptor(Component component,
- ComponentReference reference,
+ private void addBindingInterceptor(ComponentReference reference,
Binding binding,
InvocationChain chain,
- Operation operation,
- boolean isCallback) {
+ Operation operation) {
+ ReferenceBindingProvider provider = ((RuntimeComponentReference)reference).getBindingProvider(binding);
+ if (provider != null) {
+ Invoker invoker = null;
+ if (provider instanceof ReferenceBindingProvider2) {
+ invoker = ((ReferenceBindingProvider2)provider).createInvoker(operation);
+ } else {
+ // must be an old provider that only has the deprecated signature
+ invoker = provider.createInvoker(operation, false);
+ }
+ if (invoker != null) {
+ chain.addInvoker(invoker);
+ }
+ }
+ }
+
+ /**
+ * 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) {
- Invoker invoker = provider.createInvoker(operation, isCallback);
+ boolean supportsAsyncOneWayInvocation = false;
+ if (provider instanceof ReferenceBindingProvider2) {
+ supportsAsyncOneWayInvocation = ((ReferenceBindingProvider2)provider).supportsAsyncOneWayInvocation();
+ } else {
+ // must be an old provider that doesn't have this method
+ }
+ if (!supportsAsyncOneWayInvocation) {
+ chain.addInterceptor(new NonBlockingInterceptor(workScheduler));
+ }
+ }
+ }
+
+ /**
+ * Add a non-blocking interceptor if the service binding needs it
+ *
+ * @param service
+ * @param binding
+ * @param chain
+ */
+ private void addNonBlockingCallbackInterceptor(ComponentService service,
+ Binding binding,
+ InvocationChain chain) {
+ ServiceBindingProvider provider = ((RuntimeComponentService)service).getBindingProvider(binding);
+ if (provider != null) {
+ boolean supportsAsyncOneWayInvocation = false;
+ if (provider instanceof ServiceBindingProvider2) {
+ supportsAsyncOneWayInvocation = ((ServiceBindingProvider2)provider).supportsAsyncOneWayInvocation();
+ } else {
+ // must be an old provider that doesn't have this method
+ }
+ if (!supportsAsyncOneWayInvocation) {
+ chain.addInterceptor(new NonBlockingInterceptor(workScheduler));
+ }
+ }
+ }
+
+ /**
+ * Add the interceptor for callbacks through a binding
+ *
+ * @param component
+ * @param service
+ * @param binding
+ * @param chain
+ * @param operation
+ */
+ private void addBindingCallbackInterceptor(ComponentService service,
+ Binding binding,
+ InvocationChain chain,
+ Operation operation) {
+ ServiceBindingProvider provider = ((RuntimeComponentService)service).getBindingProvider(binding);
+ if (provider != null) {
+ Invoker invoker = null;
+ if (provider instanceof ServiceBindingProvider2) {
+ invoker = ((ServiceBindingProvider2)provider).createCallbackInvoker(operation);
+ } else {
+ // must be an old provider that does not support callbacks
+ }
if (invoker != null) {
chain.addInvoker(invoker);
}
Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeWireImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeWireImpl.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeWireImpl.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeWireImpl.java Tue Jul 10 21:24:38 2007
@@ -20,8 +20,10 @@
package org.apache.tuscany.sca.core.runtime;
import java.util.ArrayList;
+import java.util.IdentityHashMap;
import java.util.List;
+import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.InvocationChain;
import org.apache.tuscany.sca.runtime.EndpointReference;
import org.apache.tuscany.sca.runtime.RuntimeWire;
@@ -35,6 +37,7 @@
private final List<InvocationChain> chains = new ArrayList<InvocationChain>();
private final List<InvocationChain> callbackChains = new ArrayList<InvocationChain>();
+ IdentityHashMap<Operation, InvocationChain> callbackMap = new IdentityHashMap<Operation, InvocationChain>();
/**
* @param source
@@ -61,6 +64,15 @@
public EndpointReference getTarget() {
return wireTarget;
+ }
+
+ public void addCallbackInvocationChain(InvocationChain chain) {
+ callbackChains.add(chain);
+ callbackMap.put(chain.getSourceOperation(), chain);
+ }
+
+ public IdentityHashMap<Operation, InvocationChain> getCallbackInvocationMap() {
+ return callbackMap;
}
}
Modified: incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java (original)
+++ incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java Tue Jul 10 21:24:38 2007
@@ -25,7 +25,7 @@
*
* @version $Rev$ $Date$
*/
-public interface InterfaceContract {
+public interface InterfaceContract extends Cloneable {
/**
* Returns the interface definition representing the interface for
@@ -62,5 +62,15 @@
* interface for invocations from the provider to the requestor.
*/
void setCallbackInterface(Interface callbackInterface);
+
+ // FIXME: We need a better way to do this
+ /**
+ * Convert an interface contract to a unidirectional interface contract
+ *
+ * @param isCallback true for a callback interface contract, false for
+ * a forward interface contract
+ * @return A unidirectional interface contract, cloned if necessary
+ */
+ InterfaceContract makeUnidirectional(boolean isCallback);
}
Modified: incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java (original)
+++ incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java Tue Jul 10 21:24:38 2007
@@ -48,4 +48,26 @@
this.callInterface = callInterface;
}
+ public InterfaceContract makeUnidirectional(boolean isCallback) {
+ if (!isCallback && callbackInterface == null)
+ return this; // already a unidirectional forward interface contract
+
+ if (isCallback && callInterface == null)
+ return this; // already a unidirectional callback interface contract
+
+ // contract is bidrectional, so create a new unidirectional contract
+ try {
+ InterfaceContract newContract = (InterfaceContract)clone();
+ if (!isCallback) {
+ newContract.setCallbackInterface(null); // create unidirectional forward interface contract
+ } else {
+ newContract.setInterface(null); // create unidirectional callback interface contract
+ }
+ return newContract;
+ } catch (CloneNotSupportedException e) {
+ // will not happen
+ return null;
+ }
+ }
+
}
Modified: incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java (original)
+++ incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java Tue Jul 10 21:24:38 2007
@@ -38,6 +38,9 @@
return true;
}
if (!remotable) {
+ if (source == null || target == null) {
+ return false;
+ }
// For local case
return target.getPhysical() == source.getPhysical();
} else {
@@ -57,6 +60,10 @@
if (!source.getName().equals(target.getName())) {
return false;
}
+
+ if (source.getInterface().isRemotable() != target.getInterface().isRemotable()) {
+ return false;
+ }
// FIXME: We need to deal with wrapped<-->unwrapped conversion
@@ -196,12 +203,15 @@
return false;
}
}
- if (!operation.equals(targetOperation)) {
- if (!silent) {
- throw new IncompatibleInterfaceContractException("Target callback operation is not compatible",
- source, target, operation, targetOperation);
- } else {
- return false;
+ if (!source.getCallbackInterface().isRemotable()) {
+ // FIXME: for remotable operation, only compare name for now
+ if (!operation.equals(targetOperation)) {
+ if (!silent) {
+ throw new IncompatibleInterfaceContractException("Target callback operation is not compatible",
+ source, target, operation, targetOperation);
+ } else {
+ return false;
+ }
}
}
}
Modified: incubator/tuscany/java/sca/modules/topology-xml/src/main/java/org/apache/tuscany/sca/topology/xml/BaseArtifactProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/topology-xml/src/main/java/org/apache/tuscany/sca/topology/xml/BaseArtifactProcessor.java?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/modules/topology-xml/src/main/java/org/apache/tuscany/sca/topology/xml/BaseArtifactProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/topology-xml/src/main/java/org/apache/tuscany/sca/topology/xml/BaseArtifactProcessor.java Tue Jul 10 21:24:38 2007
@@ -277,6 +277,14 @@
Binding binding = contract.getBindings().get(i);
extensionProcessor.resolve(binding, resolver);
}
+
+ // Resolve callback bindings
+ if (contract.getCallback() != null) {
+ for (int i = 0, n = contract.getCallback().getBindings().size(); i < n; i++) {
+ Binding binding = contract.getCallback().getBindings().get(i);
+ extensionProcessor.resolve(binding, resolver);
+ }
+ }
}
}
Modified: incubator/tuscany/java/sca/samples/README
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/README?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/samples/README (original)
+++ incubator/tuscany/java/sca/samples/README Tue Jul 10 21:24:38 2007
@@ -38,6 +38,8 @@
JSONRPC
simple-callback - An SCA application with two components demonstrating
the callback interface
+simple-callback-ws - An SCA application with two components demonstrating
+ the callback interface across the Web service binding
implementation-composite - An SCA application that shows how composites are used to
implement components
supplychain - A more complicated sample showing how asynchronous
@@ -241,4 +243,5 @@
The details of how to do this for other development environments will
vary but the process will be similar.
+
Modified: incubator/tuscany/java/sca/samples/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/pom.xml?view=diff&rev=555162&r1=555161&r2=555162
==============================================================================
--- incubator/tuscany/java/sca/samples/pom.xml (original)
+++ incubator/tuscany/java/sca/samples/pom.xml Tue Jul 10 21:24:38 2007
@@ -66,6 +66,7 @@
<module>simple-bigbank</module>
<module>simple-bigbank-spring</module>
<module>simple-callback</module>
+ <module>simple-callback-ws</module>
<module>supplychain</module>
<module>web-resource</module>
</modules>
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org