summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/assembly/src/main
diff options
context:
space:
mode:
authornash <nash@13f79535-47bb-0310-9956-ffa450edef68>2008-07-25 12:09:35 +0000
committernash <nash@13f79535-47bb-0310-9956-ffa450edef68>2008-07-25 12:09:35 +0000
commitc2d02c05c8e0a886cdce693b1abd8341b23dc464 (patch)
tree0c2cd4e3d4174250270a95f0dc952b91f9963a90 /java/sca/modules/assembly/src/main
parent8ae097d142aeb570f17a36ab3c8a8487e9ebbf64 (diff)
Copy 1.3 branch revisions 678491, 678875, 679082, 679205, 679334 and 679385
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@679774 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/assembly/src/main')
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java14
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java18
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java18
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java355
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java248
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java18
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionWireBuilderImpl.java165
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServicePromotionBuilderImpl.java99
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java50
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java50
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.java224
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java62
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceBindingBuilderImpl.java2
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java170
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServicePromotionBuilderImpl.java77
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java169
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ServiceConfigurationUtil.java29
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java21
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java11
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java17
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java8
-rw-r--r--java/sca/modules/assembly/src/main/resources/assembly-validation-messages.properties1
22 files changed, 1313 insertions, 513 deletions
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java
index 55540452af..f9a62774e6 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java
@@ -20,6 +20,7 @@ package org.apache.tuscany.sca.assembly;
import java.util.List;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
/**
@@ -78,4 +79,17 @@ public interface Contract extends AbstractContract, PolicySetAttachPoint, Clonea
*/
Object clone() throws CloneNotSupportedException;
+ /**
+ * Returns the interface contract given a binding. Important in the case where
+ * a reference with multiplicity > 1 has been promoted and has it's list of
+ * resolved bindings extended by a promoting reference. Here the binding
+ * from the promoting reference may need the interface contract from the
+ * promoting reference and not the promoted reference.
+ * TODO - remove this wrinkle with better endpoint support.
+ *
+ * @param binding the binding for which the interface contract is required
+ * @return the interface contract
+ */
+ InterfaceContract getInterfaceContract(Binding binding);
+
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java
index f1522688fc..ee63497fbe 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java
@@ -20,6 +20,8 @@ package org.apache.tuscany.sca.assembly;
import java.util.List;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+
/**
* Represents an endpoint (primarily a combination of a target service name and a set of
* candidate bindings)
@@ -147,5 +149,19 @@ public interface Endpoint extends Base, Cloneable {
*
* @param binding target binding
*/
- void setTargetBinding(Binding binding);
+ void setTargetBinding(Binding binding);
+
+ /**
+ * Returns the interface contract defining the interface
+ *
+ * @return the interface contract
+ */
+ InterfaceContract getInterfaceContract();
+
+ /**
+ * Sets the interface contract defining the interface
+ *
+ * @param interfaceContract the interface contract
+ */
+ void setInterfaceContract(InterfaceContract interfaceContract);
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java
index f38346663a..2eb1bf21b0 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java
@@ -47,6 +47,24 @@ public interface Reference extends AbstractReference, Contract {
void setWiredByImpl(boolean wiredByImpl);
/**
+ * Returns a boolean value, "false" by default, which indicates whether
+ * the configuration of this reference is a promotion override for
+ * another more deeply nested reference.
+ *
+ * @return true if the reference is a promotion override
+ */
+ boolean isPromotionOverride();
+
+ /**
+ * Sets a boolean value, "false" by default, which indicates whether
+ * the configuration of this reference is a promotion override for
+ * another more deeply nested reference.
+ *
+ * @param promotionOverride whether the reference is a promotion override
+ */
+ void setPromotionOverride(boolean promotionOverride);
+
+ /**
* Returns the targets of this reference.
*
* @return the targets of this reference.
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java
index 71523bd713..bbdb89ad3c 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java
@@ -35,6 +35,7 @@ import org.apache.tuscany.sca.assembly.ComponentReference;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Contract;
import org.apache.tuscany.sca.assembly.Implementation;
import org.apache.tuscany.sca.assembly.Property;
import org.apache.tuscany.sca.assembly.Reference;
@@ -90,7 +91,7 @@ public abstract class BaseConfigurationBuilderImpl {
protected void configureComponents(Composite composite) throws CompositeBuilderException {
configureComponents(composite, null);
configureSourcedProperties(composite, null);
- configureBindingURIs(composite, null, null);
+ //configureBindingURIs(composite, null, null);
}
/**
@@ -133,7 +134,7 @@ public abstract class BaseConfigurationBuilderImpl {
SCABinding scaBinding = createSCABinding();
service.getBindings().add(scaBinding);
}
-
+/*
// Initialize binding names and URIs
for (Binding binding : service.getBindings()) {
@@ -150,6 +151,7 @@ public abstract class BaseConfigurationBuilderImpl {
}
}
}
+*/
}
// Initialize reference bindings
@@ -159,7 +161,7 @@ public abstract class BaseConfigurationBuilderImpl {
SCABinding scaBinding = createSCABinding();
reference.getBindings().add(scaBinding);
}
-
+/*
// Set binding names
for (Binding binding : reference.getBindings()) {
if (binding.getName() == null) {
@@ -174,6 +176,7 @@ public abstract class BaseConfigurationBuilderImpl {
}
}
}
+*/
}
// Initialize all component services and references
@@ -247,7 +250,7 @@ public abstract class BaseConfigurationBuilderImpl {
SCABinding scaBinding = createSCABinding();
componentService.getBindings().add(scaBinding);
}
-
+/*
// Set binding names
for (Binding binding : componentService.getBindings()) {
@@ -263,6 +266,7 @@ public abstract class BaseConfigurationBuilderImpl {
}
}
}
+*/
}
// Initialize reference bindings
@@ -273,7 +277,7 @@ public abstract class BaseConfigurationBuilderImpl {
SCABinding scaBinding = createSCABinding();
componentReference.getBindings().add(scaBinding);
}
-
+/*
// Set binding names
for (Binding binding : componentReference.getBindings()) {
if (binding.getName() == null) {
@@ -287,6 +291,7 @@ public abstract class BaseConfigurationBuilderImpl {
}
}
}
+*/
}
}
}
@@ -796,208 +801,6 @@ public abstract class BaseConfigurationBuilderImpl {
}
/**
- * Activate composite services in nested composites.
- *
- * @param composite
- * @param problems
- */
- protected void configureCompositeServices(Composite composite) {
-
- // Process nested composites recursively
- configureNestedCompositeServices(composite);
-
- // Process top level composite services
- for (Service service : composite.getServices()) {
- CompositeService compositeService = (CompositeService)service;
-
- // Get the inner most promoted service
- ComponentService promotedService = ServiceConfigurationUtil.getPromotedComponentService(compositeService);
- if (promotedService != null) {
- Component promotedComponent = getPromotedComponent(compositeService);
-
- // Default to use the interface from the promoted service
- if (compositeService.getInterfaceContract() == null && promotedService.getInterfaceContract() != null) {
- compositeService.setInterfaceContract(promotedService.getInterfaceContract());
- }
-
- // Create a new component service to represent this composite
- // service on the promoted component
- ComponentService newComponentService = assemblyFactory.createComponentService();
- newComponentService.setName("$promoted$." + compositeService.getName());
- promotedComponent.getServices().add(newComponentService);
- newComponentService.setService(promotedService.getService());
- // set the bindings using the top level bindings to override the
- // lower level bindings
- if (bindingsSpecifiedManually(compositeService.getBindings())){
- newComponentService.getBindings()
- .addAll(compositeService.getBindings());
- } else {
- for (Binding binding : promotedService.getBindings()){
- try {
- newComponentService.getBindings().add((Binding)binding.clone());
- } catch(CloneNotSupportedException ex){
- // this binding can't be used in the promoted service
- }
- }
- }
- newComponentService.setInterfaceContract(compositeService.getInterfaceContract());
- if (compositeService.getInterfaceContract() != null && compositeService
- .getInterfaceContract().getCallbackInterface() != null) {
- newComponentService.setCallback(assemblyFactory.createCallback());
- if ((compositeService.getCallback() != null) &&
- (bindingsSpecifiedManually(compositeService.getCallback().getBindings()))){
- newComponentService.getCallback().getBindings()
- .addAll(compositeService.getCallback().getBindings());
- } else if ((promotedService.getCallback() != null) &&
- (bindingsSpecifiedManually(promotedService.getCallback().getBindings()))){
- for (Binding binding : promotedService.getCallback().getBindings()){
- try {
- newComponentService.getCallback().getBindings().add((Binding)binding.clone());
- } catch(CloneNotSupportedException ex){
- // this binding can't be used in the promoted service
- }
- }
- }
- }
-
- // Change the composite service to now promote the newly
- // created component service directly
- compositeService.setPromotedComponent(promotedComponent);
- compositeService.setPromotedService(newComponentService);
- }
- }
- }
-
- /**
- * Activate composite services in nested composites.
- *
- * @param composite
- * @param problems
- */
- private void configureNestedCompositeServices(Composite composite) {
-
- // Process nested composites recursively
- for (Component component : composite.getComponents()) {
- Implementation implementation = component.getImplementation();
- if (implementation instanceof Composite) {
-
- // First process nested composites
- configureNestedCompositeServices((Composite)implementation);
-
- // Process the component services declared on components
- // in this composite
- for (ComponentService componentService : component.getServices()) {
- Service implService = componentService.getService();
- if (implService != null && implService instanceof CompositeService) {
- CompositeService compositeService = (CompositeService)implService;
-
- // Get the inner most promoted service
- ComponentService promotedService =
- ServiceConfigurationUtil.getPromotedComponentService(compositeService);
- if (promotedService != null) {
- Component promotedComponent = getPromotedComponent(compositeService);
-
- // Default to use the interface from the promoted
- // service
- if (compositeService.getInterfaceContract() == null) {
- compositeService.setInterfaceContract(promotedService
- .getInterfaceContract());
- }
- if (componentService.getInterfaceContract() == null) {
- componentService.setInterfaceContract(promotedService
- .getInterfaceContract());
- }
-
- // Create a new component service to represent this
- // composite service on the promoted component
- ComponentService newComponentService =
- assemblyFactory.createComponentService();
- newComponentService.setName("$promoted$." + componentService.getName());
- promotedComponent.getServices().add(newComponentService);
- newComponentService.setService(promotedService.getService());
-
- // set the bindings using the top level bindings to override the
- // lower level bindings
- if (bindingsSpecifiedManually(componentService.getBindings())){
- newComponentService.getBindings()
- .addAll(componentService.getBindings());
- } else if (bindingsSpecifiedManually(compositeService.getBindings())){
- newComponentService.getBindings()
- .addAll(compositeService.getBindings());
- } else {
- for (Binding binding : promotedService.getBindings()){
- try {
- newComponentService.getBindings().add((Binding)binding.clone());
- } catch(CloneNotSupportedException ex){
- // this binding can't be used in the promoted service
- }
- }
- }
-
- newComponentService.setInterfaceContract(componentService
- .getInterfaceContract());
-
- if (componentService.getInterfaceContract() != null &&
- componentService.getInterfaceContract().getCallbackInterface() != null) {
-
- newComponentService.setCallback(assemblyFactory.createCallback());
-
- // set the bindings using the top level bindings to override the
- // lower level bindings
- if ((componentService.getCallback() != null) &&
- (bindingsSpecifiedManually(componentService.getCallback().getBindings()))){
- newComponentService.getCallback().getBindings()
- .addAll(componentService.getCallback().getBindings());
- } else if ((compositeService.getCallback() != null) &&
- (bindingsSpecifiedManually(compositeService.getCallback().getBindings()))){
- newComponentService.getCallback().getBindings()
- .addAll(compositeService.getCallback().getBindings());
- } else if ((promotedService.getCallback() != null) &&
- (bindingsSpecifiedManually(promotedService.getCallback().getBindings()))){
- for (Binding binding : promotedService.getCallback().getBindings()){
- try {
- newComponentService.getCallback().getBindings().add((Binding)binding.clone());
- } catch(CloneNotSupportedException ex){
- // this binding can't be used in the promoted service
- }
- }
- }
- }
-
- // Change the composite service to now promote the
- // newly created component service directly
- compositeService.setPromotedComponent(promotedComponent);
- compositeService.setPromotedService(newComponentService);
- }
- }
- }
- }
- }
- }
-
- /**
- * If the bindings are specified in the composite file return true as they should
- * otherwise return false
- *
- * @param bindings
- * @return true if the bindings were specified manually
- */
- private boolean bindingsSpecifiedManually(List<Binding> bindings){
-
- if (bindings.size() > 1){
- return true;
- } else if ((bindings.size() == 1) &&
- (bindings.get(0) instanceof AutomaticBinding) &&
- (((AutomaticBinding)bindings.get(0)).getIsAutomatic() == true )){
- return false;
- } else if (bindings.size() == 1) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
* @param composite
*/
private void configureSourcedProperties(Composite composite, List<ComponentProperty> propertySettings) {
@@ -1027,34 +830,6 @@ public abstract class BaseConfigurationBuilderImpl {
}
}
- /**
- * Follow a service promotion chain down to the inner most (non composite)
- * component.
- *
- * @param compositeService
- * @return
- */
- protected static Component getPromotedComponent(CompositeService compositeService) {
- ComponentService componentService = compositeService.getPromotedService();
- if (componentService != null) {
- Service service = componentService.getService();
- if (componentService.getName() != null && service instanceof CompositeService) {
-
- // Continue to follow the service promotion chain
- return getPromotedComponent((CompositeService)service);
-
- } else {
-
- // Found a non-composite service
- return compositeService.getPromotedComponent();
- }
- } else {
-
- // No promoted service
- return null;
- }
- }
-
private ComponentProperty getComponentPropertyByName(String propertyName, List<ComponentProperty> properties) {
if (properties != null) {
for (ComponentProperty aProperty : properties) {
@@ -1069,8 +844,8 @@ public abstract class BaseConfigurationBuilderImpl {
private SCABinding createSCABinding() {
SCABinding scaBinding = scaBindingFactory.createSCABinding();
- // mark the bindings that are added automatically so that theu can
- // can be disregarded for overriding purposes
+ // mark the bindings that are added automatically so that they can
+ // be disregarded for overriding purposes
if (scaBinding instanceof AutomaticBinding){
((AutomaticBinding)scaBinding).setIsAutomatic(true);
}
@@ -1087,6 +862,16 @@ public abstract class BaseConfigurationBuilderImpl {
}
/**
+ * Called by CompositeBindingURIBuilderImpl
+ *
+ * @param composite the composite to be configured
+ */
+ protected void configureBindingURIsAndNames(Composite composite) throws CompositeBuilderException {
+ configureBindingURIs(composite, null, null);
+ configureBindingNames(composite);
+ }
+
+ /**
* Fully resolve the binding URIs based on available information. This includes information
* from the ".composite" files, from resources associated with the binding, e.g. WSDL files,
* from any associated policies and from the default information for each binding type.
@@ -1103,7 +888,13 @@ public abstract class BaseConfigurationBuilderImpl {
* from the ".composite" files, from resources associated with the binding, e.g. WSDL files,
* from any associated policies and from the default information for each binding type.
*
- * TODO: Share the URL calculation algorithm with the configureComponents() method above
+ * NOTE: This method repeats some of the processing performed by the configureComponents()
+ * method above. The duplication is needed because NodeConfigurationServiceImpl
+ * calls this method without previously calling configureComponents(). In the
+ * normal builder sequence used by CompositeBuilderImpl, both of these methods
+ * are called.
+ *
+ * TODO: Share the URL calculation algorithm with the configureComponents() method above
* although keeping the configureComponents() methods signature as is because when
* a composite is actually build in a node the node default information is currently
* available
@@ -1204,23 +995,96 @@ public abstract class BaseConfigurationBuilderImpl {
}
}
}
+
+ /**
+ * Add default names for callback bindings and reference bindings. Needs to be
+ * separate from configureBindingURIs() because configureBindingURIs() is called
+ * by NodeConfigurationServiceImpl as well as by CompositeBuilderImpl.
+ */
+ private void configureBindingNames(Composite composite) {
+
+ // Process nested composites recursively
+ for (Component component : composite.getComponents()) {
+
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+
+ // Process nested composite
+ configureBindingNames((Composite)implementation);
+ }
+ }
+
+ // Initialize composite service callback binding names
+ for (Service service : composite.getServices()) {
+
+ if (service.getCallback() != null) {
+ for (Binding binding : service.getCallback().getBindings()) {
+ constructBindingName(service, binding);
+ }
+ }
+ }
+
+ // Initialize composite reference binding names
+ for (Reference reference : composite.getReferences()) {
+
+ for (Binding binding : reference.getBindings()) {
+ constructBindingName(reference, binding);
+ }
+
+ if (reference.getCallback() != null) {
+ for (Binding binding : reference.getCallback().getBindings()) {
+ constructBindingName(reference, binding);
+ }
+ }
+ }
+
+ // Initialize component service and reference binding names
+ for (Component component : composite.getComponents()) {
+
+ // Initialize component service callback binding names
+ for (ComponentService service : component.getServices()) {
+
+ if (service.getCallback() != null) {
+ for (Binding binding : service.getCallback().getBindings()) {
+ constructBindingName(service, binding);
+ }
+ }
+ }
+
+ // Initialize component reference binding names
+ for (ComponentReference reference : component.getReferences()) {
+
+ // Initialize binding names
+ for (Binding binding : reference.getBindings()) {
+ constructBindingName(reference, binding);
+ }
+
+ if (reference.getCallback() != null) {
+ for (Binding binding : reference.getCallback().getBindings()) {
+ constructBindingName(reference, binding);
+ }
+ }
+ }
+ }
+ }
/**
- * If a binding name is not provided by the user construct it based on the service name
+ * If a binding name is not provided by the user, construct it based on the service
+ * or reference name
*
- * @param service
+ * @param contract the service or reference
* @param binding
*/
- private void constructBindingName(Service service, Binding binding) throws CompositeBuilderException{
+ private void constructBindingName(Contract contract, Binding binding) {
// set the default binding name if one is required
- // if there is no name on the binding then set it to the service name
+ // if there is no name on the binding then set it to the service or reference name
if (binding.getName() == null){
- binding.setName(service.getName());
+ binding.setName(contract.getName());
}
// Check that multiple bindings do not have the same name
- for (Binding otherBinding : service.getBindings()) {
+ for (Binding otherBinding : contract.getBindings()) {
if (otherBinding == binding) {
// Skip the current binding
continue;
@@ -1230,7 +1094,8 @@ public abstract class BaseConfigurationBuilderImpl {
continue;
}
if (binding.getName().equals(otherBinding.getName())) {
- warning("MultipleBindingsForService", binding, service.getName(), binding.getName());
+ warning(contract instanceof Service ? "MultipleBindingsForService" : "MultipleBindingsForReference",
+ binding, contract.getName(), binding.getName());
}
}
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java
index 544240d07e..0c2d02ab48 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java
@@ -424,6 +424,7 @@ class BaseWireBuilderImpl {
endpoint.setTargetName(targetComponent.getName());
endpoint.setSourceComponent(null); // TODO - fixed up at start
endpoint.setSourceComponentReference(componentReference);
+ endpoint.setInterfaceContract(componentReference.getInterfaceContract());
endpoint.setTargetComponent(targetComponent);
endpoint.setTargetComponentService(targetComponentService);
endpoint.getCandidateBindings().addAll(componentReference.getBindings());
@@ -477,7 +478,8 @@ class BaseWireBuilderImpl {
Endpoint endpoint = endpointFactory.createEndpoint();
endpoint.setTargetName(targetComponent.getName());
endpoint.setSourceComponent(null); // TODO - fixed up at start
- endpoint.setSourceComponentReference(componentReference);
+ endpoint.setSourceComponentReference(componentReference);
+ endpoint.setInterfaceContract(componentReference.getInterfaceContract());
endpoint.setTargetComponent(targetComponent);
endpoint.setTargetComponentService(targetComponentService);
endpoint.getCandidateBindings().addAll(componentReference.getBindings());
@@ -498,7 +500,8 @@ class BaseWireBuilderImpl {
Endpoint endpoint = endpointFactory.createEndpoint();
endpoint.setTargetName(name);
endpoint.setSourceComponent(null); // TODO - fixed up at start
- endpoint.setSourceComponentReference(componentReference);
+ endpoint.setSourceComponentReference(componentReference);
+ endpoint.setInterfaceContract(componentReference.getInterfaceContract());
endpoint.getCandidateBindings().addAll(componentReference.getBindings());
endpoints.add(endpoint);
@@ -536,7 +539,8 @@ class BaseWireBuilderImpl {
Endpoint endpoint = endpointFactory.createEndpoint();
endpoint.setTargetName(targetComponent.getName());
endpoint.setSourceComponent(null); // TODO - fixed up at start
- endpoint.setSourceComponentReference(componentReference);
+ endpoint.setSourceComponentReference(componentReference);
+ endpoint.setInterfaceContract(componentReference.getInterfaceContract());
endpoint.setTargetComponent(targetComponent);
endpoint.setTargetComponentService(targetComponentService);
endpoint.getCandidateBindings().addAll(componentReference.getBindings());
@@ -560,7 +564,8 @@ class BaseWireBuilderImpl {
Endpoint endpoint = endpointFactory.createEndpoint();
endpoint.setTargetName(name);
endpoint.setSourceComponent(null); // TODO - fixed up at start
- endpoint.setSourceComponentReference(componentReference);
+ endpoint.setSourceComponentReference(componentReference);
+ endpoint.setInterfaceContract(componentReference.getInterfaceContract());
endpoint.getCandidateBindings().addAll(componentReference.getBindings());
endpoints.add(endpoint);
@@ -625,7 +630,8 @@ class BaseWireBuilderImpl {
Endpoint endpoint = endpointFactory.createEndpoint();
endpoint.setTargetName(targetComponent.getName());
endpoint.setSourceComponent(null); // TODO - fixed up at start
- endpoint.setSourceComponentReference(componentReference);
+ endpoint.setSourceComponentReference(componentReference);
+ endpoint.setInterfaceContract(componentReference.getInterfaceContract());
endpoint.setTargetComponent(targetComponent);
endpoint.setTargetComponentService(targetComponentService);
endpoint.getCandidateBindings().add(binding);
@@ -639,16 +645,14 @@ class BaseWireBuilderImpl {
}
} else {
- /* TODO - don't enable this yet as we have tests that
- use relative URIs in bindings that don't refer to
- targets
+ // create endpoints for manually configured bindings
Endpoint endpoint = endpointFactory.createEndpoint();
endpoint.setTargetName(uri);
endpoint.setSourceComponent(null); // TODO - fixed up at start
- endpoint.setSourceComponentReference(componentReference);
- endpoint.getCandidateBindings().add(binding);
+ endpoint.setSourceComponentReference(componentReference);
+ endpoint.setInterfaceContract(componentReference.getInterfaceContract());
+ endpoint.setSourceBinding(binding);
endpoints.add(endpoint);
- */
}
}
}
@@ -679,8 +683,16 @@ class BaseWireBuilderImpl {
componentReference.getEndpoints().addAll(endpoints);
+ // the result of calculating the endpoints is either that bindings have been
+ // configured manually using a URI or that targets have been provided and the
+ // endpoint remains unresolved. So all endpoints should be either resved or uresolved.
+ boolean endpointsRequireAutomaticResolution = false;
+ for(Endpoint endpoint : endpoints){
+ endpointsRequireAutomaticResolution = endpoint.isUnresolved();
+ }
+
// build each endpoint
- if (!endpoints.isEmpty()) {
+ if (endpointsRequireAutomaticResolution) {
for(Endpoint endpoint : endpoints){
endpointBuilder.build(endpoint);
@@ -939,218 +951,6 @@ class BaseWireBuilderImpl {
// Clear the list of wires
composite.getWires().clear();
}
-
- /**
- * Wire composite references in nested composites.
- *
- * @param composite
- * @param problems
- */
- protected void wireCompositeReferences(Composite composite) {
-
- // Process nested composites recursively
- for (Component component : composite.getComponents()) {
- Implementation implementation = component.getImplementation();
- if (implementation instanceof Composite) {
- wireCompositeReferences((Composite)implementation);
- }
- }
-
- // Process composite references declared in this composite
- for (Reference reference : composite.getReferences()) {
- CompositeReference compositeReference = (CompositeReference)reference;
- List<ComponentReference> promotedReferences = getPromotedComponentReferences(compositeReference);
- for (ComponentReference promotedReference : promotedReferences) {
-
- reconcileReferenceBindings(compositeReference, promotedReference);
- if (compositeReference.getInterfaceContract() != null && // can be null in unit tests
- compositeReference.getInterfaceContract().getCallbackInterface() != null) {
- SCABinding scaCallbackBinding = promotedReference.getCallbackBinding(SCABinding.class);
- if (promotedReference.getCallback() != null) {
- promotedReference.getCallback().getBindings().clear();
- } else {
- promotedReference.setCallback(assemblyFactory.createCallback());
- }
- if (scaCallbackBinding != null) {
- promotedReference.getCallback().getBindings().add(scaCallbackBinding);
- }
- if (compositeReference.getCallback() != null) {
- promotedReference.getCallback().getBindings().addAll(compositeReference.getCallback()
- .getBindings());
- }
- }
- }
- }
-
- // Process the component references declared on components
- // in this composite
- for (Component component : composite.getComponents()) {
- Implementation implementation = component.getImplementation();
- if (implementation instanceof Composite) {
- for (ComponentReference componentReference : component.getReferences()) {
- Reference implReference = componentReference.getReference();
- if (implReference != null && implReference instanceof CompositeReference) {
- CompositeReference compositeReference = (CompositeReference)implReference;
- List<ComponentReference> promotedReferences =
- getPromotedComponentReferences(compositeReference);
- for (ComponentReference promotedReference : promotedReferences) {
-
- // Override the configuration of the promoted reference
- reconcileReferenceBindings(componentReference, promotedReference);
- if (componentReference.getInterfaceContract() != null && // can be null in unit tests
- componentReference.getInterfaceContract().getCallbackInterface() != null) {
- SCABinding scaCallbackBinding = promotedReference.getCallbackBinding(SCABinding.class);
- if (promotedReference.getCallback() != null) {
- promotedReference.getCallback().getBindings().clear();
- } else {
- promotedReference.setCallback(assemblyFactory.createCallback());
- }
- if (scaCallbackBinding != null) {
- promotedReference.getCallback().getBindings().add(scaCallbackBinding);
- }
- if (componentReference.getCallback() != null) {
- promotedReference.getCallback().getBindings().addAll(componentReference
- .getCallback().getBindings());
- }
- }
-
- // Wire the promoted reference to the actual
- // non-composite component services
- if (promotedReference.getMultiplicity() == Multiplicity.ONE_ONE || promotedReference
- .getMultiplicity() == Multiplicity.ONE_ONE) {
- // promotedReference.getTargets().clear();
- }
- for (ComponentService target : componentReference.getTargets()) {
- if (target.getService() instanceof CompositeService) {
-
- // Wire to the actual component service
- // promoted by a composite service
- CompositeService compositeService = (CompositeService)target.getService();
- // Find the promoted component service
- ComponentService componentService = ServiceConfigurationUtil.getPromotedComponentService(compositeService);
- if (componentService != null) {
- promotedReference.getTargets().add(componentService);
- }
- } else {
-
- // Wire to a non-composite target service
- promotedReference.getTargets().add(target);
- }
- }
- }
- }
- }
- } else {
- for (ComponentReference componentReference : component.getReferences()) {
-
- // Wire the component reference to the actual
- // non-composite component services
- List<ComponentService> targets = componentReference.getTargets();
- for (int i = 0, n = targets.size(); i < n; i++) {
- ComponentService target = targets.get(i);
- if (target.getService() instanceof CompositeService) {
-
- // Wire to the actual component service
- // promoted by a composite service
- CompositeService compositeService = (CompositeService)target.getService();
- ComponentService componentService = compositeService.getPromotedService();
- if (componentService != null) {
- targets.set(i, componentService);
- }
- }
- }
- }
- }
- }
- }
-
- /**
- * Follow a reference promotion chain down to the inner most (non composite)
- * component references.
- *
- * @param compositeReference
- * @return
- */
- private List<ComponentReference> getPromotedComponentReferences(CompositeReference compositeReference) {
- List<ComponentReference> componentReferences = new ArrayList<ComponentReference>();
- collectPromotedComponentReferences(compositeReference, componentReferences);
- return componentReferences;
- }
-
- /**
- * Follow a reference promotion chain down to the inner most (non composite)
- * component references.
- *
- * @param compositeReference
- * @param componentReferences
- * @return
- */
- private void collectPromotedComponentReferences(CompositeReference compositeReference,
- List<ComponentReference> componentReferences) {
- for (ComponentReference componentReference : compositeReference.getPromotedReferences()) {
- Reference reference = componentReference.getReference();
- if (reference instanceof CompositeReference) {
-
- // Continue to follow the reference promotion chain
- collectPromotedComponentReferences((CompositeReference)reference, componentReferences);
-
- } else if (reference != null) {
-
- // Found a non-composite reference
- componentReferences.add(componentReference);
- }
- }
- }
-
- /**
- * Override the bindings for a promoted reference from an outer component
- * reference
- *
- * @param reference
- * @param promotedReference
- */
- private void reconcileReferenceBindings(Reference reference, ComponentReference promotedReference) {
- List<Binding> bindings = new ArrayList<Binding>();
-
- // collect the top level bindings first
- for (Binding binding : reference.getBindings()) {
- if ((!(binding instanceof OptimizableBinding)) || binding.getURI() != null) {
- bindings.add(binding);
- }
- }
-
- // if there are not top level bindings to override the promoted bindings
- // then collect the promoted bindings
- if (bindings.size() == 0){
- for (Binding binding : promotedReference.getBindings()) {
- if ((!(binding instanceof OptimizableBinding)) || binding.getURI() != null) {
- bindings.add(binding);
- }
- }
- }
-
- promotedReference.getBindings().clear();
- promotedReference.getBindings().addAll(bindings);
-
- if (promotedReference.getMultiplicity() == Multiplicity.ONE_ONE || promotedReference.getMultiplicity() == Multiplicity.ZERO_ONE) {
- if (promotedReference.getBindings().size() > 1) {
- warning("ComponentReferenceMoreWire", promotedReference, promotedReference.getName());
- }
- }
- Set<Binding> callbackBindings = new HashSet<Binding>();
- if (promotedReference.getCallback() != null) {
- callbackBindings.addAll(promotedReference.getCallback().getBindings());
- }
- if (reference.getCallback() != null) {
- callbackBindings.addAll(reference.getCallback().getBindings());
- }
- promotedReference.setCallback(assemblyFactory.createCallback());
- for (Binding binding : callbackBindings) {
- if ((!(binding instanceof OptimizableBinding)) || binding.getURI() != null) {
- promotedReference.getCallback().getBindings().add(binding);
- }
- }
- }
private void addPoliciesFromPromotedService(CompositeService compositeService) {
//inherit intents and policies from promoted service
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java
index dc0628a54f..4913705e91 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java
@@ -47,16 +47,8 @@ public class ComponentReferenceBindingBuilderImpl implements CompositeBuilder {
}
private void buildReferenceBindings(Composite composite) {
-
- // build bindings recursively
- for (Component component : composite.getComponents()) {
- Implementation implementation = component.getImplementation();
- if (implementation instanceof Composite) {
- buildReferenceBindings((Composite)implementation);
- }
- }
- // find all the component reference bindings
+ // find all the component reference bindings (starting at top level)
for (Component component : composite.getComponents()) {
for (ComponentReference componentReference : component.getReferences()) {
for (Binding binding : componentReference.getBindings()) {
@@ -66,6 +58,14 @@ public class ComponentReferenceBindingBuilderImpl implements CompositeBuilder {
}
}
}
+
+ // build bindings recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ buildReferenceBindings((Composite)implementation);
+ }
+ }
}
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionWireBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionWireBuilderImpl.java
new file mode 100644
index 0000000000..c0702c87b3
--- /dev/null
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionWireBuilderImpl.java
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.builder.impl;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.EndpointFactory;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A composite builder that handles the creation of promoted composite services.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentReferencePromotionWireBuilderImpl implements CompositeBuilder {
+ private AssemblyFactory assemblyFactory;
+ private EndpointFactory endpointFactory;
+ private Monitor monitor;
+
+ public ComponentReferencePromotionWireBuilderImpl(AssemblyFactory assemblyFactory, EndpointFactory endpointFactory, Monitor monitor) {
+ this.assemblyFactory = assemblyFactory;
+ this.endpointFactory = endpointFactory;
+ this.monitor = monitor;
+ }
+
+ public void build(Composite composite) throws CompositeBuilderException {
+ wireCompositeReferences(composite);
+ }
+
+ /**
+ * Wire composite references in nested composites.
+ *
+ * @param composite
+ * @param problems
+ */
+ private void wireCompositeReferences(Composite composite) {
+
+ // Process nested composites recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ wireCompositeReferences((Composite)implementation);
+ }
+ }
+
+ // Process component references declared on components in this composite
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ for (ComponentReference componentReference : component.getReferences()) {
+ Reference implReference = componentReference.getReference();
+ if (implReference != null && implReference instanceof CompositeReference) {
+
+ // If the component reference is wired, it is a promotion override
+ if (!componentReference.getEndpoints().isEmpty()) {
+ componentReference.setPromotionOverride(true);
+ }
+
+ // If the component reference is a promotion override, override the
+ // configuration of the promoted reference
+ if (componentReference.isPromotionOverride()) {
+ CompositeReference compositeReference = (CompositeReference)implReference;
+ List<ComponentReference> promotedReferences =
+ ReferenceConfigurationUtil.getPromotedComponentReferences(compositeReference);
+ for (ComponentReference promotedReference : promotedReferences) {
+ ReferenceConfigurationUtil.reconcileReferenceBindings(
+ componentReference, promotedReference, assemblyFactory, endpointFactory, monitor);
+ if (componentReference.getInterfaceContract() != null && // can be null in unit tests
+ componentReference.getInterfaceContract().getCallbackInterface() != null) {
+ SCABinding scaCallbackBinding = promotedReference.getCallbackBinding(SCABinding.class);
+ if (promotedReference.getCallback() != null) {
+ promotedReference.getCallback().getBindings().clear();
+ } else {
+ promotedReference.setCallback(assemblyFactory.createCallback());
+ }
+ if (scaCallbackBinding != null) {
+ promotedReference.getCallback().getBindings().add(scaCallbackBinding);
+ }
+ if (componentReference.getCallback() != null) {
+ promotedReference.getCallback().getBindings().addAll(componentReference
+ .getCallback().getBindings());
+ }
+ }
+
+ // Wire the promoted reference to the actual non-composite component services
+ if (promotedReference.getMultiplicity() == Multiplicity.ONE_ONE) {
+ // promotedReference.getTargets().clear();
+ }
+ for (ComponentService target : componentReference.getTargets()) {
+ if (target.getService() instanceof CompositeService) {
+
+ // Wire to the actual component service
+ // promoted by a composite service
+ CompositeService compositeService = (CompositeService)target.getService();
+ // Find the promoted component service
+ ComponentService componentService =
+ ServiceConfigurationUtil.getPromotedComponentService(compositeService);
+ if (componentService != null) {
+ promotedReference.getTargets().add(componentService);
+ }
+ } else {
+
+ // Wire to a non-composite target service
+ promotedReference.getTargets().add(target);
+ }
+ }
+ }
+ }
+ }
+ }
+ } else {
+ for (ComponentReference componentReference : component.getReferences()) {
+
+ // Wire the component reference to the actual
+ // non-composite component services
+ List<ComponentService> targets = componentReference.getTargets();
+ for (int i = 0, n = targets.size(); i < n; i++) {
+ ComponentService target = targets.get(i);
+ if (target.getService() instanceof CompositeService) {
+
+ // Wire to the actual component service
+ // promoted by a composite service
+ CompositeService compositeService = (CompositeService)target.getService();
+ ComponentService componentService = compositeService.getPromotedService();
+ if (componentService != null) {
+ targets.set(i, componentService);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServicePromotionBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServicePromotionBuilderImpl.java
new file mode 100644
index 0000000000..53e6eda1eb
--- /dev/null
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServicePromotionBuilderImpl.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.builder.impl;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+
+/**
+ * A composite builder that handles the creation of promoted services.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentServicePromotionBuilderImpl implements CompositeBuilder {
+ private AssemblyFactory assemblyFactory;
+
+ public ComponentServicePromotionBuilderImpl(AssemblyFactory assemblyFactory) {
+ this.assemblyFactory = assemblyFactory;
+ }
+
+ public void build(Composite composite) throws CompositeBuilderException {
+
+ // Process nested composites recursively
+ configureNestedCompositeServices(composite);
+ }
+
+ private void configureNestedCompositeServices(Composite composite) {
+
+ // Process nested composites recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+
+ // First process nested composites
+ configureNestedCompositeServices((Composite)implementation);
+
+ // Process the component services declared on components in this composite
+ for (ComponentService componentService : component.getServices()) {
+ Service implService = componentService.getService();
+ if (implService != null && implService instanceof CompositeService) {
+ CompositeService compositeService = (CompositeService)implService;
+
+ // Get the innermost promoted service
+ ComponentService promotedService =
+ ServiceConfigurationUtil.getPromotedComponentService(compositeService);
+ if (promotedService != null) {
+ Component promotedComponent = ServiceConfigurationUtil.getPromotedComponent(compositeService);
+
+ // Create a new component service to represent this
+ // component service on the promoted component
+ ComponentService newComponentService = assemblyFactory.createComponentService();
+ newComponentService.setName("$promoted$." + component.getName() + "." + componentService.getName());
+ promotedComponent.getServices().add(newComponentService);
+ newComponentService.setService(promotedService.getService());
+ newComponentService.getBindings().addAll(componentService.getBindings());
+ newComponentService.setInterfaceContract(componentService.getInterfaceContract());
+
+ if (componentService.getInterfaceContract() != null &&
+ componentService.getInterfaceContract().getCallbackInterface() != null) {
+ newComponentService.setCallback(assemblyFactory.createCallback());
+ newComponentService.getCallback().getBindings()
+ .addAll(componentService.getCallback().getBindings());
+ }
+
+ // Change the composite service to now promote the
+ // newly created component service directly
+ compositeService.setPromotedComponent(promotedComponent);
+ compositeService.setPromotedService(newComponentService);
+ }
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java
new file mode 100644
index 0000000000..4c2c369f3e
--- /dev/null
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.builder.impl;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.definitions.SCADefinitions;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A composite builder that handles the configuration of binding URIs.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeBindingURIBuilderImpl extends BaseConfigurationBuilderImpl implements CompositeBuilder {
+
+ public CompositeBindingURIBuilderImpl(AssemblyFactory assemblyFactory,
+ SCABindingFactory scaBindingFactory,
+ InterfaceContractMapper interfaceContractMapper,
+ SCADefinitions policyDefinitions,
+ Monitor monitor) {
+ super(assemblyFactory, scaBindingFactory, interfaceContractMapper, policyDefinitions, monitor);
+ }
+
+ public void build(Composite composite) throws CompositeBuilderException {
+ configureBindingURIsAndNames(composite);
+ }
+
+}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
index dd80312b4b..6fc946b29a 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
@@ -42,15 +42,19 @@ import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
public class CompositeBuilderImpl implements CompositeBuilder {
private static final Logger logger = Logger.getLogger(CompositeBuilderImpl.class.getName());
private CompositeBuilder compositeIncludeBuilder;
- private CompositeBuilder componentWireBuilder;
+ private CompositeBuilder componentReferenceWireBuilder;
+ private CompositeBuilder componentReferencePromotionWireBuilder;
private CompositeBuilder compositeReferenceWireBuilder;
private CompositeBuilder compositeCloneBuilder;
private CompositeBuilder componentConfigurationBuilder;
private CompositeBuilder compositeServiceConfigurationBuilder;
+ private CompositeBuilder compositeReferenceConfigurationBuilder;
+ private CompositeBuilder compositeBindingURIBuilder;
+ private CompositeBuilder componentServicePromotionBuilder;
+ private CompositeBuilder compositeServicePromotionBuilder;
private CompositeBuilder compositePromotionBuilder;
private CompositeBuilder compositePolicyBuilder;
private CompositeBuilder componentServiceBindingBuilder;
- private CompositeBuilder compositeServiceBindingBuilder;
private CompositeBuilder componentReferenceBindingBuilder;
/**
@@ -94,15 +98,19 @@ public class CompositeBuilderImpl implements CompositeBuilder {
}
compositeIncludeBuilder = new CompositeIncludeBuilderImpl(monitor);
- componentWireBuilder = new ComponentReferenceWireBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper, monitor);
- compositeReferenceWireBuilder = new CompositeReferenceWireBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper, monitor);
+ componentReferenceWireBuilder = new ComponentReferenceWireBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper, monitor);
+ componentReferencePromotionWireBuilder = new ComponentReferencePromotionWireBuilderImpl(assemblyFactory, endpointFactory, monitor);
+ compositeReferenceWireBuilder = new CompositeReferenceWireBuilderImpl(assemblyFactory, endpointFactory, monitor);
compositeCloneBuilder = new CompositeCloneBuilderImpl(monitor);
componentConfigurationBuilder = new ComponentConfigurationBuilderImpl(assemblyFactory, scaBindingFactory, interfaceContractMapper, policyDefinitions, monitor);
- compositeServiceConfigurationBuilder = new CompositeServiceConfigurationBuilderImpl(assemblyFactory, scaBindingFactory, interfaceContractMapper, policyDefinitions, monitor);
+ compositeServiceConfigurationBuilder = new CompositeServiceConfigurationBuilderImpl(assemblyFactory);
+ compositeReferenceConfigurationBuilder = new CompositeReferenceConfigurationBuilderImpl(assemblyFactory);
+ compositeBindingURIBuilder = new CompositeBindingURIBuilderImpl(assemblyFactory, scaBindingFactory, interfaceContractMapper, policyDefinitions, monitor);
+ componentServicePromotionBuilder = new ComponentServicePromotionBuilderImpl(assemblyFactory);
+ compositeServicePromotionBuilder = new CompositeServicePromotionBuilderImpl(assemblyFactory);
compositePromotionBuilder = new CompositePromotionBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper, monitor);
compositePolicyBuilder = new CompositePolicyBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper, monitor);
componentServiceBindingBuilder = new ComponentServiceBindingBuilderImpl(monitor);
- compositeServiceBindingBuilder = new CompositeServiceBindingBuilderImpl(monitor);
componentReferenceBindingBuilder = new ComponentReferenceBindingBuilderImpl(monitor);
}
@@ -119,28 +127,40 @@ public class CompositeBuilderImpl implements CompositeBuilder {
// Connect composite services/references to promoted services/references
compositePromotionBuilder.build(composite);
-
+
// Compute the policies across the model hierarchy
compositePolicyBuilder.build(composite);
- // Build component service binding-related information
- componentServiceBindingBuilder.build(composite);
-
- // Build composite service binding-related information
- compositeServiceBindingBuilder.build(composite);
-
// Configure composite services
compositeServiceConfigurationBuilder.build(composite);
+ // Configure composite references
+ compositeReferenceConfigurationBuilder.build(composite);
+
+ // Configure binding URIs
+ compositeBindingURIBuilder.build(composite);
+
+ // Create promoted component services
+ componentServicePromotionBuilder.build(composite);
+
+ // Create promoted composite services
+ compositeServicePromotionBuilder.build(composite);
+
+ // Build component service binding-related information
+ componentServiceBindingBuilder.build(composite);
+
// Wire the components
- componentWireBuilder.build(composite);
+ componentReferenceWireBuilder.build(composite);
+
+ // Wire the promoted component references
+ componentReferencePromotionWireBuilder.build(composite);
// Wire the composite references
compositeReferenceWireBuilder.build(composite);
// Build component reference binding-related information
componentReferenceBindingBuilder.build(composite);
-
+
// Fuse nested composites
//FIXME do this later
//cloneBuilder.fuseCompositeImplementations(composite);
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.java
new file mode 100644
index 0000000000..41462b151d
--- /dev/null
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.java
@@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.builder.impl;
+
+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;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.builder.AutomaticBinding;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+
+/**
+ * A composite builder that handles the configuration of composite references.
+ *
+ * @version $Rev: 651179 $ $Date: 2008-04-24 08:21:13 +0100 (Thu, 24 Apr 2008) $
+ */
+public class CompositeReferenceConfigurationBuilderImpl implements CompositeBuilder {
+ private AssemblyFactory assemblyFactory;
+
+ public CompositeReferenceConfigurationBuilderImpl(AssemblyFactory assemblyFactory) {
+ this.assemblyFactory = assemblyFactory;
+ }
+
+ public void build(Composite composite) throws CompositeBuilderException {
+
+ // Process nested composites recursively
+ configureNestedCompositeReferences(composite);
+
+ // Process top level composite references
+ for (Reference reference : composite.getReferences()) {
+ CompositeReference compositeReference = (CompositeReference)reference;
+
+ // Get the next lower level promoted reference
+ List<ComponentReference> promotedRefs = compositeReference.getPromotedReferences();
+ if (!promotedRefs.isEmpty()) {
+ if (promotedRefs.size() == 1) {
+ ComponentReference promotedReference = promotedRefs.get(0);
+
+ // Set the bindings using the top level bindings to override the lower level bindings
+ if (bindingsSpecifiedManually(compositeReference.getBindings())) {
+ compositeReference.setPromotionOverride(true);
+ } else if (bindingsSpecifiedManually(promotedReference.getBindings()) ) {
+ compositeReference.getBindings().clear();
+ for (Binding binding : promotedReference.getBindings()) {
+ try {
+ compositeReference.getBindings().add((Binding)binding.clone());
+ } catch (CloneNotSupportedException ex) {
+ // this binding can't be used in the promoted reference
+ }
+ }
+ }
+ if (compositeReference.getInterfaceContract() != null &&
+ compositeReference.getInterfaceContract().getCallbackInterface() != null) {
+ if (compositeReference.getCallback() != null &&
+ bindingsSpecifiedManually(compositeReference.getCallback().getBindings())) {
+ compositeReference.setPromotionOverride(true);
+ } else if (promotedReference.getCallback() != null &&
+ bindingsSpecifiedManually(promotedReference.getCallback().getBindings())) {
+ if (compositeReference.getCallback() != null) {
+ compositeReference.getCallback().getBindings().clear();
+ } else {
+ compositeReference.setCallback(assemblyFactory.createCallback());
+ }
+ for (Binding binding : promotedReference.getCallback().getBindings()) {
+ try {
+ compositeReference.getCallback().getBindings().add((Binding)binding.clone());
+ } catch (CloneNotSupportedException ex) {
+ // this binding can't be used in the promoted reference
+ }
+ }
+ }
+ }
+ } else {
+ // This composite reference promotes multiple component references.
+ // Because the component reference bindings can all be different, we don't
+ // copy any of them up to this composite reference, which will therefore always
+ // have its own binding, even if it's only the default SCA binding.
+ if (bindingsSpecifiedManually(compositeReference.getBindings()) ||
+ (compositeReference.getCallback() != null &&
+ bindingsSpecifiedManually(compositeReference.getCallback().getBindings()))) {
+ compositeReference.setPromotionOverride(true);
+ }
+ }
+ }
+ }
+ }
+
+ private void configureNestedCompositeReferences(Composite composite) {
+
+ // Process nested composites recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+
+ // First process nested composites
+ configureNestedCompositeReferences((Composite)implementation);
+
+ // Process the component references declared on components in this composite
+ for (ComponentReference componentReference : component.getReferences()) {
+ Reference implReference = componentReference.getReference();
+ if (implReference != null && implReference instanceof CompositeReference) {
+ CompositeReference compositeReference = (CompositeReference)implReference;
+
+ // Get the next lower level promoted reference
+ List<ComponentReference> promotedRefs = compositeReference.getPromotedReferences();
+ if (!promotedRefs.isEmpty()) {
+ if (promotedRefs.size() == 1) {
+ ComponentReference promotedReference = promotedRefs.get(0);
+
+ // Set the bindings using the top level bindings to override the lower level bindings
+ if (!bindingsSpecifiedManually(compositeReference.getBindings()) &&
+ bindingsSpecifiedManually(promotedReference.getBindings()) ) {
+ compositeReference.getBindings().clear();
+ for (Binding binding : promotedReference.getBindings()) {
+ try {
+ compositeReference.getBindings().add((Binding)binding.clone());
+ } catch (CloneNotSupportedException ex) {
+ // this binding can't be used in the promoted reference
+ }
+ }
+ }
+ if (bindingsSpecifiedManually(componentReference.getBindings())) {
+ componentReference.setPromotionOverride(true);
+ } else if (bindingsSpecifiedManually(compositeReference.getBindings()) ) {
+ componentReference.getBindings().clear();
+ componentReference.getBindings().addAll(compositeReference.getBindings());
+ }
+ if (componentReference.getInterfaceContract() != null &&
+ componentReference.getInterfaceContract().getCallbackInterface() != null) {
+ if (!(compositeReference.getCallback() != null &&
+ bindingsSpecifiedManually(compositeReference.getCallback().getBindings())) &&
+ promotedReference.getCallback() != null &&
+ bindingsSpecifiedManually(promotedReference.getCallback().getBindings())) {
+ if (compositeReference.getCallback() != null) {
+ compositeReference.getCallback().getBindings().clear();
+ } else {
+ compositeReference.setCallback(assemblyFactory.createCallback());
+ }
+ compositeReference.getCallback().getBindings().addAll(
+ promotedReference.getCallback().getBindings());
+ }
+ if (componentReference.getCallback() != null &&
+ bindingsSpecifiedManually(componentReference.getCallback().getBindings())) {
+ componentReference.setPromotionOverride(true);
+ } else if (compositeReference.getCallback() != null &&
+ bindingsSpecifiedManually(compositeReference.getCallback().getBindings())) {
+ if (componentReference.getCallback() != null) {
+ componentReference.getCallback().getBindings().clear();
+ } else {
+ componentReference.setCallback(assemblyFactory.createCallback());
+ }
+ for (Binding binding : compositeReference.getCallback().getBindings()) {
+ try {
+ componentReference.getCallback().getBindings().add((Binding)binding.clone());
+ } catch (CloneNotSupportedException ex) {
+ // this binding can't be used in the promoted reference
+ }
+ }
+ }
+ }
+ } else {
+ // This component reference promotes multiple lower-level component references.
+ // Because the lower-level component reference bindings can all be different,
+ // we don't copy any of them up to this component reference, which will therefore
+ // always have its own binding, even if it's only the default SCA binding.
+ if (bindingsSpecifiedManually(componentReference.getBindings()) ||
+ (componentReference.getCallback() != null &&
+ bindingsSpecifiedManually(componentReference.getCallback().getBindings()))) {
+ componentReference.setPromotionOverride(true);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * If the bindings are specified in the composite file return true as they should
+ * otherwise return false
+ *
+ * @param bindings
+ * @return true if the bindings were specified manually
+ */
+ private boolean bindingsSpecifiedManually(List<Binding> bindings) {
+
+ if (bindings.size() > 1) {
+ return true;
+ } else if (bindings.size() == 1 &&
+ bindings.get(0) instanceof AutomaticBinding &&
+ ((AutomaticBinding)bindings.get(0)).getIsAutomatic()) {
+ return false;
+ } else if (bindings.size() == 1) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java
index 56b3fc79dd..8aa1897311 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java
@@ -19,12 +19,19 @@
package org.apache.tuscany.sca.assembly.builder.impl;
+import java.util.List;
+
import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeReference;
import org.apache.tuscany.sca.assembly.EndpointFactory;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.SCABinding;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
-import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.monitor.Monitor;
/**
@@ -32,13 +39,58 @@ import org.apache.tuscany.sca.monitor.Monitor;
*
* @version $Rev$ $Date$
*/
-public class CompositeReferenceWireBuilderImpl extends BaseWireBuilderImpl implements CompositeBuilder {
+public class CompositeReferenceWireBuilderImpl implements CompositeBuilder {
+ private AssemblyFactory assemblyFactory;
+ private EndpointFactory endpointFactory;
+ private Monitor monitor;
- public CompositeReferenceWireBuilderImpl(AssemblyFactory assemblyFactory, EndpointFactory endpointFactory, InterfaceContractMapper interfaceContractMapper, Monitor monitor) {
- super(assemblyFactory, endpointFactory, interfaceContractMapper, monitor);
+ public CompositeReferenceWireBuilderImpl(AssemblyFactory assemblyFactory, EndpointFactory endpointFactory, Monitor monitor) {
+ this.assemblyFactory = assemblyFactory;
+ this.endpointFactory = endpointFactory;
+ this.monitor = monitor;
}
+ /**
+ * Wire composite references in a deployment composite.
+ *
+ * @param composite
+ */
public void build(Composite composite) throws CompositeBuilderException {
- wireCompositeReferences(composite);
+
+ // Process composite references declared in this composite
+ for (Reference reference : composite.getReferences()) {
+ CompositeReference compositeReference = (CompositeReference)reference;
+
+ // If the composite reference is a promotion override, override the
+ // configuration of the promoted reference.
+ //FIXME: Policy configuration or wiring of domain-level composite references
+ // doesn't cause a promotion override, unless the composite reference has
+ // additional bindings. Do we need to detect this and force an override?
+ if (compositeReference.isPromotionOverride()) {
+ List<ComponentReference> promotedReferences =
+ ReferenceConfigurationUtil.getPromotedComponentReferences(compositeReference);
+ for (ComponentReference promotedReference : promotedReferences) {
+ ReferenceConfigurationUtil.reconcileReferenceBindings(
+ compositeReference, promotedReference, assemblyFactory, endpointFactory, monitor);
+ if (compositeReference.getInterfaceContract() != null && // can be null in unit tests
+ compositeReference.getInterfaceContract().getCallbackInterface() != null) {
+ SCABinding scaCallbackBinding = promotedReference.getCallbackBinding(SCABinding.class);
+ if (promotedReference.getCallback() != null) {
+ promotedReference.getCallback().getBindings().clear();
+ } else {
+ promotedReference.setCallback(assemblyFactory.createCallback());
+ }
+ if (scaCallbackBinding != null) {
+ promotedReference.getCallback().getBindings().add(scaCallbackBinding);
+ }
+ if (compositeReference.getCallback() != null) {
+ promotedReference.getCallback().getBindings().addAll(compositeReference.getCallback()
+ .getBindings());
+ }
+ }
+ }
+ }
+ }
}
+
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceBindingBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceBindingBuilderImpl.java
index 3842fee909..3aa9f3bf85 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceBindingBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceBindingBuilderImpl.java
@@ -61,7 +61,7 @@ public class CompositeServiceBindingBuilderImpl implements CompositeBuilder {
for (Service service : composite.getServices()) {
for (Binding binding : service.getBindings()) {
if (binding instanceof BindingBuilderExtension) {
- Component component = BaseConfigurationBuilderImpl.getPromotedComponent((CompositeService)service);
+ Component component = ServiceConfigurationUtil.getPromotedComponent((CompositeService)service);
((BindingBuilderExtension)binding).getBuilder().build(component, service, binding, monitor);
}
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java
index 7303570ac8..a3f31ea2fa 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java
@@ -19,32 +19,176 @@
package org.apache.tuscany.sca.assembly.builder.impl;
+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;
+import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.builder.AutomaticBinding;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
-import org.apache.tuscany.sca.definitions.SCADefinitions;
-import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
-import org.apache.tuscany.sca.monitor.Monitor;
/**
* A composite builder that handles the configuration of composite services.
*
* @version $Rev$ $Date$
*/
-public class CompositeServiceConfigurationBuilderImpl extends BaseConfigurationBuilderImpl implements CompositeBuilder {
-
- public CompositeServiceConfigurationBuilderImpl(AssemblyFactory assemblyFactory,
- SCABindingFactory scaBindingFactory,
- InterfaceContractMapper interfaceContractMapper,
- SCADefinitions policyDefinitions,
- Monitor monitor) {
- super(assemblyFactory, scaBindingFactory, interfaceContractMapper, policyDefinitions, monitor);
+public class CompositeServiceConfigurationBuilderImpl implements CompositeBuilder {
+ private AssemblyFactory assemblyFactory;
+
+ public CompositeServiceConfigurationBuilderImpl(AssemblyFactory assemblyFactory) {
+ this.assemblyFactory = assemblyFactory;
}
public void build(Composite composite) throws CompositeBuilderException {
- configureCompositeServices(composite);
+
+ // Process nested composites recursively
+ configureNestedCompositeServices(composite);
+
+ // Process top level composite services
+ for (Service service : composite.getServices()) {
+ CompositeService compositeService = (CompositeService)service;
+
+ // Get the next lower level promoted service
+ ComponentService promotedService = compositeService.getPromotedService();
+ if (promotedService != null) {
+
+ // Set the bindings using the top level bindings to override the lower level bindings
+ if (!bindingsSpecifiedManually(compositeService.getBindings()) &&
+ bindingsSpecifiedManually(promotedService.getBindings())) {
+ compositeService.getBindings().clear();
+ for (Binding binding : promotedService.getBindings()) {
+ try {
+ compositeService.getBindings().add((Binding)binding.clone());
+ } catch (CloneNotSupportedException ex) {
+ // this binding can't be used in the promoted service
+ }
+ }
+ }
+ if (compositeService.getInterfaceContract() != null &&
+ compositeService.getInterfaceContract().getCallbackInterface() != null) {
+ if (!(compositeService.getCallback() != null &&
+ bindingsSpecifiedManually(compositeService.getCallback().getBindings())) &&
+ promotedService.getCallback() != null &&
+ bindingsSpecifiedManually(promotedService.getCallback().getBindings())) {
+ if (compositeService.getCallback() != null) {
+ compositeService.getCallback().getBindings().clear();
+ } else {
+ compositeService.setCallback(assemblyFactory.createCallback());
+ }
+ for (Binding binding : promotedService.getCallback().getBindings()) {
+ try {
+ compositeService.getCallback().getBindings().add((Binding)binding.clone());
+ } catch (CloneNotSupportedException ex) {
+ // this binding can't be used in the promoted service
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void configureNestedCompositeServices(Composite composite) {
+
+ // Process nested composites recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+
+ // First process nested composites
+ configureNestedCompositeServices((Composite)implementation);
+
+ // Process the component services declared on components in this composite
+ for (ComponentService componentService : component.getServices()) {
+ Service implService = componentService.getService();
+ if (implService != null && implService instanceof CompositeService) {
+ CompositeService compositeService = (CompositeService)implService;
+
+ // Get the next lower level promoted service
+ ComponentService promotedService = compositeService.getPromotedService();
+ if (promotedService != null) {
+
+ // Set the bindings using the top level bindings to override the lower level bindings
+ if (!bindingsSpecifiedManually(compositeService.getBindings()) &&
+ bindingsSpecifiedManually(promotedService.getBindings()) ) {
+ compositeService.getBindings().clear();
+ for (Binding binding : promotedService.getBindings()) {
+ try {
+ compositeService.getBindings().add((Binding)binding.clone());
+ } catch (CloneNotSupportedException ex) {
+ // this binding can't be used in the promoted service
+ }
+ }
+ }
+ if (!bindingsSpecifiedManually(componentService.getBindings()) &&
+ bindingsSpecifiedManually(compositeService.getBindings()) ) {
+ componentService.getBindings().clear();
+ componentService.getBindings().addAll(compositeService.getBindings());
+ }
+ if (componentService.getInterfaceContract() != null &&
+ componentService.getInterfaceContract().getCallbackInterface() != null) {
+ if (!(compositeService.getCallback() != null &&
+ bindingsSpecifiedManually(compositeService.getCallback().getBindings())) &&
+ promotedService.getCallback() != null &&
+ bindingsSpecifiedManually(promotedService.getCallback().getBindings())) {
+ if (compositeService.getCallback() != null) {
+ compositeService.getCallback().getBindings().clear();
+ } else {
+ compositeService.setCallback(assemblyFactory.createCallback());
+ }
+ for (Binding binding : promotedService.getCallback().getBindings()) {
+ try {
+ compositeService.getCallback().getBindings().add((Binding)binding.clone());
+ } catch (CloneNotSupportedException ex) {
+ // this binding can't be used in the promoted service
+ }
+ }
+ }
+ if (!(componentService.getCallback() != null &&
+ bindingsSpecifiedManually(componentService.getCallback().getBindings())) &&
+ compositeService.getCallback() != null &&
+ bindingsSpecifiedManually(compositeService.getCallback().getBindings())) {
+ if (componentService.getCallback() != null) {
+ componentService.getCallback().getBindings().clear();
+ } else {
+ componentService.setCallback(assemblyFactory.createCallback());
+ }
+ componentService.getCallback().getBindings().addAll(
+ compositeService.getCallback().getBindings());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * If the bindings are specified in the composite file return true as they should
+ * otherwise return false
+ *
+ * @param bindings
+ * @return true if the bindings were specified manually
+ */
+ private boolean bindingsSpecifiedManually(List<Binding> bindings) {
+
+ if (bindings.size() > 1) {
+ return true;
+ } else if (bindings.size() == 1 &&
+ bindings.get(0) instanceof AutomaticBinding &&
+ ((AutomaticBinding)bindings.get(0)).getIsAutomatic()) {
+ return false;
+ } else if (bindings.size() == 1) {
+ return true;
+ } else {
+ return false;
+ }
}
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServicePromotionBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServicePromotionBuilderImpl.java
new file mode 100644
index 0000000000..39d2cec396
--- /dev/null
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServicePromotionBuilderImpl.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.builder.impl;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+
+/**
+ * A composite builder that handles the creation of promoted composite services.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeServicePromotionBuilderImpl implements CompositeBuilder {
+ private AssemblyFactory assemblyFactory;
+
+ public CompositeServicePromotionBuilderImpl(AssemblyFactory assemblyFactory) {
+ this.assemblyFactory = assemblyFactory;
+ }
+
+ public void build(Composite composite) throws CompositeBuilderException {
+
+ // Process top level composite services
+ for (Service service : composite.getServices()) {
+ CompositeService compositeService = (CompositeService)service;
+
+ // Get the innermost promoted service
+ ComponentService promotedService = ServiceConfigurationUtil.getPromotedComponentService(compositeService);
+ if (promotedService != null) {
+ Component promotedComponent = ServiceConfigurationUtil.getPromotedComponent(compositeService);
+
+ // Create a new component service to represent this composite
+ // service on the promoted component
+ ComponentService newComponentService = assemblyFactory.createComponentService();
+ newComponentService.setName("$promoted$." + compositeService.getName());
+ promotedComponent.getServices().add(newComponentService);
+ newComponentService.setService(promotedService.getService());
+ newComponentService.getBindings().addAll(compositeService.getBindings());
+ newComponentService.setInterfaceContract(compositeService.getInterfaceContract());
+ if (compositeService.getInterfaceContract() != null &&
+ compositeService.getInterfaceContract().getCallbackInterface() != null) {
+ newComponentService.setCallback(assemblyFactory.createCallback());
+ newComponentService.getCallback().getBindings()
+ .addAll(compositeService.getCallback().getBindings());
+ }
+
+ // Change the composite service to now promote the newly
+ // created component service directly
+ compositeService.setPromotedComponent(promotedComponent);
+ compositeService.setPromotedService(newComponentService);
+ }
+ }
+ }
+
+}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java
index 5d3d8a3a04..23d547efaf 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java
@@ -18,11 +18,23 @@
*/
package org.apache.tuscany.sca.assembly.builder.impl;
+import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointFactory;
import org.apache.tuscany.sca.assembly.Multiplicity;
import org.apache.tuscany.sca.assembly.OptimizableBinding;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
/**
* This class encapsulates utility methods to deal with reference definitions
@@ -30,6 +42,21 @@ import org.apache.tuscany.sca.assembly.OptimizableBinding;
* @version $Rev$ $Date$
*/
abstract class ReferenceConfigurationUtil {
+
+ /**
+ * Report a warning.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private static void warning(Monitor monitor, String message, Object model, String... messageParameters) {
+ if (monitor != null) {
+ Problem problem = new ProblemImpl(ReferenceConfigurationUtil.class.getName(), "assembly-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
static boolean isValidMultiplicityOverride(Multiplicity definedMul, Multiplicity overridenMul) {
if (definedMul != overridenMul) {
switch (definedMul) {
@@ -92,4 +119,146 @@ abstract class ReferenceConfigurationUtil {
}
return true;
}
+
+ /**
+ * Follow a reference promotion chain down to the innermost (non composite)
+ * component references.
+ *
+ * @param compositeReference
+ * @return
+ */
+ static List<ComponentReference> getPromotedComponentReferences(CompositeReference compositeReference) {
+ List<ComponentReference> componentReferences = new ArrayList<ComponentReference>();
+ collectPromotedComponentReferences(compositeReference, componentReferences);
+ return componentReferences;
+ }
+
+ /**
+ * Follow a reference promotion chain down to the innermost (non composite)
+ * component references.
+ *
+ * @param compositeReference
+ * @param componentReferences
+ * @return
+ */
+ private static void collectPromotedComponentReferences(CompositeReference compositeReference,
+ List<ComponentReference> componentReferences) {
+ for (ComponentReference componentReference : compositeReference.getPromotedReferences()) {
+ Reference reference = componentReference.getReference();
+ if (reference instanceof CompositeReference) {
+
+ // Continue to follow the reference promotion chain
+ collectPromotedComponentReferences((CompositeReference)reference, componentReferences);
+
+ } else if (reference != null) {
+
+ // Found a non-composite reference
+ componentReferences.add(componentReference);
+ }
+ }
+ }
+
+ /**
+ * Override the bindings for a promoted reference from an outer component
+ * reference
+ *
+ * @param reference
+ * @param promotedReference
+ */
+ static void reconcileReferenceBindings(Reference reference,
+ ComponentReference promotedReference,
+ AssemblyFactory assemblyFactory,
+ EndpointFactory endpointFactory,
+ Monitor monitor) {
+
+ if (promotedReference.getMultiplicity() == Multiplicity.ONE_ONE ||
+ promotedReference.getMultiplicity() == Multiplicity.ZERO_ONE) {
+
+ // if necessary override the promoted endpoints (and bindings) with the top level bindings
+ if (reference.getBindings().size() > 0 ){
+
+ List<Binding> bindingsToCopyDown = new ArrayList<Binding>();
+ List<Endpoint> endpointsToCopyDown = new ArrayList<Endpoint>();
+
+ for (Binding binding : reference.getBindings()) {
+ if ((!(binding instanceof OptimizableBinding)) || binding.getURI() != null) {
+ bindingsToCopyDown.add(binding);
+
+ if (reference instanceof ComponentReference){
+ for (Endpoint endpoint : ((ComponentReference)reference).getEndpoints()){
+ if ( endpoint.getSourceBinding() == binding){
+ endpointsToCopyDown.add(endpoint);
+ break;
+ }
+ }
+ } else {
+ // create a new endpoint to represent this promoted binding
+ Endpoint endpoint = endpointFactory.createEndpoint();
+ endpoint.setTargetName(binding.getURI());
+ endpoint.setSourceComponent(null); // TODO - fixed up at start
+ endpoint.setSourceComponentReference(promotedReference);
+ endpoint.setInterfaceContract(reference.getInterfaceContract());
+ endpoint.setSourceBinding(binding);
+ endpointsToCopyDown.add(endpoint);
+ }
+ }
+ }
+
+ if (bindingsToCopyDown.size() > 0) {
+ promotedReference.getBindings().clear();
+ promotedReference.getBindings().addAll(bindingsToCopyDown);
+
+ promotedReference.getEndpoints().clear();
+ promotedReference.getEndpoints().addAll(endpointsToCopyDown);
+ }
+ }
+
+ if (promotedReference.getBindings().size() > 1) {
+ warning(monitor, "ComponentReferenceMoreWire", promotedReference, promotedReference.getName());
+ }
+ } else {
+ // if necessary merge the promoted endpoints (and bindings) with the top level bindings
+ if (reference.getBindings().size() > 0 ){
+
+ for (Binding binding : reference.getBindings()) {
+ if ((!(binding instanceof OptimizableBinding)) || binding.getURI() != null) {
+ promotedReference.getBindings().add(binding);
+
+ if (reference instanceof ComponentReference){
+ for (Endpoint endpoint : ((ComponentReference)reference).getEndpoints()){
+ if ( endpoint.getSourceBinding() == binding){
+ promotedReference.getEndpoints().add(endpoint);
+ break;
+ }
+ }
+ } else {
+ // create a new endpoint to represent this promoted binding
+ Endpoint endpoint = endpointFactory.createEndpoint();
+ endpoint.setTargetName(binding.getURI());
+ endpoint.setSourceComponent(null); // TODO - fixed up at start
+ endpoint.setSourceComponentReference(promotedReference);
+ endpoint.setInterfaceContract(reference.getInterfaceContract());
+ endpoint.setSourceBinding(binding);
+ promotedReference.getEndpoints().add(endpoint);
+ }
+ }
+ }
+ }
+ }
+
+ Set<Binding> callbackBindings = new HashSet<Binding>();
+ if (promotedReference.getCallback() != null) {
+ callbackBindings.addAll(promotedReference.getCallback().getBindings());
+ }
+ if (reference.getCallback() != null) {
+ callbackBindings.addAll(reference.getCallback().getBindings());
+ }
+ promotedReference.setCallback(assemblyFactory.createCallback());
+ for (Binding binding : callbackBindings) {
+ if ((!(binding instanceof OptimizableBinding)) || binding.getURI() != null) {
+ promotedReference.getCallback().getBindings().add(binding);
+ }
+ }
+ }
+
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ServiceConfigurationUtil.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ServiceConfigurationUtil.java
index 5a8d373eb2..41a8b3f8ba 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ServiceConfigurationUtil.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ServiceConfigurationUtil.java
@@ -18,6 +18,7 @@
*/
package org.apache.tuscany.sca.assembly.builder.impl;
+import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.CompositeService;
import org.apache.tuscany.sca.assembly.Service;
@@ -56,4 +57,32 @@ abstract class ServiceConfigurationUtil {
return null;
}
}
+
+ /**
+ * Follow a service promotion chain down to the innermost (non-composite) component.
+ *
+ * @param compositeService
+ * @return
+ */
+ static Component getPromotedComponent(CompositeService compositeService) {
+ ComponentService componentService = compositeService.getPromotedService();
+ if (componentService != null) {
+ Service service = componentService.getService();
+ if (componentService.getName() != null && service instanceof CompositeService) {
+
+ // Continue to follow the service promotion chain
+ return getPromotedComponent((CompositeService)service);
+
+ } else {
+
+ // Found a non-composite service
+ return compositeService.getPromotedComponent();
+ }
+ } else {
+
+ // No promoted service
+ return null;
+ }
+ }
+
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java
index b3fdd32aee..ea9f768f4e 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java
@@ -22,11 +22,13 @@ package org.apache.tuscany.sca.assembly.impl;
import java.util.ArrayList;
import java.util.List;
+import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.ComponentReference;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.CompositeReference;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
/**
* Represents a component reference
@@ -88,4 +90,23 @@ public class ComponentReferenceImpl extends ReferenceImpl implements ComponentRe
public List<Endpoint> getEndpoints(){
return endpoints;
}
+
+ /**
+ * Use endpoint information to work out what the interface contract for the
+ * binding is.
+ */
+ public InterfaceContract getInterfaceContract(Binding binding){
+ InterfaceContract interfaceContract = null;
+
+ for (Endpoint theEndpoint : endpoints){
+ if (theEndpoint.getSourceBinding() == binding){
+ interfaceContract = theEndpoint.getInterfaceContract();
+ }
+ }
+
+ if (interfaceContract == null){
+ interfaceContract = getInterfaceContract();
+ }
+ return interfaceContract;
+ }
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java
index 4396967137..5748abb07d 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java
@@ -26,6 +26,7 @@ import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentReference;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
/**
* The assembly model object for an endpoint.
@@ -48,6 +49,8 @@ public class EndpointImpl implements Endpoint {
private Binding targetBinding;
private Binding targetCallbackBinding;
+ private InterfaceContract interfaceContract;
+
protected EndpointImpl() {
}
@@ -140,4 +143,12 @@ public class EndpointImpl implements Endpoint {
public void setTargetCallbackBinding(Binding targetCallbackBinding){
this.targetCallbackBinding = targetCallbackBinding;
}
+
+ public InterfaceContract getInterfaceContract() {
+ return interfaceContract;
+ }
+
+ public void setInterfaceContract(InterfaceContract interfaceContract) {
+ this.interfaceContract = interfaceContract;
+ }
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java
index 297a7c3a99..1800222bfb 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java
@@ -26,6 +26,7 @@ import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Callback;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.policy.PolicySet;
/**
@@ -40,6 +41,7 @@ public class ReferenceImpl extends AbstractReferenceImpl implements Reference, C
private List<ComponentService> targets = new ArrayList<ComponentService>();
private Callback callback;
private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+ private boolean promotionOverride;
public List<PolicySet> getApplicablePolicySets() {
return applicablePolicySets;
@@ -93,6 +95,14 @@ public class ReferenceImpl extends AbstractReferenceImpl implements Reference, C
this.wiredByImpl = wiredByImpl;
}
+ public boolean isPromotionOverride() {
+ return promotionOverride;
+ }
+
+ public void setPromotionOverride(boolean promotionOverride) {
+ this.promotionOverride = promotionOverride;
+ }
+
public List<PolicySet> getPolicySets() {
return policySets;
}
@@ -112,5 +122,12 @@ public class ReferenceImpl extends AbstractReferenceImpl implements Reference, C
public void setPolicySets(List<PolicySet> policySets) {
this.policySets = policySets;
}
+
+ /**
+ * By default return the interface contract for the reference
+ */
+ public InterfaceContract getInterfaceContract(Binding binding){
+ return getInterfaceContract();
+ }
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java
index bee7cbec2d..8d745cb7e1 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java
@@ -25,6 +25,7 @@ import java.util.List;
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Callback;
import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.policy.PolicySet;
/**
@@ -95,5 +96,12 @@ public class ServiceImpl extends AbstractServiceImpl implements Service, Cloneab
public void setPolicySets(List<PolicySet> policySets) {
this.policySets = policySets;
}
+
+ /**
+ * By default return the interface contract for the service
+ */
+ public InterfaceContract getInterfaceContract(Binding binding){
+ return getInterfaceContract();
+ }
}
diff --git a/java/sca/modules/assembly/src/main/resources/assembly-validation-messages.properties b/java/sca/modules/assembly/src/main/resources/assembly-validation-messages.properties
index eaf01e0e62..f9760aa3cb 100644
--- a/java/sca/modules/assembly/src/main/resources/assembly-validation-messages.properties
+++ b/java/sca/modules/assembly/src/main/resources/assembly-validation-messages.properties
@@ -38,6 +38,7 @@ ReferenceIncompatibleInterface = Incompatible interfaces on component reference
ReferenceIncompatibleComponentInterface = Component reference interface incompatible with reference interface: Component = {0} Reference = {1}
ServiceIncompatibleComponentInterface = Component service interface incompatible with service interface: Component = {0} Service = {1}
MultipleBindingsForService = Multiple bindings with the same name for a service: Binding = {0} Service = {1} Binding = {2}
+MultipleBindingsForReference = Multiple bindings with the same name for a reference: Binding = {0} Reference = {1} Binding = {2}
ReferenceWithoutTargets = No targets for reference: Composite = {0} Reference = {1}
PromotedReferenceNotFound = Promoted component reference not found: Composite = {0} Reference = {1}
PromotedServiceNotFound = Promoted component service not found: Composite = {0} Service = {1}