diff options
Diffstat (limited to 'sca-java-2.x/trunk')
8 files changed, 70 insertions, 18 deletions
diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java index 6d81a596b3..23a50e5f22 100644 --- a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java +++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java @@ -23,6 +23,7 @@ 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.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.definitions.Definitions; import org.apache.tuscany.sca.invocation.Message; import org.apache.tuscany.sca.runtime.EndpointRegistry; import org.apache.tuscany.sca.runtime.RuntimeComponent; @@ -41,8 +42,9 @@ public class CompositeContext { protected Composite domainComposite; protected String nodeURI; protected String domainURI; + protected Definitions systemDefinitions; - public CompositeContext(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry, Composite domainComposite, String domainURI, String nodeURI) { + public CompositeContext(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry, Composite domainComposite, String domainURI, String nodeURI, Definitions systemDefinitions) { this.extensionPointRegistry = registry; this.endpointRegistry = endpointRegistry; ContextFactoryExtensionPoint contextFactories = registry.getExtensionPoint(ContextFactoryExtensionPoint.class); @@ -50,10 +52,11 @@ public class CompositeContext { this.domainComposite = domainComposite; this.domainURI = domainURI; this.nodeURI = nodeURI; + this.systemDefinitions = systemDefinitions; } public CompositeContext(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry) { - this(registry, endpointRegistry, null, "default", "default"); + this(registry, endpointRegistry, null, "default", "default", null); } /** @@ -136,4 +139,14 @@ public class CompositeContext { public String getDomainURI() { return domainURI; } + + /** + * The system definitions that result from starting the runtime. + * TODO - these can be null when the SCAClient starts the runtime + * + * @return systemDefinitions + */ + public Definitions getSystemDefinitions() { + return systemDefinitions; + } } diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpoint.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpoint.java index 178f184c1f..97a849f14c 100644 --- a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpoint.java +++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpoint.java @@ -22,6 +22,7 @@ package org.apache.tuscany.sca.runtime; import java.io.Serializable; import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.context.CompositeContext; import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.provider.ServiceBindingProvider; @@ -55,4 +56,11 @@ public interface RuntimeEndpoint extends Endpoint, Invocable, Serializable { * @return The target component type service interface contract */ InterfaceContract getComponentTypeServiceInterfaceContract(); + + /** + * Get the composite context for the composite that contains this endpoint. This + * is useful for accessing various composite level objects from within the + * runtime code + */ + CompositeContext getCompositeContext(); } diff --git a/sca-java-2.x/trunk/modules/core/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/core/META-INF/MANIFEST.MF index da7db3a718..62fc183f20 100644 --- a/sca-java-2.x/trunk/modules/core/META-INF/MANIFEST.MF +++ b/sca-java-2.x/trunk/modules/core/META-INF/MANIFEST.MF @@ -47,6 +47,7 @@ Import-Package: javax.security.auth, org.apache.tuscany.sca.core.factory;version="2.0.0",
org.apache.tuscany.sca.core.invocation;version="2.0.0",
org.apache.tuscany.sca.core.scope;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
org.apache.tuscany.sca.extensibility;version="2.0.0",
org.apache.tuscany.sca.interfacedef;version="2.0.0",
org.apache.tuscany.sca.interfacedef.impl;version="2.0.0";resolution:=optional,
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java index 8eade75a8c..0a88429848 100644 --- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java +++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java @@ -40,15 +40,19 @@ import org.apache.tuscany.sca.assembly.builder.PolicyBuilder; 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.assembly.impl.RuntimeEndpointImpl; +import org.apache.tuscany.sca.definitions.Definitions; import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; +import org.apache.tuscany.sca.policy.BindingType; import org.apache.tuscany.sca.policy.Intent; import org.apache.tuscany.sca.policy.IntentMap; import org.apache.tuscany.sca.policy.PolicySet; import org.apache.tuscany.sca.policy.Qualifier; import org.apache.tuscany.sca.runtime.EndpointReferenceBinder; import org.apache.tuscany.sca.runtime.EndpointRegistry; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; import org.oasisopen.sca.ServiceRuntimeException; /** @@ -482,18 +486,26 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder { List<Intent> eprIntents = new ArrayList<Intent>(); eprIntents.addAll(endpointReference.getRequiredIntents()); + // TODO - seems that we should do this loop on a binding by binding basis + // rather than each time we do matching + BindingType bindingType = null; + Definitions systemDefinitions = ((RuntimeEndpoint)endpoint).getCompositeContext().getSystemDefinitions(); + for (BindingType loopBindingType : systemDefinitions.getBindingTypes()){ + if (loopBindingType.getType().equals(binding.getType())){ + bindingType = loopBindingType; + break; + } + } + // first check the binding type - for (Intent intent : endpointReference.getRequiredIntents()){ -/* TODO - BindingType bindingType = null; //TODO - where to get this? - - if (bindingType.getAlwaysProvidedIntents().contains(intent)){ + for (Intent intent : endpointReference.getRequiredIntents()){ + if (bindingType != null && + bindingType.getAlwaysProvidedIntents().contains(intent)){ eprIntents.remove(intent); - } else if (bindingType.getMayProvidedIntents().contains(intent)){ + } else if (bindingType != null && + bindingType.getMayProvidedIntents().contains(intent)){ eprIntents.remove(intent); } else { - -*/ // TODO - this code also appears in the ComponentPolicyBuilder // so should rationalize loop: for (PolicySet policySet : referencePolicySets){ @@ -517,11 +529,8 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder { } } } - } - -/* + } } - */ } // if there are unresolved intents the service and reference don't match diff --git a/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java b/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java index e0691ab11b..349c28d66e 100644 --- a/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java +++ b/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java @@ -471,4 +471,14 @@ public class NodeFactoryImpl extends NodeFactory { super.configure(attributes); } + /** + * Added to allow the node access to the deployer in order to get + * to the systemContribution and hence set up the CompositeContext so that + * the runtime epr matching algorithm can get at the binding types + * @return + */ + public Deployer getDeployer() { + return deployer; + } + } diff --git a/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java index eef9f39009..36091bec6c 100644 --- a/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java +++ b/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java @@ -128,8 +128,13 @@ public class NodeImpl implements Node { domainComposite = manager.configureNode(configuration, contributions, context); this.compositeContext = - new CompositeContext(manager.registry, endpointRegistry, domainComposite, configuration - .getDomainURI(), configuration.getURI()); + new CompositeContext(manager.registry, + endpointRegistry, + domainComposite, + configuration.getDomainURI(), + configuration.getURI(), + manager.getDeployer().getSystemDefinitions()); + CompositeContext.setThreadCompositeContext(compositeContext); } finally { // Reset the thread context monitor diff --git a/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java b/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java index c3cfdc791c..d32afb2acb 100644 --- a/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java +++ b/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java @@ -93,8 +93,14 @@ public class SCAClientFactoryImpl extends SCAClientFactory { this.proxyFactory = ExtensibleProxyFactory.getInstance(extensionsRegistry); String client = "sca.client." + UUID.randomUUID(); + this.compositeContext = - new CompositeContext(extensionsRegistry, endpointRegistry, null, domainURI.toString(), client); + new CompositeContext(extensionsRegistry, + endpointRegistry, + null, + domainURI.toString(), + client, + this.nodeFactory.getDeployer().getSystemDefinitions()); } @Override diff --git a/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java b/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java index 6c4f1bacb8..86bdef8380 100644 --- a/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java +++ b/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java @@ -91,7 +91,7 @@ public class SCAClientHandler implements InvocationHandler { String client = "sca.client." + UUID.randomUUID();
CompositeContext compositeContext =
- new CompositeContext(extensionsRegistry, endpointRegistry, null, domainURI.toString(), client);
+ new CompositeContext(extensionsRegistry, endpointRegistry, null, domainURI.toString(), client, null);
List<Endpoint> eps = endpointRegistry.findEndpoint(serviceName);
if (eps == null || eps.size() < 1) {
|