From 466430ac4793692e5e1466282f605d5934633dfc Mon Sep 17 00:00:00 2001 From: rfeng Date: Mon, 6 Jul 2009 17:39:44 +0000 Subject: Organize imports and reformat the code git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@791550 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/assembly/AbstractContract.java | 2 +- .../tuscany/sca/assembly/AssemblyFactory.java | 7 +- .../java/org/apache/tuscany/sca/assembly/Base.java | 1 - .../org/apache/tuscany/sca/assembly/Binding.java | 3 - .../apache/tuscany/sca/assembly/BindingRRB.java | 13 +- .../org/apache/tuscany/sca/assembly/Component.java | 5 +- .../tuscany/sca/assembly/ComponentProperty.java | 6 +- .../tuscany/sca/assembly/ComponentReference.java | 7 +- .../tuscany/sca/assembly/ComponentService.java | 1 - .../apache/tuscany/sca/assembly/ComponentType.java | 4 +- .../org/apache/tuscany/sca/assembly/Composite.java | 3 +- .../tuscany/sca/assembly/CompositeReference.java | 2 +- .../tuscany/sca/assembly/CompositeService.java | 4 +- .../org/apache/tuscany/sca/assembly/Contract.java | 6 +- .../sca/assembly/DistributedSCABinding.java | 1 - .../org/apache/tuscany/sca/assembly/Endpoint.java | 7 +- .../tuscany/sca/assembly/EndpointReference.java | 12 +- .../apache/tuscany/sca/assembly/Extensible.java | 2 +- .../tuscany/sca/assembly/OperationSelector.java | 3 +- .../tuscany/sca/assembly/OptimizableBinding.java | 10 +- .../org/apache/tuscany/sca/assembly/Property.java | 3 +- .../org/apache/tuscany/sca/assembly/Reference.java | 4 +- .../tuscany/sca/assembly/SCABindingFactory.java | 1 - .../org/apache/tuscany/sca/assembly/Service.java | 2 +- .../java/org/apache/tuscany/sca/assembly/Wire.java | 4 +- .../apache/tuscany/sca/assembly/WireFormat.java | 3 +- .../sca/assembly/builder/AutomaticBinding.java | 4 +- .../sca/assembly/builder/BindingBuilder.java | 4 +- .../assembly/builder/BindingBuilderExtension.java | 1 - .../sca/assembly/builder/CompositeBuilder.java | 4 +- .../builder/CompositeBuilderExtensionPoint.java | 8 +- .../sca/assembly/builder/CompositeBuilderTmp.java | 7 +- .../DefaultCompositeBuilderExtensionPoint.java | 35 +- .../sca/assembly/builder/DomainBuilder.java | 17 +- .../assembly/builder/EndpointReferenceBuilder.java | 4 +- .../sca/assembly/builder/impl/BaseBuilderImpl.java | 183 +++-- .../impl/ComponentConfigurationBuilderImpl.java | 185 +++-- .../impl/ComponentReferenceBindingBuilderImpl.java | 11 +- ...onentReferenceEndpointReferenceBuilderImpl.java | 850 +++++++++++---------- .../ComponentReferencePromotionBuilderImpl.java | 107 +-- ...ComponentReferencePromotionWireBuilderImpl.java | 107 +-- .../impl/ComponentReferenceWireBuilderImpl.java | 48 +- .../impl/ComponentServiceBindingBuilderImpl.java | 4 +- .../impl/ComponentServiceEndpointBuilderImpl.java | 257 +++---- .../impl/ComponentServicePromotionBuilderImpl.java | 17 +- .../CompositeBindingConfigurationBuilderImpl.java | 24 +- .../impl/CompositeBindingURIBuilderImpl.java | 170 +++-- .../builder/impl/CompositeBuilderImpl.java | 199 ++--- .../builder/impl/CompositeCloneBuilderImpl.java | 14 +- .../builder/impl/CompositeIncludeBuilderImpl.java | 50 +- .../impl/CompositePromotionBuilderImpl.java | 92 ++- ...CompositeReferenceConfigurationBuilderImpl.java | 65 +- .../impl/CompositeReferenceWireBuilderImpl.java | 10 +- .../impl/CompositeServiceBindingBuilderImpl.java | 4 +- .../CompositeServiceConfigurationBuilderImpl.java | 60 +- .../impl/CompositeServicePromotionBuilderImpl.java | 6 +- .../builder/impl/PolicyConfigurationException.java | 6 +- .../builder/impl/PolicyConfigurationUtil.java | 185 +++-- .../builder/impl/PropertyConfigurationUtil.java | 43 +- .../builder/impl/ReferenceConfigurationUtil.java | 82 +- .../builder/impl/ServiceConfigurationUtil.java | 8 +- .../sca/assembly/impl/AbstractPropertyImpl.java | 2 +- .../sca/assembly/impl/AbstractReferenceImpl.java | 2 +- .../sca/assembly/impl/AbstractServiceImpl.java | 4 +- .../sca/assembly/impl/AssemblyFactoryImpl.java | 1 + .../apache/tuscany/sca/assembly/impl/BaseImpl.java | 2 +- .../tuscany/sca/assembly/impl/CallbackImpl.java | 6 +- .../tuscany/sca/assembly/impl/ComponentImpl.java | 3 +- .../sca/assembly/impl/ComponentPropertyImpl.java | 8 +- .../sca/assembly/impl/ComponentReferenceImpl.java | 37 +- .../sca/assembly/impl/ComponentServiceImpl.java | 4 +- .../sca/assembly/impl/ComponentTypeImpl.java | 1 + .../tuscany/sca/assembly/impl/CompositeImpl.java | 4 +- .../sca/assembly/impl/CompositeReferenceImpl.java | 4 +- .../sca/assembly/impl/CompositeServiceImpl.java | 6 +- .../sca/assembly/impl/ConstrainingTypeImpl.java | 10 +- .../tuscany/sca/assembly/impl/ContractImpl.java | 12 +- .../assembly/impl/DistributedSCABindingImpl.java | 16 +- .../tuscany/sca/assembly/impl/EndpointImpl.java | 8 +- .../sca/assembly/impl/EndpointReferenceImpl.java | 16 +- .../tuscany/sca/assembly/impl/ExtensibleImpl.java | 6 +- .../tuscany/sca/assembly/impl/ExtensionImpl.java | 2 +- .../tuscany/sca/assembly/impl/PropertyImpl.java | 8 +- .../tuscany/sca/assembly/impl/ReferenceImpl.java | 4 +- .../sca/assembly/impl/SCABindingFactoryImpl.java | 2 +- .../tuscany/sca/assembly/impl/SCABindingImpl.java | 6 +- .../tuscany/sca/assembly/impl/ServiceImpl.java | 9 +- .../apache/tuscany/sca/assembly/impl/WireImpl.java | 4 +- .../sca/assembly/AssemblyFactoryTestCase.java | 1 - .../sca/assembly/TestInterfaceContract.java | 2 +- .../builder/impl/CompositeBuilderTestCase.java | 20 +- .../assembly/builder/impl/PrintUtilTestCase.java | 4 +- 92 files changed, 1640 insertions(+), 1561 deletions(-) (limited to 'java/sca') diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java index 0a14b5658e..4532026050 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java @@ -50,7 +50,7 @@ public interface AbstractContract extends Base, Extensible, PolicySubject { * @return the interface contract */ InterfaceContract getInterfaceContract(); - + /** * Sets the interface contract defining the interface and callback * interface for the contract. diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java index 3c850dc053..6f1aaffc32 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java @@ -18,8 +18,6 @@ */ package org.apache.tuscany.sca.assembly; - - /** * A factory for the assembly model * @@ -145,21 +143,20 @@ public interface AssemblyFactory { * @return a new wire */ Wire createWire(); - + /** * Create an Extension * @return */ Extension createExtension(); - /** * Create a new endpoint * * @return a new endpoint */ Endpoint createEndpoint(); - + /** * Create a new endpoint reference * diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java index cb19ab5acb..96dc906395 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java @@ -18,7 +18,6 @@ */ package org.apache.tuscany.sca.assembly; - /** * Base interface for all assembly model objects. * diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java index 069b4d4c5a..5c5827637d 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java @@ -20,9 +20,6 @@ package org.apache.tuscany.sca.assembly; import javax.xml.namespace.QName; - - - /** * Represents a binding. * diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/BindingRRB.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/BindingRRB.java index b0bfdec6d7..35e5f148ba 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/BindingRRB.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/BindingRRB.java @@ -18,7 +18,6 @@ */ package org.apache.tuscany.sca.assembly; - /** * TODO RRB experiment. * Represents a binding implemented using Request/Response binding chains @@ -29,15 +28,15 @@ package org.apache.tuscany.sca.assembly; public interface BindingRRB extends Binding { WireFormat getRequestWireFormat(); - + void setRequestWireFormat(WireFormat wireFormat); - + WireFormat getResponseWireFormat(); - - void setResponseWireFormat(WireFormat wireFormat); - + + void setResponseWireFormat(WireFormat wireFormat); + OperationSelector getOperationSelector(); - + void setOperationSelector(OperationSelector operationSelector); } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java index 7386fc8583..8aa2215b7a 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java @@ -29,14 +29,14 @@ import org.apache.tuscany.sca.policy.PolicySubject; * @version $Rev$ $Date$ */ public interface Component extends Base, Extensible, PolicySubject, Cloneable { - + /** * Returns the URI of the component. * * @return the URI of the component */ String getURI(); - + /** * Sets the URI of the component. * @@ -119,7 +119,6 @@ public interface Component extends Base, Extensible, PolicySubject, Cloneable { * @param autowire whether component references should be autowired */ void setAutowire(Boolean autowire); - /** * Returns a clone of the component. diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java index 13d19b1757..9a6ae4d35a 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java @@ -58,13 +58,13 @@ public interface ComponentProperty extends Property { * composite */ void setSource(String source); - + /** * Get the XPath expression for the source attribute * @return the XPath expression for the source attribute */ XPathExpression getSourceXPathExpression(); - + /** * Set the XPath expression for the source attribute * @param sourceXPathExpression the XPath expression for the source attribute @@ -84,5 +84,5 @@ public interface ComponentProperty extends Property { * @param file a URI to a file containing the property value */ void setFile(String file); - + } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java index e18d4d5d8c..b204b649fe 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java @@ -18,9 +18,6 @@ */ package org.apache.tuscany.sca.assembly; - - - /** * An instance of a reference associated with a particular component. * @@ -55,7 +52,6 @@ public interface ComponentReference extends Reference { */ void setAutowire(Boolean autowire); - /** * Returns the callback service created internally as a target endpoint * for callbacks to this reference. @@ -109,7 +105,8 @@ public interface ComponentReference extends Reference { * Sets whether this Component Reference is promoted * @param isPromoted - true if the component reference is promoted */ - void setPromoted( boolean isPromoted ); + void setPromoted(boolean isPromoted); + boolean isPromoted(); } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java index 65945692f1..022d829488 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java @@ -18,7 +18,6 @@ */ package org.apache.tuscany.sca.assembly; - /** * An addressable instance of a service associated with a particular component. * diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java index 9fb3b92102..2847132093 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java @@ -28,13 +28,13 @@ import org.apache.tuscany.sca.policy.PolicySubject; * @version $Rev$ $Date$ */ public interface ComponentType extends Base, PolicySubject { - + /** * Returns the URI of this component type. * @return the URI of the component type */ String getURI(); - + /** * Sets the URI of this component type. * @param uri the URI of the component type diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java index 27bc79788e..f95a8a424d 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java @@ -24,7 +24,6 @@ import javax.xml.namespace.QName; import org.apache.tuscany.sca.policy.PolicySubject; - /** * Represents a composite. * @@ -32,6 +31,7 @@ import org.apache.tuscany.sca.policy.PolicySubject; */ public interface Composite extends Implementation, Extensible, Cloneable, PolicySubject { QName TYPE = new QName(SCA11_NS, "implementation.composite"); + /** * Returns the spec version of the composite used to build this model * @@ -112,7 +112,6 @@ public interface Composite extends Implementation, Extensible, Cloneable, Policy */ void setAutowire(Boolean autowire); - /** * Returns a clone of the component type. * diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java index 9defd8f66c..88cb2f9a2c 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java @@ -40,5 +40,5 @@ public interface CompositeReference extends Reference { * @return the promoted component references */ List getPromotedReferences(); - + } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java index 7143f571f9..690316aca4 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java @@ -38,7 +38,7 @@ public interface CompositeService extends Service { * @param promotedComponent the promoted component. */ void setPromotedComponent(Component promotedComponent); - + /** * Returns the promoted component service . * @@ -52,5 +52,5 @@ public interface CompositeService extends Service { * @param promotedService the promoted component service. */ void setPromotedService(ComponentService promotedService); - + } 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 54d6347301..6304ddb68a 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 @@ -78,7 +78,7 @@ public interface Contract extends AbstractContract, PolicySubject, Cloneable { * @throws CloneNotSupportedException */ 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 @@ -90,6 +90,6 @@ public interface Contract extends AbstractContract, PolicySubject, Cloneable { * @param binding the binding for which the interface contract is required * @return the interface contract */ - InterfaceContract getInterfaceContract(Binding binding); - + InterfaceContract getInterfaceContract(Binding binding); + } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DistributedSCABinding.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DistributedSCABinding.java index daa57caaea..f1e25a0867 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DistributedSCABinding.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DistributedSCABinding.java @@ -20,7 +20,6 @@ package org.apache.tuscany.sca.assembly; import javax.xml.namespace.QName; - /** * Represents an SCA binding used in the distributed runtime. * It provides us with a sensibly named type against which 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 cefe585595..0f59049b84 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 @@ -46,6 +46,7 @@ public interface Endpoint extends Base, PolicySubject, Cloneable, Serializable { * or <componentURI>#service(serviceName) */ void setURI(String uri); + /** * Supports endpoint cloning * @@ -126,7 +127,7 @@ public interface Endpoint extends Base, PolicySubject, Cloneable, Serializable { * @param registry */ void setExtensionPointRegistry(ExtensionPointRegistry registry); - + /** * Returns true if this endpoint represents a serivce that is not * running in this JVM @@ -134,13 +135,13 @@ public interface Endpoint extends Base, PolicySubject, Cloneable, Serializable { * @return true if the endpoint is remote */ boolean isRemote(); - + /** * Set true if this endpoint represents a serivce that is not * running in this JVM * * @param remote set to true if the endpoint is remote */ - void setRemote(boolean remote); + void setRemote(boolean remote); } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java index d96060e10b..1bfd87e90e 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java @@ -32,13 +32,13 @@ import org.apache.tuscany.sca.policy.PolicySubject; * @version $Rev$ $Date$ */ public interface EndpointReference extends Base, PolicySubject, Cloneable, Serializable { - + public static final int NOT_CONFIGURED = 0; public static final int RESOLVED_BINDING = 1; public static final int WIRED_TARGET_NOT_FOUND = 2; public static final int WIRED_TARGET_FOUND_BUT_NOT_MATCHED = 3; public static final int WIRED_TARGET_FOUND_AND_MATCHED = 4; - + /** * Get the structural URI of the reference binding * @return The structural URI of the reference/binding @@ -146,7 +146,7 @@ public interface EndpointReference extends Base, PolicySubject, Cloneable, Seria * @param callbackEndpoint the reference callback endpoint */ void setCallbackEndpoint(Endpoint callbackEndpoint); - + /** * Returns true if this endpoint reference refers to an endpoint that * is not running in this endpoint reference @@ -154,7 +154,7 @@ public interface EndpointReference extends Base, PolicySubject, Cloneable, Seria * @return true if the endpoint is remote */ boolean isRemote(); - + /** * Set true if this endpoint reference refers to an endpoint that * is not running in this endpoint reference @@ -170,7 +170,7 @@ public interface EndpointReference extends Base, PolicySubject, Cloneable, Seria * @param registry */ void setExtensionPointRegistry(ExtensionPointRegistry registry); - + /** * Rather than relying on combinations of unresolved flags and * other data we maintain a status enumeration @@ -178,7 +178,7 @@ public interface EndpointReference extends Base, PolicySubject, Cloneable, Seria * @return status */ int getStatus(); - + /** * Rather than relying on combinations of unresolved flags and * other data we maintain a status enumeration diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java index 90d6745f35..9476251305 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java @@ -33,7 +33,7 @@ public interface Extensible extends Base { * @return a list of extension objects container in this model object */ List getExtensions(); - + /** * Returns a list of attribute extensions contained in this model object * diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java index 6770e87ee1..f72b78cc3a 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java @@ -18,12 +18,11 @@ */ package org.apache.tuscany.sca.assembly; - /** * Represents an operationSelector * * @version $Rev$ $Date$ */ public interface OperationSelector extends Base, Cloneable { - + } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OptimizableBinding.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OptimizableBinding.java index 98ff92f15b..f997d03786 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OptimizableBinding.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OptimizableBinding.java @@ -31,27 +31,27 @@ public interface OptimizableBinding extends Binding, Cloneable { * @param component */ void setTargetComponent(Component component); - + /** * @param service */ void setTargetComponentService(ComponentService service); - + /** * @param binding */ void setTargetBinding(Binding binding); - + /** * @return */ Binding getTargetBinding(); - + /** * @return */ Component getTargetComponent(); - + /** * @return */ diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java index 986e1f12e4..9d1b3ac20c 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java @@ -18,7 +18,6 @@ */ package org.apache.tuscany.sca.assembly; - /** * A property allows for the configuration of an implementation with externally * set data values. An implementation can have zero or more properties. Each @@ -28,7 +27,7 @@ package org.apache.tuscany.sca.assembly; * @version $Rev$ $Date$ */ public interface Property extends AbstractProperty, Cloneable { - + /** * Returns a clone of the property. * 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 08344ca24f..702826d43e 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 @@ -70,7 +70,7 @@ public interface Reference extends AbstractReference, Contract { * @return the targets of this reference. */ List getTargets(); - + /** * Returns the endpoint references implied by this reference. * @@ -82,6 +82,6 @@ public interface Reference extends AbstractReference, Contract { * * @return the endpoint references implied by this reference */ - List getEndpointReferences(); + List getEndpointReferences(); } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java index 74dde43614..176770e553 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java @@ -18,7 +18,6 @@ */ package org.apache.tuscany.sca.assembly; - /** * A factory for the SCA binding model * diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java index e597a50f30..5069b92a50 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java @@ -37,5 +37,5 @@ public interface Service extends AbstractService, Contract { * * @return the endpoints implied by this service */ - List getEndpoints(); + List getEndpoints(); } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java index e1eb26f0c1..075b50eec1 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java @@ -54,7 +54,7 @@ public interface Wire extends Base, Extensible, PolicySubject, Cloneable { * @param target the target of the wire */ void setTarget(ComponentService target); - + /** * A boolean value, with the default of "false". When a wire element has * @replace="false", the wire is added to the set of wires which apply to @@ -67,7 +67,7 @@ public interface Wire extends Base, Extensible, PolicySubject, Cloneable { * @return */ boolean isReplace(); - + /** * Set the replace flag for the wire * @param replace diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.java index d8c530585e..fc03bfeb88 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.java @@ -18,12 +18,11 @@ */ package org.apache.tuscany.sca.assembly; - /** * Represents a wireFormat. * * @version $Rev$ $Date$ */ public interface WireFormat extends Base, Cloneable { - + } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/AutomaticBinding.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/AutomaticBinding.java index 97708f9ef5..327d2d1901 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/AutomaticBinding.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/AutomaticBinding.java @@ -25,13 +25,13 @@ package org.apache.tuscany.sca.assembly.builder; * @version $Rev$ $Date$ * */ -public interface AutomaticBinding extends Cloneable { +public interface AutomaticBinding extends Cloneable { /** * @param isAutomatic */ void setIsAutomatic(boolean isAutomatic); - + /** * @return isAutomatic */ diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java index 7bac630d5b..cd71f06279 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java @@ -30,7 +30,7 @@ import org.apache.tuscany.sca.monitor.Monitor; * @version $Rev$ $Date$ */ public interface BindingBuilder { - + /** * Configure a binding. * @@ -38,5 +38,5 @@ public interface BindingBuilder { * @param contract The binding's service or reference */ void build(Component component, AbstractContract contract, Binding binding, Monitor monitor); - + } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilderExtension.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilderExtension.java index 37ad8af0b3..0f1fee3c1d 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilderExtension.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilderExtension.java @@ -41,4 +41,3 @@ public interface BindingBuilderExtension { void setBuilder(BindingBuilder builder); } - diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java index 8a18f74b2b..b1c4b4e486 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java @@ -37,7 +37,7 @@ public interface CompositeBuilder { * @return */ String getID(); - + /** * Build a composite. * @@ -47,5 +47,5 @@ public interface CompositeBuilder { * @throws CompositeBuilderException */ void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException; - + } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderExtensionPoint.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderExtensionPoint.java index a2d6b34db5..151da31af0 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderExtensionPoint.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderExtensionPoint.java @@ -22,7 +22,7 @@ package org.apache.tuscany.sca.assembly.builder; /** * An extension point for Composite builders. * - * @version $Rev: $ $Date: $ + * @version $Rev$ $Date$ */ public interface CompositeBuilderExtensionPoint { @@ -32,14 +32,14 @@ public interface CompositeBuilderExtensionPoint { * @param compositeBuilder */ void addCompositeBuilder(CompositeBuilder compositeBuilder); - + /** * Removes a composite builder. * * @param compositeBuilder */ void removeCompositeBuilder(CompositeBuilder compositeBuilder); - + /** * Returns the composite builder with the given id. * @@ -47,5 +47,5 @@ public interface CompositeBuilderExtensionPoint { * @return */ CompositeBuilder getCompositeBuilder(String id); - + } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderTmp.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderTmp.java index c6bf6caac0..c9588130dc 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderTmp.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderTmp.java @@ -42,7 +42,7 @@ public interface CompositeBuilderTmp { * @return */ String getID(); - + /** * Build a composite. * @@ -51,6 +51,7 @@ public interface CompositeBuilderTmp { * @param monitor * @throws CompositeBuilderException */ - void build(Composite composite, Definitions definitions, Map> bindingBaseURIs, Monitor monitor) throws CompositeBuilderException; - + void build(Composite composite, Definitions definitions, Map> bindingBaseURIs, Monitor monitor) + throws CompositeBuilderException; + } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java index 035d620778..c98e31d95b 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java @@ -87,10 +87,11 @@ public class DefaultCompositeBuilderExtensionPoint implements CompositeBuilderEx } for (ServiceDeclaration builderDeclaration : builderDeclarations) { - Map attributes = builderDeclaration.getAttributes(); + Map attributes = builderDeclaration.getAttributes(); String id = attributes.get("id"); - CompositeBuilder builder = new LazyCompositeBuilder(registry, id, builderDeclaration, this, factories, mapper); + CompositeBuilder builder = + new LazyCompositeBuilder(registry, id, builderDeclaration, this, factories, mapper); builders.put(id, builder); } } @@ -109,8 +110,12 @@ public class DefaultCompositeBuilderExtensionPoint implements CompositeBuilderEx private CompositeBuilder builder; private CompositeBuilderExtensionPoint builders; - private LazyCompositeBuilder(ExtensionPointRegistry registry, String id, ServiceDeclaration factoryDeclaration, - CompositeBuilderExtensionPoint builders, FactoryExtensionPoint factories, InterfaceContractMapper mapper) { + private LazyCompositeBuilder(ExtensionPointRegistry registry, + String id, + ServiceDeclaration factoryDeclaration, + CompositeBuilderExtensionPoint builders, + FactoryExtensionPoint factories, + InterfaceContractMapper mapper) { this.registry = registry; this.id = id; this.builderDeclaration = factoryDeclaration; @@ -123,12 +128,15 @@ public class DefaultCompositeBuilderExtensionPoint implements CompositeBuilderEx return id; } - public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { + public void build(Composite composite, Definitions definitions, Monitor monitor) + throws CompositeBuilderException { getBuilder().build(composite, definitions, monitor); } - - public void build(Composite composite, Definitions definitions, Map> bindingBaseURIs, Monitor monitor) - throws CompositeBuilderException { + + public void build(Composite composite, + Definitions definitions, + Map> bindingBaseURIs, + Monitor monitor) throws CompositeBuilderException { ((CompositeBuilderTmp)getBuilder()).build(composite, definitions, bindingBaseURIs, monitor); } @@ -137,14 +145,19 @@ public class DefaultCompositeBuilderExtensionPoint implements CompositeBuilderEx try { Class builderClass = (Class)builderDeclaration.loadClass(); try { - Constructor constructor = builderClass.getConstructor(FactoryExtensionPoint.class, InterfaceContractMapper.class); + Constructor constructor = + builderClass.getConstructor(FactoryExtensionPoint.class, InterfaceContractMapper.class); builder = constructor.newInstance(factories, mapper); } catch (NoSuchMethodException e) { try { - Constructor constructor = builderClass.getConstructor(CompositeBuilderExtensionPoint.class, FactoryExtensionPoint.class, InterfaceContractMapper.class); + Constructor constructor = + builderClass.getConstructor(CompositeBuilderExtensionPoint.class, + FactoryExtensionPoint.class, + InterfaceContractMapper.class); builder = constructor.newInstance(builders, factories, mapper); } catch (NoSuchMethodException ex) { - Constructor constructor = builderClass.getConstructor(ExtensionPointRegistry.class); + Constructor constructor = + builderClass.getConstructor(ExtensionPointRegistry.class); builder = constructor.newInstance(registry); } } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DomainBuilder.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DomainBuilder.java index 20a17e1bd0..655e18ad08 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DomainBuilder.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DomainBuilder.java @@ -31,7 +31,7 @@ import org.apache.tuscany.sca.assembly.Service; * @version $Rev: 563358 $ $Date: 2007-08-07 01:26:27 +0100 (Tue, 07 Aug 2007) $ */ public interface DomainBuilder { - + /** * Wire up the references and service in a domain returning a list * of the composites that have changed @@ -41,7 +41,7 @@ public interface DomainBuilder { * @throws CompositeBuilderException */ List wireDomain(Composite domainLevelComposite); - + /** * Locates the referenced service and updates the URI on the identified binding * @@ -50,8 +50,11 @@ public interface DomainBuilder { * @param bindingClassName * @param URI */ - void updateDomainLevelServiceURI(Composite domainLevelComposite, String referenceName, String bindingClassName, String URI); - + void updateDomainLevelServiceURI(Composite domainLevelComposite, + String referenceName, + String bindingClassName, + String URI); + /** * Get the component name out of the reference name that might look like Component/Service * @@ -59,7 +62,7 @@ public interface DomainBuilder { * @return */ String getComponentNameFromReference(String referenceName); - + /** * Get the service name out of the reference name that might look like Component/Service * @@ -67,7 +70,7 @@ public interface DomainBuilder { * @return */ String getServiceNameFromReference(String referenceName); - + /** * Find the service object given a reference name * @@ -76,5 +79,5 @@ public interface DomainBuilder { * @return */ Service findServiceForReference(Composite composite, String referenceName); - + } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointReferenceBuilder.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointReferenceBuilder.java index 220d82eab9..560672d8e4 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointReferenceBuilder.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointReferenceBuilder.java @@ -30,7 +30,7 @@ import org.apache.tuscany.sca.monitor.Monitor; * @version $Rev$ $Date$ */ public interface EndpointReferenceBuilder { - + /** * Build an endpoint reference matching reference bindings * with service bindings. @@ -39,5 +39,5 @@ public interface EndpointReferenceBuilder { * @param monitor */ void build(EndpointReference endpointReference, Monitor monitor); - + } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java index 84368b810f..b2debe6513 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java @@ -64,7 +64,6 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { protected DocumentBuilderFactory documentBuilderFactory; protected TransformerFactory transformerFactory; - protected BaseBuilderImpl(AssemblyFactory assemblyFactory, SCABindingFactory scaBindingFactory, DocumentBuilderFactory documentBuilderFactory, @@ -87,7 +86,13 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { */ protected void warning(Monitor monitor, String message, Object model, String... messageParameters) { if (monitor != null) { - Problem problem = monitor.createProblem(this.getClass().getName(), "assembly-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters); + Problem problem = + monitor.createProblem(this.getClass().getName(), + "assembly-validation-messages", + Severity.WARNING, + model, + message, + (Object[])messageParameters); monitor.problem(problem); } } @@ -102,7 +107,13 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { */ protected void error(Monitor monitor, String message, Object model, String... messageParameters) { if (monitor != null) { - Problem problem = monitor.createProblem(this.getClass().getName(), "assembly-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters); + Problem problem = + monitor.createProblem(this.getClass().getName(), + "assembly-validation-messages", + Severity.ERROR, + model, + message, + (Object[])messageParameters); monitor.problem(problem); } } @@ -117,7 +128,13 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { protected void error(Monitor monitor, String message, Object model, Exception ex) { if (monitor != null) { Problem problem = null; - problem = monitor.createProblem(this.getClass().getName(), "assembly-validation-messages", Severity.ERROR, model, message, ex); + problem = + monitor.createProblem(this.getClass().getName(), + "assembly-validation-messages", + Severity.ERROR, + model, + message, + ex); monitor.problem(problem); } } @@ -129,8 +146,7 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { * @param componentServices */ - protected void indexComponents(Composite composite, - Map components) { + protected void indexComponents(Composite composite, Map components) { for (Component component : composite.getComponents()) { // Index components by name components.put(component.getName(), component); @@ -143,8 +159,7 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { * @param composite * @param componentServices */ - protected void indexServices(Composite composite, - Map componentServices) { + protected void indexServices(Composite composite, Map componentServices) { for (Component component : composite.getComponents()) { @@ -173,7 +188,6 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { } } - /** * Index components, services and references inside a composite. * @param composite @@ -232,48 +246,46 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { } } - protected void indexComponentPropertiesServicesAndReferences( - Component component, - Map componentServices, - Map componentReferences, - Map componentProperties, Monitor monitor) { + protected void indexComponentPropertiesServicesAndReferences(Component component, + Map componentServices, + Map componentReferences, + Map componentProperties, + Monitor monitor) { for (ComponentService componentService : component.getServices()) { if (componentServices.containsKey(componentService.getName())) { - // [MJE 13/05/2009] Changed to "error" since allowing these violates the OASIS spec - error(monitor, "DuplicateComponentServiceName", component, - component.getName(), componentService.getName()); + // [MJE 13/05/2009] Changed to "error" since allowing these violates the OASIS spec + error(monitor, "DuplicateComponentServiceName", component, component.getName(), componentService + .getName()); } else { - componentServices.put(componentService.getName(), - componentService); + componentServices.put(componentService.getName(), componentService); } } for (ComponentReference componentReference : component.getReferences()) { if (componentReferences.containsKey(componentReference.getName())) { - // [MJE 13/05/2009] Changed to "error" since allowing these violates the OASIS spec - error(monitor, "DuplicateComponentReferenceName", component, - component.getName(), componentReference.getName()); + // [MJE 13/05/2009] Changed to "error" since allowing these violates the OASIS spec + error(monitor, "DuplicateComponentReferenceName", component, component.getName(), componentReference + .getName()); } else { - componentReferences.put(componentReference.getName(), - componentReference); + componentReferences.put(componentReference.getName(), componentReference); } } for (ComponentProperty componentProperty : component.getProperties()) { if (componentProperties.containsKey(componentProperty.getName())) { - // [MJE 13/05/2009] Changed to "error" since allowing these violates the OASIS spec - error(monitor, "DuplicateComponentPropertyName", component, - component.getName(), componentProperty.getName()); + // [MJE 13/05/2009] Changed to "error" since allowing these violates the OASIS spec + error(monitor, "DuplicateComponentPropertyName", component, component.getName(), componentProperty + .getName()); } else { - componentProperties.put(componentProperty.getName(), - componentProperty); + componentProperties.put(componentProperty.getName(), componentProperty); } } } - protected void indexImplementationPropertiesServicesAndReferences( - Component component, Map services, - Map references, - Map properties, Monitor monitor) { + protected void indexImplementationPropertiesServicesAndReferences(Component component, + Map services, + Map references, + Map properties, + Monitor monitor) { // First check that the component has a resolved implementation Implementation implementation = component.getImplementation(); if (implementation == null) { @@ -283,8 +295,7 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { } else if (implementation.isUnresolved()) { // The implementation must be fully resolved - error(monitor, "UnresolvedComponentImplementation", component, - component.getName(), implementation.getURI()); + error(monitor, "UnresolvedComponentImplementation", component, component.getName(), implementation.getURI()); } else { @@ -292,27 +303,27 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { // duplicates for (Property property : implementation.getProperties()) { if (properties.containsKey(property.getName())) { - // [MJE 13/05/2009] Changed to "error" since allowing these violates the OASIS spec - error(monitor, "DuplicateImplementationPropertyName", - component, component.getName(), property.getName()); + // [MJE 13/05/2009] Changed to "error" since allowing these violates the OASIS spec + error(monitor, "DuplicateImplementationPropertyName", component, component.getName(), property + .getName()); } else { properties.put(property.getName(), property); } } for (Service service : implementation.getServices()) { if (services.containsKey(service.getName())) { - // [MJE 13/05/2009] Changed to "error" since allowing these violates the OASIS spec - error(monitor, "DuplicateImplementationServiceName", - component, component.getName(), service.getName()); + // [MJE 13/05/2009] Changed to "error" since allowing these violates the OASIS spec + error(monitor, "DuplicateImplementationServiceName", component, component.getName(), service + .getName()); } else { services.put(service.getName(), service); } } for (Reference reference : implementation.getReferences()) { if (references.containsKey(reference.getName())) { - // [MJE 13/05/2009] Changed to "error" since allowing these violates the OASIS spec - error(monitor, "DuplicateImplementationReferenceName", - component, component.getName(), reference.getName()); + // [MJE 13/05/2009] Changed to "error" since allowing these violates the OASIS spec + error(monitor, "DuplicateImplementationReferenceName", component, component.getName(), reference + .getName()); } else { references.put(reference.getName(), reference); } @@ -331,9 +342,9 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { * @param problems */ protected void reconcileProperties(Component component, - Map properties, - Map componentProperties, - Monitor monitor) { + Map properties, + Map componentProperties, + Monitor monitor) { // Connect component properties to their properties for (ComponentProperty componentProperty : component.getProperties()) { @@ -368,7 +379,11 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { // Check that a component property does not override the // mustSupply attribute if (!property.isMustSupply() && componentProperty.isMustSupply()) { - warning(monitor, "PropertyMustSupplyIncompatible", component, component.getName(), componentProperty.getName()); + warning(monitor, + "PropertyMustSupplyIncompatible", + component, + component.getName(), + componentProperty.getName()); } // Default to the mustSupply attribute specified on the property @@ -381,20 +396,22 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { } // Override the property value for the composite - if(component.getImplementation() instanceof Composite) { + if (component.getImplementation() instanceof Composite) { property.setValue(componentProperty.getValue()); } // Check that a value is supplied if (componentProperty.getValue() == null && property.isMustSupply()) { - warning(monitor, "PropertyMustSupplyNull", component, component.getName(), componentProperty.getName()); + warning(monitor, "PropertyMustSupplyNull", component, component.getName(), componentProperty + .getName()); } // Check that a a component property does not override the // many attribute if (!property.isMany() && componentProperty.isMany()) { - warning(monitor, "PropertyOverrideManyAttribute", component, component.getName(), componentProperty.getName()); + warning(monitor, "PropertyOverrideManyAttribute", component, component.getName(), componentProperty + .getName()); } // Default to the many attribute defined on the property @@ -410,7 +427,8 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { // Check that a type or element are specified if (componentProperty.getXSDElement() == null && componentProperty.getXSDType() == null) { - warning(monitor, "NoTypeForComponentProperty", component, component.getName(), componentProperty.getName()); + warning(monitor, "NoTypeForComponentProperty", component, component.getName(), componentProperty + .getName()); } } } @@ -426,9 +444,9 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { * @param monitor */ protected void reconcileReferences(Component component, - Map references, - Map componentReferences, - Monitor monitor) { + Map references, + Map componentReferences, + Monitor monitor) { // Connect each component reference to the corresponding reference for (ComponentReference componentReference : component.getReferences()) { @@ -449,8 +467,7 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { if (component.getImplementation() != null) { for (Reference reference : component.getImplementation().getReferences()) { if (!componentReferences.containsKey(reference.getName())) { - ComponentReference componentReference = - assemblyFactory.createComponentReference(); + ComponentReference componentReference = assemblyFactory.createComponentReference(); componentReference.setIsCallback(reference.isCallback()); componentReference.setName(reference.getName()); componentReference.setReference(reference); @@ -466,9 +483,12 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { // Reconcile multiplicity if (componentReference.getMultiplicity() != null) { if (!ReferenceConfigurationUtil.isValidMultiplicityOverride(reference.getMultiplicity(), - componentReference - .getMultiplicity())) { - warning(monitor, "ReferenceIncompatibleMultiplicity", component, component.getName(), componentReference.getName()); + componentReference.getMultiplicity())) { + warning(monitor, + "ReferenceIncompatibleMultiplicity", + component, + component.getName(), + componentReference.getName()); } } else { componentReference.setMultiplicity(reference.getMultiplicity()); @@ -481,7 +501,11 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { .getInterfaceContract())) { if (!interfaceContractMapper.isCompatible(componentReference.getInterfaceContract(), interfaceContract)) { - warning(monitor, "ReferenceIncompatibleComponentInterface", component, component.getName(), componentReference.getName()); + warning(monitor, + "ReferenceIncompatibleComponentInterface", + component, + component.getName(), + componentReference.getName()); } } } else { @@ -501,10 +525,8 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { componentReference.setCallback(assemblyFactory.createCallback()); } - } else if (componentReference.getCallback().getBindings().isEmpty() && reference - .getCallback() != null) { - componentReference.getCallback().getBindings().addAll(reference.getCallback() - .getBindings()); + } else if (componentReference.getCallback().getBindings().isEmpty() && reference.getCallback() != null) { + componentReference.getCallback().getBindings().addAll(reference.getCallback().getBindings()); } // Propagate autowire setting from the component @@ -529,9 +551,9 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { * @param monitor */ protected void reconcileServices(Component component, - Map services, - Map componentServices, - Monitor monitor) { + Map services, + Map componentServices, + Monitor monitor) { // Connect each component service to the corresponding service for (ComponentService componentService : component.getServices()) { @@ -542,7 +564,8 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { if (service != null) { componentService.setService(service); } else { - warning(monitor, "ServiceNotFoundForComponentService", component, component.getName(), componentService.getName()); + warning(monitor, "ServiceNotFoundForComponentService", component, component.getName(), componentService + .getName()); } } @@ -571,8 +594,12 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { if (interfaceContract != null && !componentService.getInterfaceContract().equals(interfaceContract)) { if (!interfaceContractMapper.isCompatible(componentService.getInterfaceContract(), interfaceContract)) { - // MJE, 16/05/2009 - Upgraded from "warning" to "error" since this is a fatal problem - TUSCANY-3036 - error(monitor, "ServiceIncompatibleComponentInterface", component, component.getName(), componentService.getName()); + // MJE, 16/05/2009 - Upgraded from "warning" to "error" since this is a fatal problem - TUSCANY-3036 + error(monitor, + "ServiceIncompatibleComponentInterface", + component, + component.getName(), + componentService.getName()); } } } else { @@ -591,10 +618,8 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { // Create an empty callback to avoid null check componentService.setCallback(assemblyFactory.createCallback()); } - } else if (componentService.getCallback().getBindings().isEmpty() && service - .getCallback() != null) { - componentService.getCallback().getBindings().addAll(service.getCallback() - .getBindings()); + } else if (componentService.getCallback().getBindings().isEmpty() && service.getCallback() != null) { + componentService.getCallback().getBindings().addAll(service.getCallback().getBindings()); } } } @@ -605,13 +630,13 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { // mark the bindings that are added automatically so that they can // be disregarded for overriding purposes - if (scaBinding instanceof AutomaticBinding){ + if (scaBinding instanceof AutomaticBinding) { ((AutomaticBinding)scaBinding).setIsAutomatic(true); } - if ( definitions != null ) { - for ( ExtensionType attachPointType : definitions.getBindingTypes() ) { - if ( attachPointType.getType().equals(BINDING_SCA_QNAME)) { + if (definitions != null) { + for (ExtensionType attachPointType : definitions.getBindingTypes()) { + if (attachPointType.getType().equals(BINDING_SCA_QNAME)) { ((PolicySubject)scaBinding).setExtensionType(attachPointType); } } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java index fc769f5037..add4b09bb0 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java @@ -60,9 +60,7 @@ public class ComponentConfigurationBuilderImpl extends BaseBuilderImpl implement public ComponentConfigurationBuilderImpl(AssemblyFactory assemblyFactory, SCABindingFactory scaBindingFactory, InterfaceContractMapper interfaceContractMapper) { - super(assemblyFactory, scaBindingFactory, - null, null, - interfaceContractMapper); + super(assemblyFactory, scaBindingFactory, null, null, interfaceContractMapper); } public ComponentConfigurationBuilderImpl(AssemblyFactory assemblyFactory, @@ -70,11 +68,9 @@ public class ComponentConfigurationBuilderImpl extends BaseBuilderImpl implement DocumentBuilderFactory documentBuilderFactory, TransformerFactory transformerFactory, InterfaceContractMapper interfaceContractMapper) { - super(assemblyFactory, scaBindingFactory, - documentBuilderFactory, transformerFactory, - interfaceContractMapper); + super(assemblyFactory, scaBindingFactory, documentBuilderFactory, transformerFactory, interfaceContractMapper); } - + public String getID() { return "org.apache.tuscany.sca.assembly.builder.ComponentConfigurationBuilder"; } @@ -82,18 +78,19 @@ public class ComponentConfigurationBuilderImpl extends BaseBuilderImpl implement public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { configureComponents(composite, definitions, monitor); } - + /** * Configure components in the composite. * * @param composite * @param monitor */ - protected void configureComponents(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { + protected void configureComponents(Composite composite, Definitions definitions, Monitor monitor) + throws CompositeBuilderException { configureComponents(composite, null, definitions, monitor); configureSourcedProperties(composite, null); - } - + } + /** * Configure components in the composite. * @@ -128,7 +125,7 @@ public class ComponentConfigurationBuilderImpl extends BaseBuilderImpl implement List compositeServices = composite.getServices(); for (Service service : compositeServices) { // Set default binding names - + // Create default SCA binding if (service.getBindings().isEmpty()) { SCABinding scaBinding = createSCABinding(definitions); @@ -169,11 +166,7 @@ public class ComponentConfigurationBuilderImpl extends BaseBuilderImpl implement Map services = new HashMap(); Map references = new HashMap(); Map properties = new HashMap(); - indexImplementationPropertiesServicesAndReferences(component, - services, - references, - properties, - monitor); + indexImplementationPropertiesServicesAndReferences(component, services, references, properties, monitor); // Index component services, references and properties // Also check for duplicates @@ -222,22 +215,20 @@ public class ComponentConfigurationBuilderImpl extends BaseBuilderImpl implement } } } - } - + } + /** * For all the references with callbacks, create a corresponding callback * service. * * @param component */ - private void configureCallbackServices(Component component, - Map componentServices) { + private void configureCallbackServices(Component component, Map componentServices) { for (ComponentReference reference : component.getReferences()) { if (reference.getInterfaceContract() != null && // can be null in - // unit tests - reference.getInterfaceContract().getCallbackInterface() != null) { - ComponentService service = - componentServices.get(reference.getName()); + // unit tests + reference.getInterfaceContract().getCallbackInterface() != null) { + ComponentService service = componentServices.get(reference.getName()); if (service == null) { service = createCallbackService(component, reference); } @@ -262,8 +253,7 @@ public class ComponentConfigurationBuilderImpl extends BaseBuilderImpl implement componentService.setIsCallback(true); componentService.setName(reference.getName()); try { - InterfaceContract contract = - (InterfaceContract)reference.getInterfaceContract().clone(); + InterfaceContract contract = (InterfaceContract)reference.getInterfaceContract().clone(); contract.setInterface(contract.getCallbackInterface()); contract.setCallbackInterface(null); componentService.setInterfaceContract(contract); @@ -272,38 +262,38 @@ public class ComponentConfigurationBuilderImpl extends BaseBuilderImpl implement } Reference implReference = reference.getReference(); if (implReference != null) { - // If the implementation reference is a CompositeReference, ensure that the Service that is - // created is a CompositeService, otherwise create a Service - Service implService; - if( implReference instanceof CompositeReference ) { - CompositeService implCompService = assemblyFactory.createCompositeService(); - // TODO The reality here is that the composite reference which has the callback COULD promote more than - // one component reference - and there must be a separate composite callback service for each of these component - // references - // Set the promoted component from the promoted component of the composite reference - implCompService.setPromotedComponent(((CompositeReference) implReference).getPromotedComponents().get(0)); - implCompService.setIsCallback(true); - // Set the promoted service - ComponentService promotedService = assemblyFactory.createComponentService(); - promotedService.setName(((CompositeReference)implReference).getPromotedReferences().get(0).getName()); - promotedService.setUnresolved(true); - promotedService.setIsCallback(true); - implCompService.setPromotedService(promotedService); - implService = implCompService; - // Add the composite service to the composite implementation artifact - Implementation implementation = component.getImplementation(); - if( implementation != null && implementation instanceof Composite) { - ((Composite)implementation).getServices().add(implCompService); - } // end if - // - } else { - implService = assemblyFactory.createService(); - } // end if - // + // If the implementation reference is a CompositeReference, ensure that the Service that is + // created is a CompositeService, otherwise create a Service + Service implService; + if (implReference instanceof CompositeReference) { + CompositeService implCompService = assemblyFactory.createCompositeService(); + // TODO The reality here is that the composite reference which has the callback COULD promote more than + // one component reference - and there must be a separate composite callback service for each of these component + // references + // Set the promoted component from the promoted component of the composite reference + implCompService + .setPromotedComponent(((CompositeReference)implReference).getPromotedComponents().get(0)); + implCompService.setIsCallback(true); + // Set the promoted service + ComponentService promotedService = assemblyFactory.createComponentService(); + promotedService.setName(((CompositeReference)implReference).getPromotedReferences().get(0).getName()); + promotedService.setUnresolved(true); + promotedService.setIsCallback(true); + implCompService.setPromotedService(promotedService); + implService = implCompService; + // Add the composite service to the composite implementation artifact + Implementation implementation = component.getImplementation(); + if (implementation != null && implementation instanceof Composite) { + ((Composite)implementation).getServices().add(implCompService); + } // end if + // + } else { + implService = assemblyFactory.createService(); + } // end if + // implService.setName(implReference.getName()); try { - InterfaceContract implContract = - (InterfaceContract)implReference.getInterfaceContract().clone(); + InterfaceContract implContract = (InterfaceContract)implReference.getInterfaceContract().clone(); implContract.setInterface(implContract.getCallbackInterface()); implContract.setCallbackInterface(null); implService.setInterfaceContract(implContract); @@ -322,23 +312,22 @@ public class ComponentConfigurationBuilderImpl extends BaseBuilderImpl implement * @param component * @param componentReferences */ - private void configureCallbackReferences(Component component, - Map componentReferences) { + private void configureCallbackReferences(Component component, Map componentReferences) { for (ComponentService service : component.getServices()) { if (service.getInterfaceContract() != null && // can be null in unit tests - service.getInterfaceContract().getCallbackInterface() != null) { + service.getInterfaceContract().getCallbackInterface() != null) { ComponentReference reference = componentReferences.get(service.getName()); if (reference == null) { reference = createCallbackReference(component, service); } // end if // Set the bindings of the callback reference - if ( reference.getBindings().isEmpty() ) { - // If there are specific callback bindings set, use them - if (service.getCallback() != null) { + if (reference.getBindings().isEmpty()) { + // If there are specific callback bindings set, use them + if (service.getCallback() != null) { reference.getBindings().addAll(service.getCallback().getBindings()); } else { - // otherwise use the bindings on the forward service - reference.getBindings().addAll(service.getBindings()); + // otherwise use the bindings on the forward service + reference.getBindings().addAll(service.getBindings()); } // end if } // end if service.setCallbackReference(reference); @@ -366,36 +355,36 @@ public class ComponentConfigurationBuilderImpl extends BaseBuilderImpl implement } Service implService = service.getService(); if (implService != null) { - - // If the implementation service is a CompositeService, ensure that the Reference that is - // created is a CompositeReference, otherwise create a Reference - Reference implReference; - if( implService instanceof CompositeService ) { - CompositeReference implCompReference = assemblyFactory.createCompositeReference(); - // Set the promoted component from the promoted component of the composite service - implCompReference.getPromotedComponents().add(((CompositeService) implService).getPromotedComponent()); - // Set the promoted service - ComponentReference promotedReference = assemblyFactory.createComponentReference(); - String promotedRefName = ((CompositeService) implService).getPromotedComponent().getName() + "/" + - ((CompositeService)implService).getPromotedService().getName(); - promotedReference.setName(promotedRefName); - promotedReference.setUnresolved(true); - implCompReference.getPromotedReferences().add(promotedReference); - implReference = implCompReference; - // Add the composite reference to the composite implementation artifact - Implementation implementation = component.getImplementation(); - if( implementation != null && implementation instanceof Composite) { - ((Composite)implementation).getReferences().add(implCompReference); - } // end if - } else { - implReference = assemblyFactory.createReference(); - } // end if - // - + + // If the implementation service is a CompositeService, ensure that the Reference that is + // created is a CompositeReference, otherwise create a Reference + Reference implReference; + if (implService instanceof CompositeService) { + CompositeReference implCompReference = assemblyFactory.createCompositeReference(); + // Set the promoted component from the promoted component of the composite service + implCompReference.getPromotedComponents().add(((CompositeService)implService).getPromotedComponent()); + // Set the promoted service + ComponentReference promotedReference = assemblyFactory.createComponentReference(); + String promotedRefName = + ((CompositeService)implService).getPromotedComponent().getName() + "/" + + ((CompositeService)implService).getPromotedService().getName(); + promotedReference.setName(promotedRefName); + promotedReference.setUnresolved(true); + implCompReference.getPromotedReferences().add(promotedReference); + implReference = implCompReference; + // Add the composite reference to the composite implementation artifact + Implementation implementation = component.getImplementation(); + if (implementation != null && implementation instanceof Composite) { + ((Composite)implementation).getReferences().add(implCompReference); + } // end if + } else { + implReference = assemblyFactory.createReference(); + } // end if + // + implReference.setName(implService.getName()); try { - InterfaceContract implContract = - (InterfaceContract)implService.getInterfaceContract().clone(); + InterfaceContract implContract = (InterfaceContract)implService.getInterfaceContract().clone(); implContract.setInterface(implContract.getCallbackInterface()); implContract.setCallbackInterface(null); implReference.setInterfaceContract(implContract); @@ -423,11 +412,13 @@ public class ComponentConfigurationBuilderImpl extends BaseBuilderImpl implement compositeProperties.put(p.getName(), p); } } - + for (Component component : composite.getComponents()) { try { - PropertyConfigurationUtil.sourceComponentProperties(compositeProperties, component, - documentBuilderFactory, transformerFactory); + PropertyConfigurationUtil.sourceComponentProperties(compositeProperties, + component, + documentBuilderFactory, + transformerFactory); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -448,5 +439,5 @@ public class ComponentConfigurationBuilderImpl extends BaseBuilderImpl implement } } return null; - } + } } 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 734b373f11..ca9e55662a 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 @@ -44,24 +44,27 @@ public class ComponentReferenceBindingBuilderImpl implements CompositeBuilder { public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { buildReferenceBindings(composite, monitor); } - + public String getID() { return "org.apache.tuscany.sca.assembly.builder.ComponentReferenceBindingBuilder"; } private void buildReferenceBindings(Composite composite, Monitor monitor) { - + // 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()) { if (binding instanceof BindingBuilderExtension) { - ((BindingBuilderExtension)binding).getBuilder().build(component, componentReference, binding, monitor); + ((BindingBuilderExtension)binding).getBuilder().build(component, + componentReference, + binding, + monitor); } } } } - + // build bindings recursively for (Component component : composite.getComponents()) { Implementation implementation = component.getImplementation(); diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java index 8ae7906360..5a9b53593a 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java @@ -38,7 +38,6 @@ import org.apache.tuscany.sca.assembly.Multiplicity; 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.assembly.impl.SCABindingImpl; import org.apache.tuscany.sca.definitions.Definitions; import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; @@ -53,12 +52,13 @@ import org.apache.tuscany.sca.policy.PolicySet; */ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderImpl implements CompositeBuilder { - Monitor monitor; - // Testing - //boolean useNew = true; - boolean useNew = false; + Monitor monitor; + // Testing + //boolean useNew = true; + boolean useNew = false; - public ComponentReferenceEndpointReferenceBuilderImpl(AssemblyFactory assemblyFactory, InterfaceContractMapper interfaceContractMapper) { + public ComponentReferenceEndpointReferenceBuilderImpl(AssemblyFactory assemblyFactory, + InterfaceContractMapper interfaceContractMapper) { super(assemblyFactory, null, null, null, interfaceContractMapper); } @@ -71,13 +71,11 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI * * @param composite */ - public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException - { - this.monitor = monitor; + public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { + this.monitor = monitor; - - // process component services - processComponentReferences(composite); + // process component services + processComponentReferences(composite); } private void processComponentReferences(Composite composite) { @@ -94,7 +92,7 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI for (Component component : composite.getComponents()) { for (ComponentReference reference : component.getReferences()) { - createReferenceEndpointReferences2( composite, component, reference, components, componentServices); + createReferenceEndpointReferences2(composite, component, reference, components, componentServices); } // end for // recurse for composite implementations @@ -106,16 +104,16 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI // create endpoint references to represent the component reference for (ComponentReference reference : component.getReferences()) { - if( !useNew ) { - createReferenceEndpointReferences(composite, component, reference, components, componentServices); - } // end if + if (!useNew) { + createReferenceEndpointReferences(composite, component, reference, components, componentServices); + } // end if // fix up links between endpoints and endpoint references that represent callbacks - for (ComponentService service : component.getServices()){ - if ((service.getInterfaceContract() != null) && - (service.getInterfaceContract().getCallbackInterface() != null)){ - if ( reference.getName().equals(service.getName())){ - for ( Endpoint endpoint : service.getEndpoints()){ + for (ComponentService service : component.getServices()) { + if ((service.getInterfaceContract() != null) && (service.getInterfaceContract() + .getCallbackInterface() != null)) { + if (reference.getName().equals(service.getName())) { + for (Endpoint endpoint : service.getEndpoints()) { endpoint.getCallbackEndpointReferences().addAll(reference.getEndpointReferences()); } break; @@ -130,12 +128,10 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI Component component, ComponentReference reference, Map components, - Map componentServices) - { + Map componentServices) { // Get reference targets - List refTargets = getReferenceTargets( reference ); - if (reference.getAutowire() == Boolean.TRUE && - reference.getTargets().isEmpty()) { + List refTargets = getReferenceTargets(reference); + if (reference.getAutowire() == Boolean.TRUE && reference.getTargets().isEmpty()) { // Find suitable targets in the current composite for an // autowired reference @@ -143,44 +139,39 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI for (Component targetComponent : composite.getComponents()) { // Prevent autowire connecting to self - if( targetComponent == component ) continue; + if (targetComponent == component) + continue; for (ComponentService targetComponentService : targetComponent.getServices()) { - if (reference.getInterfaceContract() == null || - interfaceContractMapper.isCompatible(reference.getInterfaceContract(), - targetComponentService.getInterfaceContract())) { + if (reference.getInterfaceContract() == null || interfaceContractMapper.isCompatible(reference + .getInterfaceContract(), targetComponentService.getInterfaceContract())) { // create endpoint reference - with a dummy endpoint which will be replaced when policies // are matched and bindings are configured later - EndpointReference endpointRef = createEndpointRef( component, reference, false ); - endpointRef.setTargetEndpoint( createEndpoint(targetComponent, targetComponentService, true) ); + EndpointReference endpointRef = createEndpointRef(component, reference, false); + endpointRef.setTargetEndpoint(createEndpoint(targetComponent, targetComponentService, true)); endpointRef.setStatus(EndpointReference.WIRED_TARGET_FOUND_BUT_NOT_MATCHED); reference.getEndpointReferences().add(endpointRef); - // Stop with the first match for 0..1 and 1..1 references - if (multiplicity == Multiplicity.ZERO_ONE || - multiplicity == Multiplicity.ONE_ONE) { + if (multiplicity == Multiplicity.ZERO_ONE || multiplicity == Multiplicity.ONE_ONE) { break; } // end if } // end if } // end for } // end for - if (multiplicity == Multiplicity.ONE_N || - multiplicity == Multiplicity.ONE_ONE) { + if (multiplicity == Multiplicity.ONE_N || multiplicity == Multiplicity.ONE_ONE) { if (reference.getEndpointReferences().size() == 0) { - warning(monitor, "NoComponentReferenceTarget", - reference, - reference.getName()); + warning(monitor, "NoComponentReferenceTarget", reference, reference.getName()); } } } else if (!refTargets.isEmpty()) { // Check that the component reference does not mix the use of endpoint references - // specified via the target attribute with the presence of binding elements - if( bindingsIdentifyTargets( reference ) ) { - warning(monitor, "ReferenceEndPointMixWithTarget", - composite, composite.getName().toString(), component.getName(), reference.getName()); + // specified via the target attribute with the presence of binding elements + if (bindingsIdentifyTargets(reference)) { + warning(monitor, "ReferenceEndPointMixWithTarget", composite, composite.getName().toString(), component + .getName(), reference.getName()); } // Resolve targets specified on the component reference @@ -189,22 +180,22 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI String targetName = target.getName(); ComponentService targetComponentService = componentServices.get(targetName); - Component targetComponent = getComponentFromTargetName( components, targetName ); + Component targetComponent = getComponentFromTargetName(components, targetName); if (targetComponentService != null) { // Check that target component service provides a superset of the component reference interface - if (reference.getInterfaceContract() == null || - interfaceContractMapper.isCompatible(reference.getInterfaceContract(), - targetComponentService.getInterfaceContract())) { + if (reference.getInterfaceContract() == null || interfaceContractMapper.isCompatible(reference + .getInterfaceContract(), targetComponentService.getInterfaceContract())) { // create endpoint reference - with dummy endpoint which will be replaced when policies // are matched and bindings are configured later - EndpointReference endpointRef = createEndpointRef( component, reference, false ); + EndpointReference endpointRef = createEndpointRef(component, reference, false); endpointRef.setTargetEndpoint(createEndpoint(targetComponent, targetComponentService, true)); endpointRef.setStatus(EndpointReference.WIRED_TARGET_FOUND_BUT_NOT_MATCHED); reference.getEndpointReferences().add(endpointRef); } else { - warning(monitor, "ReferenceIncompatibleInterface", + warning(monitor, + "ReferenceIncompatibleInterface", composite, composite.getName().toString(), component.getName() + "." + reference.getName(), @@ -212,12 +203,13 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI } } else { // add an unresolved endpoint reference with an unresolved endpoint to go with it - EndpointReference endpointRef = createEndpointRef( component, reference, true ); + EndpointReference endpointRef = createEndpointRef(component, reference, true); endpointRef.setTargetEndpoint(createEndpoint(component, targetName)); endpointRef.setRemote(true); endpointRef.setStatus(EndpointReference.WIRED_TARGET_NOT_FOUND); reference.getEndpointReferences().add(endpointRef); - warning(monitor, "ComponentReferenceTargetNotFound", + warning(monitor, + "ComponentReferenceTargetNotFound", composite, composite.getName().toString(), targetName); @@ -234,15 +226,15 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI // user hasn't put a uri on the binding so it's not a target name and the assumption is that // the target is established via configuration of the binding element itself if (uri == null) { - // Regular forward references are UNWIRED with no endpoint if they have an SCABinding with NO targets - // and NO URI set - but Callbacks with an SCABinding are wired and need an endpoint - if( !reference.isCallback() && (binding instanceof SCABinding) ) continue; + // Regular forward references are UNWIRED with no endpoint if they have an SCABinding with NO targets + // and NO URI set - but Callbacks with an SCABinding are wired and need an endpoint + if (!reference.isCallback() && (binding instanceof SCABinding)) + continue; // create endpoint reference for manually configured bindings with a resolved endpoint to - // signify that this reference is pointing at some unwired endpoint - EndpointReference endpointRef = createEndpointRef( component, reference, - binding, null, false ); - if (binding instanceof SCABinding){ + // signify that this reference is pointing at some unwired endpoint + EndpointReference endpointRef = createEndpointRef(component, reference, binding, null, false); + if (binding instanceof SCABinding) { // Assume that the system need to resolve this binding later as // it's the SCA binding endpointRef.setTargetEndpoint(createEndpoint(true)); @@ -267,7 +259,7 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI // Resolve the target component and service ComponentService targetComponentService = componentServices.get(uri); - Component targetComponent = getComponentFromTargetName( components, uri ); + Component targetComponent = getComponentFromTargetName(components, uri); // If the binding URI matches a component in the composite, configure an endpoint reference with // this component as the target. @@ -276,17 +268,17 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI // Check that the target component service provides // a superset of the component reference interface - if (reference.getInterfaceContract() == null || - interfaceContractMapper.isCompatible(reference.getInterfaceContract(), - targetComponentService.getInterfaceContract())) { + if (reference.getInterfaceContract() == null || interfaceContractMapper.isCompatible(reference + .getInterfaceContract(), targetComponentService.getInterfaceContract())) { // create endpoint reference with dummy endpoint which will be replaced when policies // are matched and bindings are configured later - EndpointReference endpointRef = createEndpointRef( component, reference, binding, null, false ); + EndpointReference endpointRef = createEndpointRef(component, reference, binding, null, false); endpointRef.setTargetEndpoint(createEndpoint(targetComponent, targetComponentService, true)); endpointRef.setStatus(EndpointReference.WIRED_TARGET_FOUND_BUT_NOT_MATCHED); reference.getEndpointReferences().add(endpointRef); } else { - warning(monitor, "ReferenceIncompatibleInterface", + warning(monitor, + "ReferenceIncompatibleInterface", composite, composite.getName().toString(), reference.getName(), @@ -294,10 +286,10 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI } } else { // create endpoint reference for manually configured bindings with resolved endpoint - // to signify that this reference is pointing at some unwired endpoint. The endpoint + // to signify that this reference is pointing at some unwired endpoint. The endpoint // is given the configured binding as a representation of the endpoint configuration. - EndpointReference endpointRef = createEndpointRef( component, reference, binding, null, false ); - Endpoint endpoint = createEndpoint( false ); + EndpointReference endpointRef = createEndpointRef(component, reference, binding, null, false); + Endpoint endpoint = createEndpoint(false); endpoint.setBinding(binding); endpointRef.setTargetEndpoint(endpoint); endpointRef.setRemote(true); @@ -317,94 +309,101 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI * @param componentServices - a map of the component services in the composite */ private void createReferenceEndpointReferences2(Composite composite, - Component component, - ComponentReference reference, - Map components, - Map componentServices) - { - // Find all the leafmost component references related to this component reference - EndpointrefInfo refInfo = gatherEndpointrefInfo( component, reference, null ); - - List endpoints = getReferenceEndpoints( composite, component, - reference, components, componentServices ); - - Multiplicity multiplicity = reference.getMultiplicity(); + Component component, + ComponentReference reference, + Map components, + Map componentServices) { + // Find all the leafmost component references related to this component reference + EndpointrefInfo refInfo = gatherEndpointrefInfo(component, reference, null); + + List endpoints = + getReferenceEndpoints(composite, component, reference, components, componentServices); + + Multiplicity multiplicity = reference.getMultiplicity(); if (multiplicity == Multiplicity.ONE_N || multiplicity == Multiplicity.ONE_ONE) { - // If there are no endpoints defined and also no endpoint references already present - // then this reference is unwired, which is an error - the existing endpoint references - // will have been attached to a nested reference when a promoting reference has its endpoint - // references computed - if (endpoints.size() == 0 && !reference.isPromoted() ) { - warning(monitor, "ReferenceWithoutTargets", reference, - composite.getName().toString(), reference.getName()); + // If there are no endpoints defined and also no endpoint references already present + // then this reference is unwired, which is an error - the existing endpoint references + // will have been attached to a nested reference when a promoting reference has its endpoint + // references computed + if (endpoints.size() == 0 && !reference.isPromoted()) { + warning(monitor, "ReferenceWithoutTargets", reference, composite.getName().toString(), reference + .getName()); } // end if } // end if // An endpoint reference is created for the combination of each leafmost component reference and // each discovered endpoint - for( int i = 0; i < refInfo.getRefs().size(); i++ ) { - Component leafComponent = refInfo.getComponents().get(i); - ComponentReference leafReference = refInfo.getRefs().get(i); - boolean unresolved = false; - - for( Endpoint endpoint : endpoints ) { - if( endpoint.isUnresolved() && endpoint.getComponent() == null && endpoint.getService() == null ) { - unresolved = true; - } else { - unresolved = false; - } // end if - // Create an EndpointReference pointing at the endpoint - EndpointReference endRef = createEndpointRef( leafComponent, leafReference, - endpoint.getBinding(), endpoint, unresolved); - // Add the EndpointReference to the top level AND the leaf level reference, if not the same!! - if( useNew ) { - leafReference.getEndpointReferences().add( endRef ); - if( leafReference != reference ) { - reference.getEndpointReferences().add( endRef ); - } // end if - } // end if - // (Debug) For the moment, print out the results - // disable for the time being - SL - //System.out.println( "Created endpointRef. Component = " + component.getName() + " Reference = " + - // reference.getName() + " LeafComponent = " + endRef.getComponent().getName() + " LeafReference = " + - // endRef.getReference().getName() + " Binding = " + endRef.getBinding() + " target Component = " + - // endpoint.getComponent() + " target Service = " + endpoint.getService() ); - } // end for + for (int i = 0; i < refInfo.getRefs().size(); i++) { + Component leafComponent = refInfo.getComponents().get(i); + ComponentReference leafReference = refInfo.getRefs().get(i); + boolean unresolved = false; + + for (Endpoint endpoint : endpoints) { + if (endpoint.isUnresolved() && endpoint.getComponent() == null && endpoint.getService() == null) { + unresolved = true; + } else { + unresolved = false; + } // end if + // Create an EndpointReference pointing at the endpoint + EndpointReference endRef = + createEndpointRef(leafComponent, leafReference, endpoint.getBinding(), endpoint, unresolved); + // Add the EndpointReference to the top level AND the leaf level reference, if not the same!! + if (useNew) { + leafReference.getEndpointReferences().add(endRef); + if (leafReference != reference) { + reference.getEndpointReferences().add(endRef); + } // end if + } // end if + // (Debug) For the moment, print out the results + // disable for the time being - SL + //System.out.println( "Created endpointRef. Component = " + component.getName() + " Reference = " + + // reference.getName() + " LeafComponent = " + endRef.getComponent().getName() + " LeafReference = " + + // endRef.getReference().getName() + " Binding = " + endRef.getBinding() + " target Component = " + + // endpoint.getComponent() + " target Service = " + endpoint.getService() ); + } // end for } // end for } // end method createReferenceEndpointReferences2 - private List getReferenceEndpoints(Composite composite, Component component, - ComponentReference reference, Map components, - Map componentServices ) { - // Target services for a component reference are specified in one of a number of ways, in order: - // 1. Component services declared by the @target attribute of the reference - // 2. Service endpoints inside or outside the domain through bindings with configured endpoints - // 3. If @autowire=true is declared, component services within the composite containing the component which - // are compatible with the reference - // 1. takes precedence over 2. - 3. is only used if neither of the other applies - - List endpoints = new ArrayList(); - - // Get targets for references that are callbacks... - if( getReferenceCallbackEndpoints( composite, component, reference, - components, componentServices, endpoints ) ) { - - // Get reference targets declared by @target attribute - } else if ( getReferenceTargetEndpoints( composite, component, reference, - components, componentServices, endpoints ) ) { - - // TODO - need to ensure that elements are handled correctly - // Get reference targets identified by configured subelements - } else if ( getReferenceBindingEndpoints( composite, component, reference, - components, componentServices, endpoints )) { - - // Get reference targets identified by @autowire - } else { - getReferenceAutowireEndpoints( composite, component, reference, - components, componentServices, endpoints ); - } // end if - return endpoints; + private List getReferenceEndpoints(Composite composite, + Component component, + ComponentReference reference, + Map components, + Map componentServices) { + // Target services for a component reference are specified in one of a number of ways, in order: + // 1. Component services declared by the @target attribute of the reference + // 2. Service endpoints inside or outside the domain through bindings with configured endpoints + // 3. If @autowire=true is declared, component services within the composite containing the component which + // are compatible with the reference + // 1. takes precedence over 2. - 3. is only used if neither of the other applies + + List endpoints = new ArrayList(); + + // Get targets for references that are callbacks... + if (getReferenceCallbackEndpoints(composite, component, reference, components, componentServices, endpoints)) { + + // Get reference targets declared by @target attribute + } else if (getReferenceTargetEndpoints(composite, + component, + reference, + components, + componentServices, + endpoints)) { + + // TODO - need to ensure that elements are handled correctly + // Get reference targets identified by configured subelements + } else if (getReferenceBindingEndpoints(composite, + component, + reference, + components, + componentServices, + endpoints)) { + + // Get reference targets identified by @autowire + } else { + getReferenceAutowireEndpoints(composite, component, reference, components, componentServices, endpoints); + } // end if + return endpoints; } // end method getReferenceEndpoints /** @@ -417,22 +416,25 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI * @param endpoints - a list of the endpoints (in/out parameter) * @return - true if the reference is a callback reference, false otherwise */ - private boolean getReferenceCallbackEndpoints( Composite composite, Component component, - ComponentReference reference, Map components, - Map componentServices, List endpoints ) { - // Only if this reference is a callback are there any endpoints of this kind - if( reference.isCallback() ) { + private boolean getReferenceCallbackEndpoints(Composite composite, + Component component, + ComponentReference reference, + Map components, + Map componentServices, + List endpoints) { + // Only if this reference is a callback are there any endpoints of this kind + if (reference.isCallback()) { // add an unresolved endpoint reference with an unresolved endpoint to go with it - // there will be one of these for each binding on the reference - for( Binding binding : reference.getBindings() ) { - Endpoint endpoint = createEndpoint(true); - endpoint.setBinding(binding); - endpoints.add( endpoint ); - } // end for - return true; - } else { - return false; - } // end if + // there will be one of these for each binding on the reference + for (Binding binding : reference.getBindings()) { + Endpoint endpoint = createEndpoint(true); + endpoint.setBinding(binding); + endpoints.add(endpoint); + } // end for + return true; + } else { + return false; + } // end if } // end method getReferenceCallbackEndpoints @@ -446,50 +448,58 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI * @param endpoints - a list of the endpoints (in/out parameter) * @return true if the @target attribute was set, false otherwise */ - private boolean getReferenceTargetEndpoints( Composite composite, Component component, - ComponentReference reference, Map components, - Map componentServices, List endpoints ) { - - List refTargets = getReferenceTargets( reference ); - if ( !refTargets.isEmpty() ) { + private boolean getReferenceTargetEndpoints(Composite composite, + Component component, + ComponentReference reference, + Map components, + Map componentServices, + List endpoints) { + + List refTargets = getReferenceTargets(reference); + if (!refTargets.isEmpty()) { // Resolve targets specified on the component reference - for (ComponentService target : refTargets) { - - String targetName = target.getName(); - Component targetComponent = getComponentFromTargetName( components, targetName ); - ComponentService targetComponentService = componentServices.get(targetName); - - if (targetComponentService != null) { - // Check that target component service provides a superset of the component reference interface - if (InterfaceContractIsCompatible( reference, targetComponentService )) { - // create endpoint reference - with dummy endpoint which will be replaced when policies - // are matched and bindings are configured later - // TODO - Endpoint endpoint = selectTargetEndpoint( reference, targetComponentService ); - // SL - Turn off for now - //System.out.println("Selected Endpoint: component=" + endpoint.getComponent().getName() + - // " service=" + endpoint.getService().getName() + - // " binding=" + endpoint.getBinding().toString()); - Endpoint endpoint2 = createEndpoint(targetComponent, targetComponentService, true); - endpoint2.setBinding( endpoint.getBinding() ); - endpoints.add( endpoint2 ); - } else { - warning(monitor, "ReferenceIncompatibleInterface", - composite, composite.getName().toString(), - reference.getName(), targetName); - } - } else { - // add an unresolved endpoint reference with an unresolved endpoint to go with it - endpoints.add( createEndpoint(true) ); - warning(monitor, "ComponentReferenceTargetNotFound", - composite, composite.getName().toString(), - targetName); - } // end if - } // end for - return true; - } else { - return false; - } // end if + for (ComponentService target : refTargets) { + + String targetName = target.getName(); + Component targetComponent = getComponentFromTargetName(components, targetName); + ComponentService targetComponentService = componentServices.get(targetName); + + if (targetComponentService != null) { + // Check that target component service provides a superset of the component reference interface + if (InterfaceContractIsCompatible(reference, targetComponentService)) { + // create endpoint reference - with dummy endpoint which will be replaced when policies + // are matched and bindings are configured later + // TODO + Endpoint endpoint = selectTargetEndpoint(reference, targetComponentService); + // SL - Turn off for now + //System.out.println("Selected Endpoint: component=" + endpoint.getComponent().getName() + + // " service=" + endpoint.getService().getName() + + // " binding=" + endpoint.getBinding().toString()); + Endpoint endpoint2 = createEndpoint(targetComponent, targetComponentService, true); + endpoint2.setBinding(endpoint.getBinding()); + endpoints.add(endpoint2); + } else { + warning(monitor, + "ReferenceIncompatibleInterface", + composite, + composite.getName().toString(), + reference.getName(), + targetName); + } + } else { + // add an unresolved endpoint reference with an unresolved endpoint to go with it + endpoints.add(createEndpoint(true)); + warning(monitor, + "ComponentReferenceTargetNotFound", + composite, + composite.getName().toString(), + targetName); + } // end if + } // end for + return true; + } else { + return false; + } // end if } // end method getReferenceTargetEndpoints @@ -501,15 +511,15 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI * This will in practice select a particular binding on the service if there is more than one endpoint on the * service. If there are no matches, this method returns null */ - private Endpoint selectTargetEndpoint( ComponentReference reference, ComponentService service ) { + private Endpoint selectTargetEndpoint(ComponentReference reference, ComponentService service) { - // Return the first endpoint with a Binding which is compatible with the policy requirements on - // the reference - for( Endpoint endpoint : service.getEndpoints() ) { - return endpoint; - } //end for + // Return the first endpoint with a Binding which is compatible with the policy requirements on + // the reference + for (Endpoint endpoint : service.getEndpoints()) { + return endpoint; + } //end for - return null; + return null; } // end method selectTargetEndpoint /** @@ -522,11 +532,14 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI * @param endpoints - a list of the endpoints (in/out parameter) * @return true if the subelements identify target services, false otherwise */ - private boolean getReferenceBindingEndpoints( Composite composite, Component component, - ComponentReference reference, Map components, - Map componentServices, List endpoints ) { - // Get service endpoints declared by subelements - if( bindingsIdentifyTargets( reference ) ) { + private boolean getReferenceBindingEndpoints(Composite composite, + Component component, + ComponentReference reference, + Map components, + Map componentServices, + List endpoints) { + // Get service endpoints declared by subelements + if (bindingsIdentifyTargets(reference)) { for (Binding binding : reference.getBindings()) { String uri = binding.getURI(); @@ -534,25 +547,27 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI // user hasn't put a uri on the binding so it's not a target name and the assumption is that // the target is established via configuration of the binding element itself if (uri == null) { - // Regular forward references are UNWIRED with no endpoint if they have an SCABinding with NO targets - // and NO URI set - but Callbacks with an SCABinding are wired and need an endpoint - if( !reference.isCallback() && (binding instanceof SCABinding) ) continue; + // Regular forward references are UNWIRED with no endpoint if they have an SCABinding with NO targets + // and NO URI set - but Callbacks with an SCABinding are wired and need an endpoint + if (!reference.isCallback() && (binding instanceof SCABinding)) + continue; // create an unwired endpoint containing the binding - Endpoint endpoint = createEndpoint( false ); - endpoint.setBinding( binding ); - endpoints.add( endpoint ); + Endpoint endpoint = createEndpoint(false); + endpoint.setBinding(binding); + endpoints.add(endpoint); continue; } // end if // user might have put a local target name in the uri - see if it refers to a target we know about // - if it does the reference binding will be matched with a service binding // - if it doesn't it is assumed to be an external reference - if (uri.startsWith("/")) uri = uri.substring(1); + if (uri.startsWith("/")) + uri = uri.substring(1); // Resolve the target component and service ComponentService targetComponentService = componentServices.get(uri); - Component targetComponent = getComponentFromTargetName( components, uri ); + Component targetComponent = getComponentFromTargetName(components, uri); // If the binding URI matches a component in the composite, configure an endpoint reference with // this component as the target. @@ -560,24 +575,27 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI if (targetComponentService != null) { // Check that the target component service provides // a superset of the component reference interface - if (InterfaceContractIsCompatible( reference, targetComponentService )) { + if (InterfaceContractIsCompatible(reference, targetComponentService)) { // create dummy endpoint which will be replaced when policies // are matched and bindings are configured later - endpoints.add( createEndpoint(targetComponent, targetComponentService, true) ); + endpoints.add(createEndpoint(targetComponent, targetComponentService, true)); } else { - warning(monitor, "ReferenceIncompatibleInterface", - composite, composite.getName().toString(), - reference.getName(), uri); + warning(monitor, + "ReferenceIncompatibleInterface", + composite, + composite.getName().toString(), + reference.getName(), + uri); } // end if } else { // create resolved endpoint to signify that this reference is pointing at some unwired endpoint - endpoints.add( createEndpoint( false ) ); + endpoints.add(createEndpoint(false)); } // end if } // end for - return true; - } else { - return false; - } // end if + return true; + } else { + return false; + } // end if } // end method getReferenceBindingEndpoints @@ -591,36 +609,39 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI * @param endpoints - a list of the endpoints (in/out parameter) * @return true if the @autowire attribute was set, false otherwise */ - private boolean getReferenceAutowireEndpoints( Composite composite, Component component, - ComponentReference reference, Map components, - Map componentServices, List endpoints ) { - // Get compatible target services if @autowire=true is specified - if ( reference.getAutowire() == Boolean.TRUE ) { + private boolean getReferenceAutowireEndpoints(Composite composite, + Component component, + ComponentReference reference, + Map components, + Map componentServices, + List endpoints) { + // Get compatible target services if @autowire=true is specified + if (reference.getAutowire() == Boolean.TRUE) { Multiplicity multiplicity = reference.getMultiplicity(); for (Component targetComponent : composite.getComponents()) { // Prevent autowire connecting to self - if( targetComponent == component ) continue; + if (targetComponent == component) + continue; for (ComponentService targetComponentService : targetComponent.getServices()) { - if (InterfaceContractIsCompatible( reference, targetComponentService )) { + if (InterfaceContractIsCompatible(reference, targetComponentService)) { // create endpoint reference - with a dummy endpoint which will be replaced when policies // are matched and bindings are configured later - endpoints.add( createEndpoint(targetComponent, targetComponentService, true) ); + endpoints.add(createEndpoint(targetComponent, targetComponentService, true)); // Stop with the first match for 0..1 and 1..1 references - if (multiplicity == Multiplicity.ZERO_ONE || - multiplicity == Multiplicity.ONE_ONE) { + if (multiplicity == Multiplicity.ZERO_ONE || multiplicity == Multiplicity.ONE_ONE) { break; } // end if } // end if } // end for } // end for - return true; - } else { - return false; - } // end if + return true; + } else { + return false; + } // end if } // end method getReferenceAutowireEndpoints @@ -631,10 +652,10 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI * @param service - the component service * @return - true if the interface of the service is a compatible superset of the interface of the reference, false otherwise */ - private boolean InterfaceContractIsCompatible( ComponentReference reference, ComponentService service ) { - if (reference.getInterfaceContract() == null ) return true; - return interfaceContractMapper.isCompatible(reference.getInterfaceContract(), - service.getInterfaceContract()); + private boolean InterfaceContractIsCompatible(ComponentReference reference, ComponentService service) { + if (reference.getInterfaceContract() == null) + return true; + return interfaceContractMapper.isCompatible(reference.getInterfaceContract(), service.getInterfaceContract()); } // end method InterfaceContractIsCompatible /** @@ -647,37 +668,42 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI * @return - an EndpointrefInfo - the same object as the refInfo parameter, unless that parameter is null in which case * it is a new object */ - private EndpointrefInfo gatherEndpointrefInfo( Component component, ComponentReference reference, EndpointrefInfo refInfo ) { - if( refInfo == null ) refInfo = new EndpointrefInfo(); - // Deal with the cases where there is an error in the configuration - if( reference.isUnresolved() ) return refInfo; - - refInfo.setContract(reference.getInterfaceContract()); - // RULE: If the interface contract is not already set at this level, then it must be - // identical across all the next level elements - otherwise they can be subsets - boolean equalInterfaces = false; - if( refInfo.getContract() == null ) equalInterfaces = true; - - refInfo.addIntents(reference.getRequiredIntents()); - if( reference.getReference() instanceof CompositeReference ) { - // It's a composite reference - get hold of the set of promoted references - CompositeReference compRef = (CompositeReference)reference.getReference(); - List components = compRef.getPromotedComponents(); - List componentRefs = compRef.getPromotedReferences(); - // Scan over all promoted references - for( int i = 0; i < componentRefs.size(); i++ ) { - refInfo.setContractEqual( equalInterfaces ); - gatherEndpointrefInfo( components.get(i), componentRefs.get(i), refInfo ); - } // end for - } else { - // Otherwise it's a leaf node reference which must be recorded as an endpoint reference - refInfo.addRef(reference); - refInfo.addComponent(component); - } // end if - // RULE: Any PolicySets at this level override PolicySets from lower levels - refInfo.setPolicySets(reference.getPolicySets()); - - return refInfo; + private EndpointrefInfo gatherEndpointrefInfo(Component component, + ComponentReference reference, + EndpointrefInfo refInfo) { + if (refInfo == null) + refInfo = new EndpointrefInfo(); + // Deal with the cases where there is an error in the configuration + if (reference.isUnresolved()) + return refInfo; + + refInfo.setContract(reference.getInterfaceContract()); + // RULE: If the interface contract is not already set at this level, then it must be + // identical across all the next level elements - otherwise they can be subsets + boolean equalInterfaces = false; + if (refInfo.getContract() == null) + equalInterfaces = true; + + refInfo.addIntents(reference.getRequiredIntents()); + if (reference.getReference() instanceof CompositeReference) { + // It's a composite reference - get hold of the set of promoted references + CompositeReference compRef = (CompositeReference)reference.getReference(); + List components = compRef.getPromotedComponents(); + List componentRefs = compRef.getPromotedReferences(); + // Scan over all promoted references + for (int i = 0; i < componentRefs.size(); i++) { + refInfo.setContractEqual(equalInterfaces); + gatherEndpointrefInfo(components.get(i), componentRefs.get(i), refInfo); + } // end for + } else { + // Otherwise it's a leaf node reference which must be recorded as an endpoint reference + refInfo.addRef(reference); + refInfo.addComponent(component); + } // end if + // RULE: Any PolicySets at this level override PolicySets from lower levels + refInfo.setPolicySets(reference.getPolicySets()); + + return refInfo; } // end method gatherEndpointrefInfo /** @@ -687,91 +713,91 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI * @author MikeEdwards */ private class EndpointrefInfo { - private List components = new ArrayList(); - private List refs = new ArrayList(); - private InterfaceContract contract = null; - private List intents = new ArrayList(); - private List policySets = null; - private boolean contractEqual = false; - - /** - * Sets whether new contracts must be equal to the current contract or not - * @param isEqual - true means that Contracts must be equal to the current contract - false means that Contracts - * can be subsets of the current contract - */ - void setContractEqual( boolean isEqual ) { - contractEqual = isEqual; - } - - boolean getContractEqual() { - return contractEqual; - } - - List getPolicySets() { - return policySets; - } - - void setPolicySets(List policySets) { - this.policySets = policySets; - } - - List getComponents() { - return components; - } - - void addComponent(Component component) { - this.components.add( component ); - } - - List getRefs() { - return refs; - } - - void addRef(ComponentReference ref) { - this.refs.add( ref ); - } - - InterfaceContract getContract() { - return contract; - } - - /** - * Set the contract - with checking of the contract if a contract is already set - * @param contract - the contract to set - */ - void setContract(InterfaceContract contract) { - // Add the contract if there is no existing contract set - if( this.contract == null ) { - this.contract = contract; - } else { - // RULE: Raise an error if the new contract is not a subset of the existing contract - if( contractEqual ) { - // Contracts must be equal - if( !interfaceContractMapper.isEqual( this.contract, contract ) ) { - warning(monitor, "ReferencePromotionInterfacesNotEqual", - this.contract.toString(), contract.toString() ); - } // end if - } else { - // Contract must be subset - if( !interfaceContractMapper.isCompatible( contract, this.contract ) ) { - warning(monitor, "ReferencePromotionIncompatibleInterface", - this.contract.toString(), contract.toString() ); - } // end if - } // end if - } // end if - } - - List getIntents() { - return intents; - } - /** - * Accumulate intents - * @param intents - */ - void addIntents(List intents) { - this.intents.addAll( intents ); - } + private List components = new ArrayList(); + private List refs = new ArrayList(); + private InterfaceContract contract = null; + private List intents = new ArrayList(); + private List policySets = null; + private boolean contractEqual = false; + + /** + * Sets whether new contracts must be equal to the current contract or not + * @param isEqual - true means that Contracts must be equal to the current contract - false means that Contracts + * can be subsets of the current contract + */ + void setContractEqual(boolean isEqual) { + contractEqual = isEqual; + } + + boolean getContractEqual() { + return contractEqual; + } + + List getPolicySets() { + return policySets; + } + + void setPolicySets(List policySets) { + this.policySets = policySets; + } + + List getComponents() { + return components; + } + + void addComponent(Component component) { + this.components.add(component); + } + List getRefs() { + return refs; + } + + void addRef(ComponentReference ref) { + this.refs.add(ref); + } + + InterfaceContract getContract() { + return contract; + } + + /** + * Set the contract - with checking of the contract if a contract is already set + * @param contract - the contract to set + */ + void setContract(InterfaceContract contract) { + // Add the contract if there is no existing contract set + if (this.contract == null) { + this.contract = contract; + } else { + // RULE: Raise an error if the new contract is not a subset of the existing contract + if (contractEqual) { + // Contracts must be equal + if (!interfaceContractMapper.isEqual(this.contract, contract)) { + warning(monitor, "ReferencePromotionInterfacesNotEqual", this.contract.toString(), contract + .toString()); + } // end if + } else { + // Contract must be subset + if (!interfaceContractMapper.isCompatible(contract, this.contract)) { + warning(monitor, "ReferencePromotionIncompatibleInterface", this.contract.toString(), contract + .toString()); + } // end if + } // end if + } // end if + } + + List getIntents() { + return intents; + } + + /** + * Accumulate intents + * @param intents + */ + void addIntents(List intents) { + this.intents.addAll(intents); + } } // end class EndpointrefInfo @@ -780,15 +806,16 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI * @param reference - the reference * @return true if the bindings identify a target, false otherwise */ - private boolean bindingsIdentifyTargets( ComponentReference reference ) { - for( Binding binding : reference.getBindings() ) { - // getReferenceTargets( ComponentReference reference ) { - List theTargets = reference.getTargets(); - if( theTargets.isEmpty() ) { - // Component reference list of targets is empty, try the implementation reference - if( reference.getReference() != null ) { - theTargets = reference.getReference().getTargets(); - } // end if - } // end if - return theTargets; + private List getReferenceTargets(ComponentReference reference) { + List theTargets = reference.getTargets(); + if (theTargets.isEmpty()) { + // Component reference list of targets is empty, try the implementation reference + if (reference.getReference() != null) { + theTargets = reference.getReference().getTargets(); + } // end if + } // end if + return theTargets; } // end method getReferenceTargets /** @@ -813,15 +840,15 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI * @param targetName * @return the component */ - private Component getComponentFromTargetName( Map components, String targetName ) { - Component theComponent; + private Component getComponentFromTargetName(Map components, String targetName) { + Component theComponent; int s = targetName.indexOf('/'); if (s == -1) { - theComponent = components.get(targetName); + theComponent = components.get(targetName); } else { - theComponent = components.get(targetName.substring(0, s)); + theComponent = components.get(targetName.substring(0, s)); } - return theComponent; + return theComponent; } // end method getComponentFromTargetName /** @@ -833,9 +860,12 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI * @param unresolved * @return the endpoint reference */ - private EndpointReference createEndpointRef( Component component, ComponentReference reference, - Binding binding, Endpoint endpoint, boolean unresolved ) { - EndpointReference endpointRef = createEndpointRef( component, reference, unresolved ); + private EndpointReference createEndpointRef(Component component, + ComponentReference reference, + Binding binding, + Endpoint endpoint, + boolean unresolved) { + EndpointReference endpointRef = createEndpointRef(component, reference, unresolved); endpointRef.setBinding(binding); endpointRef.setTargetEndpoint(endpoint); return endpointRef; @@ -848,15 +878,14 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI * @param unresolved * @return the endpoint reference */ - private EndpointReference createEndpointRef( Component component, ComponentReference reference, boolean unresolved ) { - EndpointReference endpointRef = assemblyFactory.createEndpointReference(); - endpointRef.setComponent(component); - endpointRef.setReference(reference); - endpointRef.setUnresolved(unresolved); - return endpointRef; + private EndpointReference createEndpointRef(Component component, ComponentReference reference, boolean unresolved) { + EndpointReference endpointRef = assemblyFactory.createEndpointReference(); + endpointRef.setComponent(component); + endpointRef.setReference(reference); + endpointRef.setUnresolved(unresolved); + return endpointRef; } // end method createEndpointRef - /** * Helper method to create an endpoint * @param component @@ -864,12 +893,12 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI * @param unresolved * @return the endpoint */ - private Endpoint createEndpoint( Component component, ComponentService service, boolean unresolved) { - Endpoint endpoint = createEndpoint( unresolved); - endpoint.setComponent(component); - endpoint.setService(service); - endpoint.setUnresolved(unresolved); - return endpoint; + private Endpoint createEndpoint(Component component, ComponentService service, boolean unresolved) { + Endpoint endpoint = createEndpoint(unresolved); + endpoint.setComponent(component); + endpoint.setService(service); + endpoint.setUnresolved(unresolved); + return endpoint; } // end method createEndpoint /** @@ -877,10 +906,10 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI * @param unresolved * @return the endpoint */ - private Endpoint createEndpoint( boolean unresolved) { - Endpoint endpoint = assemblyFactory.createEndpoint(); - endpoint.setUnresolved(unresolved); - return endpoint; + private Endpoint createEndpoint(boolean unresolved) { + Endpoint endpoint = assemblyFactory.createEndpoint(); + endpoint.setUnresolved(unresolved); + return endpoint; } // end method createEndpoint /** @@ -932,5 +961,4 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI return endpoint; } // end method createEndpoint - } // end class diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionBuilderImpl.java index eb06f67f8e..fb723bf43c 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionBuilderImpl.java @@ -61,7 +61,7 @@ public class ComponentReferencePromotionBuilderImpl implements CompositeBuilder * @param problems */ private void configureNestedCompositeReferences(Composite composite, Monitor monitor) { - + // Process nested composites recursively for (Component component : composite.getComponents()) { Implementation implementation = component.getImplementation(); @@ -69,7 +69,7 @@ public class ComponentReferencePromotionBuilderImpl implements CompositeBuilder configureNestedCompositeReferences((Composite)implementation, monitor); } } - + // Process component references declared on components in this composite for (Component component : composite.getComponents()) { Implementation implementation = component.getImplementation(); @@ -82,7 +82,7 @@ public class ComponentReferencePromotionBuilderImpl implements CompositeBuilder if (!componentReference.getEndpointReferences().isEmpty()) { componentReference.setPromotionOverride(true); } - + // If the component reference is a promotion override, override the // configuration of the promoted reference if (componentReference.isPromotionOverride()) { @@ -90,11 +90,14 @@ public class ComponentReferencePromotionBuilderImpl implements CompositeBuilder List promotedReferences = ReferenceConfigurationUtil.getPromotedComponentReferences(compositeReference); for (ComponentReference promotedReference : promotedReferences) { - ReferenceConfigurationUtil.reconcileReferenceBindings( - componentReference, promotedReference, assemblyFactory, monitor); + ReferenceConfigurationUtil.reconcileReferenceBindings(componentReference, + promotedReference, + assemblyFactory, + monitor); if (componentReference.getInterfaceContract() != null && // can be null in unit tests - componentReference.getInterfaceContract().getCallbackInterface() != null) { - SCABinding scaCallbackBinding = promotedReference.getCallbackBinding(SCABinding.class); + componentReference.getInterfaceContract().getCallbackInterface() != null) { + SCABinding scaCallbackBinding = + promotedReference.getCallbackBinding(SCABinding.class); if (promotedReference.getCallback() != null) { promotedReference.getCallback().getBindings().clear(); } else { @@ -108,56 +111,56 @@ public class ComponentReferencePromotionBuilderImpl implements CompositeBuilder .getCallback().getBindings()); } } - /* TODO - let endpoint references worry about target service - // 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); - } - } -*/ + /* TODO - let endpoint references worry about target service + // 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 { -/* TODO - let endpoint references worry about target servicep - for (ComponentReference componentReference : component.getReferences()) { - - // Wire the component reference to the actual - // non-composite component services - List 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); - } - } - } - } -*/ + /* TODO - let endpoint references worry about target servicep + for (ComponentReference componentReference : component.getReferences()) { + + // Wire the component reference to the actual + // non-composite component services + List 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/ComponentReferencePromotionWireBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionWireBuilderImpl.java index 5552fda286..87e622ee35 100644 --- 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 @@ -61,7 +61,7 @@ public class ComponentReferencePromotionWireBuilderImpl implements CompositeBuil * @param problems */ private void wireCompositeReferences(Composite composite, Monitor monitor) { - + // Process nested composites recursively for (Component component : composite.getComponents()) { Implementation implementation = component.getImplementation(); @@ -69,7 +69,7 @@ public class ComponentReferencePromotionWireBuilderImpl implements CompositeBuil wireCompositeReferences((Composite)implementation, monitor); } } - + // Process component references declared on components in this composite for (Component component : composite.getComponents()) { Implementation implementation = component.getImplementation(); @@ -82,7 +82,7 @@ public class ComponentReferencePromotionWireBuilderImpl implements CompositeBuil if (!componentReference.getEndpointReferences().isEmpty()) { componentReference.setPromotionOverride(true); } - + // If the component reference is a promotion override, override the // configuration of the promoted reference if (componentReference.isPromotionOverride()) { @@ -90,11 +90,14 @@ public class ComponentReferencePromotionWireBuilderImpl implements CompositeBuil List promotedReferences = ReferenceConfigurationUtil.getPromotedComponentReferences(compositeReference); for (ComponentReference promotedReference : promotedReferences) { - ReferenceConfigurationUtil.reconcileReferenceBindings( - componentReference, promotedReference, assemblyFactory, monitor); + ReferenceConfigurationUtil.reconcileReferenceBindings(componentReference, + promotedReference, + assemblyFactory, + monitor); if (componentReference.getInterfaceContract() != null && // can be null in unit tests - componentReference.getInterfaceContract().getCallbackInterface() != null) { - SCABinding scaCallbackBinding = promotedReference.getCallbackBinding(SCABinding.class); + componentReference.getInterfaceContract().getCallbackInterface() != null) { + SCABinding scaCallbackBinding = + promotedReference.getCallbackBinding(SCABinding.class); if (promotedReference.getCallback() != null) { promotedReference.getCallback().getBindings().clear(); } else { @@ -108,56 +111,56 @@ public class ComponentReferencePromotionWireBuilderImpl implements CompositeBuil .getCallback().getBindings()); } } - /* TODO - let endpoint references worry about target service - // 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); - } - } -*/ + /* TODO - let endpoint references worry about target service + // 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 { -/* TODO - let endpoint references worry about target servicep - for (ComponentReference componentReference : component.getReferences()) { - - // Wire the component reference to the actual - // non-composite component services - List 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); - } - } - } - } -*/ + /* TODO - let endpoint references worry about target servicep + for (ComponentReference componentReference : component.getReferences()) { + + // Wire the component reference to the actual + // non-composite component services + List 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/ComponentReferenceWireBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java index dc0a9298fa..f97ed8d474 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java @@ -44,8 +44,9 @@ import org.apache.tuscany.sca.monitor.Monitor; * @version $Rev$ $Date$ */ public class ComponentReferenceWireBuilderImpl extends BaseBuilderImpl implements CompositeBuilder { - - public ComponentReferenceWireBuilderImpl(AssemblyFactory assemblyFactory, InterfaceContractMapper interfaceContractMapper) { + + public ComponentReferenceWireBuilderImpl(AssemblyFactory assemblyFactory, + InterfaceContractMapper interfaceContractMapper) { super(assemblyFactory, null, null, null, interfaceContractMapper); } @@ -56,7 +57,7 @@ public class ComponentReferenceWireBuilderImpl extends BaseBuilderImpl implement public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { wireComponentReferences(composite, monitor); } - + /** * Wire component references to component services and connect promoted * services/references to component services/references inside a composite. @@ -82,12 +83,12 @@ public class ComponentReferenceWireBuilderImpl extends BaseBuilderImpl implement // Connect component references as described in wires connectWires(composite, componentServices, componentReferences, monitor); - // Validate that references are wired or promoted, according // to their multiplicity for (ComponentReference componentReference : componentReferences.values()) { - if (!ReferenceConfigurationUtil.validateMultiplicityAndTargets(componentReference.getMultiplicity(), componentReference - .getTargets(), componentReference.getBindings())) { + if (!ReferenceConfigurationUtil.validateMultiplicityAndTargets(componentReference.getMultiplicity(), + componentReference.getTargets(), + componentReference.getBindings())) { if (componentReference.getTargets().isEmpty()) { // No warning if the reference is promoted out of the current composite @@ -100,22 +101,25 @@ public class ComponentReferenceWireBuilderImpl extends BaseBuilderImpl implement } } if (!promoted && !componentReference.isCallback()) { - warning(monitor, "ReferenceWithoutTargets", composite, composite.getName().toString(), - componentReference.getName()); + warning(monitor, + "ReferenceWithoutTargets", + composite, + composite.getName().toString(), + componentReference.getName()); } } else { warning(monitor, "TooManyReferenceTargets", composite, componentReference.getName()); } } } - + // Finally clear the original reference target lists as we now have // bindings to represent the targets - // for (ComponentReference componentReference : componentReferences.values()) { - // componentReference.getTargets().clear(); - // } - } - + // for (ComponentReference componentReference : componentReferences.values()) { + // componentReference.getTargets().clear(); + // } + } + /** * Resolve wires and connect the sources to their targets * @@ -128,16 +132,16 @@ public class ComponentReferenceWireBuilderImpl extends BaseBuilderImpl implement Map componentServices, Map componentReferences, Monitor monitor) { - + // For each wire, resolve the source reference, the target service, and // add it to the list of targets of the reference List wires = composite.getWires(); for (int i = 0, n = wires.size(); i < n; i++) { Wire wire = wires.get(i); - + ComponentReference resolvedReference; ComponentService resolvedService; - + // Resolve the source reference ComponentReference source = wire.getSource(); if (source != null && source.isUnresolved()) { @@ -150,7 +154,7 @@ public class ComponentReferenceWireBuilderImpl extends BaseBuilderImpl implement } else { resolvedReference = wire.getSource(); } - + // Resolve the target service ComponentService target = wire.getTarget(); if (target != null && target.isUnresolved()) { @@ -163,7 +167,7 @@ public class ComponentReferenceWireBuilderImpl extends BaseBuilderImpl implement } else { resolvedService = wire.getTarget(); } - + // Add the target service to the list of targets of the // reference if (resolvedReference != null && resolvedService != null) { @@ -172,7 +176,7 @@ public class ComponentReferenceWireBuilderImpl extends BaseBuilderImpl implement // the component reference interface if (resolvedReference.getInterfaceContract() == null || interfaceContractMapper .isCompatible(resolvedReference.getInterfaceContract(), resolvedService.getInterfaceContract())) { - + //resolvedReference.getTargets().add(resolvedService); resolvedReference.getTargets().add(wire.getTarget()); } else { @@ -180,9 +184,9 @@ public class ComponentReferenceWireBuilderImpl extends BaseBuilderImpl implement } } } - + // Clear the list of wires composite.getWires().clear(); } - + } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceBindingBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceBindingBuilderImpl.java index c725ea8947..613b39171f 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceBindingBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceBindingBuilderImpl.java @@ -49,9 +49,9 @@ public class ComponentServiceBindingBuilderImpl implements CompositeBuilder { public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { buildServiceBindings(composite, monitor); } - + private void buildServiceBindings(Composite composite, Monitor monitor) { - + // build bindings recursively for (Component component : composite.getComponents()) { Implementation implementation = component.getImplementation(); diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceEndpointBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceEndpointBuilderImpl.java index 00674b1f27..fd04c809ca 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceEndpointBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceEndpointBuilderImpl.java @@ -29,9 +29,7 @@ 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.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.assembly.Service; import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; @@ -48,10 +46,10 @@ import org.apache.tuscany.sca.policy.PolicySet; */ public class ComponentServiceEndpointBuilderImpl implements CompositeBuilder { private AssemblyFactory assemblyFactory; - - // Testing - //boolean useNew = true; - boolean useNew = false; + + // Testing + //boolean useNew = true; + boolean useNew = false; public ComponentServiceEndpointBuilderImpl(AssemblyFactory assemblyFactory) { this.assemblyFactory = assemblyFactory; @@ -69,19 +67,19 @@ public class ComponentServiceEndpointBuilderImpl implements CompositeBuilder { * @param monitor - a Monitor for logging errors */ public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { - + // process component services - if( !useNew ) { - processComponentServices(composite); - } // end if - processComponentServices2( composite ); - + if (!useNew) { + processComponentServices(composite); + } // end if + processComponentServices2(composite); + } // end method build - + private void processComponentServices(Composite composite) { for (Component component : composite.getComponents()) { - + // recurse for composite implementations Implementation implementation = component.getImplementation(); if (implementation instanceof Composite) { @@ -90,10 +88,10 @@ public class ComponentServiceEndpointBuilderImpl implements CompositeBuilder { // create an endpoint for each component service binding for (ComponentService service : component.getServices()) { - + Component endpointComponent = component; ComponentService endpointService = service; - + // TODO - EPR - We maintain all endpoints at the right level now // but endpoints for promoting services must point down // to the services they promote. @@ -102,8 +100,8 @@ public class ComponentServiceEndpointBuilderImpl implements CompositeBuilder { endpointService = ServiceConfigurationUtil.getPromotedComponentService(compositeService); endpointComponent = ServiceConfigurationUtil.getPromotedComponent(compositeService); } // end if - - for (Binding binding : service.getBindings()){ + + for (Binding binding : service.getBindings()) { Endpoint endpoint = assemblyFactory.createEndpoint(); endpoint.setComponent(endpointComponent); endpoint.setService(endpointService); @@ -114,20 +112,20 @@ public class ComponentServiceEndpointBuilderImpl implements CompositeBuilder { } } } // end method processComponentServices - + /** * @param composite - the composite which contains the component services */ private void processComponentServices2(Composite composite) { - for( Component component : composite.getComponents() ) { - for( ComponentService service : component.getServices() ) { - EndpointInfo theInfo = scanComponentService( component, service, null ); - - List theBindings = theInfo.getBindings(); - // Create an endpoint for each binding which applies to this service - // and copy across the information relating to the endpoint. - for( Binding binding : theBindings ) { - Endpoint endpoint = assemblyFactory.createEndpoint(); + for (Component component : composite.getComponents()) { + for (ComponentService service : component.getServices()) { + EndpointInfo theInfo = scanComponentService(component, service, null); + + List theBindings = theInfo.getBindings(); + // Create an endpoint for each binding which applies to this service + // and copy across the information relating to the endpoint. + for (Binding binding : theBindings) { + Endpoint endpoint = assemblyFactory.createEndpoint(); endpoint.setComponent(theInfo.getComponent()); endpoint.setService(theInfo.getComponentService()); endpoint.setBinding(binding); @@ -136,28 +134,28 @@ public class ComponentServiceEndpointBuilderImpl implements CompositeBuilder { endpoint.getPolicySets().addAll(theInfo.getPolicySets()); endpoint.setUnresolved(false); // Add the endpoint to the component service - if( useNew ) { - // Add to top level and leaf level services, if different - service.getEndpoints().add(endpoint); - ComponentService leafService = theInfo.getComponentService(); - if( service != leafService ) { - leafService.getEndpoints().add(endpoint); - } // end if + if (useNew) { + // Add to top level and leaf level services, if different + service.getEndpoints().add(endpoint); + ComponentService leafService = theInfo.getComponentService(); + if (service != leafService) { + leafService.getEndpoints().add(endpoint); + } // end if } // end if // debug // disabled for the time being - SL //System.out.println( "Endpoint created for Component = " + component.getName() + " Leaf component = " + // endpoint.getComponent().getName() + " service = " + // endpoint.getService().getName() + " binding = " + endpoint.getBinding() ); - } // end for - } // end for - // Handle composites as implementations - if( component.getImplementation() instanceof Composite ) { - processComponentServices2( (Composite) component.getImplementation() ); - } // end if - } // end for + } // end for + } // end for + // Handle composites as implementations + if (component.getImplementation() instanceof Composite) { + processComponentServices2((Composite)component.getImplementation()); + } // end if + } // end for } // end method processComponentServices2 - + /** * Scan a component service for endpoint information, recursing down to the leafmost promoted service if the component service is * implemented by a Composite service @@ -166,102 +164,101 @@ public class ComponentServiceEndpointBuilderImpl implements CompositeBuilder { * @param theInfo - an EndpointInfo object in which the endpoint information is accumulated. If null on entry, a new EndpointInfo object is created * @return - the EndpointInfo object containing the information about the component service */ - private EndpointInfo scanComponentService( Component component, ComponentService service, EndpointInfo theInfo ) { - if( theInfo == null ) { - theInfo = new EndpointInfo(); - } // end if - + private EndpointInfo scanComponentService(Component component, ComponentService service, EndpointInfo theInfo) { + if (theInfo == null) { + theInfo = new EndpointInfo(); + } // end if + theInfo.setBindings(service.getBindings()); - theInfo.setInterfaceContract(service.getInterfaceContract()); - theInfo.setIntents(service.getRequiredIntents()); - theInfo.setPolicySets(service.getPolicySets()); - - Service implService = service.getService(); - if( implService instanceof CompositeService ) { - // If it is implemented by a Composite, scan through the promoted service + theInfo.setInterfaceContract(service.getInterfaceContract()); + theInfo.setIntents(service.getRequiredIntents()); + theInfo.setPolicySets(service.getPolicySets()); + + Service implService = service.getService(); + if (implService instanceof CompositeService) { + // If it is implemented by a Composite, scan through the promoted service ComponentService promotedService = ((CompositeService)implService).getPromotedService(); Component promotedComponent = ((CompositeService)implService).getPromotedComponent(); if (promotedService != null) { - scanComponentService( promotedComponent, promotedService, theInfo ); + scanComponentService(promotedComponent, promotedService, theInfo); } else { - // If its a composite service with no promoted component service, it's an error + // If its a composite service with no promoted component service, it's an error } // end if - } else { - // Otherwise the component and service are the ones at this level - theInfo.setComponent(component); - theInfo.setComponentService(service); - } //end if - + } else { + // Otherwise the component and service are the ones at this level + theInfo.setComponent(component); + theInfo.setComponentService(service); + } //end if + return theInfo; } // end method scanPromotedComponentService - + private class EndpointInfo { - private Component leafComponent = null; - private ComponentService leafComponentService = null; - private List bindings = null; - private InterfaceContract contract; - private List intents = new Vector(); - private List policySets = null; - - void setComponent( Component component ){ - leafComponent = component; - } // end method - - Component getComponent() { - return leafComponent; - } // end method - - void setComponentService( ComponentService service ) { - leafComponentService = service; - } // end method - - ComponentService getComponentService() { - return leafComponentService; - } // end method - - void setBindings( List theBindings ) { - // RULE: Bindings from higher in the hierarchy take precedence - if( bindings == null ) { - bindings = theBindings; - } // end if - } // end method - - List getBindings() { - return bindings; - } // end method - - void setInterfaceContract( InterfaceContract theInterface ) { - // RULE: Interface contract from higher in the hierarchy takes precedence - if( contract == null ) { - contract = theInterface; - } // end if - } // end method - - InterfaceContract getInterfaceContract() { - return contract; - } // end method - - List getIntents() { - return intents; - } // end method - - void setIntents(List intents) { - // RULE: Intents accumulate from all levels in the hierarchy - this.intents.addAll( intents ); - } // end method - - List getPolicySets() { - return policySets; - } // end method - - void setPolicySets(List policySets) { - // RULE: Policy Sets from higher in the hierarchy override those lower - if( this.policySets == null ) { - this.policySets = policySets; - } // end if - } // end method - - + private Component leafComponent = null; + private ComponentService leafComponentService = null; + private List bindings = null; + private InterfaceContract contract; + private List intents = new Vector(); + private List policySets = null; + + void setComponent(Component component) { + leafComponent = component; + } // end method + + Component getComponent() { + return leafComponent; + } // end method + + void setComponentService(ComponentService service) { + leafComponentService = service; + } // end method + + ComponentService getComponentService() { + return leafComponentService; + } // end method + + void setBindings(List theBindings) { + // RULE: Bindings from higher in the hierarchy take precedence + if (bindings == null) { + bindings = theBindings; + } // end if + } // end method + + List getBindings() { + return bindings; + } // end method + + void setInterfaceContract(InterfaceContract theInterface) { + // RULE: Interface contract from higher in the hierarchy takes precedence + if (contract == null) { + contract = theInterface; + } // end if + } // end method + + InterfaceContract getInterfaceContract() { + return contract; + } // end method + + List getIntents() { + return intents; + } // end method + + void setIntents(List intents) { + // RULE: Intents accumulate from all levels in the hierarchy + this.intents.addAll(intents); + } // end method + + List getPolicySets() { + return policySets; + } // end method + + void setPolicySets(List policySets) { + // RULE: Policy Sets from higher in the hierarchy override those lower + if (this.policySets == null) { + this.policySets = policySets; + } // end if + } // end method + } // end class EndpointInfo } // end class 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 index d5a94e0ee9..32d1cfc690 100644 --- 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 @@ -73,22 +73,25 @@ public class ComponentServicePromotionBuilderImpl implements CompositeBuilder { ComponentService promotedService = ServiceConfigurationUtil.getPromotedComponentService(compositeService); if (promotedService != null) { - Component promotedComponent = ServiceConfigurationUtil.getPromotedComponent(compositeService); + 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() + "$slash$" + componentService.getName()); + newComponentService.setName("$promoted$" + component.getName() + + "$slash$" + + 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) { + + if (componentService.getInterfaceContract() != null && componentService + .getInterfaceContract().getCallbackInterface() != null) { newComponentService.setCallback(assemblyFactory.createCallback()); - newComponentService.getCallback().getBindings() - .addAll(componentService.getCallback().getBindings()); + newComponentService.getCallback().getBindings().addAll(componentService.getCallback() + .getBindings()); } // Change the composite service to now promote the diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingConfigurationBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingConfigurationBuilderImpl.java index d6757fd42b..1c1047da3e 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingConfigurationBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingConfigurationBuilderImpl.java @@ -41,31 +41,27 @@ import org.apache.tuscany.sca.monitor.Monitor; * * @version $Rev$ $Date$ */ -public class CompositeBindingConfigurationBuilderImpl extends CompositeBindingURIBuilderImpl implements CompositeBuilder { +public class CompositeBindingConfigurationBuilderImpl extends CompositeBindingURIBuilderImpl implements + CompositeBuilder { public CompositeBindingConfigurationBuilderImpl(FactoryExtensionPoint factories, InterfaceContractMapper mapper) { - super(factories.getFactory(AssemblyFactory.class), - factories.getFactory(SCABindingFactory.class), - null, null, + super(factories.getFactory(AssemblyFactory.class), factories.getFactory(SCABindingFactory.class), null, null, mapper); } - + public CompositeBindingConfigurationBuilderImpl(AssemblyFactory assemblyFactory, - SCABindingFactory scaBindingFactory, - InterfaceContractMapper interfaceContractMapper) { - super(assemblyFactory, - scaBindingFactory, - null, null, - interfaceContractMapper); + SCABindingFactory scaBindingFactory, + InterfaceContractMapper interfaceContractMapper) { + super(assemblyFactory, scaBindingFactory, null, null, interfaceContractMapper); } - + public String getID() { return "org.apache.tuscany.sca.assembly.builder.CompositeServiceBindingBuilder"; } public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { List defaultBindings = null; - for (Object x: composite.getExtensions()) { + for (Object x : composite.getExtensions()) { if (x instanceof List) { defaultBindings = (List)x; } @@ -73,5 +69,5 @@ public class CompositeBindingConfigurationBuilderImpl extends CompositeBindingUR // TODO - EPR - is this ever used? //configureBindingURIs(composite, definitions, defaultBindings, monitor); } - + } 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 index 2ef6202a85..af572349a6 100644 --- 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 @@ -61,9 +61,7 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C public CompositeBindingURIBuilderImpl(AssemblyFactory assemblyFactory, SCABindingFactory scaBindingFactory, InterfaceContractMapper interfaceContractMapper) { - super(assemblyFactory, scaBindingFactory, - null, null, - interfaceContractMapper); + super(assemblyFactory, scaBindingFactory, null, null, interfaceContractMapper); } public CompositeBindingURIBuilderImpl(AssemblyFactory assemblyFactory, @@ -71,8 +69,7 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C DocumentBuilderFactory documentBuilderFactory, TransformerFactory transformerFactory, InterfaceContractMapper interfaceContractMapper) { - super(assemblyFactory, scaBindingFactory, - documentBuilderFactory, transformerFactory, interfaceContractMapper); + super(assemblyFactory, scaBindingFactory, documentBuilderFactory, transformerFactory, interfaceContractMapper); } public String getID() { @@ -83,8 +80,10 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C configureBindingURIsAndNames(composite, definitions, monitor); } - public void build(Composite composite, Definitions definitions, Map> bindingBaseURIs, Monitor monitor) - throws CompositeBuilderException { + public void build(Composite composite, + Definitions definitions, + Map> bindingBaseURIs, + Monitor monitor) throws CompositeBuilderException { configureBindingURIs(composite, null, definitions, bindingBaseURIs, monitor); configureBindingNames(composite, monitor); } @@ -94,7 +93,8 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C * * @param composite the composite to be configured */ - protected void configureBindingURIsAndNames(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { + protected void configureBindingURIsAndNames(Composite composite, Definitions definitions, Monitor monitor) + throws CompositeBuilderException { configureBindingURIs(composite, null, definitions, null, monitor); configureBindingNames(composite, monitor); } @@ -108,33 +108,36 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C * @param defaultBindings list of default binding configurations */ protected void configureBindingURIs(Composite composite, - Definitions definitions, Map> defaultBindings, + Definitions definitions, + Map> defaultBindings, Monitor monitor) throws CompositeBuilderException { configureBindingURIs(composite, null, definitions, defaultBindings, monitor); } - /** - * 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. - * - * 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 - * - * @param composite the composite to be configured - * @param uri the path to the composite provided through any nested composite component implementations - * @param defaultBindings list of default binding configurations - */ - private void configureBindingURIs(Composite composite, String uri, - Definitions definitions, Map> defaultBindings, + /** + * 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. + * + * 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 + * + * @param composite the composite to be configured + * @param uri the path to the composite provided through any nested composite component implementations + * @param defaultBindings list of default binding configurations + */ + private void configureBindingURIs(Composite composite, + String uri, + Definitions definitions, + Map> defaultBindings, Monitor monitor) throws CompositeBuilderException { String parentComponentURI = uri; @@ -184,20 +187,13 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C Map services = new HashMap(); Map references = new HashMap(); Map properties = new HashMap(); - indexImplementationPropertiesServicesAndReferences(component, - services, - references, - properties, - monitor); + indexImplementationPropertiesServicesAndReferences(component, services, references, properties, monitor); // Index component services, references and properties // Also check for duplicates - Map componentServices = - new HashMap(); - Map componentReferences = - new HashMap(); - Map componentProperties = - new HashMap(); + Map componentServices = new HashMap(); + Map componentReferences = new HashMap(); + Map componentProperties = new HashMap(); indexComponentPropertiesServicesAndReferences(component, componentServices, componentReferences, @@ -313,7 +309,7 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C // set the default binding name if one is required // if there is no name on the binding then set it to the service or reference name - if (binding.getName() == null){ + if (binding.getName() == null) { binding.setName(contract.getName()); } @@ -328,8 +324,8 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C continue; } if (binding.getName().equals(otherBinding.getName())) { - warning(monitor, contract instanceof Service ? "MultipleBindingsForService" : "MultipleBindingsForReference", - binding, contract.getName(), binding.getName()); + warning(monitor, contract instanceof Service ? "MultipleBindingsForService" + : "MultipleBindingsForReference", binding, contract.getName(), binding.getName()); } } } @@ -346,28 +342,33 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C * @param binding * @param defaultBindings */ - private void constructBindingURI(String parentComponentURI, Composite composite, Service service, - Binding binding, Map> defaultBindings, Monitor monitor) - throws CompositeBuilderException{ + private void constructBindingURI(String parentComponentURI, + Composite composite, + Service service, + Binding binding, + Map> defaultBindings, + Monitor monitor) throws CompositeBuilderException { // This is a composite service so there is no component to provide a component URI // The path to this composite (through nested composites) is used. boolean includeBindingName = composite.getServices().size() != 1; constructBindingURI(parentComponentURI, service, binding, includeBindingName, defaultBindings, monitor); } - /** - * URI construction for component bindings based on Assembly Specification section 1.7.2. This method - * calculates the component URI part based on component information before calling the generic - * constructBindingURI method - * - * @param component the component that holds the service - * @param service the service that holds the binding - * @param binding the binding for which the URI is being constructed - * @param defaultBindings the list of default binding configurations - */ - private void constructBindingURI(Component component, Service service, - Binding binding, Map> defaultBindings, Monitor monitor) - throws CompositeBuilderException{ + /** + * URI construction for component bindings based on Assembly Specification section 1.7.2. This method + * calculates the component URI part based on component information before calling the generic + * constructBindingURI method + * + * @param component the component that holds the service + * @param service the service that holds the binding + * @param binding the binding for which the URI is being constructed + * @param defaultBindings the list of default binding configurations + */ + private void constructBindingURI(Component component, + Service service, + Binding binding, + Map> defaultBindings, + Monitor monitor) throws CompositeBuilderException { boolean includeBindingName = component.getServices().size() != 1; constructBindingURI(component.getURI(), service, binding, includeBindingName, defaultBindings, monitor); } @@ -382,18 +383,21 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C * @param defaultBindings the list of default binding configurations * @throws CompositeBuilderException */ - private void constructBindingURI(String componentURIString, Service service, Binding binding, - boolean includeBindingName, Map> defaultBindings, Monitor monitor) - throws CompositeBuilderException{ + private void constructBindingURI(String componentURIString, + Service service, + Binding binding, + boolean includeBindingName, + Map> defaultBindings, + Monitor monitor) throws CompositeBuilderException { try { // calculate the service binding URI URI bindingURI; - if (binding.getURI() != null){ + if (binding.getURI() != null) { bindingURI = new URI(binding.getURI()); // if the user has provided an absolute binding URI then use it - if (bindingURI.isAbsolute()){ + if (bindingURI.isAbsolute()) { binding.setURI(bindingURI.toString()); return; } @@ -419,8 +423,13 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C } // if the user has provided an absolute component URI then use it - if (componentURI != null && componentURI.isAbsolute()){ - binding.setURI(constructBindingURI(null, componentURI, bindingURI, serviceName, includeBindingName, bindingName)); + if (componentURI != null && componentURI.isAbsolute()) { + binding.setURI(constructBindingURI(null, + componentURI, + bindingURI, + serviceName, + includeBindingName, + bindingName)); return; } @@ -433,7 +442,12 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C } } - binding.setURI(constructBindingURI(baseURI, componentURI, bindingURI, serviceName, includeBindingName, bindingName)); + binding.setURI(constructBindingURI(baseURI, + componentURI, + bindingURI, + serviceName, + includeBindingName, + bindingName)); } catch (URISyntaxException ex) { error(monitor, "URLSyntaxException", binding, componentURIString, service.getName(), binding.getName()); } @@ -447,8 +461,8 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C * @param path the path string to which the "/" is to be added * @return the resulting path with a "/" added if it not already there */ - private static String addSlashToPath(String path){ - if (path.endsWith("/") || path.endsWith("#")){ + private static String addSlashToPath(String path) { + if (path.endsWith("/") || path.endsWith("#")) { return path; } else { return path + "/"; @@ -475,14 +489,14 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C String uriString; if (baseURI == null) { - if (componentURI == null){ - if (bindingURI != null ) { + if (componentURI == null) { + if (bindingURI != null) { uriString = bindingURI.toString(); } else { uriString = name; } } else { - if (bindingURI != null ) { + if (bindingURI != null) { uriString = componentURI.resolve(bindingURI).toString(); } else { uriString = componentURI.resolve(name).toString(); @@ -490,13 +504,13 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C } } else { if (componentURI == null) { - if (bindingURI != null ) { + if (bindingURI != null) { uriString = basedURI(baseURI, bindingURI).toString(); } else { uriString = basedURI(baseURI, URI.create(name)).toString(); } } else { - if (bindingURI != null ) { + if (bindingURI != null) { uriString = basedURI(baseURI, componentURI.resolve(bindingURI)).toString(); } else { uriString = basedURI(baseURI, componentURI.resolve(name)).toString(); @@ -505,8 +519,8 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C } // tidy up by removing any trailing "/" - if (uriString.endsWith("/")){ - uriString = uriString.substring(0, uriString.length()-1); + if (uriString.endsWith("/")) { + uriString = uriString.substring(0, uriString.length() - 1); } URI uri = URI.create(uriString); 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 bced0c807e..b065a5eafe 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 @@ -62,21 +62,18 @@ public class CompositeBuilderImpl implements CompositeBuilder, CompositeBuilderT private CompositeBuilder compositePolicyBuilder; private CompositeBuilder componentServiceBindingBuilder; private CompositeBuilder componentReferenceBindingBuilder; - + private CompositeBuilder componentReferenceEndpointReferenceBuilder; private CompositeBuilder componentServiceEndpointBuilder; + //private CompositeBuilder endpointReferenceBuilder; - + public CompositeBuilderImpl(FactoryExtensionPoint factories, InterfaceContractMapper mapper) { - this(factories.getFactory(AssemblyFactory.class), - factories.getFactory(SCABindingFactory.class), - factories.getFactory(PolicyFactory.class), - factories.getFactory(DocumentBuilderFactory.class), - factories.getFactory(TransformerFactory.class), - mapper); + this(factories.getFactory(AssemblyFactory.class), factories.getFactory(SCABindingFactory.class), factories + .getFactory(PolicyFactory.class), factories.getFactory(DocumentBuilderFactory.class), factories + .getFactory(TransformerFactory.class), mapper); } - /** * Constructs a new composite builder. * @@ -91,12 +88,11 @@ public class CompositeBuilderImpl implements CompositeBuilder, CompositeBuilderT @Deprecated public CompositeBuilderImpl(AssemblyFactory assemblyFactory, SCABindingFactory scaBindingFactory, - PolicyFactory intentAttachPointTypeFactory, + PolicyFactory intentAttachPointTypeFactory, InterfaceContractMapper interfaceContractMapper) { - this(assemblyFactory, scaBindingFactory, intentAttachPointTypeFactory, - null, null, interfaceContractMapper); + this(assemblyFactory, scaBindingFactory, intentAttachPointTypeFactory, null, null, interfaceContractMapper); } - + /** * Constructs a new composite builder. * @@ -110,30 +106,34 @@ public class CompositeBuilderImpl implements CompositeBuilder, CompositeBuilderT */ public CompositeBuilderImpl(AssemblyFactory assemblyFactory, SCABindingFactory scaBindingFactory, - PolicyFactory intentAttachPointTypeFactory, + PolicyFactory intentAttachPointTypeFactory, DocumentBuilderFactory documentBuilderFactory, TransformerFactory transformerFactory, InterfaceContractMapper interfaceContractMapper) { - - - compositeIncludeBuilder = new CompositeIncludeBuilderImpl(assemblyFactory); + + compositeIncludeBuilder = new CompositeIncludeBuilderImpl(assemblyFactory); componentReferenceWireBuilder = new ComponentReferenceWireBuilderImpl(assemblyFactory, interfaceContractMapper); //componentReferencePromotionWireBuilder = new ComponentReferencePromotionWireBuilderImpl(assemblyFactory, endpointFactory); componentReferencePromotionBuilder = new ComponentReferencePromotionBuilderImpl(assemblyFactory); //compositeReferenceWireBuilder = new CompositeReferenceWireBuilderImpl(assemblyFactory, endpointFactory); compositeCloneBuilder = new CompositeCloneBuilderImpl(); - componentConfigurationBuilder = new ComponentConfigurationBuilderImpl(assemblyFactory, scaBindingFactory, documentBuilderFactory, transformerFactory, interfaceContractMapper); + componentConfigurationBuilder = + new ComponentConfigurationBuilderImpl(assemblyFactory, scaBindingFactory, documentBuilderFactory, + transformerFactory, interfaceContractMapper); compositeServiceConfigurationBuilder = new CompositeServiceConfigurationBuilderImpl(assemblyFactory); compositeReferenceConfigurationBuilder = new CompositeReferenceConfigurationBuilderImpl(assemblyFactory); - compositeBindingURIBuilder = new CompositeBindingURIBuilderImpl(assemblyFactory, scaBindingFactory, documentBuilderFactory, transformerFactory, interfaceContractMapper); + compositeBindingURIBuilder = + new CompositeBindingURIBuilderImpl(assemblyFactory, scaBindingFactory, documentBuilderFactory, + transformerFactory, interfaceContractMapper); //componentServicePromotionBuilder = new ComponentServicePromotionBuilderImpl(assemblyFactory); //compositeServicePromotionBuilder = new CompositeServicePromotionBuilderImpl(assemblyFactory); compositePromotionBuilder = new CompositePromotionBuilderImpl(assemblyFactory, interfaceContractMapper); compositePolicyBuilder = new CompositePolicyBuilderImpl(assemblyFactory, interfaceContractMapper); componentServiceBindingBuilder = new ComponentServiceBindingBuilderImpl(); componentReferenceBindingBuilder = new ComponentReferenceBindingBuilderImpl(); - - componentReferenceEndpointReferenceBuilder = new ComponentReferenceEndpointReferenceBuilderImpl(assemblyFactory, interfaceContractMapper); + + componentReferenceEndpointReferenceBuilder = + new ComponentReferenceEndpointReferenceBuilderImpl(assemblyFactory, interfaceContractMapper); componentServiceEndpointBuilder = new ComponentServiceEndpointBuilderImpl(assemblyFactory); //endpointReferenceBuilder = new EndpointReference2BuilderImpl(assemblyFactory, interfaceContractMapper); } @@ -141,85 +141,88 @@ public class CompositeBuilderImpl implements CompositeBuilder, CompositeBuilderT public String getID() { return "org.apache.tuscany.sca.assembly.builder.CompositeBuilder"; } - + public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { - build(composite, definitions, null, monitor); + build(composite, definitions, null, monitor); } - - public void build(Composite composite, Definitions definitions, Map> bindingBaseURIs, Monitor monitor) throws CompositeBuilderException { - - try { - // Collect and fuse includes - compositeIncludeBuilder.build(composite, definitions, monitor); - - // Expand nested composites - compositeCloneBuilder.build(composite, definitions, monitor); - - // Configure all components - componentConfigurationBuilder.build(composite, definitions, monitor); - - // Connect composite services/references to promoted services/references - compositePromotionBuilder.build(composite, definitions, monitor); - - // Configure composite services by copying bindings up the promotion - // hierarchy overwriting automatic bindings with those added manually - compositeServiceConfigurationBuilder.build(composite, definitions, monitor); - - // Configure composite references by copying bindings down promotion - // hierarchy overwriting automatic bindings with those added manually - compositeReferenceConfigurationBuilder.build(composite, definitions, monitor); - - // Configure service binding URIs and names. Creates an SCA defined URI based - // on the scheme base URI, the component name and the binding name - ((CompositeBuilderTmp)compositeBindingURIBuilder).build(composite, definitions, bindingBaseURIs, monitor); - - // Create $promoted$ component services on bottom level components - // to represent promoted services - // TODO - EPR replaced by endpoints on the promoted services - //componentServicePromotionBuilder.build(composite, definitions, monitor); - - // Create $promoted$ component services on bottom level components - // to represent promoted composite services - // TODO - EPR OASIS doesn't deploy top level composite services - // if it did it would be replaced by endpoints - //compositeServicePromotionBuilder.build(composite, definitions, monitor); - - // Perform and service binding related build activities. The binding - // will provide the builder. - componentServiceBindingBuilder.build(composite, definitions, monitor); - - // create endpoints on component services. - componentServiceEndpointBuilder.build(composite, definitions, monitor); - - // Apply any wires in the composite to create new component reference targets - componentReferenceWireBuilder.build(composite, definitions, monitor); - - // create reference endpoint reference models - componentReferenceEndpointReferenceBuilder.build(composite, definitions, monitor); - - // Push down configuration from promoted references to the - // references they promote - componentReferencePromotionBuilder.build(composite, definitions, monitor); - - // Push down configuration from promoted references to the - // references they promote - // TODO - EPR Seems to be a repeat of compositeReferenceConfigurationBuilder - // componentReferencePromotionWireBuilder.build(composite, definitions, monitor); - - // Wire the composite references - // TODO - EPR OASIS doesn't deploy top level composite references - // compositeReferenceWireBuilder.build(composite, definitions, monitor); - - // Perform and reference binding related build activities. The binding - // will provide the builder. - componentReferenceBindingBuilder.build(composite, definitions, monitor); - - // Compute the policies across the model hierarchy - compositePolicyBuilder.build(composite, definitions, monitor); - } catch (Exception e) { - throw new CompositeBuilderException("Exception while building composite " + composite.getName(), e); - } // end try - + + public void build(Composite composite, + Definitions definitions, + Map> bindingBaseURIs, + Monitor monitor) throws CompositeBuilderException { + + try { + // Collect and fuse includes + compositeIncludeBuilder.build(composite, definitions, monitor); + + // Expand nested composites + compositeCloneBuilder.build(composite, definitions, monitor); + + // Configure all components + componentConfigurationBuilder.build(composite, definitions, monitor); + + // Connect composite services/references to promoted services/references + compositePromotionBuilder.build(composite, definitions, monitor); + + // Configure composite services by copying bindings up the promotion + // hierarchy overwriting automatic bindings with those added manually + compositeServiceConfigurationBuilder.build(composite, definitions, monitor); + + // Configure composite references by copying bindings down promotion + // hierarchy overwriting automatic bindings with those added manually + compositeReferenceConfigurationBuilder.build(composite, definitions, monitor); + + // Configure service binding URIs and names. Creates an SCA defined URI based + // on the scheme base URI, the component name and the binding name + ((CompositeBuilderTmp)compositeBindingURIBuilder).build(composite, definitions, bindingBaseURIs, monitor); + + // Create $promoted$ component services on bottom level components + // to represent promoted services + // TODO - EPR replaced by endpoints on the promoted services + //componentServicePromotionBuilder.build(composite, definitions, monitor); + + // Create $promoted$ component services on bottom level components + // to represent promoted composite services + // TODO - EPR OASIS doesn't deploy top level composite services + // if it did it would be replaced by endpoints + //compositeServicePromotionBuilder.build(composite, definitions, monitor); + + // Perform and service binding related build activities. The binding + // will provide the builder. + componentServiceBindingBuilder.build(composite, definitions, monitor); + + // create endpoints on component services. + componentServiceEndpointBuilder.build(composite, definitions, monitor); + + // Apply any wires in the composite to create new component reference targets + componentReferenceWireBuilder.build(composite, definitions, monitor); + + // create reference endpoint reference models + componentReferenceEndpointReferenceBuilder.build(composite, definitions, monitor); + + // Push down configuration from promoted references to the + // references they promote + componentReferencePromotionBuilder.build(composite, definitions, monitor); + + // Push down configuration from promoted references to the + // references they promote + // TODO - EPR Seems to be a repeat of compositeReferenceConfigurationBuilder + // componentReferencePromotionWireBuilder.build(composite, definitions, monitor); + + // Wire the composite references + // TODO - EPR OASIS doesn't deploy top level composite references + // compositeReferenceWireBuilder.build(composite, definitions, monitor); + + // Perform and reference binding related build activities. The binding + // will provide the builder. + componentReferenceBindingBuilder.build(composite, definitions, monitor); + + // Compute the policies across the model hierarchy + compositePolicyBuilder.build(composite, definitions, monitor); + } catch (Exception e) { + throw new CompositeBuilderException("Exception while building composite " + composite.getName(), e); + } // end try + } // end method build } //end class diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeCloneBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeCloneBuilderImpl.java index 21e5192ae8..d489e81d6b 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeCloneBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeCloneBuilderImpl.java @@ -37,10 +37,10 @@ import org.apache.tuscany.sca.monitor.Monitor; * @version $Rev$ $Date$ */ public class CompositeCloneBuilderImpl implements CompositeBuilder { - + public CompositeCloneBuilderImpl() { } - + public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { expandCompositeImplementations(composite); } @@ -59,7 +59,7 @@ public class CompositeCloneBuilderImpl implements CompositeBuilder { for (Component component : composite.getComponents()) { Implementation implementation = component.getImplementation(); if (implementation instanceof Composite) { - + Composite compositeImplementation = (Composite)implementation; Composite clone; try { @@ -96,21 +96,21 @@ public class CompositeCloneBuilderImpl implements CompositeBuilder { * @param composite */ private void fuseCompositeImplementations(Composite composite) { - + // First collect all nested composites List nested = new ArrayList(); collectNestedComposites(composite, nested); - + // Then add all the non-composite components they contain for (Composite nestedComposite : nested) { - for (Component component: nestedComposite.getComponents()) { + for (Component component : nestedComposite.getComponents()) { Implementation implementation = component.getImplementation(); if (!(implementation instanceof Composite)) { composite.getComponents().add(component); } } } - + // Clear the initial list of composite components for (Iterator i = composite.getComponents().iterator(); i.hasNext();) { Component component = i.next(); diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeIncludeBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeIncludeBuilderImpl.java index 75699bd235..56fd732d86 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeIncludeBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeIncludeBuilderImpl.java @@ -19,9 +19,7 @@ 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; @@ -29,9 +27,7 @@ import org.apache.tuscany.sca.assembly.Component; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.Problem; import org.apache.tuscany.sca.monitor.Problem.Severity; @@ -42,13 +38,13 @@ import org.apache.tuscany.sca.monitor.Problem.Severity; * @version $Rev$ $Date$ */ public class CompositeIncludeBuilderImpl implements CompositeBuilder { - + private AssemblyFactory assemblyFactory; - + public CompositeIncludeBuilderImpl(AssemblyFactory assemblyFactory) { this.assemblyFactory = assemblyFactory; } - + public String getID() { return "org.apache.tuscany.sca.assembly.builder.CompositeIncludeBuilder"; } @@ -58,8 +54,14 @@ public class CompositeIncludeBuilderImpl implements CompositeBuilder { } private void warning(Monitor monitor, String message, Object model, String... messageParameters) { - if (monitor != null){ - Problem problem = monitor.createProblem(this.getClass().getName(), "assembly-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters); + if (monitor != null) { + Problem problem = + monitor.createProblem(this.getClass().getName(), + "assembly-validation-messages", + Severity.WARNING, + model, + message, + (Object[])messageParameters); monitor.problem(problem); } } @@ -70,10 +72,10 @@ public class CompositeIncludeBuilderImpl implements CompositeBuilder { * @param composite */ private void fuseIncludes(Composite composite, Monitor monitor) { - + Set visited = new HashSet(); visited.add(composite); - + for (Composite included : composite.getIncludes()) { Composite fusedComposite = fuseInclude(included, visited, monitor); if (fusedComposite != null) { @@ -86,30 +88,28 @@ public class CompositeIncludeBuilderImpl implements CompositeBuilder { composite.getRequiredIntents().addAll(fusedComposite.getRequiredIntents()); } } - + // Clear the list of includes as all of the included components // have now been added into the top level composite composite.getIncludes().clear(); } - - private Composite fuseInclude(Composite include, - Set visited, - Monitor monitor) { - + + private Composite fuseInclude(Composite include, Set visited, Monitor monitor) { + if (visited.contains(include)) { warning(monitor, "CompositeAlreadyIncluded", include, include.getName().toString()); return null; } - + visited.add(include); - + Composite clone; try { clone = (Composite)include.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException(e); } - + // get the components etc. from any included composites for (Composite included : include.getIncludes()) { Composite fusedComposite = fuseInclude(included, visited, monitor); @@ -123,17 +123,17 @@ public class CompositeIncludeBuilderImpl implements CompositeBuilder { clone.getRequiredIntents().addAll(fusedComposite.getRequiredIntents()); } } - + // apply the autowire flag on this composite to any inline // components - Assembly 5.6 point 4 - if (include.getAutowire() == Boolean.TRUE){ - for ( Component component : clone.getComponents()){ - if (component.getAutowire() == null){ + if (include.getAutowire() == Boolean.TRUE) { + for (Component component : clone.getComponents()) { + if (component.getAutowire() == null) { component.setAutowire(true); } } } - + // return the fused composite we have built up so far return clone; } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java index e2f17f5efd..e29cef3ad9 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java @@ -19,7 +19,6 @@ package org.apache.tuscany.sca.assembly.builder.impl; - import java.util.HashMap; import java.util.List; import java.util.Map; @@ -49,7 +48,8 @@ import org.apache.tuscany.sca.monitor.Monitor; */ public class CompositePromotionBuilderImpl extends BaseBuilderImpl implements CompositeBuilder { - public CompositePromotionBuilderImpl(AssemblyFactory assemblyFactory, InterfaceContractMapper interfaceContractMapper) { + public CompositePromotionBuilderImpl(AssemblyFactory assemblyFactory, + InterfaceContractMapper interfaceContractMapper) { super(assemblyFactory, null, null, null, interfaceContractMapper); } @@ -60,7 +60,7 @@ public class CompositePromotionBuilderImpl extends BaseBuilderImpl implements Co public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { connectCompositeReferencesAndServices(composite, monitor); } - + /** * Connect composite references and services to the reference and services that they promote. * @@ -68,7 +68,7 @@ public class CompositePromotionBuilderImpl extends BaseBuilderImpl implements Co * @param componentServices * @param problems */ - protected void connectCompositeReferencesAndServices(Composite composite, Monitor monitor){ + protected void connectCompositeReferencesAndServices(Composite composite, Monitor monitor) { // Wire nested composites recursively for (Component component : composite.getComponents()) { Implementation implementation = component.getImplementation(); @@ -88,7 +88,7 @@ public class CompositePromotionBuilderImpl extends BaseBuilderImpl implements Co connectCompositeServices(composite, components, componentServices, monitor); connectCompositeReferences(composite, components, componentReferences, monitor); } - + /** * Connect composite services to the component services that they promote. * @@ -100,7 +100,7 @@ public class CompositePromotionBuilderImpl extends BaseBuilderImpl implements Co Map components, Map componentServices, Monitor monitor) { - + // Propagate interfaces from inner composite components' services to // their component services for (Component component : composite.getComponents()) { @@ -115,35 +115,35 @@ public class CompositePromotionBuilderImpl extends BaseBuilderImpl implements Co } } } - + // Connect composite services to the component services that they promote for (Service service : composite.getServices()) { CompositeService compositeService = (CompositeService)service; ComponentService componentService = compositeService.getPromotedService(); if (componentService != null && componentService.isUnresolved()) { - - String promotedComponentName = compositeService.getPromotedComponent().getName(); + + String promotedComponentName = compositeService.getPromotedComponent().getName(); String promotedServiceName; if (componentService.getName() != null) { - if( compositeService.isCallback() ) { - // For callbacks the name already has the form "componentName"/"servicename" - promotedServiceName = componentService.getName(); - } else { - promotedServiceName = promotedComponentName + '/' + componentService.getName(); - } + if (compositeService.isCallback()) { + // For callbacks the name already has the form "componentName"/"servicename" + promotedServiceName = componentService.getName(); + } else { + promotedServiceName = promotedComponentName + '/' + componentService.getName(); + } } else { promotedServiceName = promotedComponentName; } ComponentService promotedService = componentServices.get(promotedServiceName); if (promotedService != null) { - + // Point to the resolved component Component promotedComponent = components.get(promotedComponentName); compositeService.setPromotedComponent(promotedComponent); - + // Point to the resolved component service compositeService.setPromotedService(promotedService); - + // Use the interface contract from the component service if // none is specified on the composite service InterfaceContract compositeServiceInterfaceContract = compositeService.getInterfaceContract(); @@ -152,19 +152,25 @@ public class CompositePromotionBuilderImpl extends BaseBuilderImpl implements Co compositeService.setInterfaceContract(promotedServiceInterfaceContract); } else if (promotedServiceInterfaceContract != null) { // Check the compositeServiceInterfaceContract and promotedServiceInterfaceContract - boolean isCompatible = interfaceContractMapper.isCompatible(compositeServiceInterfaceContract, promotedServiceInterfaceContract); - if(!isCompatible){ + boolean isCompatible = + interfaceContractMapper.isCompatible(compositeServiceInterfaceContract, + promotedServiceInterfaceContract); + if (!isCompatible) { warning(monitor, "ServiceInterfaceNotSubSet", compositeService, promotedServiceName); } } - + } else { - // MJE 15/05/2005 - Priority raised from "warning" to "error" to fix TUSCANY-3034 - error(monitor, "PromotedServiceNotFound", composite, composite.getName().toString(), promotedServiceName); + // MJE 15/05/2005 - Priority raised from "warning" to "error" to fix TUSCANY-3034 + error(monitor, + "PromotedServiceNotFound", + composite, + composite.getName().toString(), + promotedServiceName); } } } - + } /** @@ -176,8 +182,9 @@ public class CompositePromotionBuilderImpl extends BaseBuilderImpl implements Co */ private void connectCompositeReferences(Composite composite, Map components, - Map componentReferences, Monitor monitor) { - + Map componentReferences, + Monitor monitor) { + // Propagate interfaces from inner composite components' references to // their component references for (Component component : composite.getComponents()) { @@ -192,7 +199,7 @@ public class CompositePromotionBuilderImpl extends BaseBuilderImpl implements Co } } } - + // Connect composite references to the component references that they promote for (Reference reference : composite.getReferences()) { CompositeReference compositeReference = (CompositeReference)reference; @@ -207,30 +214,41 @@ public class CompositePromotionBuilderImpl extends BaseBuilderImpl implements Co Component promotedComponent = compositeReference.getPromotedComponents().get(i); promotedComponent = components.get(promotedComponent.getName()); compositeReference.getPromotedComponents().set(i, promotedComponent); - - componentReference.setPromoted( true ); - + + componentReference.setPromoted(true); + // Point to the resolved component reference promotedReferences.set(i, componentReference); - + // Use the interface contract from the component reference if none // is specified on the composite reference - InterfaceContract compositeReferenceInterfaceContract = compositeReference.getInterfaceContract(); - InterfaceContract componentReferenceInterfaceContract = componentReference.getInterfaceContract(); + InterfaceContract compositeReferenceInterfaceContract = + compositeReference.getInterfaceContract(); + InterfaceContract componentReferenceInterfaceContract = + componentReference.getInterfaceContract(); if (compositeReferenceInterfaceContract == null) { compositeReference.setInterfaceContract(componentReferenceInterfaceContract); } else if (componentReferenceInterfaceContract != null) { // Check that the componentInterfaceContract is a subset of the compositeInterfaceContract - boolean isCompatible = interfaceContractMapper.isCompatible( componentReferenceInterfaceContract, compositeReferenceInterfaceContract); + boolean isCompatible = + interfaceContractMapper.isCompatible(componentReferenceInterfaceContract, + compositeReferenceInterfaceContract); if (!isCompatible) { - warning(monitor, "ReferenceInterfaceNotSubSet", compositeReference, componentReferenceName); + warning(monitor, + "ReferenceInterfaceNotSubSet", + compositeReference, + componentReferenceName); } } } else { - warning(monitor, "PromotedReferenceNotFound", composite, composite.getName().toString(), componentReferenceName); + warning(monitor, + "PromotedReferenceNotFound", + composite, + composite.getName().toString(), + componentReferenceName); } } } } - } + } } 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 index 07422ef9f2..7b9550f1b8 100644 --- 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 @@ -70,7 +70,7 @@ public class CompositeReferenceConfigurationBuilderImpl implements CompositeBuil // 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()) ) { + } else if (bindingsSpecifiedManually(promotedReference.getBindings())) { compositeReference.getBindings().clear(); for (Binding binding : promotedReference.getBindings()) { try { @@ -80,13 +80,13 @@ public class CompositeReferenceConfigurationBuilderImpl implements CompositeBuil } } } - if (compositeReference.getInterfaceContract() != null && - compositeReference.getInterfaceContract().getCallbackInterface() != null) { - if (compositeReference.getCallback() != null && - bindingsSpecifiedManually(compositeReference.getCallback().getBindings())) { + 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())) { + } else if (promotedReference.getCallback() != null && bindingsSpecifiedManually(promotedReference + .getCallback().getBindings())) { if (compositeReference.getCallback() != null) { compositeReference.getCallback().getBindings().clear(); } else { @@ -106,9 +106,9 @@ public class CompositeReferenceConfigurationBuilderImpl implements CompositeBuil // 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()))) { + if (bindingsSpecifiedManually(compositeReference.getBindings()) || (compositeReference + .getCallback() != null && bindingsSpecifiedManually(compositeReference.getCallback() + .getBindings()))) { compositeReference.setPromotionOverride(true); } } @@ -139,8 +139,8 @@ public class CompositeReferenceConfigurationBuilderImpl implements CompositeBuil 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()) ) { + if (!bindingsSpecifiedManually(compositeReference.getBindings()) && bindingsSpecifiedManually(promotedReference + .getBindings())) { compositeReference.getBindings().clear(); for (Binding binding : promotedReference.getBindings()) { try { @@ -152,29 +152,28 @@ public class CompositeReferenceConfigurationBuilderImpl implements CompositeBuil } if (bindingsSpecifiedManually(componentReference.getBindings())) { componentReference.setPromotionOverride(true); - } else if (bindingsSpecifiedManually(compositeReference.getBindings()) ) { + } 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 (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()); + compositeReference.getCallback().getBindings().addAll(promotedReference + .getCallback().getBindings()); } - if (componentReference.getCallback() != null && - bindingsSpecifiedManually(componentReference.getCallback().getBindings())) { + if (componentReference.getCallback() != null && bindingsSpecifiedManually(componentReference + .getCallback().getBindings())) { componentReference.setPromotionOverride(true); - } else if (compositeReference.getCallback() != null && - bindingsSpecifiedManually(compositeReference.getCallback().getBindings())) { + } else if (compositeReference.getCallback() != null && bindingsSpecifiedManually(compositeReference + .getCallback().getBindings())) { if (componentReference.getCallback() != null) { componentReference.getCallback().getBindings().clear(); } else { @@ -182,7 +181,8 @@ public class CompositeReferenceConfigurationBuilderImpl implements CompositeBuil } for (Binding binding : compositeReference.getCallback().getBindings()) { try { - componentReference.getCallback().getBindings().add((Binding)binding.clone()); + componentReference.getCallback().getBindings().add((Binding)binding + .clone()); } catch (CloneNotSupportedException ex) { // this binding can't be used in the promoted reference } @@ -194,9 +194,9 @@ public class CompositeReferenceConfigurationBuilderImpl implements CompositeBuil // 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()))) { + if (bindingsSpecifiedManually(componentReference.getBindings()) || (componentReference + .getCallback() != null && bindingsSpecifiedManually(componentReference + .getCallback().getBindings()))) { componentReference.setPromotionOverride(true); } } @@ -218,9 +218,8 @@ public class CompositeReferenceConfigurationBuilderImpl implements CompositeBuil if (bindings.size() > 1) { return true; - } else if (bindings.size() == 1 && - bindings.get(0) instanceof AutomaticBinding && - ((AutomaticBinding)bindings.get(0)).getIsAutomatic()) { + } else if (bindings.size() == 1 && bindings.get(0) instanceof AutomaticBinding + && ((AutomaticBinding)bindings.get(0)).getIsAutomatic()) { return false; } else if (bindings.size() == 1) { return true; @@ -228,5 +227,5 @@ public class CompositeReferenceConfigurationBuilderImpl implements CompositeBuil 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 451b378941..d74386cf33 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 @@ -54,7 +54,7 @@ public class CompositeReferenceWireBuilderImpl implements CompositeBuilder { * @param composite */ public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { - + // Process composite references declared in this composite for (Reference reference : composite.getReferences()) { CompositeReference compositeReference = (CompositeReference)reference; @@ -68,10 +68,12 @@ public class CompositeReferenceWireBuilderImpl implements CompositeBuilder { List promotedReferences = ReferenceConfigurationUtil.getPromotedComponentReferences(compositeReference); for (ComponentReference promotedReference : promotedReferences) { - ReferenceConfigurationUtil.reconcileReferenceBindings( - compositeReference, promotedReference, assemblyFactory, monitor); + ReferenceConfigurationUtil.reconcileReferenceBindings(compositeReference, + promotedReference, + assemblyFactory, + monitor); if (compositeReference.getInterfaceContract() != null && // can be null in unit tests - compositeReference.getInterfaceContract().getCallbackInterface() != null) { + compositeReference.getInterfaceContract().getCallbackInterface() != null) { SCABinding scaCallbackBinding = promotedReference.getCallbackBinding(SCABinding.class); if (promotedReference.getCallback() != null) { promotedReference.getCallback().getBindings().clear(); 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 6a8da7241a..bf12b57a86 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 @@ -49,9 +49,9 @@ public class CompositeServiceBindingBuilderImpl implements CompositeBuilder { public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { buildServiceBindings(composite, monitor); } - + private void buildServiceBindings(Composite composite, Monitor monitor) { - + // build bindings recursively for (Component component : composite.getComponents()) { Implementation implementation = component.getImplementation(); 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 099996d244..e251bcc25e 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 @@ -66,8 +66,8 @@ public class CompositeServiceConfigurationBuilderImpl implements CompositeBuilde if (promotedService != null) { // Set the bindings using the top level bindings to override the lower level bindings - if (!bindingsSpecifiedManually(compositeService.getBindings()) && - bindingsSpecifiedManually(promotedService.getBindings())) { + if (!bindingsSpecifiedManually(compositeService.getBindings()) && bindingsSpecifiedManually(promotedService + .getBindings())) { compositeService.getBindings().clear(); for (Binding binding : promotedService.getBindings()) { try { @@ -75,14 +75,13 @@ public class CompositeServiceConfigurationBuilderImpl implements CompositeBuilde } 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.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 { @@ -94,7 +93,7 @@ public class CompositeServiceConfigurationBuilderImpl implements CompositeBuilde } catch (CloneNotSupportedException ex) { // this binding can't be used in the promoted service } - } + } } } } @@ -122,8 +121,8 @@ public class CompositeServiceConfigurationBuilderImpl implements CompositeBuilde if (promotedService != null) { // Set the bindings using the top level bindings to override the lower level bindings - if (!bindingsSpecifiedManually(compositeService.getBindings()) && - bindingsSpecifiedManually(promotedService.getBindings()) ) { + if (!bindingsSpecifiedManually(compositeService.getBindings()) && bindingsSpecifiedManually(promotedService + .getBindings())) { compositeService.getBindings().clear(); for (Binding binding : promotedService.getBindings()) { try { @@ -131,19 +130,18 @@ public class CompositeServiceConfigurationBuilderImpl implements CompositeBuilde } catch (CloneNotSupportedException ex) { // this binding can't be used in the promoted service } - } + } } - if (!bindingsSpecifiedManually(componentService.getBindings()) && - bindingsSpecifiedManually(compositeService.getBindings()) ) { + 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 (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 { @@ -155,19 +153,18 @@ public class CompositeServiceConfigurationBuilderImpl implements CompositeBuilde } 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 && 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()); + componentService.getCallback().getBindings().addAll(compositeService.getCallback() + .getBindings()); } } } @@ -188,9 +185,8 @@ public class CompositeServiceConfigurationBuilderImpl implements CompositeBuilde if (bindings.size() > 1) { return true; - } else if (bindings.size() == 1 && - bindings.get(0) instanceof AutomaticBinding && - ((AutomaticBinding)bindings.get(0)).getIsAutomatic()) { + } else if (bindings.size() == 1 && bindings.get(0) instanceof AutomaticBinding + && ((AutomaticBinding)bindings.get(0)).getIsAutomatic()) { return false; } else if (bindings.size() == 1) { return true; @@ -198,5 +194,5 @@ public class CompositeServiceConfigurationBuilderImpl implements CompositeBuilde 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 index 3004a9f590..e5727777fe 100644 --- 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 @@ -65,11 +65,11 @@ public class CompositeServicePromotionBuilderImpl implements CompositeBuilder { newComponentService.setService(promotedService.getService()); newComponentService.getBindings().addAll(compositeService.getBindings()); newComponentService.setInterfaceContract(compositeService.getInterfaceContract()); - if (compositeService.getInterfaceContract() != null && - compositeService.getInterfaceContract().getCallbackInterface() != null) { + if (compositeService.getInterfaceContract() != null && compositeService.getInterfaceContract() + .getCallbackInterface() != null) { newComponentService.setCallback(assemblyFactory.createCallback()); newComponentService.getCallback().getBindings() - .addAll(compositeService.getCallback().getBindings()); + .addAll(compositeService.getCallback().getBindings()); } // Change the composite service to now promote the newly diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationException.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationException.java index 944cf2cf36..b53f3641f5 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationException.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationException.java @@ -26,13 +26,13 @@ package org.apache.tuscany.sca.assembly.builder.impl; */ public class PolicyConfigurationException extends Exception { private static final long serialVersionUID = 506979037642587755L; - + public PolicyConfigurationException(String message) { super(message); } - + public PolicyConfigurationException(Throwable e) { super(e); } - + } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java index 37f4ae6672..ca23948632 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java @@ -50,8 +50,8 @@ import org.apache.tuscany.sca.policy.util.PolicyValidationUtils; */ abstract class PolicyConfigurationUtil { - private static List computeInheritableIntents(ExtensionType attachPointType, - List inheritableIntents) throws PolicyValidationException { + private static List computeInheritableIntents(ExtensionType attachPointType, List inheritableIntents) + throws PolicyValidationException { List validInheritableIntents = new ArrayList(); //expand profile intents in inherited intents @@ -60,15 +60,16 @@ abstract class PolicyConfigurationUtil { //validate if inherited intent applies to the attachpoint (binding / implementation) and //only add such intents to the attachpoint (binding / implementation) for (Intent intent : inheritableIntents) { - if ( !intent.isUnresolved() ) { + if (!intent.isUnresolved()) { for (ExtensionType constrained : intent.getConstrainedTypes()) { - if ( PolicyValidationUtils.isConstrained(constrained, attachPointType)) { + if (PolicyValidationUtils.isConstrained(constrained, attachPointType)) { validInheritableIntents.add(intent); break; } } } else { - throw new PolicyValidationException("Policy Intent '" + intent.getName() + "' is not defined in this domain"); + throw new PolicyValidationException("Policy Intent '" + intent.getName() + + "' is not defined in this domain"); } } @@ -84,25 +85,24 @@ abstract class PolicyConfigurationUtil { filterDuplicatesAndQualifiableIntents(intentAttachPoint); } - private static void trimInherentlyProvidedIntents(ExtensionType attachPointType, Listintents) { + private static void trimInherentlyProvidedIntents(ExtensionType attachPointType, List intents) { //exclude intents that are inherently supported by the //attachpoint-type (binding-type / implementation-type) List requiredIntents = new ArrayList(intents); - for ( Intent intent : requiredIntents ) { - if ( isProvidedInherently(attachPointType, intent) ) { + for (Intent intent : requiredIntents) { + if (isProvidedInherently(attachPointType, intent)) { intents.remove(intent); } } } - private static List computeInheritablePolicySets(List inheritablePolicySets) - throws PolicyValidationException { + throws PolicyValidationException { // FIXME: return inheritablePolicySets; } - private static void normalizePolicySets(PolicySubject subject ) { + private static void normalizePolicySets(PolicySubject subject) { //get rid of duplicate entries Set policySetTable = new HashSet(subject.getPolicySets()); @@ -110,20 +110,20 @@ abstract class PolicyConfigurationUtil { subject.getPolicySets().addAll(policySetTable); //expand profile intents - for ( PolicySet policySet : subject.getPolicySets() ) { + for (PolicySet policySet : subject.getPolicySets()) { PolicyComputationUtils.expandProfileIntents(policySet.getProvidedIntents()); } } private static void trimProvidedIntents(List requiredIntents, List policySets) { - for ( PolicySet policySet : policySets ) { + for (PolicySet policySet : policySets) { trimProvidedIntents(requiredIntents, policySet); } } private static void determineApplicableDomainPolicySets(List applicablePolicySets, - PolicySubject policySetAttachPoint, - ExtensionType intentAttachPointType) { + PolicySubject policySetAttachPoint, + ExtensionType intentAttachPointType) { if (policySetAttachPoint.getRequiredIntents().size() > 0) { @@ -131,7 +131,8 @@ abstract class PolicyConfigurationUtil { List combinedTargetIntents = new ArrayList(); combinedTargetIntents.addAll(policySetAttachPoint.getRequiredIntents()); for (PolicySet targetPolicySet : policySetAttachPoint.getPolicySets()) { - combinedTargetIntents.addAll(PolicyComputationUtils.findAndExpandProfileIntents(targetPolicySet.getProvidedIntents())); + combinedTargetIntents.addAll(PolicyComputationUtils.findAndExpandProfileIntents(targetPolicySet + .getProvidedIntents())); } //since the set of applicable policysets for this attachpoint is known @@ -139,7 +140,8 @@ abstract class PolicyConfigurationUtil { for (PolicySet policySet : applicablePolicySets) { // do not use the policy set if it provides intents that conflict with required intents boolean conflict = false; - List providedIntents = PolicyComputationUtils.findAndExpandProfileIntents(policySet.getProvidedIntents()); + List providedIntents = + PolicyComputationUtils.findAndExpandProfileIntents(policySet.getProvidedIntents()); checkConflict: for (Intent intent : providedIntents) { for (Intent excluded : intent.getExcludedIntents()) { if (combinedTargetIntents.contains(excluded)) { @@ -162,23 +164,20 @@ abstract class PolicyConfigurationUtil { } private static boolean isProvidedInherently(ExtensionType attachPointType, Intent intent) { - return ( attachPointType != null && - (( attachPointType.getAlwaysProvidedIntents() != null && - attachPointType.getAlwaysProvidedIntents().contains(intent) ) || - ( attachPointType.getMayProvidedIntents() != null && - attachPointType.getMayProvidedIntents().contains(intent) ) - ) ); - } + return (attachPointType != null && ((attachPointType.getAlwaysProvidedIntents() != null && attachPointType + .getAlwaysProvidedIntents().contains(intent)) || (attachPointType.getMayProvidedIntents() != null && attachPointType + .getMayProvidedIntents().contains(intent)))); + } private static void trimProvidedIntents(List requiredIntents, PolicySet policySet) { - for ( Intent providedIntent : policySet.getProvidedIntents() ) { - if ( requiredIntents.contains(providedIntent) ) { + for (Intent providedIntent : policySet.getProvidedIntents()) { + if (requiredIntents.contains(providedIntent)) { requiredIntents.remove(providedIntent); } } - for ( IntentMap intentMap : policySet.getIntentMaps() ) { - if ( requiredIntents.contains(intentMap.getProvidedIntent()) ) { + for (IntentMap intentMap : policySet.getIntentMaps()) { + if (requiredIntents.contains(intentMap.getProvidedIntent())) { requiredIntents.remove(intentMap.getProvidedIntent()); } } @@ -187,16 +186,16 @@ abstract class PolicyConfigurationUtil { private static void filterDuplicatesAndQualifiableIntents(PolicySubject intentAttachPoint) { //remove duplicates Map intentsTable = new HashMap(); - for ( Intent intent : intentAttachPoint.getRequiredIntents() ) { + for (Intent intent : intentAttachPoint.getRequiredIntents()) { intentsTable.put(intent.getName(), intent); } //where qualified form of intent exists retain it and remove the qualifiable intent Map intentsTableCopy = new HashMap(intentsTable); //if qualified form of intent exists remove the unqualified form - for ( Intent intent : intentsTableCopy.values() ) { - if ( intent.getQualifiableIntent()!=null ) { - if ( intentsTable.get(intent.getQualifiableIntent().getName()) != null ) { + for (Intent intent : intentsTableCopy.values()) { + if (intent.getQualifiableIntent() != null) { + if (intentsTable.get(intent.getQualifiableIntent().getName()) != null) { intentsTable.remove(intent.getQualifiableIntent().getName()); } } @@ -205,7 +204,7 @@ abstract class PolicyConfigurationUtil { intentAttachPoint.getRequiredIntents().addAll(intentsTable.values()); } - static void computeBindingIntentsAndPolicySets(Contract contract) throws PolicyValidationException { + static void computeBindingIntentsAndPolicySets(Contract contract) throws PolicyValidationException { for (Binding binding : contract.getBindings()) { if (binding instanceof PolicySubject) { PolicySubject policiedBinding = (PolicySubject)binding; @@ -213,15 +212,14 @@ abstract class PolicyConfigurationUtil { computePolicySets(policiedBinding, contract.getPolicySets()); - PolicyComputationUtils.checkForMutuallyExclusiveIntents( - policiedBinding.getRequiredIntents(), - policiedBinding.getPolicySets(), - policiedBinding.getExtensionType(), - contract.getName()); + PolicyComputationUtils.checkForMutuallyExclusiveIntents(policiedBinding.getRequiredIntents(), + policiedBinding.getPolicySets(), + policiedBinding.getExtensionType(), + contract.getName()); } } - if ( contract.getCallback() != null ) { + if (contract.getCallback() != null) { for (Binding binding : contract.getCallback().getBindings()) { if (binding instanceof PolicySubject) { PolicySubject policiedBinding = (PolicySubject)binding; @@ -229,11 +227,10 @@ abstract class PolicyConfigurationUtil { computePolicySets(policiedBinding, contract.getCallback().getPolicySets()); - PolicyComputationUtils.checkForMutuallyExclusiveIntents( - policiedBinding.getRequiredIntents(), - policiedBinding.getPolicySets(), - policiedBinding.getExtensionType(), - contract.getName() + " callback"); + PolicyComputationUtils.checkForMutuallyExclusiveIntents(policiedBinding.getRequiredIntents(), + policiedBinding.getPolicySets(), + policiedBinding.getExtensionType(), + contract.getName() + " callback"); } } @@ -241,42 +238,41 @@ abstract class PolicyConfigurationUtil { } private static void computeIntents(PolicySubject policiedBinding, List inheritedIntents) - throws PolicyValidationException { - //since the parent component could also contain intents that apply to implementation - //and binding elements within, we filter out only those that apply to this binding type - List prunedIntents = computeInheritableIntents(policiedBinding.getExtensionType(), - inheritedIntents); - policiedBinding.getRequiredIntents().addAll(prunedIntents); - - normalizeIntents(policiedBinding); + throws PolicyValidationException { + //since the parent component could also contain intents that apply to implementation + //and binding elements within, we filter out only those that apply to this binding type + List prunedIntents = computeInheritableIntents(policiedBinding.getExtensionType(), inheritedIntents); + policiedBinding.getRequiredIntents().addAll(prunedIntents); + + normalizeIntents(policiedBinding); } - private static void computePolicySets(PolicySubject policiedBinding, - List inheritedPolicySets) throws PolicyValidationException { + private static void computePolicySets(PolicySubject policiedBinding, List inheritedPolicySets) + throws PolicyValidationException { List prunedPolicySets = computeInheritablePolicySets(inheritedPolicySets); policiedBinding.getPolicySets().addAll(prunedPolicySets); normalizePolicySets(policiedBinding); } - static void determineApplicableBindingPolicySets(Contract source, Contract target) throws PolicyConfigurationException { + static void determineApplicableBindingPolicySets(Contract source, Contract target) + throws PolicyConfigurationException { List intentsCopy = null; for (Binding aBinding : source.getBindings()) { if (aBinding instanceof PolicySubject) { PolicySubject policiedBinding = (PolicySubject)aBinding; ExtensionType bindingType = policiedBinding.getExtensionType(); - intentsCopy = new ArrayList(policiedBinding.getRequiredIntents()); // add the target component's intents to the reference binding if (target != null) { for (Intent intent : target.getRequiredIntents()) { if (!policiedBinding.getRequiredIntents().contains(intent)) { for (ExtensionType constrained : intent.getConstrainedTypes()) { - if (bindingType != null && bindingType.getType().getNamespaceURI() - .equals(constrained.getType().getNamespaceURI()) - && bindingType.getType().getLocalPart().startsWith(constrained - .getType().getLocalPart())) { + if (bindingType != null && bindingType.getType().getNamespaceURI().equals(constrained + .getType().getNamespaceURI()) + && bindingType.getType().getLocalPart().startsWith(constrained.getType() + .getLocalPart())) { policiedBinding.getRequiredIntents().add(intent); break; } @@ -285,10 +281,8 @@ abstract class PolicyConfigurationUtil { } } - trimInherentlyProvidedIntents(policiedBinding.getExtensionType(), - policiedBinding.getRequiredIntents()); - trimProvidedIntents(policiedBinding.getRequiredIntents(), policiedBinding - .getPolicySets()); + trimInherentlyProvidedIntents(policiedBinding.getExtensionType(), policiedBinding.getRequiredIntents()); + trimProvidedIntents(policiedBinding.getRequiredIntents(), policiedBinding.getPolicySets()); // determine additional policysets that match remaining intents // TODO: resolved to domain policy registry and attach suitable @@ -307,9 +301,8 @@ abstract class PolicyConfigurationUtil { } } - private static void determineApplicableDomainPolicySets(Contract contract, - PolicySubject policiedBinding) - throws PolicyConfigurationException { + private static void determineApplicableDomainPolicySets(Contract contract, PolicySubject policiedBinding) + throws PolicyConfigurationException { // FIXME: /* //if ( domainPolicySets != null) { @@ -336,7 +329,7 @@ abstract class PolicyConfigurationUtil { target.addAll(source); //strip duplicates Hashtable policySetTable = new Hashtable(); - for ( PolicySet policySet : target ) { + for (PolicySet policySet : target) { policySetTable.put(policySet.getName(), policySet); } @@ -349,34 +342,32 @@ abstract class PolicyConfigurationUtil { for (Contract contract : contracts) { // The contract inherits default policies from the parent composite/component. - if ( parent instanceof PolicySubject ) { - PolicyComputationUtils.addDefaultPolicies( - ((PolicySubject)parent).getRequiredIntents(), - ((PolicySubject)parent).getPolicySets(), - contract.getRequiredIntents(), - contract.getPolicySets()); + if (parent instanceof PolicySubject) { + PolicyComputationUtils.addDefaultPolicies(((PolicySubject)parent).getRequiredIntents(), + ((PolicySubject)parent).getPolicySets(), + contract.getRequiredIntents(), + contract.getPolicySets()); } // The contract's callback inherits default policies from the contract. if (contract.getCallback() != null) { - PolicyComputationUtils.addDefaultPolicies( - contract.getRequiredIntents(), - contract.getPolicySets(), - contract.getCallback().getRequiredIntents(), - contract.getCallback().getPolicySets()); + PolicyComputationUtils.addDefaultPolicies(contract.getRequiredIntents(), + contract.getPolicySets(), + contract.getCallback().getRequiredIntents(), + contract.getCallback().getPolicySets()); } } } static void computeImplementationIntentsAndPolicySets(Implementation implementation, Component parent) - throws PolicyValidationException, PolicyConfigurationException { - if ( implementation instanceof PolicySubject ) { + throws PolicyValidationException, PolicyConfigurationException { + if (implementation instanceof PolicySubject) { PolicySubject policiedImplementation = (PolicySubject)implementation; //since for an implementation the component has its policy intents and policysets its possible //that there are some intents there that does not constrain the implementation.. so prune - List prunedIntents = computeInheritableIntents(policiedImplementation.getExtensionType(), - parent.getRequiredIntents()); + List prunedIntents = + computeInheritableIntents(policiedImplementation.getExtensionType(), parent.getRequiredIntents()); parent.getRequiredIntents().clear(); parent.getRequiredIntents().addAll(prunedIntents); normalizeIntents(parent); @@ -386,25 +377,24 @@ abstract class PolicyConfigurationUtil { parent.getPolicySets().addAll(prunedPolicySets); normalizePolicySets(parent); - PolicyComputationUtils.checkForMutuallyExclusiveIntents( - parent.getRequiredIntents(), - parent.getPolicySets(), - policiedImplementation.getExtensionType(), - parent.getName()); + PolicyComputationUtils.checkForMutuallyExclusiveIntents(parent.getRequiredIntents(), + parent.getPolicySets(), + policiedImplementation.getExtensionType(), + parent.getName()); determineApplicableImplementationPolicySets(parent); } } - private static void determineApplicableImplementationPolicySets(Component component) throws PolicyConfigurationException { + private static void determineApplicableImplementationPolicySets(Component component) + throws PolicyConfigurationException { List intentsCopy = null; - if ( component.getImplementation() instanceof PolicySubject ) { + if (component.getImplementation() instanceof PolicySubject) { PolicySubject policiedImplementation = (PolicySubject)component.getImplementation(); intentsCopy = new ArrayList(component.getRequiredIntents()); - trimInherentlyProvidedIntents(policiedImplementation.getExtensionType(), - component.getRequiredIntents()); + trimInherentlyProvidedIntents(policiedImplementation.getExtensionType(), component.getRequiredIntents()); trimProvidedIntents(component.getRequiredIntents(), component.getPolicySets()); //determine additional policysets that match remaining intents @@ -413,10 +403,13 @@ abstract class PolicyConfigurationUtil { //...for now using the SCA Definitions instead of registry //if ( domainPolicySets != null) { - if (component.getRequiredIntents().size() > 0) { - throw new PolicyConfigurationException("The following are unfulfilled intents for component implementation - " + component - .getName() + "\nUnfulfilled Intents = " + component.getRequiredIntents()); - } + if (component.getRequiredIntents().size() > 0) { + throw new PolicyConfigurationException( + "The following are unfulfilled intents for component implementation - " + component + .getName() + + "\nUnfulfilled Intents = " + + component.getRequiredIntents()); + } //} //the intents list could have been trimmed when matching for policysets diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyConfigurationUtil.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyConfigurationUtil.java index 0105d4af50..283843498e 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyConfigurationUtil.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyConfigurationUtil.java @@ -59,9 +59,11 @@ import org.xml.sax.InputSource; * @version $Rev$ $Date$ */ abstract class PropertyConfigurationUtil { - - private static Document evaluate(Document node, XPathExpression expression, DocumentBuilderFactory documentBuilderFactory) - throws XPathExpressionException, ParserConfigurationException { + + private static Document evaluate(Document node, + XPathExpression expression, + DocumentBuilderFactory documentBuilderFactory) throws XPathExpressionException, + ParserConfigurationException { Node value = node.getDocumentElement(); Node result = (Node)expression.evaluate(value, XPathConstants.NODE); @@ -80,9 +82,9 @@ abstract class PropertyConfigurationUtil { return document; } } - - private static Document loadFromFile(String file, TransformerFactory transformerFactory) throws MalformedURLException, IOException, - TransformerException, ParserConfigurationException { + + private static Document loadFromFile(String file, TransformerFactory transformerFactory) + throws MalformedURLException, IOException, TransformerException, ParserConfigurationException { URI uri = URI.create(file); // URI resolution for relative URIs is done when the composite is resolved. URL url = uri.toURL(); @@ -91,14 +93,14 @@ abstract class PropertyConfigurationUtil { InputStream is = null; try { is = connection.getInputStream(); - + Source streamSource = new SAXSource(new InputSource(is)); DOMResult result = new DOMResult(); javax.xml.transform.Transformer transformer = transformerFactory.newTransformer(); transformer.transform(streamSource, result); - + Document document = (Document)result.getNode(); - + // TUSCANY-2377, Add a fake value element so it's consistent with // the DOM tree loaded from inside SCDL Element root = document.createElementNS(null, "value"); @@ -111,15 +113,12 @@ abstract class PropertyConfigurationUtil { } } } - + static void sourceComponentProperties(Map compositeProperties, - Component componentDefinition, - DocumentBuilderFactory documentBuilderFactory, - TransformerFactory transformerFactory) throws CompositeBuilderException, - ParserConfigurationException, - XPathExpressionException, - TransformerException, - IOException { + Component componentDefinition, + DocumentBuilderFactory documentBuilderFactory, + TransformerFactory transformerFactory) throws CompositeBuilderException, + ParserConfigurationException, XPathExpressionException, TransformerException, IOException { List componentProperties = componentDefinition.getProperties(); for (ComponentProperty aProperty : componentProperties) { @@ -137,13 +136,15 @@ abstract class PropertyConfigurationUtil { String name = source.substring(1, index); Property compositeProp = compositeProperties.get(name); if (compositeProp == null) { - throw new CompositeBuilderException("The 'source' cannot be resolved to a composite property: " + source); + throw new CompositeBuilderException( + "The 'source' cannot be resolved to a composite property: " + source); } Document compositePropDefValues = (Document)compositeProp.getValue(); // FIXME: How to deal with namespaces? - Document node = evaluate(compositePropDefValues, aProperty.getSourceXPathExpression(), documentBuilderFactory); + Document node = + evaluate(compositePropDefValues, aProperty.getSourceXPathExpression(), documentBuilderFactory); if (node != null) { aProperty.setValue(node); @@ -157,7 +158,7 @@ abstract class PropertyConfigurationUtil { } } } - + private static class DOMNamespaceContext implements NamespaceContext { private Node node; @@ -209,5 +210,5 @@ abstract class PropertyConfigurationUtil { } } - + } 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 9f810a2c60..fa5d42a71d 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 @@ -51,7 +51,13 @@ abstract class ReferenceConfigurationUtil { */ private static void warning(Monitor monitor, String message, Object model, String... messageParameters) { if (monitor != null) { - Problem problem = monitor.createProblem(ReferenceConfigurationUtil.class.getName(), "assembly-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters); + Problem problem = + monitor.createProblem(ReferenceConfigurationUtil.class.getName(), + "assembly-validation-messages", + Severity.WARNING, + model, + message, + (Object[])messageParameters); monitor.problem(problem); } } @@ -70,19 +76,18 @@ abstract class ReferenceConfigurationUtil { return true; } } - - static boolean validateMultiplicityAndTargets(Multiplicity multiplicity, - List targets, List bindings) { - + + static boolean validateMultiplicityAndTargets(Multiplicity multiplicity, List targets, List bindings) { + // Count targets int count = targets.size(); - + //FIXME workaround, this validation is sometimes invoked too early // before we get a chance to init the multiplicity attribute if (multiplicity == null) { return true; } - + switch (multiplicity) { case ZERO_N: break; @@ -94,8 +99,8 @@ abstract class ReferenceConfigurationUtil { case ONE_ONE: if (count != 1) { if (count == 0) { - for (Binding binding: bindings) { - if (!(binding instanceof OptimizableBinding) || binding.getURI()!=null) { + for (Binding binding : bindings) { + if (!(binding instanceof OptimizableBinding) || binding.getURI() != null) { return true; } } @@ -106,8 +111,8 @@ abstract class ReferenceConfigurationUtil { case ONE_N: if (count < 1) { if (count == 0) { - for (Binding binding: bindings) { - if (!(binding instanceof OptimizableBinding) || binding.getURI()!=null) { + for (Binding binding : bindings) { + if (!(binding instanceof OptimizableBinding) || binding.getURI() != null) { return true; } } @@ -145,12 +150,12 @@ abstract class ReferenceConfigurationUtil { 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); } @@ -167,24 +172,23 @@ abstract class ReferenceConfigurationUtil { ComponentReference promotedReference, AssemblyFactory assemblyFactory, Monitor monitor) { - - if (reference.getEndpointReferences().size() > 0){ - if (promotedReference.getMultiplicity() == Multiplicity.ONE_ONE || - promotedReference.getMultiplicity() == Multiplicity.ZERO_ONE) { - // Override any existing wires for 0..1 and 1..1 multiplicity - promotedReference.getEndpointReferences().clear(); - // For 0..1 and 1..1, there should not be more than 1 endpoint reference + + if (reference.getEndpointReferences().size() > 0) { + if (promotedReference.getMultiplicity() == Multiplicity.ONE_ONE || promotedReference.getMultiplicity() == Multiplicity.ZERO_ONE) { + // Override any existing wires for 0..1 and 1..1 multiplicity + promotedReference.getEndpointReferences().clear(); + // For 0..1 and 1..1, there should not be more than 1 endpoint reference if (reference.getEndpointReferences().size() > 1) { - warning(monitor, "ComponentReferenceMoreWire", promotedReference, promotedReference.getName()); + warning(monitor, "ComponentReferenceMoreWire", promotedReference, promotedReference.getName()); } // end if } // end if // Clone the EndpointReferences from the outer level and add to the promoted reference - for( EndpointReference epRef : reference.getEndpointReferences()){ - EndpointReference epRefClone = copyHigherReference( epRef, promotedReference ); - promotedReference.getEndpointReferences().add(epRefClone); + for (EndpointReference epRef : reference.getEndpointReferences()) { + EndpointReference epRefClone = copyHigherReference(epRef, promotedReference); + promotedReference.getEndpointReferences().add(epRefClone); } // end for } // end if - + Set callbackBindings = new HashSet(); if (promotedReference.getCallback() != null) { callbackBindings.addAll(promotedReference.getCallback().getBindings()); @@ -199,25 +203,25 @@ abstract class ReferenceConfigurationUtil { } // end if } // end for } // end method reconcileReferenceBindings - + /** * Copy a higher level EndpointReference down to a lower level reference which it promotes * @param epRef - the endpoint reference * @param promotedReference - the promoted reference * @return - a copy of the EndpointReference with data merged from the promoted reference */ - private static EndpointReference copyHigherReference( EndpointReference epRef, ComponentReference promotedReference ) { - EndpointReference epRefClone = null; - try { - epRefClone = (EndpointReference) epRef.clone(); - } catch (Exception e) { - // Ignore (we know that EndpointReference2 can be cloned) - } // end try - // Copy across details of the inner reference - ComponentReference ref = epRefClone.getReference(); - //FIXME - epRefClone.setReference(promotedReference); - return epRefClone; + private static EndpointReference copyHigherReference(EndpointReference epRef, ComponentReference promotedReference) { + EndpointReference epRefClone = null; + try { + epRefClone = (EndpointReference)epRef.clone(); + } catch (Exception e) { + // Ignore (we know that EndpointReference2 can be cloned) + } // end try + // Copy across details of the inner reference + ComponentReference ref = epRefClone.getReference(); + //FIXME + epRefClone.setReference(promotedReference); + return epRefClone; } // end copyHigherReference } // end class 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 41a8b3f8ba..312be1b40e 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 @@ -42,17 +42,17 @@ abstract class ServiceConfigurationUtil { if (componentService != null) { Service service = componentService.getService(); if (componentService.getName() != null && service instanceof CompositeService) { - + // Continue to follow the service promotion chain return getPromotedComponentService((CompositeService)service); - + } else { - + // Found a non-composite service return componentService; } } else { - + // No promoted service return null; } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java index db4bcb0060..49995f5ab8 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java @@ -41,7 +41,7 @@ public class AbstractPropertyImpl extends ExtensibleImpl implements AbstractProp */ protected AbstractPropertyImpl() { } - + public Object getValue() { return value; } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java index d0ee3832c5..3e44f5f7ae 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java @@ -34,7 +34,7 @@ public class AbstractReferenceImpl extends ContractImpl implements AbstractRefer */ protected AbstractReferenceImpl() { } - + public Multiplicity getMultiplicity() { return multiplicity; } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java index 346764b1b4..24b1a0e03e 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java @@ -26,11 +26,11 @@ import org.apache.tuscany.sca.assembly.AbstractService; * @version $Rev$ $Date$ */ public class AbstractServiceImpl extends ContractImpl implements AbstractService { - + /** * Constructs a new abstract service. */ protected AbstractServiceImpl() { } - + } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java index ab43fc5b5d..421be55db3 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java @@ -50,6 +50,7 @@ import org.apache.tuscany.sca.core.ExtensionPointRegistry; public abstract class AssemblyFactoryImpl implements AssemblyFactory { protected ExtensionPointRegistry registry; + protected AssemblyFactoryImpl(ExtensionPointRegistry registry) { super(); this.registry = registry; diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java index 553e600bc9..516b11724f 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java @@ -33,7 +33,7 @@ public abstract class BaseImpl implements Base { */ protected BaseImpl() { } - + public boolean isUnresolved() { return unresolved; } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java index 2d8513309e..dcd6c7b08a 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java @@ -52,16 +52,16 @@ public class CallbackImpl extends ExtensibleImpl implements Callback { public List getBindings() { return bindings; } - + public ExtensionType getExtensionType() { return null; } public void setExtensionType(ExtensionType type) { } - + public void setRequiredIntents(List intents) { this.requiredIntents = intents; } - + } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java index 8eee73b469..0f10fb50a4 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java @@ -48,6 +48,7 @@ public class ComponentImpl extends ExtensibleImpl implements Component, Cloneabl private List policySets = new ArrayList(); private Boolean autowire; private ExtensionType type; + /** * Constructs a new component. */ @@ -132,7 +133,7 @@ public class ComponentImpl extends ExtensibleImpl implements Component, Cloneabl public void setAutowire(Boolean autowire) { this.autowire = autowire; } - + public Boolean getAutowire() { return autowire; } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java index e2e7b59896..5cb1693799 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java @@ -34,18 +34,18 @@ public class ComponentPropertyImpl extends PropertyImpl implements ComponentProp private Property property; private String source; private XPathExpression sourceXPathExpression; - + /** * Constructs a new component property. */ protected ComponentPropertyImpl() { } - + @Override public Object clone() throws CloneNotSupportedException { return super.clone(); } - + // FIXME getValue should not delegate to property.getValue() // Doing this violates the setValue/getValue semantics, as you // can call setValue() then get a different value from getValue() @@ -57,7 +57,7 @@ public class ComponentPropertyImpl extends PropertyImpl implements ComponentProp return super.getValue(); } } - + public String getFile() { return file; } 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 bb5b163762..78b54668b3 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 @@ -35,12 +35,12 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContract; * @version $Rev$ $Date$ */ public class ComponentReferenceImpl extends ReferenceImpl implements ComponentReference, Cloneable { - private Reference reference; - private Boolean autowire; - private boolean nonOverridable; - private List promotedAs = new ArrayList(); - private ComponentService callbackService; - private boolean isPromoted = false; + private Reference reference; + private Boolean autowire; + private boolean nonOverridable; + private List promotedAs = new ArrayList(); + private ComponentService callbackService; + private boolean isPromoted = false; /** * Constructs a new component reference. @@ -54,7 +54,7 @@ public class ComponentReferenceImpl extends ReferenceImpl implements ComponentRe public Object clone() throws CloneNotSupportedException { return super.clone(); } - + public Reference getReference() { return reference; } @@ -70,7 +70,7 @@ public class ComponentReferenceImpl extends ReferenceImpl implements ComponentRe public void setAutowire(Boolean autowire) { this.autowire = autowire; } - + public Boolean getAutowire() { return autowire; } @@ -86,17 +86,16 @@ public class ComponentReferenceImpl extends ReferenceImpl implements ComponentRe public void setCallbackService(ComponentService callbackService) { this.callbackService = callbackService; } - - + /** * Use endpoint information to work out what the interface contract for the * binding is. */ @Override - public InterfaceContract getInterfaceContract(Binding binding){ + public InterfaceContract getInterfaceContract(Binding binding) { InterfaceContract interfaceContract = null; - - if (interfaceContract == null){ + + if (interfaceContract == null) { interfaceContract = getInterfaceContract(); } return interfaceContract; @@ -108,13 +107,13 @@ public class ComponentReferenceImpl extends ReferenceImpl implements ComponentRe public void setNonOverridable(boolean nonOverridable) { this.nonOverridable = nonOverridable; - } - - public void setPromoted( boolean isPromoted ) { - this.isPromoted = isPromoted; + } + + public void setPromoted(boolean isPromoted) { + this.isPromoted = isPromoted; } // end method setPromoted - + public boolean isPromoted() { - return isPromoted; + return isPromoted; } } // end class ComponentReferenceImpl diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java index 0c78a2505f..f8c9f53413 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java @@ -36,7 +36,7 @@ public class ComponentServiceImpl extends ServiceImpl implements ComponentServic private Service service; private List promotedAs = new ArrayList(); private ComponentReference callbackReference; - + /** * Constructs a new component service. */ @@ -47,7 +47,7 @@ public class ComponentServiceImpl extends ServiceImpl implements ComponentServic public Object clone() throws CloneNotSupportedException { return super.clone(); } - + public Service getService() { return service; } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java index 5d55f76903..9bad01b653 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java @@ -43,6 +43,7 @@ public class ComponentTypeImpl extends ExtensibleImpl implements ComponentType, private List services = new ArrayList(); private List requiredIntents = new ArrayList(); private List policySets = new ArrayList(); + /** * Constructs a new component type. */ diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java index 7ebd770935..0aa63c4c92 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java @@ -157,7 +157,7 @@ public class CompositeImpl extends ImplementationImpl implements Composite, Clon } @Override - public String toString(){ - return ( this.name != null ) ? getName().toString() : "null"; + public String toString() { + return (this.name != null) ? getName().toString() : "null"; } } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java index 97b0db3bcc..ae5fad461b 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java @@ -40,7 +40,7 @@ public class CompositeReferenceImpl extends ReferenceImpl implements CompositeRe */ protected CompositeReferenceImpl() { } - + @Override public Object clone() throws CloneNotSupportedException { CompositeReferenceImpl copy = (CompositeReferenceImpl)super.clone(); @@ -56,7 +56,7 @@ public class CompositeReferenceImpl extends ReferenceImpl implements CompositeRe public List getPromotedComponents() { return promotedComponents; } - + public String toString() { return getName(); } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java index 6777a96982..55b48ec578 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java @@ -50,13 +50,13 @@ public class CompositeServiceImpl extends ServiceImpl implements CompositeServic public void setPromotedService(ComponentService promotedService) { this.promotedService = promotedService; } - + public Component getPromotedComponent() { return promotedComponent; } - + public void setPromotedComponent(Component promotedComponent) { this.promotedComponent = promotedComponent; } - + } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.java index b1e36ee60d..16ea948391 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.java @@ -43,7 +43,7 @@ public class ConstrainingTypeImpl extends ExtensibleImpl implements Constraining private List services = new ArrayList(); private List requiredIntents = new ArrayList(); private List policySets = new ArrayList(); - + /** * Constructs a new ConstrainingType */ @@ -73,7 +73,7 @@ public class ConstrainingTypeImpl extends ExtensibleImpl implements Constraining public List getRequiredIntents() { return requiredIntents; } - + public List getPolicySets() { return policySets; } @@ -82,7 +82,7 @@ public class ConstrainingTypeImpl extends ExtensibleImpl implements Constraining public int hashCode() { return String.valueOf(getName()).hashCode(); } - + @Override public boolean equals(Object obj) { if (obj == this) { @@ -97,12 +97,12 @@ public class ConstrainingTypeImpl extends ExtensibleImpl implements Constraining return false; } } - + public ExtensionType getExtensionType() { return null; } public void setExtensionType(ExtensionType type) { } - + } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java index ab8d7dc19e..89c7bd1eb7 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java @@ -37,15 +37,15 @@ public class ContractImpl extends ExtensibleImpl implements AbstractContract { private String name; private List requiredIntents = new ArrayList(); private List policySets = new ArrayList(); - + private boolean isCallback = false; - + /** * Constructs a new contract. */ protected ContractImpl() { } - + public String getName() { return name; } @@ -57,11 +57,11 @@ public class ContractImpl extends ExtensibleImpl implements AbstractContract { public InterfaceContract getInterfaceContract() { return interfaceContract; } - + public void setInterfaceContract(InterfaceContract interfaceContract) { this.interfaceContract = interfaceContract; } - + public List getRequiredIntents() { return requiredIntents; } @@ -80,7 +80,7 @@ public class ContractImpl extends ExtensibleImpl implements AbstractContract { public void setExtensionType(ExtensionType type) { } - + public List getPolicySets() { return policySets; } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/DistributedSCABindingImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/DistributedSCABindingImpl.java index d6bcbba797..fd58b44d21 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/DistributedSCABindingImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/DistributedSCABindingImpl.java @@ -34,34 +34,34 @@ public class DistributedSCABindingImpl implements DistributedSCABinding { private SCABinding scaBinding; - public SCABinding getSCABinding(){ + public SCABinding getSCABinding() { return scaBinding; } - public void setSCABinding(SCABinding scaBinding){ + public void setSCABinding(SCABinding scaBinding) { this.scaBinding = scaBinding; } - public String getURI(){ + public String getURI() { return null; } - public void setURI(String uri){ + public void setURI(String uri) { } - public String getName(){ + public String getName() { return null; } - public void setName(String name){ + public void setName(String name) { } - public boolean isUnresolved(){ + public boolean isUnresolved() { return false; } - public void setUnresolved(boolean unresolved){ + public void setUnresolved(boolean unresolved) { } 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 2a7c010c11..978d9e2b68 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 @@ -116,7 +116,7 @@ public class EndpointImpl implements Endpoint { * * @return callbackEndpoint the reference callback endpoint */ - public List getCallbackEndpointReferences(){ + public List getCallbackEndpointReferences() { resolve(); return callbackEndpointReferences; } @@ -142,10 +142,10 @@ public class EndpointImpl implements Endpoint { throw new UnsupportedOperationException(); } - public String toString(){ - String output = "Endpoint: "; + public String toString() { + String output = "Endpoint: "; - if (getURI() != null){ + if (getURI() != null) { output += " URI = " + uri; } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java index f017b598bf..1890687ca9 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java @@ -39,10 +39,8 @@ import org.apache.tuscany.sca.policy.PolicySubject; * @version $Rev$ $Date$ */ public class EndpointReferenceImpl implements EndpointReference { - private static final long serialVersionUID = 8838066441709300972L; - + private static final long serialVersionUID = 8838066441709300972L; - protected ExtensionPointRegistry registry; protected boolean unresolved = true; protected String uri; @@ -62,7 +60,7 @@ public class EndpointReferenceImpl implements EndpointReference { // will be directed toward protected Endpoint callbackEndpoint; - protected EndpointReferenceImpl(ExtensionPointRegistry registry){ + protected EndpointReferenceImpl(ExtensionPointRegistry registry) { this.registry = registry; } @@ -70,7 +68,7 @@ public class EndpointReferenceImpl implements EndpointReference { public Object clone() throws CloneNotSupportedException { EndpointReference cloned = (EndpointReference)super.clone(); - if (targetEndpoint != null){ + if (targetEndpoint != null) { cloned.setTargetEndpoint((Endpoint)targetEndpoint.clone()); } @@ -172,7 +170,7 @@ public class EndpointReferenceImpl implements EndpointReference { if (getURI() != null) { output += " URI = " + uri; } - + switch (status) { case 0: output += " NOT_CONFIGURED "; @@ -237,12 +235,12 @@ public class EndpointReferenceImpl implements EndpointReference { public void setExtensionPointRegistry(ExtensionPointRegistry registry) { this.registry = registry; } - + public int getStatus() { return status; } - + public void setStatus(int status) { - this.status = status; + this.status = status; } } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java index 761799a4d5..340fa2854c 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java @@ -38,12 +38,12 @@ public abstract class ExtensibleImpl extends BaseImpl implements Extensible { */ protected ExtensibleImpl() { } - + public List getExtensions() { return extensions; } - + public List getAttributeExtensions() { return attributeExtensions; } -} \ No newline at end of file +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java index 9befad9f2b..b5018c4d43 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java @@ -45,7 +45,7 @@ public class ExtensionImpl implements Extension { } public T getValue() { - return (T) value; + return (T)value; } public void setValue(T value) { diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java index 0c1051199f..263af296b1 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java @@ -33,13 +33,13 @@ import org.apache.tuscany.sca.policy.PolicySet; public class PropertyImpl extends AbstractPropertyImpl implements Property, Cloneable { private List policySets = new ArrayList(); private List applicablePolicySets = new ArrayList(); - + /** * Constructs a new property. */ protected PropertyImpl() { } - + @Override public Object clone() throws CloneNotSupportedException { return super.clone(); @@ -48,9 +48,9 @@ public class PropertyImpl extends AbstractPropertyImpl implements Property, Clon public List getPolicySets() { return policySets; } - + public void setPolicySets(List policySets) { - this.policySets = policySets; + this.policySets = policySets; } public List getApplicablePolicySets() { 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 454a24225f..af6e48959a 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 @@ -57,8 +57,8 @@ public class ReferenceImpl extends AbstractReferenceImpl implements Reference, C // clone the endpoint references themselves and set the reference pointer back to // this new refrence clone.endpointReferences = new ArrayList(); - - for (EndpointReference epr : endpointReferences){ + + for (EndpointReference epr : endpointReferences) { EndpointReference eprClone = (EndpointReference)epr.clone(); eprClone.setReference((ComponentReference)clone); clone.endpointReferences.add(eprClone); diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java index 7e311d8312..cf7e744e88 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java @@ -30,7 +30,7 @@ import org.apache.tuscany.sca.assembly.SCABindingFactory; */ public class SCABindingFactoryImpl implements SCABindingFactory { - public SCABindingFactoryImpl (){ + public SCABindingFactoryImpl() { } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java index 3a24759cd3..eecb1bfb47 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java @@ -100,7 +100,7 @@ public class SCABindingImpl implements SCABinding, Extensible, PolicySubject, Op } public boolean isUnresolved() { - if (targetComponentService == null){ + if (targetComponentService == null) { return true; } else { return targetComponentService.isUnresolved(); @@ -160,11 +160,11 @@ public class SCABindingImpl implements SCABinding, Extensible, PolicySubject, Op this.requiredIntents = intents; } - public void setIsAutomatic(boolean isAutomatic){ + public void setIsAutomatic(boolean isAutomatic) { this.isAutomatic = isAutomatic; } - public boolean getIsAutomatic(){ + public boolean getIsAutomatic() { return this.isAutomatic; } 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 8f1ce29fdb..087d950fb6 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 @@ -38,13 +38,12 @@ public class ServiceImpl extends AbstractServiceImpl implements Service, Cloneab private Callback callback; private List endpoints = new ArrayList(); - /** * Constructs a new service. */ protected ServiceImpl() { } - + @Override public Object clone() throws CloneNotSupportedException { ServiceImpl clone = (ServiceImpl)super.clone(); @@ -84,13 +83,13 @@ public class ServiceImpl extends AbstractServiceImpl implements Service, Cloneab public void setCallback(Callback callback) { this.callback = callback; } - + /** * By default return the interface contract for the service */ - public InterfaceContract getInterfaceContract(Binding binding){ + public InterfaceContract getInterfaceContract(Binding binding) { return getInterfaceContract(); - } + } public List getEndpoints() { return endpoints; diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java index 19e9b775d1..a4990f6a98 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java @@ -86,9 +86,9 @@ public class WireImpl extends ExtensibleImpl implements Wire, Cloneable { public void setExtensionType(ExtensionType type) { } - + public void setPolicySets(List policySets) { - this.policySets = policySets; + this.policySets = policySets; } public void setRequiredIntents(List intents) { diff --git a/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java b/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java index e73119204d..e58904cf00 100644 --- a/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java +++ b/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java @@ -23,7 +23,6 @@ import javax.xml.namespace.QName; import org.junit.BeforeClass; import org.junit.Test; - /** * Test building of assembly model instances using the assembly factory. * diff --git a/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java b/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java index ee6b95edc9..24be8a3e7d 100644 --- a/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java +++ b/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java @@ -29,7 +29,7 @@ import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractImpl; public class TestInterfaceContract extends InterfaceContractImpl implements InterfaceContract { public TestInterfaceContract(AssemblyFactory factory) { - + TestInterface testInterface = new TestInterface(factory); setInterface(testInterface); diff --git a/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderTestCase.java b/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderTestCase.java index 2b94fae610..8dc627b88c 100644 --- a/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderTestCase.java +++ b/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderTestCase.java @@ -38,14 +38,14 @@ import org.junit.Test; * @version $Rev$ $Date$ */ public class CompositeBuilderTestCase { - + private static AssemblyFactory assemblyFactory; - + @BeforeClass public static void setUp() throws Exception { assemblyFactory = new DefaultAssemblyFactory(); } - + @Test public void testFuseIncludes() throws Exception { Composite c1 = assemblyFactory.createComposite(); @@ -66,19 +66,19 @@ public class CompositeBuilderTestCase { Component b = assemblyFactory.createComponent(); b.setName("b"); c2.getComponents().add(b); - + Composite c = assemblyFactory.createComposite(); c.setName(new QName("http://foo", "C")); c.getIncludes().add(c1); - + new CompositeIncludeBuilderImpl(null).build(c, null, null); - + assertTrue(c.getComponents().get(0).getName().equals("a")); assertTrue(c.getComponents().get(1).getName().equals("b")); assertTrue(c.getServices().get(0).getName().equals("s")); assertTrue(c.getReferences().get(0).getName().equals("r")); } - + @Test public void testExpandComposites() throws Exception { Composite c1 = assemblyFactory.createComposite(); @@ -98,7 +98,7 @@ public class CompositeBuilderTestCase { Component b = assemblyFactory.createComponent(); b.setName("b"); c2.getComponents().add(b); - + Composite c = assemblyFactory.createComposite(); c.setName(new QName("http://foo", "C")); Component x = assemblyFactory.createComponent(); @@ -113,9 +113,9 @@ public class CompositeBuilderTestCase { z.setName("z"); z.setImplementation(c1); c.getComponents().add(z); - + new CompositeCloneBuilderImpl().build(c, null, null); - + assertTrue(c.getComponents().get(0).getImplementation() != c1); assertTrue(c.getComponents().get(1).getImplementation() != c2); assertTrue(c.getComponents().get(2).getImplementation() != c1); diff --git a/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/PrintUtilTestCase.java b/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/PrintUtilTestCase.java index 82b1fd8665..62141844cb 100644 --- a/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/PrintUtilTestCase.java +++ b/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/PrintUtilTestCase.java @@ -55,7 +55,7 @@ import org.junit.Test; public class PrintUtilTestCase { private AssemblyFactory factory = new DefaultAssemblyFactory(); - + /** * Create a composite */ @@ -225,5 +225,5 @@ public class PrintUtilTestCase { PrintUtil p = new PrintUtil(new PrintWriter(sw), false); p.print(composite); // System.out.println(sw.toString()); - } + } } -- cgit v1.2.3