diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 23:09:31 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 23:09:31 +0000 |
commit | a7c1a39d8c3c4ef4d5878dbff726085082a17e8a (patch) | |
tree | 54faa0e87eb8c8242a4a0baeb5f7b505a175d00f /branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache | |
parent | 4e13586bc791d71c41760cf4d0a5cc908973de3e (diff) |
Moving 2.x branches
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835136 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache')
103 files changed, 0 insertions, 12552 deletions
diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java deleted file mode 100644 index 0a14b5658e..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.policy.PolicySubject; - -/** - * Interface contracts define one or more business functions. These business - * functions are provided by services and are used by references. - * - * @version $Rev$ $Date$ - */ -public interface AbstractContract extends Base, Extensible, PolicySubject { - - /** - * Returns the name of the contract. - * - * @return the name of the contract - */ - String getName(); - - /** - * Sets the name of the contract. - * - * @param name the name of the contract - */ - void setName(String name); - - /** - * Returns the interface contract defining the interface and callback - * interface for the contract. - * - * @return the interface contract - */ - InterfaceContract getInterfaceContract(); - - /** - * Sets the interface contract defining the interface and callback - * interface for the contract. - * - * @param interfaceContract the interface contract - */ - void setInterfaceContract(InterfaceContract interfaceContract); - - /** - * Returns true if this contract is a reference or service created internally - * to handle a callback interface of another contract, false otherwise. - * - * @return true for a callback contract, false otherwise - */ - boolean isCallback(); - - /** - * Sets a flag indicating whether this is a callback contract. - * - * @param isCallback true for a callback contract, false otherwise - */ - void setIsCallback(boolean isCallback); - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java deleted file mode 100644 index fcad39d8cb..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -import javax.xml.namespace.QName; - -/** - * A property allows for the configuration of an implementation with externally - * set data values. An implementation can have zero or more properties. Each - * property has a data type, which may be either simple or complex. An - * implementation may also define a default value for a property. - * - * @version $Rev$ $Date$ - */ -public interface AbstractProperty extends Base, Extensible { - - /** - * Returns the property name. - * - * @return the property name - */ - String getName(); - - /** - * Sets the property name. - * - * @param name the property name - */ - void setName(String name); - - /** - * Returns the default value of the property. - * - * @return the default value of this property - */ - Object getValue(); - - /** - * Sets the default value of the property. - * - * @param defaultValue the default value of this property - */ - void setValue(Object defaultValue); - - /** - * Returns true if the property allows multiple values. - * - * @return true if the property allows multiple values - */ - boolean isMany(); - - /** - * Sets whether or not the property allows multiple values. - * - * @param many true if the property should allow multiple values - */ - void setMany(boolean many); - - /** - * Returns true if a value must be supplied for the property. - * - * @return true is a value must be supplied for the property - */ - boolean isMustSupply(); - - /** - * Sets whether a value must be supplied for the property. - * - * @param mustSupply set to true to require that a value be supplied for - * uses of this property - */ - void setMustSupply(boolean mustSupply); - - /** - * Returns the data type of this property. This is the qualified name of an - * XML schema type. - * - * @return the type of this property - */ - QName getXSDType(); - - /** - * Sets the data type of this property. This is the qualified name of an XML - * schema type. - * - * @param type the type of this property - */ - void setXSDType(QName type); - - /** - * Returns the element defining the data type of this property. This is the - * qualified name of an XML schema element. - * - * @return the element defining the type of this property - */ - QName getXSDElement(); - - /** - * Sets the element defining the data type of this property. This is the - * qualified name of an XML schema element. - * - * @param element the element defining the type of this property - */ - void setXSDElement(QName element); - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java deleted file mode 100644 index a9ef26bbb9..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -/** - * Represents a reference contract. - * - * @version $Rev$ $Date$ - */ -public interface AbstractReference extends AbstractContract { - - /** - * Returns the multiplicity allowed for wires connected to this reference. - * - * @return the multiplicity allowed for wires connected to this reference - */ - Multiplicity getMultiplicity(); - - /** - * Sets the multiplicity allowed for wires connected to this reference. - * - * @param multiplicity the multiplicity allowed for wires connected to this - * reference - */ - void setMultiplicity(Multiplicity multiplicity); - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.java deleted file mode 100644 index 9ae511c07b..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -/** - * Represents a service contract. - * - * @version $Rev$ $Date$ - */ -public interface AbstractService extends AbstractContract { - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java deleted file mode 100644 index 3c850dc053..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - - - -/** - * A factory for the assembly model - * - * @version $Rev$ $Date$ - */ -public interface AssemblyFactory { - - /** - * Create a new abstract property. - * - * @return a new abstract property - */ - AbstractProperty createAbstractProperty(); - - /** - * Create a new abstract reference. - * - * @return a new abstract reference - */ - AbstractReference createAbstractReference(); - - /** - * Create a new abstract service. - * - * @return a new abstract service - */ - AbstractService createAbstractService(); - - /** - * Create a new callback. - * - * @return - */ - Callback createCallback(); - - /** - * Create a new component. - * - * @return a new component - */ - Component createComponent(); - - /** - * Create a new component property. - * - * @return a new component property - */ - ComponentProperty createComponentProperty(); - - /** - * Create a new component reference. - * - * @return a new component reference - */ - ComponentReference createComponentReference(); - - /** - * Create a new component service. - * - * @return a new component service - */ - ComponentService createComponentService(); - - /** - * Create a new component type - * - * @return a new component type - */ - ComponentType createComponentType(); - - /** - * Create a new composite. - * - * @return a new composite - */ - Composite createComposite(); - - /** - * Create a new composite reference. - * - * @return a new composite reference - */ - CompositeReference createCompositeReference(); - - /** - * Create a new composite service. - * - * @return a new composite service - */ - CompositeService createCompositeService(); - - /** - * Create a new constraining type. - * - * @return a new constraining type - */ - ConstrainingType createConstrainingType(); - - /** - * Create a new property. - * - * @return a new property - */ - Property createProperty(); - - /** - * Create a new reference. - * - * @return a new reference - */ - Reference createReference(); - - /** - * Create a new service. - * - * @return a new service - */ - Service createService(); - - /** - * Create a new wire. - * - * @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 - * - * @return a new endpoint reference - */ - EndpointReference createEndpointReference(); -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java deleted file mode 100644 index 76511d351d..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - - -/** - * Base interface for all assembly model objects. - * - * @version $Rev$ $Date$ - */ -public interface Base { - - /** - * Returns true if the model element is unresolved. - * - * @return true if the model element is unresolved. - */ - boolean isUnresolved(); - - /** - * Sets whether the model element is unresolved. - * - * @param unresolved whether the model element is unresolved - */ - void setUnresolved(boolean unresolved); - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java deleted file mode 100644 index 0423e0b128..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - - - -/** - * Represents a binding. - * - * @version $Rev$ $Date$ - */ -public interface Binding extends Base, Cloneable { - - /** - * Returns the binding URI. - * - * @return the binding URI - */ - String getURI(); - - /** - * Sets the binding URI. - * - * @param uri the binding URI - */ - void setURI(String uri); - - /** - * Returns the binding name. - * - * @return the binding name - */ - String getName(); - - /** - * Sets the binding name. - * - * @param name the binding name - */ - void setName(String name); - - /** - * Clone the binding - * - * @return - */ - Object clone() throws CloneNotSupportedException; -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/BindingRRB.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/BindingRRB.java deleted file mode 100644 index b0bfdec6d7..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/BindingRRB.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - - -/** - * TODO RRB experiment. - * Represents a binding implemented using Request/Response binding chains - * Used to test the RRB idea hence no integrated into the Binding interface, yet - * - * @version $Rev$ $Date$ - */ -public interface BindingRRB extends Binding { - - WireFormat getRequestWireFormat(); - - void setRequestWireFormat(WireFormat wireFormat); - - WireFormat getResponseWireFormat(); - - void setResponseWireFormat(WireFormat wireFormat); - - OperationSelector getOperationSelector(); - - void setOperationSelector(OperationSelector operationSelector); - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java deleted file mode 100644 index d34ec7d01f..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -import java.util.List; - -import org.apache.tuscany.sca.policy.PolicySubject; - -/** - * Represents a callback object describing the bindings to use for callbacks. - * - * @version $Rev$ $Date$ - */ -public interface Callback extends Base, Extensible, PolicySubject { - - /** - * Returns the bindings supported for callbacks. - * - * @return the bindings supported for callbacks - */ - List<Binding> getBindings(); - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java deleted file mode 100644 index 7386fc8583..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -import java.util.List; - -import org.apache.tuscany.sca.policy.PolicySubject; - -/** - * Represents a component. A component is a configured instance of an - * implementation. - * - * @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. - * - * @param uri the URI of the component - */ - void setURI(String uri); - - /** - * Returns the name of the component. - * - * @return the name of the component - */ - String getName(); - - /** - * Sets the name of the component. - * - * @param name the name of the component - */ - void setName(String name); - - /** - * Returns the component implementation. - * - * @return the component implementation - */ - Implementation getImplementation(); - - /** - * Sets the component implementation - * - * @param implementation the component implementation - */ - void setImplementation(Implementation implementation); - - /** - * Returns a list of references used by the component. - * - * @return a list of references used by the component - */ - List<ComponentReference> getReferences(); - - /** - * Returns a list of services exposed by the component. - * - * @return a list of services exposed by the component - */ - List<ComponentService> getServices(); - - /** - * Returns a list of properties for the component. - * - * @return a list of properties - */ - List<ComponentProperty> getProperties(); - - /** - * Returns a constraining type defining the shape of the component. - * - * @return a constraining type - */ - ConstrainingType getConstrainingType(); - - /** - * Sets a constraining type defining the shape of the component. - * - * @param constrainingType the constraining type - */ - void setConstrainingType(ConstrainingType constrainingType); - - /** - * Return the Boolean value of autowire - * @return null/TRUE/FALSE - */ - Boolean getAutowire(); - - /** - * Sets whether component references should be autowired. - * - * @param autowire whether component references should be autowired - */ - void setAutowire(Boolean autowire); - - - /** - * Returns a clone of the component. - * - * @return a clone of the component - * @throws CloneNotSupportedException - */ - Object clone() throws CloneNotSupportedException; - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java deleted file mode 100644 index 13d19b1757..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -import javax.xml.xpath.XPathExpression; - -/** - * Represents a configured property of a component. - * - * @version $Rev$ $Date$ - */ -public interface ComponentProperty extends Property { - - /** - * Returns the property defined by the component implementation. - * - * @return the property defined by the component implementation - */ - Property getProperty(); - - /** - * Sets the property defined by this component implementation. - * - * @param property the property defined by this component implementation - */ - void setProperty(Property property); - - /** - * Returns an XPath expression referencing a property of the enclosing - * composite. - * - * @return an XPath expression referencing a property of the enclosing - * composite - */ - String getSource(); - - /** - * Sets an XPath expression referencing a property of the enclosing - * composite. - * - * @param source an XPath expression referencing a property of the enclosing - * 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 - */ - void setSourceXPathExpression(XPathExpression sourceXPathExpression); - - /** - * Returns a URI to a file containing the property value. - * - * @return a URI to a file containing the property value - */ - String getFile(); - - /** - * Sets a URI to a file containing the property value. - * - * @param file a URI to a file containing the property value - */ - void setFile(String file); - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java deleted file mode 100644 index e18d4d5d8c..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - - - - -/** - * An instance of a reference associated with a particular component. - * - * @version $Rev$ $Date$ - */ -public interface ComponentReference extends Reference { - - /** - * Returns the reference defined by the implementation for this reference. - * - * @return the implementation reference - */ - Reference getReference(); - - /** - * Sets the reference defined by the implementation for this reference. - * - * @param reference the implementation reference - */ - void setReference(Reference reference); - - /** - * Return the Boolean value of autowire - * @return null/TRUE/FALSE - */ - Boolean getAutowire(); - - /** - * Sets whether component references should be autowired. - * - * @param autowire whether component references should be autowired - */ - void setAutowire(Boolean autowire); - - - /** - * Returns the callback service created internally as a target endpoint - * for callbacks to this reference. - * - * @return the callback service - */ - ComponentService getCallbackService(); - - /** - * Sets the callback service created internally as a target endpoint - * for callbacks to this reference. - * - * @param callbackService the callback service - */ - void setCallbackService(ComponentService callbackService); - - /** - * A boolean value, "false" by default, which indicates whether this component reference - * can have its targets overridden by a composite reference which promotes the - * component reference. - * - * If @nonOverridable==false, the target(s) of the promoting composite reference - * replace all the targets explicitly declared on the component reference for any - * value of @multiplicity on the component reference. - * - * If the component reference has @nonOverridable==false and @multiplicity 1..1 - * and the reference has a target, then any composite reference which promotes - * the component reference has @multiplicity 0..1.by default and MAY have an explicit @multiplicity of either - * 0..1 or 1..1. - * - * If @nonOverridable==true, and the component reference has @multiplicity 0..1 or - * 1..1 and the component reference also declares a target, promotion implies - * that the promoting composite reference has @wiredbyImpl==true and the composite - * reference cannot supply a target, but can influence the policy attached to the - * component reference. - * - * If @nonOverridable==true, and the component reference @multiplicity is 0..n - * or 1..n, promotion targeting is additive - * - * @return - */ - boolean isNonOverridable(); - - /** - * Set the nonOverridable flag - * @param nonOverridable - */ - void setNonOverridable(boolean nonOverridable); - - /** - * Sets whether this Component Reference is promoted - * @param isPromoted - true if the component reference is promoted - */ - void setPromoted( boolean isPromoted ); - boolean isPromoted(); - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java deleted file mode 100644 index 65945692f1..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - - -/** - * An addressable instance of a service associated with a particular component. - * - * @version $Rev$ $Date$ - */ -public interface ComponentService extends Service { - - /** - * Returns the service defined by the implementation for this service. - * - * @return - */ - Service getService(); - - /** - * Sets the service defined by the implementation for this service. - * - * @param service - */ - void setService(Service service); - - /** - * Returns the callback reference created internally as a source endpoint - * for callbacks from this service. - * - * @return the callback reference - */ - ComponentReference getCallbackReference(); - - /** - * Sets the callback reference created internally as a source endpoint - * for callbacks from this service. - * - * @param callbackReference the callback reference - */ - void setCallbackReference(ComponentReference callbackReference); - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java deleted file mode 100644 index 9fb3b92102..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -import java.util.List; - -import org.apache.tuscany.sca.policy.PolicySubject; - -/** - * Describes an implementation and represents its configurable aspects. - * - * @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 - */ - void setURI(String uri); - - /** - * Returns a list of services that are offered. - * - * @return a list of services that are offered - */ - List<Service> getServices(); - - /** - * Returns the list of reference types that are used. - * - * @return the list of reference types that are used - */ - List<Reference> getReferences(); - - /** - * Returns the list of properties that can be set. - * - * @return the list of properties that can be set - */ - List<Property> getProperties(); - - /** - * Returns a constraining type defining the shape of the implementation. - * - * @return a constraining type - */ - ConstrainingType getConstrainingType(); - - /** - * Sets a constraining type defining the shape of the implementation. - * - * @param constrainingType the constraining type to set - */ - void setConstrainingType(ConstrainingType constrainingType); - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java deleted file mode 100644 index 12542297b3..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -import java.util.List; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.policy.PolicySubject; - - -/** - * Represents a composite. - * - * @version $Rev$ $Date$ - */ -public interface Composite extends Implementation, Extensible, Cloneable, PolicySubject { - - /** - * Returns the spec version of the composite used to build this model - * - * @return the spec version used to build this model - */ - String getSpecVersion(); - - /** - * Sets the spec version of the composite used to build this model - * - * @param specVersion the spec version used to build this model - */ - void setSpecVersion(String specVersion); - - /** - * Returns the name of the composite. - * - * @return the name of the composite - */ - QName getName(); - - /** - * Sets the name of the composite. - * - * @param name the name of the composite - */ - void setName(QName name); - - /** - * Returns a list of composites included in this composite. - * - * @return a list of composites included in this composite. - */ - List<Composite> getIncludes(); - - /** - * Returns a list of components contained in this composite. - * - * @return a list of components contained in this composite - */ - List<Component> getComponents(); - - /** - * Returns a list of wires contained in this composite. - * - * @return a list of wires contained in this composite - */ - List<Wire> getWires(); - - /** - * Returns true if all the components within the composite must run in the - * same process. - * - * @return true if all the components within the composite must run in the - * same process - */ - boolean isLocal(); - - /** - * Sets whether all the components within the composite must run in the same - * process. - * - * @param local whether all the components within the composite must run in - * the same process - */ - void setLocal(boolean local); - - /** - * Return the Boolean value of autowire - * @return null/TRUE/FALSE - */ - Boolean getAutowire(); - - /** - * Sets whether component references should be autowired. - * - * @param autowire whether component references should be autowired - */ - void setAutowire(Boolean autowire); - - - /** - * Returns a clone of the component type. - * - * @return a clone of the component type - * @throws CloneNotSupportedException - */ - Object clone() throws CloneNotSupportedException; - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java deleted file mode 100644 index 9defd8f66c..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -import java.util.List; - -/** - * Represents composite reference. - * - * @version $Rev$ $Date$ - */ -public interface CompositeReference extends Reference { - /** - * Returns the promoted components. For each promoted component/reference, - * they have the same index in the component and reference list. - * - * @return the promoted components - */ - List<Component> getPromotedComponents(); - - /** - * Returns the promoted component references. - * - * @return the promoted component references - */ - List<ComponentReference> getPromotedReferences(); - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java deleted file mode 100644 index 7143f571f9..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -/** - * Represents a composite service. - * - * @version $Rev$ $Date$ - */ -public interface CompositeService extends Service { - - /** - * Returns the promoted component. - * - * @return the promoted component. - */ - Component getPromotedComponent(); - - /** - * Sets the promoted component - * - * @param promotedComponent the promoted component. - */ - void setPromotedComponent(Component promotedComponent); - - /** - * Returns the promoted component service . - * - * @return the promoted component service. - */ - ComponentService getPromotedService(); - - /** - * Sets the promoted component service - * - * @param promotedService the promoted component service. - */ - void setPromotedService(ComponentService promotedService); - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConstrainingType.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConstrainingType.java deleted file mode 100644 index 74c2e70d30..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConstrainingType.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -import java.util.List; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.policy.PolicySubject; - -/** - * A constrainingType provides the "shape" for a component and its - * implementation. Any component configuration that points to a constrainingType - * is constrained by this shape. The constrainingType specifies the services, - * references and properties that must be implemented. - * - * @version $Rev$ $Date$ - */ -public interface ConstrainingType extends Base, Extensible, PolicySubject { - - /** - * Returns the name of the constrainingType. - * - * @return the name of the constrainingType - */ - QName getName(); - - /** - * Sets the name of the constrainingType. - * - * @param name the name of the constrainingType - */ - void setName(QName name); - - /** - * Returns a list of services that are offered. - * - * @return a list of services that are offered - */ - List<AbstractService> getServices(); - - /** - * Returns the list of references that are used. - * - * @return the list of references that are used - */ - List<AbstractReference> getReferences(); - - /** - * Returns the list of properties that can be set. - * - * @return the list of properties that can be set - */ - List<AbstractProperty> getProperties(); - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java deleted file mode 100644 index 54d6347301..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -import java.util.List; - -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.policy.PolicySubject; - -/** - * Represents a contract. A contract can be either a service or a reference. - * - * @version $Rev$ $Date$ - */ -public interface Contract extends AbstractContract, PolicySubject, Cloneable { - - /** - * Returns the bindings supported by this contract. - * - * @return the bindings supported by this contract - */ - List<Binding> getBindings(); - - /** - * Returns a binding of the specified type or null if there is no such - * binding configured on this contract. - * - * @param <B> the binding type - * @param bindingClass the binding type class - * @return the binding or null if there is no binding of the specified type - */ - <B> B getBinding(Class<B> bindingClass); - - /** - * Returns a callback binding of the specified type or null if there is no such - * callback binding configured on this contract. - * - * @param <B> the callback binding type - * @param bindingClass the callback binding type class - * @return the callback binding or null if there is no callback binding of the specified type - */ - <B> B getCallbackBinding(Class<B> bindingClass); - - /** - * Returns a callback definition of the bindings to use for callbacks. - * - * @return a definition of the bindings to use for callbacks - */ - Callback getCallback(); - - /** - * Sets a callback definition of the bindings to use for callbacks - * - * @param callback a definition of the bindings to use for callbacks - */ - void setCallback(Callback callback); - - /** - * Returns a clone of the contract. - * - * @return a clone of the reference - * @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 - * resolved bindings extended by a promoting reference. Here the binding - * from the promoting reference may need the interface contract from the - * promoting reference and not the promoted reference. - * TODO - remove this wrinkle with better endpoint support. - * - * @param binding the binding for which the interface contract is required - * @return the interface contract - */ - InterfaceContract getInterfaceContract(Binding binding); - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.java deleted file mode 100644 index 6d8350fc66..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly; - -import org.apache.tuscany.sca.assembly.impl.AssemblyFactoryImpl; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; - -/** - * A factory for the assembly model. - * - * @version $Rev$ $Date$ - */ -public class DefaultAssemblyFactory extends AssemblyFactoryImpl implements AssemblyFactory { - - public DefaultAssemblyFactory(ExtensionPointRegistry registry) { - super(registry); - } - - public DefaultAssemblyFactory() { - super(new DefaultExtensionPointRegistry()); - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DistributedSCABinding.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DistributedSCABinding.java deleted file mode 100644 index f8adb980be..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DistributedSCABinding.java +++ /dev/null @@ -1,46 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.assembly;
-
-import org.apache.tuscany.sca.assembly.Binding;
-import org.apache.tuscany.sca.assembly.SCABinding;
-
-
-/**
- * Represents an SCA binding used in the distributed runtime.
- * At the moment just provides us with a sensibly named type
- * against which the distributed sca binding providers can be registered
- *
- * @version $Rev: 556322 $ $Date: 2007-07-14 19:53:15 +0100 (Sat, 14 Jul 2007) $
- */
-public interface DistributedSCABinding extends Binding {
-
- /**
- * Return the wrapped SCA binding
- * @return the SCA binding model element
- */
- SCABinding getSCABinding();
-
- /**
- * Set the wrapped SCA binding
- * @param scaBinding the SCA binding model element
- */
- void setSCABinding(SCABinding scaBinding);
-
-}
diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java deleted file mode 100644 index 5aa26e16cf..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -import java.io.Serializable; -import java.util.List; - -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.policy.PolicySubject; - -/** - * Represents a service endpoint which is what results from having a configured - * binding applied to a component service. In a deployed application an endpoint - * will relate directly to a physical endpoint, for example, a HTTP URL or a - * JMS destination. - * - * @version $Rev$ $Date$ - */ -public interface Endpoint extends Base, PolicySubject, Cloneable, Serializable { - /** - * Get the structural URI of the service binding - * @return structural URI of the service/binding - */ - String getURI(); - - /** - * Set the structural URI of the service binding - * @param uri <componentURI>#service-binding(serviceName/bindingName) - * or <componentURI>#service(serviceName) - */ - void setURI(String uri); - /** - * Supports endpoint cloning - * - * @return endpoint - * @throws CloneNotSupportedException - */ - Object clone() throws CloneNotSupportedException; - - /** - * Get the component model object - * - * @return component - */ - Component getComponent(); - - /** - * Set the component model object - * - * @param component - */ - void setComponent(Component component); - - /** - * Get the service model object - * - * @return service - */ - ComponentService getService(); - - /** - * Set the service model object - * - * @param service - */ - void setService(ComponentService service); - - /** - * Get the resolved target binding - * - * @return target binding - */ - Binding getBinding(); - - /** - * Set the binding - * - * @param binding - */ - void setBinding(Binding binding); - - /** - * Returns the interface contract defining the interface - * - * @return the interface contract - */ - InterfaceContract getInterfaceContract(); - - /** - * Sets the interface contract defining the interface - * - * @param interfaceContract the interface contract - */ - void setInterfaceContract(InterfaceContract interfaceContract); - - /** - * Get the service's callback endpoint references that - * represent endpoint references from which callbacks - * originate - * - * @return callbackEndpoint the reference callback endpoint - */ - List<EndpointReference> getCallbackEndpointReferences(); - - /** - * Set the extension point registry against the endpoint after it is deserialized as - * the registry needs to be re-attached - * - * @param registry - */ - void setExtensionPointRegistry(ExtensionPointRegistry registry); - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java deleted file mode 100644 index 204719e7e4..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -import java.io.Serializable; - -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.policy.PolicySubject; - -/** - * Represents an endpoint reference. An SCA reference can reference service endpoints in a - * number of ways. Target names, autowire, configured bindings. The endpoint reference - * captures the result of specifying one of these things. - * - * @version $Rev$ $Date$ - */ -public interface EndpointReference extends Base, PolicySubject, Cloneable, Serializable { - /** - * Get the structural URI of the reference binding - * @return The structural URI of the reference/binding - */ - String getURI(); - - /** - * Set the structural URI of the reference binding - * @param uri <componentURI>#reference-binding(referenceName/bindingName) - * or <componentURI>#reference(referenceName) if binding is not present - * - */ - void setURI(String uri); - - /** - * Supports endpoint reference cloning - * - * @return endpointReference - * @throws CloneNotSupportedException - */ - Object clone() throws CloneNotSupportedException; - - /** - * Get the component model object - * - * @return component - */ - Component getComponent(); - - /** - * Set the component model object - * - * @param component the component for the endpoint - */ - void setComponent(Component component); - - /** - * Get the source component reference model object - * - * @return reference the source component reference for the endpoint - */ - ComponentReference getReference(); - - /** - * Set the source component reference model object - * - * @param reference - */ - void setReference(ComponentReference reference); - - /** - * Get the resolved reference binding - * - * @return binding the resolved reference binding - */ - Binding getBinding(); - - /** - * Set the resolved reference binding - * - * @param binding the resolved reference binding - */ - void setBinding(Binding binding); - - /** - * Get the target endpoint - * - * @return endpoint the target endpoint - */ - Endpoint getTargetEndpoint(); - - /** - * Set the target endpoint model object - * - * @param endpoint the target endpoint - */ - void setTargetEndpoint(Endpoint targetEndpoint); - - /** - * Returns the interface contract defining the interface - * - * @return the interface contract - */ - InterfaceContract getInterfaceContract(); - - /** - * Sets the interface contract defining the interface - * - * @param interfaceContract the interface contract - */ - void setInterfaceContract(InterfaceContract interfaceContract); - - /** - * Get the reference callback endpoint that - * represents that target endpoint to which callback - * messages will be directed - * - * @return callbackEndpoint the reference callback endpoint - */ - Endpoint getCallbackEndpoint(); - - /** - * Set the reference callback endpoint - * - * @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 - * - * @return true if the endpoint is remote - */ - boolean getIsRemoteReference(); - - /** - * Set true if this endpoint reference refers to an endpoint that - * is not running in this endpoint reference - * - * @param isRemoteReference set to true if the endpoint is remote - */ - void setIsRemoteReference(boolean isRemoteReference); - - /** - * Set the extension point registry against the endpoint after it is deserialized as - * the registry needs to be re-attached - * - * @param registry - */ - void setExtensionPointRegistry(ExtensionPointRegistry registry); -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java deleted file mode 100644 index 90d6745f35..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -import java.util.List; - -/** - * Base interface for extensible assembly model objects. - * - * @version $Rev$ $Date$ - */ -public interface Extensible extends Base { - - /** - * Returns a list of extension objects contained in this model object. - * - * @return a list of extension objects container in this model object - */ - List<Object> getExtensions(); - - /** - * Returns a list of attribute extensions contained in this model object - * - * @return a list of attribute extensions contained in this model object - */ - List<Extension> getAttributeExtensions(); - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java deleted file mode 100644 index 4d5b1a2ecd..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -import javax.xml.namespace.QName; - -/** - * Base interface for storing contents of extensible assembly model objects. - * - * @version $Rev$ $Date$ - */ -public interface Extension { - - /** - * Return QName for the extension - * @return the extension QName - */ - QName getQName(); - - /** - * Set QName for the extension - * @param qName the extension QName - */ - void setQName(QName qName); - - /** - * Return the original extension value - * @return the extension value - */ - <T> T getValue(); - - /** - * Set the original extension value - * @param value the extension value - */ - <T> void setValue(T value); - - /** - * Return whether or not the extension is an attribute - * @return - */ - boolean isAttribute(); - - /** - * Set whether or not the extension is an attribute - * @param value - */ - void setAttribute(boolean isAttribute); -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java deleted file mode 100644 index 720a6801a2..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -/** - * Represents a component implementation. - * - * @version $Rev$ $Date$ - */ -public interface Implementation extends ComponentType { -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.java deleted file mode 100644 index 5d15ce9938..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -/** - * Enumeration for multiplicity. Defines the number of wires that can connect a - * reference to target services. - * - * @version $Rev$ $Date$ - */ -public enum Multiplicity { - - /** - * Zero or one wire can have the reference as a source. - */ - ZERO_ONE, - - /** - * The default setting, one wire can have the reference as a source. - */ - ONE_ONE, - - /** - * Zero or more wires can have the reference as a source. - */ - ZERO_N, - - /** - * One or more wires can have the reference as a source. - */ - ONE_N - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java deleted file mode 100644 index 6770e87ee1..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - - -/** - * Represents an operationSelector - * - * @version $Rev$ $Date$ - */ -public interface OperationSelector extends Base, Cloneable { - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OptimizableBinding.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OptimizableBinding.java deleted file mode 100644 index 98ff92f15b..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OptimizableBinding.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -/** - * Represent a reference binding that supports optimized SCA local wiring between component - * references and services - * - * @version $Rev$ $Date$ - * - */ -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 - */ - ComponentService getTargetComponentService(); - - /** - * Clone the binding - * @return - */ - Object clone() throws CloneNotSupportedException; - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java deleted file mode 100644 index 986e1f12e4..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - - -/** - * A property allows for the configuration of an implementation with externally - * set data values. An implementation can have zero or more properties. Each - * property has a data type, which may be either simple or complex. An - * implementation may also define a default value for a property. - * - * @version $Rev$ $Date$ - */ -public interface Property extends AbstractProperty, Cloneable { - - /** - * Returns a clone of the property. - * - * @return a clone of the property - * @throws CloneNotSupportedException - */ - Object clone() throws CloneNotSupportedException; - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java deleted file mode 100644 index 08344ca24f..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -import java.util.List; - -/** - * Represents a reference. References within an implementation represent links - * to services that the implementation uses that must be provided by other - * components. - * - * @version $Rev$ $Date$ - */ -public interface Reference extends AbstractReference, Contract { - - /** - * Returns a boolean value, "false" by default, which indicates that the - * implementation wires this reference dynamically. - * - * @return true if the implementation wires this reference dynamically - */ - boolean isWiredByImpl(); - - /** - * Sets a boolean value, "false" by default, which indicates that the - * implementation wires this reference dynamically. - * - * @param wiredByImpl whether the implementation wires this reference - * dynamically - */ - void setWiredByImpl(boolean wiredByImpl); - - /** - * Returns a boolean value, "false" by default, which indicates whether - * the configuration of this reference is a promotion override for - * another more deeply nested reference. - * - * @return true if the reference is a promotion override - */ - boolean isPromotionOverride(); - - /** - * Sets a boolean value, "false" by default, which indicates whether - * the configuration of this reference is a promotion override for - * another more deeply nested reference. - * - * @param promotionOverride whether the reference is a promotion override - */ - void setPromotionOverride(boolean promotionOverride); - - /** - * Returns the targets of this reference. - * - * @return the targets of this reference. - */ - List<ComponentService> getTargets(); - - /** - * Returns the endpoint references implied by this reference. - * - * Endpoint references are used to represent: - * - * - manually specified reference targets - * - reference targets determined by autowire - * - manually configured remote bindings - * - * @return the endpoint references implied by this reference - */ - List<EndpointReference> getEndpointReferences(); - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java deleted file mode 100644 index 2cf04277cd..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -/** - * Represents an SCA binding. - * - * @version $Rev$ $Date$ - */ -public interface SCABinding extends Binding { -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java deleted file mode 100644 index 74dde43614..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - - -/** - * A factory for the SCA binding model - * - * @version $Rev$ $Date$ - */ -public interface SCABindingFactory { - - /** - * Create a new SCA binding. - * - * @return a new SCA binding - */ - SCABinding createSCABinding(); - - DistributedSCABinding createDistributedSCABinding(); - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java deleted file mode 100644 index e597a50f30..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -import java.util.List; - -/** - * Represents a service. Services are used to publish services provided by - * implementations, so that they are addressable by other components. - * - * @version $Rev$ $Date$ - */ -public interface Service extends AbstractService, Contract { - /** - * Returns the endpoints implied by this service. - * - * Endpoints represent configured bindings for a service. Hence a service - * with two bindings will expose two Endpoints. Where a promoted service has - * new binding configuration applied by a promoting component Endpoints are - * introduced to represent these new bindings. - * - * @return the endpoints implied by this service - */ - List<Endpoint> getEndpoints(); -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java deleted file mode 100644 index e1eb26f0c1..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - -import org.apache.tuscany.sca.policy.PolicySubject; - -/** - * Represents a wire. - * - * @version $Rev$ $Date$ - */ -public interface Wire extends Base, Extensible, PolicySubject, Cloneable { - - /** - * Returns the source of the wire. - * - * @return the source of the wire - */ - ComponentReference getSource(); - - /** - * Sets the source of the wire. - * - * @param source the source of the wire - */ - void setSource(ComponentReference source); - - /** - * Returns the target of the wire. - * - * @return the target of the wire - */ - ComponentService getTarget(); - - /** - * Sets the target of the wire. - * - * @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 - * the reference identified by the @source attribute. When a wire element - * has @replace="true", the wire is added to the set of wires which apply to - * the reference identified by the @source attribute - but any wires for that - * reference specified by means of the @target attribute of the reference - * are removed from the set of wires which apply to the reference. - * - * @return - */ - boolean isReplace(); - - /** - * Set the replace flag for the wire - * @param replace - */ - void setReplace(boolean replace); - - /** - * Returns a clone of the wire. - * - * @return a clone of the wire - * @throws CloneNotSupportedException - */ - Object clone() throws CloneNotSupportedException; - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.java deleted file mode 100644 index d8c530585e..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly; - - -/** - * Represents a wireFormat. - * - * @version $Rev$ $Date$ - */ -public interface WireFormat extends Base, Cloneable { - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/AutomaticBinding.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/AutomaticBinding.java deleted file mode 100644 index 97708f9ef5..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/AutomaticBinding.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.builder; - -/** - * Represent a binding that has been added automatically to the model rather - * than being specified by the user through the composite file - * - * @version $Rev$ $Date$ - * - */ -public interface AutomaticBinding extends Cloneable { - - /** - * @param isAutomatic - */ - void setIsAutomatic(boolean isAutomatic); - - /** - * @return isAutomatic - */ - boolean getIsAutomatic(); -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java deleted file mode 100644 index 7bac630d5b..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder; - -import org.apache.tuscany.sca.assembly.AbstractContract; -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * A builder that handles any build-time configuration needed by bindings. - * - * @version $Rev$ $Date$ - */ -public interface BindingBuilder { - - /** - * Configure a binding. - * - * @param component The component for the binding's service or reference - * @param contract The binding's service or reference - */ - void build(Component component, AbstractContract contract, Binding binding, Monitor monitor); - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilderExtension.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilderExtension.java deleted file mode 100644 index 37ad8af0b3..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilderExtension.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder; - -/** - * An extension that can be implemented by bindings to provide a binding builder. - * - * @version $Rev$ $Date$ - */ -public interface BindingBuilderExtension { - - /** - * Returns the binding builder. - * - * @return the binding builder - */ - BindingBuilder getBuilder(); - - /** - * Sets the binding builder. - * - * @param builder the binding builder - */ - void setBuilder(BindingBuilder builder); - -} - diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ComponentPreProcessor.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ComponentPreProcessor.java deleted file mode 100644 index d2fae4d24a..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ComponentPreProcessor.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder; - -import org.apache.tuscany.sca.assembly.Component; - -/** - * Interface for Component Pre Processors. - * - * @version $Rev$ $Date$ - */ -public interface ComponentPreProcessor { - - void preProcess(Component component); - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java deleted file mode 100644 index 8a18f74b2b..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * A builder that handles the configuration of the components inside a - * composite and the wiring of component references to component services. - * - * @version $Rev$ $Date$ - */ -public interface CompositeBuilder { - - /** - * Returns the ID of the builder. - * - * @return - */ - String getID(); - - /** - * Build a composite. - * - * @param composite - * @param definitions - * @param monitor - * @throws CompositeBuilderException - */ - void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException; - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java deleted file mode 100644 index 5a2015f55e..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder; - -/** - * Reports a composite builder exception. - * - * @version $Rev$ $Date$ - */ -public class CompositeBuilderException extends Exception { - private static final long serialVersionUID = -8916323176803443856L; - - public CompositeBuilderException() { - } - - public CompositeBuilderException(String message) { - super(message); - } - - public CompositeBuilderException(Throwable cause) { - super(cause); - } - - public CompositeBuilderException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderExtensionPoint.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderExtensionPoint.java deleted file mode 100644 index a2d6b34db5..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderExtensionPoint.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder; - -/** - * An extension point for Composite builders. - * - * @version $Rev: $ $Date: $ - */ -public interface CompositeBuilderExtensionPoint { - - /** - * Adds a composite builder. - * - * @param compositeBuilder - */ - void addCompositeBuilder(CompositeBuilder compositeBuilder); - - /** - * Removes a composite builder. - * - * @param compositeBuilder - */ - void removeCompositeBuilder(CompositeBuilder compositeBuilder); - - /** - * Returns the composite builder with the given id. - * - * @param id - * @return - */ - CompositeBuilder getCompositeBuilder(String id); - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java deleted file mode 100644 index 32444349b2..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder; - -import java.lang.reflect.Constructor; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.core.UtilityExtensionPoint; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.extensibility.ServiceDeclaration; -import org.apache.tuscany.sca.extensibility.ServiceDiscovery; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * Default implementation of a provider factory extension point. - * - * @version $Rev$ $Date$ - */ -public class DefaultCompositeBuilderExtensionPoint implements CompositeBuilderExtensionPoint { - - private ExtensionPointRegistry registry; - private final Map<String, CompositeBuilder> builders = new HashMap<String, CompositeBuilder>(); - private boolean loaded; - - public DefaultCompositeBuilderExtensionPoint(ExtensionPointRegistry registry) { - this.registry = registry; - } - - public void addCompositeBuilder(CompositeBuilder builder) { - builders.put(builder.getID(), builder); - } - - public void removeCompositeBuilder(CompositeBuilder builder) { - builders.remove(builder.getID()); - } - - public CompositeBuilder getCompositeBuilder(String id) { - loadBuilders(); - return builders.get(id); - } - - /** - * Load builders declared under META-INF/services. - */ - private synchronized void loadBuilders() { - if (loaded) - return; - - FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class); - - UtilityExtensionPoint utils = registry.getExtensionPoint(UtilityExtensionPoint.class); - InterfaceContractMapper mapper = utils.getUtility(InterfaceContractMapper.class); - - // Get the provider factory service declarations - Collection<ServiceDeclaration> builderDeclarations; - ServiceDiscovery serviceDiscovery = ServiceDiscovery.getInstance(); - try { - builderDeclarations = serviceDiscovery.getServiceDeclarations(CompositeBuilder.class.getName()); - } catch (Exception e) { - throw new IllegalStateException(e); - } - - for (ServiceDeclaration builderDeclaration : builderDeclarations) { - Map<String, String> attributes = builderDeclaration.getAttributes(); - String id = attributes.get("id"); - - CompositeBuilder builder = new LazyCompositeBuilder(registry, id, builderDeclaration, this, factories, mapper); - builders.put(id, builder); - } - } - - /** - * A wrapper around a composite builder allowing lazy - * loading and initialization of implementation providers. - */ - private static class LazyCompositeBuilder implements CompositeBuilder { - - private ExtensionPointRegistry registry; - private FactoryExtensionPoint factories; - private InterfaceContractMapper mapper; - private String id; - private ServiceDeclaration builderDeclaration; - private CompositeBuilder builder; - private CompositeBuilderExtensionPoint builders; - - private LazyCompositeBuilder(ExtensionPointRegistry registry, String id, ServiceDeclaration factoryDeclaration, - CompositeBuilderExtensionPoint builders, FactoryExtensionPoint factories, InterfaceContractMapper mapper) { - this.registry = registry; - this.id = id; - this.builderDeclaration = factoryDeclaration; - this.builders = builders; - this.factories = factories; - this.mapper = mapper; - } - - public String getID() { - return id; - } - - public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { - getBuilder().build(composite, definitions, monitor); - } - - private CompositeBuilder getBuilder() { - if (builder == null) { - try { - Class<CompositeBuilder> builderClass = (Class<CompositeBuilder>)builderDeclaration.loadClass(); - try { - Constructor<CompositeBuilder> constructor = builderClass.getConstructor(FactoryExtensionPoint.class, InterfaceContractMapper.class); - builder = constructor.newInstance(factories, mapper); - } catch (NoSuchMethodException e) { - try { - Constructor<CompositeBuilder> constructor = builderClass.getConstructor(CompositeBuilderExtensionPoint.class, FactoryExtensionPoint.class, InterfaceContractMapper.class); - builder = constructor.newInstance(builders, factories, mapper); - } catch (NoSuchMethodException ex) { - Constructor<CompositeBuilder> constructor = builderClass.getConstructor(ExtensionPointRegistry.class); - builder = constructor.newInstance(registry); - } - } - } catch (Exception e) { - throw new IllegalStateException(e); - } - } - return builder; - } - - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DomainBuilder.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DomainBuilder.java deleted file mode 100644 index 20a17e1bd0..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DomainBuilder.java +++ /dev/null @@ -1,80 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.assembly.builder;
-
-import java.util.List;
-
-import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.assembly.Service;
-
-/**
- * A builder that handles the configuration of the components inside a
- * composite and the wiring of component references to component services.
- *
- * @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
- *
- * @param domainLevelCompsite
- * @return a list of change composites
- * @throws CompositeBuilderException
- */
- List<Composite> wireDomain(Composite domainLevelComposite);
-
- /**
- * Locates the referenced service and updates the URI on the identified binding
- *
- * @param domainLevelComposite
- * @param referenceName
- * @param bindingClassName
- * @param 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
- *
- * @param referenceName
- * @return
- */
- String getComponentNameFromReference(String referenceName);
-
- /**
- * Get the service name out of the reference name that might look like Component/Service
- *
- * @param referenceName
- * @return
- */
- String getServiceNameFromReference(String referenceName);
-
- /**
- * Find the service object given a reference name
- *
- * @param composite
- * @param referenceName
- * @return
- */
- Service findServiceForReference(Composite composite, String referenceName);
-
-}
diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointReferenceBuilder.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointReferenceBuilder.java deleted file mode 100644 index 220d82eab9..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointReferenceBuilder.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder; - -import org.apache.tuscany.sca.assembly.EndpointReference; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * A builder that handles the configuration of endpoint references - * It collects together the logic so that it can be used at build time - * or later on during late binding scenarios - * - * @version $Rev$ $Date$ - */ -public interface EndpointReferenceBuilder { - - /** - * Build an endpoint reference matching reference bindings - * with service bindings. - * - * @param endpointReference - * @param monitor - */ - void build(EndpointReference endpointReference, Monitor monitor); - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java deleted file mode 100644 index 59dbc85d1f..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java +++ /dev/null @@ -1,622 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder.impl; - -import java.util.Map; - -import javax.xml.namespace.QName; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.TransformerFactory; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentProperty; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.assembly.SCABindingFactory; -import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.assembly.builder.AutomaticBinding; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -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; -import org.apache.tuscany.sca.policy.ExtensionType; -import org.apache.tuscany.sca.policy.PolicySubject; - -/** - * Base class for Builder implementations - * - * @version $Rev$ $Date$ - */ -public abstract class BaseBuilderImpl implements CompositeBuilder { - protected static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903"; - protected static final String BINDING_SCA = "binding.sca"; - protected static final QName BINDING_SCA_QNAME = new QName(SCA11_NS, BINDING_SCA); - - protected AssemblyFactory assemblyFactory; - protected SCABindingFactory scaBindingFactory; - protected InterfaceContractMapper interfaceContractMapper; - protected DocumentBuilderFactory documentBuilderFactory; - protected TransformerFactory transformerFactory; - - - protected BaseBuilderImpl(AssemblyFactory assemblyFactory, - SCABindingFactory scaBindingFactory, - DocumentBuilderFactory documentBuilderFactory, - TransformerFactory transformerFactory, - InterfaceContractMapper interfaceContractMapper) { - this.assemblyFactory = assemblyFactory; - this.scaBindingFactory = scaBindingFactory; - this.documentBuilderFactory = documentBuilderFactory; - this.transformerFactory = transformerFactory; - this.interfaceContractMapper = interfaceContractMapper; - } - - /** - * Report a warning. - * - * @param monitor - * @param problems - * @param message - * @param model - */ - 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); - monitor.problem(problem); - } - } - - /** - * Report a error. - * - * @param monitor - * @param problems - * @param message - * @param model - */ - 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); - monitor.problem(problem); - } - } - - /** - * Report a exception. - * - * @param problems - * @param message - * @param model - */ - 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); - monitor.problem(problem); - } - } - - /** - * Index components inside a composite - * - * @param composite - * @param componentServices - - */ - protected void indexComponents(Composite composite, - Map<String, Component> components) { - for (Component component : composite.getComponents()) { - // Index components by name - components.put(component.getName(), component); - } - } - - /** - * Index services inside a composite - * - * @param composite - * @param componentServices - */ - protected void indexServices(Composite composite, - Map<String, ComponentService> componentServices) { - - for (Component component : composite.getComponents()) { - - ComponentService nonCallbackService = null; - int nonCallbackServiceCount = 0; - - for (ComponentService componentService : component.getServices()) { - // Index component services by component name / service name - String uri = component.getName() + '/' + componentService.getName(); - componentServices.put(uri, componentService); - - // count how many non-callback there are - if (!componentService.isCallback()) { - - if (nonCallbackServiceCount == 0) { - nonCallbackService = componentService; - } - nonCallbackServiceCount++; - } - } - if (nonCallbackServiceCount == 1) { - // If we have a single non callback service, index it by - // component name as well - componentServices.put(component.getName(), nonCallbackService); - } - } - } - - - /** - * Index components, services and references inside a composite. - * @param composite - * @param components - * @param componentServices - * @param componentReferences - */ - protected void indexComponentsServicesAndReferences(Composite composite, - Map<String, Component> components, - Map<String, ComponentService> componentServices, - Map<String, ComponentReference> componentReferences) { - - for (Component component : composite.getComponents()) { - - // Index components by name - components.put(component.getName(), component); - - ComponentService nonCallbackService = null; - int nonCallbackServices = 0; - for (ComponentService componentService : component.getServices()) { - - // Index component services by component name / service name - String uri = component.getName() + '/' + componentService.getName(); - componentServices.put(uri, componentService); - - // TODO - EPR - $promoted$ no longer used but it doesn't do any harm here - boolean promotedService = false; - if (componentService.getName() != null && componentService.getName().indexOf("$promoted$") > -1) { - promotedService = true; - } - - // count how many non-callback, non-promoted services there are - // if there is only one the component name also acts as the service name - if ((!componentService.isCallback()) && (!promotedService)) { - - // Check how many non callback non-promoted services we have - if (nonCallbackServices == 0) { - nonCallbackService = componentService; - } - nonCallbackServices++; - } - - } - - if (nonCallbackServices == 1) { - // If we have a single non callback service, index it by - // component name as well - componentServices.put(component.getName(), nonCallbackService); - } - - // Index references by component name / reference name - for (ComponentReference componentReference : component.getReferences()) { - String uri = component.getName() + '/' + componentReference.getName(); - componentReferences.put(uri, componentReference); - } - } - } - - protected void indexComponentPropertiesServicesAndReferences( - Component component, - Map<String, ComponentService> componentServices, - Map<String, ComponentReference> componentReferences, - Map<String, ComponentProperty> 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()); - } else { - 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()); - } else { - 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()); - } else { - componentProperties.put(componentProperty.getName(), - componentProperty); - } - } - - } - - protected void indexImplementationPropertiesServicesAndReferences( - Component component, Map<String, Service> services, - Map<String, Reference> references, - Map<String, Property> properties, Monitor monitor) { - // First check that the component has a resolved implementation - Implementation implementation = component.getImplementation(); - if (implementation == null) { - // A component must have an implementation - error(monitor, "NoComponentImplementation", component, component.getName()); - - } else if (implementation.isUnresolved()) { - - // The implementation must be fully resolved - error(monitor, "UnresolvedComponentImplementation", component, - component.getName(), implementation.getURI()); - - } else { - - // Index properties, services and references, also check for - // 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()); - } 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()); - } 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()); - } else { - references.put(reference.getName(), reference); - } - } - } - - } - - /** - * Reconcile component properties and the properties defined by the - * component type. - * - * @param component - * @param properties - * @param componentProperties - * @param problems - */ - protected void reconcileProperties(Component component, - Map<String, Property> properties, - Map<String, ComponentProperty> componentProperties, - Monitor monitor) { - - // Connect component properties to their properties - for (ComponentProperty componentProperty : component.getProperties()) { - Property property = properties.get(componentProperty.getName()); - if (property != null) { - componentProperty.setProperty(property); - } else { - warning(monitor, "PropertyNotFound", component, component.getName(), componentProperty.getName()); - } - } - - // Create component properties for all properties - if (component.getImplementation() != null) { - for (Property property : component.getImplementation().getProperties()) { - if (!componentProperties.containsKey(property.getName())) { - ComponentProperty componentProperty = assemblyFactory.createComponentProperty(); - componentProperty.setName(property.getName()); - componentProperty.setMany(property.isMany()); - componentProperty.setXSDElement(property.getXSDElement()); - componentProperty.setXSDType(property.getXSDType()); - componentProperty.setProperty(property); - component.getProperties().add(componentProperty); - } - } - } - - // Reconcile component properties and their properties - for (ComponentProperty componentProperty : component.getProperties()) { - Property property = componentProperty.getProperty(); - if (property != null) { - - // Check that a component property does not override the - // mustSupply attribute - if (!property.isMustSupply() && componentProperty.isMustSupply()) { - warning(monitor, "PropertyMustSupplyIncompatible", component, component.getName(), componentProperty.getName()); - } - - // Default to the mustSupply attribute specified on the property - if (!componentProperty.isMustSupply()) - componentProperty.setMustSupply(property.isMustSupply()); - - // Default to the value specified on the property - if (componentProperty.getValue() == null) { - componentProperty.setValue(property.getValue()); - } - - // Override the property value for the 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()); - } - - // 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()); - } - - // Default to the many attribute defined on the property - componentProperty.setMany(property.isMany()); - - // Default to the type and element defined on the property - if (componentProperty.getXSDType() == null) { - componentProperty.setXSDType(property.getXSDType()); - } - if (componentProperty.getXSDElement() == null) { - componentProperty.setXSDElement(property.getXSDElement()); - } - - // Check that a type or element are specified - if (componentProperty.getXSDElement() == null && componentProperty.getXSDType() == null) { - warning(monitor, "NoTypeForComponentProperty", component, component.getName(), componentProperty.getName()); - } - } - } - } - - /** - * Reconcile component references with the references defined on the - * component type. - * - * @param component - * @param references - * @param componentReferences - * @param monitor - */ - protected void reconcileReferences(Component component, - Map<String, Reference> references, - Map<String, ComponentReference> componentReferences, - Monitor monitor) { - - // Connect each component reference to the corresponding reference - for (ComponentReference componentReference : component.getReferences()) { - if (componentReference.getReference() != null || componentReference.isCallback()) { - continue; - } - Reference reference = references.get(componentReference.getName()); - if (reference != null) { - componentReference.setReference(reference); - } else { - if (!componentReference.getName().startsWith("$self$.")) { - error(monitor, "ReferenceNotFound", component, component.getName(), componentReference.getName()); - } - } - } - - // Create a Component reference for each reference for which there is no declared Component reference - if (component.getImplementation() != null) { - for (Reference reference : component.getImplementation().getReferences()) { - if (!componentReferences.containsKey(reference.getName())) { - ComponentReference componentReference = - assemblyFactory.createComponentReference(); - componentReference.setIsCallback(reference.isCallback()); - componentReference.setName(reference.getName()); - componentReference.setReference(reference); - component.getReferences().add(componentReference); - } - } - } - - // Reconcile each component reference with its reference - for (ComponentReference componentReference : component.getReferences()) { - Reference reference = componentReference.getReference(); - if (reference != null) { - // Reconcile multiplicity - if (componentReference.getMultiplicity() != null) { - if (!ReferenceConfigurationUtil.isValidMultiplicityOverride(reference.getMultiplicity(), - componentReference - .getMultiplicity())) { - warning(monitor, "ReferenceIncompatibleMultiplicity", component, component.getName(), componentReference.getName()); - } - } else { - componentReference.setMultiplicity(reference.getMultiplicity()); - } - - // Reconcile interface - InterfaceContract interfaceContract = reference.getInterfaceContract(); - if (componentReference.getInterfaceContract() != null) { - if (interfaceContract != null && !componentReference.getInterfaceContract().equals(reference - .getInterfaceContract())) { - if (!interfaceContractMapper.isCompatible(componentReference.getInterfaceContract(), - interfaceContract)) { - warning(monitor, "ReferenceIncompatibleComponentInterface", component, component.getName(), componentReference.getName()); - } - } - } else { - componentReference.setInterfaceContract(interfaceContract); - } - - // Reconcile bindings - if (componentReference.getBindings().isEmpty()) { - componentReference.getBindings().addAll(reference.getBindings()); - } - - // Reconcile callback bindings - if (componentReference.getCallback() == null) { - componentReference.setCallback(reference.getCallback()); - if (componentReference.getCallback() == null) { - // Create an empty callback to avoid null check - componentReference.setCallback(assemblyFactory.createCallback()); - } - - } else if (componentReference.getCallback().getBindings().isEmpty() && reference - .getCallback() != null) { - componentReference.getCallback().getBindings().addAll(reference.getCallback() - .getBindings()); - } - - // Propagate autowire setting from the component - if (componentReference.getAutowire() == null) { - componentReference.setAutowire(component.getAutowire()); - } - - // Reconcile targets - if (componentReference.getTargets().isEmpty()) { - componentReference.getTargets().addAll(reference.getTargets()); - } - } - } - } - - /** - * Reconcile component services and services defined on the component type. - * - * @param component - * @param services - * @param componentServices - * @param monitor - */ - protected void reconcileServices(Component component, - Map<String, Service> services, - Map<String, ComponentService> componentServices, - Monitor monitor) { - - // Connect each component service to the corresponding service - for (ComponentService componentService : component.getServices()) { - if (componentService.getService() != null || componentService.isCallback()) { - continue; - } - Service service = services.get(componentService.getName()); - if (service != null) { - componentService.setService(service); - } else { - warning(monitor, "ServiceNotFoundForComponentService", component, component.getName(), componentService.getName()); - } - } - - // Create a component service for each service - if (component.getImplementation() != null) { - for (Service service : component.getImplementation().getServices()) { - if (!componentServices.containsKey(service.getName())) { - ComponentService componentService = assemblyFactory.createComponentService(); - componentService.setIsCallback(service.isCallback()); - String name = service.getName(); - componentService.setName(name); - componentService.setService(service); - component.getServices().add(componentService); - componentServices.put(name, componentService); - } - } - } - - //Reconcile each component service with its service - for (ComponentService componentService : component.getServices()) { - Service service = componentService.getService(); - if (service != null) { - // Reconcile interface - InterfaceContract interfaceContract = service.getInterfaceContract(); - if (componentService.getInterfaceContract() != null) { - 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()); - } - } - } else { - componentService.setInterfaceContract(interfaceContract); - } - - // Reconcile bindings - if (componentService.getBindings().isEmpty()) { - componentService.getBindings().addAll(service.getBindings()); - } - - // Reconcile callback bindings - if (componentService.getCallback() == null) { - componentService.setCallback(service.getCallback()); - if (componentService.getCallback() == null) { - // 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()); - } - } - } - } - - protected SCABinding createSCABinding(Definitions definitions) { - SCABinding scaBinding = scaBindingFactory.createSCABinding(); - - // mark the bindings that are added automatically so that they can - // be disregarded for overriding purposes - if (scaBinding instanceof AutomaticBinding){ - ((AutomaticBinding)scaBinding).setIsAutomatic(true); - } - - if ( definitions != null ) { - for ( ExtensionType attachPointType : definitions.getBindingTypes() ) { - if ( attachPointType.getType().equals(BINDING_SCA_QNAME)) { - ((PolicySubject)scaBinding).setType(attachPointType); - } - } - } - - return scaBinding; - } -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java deleted file mode 100644 index fc769f5037..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java +++ /dev/null @@ -1,452 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder.impl; - -import java.net.URI; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.TransformerFactory; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentProperty; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.CompositeReference; -import org.apache.tuscany.sca.assembly.CompositeService; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.assembly.SCABindingFactory; -import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.assembly.builder.ComponentPreProcessor; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * A composite builder that handles the configuration of components. - * - * @version $Rev$ $Date$ - */ -public class ComponentConfigurationBuilderImpl extends BaseBuilderImpl implements CompositeBuilder { - - @Deprecated - public ComponentConfigurationBuilderImpl(AssemblyFactory assemblyFactory, - SCABindingFactory scaBindingFactory, - InterfaceContractMapper interfaceContractMapper) { - super(assemblyFactory, scaBindingFactory, - null, null, - interfaceContractMapper); - } - - public ComponentConfigurationBuilderImpl(AssemblyFactory assemblyFactory, - SCABindingFactory scaBindingFactory, - DocumentBuilderFactory documentBuilderFactory, - TransformerFactory transformerFactory, - InterfaceContractMapper interfaceContractMapper) { - super(assemblyFactory, scaBindingFactory, - documentBuilderFactory, transformerFactory, - interfaceContractMapper); - } - - public String getID() { - return "org.apache.tuscany.sca.assembly.builder.ComponentConfigurationBuilder"; - } - - 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 { - configureComponents(composite, null, definitions, monitor); - configureSourcedProperties(composite, null); - } - - /** - * Configure components in the composite. - * - * @param composite - * @param uri - * @param problems - */ - private void configureComponents(Composite composite, String uri, Definitions definitions, Monitor monitor) { - String parentURI = uri; - - // Process nested composites recursively - for (Component component : composite.getComponents()) { - - // Initialize component URI - String componentURI; - if (parentURI == null) { - componentURI = component.getName(); - } else { - componentURI = URI.create(parentURI + '/').resolve(component.getName()).toString(); - } - component.setURI(componentURI); - - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - - // Process nested composite - configureComponents((Composite)implementation, componentURI, definitions, monitor); - } - } - - // Initialize service bindings - List<Service> compositeServices = composite.getServices(); - for (Service service : compositeServices) { - // Set default binding names - - // Create default SCA binding - if (service.getBindings().isEmpty()) { - SCABinding scaBinding = createSCABinding(definitions); - service.getBindings().add(scaBinding); - } - } - - // Initialize reference bindings - for (Reference reference : composite.getReferences()) { - // Create default SCA binding - if (reference.getBindings().isEmpty()) { - SCABinding scaBinding = createSCABinding(definitions); - reference.getBindings().add(scaBinding); - } - } - - // Initialize all component services and references - Map<String, Component> components = new HashMap<String, Component>(); - for (Component component : composite.getComponents()) { - - // Index all components and check for duplicates - if (components.containsKey(component.getName())) { - error(monitor, "DuplicateComponentName", component, composite.getName().toString(), component.getName()); - } else { - components.put(component.getName(), component); - } - - // Propagate the autowire flag from the composite to components - if (component.getAutowire() == null) { - component.setAutowire(composite.getAutowire()); - } - - if (component.getImplementation() instanceof ComponentPreProcessor) { - ((ComponentPreProcessor)component.getImplementation()).preProcess(component); - } - - // Index implementation properties, services and references - Map<String, Service> services = new HashMap<String, Service>(); - Map<String, Reference> references = new HashMap<String, Reference>(); - Map<String, Property> properties = new HashMap<String, Property>(); - indexImplementationPropertiesServicesAndReferences(component, - services, - references, - properties, - monitor); - - // Index component services, references and properties - // Also check for duplicates - Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>(); - Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>(); - Map<String, ComponentProperty> componentProperties = new HashMap<String, ComponentProperty>(); - indexComponentPropertiesServicesAndReferences(component, - componentServices, - componentReferences, - componentProperties, - monitor); - - // Reconcile component services/references/properties and - // implementation services/references and create component - // services/references/properties for the services/references - // declared by the implementation - reconcileServices(component, services, componentServices, monitor); - reconcileReferences(component, references, componentReferences, monitor); - reconcileProperties(component, properties, componentProperties, monitor); - - // Configure or create callback services for component's references - // with callbacks - configureCallbackServices(component, componentServices); - - // Configure or create callback references for component's services - // with callbacks - configureCallbackReferences(component, componentReferences); - - // Initialize service bindings - for (ComponentService componentService : component.getServices()) { - - // Create default SCA binding - if (componentService.getBindings().isEmpty()) { - SCABinding scaBinding = createSCABinding(definitions); - componentService.getBindings().add(scaBinding); - } - } - - // Initialize reference bindings - for (ComponentReference componentReference : component.getReferences()) { - - // Create default SCA binding - if (componentReference.getBindings().isEmpty()) { - SCABinding scaBinding = createSCABinding(definitions); - componentReference.getBindings().add(scaBinding); - } - } - } - } - - /** - * For all the references with callbacks, create a corresponding callback - * service. - * - * @param component - */ - private void configureCallbackServices(Component component, - Map<String, ComponentService> 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()); - if (service == null) { - service = createCallbackService(component, reference); - } - if (reference.getCallback() != null) { - if (service.getBindings().isEmpty()) { - service.getBindings().addAll(reference.getCallback().getBindings()); - } - } - reference.setCallbackService(service); - } - } - } - - /** - * Create a callback service for a component reference - * - * @param component - * @param reference - */ - private ComponentService createCallbackService(Component component, ComponentReference reference) { - ComponentService componentService = assemblyFactory.createComponentService(); - componentService.setIsCallback(true); - componentService.setName(reference.getName()); - try { - InterfaceContract contract = - (InterfaceContract)reference.getInterfaceContract().clone(); - contract.setInterface(contract.getCallbackInterface()); - contract.setCallbackInterface(null); - componentService.setInterfaceContract(contract); - } catch (CloneNotSupportedException e) { - // will not happen - } - 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 - // - implService.setName(implReference.getName()); - try { - InterfaceContract implContract = - (InterfaceContract)implReference.getInterfaceContract().clone(); - implContract.setInterface(implContract.getCallbackInterface()); - implContract.setCallbackInterface(null); - implService.setInterfaceContract(implContract); - } catch (CloneNotSupportedException e) { - // will not happen - } - componentService.setService(implService); - } - component.getServices().add(componentService); - return componentService; - } - - /** - * For all the services with callbacks, create a corresponding callback reference. - * - * @param component - * @param componentReferences - */ - private void configureCallbackReferences(Component component, - Map<String, ComponentReference> componentReferences) { - for (ComponentService service : component.getServices()) { - if (service.getInterfaceContract() != null && // can be null in unit tests - 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) { - reference.getBindings().addAll(service.getCallback().getBindings()); - } else { - // otherwise use the bindings on the forward service - reference.getBindings().addAll(service.getBindings()); - } // end if - } // end if - service.setCallbackReference(reference); - } // end if - } // end for - } // end method configureCallbackReferences - - /** - * Create a callback reference for a component service - * - * @param component - * @param service - */ - private ComponentReference createCallbackReference(Component component, ComponentService service) { - ComponentReference componentReference = assemblyFactory.createComponentReference(); - componentReference.setIsCallback(true); - componentReference.setName(service.getName()); - try { - InterfaceContract contract = (InterfaceContract)service.getInterfaceContract().clone(); - contract.setInterface(contract.getCallbackInterface()); - contract.setCallbackInterface(null); - componentReference.setInterfaceContract(contract); - } catch (CloneNotSupportedException e) { - // will not happen - } - 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 - // - - implReference.setName(implService.getName()); - try { - InterfaceContract implContract = - (InterfaceContract)implService.getInterfaceContract().clone(); - implContract.setInterface(implContract.getCallbackInterface()); - implContract.setCallbackInterface(null); - implReference.setInterfaceContract(implContract); - } catch (CloneNotSupportedException e) { - // will not happen - } - componentReference.setReference(implReference); - } - component.getReferences().add(componentReference); - return componentReference; - } - - /** - * @param composite - */ - private void configureSourcedProperties(Composite composite, List<ComponentProperty> propertySettings) { - // Resolve properties - Map<String, Property> compositeProperties = new HashMap<String, Property>(); - ComponentProperty componentProperty = null; - for (Property p : composite.getProperties()) { - componentProperty = getComponentPropertyByName(p.getName(), propertySettings); - if (componentProperty != null) { - compositeProperties.put(p.getName(), componentProperty); - } else { - compositeProperties.put(p.getName(), p); - } - } - - for (Component component : composite.getComponents()) { - try { - PropertyConfigurationUtil.sourceComponentProperties(compositeProperties, component, - documentBuilderFactory, transformerFactory); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - Implementation impl = component.getImplementation(); - if (impl instanceof Composite) { - configureSourcedProperties((Composite)impl, component.getProperties()); - } - } - } - - private ComponentProperty getComponentPropertyByName(String propertyName, List<ComponentProperty> properties) { - if (properties != null) { - for (ComponentProperty aProperty : properties) { - if (aProperty.getName().equals(propertyName)) { - return aProperty; - } - } - } - return null; - } -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java deleted file mode 100644 index 734b373f11..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder.impl; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.builder.BindingBuilderExtension; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * A composite builder that performs any additional building steps that - * component reference bindings may need. Used for WSDL generation. - * - * @version $Rev$ $Date$ - */ -public class ComponentReferenceBindingBuilderImpl implements CompositeBuilder { - - public ComponentReferenceBindingBuilderImpl() { - } - - 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); - } - } - } - } - - // build bindings recursively - for (Component component : composite.getComponents()) { - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - buildReferenceBindings((Composite)implementation, monitor); - } - } - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java deleted file mode 100644 index 5439ca538f..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java +++ /dev/null @@ -1,916 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder.impl; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.CompositeReference; -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.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.definitions.Definitions; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; - -/** - * A composite builder that creates endpoint reference models. - * - * @version $Rev$ $Date$ - */ -public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderImpl implements CompositeBuilder { - - Monitor monitor; - // Testing - //boolean useNew = true; - boolean useNew = false; - - public ComponentReferenceEndpointReferenceBuilderImpl(AssemblyFactory assemblyFactory, InterfaceContractMapper interfaceContractMapper) { - super(assemblyFactory, null, null, null, interfaceContractMapper); - } - - public String getID() { - return "org.apache.tuscany.sca.assembly.builder.ComponentReferenceEndpointReferenceBuilder"; - } - - /** - * Create endpoint references for all component references. - * - * @param composite - */ - public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException - { - this.monitor = monitor; - - - // process component services - processComponentReferences(composite); - } - - private void processComponentReferences(Composite composite) { - - // index all of the components in the composite - Map<String, Component> components = new HashMap<String, Component>(); - indexComponents(composite, components); - - // index all of the services in the composite - Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>(); - indexServices(composite, componentServices); - - // create endpoint references for each component's references - for (Component component : composite.getComponents()) { - - for (ComponentReference reference : component.getReferences()) { - createReferenceEndpointReferences2( composite, component, reference, components, componentServices); - } // end for - - // recurse for composite implementations - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - processComponentReferences((Composite)implementation); - } - - // create endpoint references to represent the component reference - for (ComponentReference reference : component.getReferences()) { - - 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()){ - endpoint.getCallbackEndpointReferences().addAll(reference.getEndpointReferences()); - } - break; - } // end if - } // end if - } // end for - } // end for - } // end for - } // end method processCompoenntReferences - - private void createReferenceEndpointReferences(Composite composite, - Component component, - ComponentReference reference, - Map<String, Component> components, - Map<String, ComponentService> componentServices) - { - // Get reference targets - List<ComponentService> refTargets = getReferenceTargets( reference ); - if (reference.getAutowire() == Boolean.TRUE && - reference.getTargets().isEmpty()) { - - // Find suitable targets in the current composite for an - // autowired reference - Multiplicity multiplicity = reference.getMultiplicity(); - for (Component targetComponent : composite.getComponents()) { - - // Prevent autowire connecting to self - if( targetComponent == component ) continue; - - for (ComponentService targetComponentService : targetComponent.getServices()) { - 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) ); - 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) { - break; - } // end if - } // end if - } // end for - } // end for - - if (multiplicity == Multiplicity.ONE_N || - multiplicity == Multiplicity.ONE_ONE) { - if (reference.getEndpointReferences().size() == 0) { - 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()); - } - - // Resolve targets specified on the component reference - for (ComponentService target : refTargets) { - - String targetName = target.getName(); - ComponentService targetComponentService = componentServices.get(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())) { - - // 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 ); - endpointRef.setTargetEndpoint(createEndpoint(targetComponent, targetComponentService, true)); - reference.getEndpointReferences().add(endpointRef); - } else { - warning(monitor, "ReferenceIncompatibleInterface", - composite, - composite.getName().toString(), - component.getName() + "." + reference.getName(), - targetName); - } - } else { - // add an unresolved endpoint reference with an unresolved endpoint to go with it - EndpointReference endpointRef = createEndpointRef( component, reference, true ); - endpointRef.setTargetEndpoint(createEndpoint(component, targetName)); - endpointRef.setIsRemoteReference(true); - reference.getEndpointReferences().add(endpointRef); - warning(monitor, "ComponentReferenceTargetNotFound", - composite, - composite.getName().toString(), - targetName); - } // end if - } // end for - } // end if - - // if no endpoints have found so far the bindings hold the targets. - if (reference.getEndpointReferences().isEmpty()) { - for (Binding binding : reference.getBindings()) { - - String uri = binding.getURI(); - - // 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; - - // 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 ); - endpointRef.setTargetEndpoint(createEndpoint(false)); - endpointRef.setIsRemoteReference(true); - reference.getEndpointReferences().add(endpointRef); - 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); - } - - // Resolve the target component and service - ComponentService targetComponentService = componentServices.get(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. - // If not, the binding URI is assumed to reference an external service - if (targetComponentService != null) { - - // Check that the target component service provides - // a superset of the component reference interface - 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 ); - endpointRef.setTargetEndpoint(createEndpoint(targetComponent, targetComponentService, true)); - reference.getEndpointReferences().add(endpointRef); - } else { - warning(monitor, "ReferenceIncompatibleInterface", - composite, - composite.getName().toString(), - reference.getName(), - uri); - } - } else { - // create endpoint reference for manually configured bindings with resolved endpoint - // to signify that this reference is pointing at some unwired endpoint - EndpointReference endpointRef = createEndpointRef( component, reference, binding, null, false ); - endpointRef.setTargetEndpoint(createEndpoint( false )); - endpointRef.setIsRemoteReference(true); - reference.getEndpointReferences().add(endpointRef); - } // end if - } - } - } // end method - - /** - * Create Endpoint References for a component reference inside a given composite - * @param composite - the composite - * @param component - the component - * @param reference - the component reference - * @param components - a map of the components in the composite - * @param componentServices - a map of the component services in the composite - */ - private void createReferenceEndpointReferences2(Composite composite, - Component component, - ComponentReference reference, - Map<String, Component> components, - Map<String, ComponentService> componentServices) - { - // Find all the leafmost component references related to this component reference - EndpointrefInfo refInfo = gatherEndpointrefInfo( component, reference, null ); - - List<Endpoint> 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()); - } // 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 - } // end for - - } // end method createReferenceEndpointReferences2 - - private List<Endpoint> getReferenceEndpoints(Composite composite, Component component, - ComponentReference reference, Map<String, Component> components, - Map<String, ComponentService> 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<Endpoint> endpoints = new ArrayList<Endpoint>(); - - // 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 <wire/> elements are handled correctly - // Get reference targets identified by configured <binding/> 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 - - /** - * Gets the callback endpoints of a reference that is a callback reference - * @param composite - the composite - * @param component - the component - * @param reference - the reference - * @param components - a mapped list of the components in the composite - * @param componentServices - a mapped list of the componentServices in the composite - * @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<String, Component> components, - Map<String, ComponentService> componentServices, List<Endpoint> 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 - - } // end method getReferenceCallbackEndpoints - - /** - * Gets the endpoints for the services identified by the @target attribute of a reference - * @param composite - the composite - * @param component - the component - * @param reference - the component reference - * @param components - a mapped list of the components in the composite - * @param componentServices - a mapped list of the componentServices in the composite - * @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<String, Component> components, - Map<String, ComponentService> componentServices, List<Endpoint> endpoints ) { - - List<ComponentService> 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 - - } // end method getReferenceTargetEndpoints - - /** - * Selects one endpoint of a target service which is compatible with the policy requirements of a reference - * @param reference - the reference (carries policy data with it) - * @param service - the target service - * @return - an endpoint belonging to the service which is compatible with the reference. - * 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 ) { - - // 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; - } // end method selectTargetEndpoint - - /** - * Gets the endpoints for the services identified by the <binding/> subelements of a reference - * @param composite - the composite - * @param component - the component - * @param reference - the component reference - * @param components - a mapped list of the components in the composite - * @param componentServices - a mapped list of the componentServices in the composite - * @param endpoints - a list of the endpoints (in/out parameter) - * @return true if the <binding/> subelements identify target services, false otherwise - */ - private boolean getReferenceBindingEndpoints( Composite composite, Component component, - ComponentReference reference, Map<String, Component> components, - Map<String, ComponentService> componentServices, List<Endpoint> endpoints ) { - // Get service endpoints declared by <binding/> subelements - if( bindingsIdentifyTargets( reference ) ) { - for (Binding binding : reference.getBindings()) { - - String uri = binding.getURI(); - - // 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; - - // create an unwired endpoint containing the binding - 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); - - // Resolve the target component and service - ComponentService targetComponentService = componentServices.get(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. - // If not, the binding URI is assumed to reference an external service - if (targetComponentService != null) { - // Check that the target component service provides - // a superset of the component reference interface - 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) ); - } else { - 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 ) ); - } // end if - } // end for - return true; - } else { - return false; - } // end if - - } // end method getReferenceBindingEndpoints - - /** - * Gets the endpoints for the services identified by the @autowire attribute of a reference - * @param composite - the composite - * @param component - the component - * @param reference - the component reference - * @param components - a mapped list of the components in the composite - * @param componentServices - a mapped list of the componentServices in the composite - * @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<String, Component> components, - Map<String, ComponentService> componentServices, List<Endpoint> 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; - - for (ComponentService targetComponentService : targetComponent.getServices()) { - 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) ); - - // Stop with the first match for 0..1 and 1..1 references - 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 - - } // end method getReferenceAutowireEndpoints - - /** - * Evaluates if the interface contract of a component service is a compatible superset of the interface contract - * of a component reference - * @param reference - the component reference - * @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()); - } // end method InterfaceContractIsCompatible - - /** - * Gather the Endpoint reference information for a component reference - * - gathers information from deeper in the hierarchy for a component which is implemented by a composite - * @param component - the component - * @param reference - the component reference - * @param refInfo - a reference info datastructure where the endpoint reference information is gathered. Can be null, in - * which case this method will allocate and return an instance of refInfo. - * @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<Component> components = compRef.getPromotedComponents(); - List<ComponentReference> 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 - - /** - * A class used to gather endpoint reference information for a component reference - * - handles the information in a promotion hierarchy where the component reference is implemented - * by a composite reference. - * @author MikeEdwards - */ - private class EndpointrefInfo { - private List<Component> components = new ArrayList<Component>(); - private List<ComponentReference> refs = new ArrayList<ComponentReference>(); - private InterfaceContract contract = null; - private List<Intent> intents = new ArrayList<Intent>(); - private List<PolicySet> 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<PolicySet> getPolicySets() { - return policySets; - } - - void setPolicySets(List<PolicySet> policySets) { - this.policySets = policySets; - } - - List<Component> getComponents() { - return components; - } - - void addComponent(Component component) { - this.components.add( component ); - } - - List<ComponentReference> 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<Intent> getIntents() { - return intents; - } - /** - * Accumulate intents - * @param intents - */ - void addIntents(List<Intent> intents) { - this.intents.addAll( intents ); - } - - - } // end class EndpointrefInfo - - /** - * Evaluates whether the bindings attached to a reference identify one or more target services. - * @param reference - the reference - * @return true if the bindings identify a target, false otherwise - */ - private boolean bindingsIdentifyTargets( ComponentReference reference ) { - for( Binding binding : reference.getBindings() ) { - // <binding.sca without a URI does not identify a target - if( (binding instanceof SCABinding) && (binding.getURI() == null) ) continue; - // any other binding implies a target - // TODO Processing for other binding types - return true; - } // end for - return false; - } // end bindingsIdentifyTargets - - /** - * Helper method which obtains a list of targets for a reference - * @param reference - Component reference - * @return - the list of targets, which will be empty if there are no targets - */ - private List<ComponentService> getReferenceTargets( ComponentReference reference ) { - List<ComponentService> 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 - - /** - * Helper method that finds the Component given a target name - * @param components - * @param targetName - * @return the component - */ - private Component getComponentFromTargetName( Map<String, Component> components, String targetName ) { - Component theComponent; - int s = targetName.indexOf('/'); - if (s == -1) { - theComponent = components.get(targetName); - } else { - theComponent = components.get(targetName.substring(0, s)); - } - return theComponent; - } // end method getComponentFromTargetName - - /** - * Helper method to create an Endpoint Reference - * @param component - * @param reference - * @param binding - * @param endpoint - * @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 ); - endpointRef.setBinding(binding); - endpointRef.setTargetEndpoint(endpoint); - return endpointRef; - } // end method - - /** - * Helper method to create an Endpoint Reference - * @param component - * @param reference - * @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; - } // end method createEndpointRef - - - /** - * Helper method to create an endpoint - * @param component - * @param service - * @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; - } // end method createEndpoint - - /** - * Helper method to create an Endpoint - * @param unresolved - * @return the endpoint - */ - private Endpoint createEndpoint( boolean unresolved) { - Endpoint endpoint = assemblyFactory.createEndpoint(); - endpoint.setUnresolved(unresolved); - return endpoint; - } // end method createEndpoint - - /** - * Helper method to create an Endpoint - * - * @param component The component that owns the reference - * @param targetName It can be one of the following formats - * <ul> - * <li>componentName - * <li>componentName/serviceName - * <li>componentName/serviceName/bindingName - * </ul> - * @return the endpoint - */ - private Endpoint createEndpoint(Component component, String targetName) { - String[] parts = targetName.split("/"); - if (parts.length < 1 || parts.length > 3) { - throw new IllegalArgumentException("Invalid target URI: " + targetName); - } - - // Find the parent uri - String uri = component.getURI(); - int index = uri.lastIndexOf('/'); - if (index == -1) { - uri = ""; - } else { - uri = uri.substring(0, index); - } - - if (parts.length >= 1) { - // Append the target component name - if (uri.length() == 0) { - uri = parts[0]; - } else { - uri = uri + "/" + parts[0]; - } - } - if (parts.length == 3) { - // <componentURI>#service-binding(serviceName/bindingName) - uri = uri + "#service-binding(" + parts[1] + "/" + parts[2] + ")"; - } else if (parts.length == 2) { - // <componentURI>#service(serviceName) - uri = uri + "#service(" + parts[1] + ")"; - } - - Endpoint endpoint = assemblyFactory.createEndpoint(); - endpoint.setUnresolved(true); - endpoint.setURI(uri); - return endpoint; - } // end method createEndpoint - - -} // end class diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionBuilderImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionBuilderImpl.java deleted file mode 100644 index eb06f67f8e..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionBuilderImpl.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder.impl; - -import java.util.List; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.CompositeReference; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * A composite builder that handles the creation of promoted composite services. - * - * @version $Rev$ $Date$ - */ -public class ComponentReferencePromotionBuilderImpl implements CompositeBuilder { - private AssemblyFactory assemblyFactory; - - public ComponentReferencePromotionBuilderImpl(AssemblyFactory assemblyFactory) { - this.assemblyFactory = assemblyFactory; - } - - public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { - configureNestedCompositeReferences(composite, monitor); - } - - public String getID() { - return "org.apache.tuscany.sca.assembly.builder.ComponentReferencePromotionBuilder"; - } - - /** - * Push down reference configuration into nested composites. - * - * @param composite - * @param problems - */ - private void configureNestedCompositeReferences(Composite composite, Monitor monitor) { - - // Process nested composites recursively - for (Component component : composite.getComponents()) { - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - configureNestedCompositeReferences((Composite)implementation, monitor); - } - } - - // Process component references declared on components in this composite - for (Component component : composite.getComponents()) { - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - for (ComponentReference componentReference : component.getReferences()) { - Reference implReference = componentReference.getReference(); - if (implReference != null && implReference instanceof CompositeReference) { - - // If the component reference is wired, it is a promotion override - if (!componentReference.getEndpointReferences().isEmpty()) { - componentReference.setPromotionOverride(true); - } - - // If the component reference is a promotion override, override the - // configuration of the promoted reference - if (componentReference.isPromotionOverride()) { - CompositeReference compositeReference = (CompositeReference)implReference; - List<ComponentReference> promotedReferences = - ReferenceConfigurationUtil.getPromotedComponentReferences(compositeReference); - for (ComponentReference promotedReference : promotedReferences) { - ReferenceConfigurationUtil.reconcileReferenceBindings( - componentReference, promotedReference, assemblyFactory, monitor); - if (componentReference.getInterfaceContract() != null && // can be null in unit tests - componentReference.getInterfaceContract().getCallbackInterface() != null) { - SCABinding scaCallbackBinding = promotedReference.getCallbackBinding(SCABinding.class); - if (promotedReference.getCallback() != null) { - promotedReference.getCallback().getBindings().clear(); - } else { - promotedReference.setCallback(assemblyFactory.createCallback()); - } - if (scaCallbackBinding != null) { - promotedReference.getCallback().getBindings().add(scaCallbackBinding); - } - if (componentReference.getCallback() != null) { - promotedReference.getCallback().getBindings().addAll(componentReference - .getCallback().getBindings()); - } - } - /* 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<ComponentService> targets = componentReference.getTargets(); - for (int i = 0, n = targets.size(); i < n; i++) { - ComponentService target = targets.get(i); - if (target.getService() instanceof CompositeService) { - - // Wire to the actual component service - // promoted by a composite service - CompositeService compositeService = (CompositeService)target.getService(); - ComponentService componentService = compositeService.getPromotedService(); - if (componentService != null) { - targets.set(i, componentService); - } - } - } - } -*/ - } - } - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionWireBuilderImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionWireBuilderImpl.java deleted file mode 100644 index 5552fda286..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionWireBuilderImpl.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder.impl; - -import java.util.List; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.CompositeReference; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * A composite builder that handles the creation of promoted composite services. - * - * @version $Rev$ $Date$ - */ -public class ComponentReferencePromotionWireBuilderImpl implements CompositeBuilder { - private AssemblyFactory assemblyFactory; - - public ComponentReferencePromotionWireBuilderImpl(AssemblyFactory assemblyFactory) { - this.assemblyFactory = assemblyFactory; - } - - public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { - wireCompositeReferences(composite, monitor); - } - - public String getID() { - return "org.apache.tuscany.sca.assembly.builder.ComponentReferencePromotionWireBuilder"; - } - - /** - * Wire composite references in nested composites. - * - * @param composite - * @param problems - */ - private void wireCompositeReferences(Composite composite, Monitor monitor) { - - // Process nested composites recursively - for (Component component : composite.getComponents()) { - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - wireCompositeReferences((Composite)implementation, monitor); - } - } - - // Process component references declared on components in this composite - for (Component component : composite.getComponents()) { - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - for (ComponentReference componentReference : component.getReferences()) { - Reference implReference = componentReference.getReference(); - if (implReference != null && implReference instanceof CompositeReference) { - - // If the component reference is wired, it is a promotion override - if (!componentReference.getEndpointReferences().isEmpty()) { - componentReference.setPromotionOverride(true); - } - - // If the component reference is a promotion override, override the - // configuration of the promoted reference - if (componentReference.isPromotionOverride()) { - CompositeReference compositeReference = (CompositeReference)implReference; - List<ComponentReference> promotedReferences = - ReferenceConfigurationUtil.getPromotedComponentReferences(compositeReference); - for (ComponentReference promotedReference : promotedReferences) { - ReferenceConfigurationUtil.reconcileReferenceBindings( - componentReference, promotedReference, assemblyFactory, monitor); - if (componentReference.getInterfaceContract() != null && // can be null in unit tests - componentReference.getInterfaceContract().getCallbackInterface() != null) { - SCABinding scaCallbackBinding = promotedReference.getCallbackBinding(SCABinding.class); - if (promotedReference.getCallback() != null) { - promotedReference.getCallback().getBindings().clear(); - } else { - promotedReference.setCallback(assemblyFactory.createCallback()); - } - if (scaCallbackBinding != null) { - promotedReference.getCallback().getBindings().add(scaCallbackBinding); - } - if (componentReference.getCallback() != null) { - promotedReference.getCallback().getBindings().addAll(componentReference - .getCallback().getBindings()); - } - } - /* 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<ComponentService> targets = componentReference.getTargets(); - for (int i = 0, n = targets.size(); i < n; i++) { - ComponentService target = targets.get(i); - if (target.getService() instanceof CompositeService) { - - // Wire to the actual component service - // promoted by a composite service - CompositeService compositeService = (CompositeService)target.getService(); - ComponentService componentService = compositeService.getPromotedService(); - if (componentService != null) { - targets.set(i, componentService); - } - } - } - } -*/ - } - } - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java deleted file mode 100644 index dc0a9298fa..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder.impl; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.CompositeReference; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.Wire; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * A composite builder that wires component references. - * - * @version $Rev$ $Date$ - */ -public class ComponentReferenceWireBuilderImpl extends BaseBuilderImpl implements CompositeBuilder { - - public ComponentReferenceWireBuilderImpl(AssemblyFactory assemblyFactory, InterfaceContractMapper interfaceContractMapper) { - super(assemblyFactory, null, null, null, interfaceContractMapper); - } - - public String getID() { - return "org.apache.tuscany.sca.assembly.builder.ComponentReferenceWireBuilder"; - } - - 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. - * - * @param composite - */ - protected void wireComponentReferences(Composite composite, Monitor monitor) { - - // Wire nested composites recursively - for (Component component : composite.getComponents()) { - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - wireComponentReferences((Composite)implementation, monitor); - } - } - - // Index components, services and references - Map<String, Component> components = new HashMap<String, Component>(); - Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>(); - Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>(); - indexComponentsServicesAndReferences(composite, components, componentServices, componentReferences); - - // 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 (componentReference.getTargets().isEmpty()) { - - // No warning if the reference is promoted out of the current composite - boolean promoted = false; - for (Reference reference : composite.getReferences()) { - CompositeReference compositeReference = (CompositeReference)reference; - if (compositeReference.getPromotedReferences().contains(componentReference)) { - promoted = true; - break; - } - } - if (!promoted && !componentReference.isCallback()) { - 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(); - // } - } - - /** - * Resolve wires and connect the sources to their targets - * - * @param composite - * @param componentServices - * @param componentReferences - * @param problems - */ - private void connectWires(Composite composite, - Map<String, ComponentService> componentServices, - Map<String, ComponentReference> 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<Wire> 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()) { - resolvedReference = componentReferences.get(source.getName()); - if (resolvedReference != null) { - wire.setSource(resolvedReference); - } else { - warning(monitor, "WireSourceNotFound", composite, source.getName()); - } - } else { - resolvedReference = wire.getSource(); - } - - // Resolve the target service - ComponentService target = wire.getTarget(); - if (target != null && target.isUnresolved()) { - resolvedService = componentServices.get(target.getName()); - if (resolvedService != null) { - wire.setTarget(target); - } else { - warning(monitor, "WireTargetNotFound", composite, source.getName()); - } - } else { - resolvedService = wire.getTarget(); - } - - // Add the target service to the list of targets of the - // reference - if (resolvedReference != null && resolvedService != null) { - // Check that the target component service provides - // a superset of - // the component reference interface - if (resolvedReference.getInterfaceContract() == null || interfaceContractMapper - .isCompatible(resolvedReference.getInterfaceContract(), resolvedService.getInterfaceContract())) { - - //resolvedReference.getTargets().add(resolvedService); - resolvedReference.getTargets().add(wire.getTarget()); - } else { - warning(monitor, "WireIncompatibleInterface", composite, source.getName(), target.getName()); - } - } - } - - // Clear the list of wires - composite.getWires().clear(); - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceBindingBuilderImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceBindingBuilderImpl.java deleted file mode 100644 index c725ea8947..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceBindingBuilderImpl.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder.impl; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.builder.BindingBuilder; -import org.apache.tuscany.sca.assembly.builder.BindingBuilderExtension; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * A composite builder that performs any additional building steps that - * component service bindings may need. Used for WSDL generation. - * - * @version $Rev$ $Date$ - */ -public class ComponentServiceBindingBuilderImpl implements CompositeBuilder { - - public ComponentServiceBindingBuilderImpl() { - } - - public String getID() { - return "org.apache.tuscany.sca.assembly.builder.ComponentServiceBindingBuilder"; - } - - 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(); - if (implementation instanceof Composite) { - buildServiceBindings((Composite)implementation, monitor); - } - } - - // find all the component service bindings - for (Component component : composite.getComponents()) { - for (ComponentService componentService : component.getServices()) { - for (Binding binding : componentService.getBindings()) { - if (binding instanceof BindingBuilderExtension) { - BindingBuilder builder = ((BindingBuilderExtension)binding).getBuilder(); - if (builder != null) { - builder.build(component, componentService, binding, monitor); - } - } - } - } - } - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceEndpointBuilderImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceEndpointBuilderImpl.java deleted file mode 100644 index 00674b1f27..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceEndpointBuilderImpl.java +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder.impl; - -import java.util.List; -import java.util.Vector; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.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; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; - -/** - * A composite builder that creates endpoint models for component services. - * - * @version $Rev$ $Date$ - */ -public class ComponentServiceEndpointBuilderImpl implements CompositeBuilder { - private AssemblyFactory assemblyFactory; - - // Testing - //boolean useNew = true; - boolean useNew = false; - - public ComponentServiceEndpointBuilderImpl(AssemblyFactory assemblyFactory) { - this.assemblyFactory = assemblyFactory; - } - - public String getID() { - return "org.apache.tuscany.sca.assembly.builder.ComponentReferenceEndpointReferenceBuilder"; - } - - /** - * Create endpoint models for all component services. - * - * @param composite - the top-level composite to build the models for - * @param definitions - * @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 ); - - } // 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) { - processComponentServices((Composite)implementation); - } - - // 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. - if (service.getService() instanceof CompositeService) { - CompositeService compositeService = (CompositeService)service.getService(); - endpointService = ServiceConfigurationUtil.getPromotedComponentService(compositeService); - endpointComponent = ServiceConfigurationUtil.getPromotedComponent(compositeService); - } // end if - - for (Binding binding : service.getBindings()){ - Endpoint endpoint = assemblyFactory.createEndpoint(); - endpoint.setComponent(endpointComponent); - endpoint.setService(endpointService); - endpoint.setBinding(binding); - endpoint.setUnresolved(false); - service.getEndpoints().add(endpoint); - } // end for - } - } - } // 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<Binding> 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); - endpoint.setInterfaceContract(theInfo.getInterfaceContract()); - endpoint.getRequiredIntents().addAll(theInfo.getIntents()); - 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 - } // 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 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 - * @param component - the component - * @param service - the component service - * @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 - - 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 - ComponentService promotedService = ((CompositeService)implService).getPromotedService(); - Component promotedComponent = ((CompositeService)implService).getPromotedComponent(); - if (promotedService != null) { - scanComponentService( promotedComponent, promotedService, theInfo ); - } else { - // 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 - - return theInfo; - } // end method scanPromotedComponentService - - private class EndpointInfo { - private Component leafComponent = null; - private ComponentService leafComponentService = null; - private List<Binding> bindings = null; - private InterfaceContract contract; - private List<Intent> intents = new Vector<Intent>(); - private List<PolicySet> 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<Binding> theBindings ) { - // RULE: Bindings from higher in the hierarchy take precedence - if( bindings == null ) { - bindings = theBindings; - } // end if - } // end method - - List<Binding> 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<Intent> getIntents() { - return intents; - } // end method - - void setIntents(List<Intent> intents) { - // RULE: Intents accumulate from all levels in the hierarchy - this.intents.addAll( intents ); - } // end method - - List<PolicySet> getPolicySets() { - return policySets; - } // end method - - void setPolicySets(List<PolicySet> 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/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServicePromotionBuilderImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServicePromotionBuilderImpl.java deleted file mode 100644 index d5a94e0ee9..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServicePromotionBuilderImpl.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder.impl; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.CompositeService; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * A composite builder that handles the creation of promoted services. - * - * @version $Rev$ $Date$ - */ -public class ComponentServicePromotionBuilderImpl implements CompositeBuilder { - private AssemblyFactory assemblyFactory; - - public ComponentServicePromotionBuilderImpl(AssemblyFactory assemblyFactory) { - this.assemblyFactory = assemblyFactory; - } - - public String getID() { - return "org.apache.tuscany.sca.assembly.builder.ComponentServicePromotionBuilder"; - } - - public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { - - // Process nested composites recursively - configureNestedCompositeServices(composite); - } - - private void configureNestedCompositeServices(Composite composite) { - - // Process nested composites recursively - for (Component component : composite.getComponents()) { - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - - // First process nested composites - configureNestedCompositeServices((Composite)implementation); - - // Process the component services declared on components in this composite - for (ComponentService componentService : component.getServices()) { - Service implService = componentService.getService(); - if (implService != null && implService instanceof CompositeService) { - CompositeService compositeService = (CompositeService)implService; - - // Get the innermost promoted service - ComponentService promotedService = - ServiceConfigurationUtil.getPromotedComponentService(compositeService); - if (promotedService != null) { - Component promotedComponent = ServiceConfigurationUtil.getPromotedComponent(compositeService); - - // Create a new component service to represent this - // component service on the promoted component - ComponentService newComponentService = assemblyFactory.createComponentService(); - newComponentService.setName("$promoted$" + component.getName() + "$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) { - newComponentService.setCallback(assemblyFactory.createCallback()); - newComponentService.getCallback().getBindings() - .addAll(componentService.getCallback().getBindings()); - } - - // Change the composite service to now promote the - // newly created component service directly - compositeService.setPromotedComponent(promotedComponent); - compositeService.setPromotedService(newComponentService); - } - } - } - } - } - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingConfigurationBuilderImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingConfigurationBuilderImpl.java deleted file mode 100644 index d31a38c70b..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingConfigurationBuilderImpl.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder.impl; - -import java.util.List; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.SCABindingFactory; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * A composite builder that performs any additional building steps that - * composite service bindings may need. Used for WSDL generation. - * - * TODO - What is this actually used for? I can't find any references in the - * code base - * - * @version $Rev$ $Date$ - */ -public class CompositeBindingConfigurationBuilderImpl extends CompositeBindingURIBuilderImpl implements CompositeBuilder { - - public CompositeBindingConfigurationBuilderImpl(FactoryExtensionPoint factories, InterfaceContractMapper mapper) { - 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); - } - - public String getID() { - return "org.apache.tuscany.sca.assembly.builder.CompositeServiceBindingBuilder"; - } - - public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { - List<Binding> defaultBindings = null; - for (Object x: composite.getExtensions()) { - if (x instanceof List) { - defaultBindings = (List<Binding>)x; - } - } - configureBindingURIs(composite, definitions, defaultBindings, monitor); - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java deleted file mode 100644 index 6b9d5d9c46..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java +++ /dev/null @@ -1,536 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder.impl; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.TransformerFactory; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentProperty; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.Contract; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.assembly.SCABindingFactory; -import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * A composite builder that handles the configuration of binding URIs. - * - * @version $Rev$ $Date$ - */ -public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements CompositeBuilder { - - @Deprecated - public CompositeBindingURIBuilderImpl(AssemblyFactory assemblyFactory, - SCABindingFactory scaBindingFactory, - InterfaceContractMapper interfaceContractMapper) { - super(assemblyFactory, scaBindingFactory, - null, null, - interfaceContractMapper); - } - - public CompositeBindingURIBuilderImpl(AssemblyFactory assemblyFactory, - SCABindingFactory scaBindingFactory, - DocumentBuilderFactory documentBuilderFactory, - TransformerFactory transformerFactory, - InterfaceContractMapper interfaceContractMapper) { - super(assemblyFactory, scaBindingFactory, - documentBuilderFactory, transformerFactory, interfaceContractMapper); - } - - public String getID() { - return "org.apache.tuscany.sca.assembly.builder.CompositeBindingURIBuilder"; - } - - public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { - configureBindingURIsAndNames(composite, definitions, monitor); - } - - /** - * Called by CompositeBindingURIBuilderImpl - * - * @param composite the composite to be configured - */ - protected void configureBindingURIsAndNames(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { - configureBindingURIs(composite, null, definitions, null, monitor); - configureBindingNames(composite, 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. - * - * @param composite the composite to be configured - * @param defaultBindings list of default binding configurations - */ - protected void configureBindingURIs(Composite composite, - Definitions definitions, List<Binding> 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, List<Binding> defaultBindings, - Monitor monitor) throws CompositeBuilderException { - - String parentComponentURI = uri; - - // Process nested composites recursively - for (Component component : composite.getComponents()) { - - // Initialize component URI - String componentURI; - if (parentComponentURI == null) { - componentURI = component.getName(); - } else { - componentURI = URI.create(parentComponentURI + '/').resolve(component.getName()).toString(); - } - component.setURI(componentURI); - - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - - // Process nested composite - configureBindingURIs((Composite)implementation, componentURI, definitions, defaultBindings, monitor); - } - } - - // Initialize composite service binding URIs - List<Service> compositeServices = composite.getServices(); - for (Service service : compositeServices) { - // Set default binding names - - // Create default SCA binding - if (service.getBindings().isEmpty()) { - SCABinding scaBinding = createSCABinding(definitions); - service.getBindings().add(scaBinding); - } - - // Initialize binding names and URIs - for (Binding binding : service.getBindings()) { - constructBindingName(service, binding, monitor); - constructBindingURI(parentComponentURI, composite, service, binding, defaultBindings, monitor); - } - } - - // Initialize component service binding URIs - for (Component component : composite.getComponents()) { - - // Index properties, services and references - Map<String, Service> services = new HashMap<String, Service>(); - Map<String, Reference> references = new HashMap<String, Reference>(); - Map<String, Property> properties = new HashMap<String, Property>(); - indexImplementationPropertiesServicesAndReferences(component, - services, - references, - properties, - monitor); - - // Index component services, references and properties - // Also check for duplicates - Map<String, ComponentService> componentServices = - new HashMap<String, ComponentService>(); - Map<String, ComponentReference> componentReferences = - new HashMap<String, ComponentReference>(); - Map<String, ComponentProperty> componentProperties = - new HashMap<String, ComponentProperty>(); - indexComponentPropertiesServicesAndReferences(component, - componentServices, - componentReferences, - componentProperties, - monitor); - - // Reconcile component services/references/properties and - // implementation services/references and create component - // services/references/properties for the services/references - // declared by the implementation - reconcileServices(component, services, componentServices, monitor); - reconcileReferences(component, references, componentReferences, monitor); - reconcileProperties(component, properties, componentProperties, monitor); - - for (ComponentService service : component.getServices()) { - - // Create default SCA binding - if (service.getBindings().isEmpty()) { - SCABinding scaBinding = createSCABinding(definitions); - service.getBindings().add(scaBinding); - } - - // Initialize binding names and URIs - for (Binding binding : service.getBindings()) { - - constructBindingName(service, binding, monitor); - constructBindingURI(component, service, binding, defaultBindings, monitor); - } - } - } - } - - /** - * Add default names for callback bindings and reference bindings. Needs to be - * separate from configureBindingURIs() because configureBindingURIs() is called - * by NodeConfigurationServiceImpl as well as by CompositeBuilderImpl. - */ - private void configureBindingNames(Composite composite, Monitor monitor) { - - // Process nested composites recursively - for (Component component : composite.getComponents()) { - - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - - // Process nested composite - configureBindingNames((Composite)implementation, monitor); - } - } - - // Initialize composite service callback binding names - for (Service service : composite.getServices()) { - - if (service.getCallback() != null) { - for (Binding binding : service.getCallback().getBindings()) { - constructBindingName(service, binding, monitor); - } - } - } - - // Initialize composite reference binding names - for (Reference reference : composite.getReferences()) { - - for (Binding binding : reference.getBindings()) { - constructBindingName(reference, binding, monitor); - } - - if (reference.getCallback() != null) { - for (Binding binding : reference.getCallback().getBindings()) { - constructBindingName(reference, binding, monitor); - } - } - } - - // Initialize component service and reference binding names - for (Component component : composite.getComponents()) { - - // Initialize component service callback binding names - for (ComponentService service : component.getServices()) { - - if (service.getCallback() != null) { - for (Binding binding : service.getCallback().getBindings()) { - constructBindingName(service, binding, monitor); - } - } - } - - // Initialize component reference binding names - for (ComponentReference reference : component.getReferences()) { - - // Initialize binding names - for (Binding binding : reference.getBindings()) { - constructBindingName(reference, binding, monitor); - } - - if (reference.getCallback() != null) { - for (Binding binding : reference.getCallback().getBindings()) { - constructBindingName(reference, binding, monitor); - } - } - } - } - } - - /** - * If a binding name is not provided by the user, construct it based on the service - * or reference name - * - * @param contract the service or reference - * @param binding - */ - private void constructBindingName(Contract contract, Binding binding, Monitor monitor) { - - // 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){ - binding.setName(contract.getName()); - } - - // Check that multiple bindings do not have the same name - for (Binding otherBinding : contract.getBindings()) { - if (otherBinding == binding) { - // Skip the current binding - continue; - } - if (binding.getClass() != otherBinding.getClass()) { - // Look for a binding of the same type - continue; - } - if (binding.getName().equals(otherBinding.getName())) { - warning(monitor, contract instanceof Service ? "MultipleBindingsForService" : "MultipleBindingsForReference", - binding, contract.getName(), binding.getName()); - } - } - } - - /** - * URI construction for composite bindings based on Assembly Specification section 1.7.2, This method - * assumes that the component URI part of the binding URI is formed from the part to the - * composite in question and just calls the generic constructBindingURI method with this - * information - * - * @param parentComponentURI - * @param composite - * @param service - * @param binding - * @param defaultBindings - */ - private void constructBindingURI(String parentComponentURI, Composite composite, Service service, - Binding binding, List<Binding> 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, List<Binding> defaultBindings, Monitor monitor) - throws CompositeBuilderException{ - boolean includeBindingName = component.getServices().size() != 1; - constructBindingURI(component.getURI(), service, binding, includeBindingName, defaultBindings, monitor); - } - - /** - * Generic URI construction for bindings based on Assembly Specification section 1.7.2 - * - * @param componentURIString the string version of the URI part that comes from the component name - * @param service the service in question - * @param binding the binding for which the URI is being constructed - * @param includeBindingName when set true the serviceBindingURI part should be used - * @param defaultBindings the list of default binding configurations - * @throws CompositeBuilderException - */ - private void constructBindingURI(String componentURIString, Service service, Binding binding, - boolean includeBindingName, List<Binding> defaultBindings, Monitor monitor) - throws CompositeBuilderException{ - - try { - // calculate the service binding URI - URI bindingURI; - if (binding.getURI() != null){ - bindingURI = new URI(binding.getURI()); - - // if the user has provided an absolute binding URI then use it - if (bindingURI.isAbsolute()){ - binding.setURI(bindingURI.toString()); - return; - } - } else { - bindingURI = null; - } - - // Get the service binding name - URI bindingName; - if (binding.getName() != null) { - bindingName = new URI(binding.getName()); - } else { - bindingName = new URI(""); - } - - // calculate the component URI - URI componentURI; - if (componentURIString != null) { - componentURI = new URI(addSlashToPath(componentURIString)); - } else { - componentURI = null; - } - - // if the user has provided an absolute component URI then use it - if (componentURI != null && componentURI.isAbsolute()){ - binding.setURI(constructBindingURI(null, componentURI, bindingURI, includeBindingName, bindingName)); - return; - } - - // calculate the base URI - URI baseURI = null; - if (defaultBindings != null) { - for (Binding defaultBinding : defaultBindings){ - if (binding.getClass() == defaultBinding.getClass()){ - baseURI = new URI(addSlashToPath(defaultBinding.getURI())); - break; - } - } - } - - binding.setURI(constructBindingURI(baseURI, componentURI, bindingURI, includeBindingName, bindingName)); - } catch (URISyntaxException ex) { - error(monitor, "URLSyntaxException", binding, componentURIString, service.getName(), binding.getName()); - } - } - - /** - * Use to ensure that URI paths end in "/" as here we want to maintain the - * last path element of an base URI when other URI are resolved against it. This is - * not the default behaviour of URI resolution as defined in RFC 2369 - * - * @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("#")){ - return path; - } else { - return path + "/"; - } - } - - /** - * Concatenate binding URI parts together based on Assembly Specification section 1.7.2 - * - * @param baseURI the base of the binding URI - * @param componentURI the middle part of the binding URI derived from the component name - * @param bindingURI the end part of the binding URI - * @param includeBindingName when set true the binding name part should be used - * @param bindingName the binding name - * @return the resulting URI as a string - */ - private static String constructBindingURI(URI baseURI, URI componentURI, URI bindingURI, boolean includeBindingName, URI bindingName){ - String uriString; - - if (baseURI == null) { - if (componentURI == null){ - if (bindingURI != null ) { - uriString = bindingURI.toString(); - } else { - uriString = bindingName.toString(); - } - } else { - if (bindingURI != null ) { - uriString = componentURI.resolve(bindingURI).toString(); - } else { - if (includeBindingName) { - uriString = componentURI.resolve(bindingName).toString(); - } else { - uriString = componentURI.toString(); - } - } - } - } else { - if (componentURI == null) { - if (bindingURI != null ) { - uriString = basedURI(baseURI, bindingURI).toString(); - } else { - if (includeBindingName) { - uriString = basedURI(baseURI, bindingName).toString(); - } else { - uriString = baseURI.toString(); - } - } - } else { - if (bindingURI != null ) { - uriString = basedURI(baseURI, componentURI.resolve(bindingURI)).toString(); - } else { - if (includeBindingName) { - uriString = basedURI(baseURI, componentURI.resolve(bindingName)).toString(); - } else { - uriString = basedURI(baseURI, componentURI).toString(); - } - } - } - } - - // tidy up by removing any trailing "/" - if (uriString.endsWith("/")){ - uriString = uriString.substring(0, uriString.length()-1); - } - - URI uri = URI.create(uriString); - if (!uri.isAbsolute()) { - uri = URI.create("/").resolve(uri); - } - return uri.toString(); - } - - /** - * Combine a URI with a base URI. - * - * @param baseURI - * @param uri - * @return - */ - private static URI basedURI(URI baseURI, URI uri) { - if (uri.getScheme() != null) { - return uri; - } - String str = uri.toString(); - if (str.startsWith("/")) { - str = str.substring(1); - } - return URI.create(baseURI.toString() + str).normalize(); - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java deleted file mode 100644 index ad60c3b200..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.builder.impl; - -import java.util.logging.Logger; - -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.TransformerFactory; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.SCABindingFactory; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.apache.tuscany.sca.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.policy.PolicyFactory; - -/** - * A builder that handles the configuration of the components inside a composite - * and the wiring of component references to component services. - * - * @version $Rev$ $Date$ - */ -public class CompositeBuilderImpl implements CompositeBuilder { - private static final Logger logger = Logger.getLogger(CompositeBuilderImpl.class.getName()); - private CompositeBuilder compositeIncludeBuilder; - private CompositeBuilder componentReferenceWireBuilder; - //private CompositeBuilder componentReferencePromotionWireBuilder; - private CompositeBuilder componentReferencePromotionBuilder; - //private CompositeBuilder compositeReferenceWireBuilder; - private CompositeBuilder compositeCloneBuilder; - private CompositeBuilder componentConfigurationBuilder; - private CompositeBuilder compositeServiceConfigurationBuilder; - private CompositeBuilder compositeReferenceConfigurationBuilder; - private CompositeBuilder compositeBindingURIBuilder; - //private CompositeBuilder componentServicePromotionBuilder; - //private CompositeBuilder compositeServicePromotionBuilder; - private CompositeBuilder compositePromotionBuilder; - private CompositeBuilder compositePolicyBuilder; - private CompositeBuilder componentServiceBindingBuilder; - private CompositeBuilder 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); - } - - - /** - * Constructs a new composite builder. - * - * @param assemblyFactory - * @param scaBindingFactory - * @param endpointFactory - * @param intentAttachPointTypeFactory - * @param interfaceContractMapper - * @param policyDefinitions - * @param monitor - */ - @Deprecated - public CompositeBuilderImpl(AssemblyFactory assemblyFactory, - SCABindingFactory scaBindingFactory, - PolicyFactory intentAttachPointTypeFactory, - InterfaceContractMapper interfaceContractMapper) { - this(assemblyFactory, scaBindingFactory, intentAttachPointTypeFactory, - null, null, interfaceContractMapper); - } - - /** - * Constructs a new composite builder. - * - * @param assemblyFactory - * @param scaBindingFactory - * @param endpointFactory - * @param intentAttachPointTypeFactory - * @param interfaceContractMapper - * @param policyDefinitions - * @param monitor - */ - public CompositeBuilderImpl(AssemblyFactory assemblyFactory, - SCABindingFactory scaBindingFactory, - PolicyFactory intentAttachPointTypeFactory, - DocumentBuilderFactory documentBuilderFactory, - TransformerFactory transformerFactory, - InterfaceContractMapper interfaceContractMapper) { - - - compositeIncludeBuilder = new CompositeIncludeBuilderImpl(); - 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); - compositeServiceConfigurationBuilder = new CompositeServiceConfigurationBuilderImpl(assemblyFactory); - compositeReferenceConfigurationBuilder = new CompositeReferenceConfigurationBuilderImpl(assemblyFactory); - 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); - componentServiceEndpointBuilder = new ComponentServiceEndpointBuilderImpl(assemblyFactory); - //endpointReferenceBuilder = new EndpointReference2BuilderImpl(assemblyFactory, interfaceContractMapper); - } - - public String getID() { - return "org.apache.tuscany.sca.assembly.builder.CompositeBuilder"; - } - - public void build(Composite composite, Definitions definitions, 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 - compositeBindingURIBuilder.build(composite, definitions, 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/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeCloneBuilderImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeCloneBuilderImpl.java deleted file mode 100644 index 21e5192ae8..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeCloneBuilderImpl.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder.impl; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * A composite builder that clones nested composites. - * - * @version $Rev$ $Date$ - */ -public class CompositeCloneBuilderImpl implements CompositeBuilder { - - public CompositeCloneBuilderImpl() { - } - - public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { - expandCompositeImplementations(composite); - } - - public String getID() { - return "org.apache.tuscany.sca.assembly.builder.CompositeCloneBuilder"; - } - - /** - * Expand composite component implementations. - * - * @param composite - * @param problems - */ - private void expandCompositeImplementations(Composite composite) { - for (Component component : composite.getComponents()) { - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - - Composite compositeImplementation = (Composite)implementation; - Composite clone; - try { - clone = (Composite)compositeImplementation.clone(); - } catch (CloneNotSupportedException e) { - throw new RuntimeException(e); - } - component.setImplementation(clone); - expandCompositeImplementations(clone); - } - } - } - - /** - * Collect all nested composite implementations in a graph of composites. - * - * @param composite - * @param nested - */ - private void collectNestedComposites(Composite composite, List<Composite> nested) { - for (Component component : composite.getComponents()) { - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - Composite nestedComposite = (Composite)implementation; - nested.add(nestedComposite); - collectNestedComposites(nestedComposite, nested); - } - } - } - - /** - * Fuse nested composites into a top level composite. - * - * @param composite - */ - private void fuseCompositeImplementations(Composite composite) { - - // First collect all nested composites - List<Composite> nested = new ArrayList<Composite>(); - collectNestedComposites(composite, nested); - - // Then add all the non-composite components they contain - for (Composite nestedComposite : nested) { - 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<Component> i = composite.getComponents().iterator(); i.hasNext();) { - Component component = i.next(); - if (component.getImplementation() instanceof Composite) { - i.remove(); - } - } - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeIncludeBuilderImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeIncludeBuilderImpl.java deleted file mode 100644 index 730c002468..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeIncludeBuilderImpl.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder.impl; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -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; - -/** - * Implementation of a CompositeBuilder. - * - * @version $Rev$ $Date$ - */ -public class CompositeIncludeBuilderImpl implements CompositeBuilder { - - public CompositeIncludeBuilderImpl(FactoryExtensionPoint factories, InterfaceContractMapper mapper) { - } - - public CompositeIncludeBuilderImpl() { - } - - public String getID() { - return "org.apache.tuscany.sca.assembly.builder.CompositeIncludeBuilder"; - } - - public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { - fuseIncludes(composite, monitor); - } - - 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); - monitor.problem(problem); - } - } - - /** - * Collect all includes in a graph of includes. - * - * @param composite - * @param includes - */ - private void collectIncludes(Composite composite, List<Composite> includes, - Set<Composite> visited, Monitor monitor) { - for (Composite include : composite.getIncludes()) { - if (visited.contains(include)) { - warning(monitor, "CompositeAlreadyIncluded", composite, include.getName().toString()); - continue; - } - - includes.add(include); - visited.add(include); - collectIncludes(include, includes, visited, monitor); - } - } - - /** - * Copy a list of includes into a composite. - * - * @param composite - */ - private void fuseIncludes(Composite composite, Monitor monitor) { - - // First collect all includes - List<Composite> includes = new ArrayList<Composite>(); - Set<Composite> visited = new HashSet<Composite>(); - visited.add(composite); - collectIncludes(composite, includes, visited, monitor); - - // Then clone them - for (Composite include : includes) { - Composite clone; - try { - clone = (Composite)include.clone(); - } catch (CloneNotSupportedException e) { - throw new RuntimeException(e); - } - composite.getComponents().addAll(clone.getComponents()); - composite.getServices().addAll(clone.getServices()); - composite.getReferences().addAll(clone.getReferences()); - composite.getProperties().addAll(clone.getProperties()); - composite.getWires().addAll(clone.getWires()); - composite.getPolicySets().addAll(clone.getPolicySets()); - composite.getRequiredIntents().addAll(clone.getRequiredIntents()); - } - - // Clear the list of includes - composite.getIncludes().clear(); - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePolicyBuilderImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePolicyBuilderImpl.java deleted file mode 100644 index 5c3249369b..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePolicyBuilderImpl.java +++ /dev/null @@ -1,365 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder.impl; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.CompositeReference; -import org.apache.tuscany.sca.assembly.CompositeService; -import org.apache.tuscany.sca.assembly.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; -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.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySubject; - -/** - * A composite builder that computes policy sets based on attached intents and policy sets. - * Useful if you want to build the model without making any runtime decisions such as - * reference/services matching - * - * @version $Rev$ $Date$ - */ -public class CompositePolicyBuilderImpl extends BaseBuilderImpl implements CompositeBuilder { - - public CompositePolicyBuilderImpl(AssemblyFactory assemblyFactory, InterfaceContractMapper interfaceContractMapper) { - super(assemblyFactory, null, null, null, interfaceContractMapper); - } - - public String getID() { - return "org.apache.tuscany.sca.assembly.builder.CompositePolicyBuilder"; - } - - public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { - computePolicies(composite, definitions, monitor); - } - - /** - * Inherit the intents and policySets from the list of models - * @param intents - * @param policySets - * @param models - */ - private void inherit(PolicySubject policySubject, Object... models) { - for (Object model : models) { - if (model instanceof PolicySubject) { - PolicySubject subject = (PolicySubject)model; - policySubject.getRequiredIntents().addAll(subject.getRequiredIntents()); - policySubject.getPolicySets().addAll(subject.getPolicySets()); - } - } - } - - /** - * Check if two policy subjects requires multually exclusive intents - * @param subject1 - * @param subject2 - * @return - */ - private boolean isMutualExclusive(PolicySubject subject1, PolicySubject subject2) { - if (subject1 == subject2 || subject1 == null || subject2 == null) { - return false; - } - for (Intent i1 : subject1.getRequiredIntents()) { - for (Intent i2 : subject1.getRequiredIntents()) { - if (i1.getExcludedIntents().contains(i2) || i2.getExcludedIntents().contains(i1)) { - return true; - } - } - } - return false; - } - - /** - * Inherit the policySets and intents from the implementation hierarchy - * @param subject - * @param composite - * @param component - * @param service - */ - private void inheritFromService(PolicySubject subject, Composite composite, Component component, Service service) { - if (service == null) { - return; - } - if (service instanceof ComponentService) { - // component!=null - if (component.getImplementation() instanceof Composite) { - composite = (Composite)component.getImplementation(); - } - inheritFromService(subject, composite, component, ((ComponentService)service).getService()); - // Component service also inherits the intents/policySets from composite/component - inherit(subject, composite, component); - } else if (service instanceof CompositeService) { - // composite!=null, component is not used - CompositeService compositeService = (CompositeService)service; - // Handle the promoted component service - inheritFromService(subject, composite, compositeService.getPromotedComponent(), compositeService - .getPromotedService()); - } - // For atomic service, the composite is not used - inherit(subject, component.getImplementation(), service); - } - - /** - * Inherit the policySets and intents from the implementation hierarchy - * @param subject - * @param composite - * @param component - * @param reference - */ - private void inheritFromReference(PolicySubject subject, - Composite composite, - Component component, - Reference reference) { - if (reference == null) { - return; - } - if (reference instanceof ComponentReference) { - // component!=null - if (component.getImplementation() instanceof Composite) { - composite = (Composite)component.getImplementation(); - } - inheritFromReference(subject, composite, component, ((ComponentReference)reference).getReference()); - } else if (reference instanceof CompositeReference) { - CompositeReference compositeReference = (CompositeReference)reference; - for (int i = 0, n = compositeReference.getPromotedReferences().size(); i < n; i++) { - inheritFromReference(subject, - composite, - compositeReference.getPromotedComponents().get(i), - compositeReference.getPromotedReferences().get(i)); - } - } - // Inherit from the componentType/reference - inherit(subject, component.getImplementation(), reference); - } - - /** - * Check if two names are equal - * @param name1 - * @param name2 - * @return - */ - private boolean isEqual(String name1, String name2) { - if (name1 == name2) { - return true; - } - if (name1 != null) { - return name1.equals(name2); - } else { - return name2.equals(name1); - } - } - - private void resolveAndNormalize(PolicySubject subject, Definitions definitions, Monitor monitor) { - - Set<Intent> intents = new HashSet<Intent>(); - if (definitions != null) { - for (Intent i : subject.getRequiredIntents()) { - int index = definitions.getIntents().indexOf(i); - if (index != -1) { - intents.add(definitions.getIntents().get(index)); - } else { - warning(monitor, "intent-not-found", subject, i.getName().toString()); - // Intent cannot be resolved - } - } - } - - // Replace profile intents with their required intents - boolean profileIntentsFound = false; - while (true) { - Set<Intent> copy = new HashSet<Intent>(intents); - for (Intent i : copy) { - if (!i.getRequiredIntents().isEmpty()) { - intents.remove(i); - intents.addAll(i.getRequiredIntents()); - profileIntentsFound = true; - } - } - if (!profileIntentsFound) { - // No more profileIntents - break; - } - } - - // Remove the intents whose @contraints do not include the current element - // Replace unqualified intents if there is a qualified intent in the list - Set<Intent> copy = new HashSet<Intent>(intents); - for (Intent i : copy) { - if (i.getQualifiableIntent() != null) { - intents.remove(i.getQualifiableIntent()); - } - } - - // Replace qualifiable intents with the default qualified intent - copy = new HashSet<Intent>(intents); - for (Intent i : copy) { - if (i.getDefaultQualifiedIntent() != null) { - intents.remove(i); - intents.add(i.getDefaultQualifiedIntent()); - } - } - - subject.getRequiredIntents().clear(); - subject.getRequiredIntents().addAll(intents); - - Set<PolicySet> policySets = new HashSet<PolicySet>(); - if (definitions != null) { - for (PolicySet policySet : subject.getPolicySets()) { - int index = definitions.getPolicySets().indexOf(policySet); - if (index != -1) { - policySets.add(definitions.getPolicySets().get(index)); - } else { - // PolicySet cannot be resolved - } - } - } - - for (PolicySet policySet : policySets) { - List<Intent> provided = policySet.getProvidedIntents(); - // FIXME: Check if required intents are provided by the policy sets - } - - } - - protected void computePolicies(Composite composite, Definitions definitions, Monitor monitor) { - - // compute policies recursively - for (Component component : composite.getComponents()) { - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - computePolicies((Composite)implementation, definitions, monitor); - } - } - - for (Component component : composite.getComponents()) { - isMutualExclusive(component, component.getImplementation()); - - for (ComponentService componentService : component.getServices()) { - isMutualExclusive(componentService, componentService.getService()); - - if (componentService.getInterfaceContract() != null && componentService.getService() != null) { - isMutualExclusive(componentService.getInterfaceContract().getInterface(), componentService - .getService().getInterfaceContract().getInterface()); - isMutualExclusive(componentService.getInterfaceContract().getCallbackInterface(), componentService - .getService().getInterfaceContract().getCallbackInterface()); - } - - for (Endpoint ep : componentService.getEndpoints()) { - // Inherit from the componentType.service.interface - if (componentService.getService() != null && componentService.getService().getInterfaceContract() != null) { - inherit(ep, componentService.getService().getInterfaceContract().getInterface()); - } - if (componentService.getInterfaceContract() != null) { - // Inherit from the component.service.interface - inherit(ep, componentService.getInterfaceContract().getInterface()); - } - // Inherit from the componentType/service - inheritFromService(ep, composite, component, componentService.getService()); - // Find the corresponding binding in the componentType and inherit the intents/policySets - if (componentService.getService() != null) { - for (Binding binding : componentService.getService().getBindings()) { - if (isEqual(ep.getBinding().getName(), binding.getName()) && (binding instanceof PolicySubject)) { - isMutualExclusive((PolicySubject)ep.getBinding(), (PolicySubject)binding); - // Inherit from componentType.service.binding - inherit(ep, binding); - break; - } - } - } - // Inherit from composite/component/service - inheritFromService(ep, composite, ep.getComponent(), ep.getService()); - // Inherit from binding - inherit(ep, ep.getBinding()); - - // Replace profile intents with their required intents - // Remove the intents whose @contraints do not include the current element - // Replace unqualified intents if there is a qualified intent in the list - // Replace qualifiable intents with the default qualied intent - resolveAndNormalize(ep, definitions, monitor); - } - } - - for (ComponentReference componentReference : component.getReferences()) { - isMutualExclusive(componentReference, componentReference.getReference()); - - if (componentReference.getInterfaceContract() != null) { - isMutualExclusive(componentReference.getInterfaceContract().getInterface(), componentReference - .getReference().getInterfaceContract().getInterface()); - isMutualExclusive(componentReference.getInterfaceContract().getCallbackInterface(), - componentReference.getReference().getInterfaceContract().getCallbackInterface()); - } - - for (EndpointReference epr : componentReference.getEndpointReferences()) { - // Inherit from the componentType.reference.interface - if (componentReference.getReference() != null && componentReference.getReference() - .getInterfaceContract() != null) { - inherit(epr, componentReference.getReference().getInterfaceContract().getInterface()); - } - // Inherit from the component.reference.interface - if (componentReference.getInterfaceContract() != null) { - inherit(epr, componentReference.getInterfaceContract().getInterface()); - } - // Inherit from the componentType/reference - inheritFromReference(epr, composite, component, componentReference.getReference()); - // Find the corresponding binding in the componentType and inherit the intents/policySets - if (componentReference.getReference() != null) { - for (Binding binding : componentReference.getReference().getBindings()) { - if (epr.getBinding() != null && isEqual(epr.getBinding().getName(), binding.getName()) - && (binding instanceof PolicySubject)) { - isMutualExclusive((PolicySubject)epr.getBinding(), (PolicySubject)binding); - // Inherit from componentType.reference.binding - inherit(epr, binding); - break; - } - } - } - // Inherit from composite/component/reference/binding - inheritFromReference(epr, composite, epr.getComponent(), epr.getReference()); - inherit(epr, epr.getBinding()); - - // Replace profile intents with their required intents - // Remove the intents whose @contraints do not include the current element - // Replace unqualified intents if there is a qualified intent in the list - // Replace qualifiable intents with the default qualied intent - resolveAndNormalize(epr, definitions, monitor); - } - } - - Implementation implementation = component.getImplementation(); - // How to deal with implementation level policySets/intents - } - } -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java deleted file mode 100644 index e2f17f5efd..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder.impl; - - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.CompositeReference; -import org.apache.tuscany.sca.assembly.CompositeService; -import org.apache.tuscany.sca.assembly.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; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * A composite builder that makes the connections between composite services and references - * and the services and references that they promote - * - * @version $Rev$ $Date$ - */ -public class CompositePromotionBuilderImpl extends BaseBuilderImpl implements CompositeBuilder { - - public CompositePromotionBuilderImpl(AssemblyFactory assemblyFactory, InterfaceContractMapper interfaceContractMapper) { - super(assemblyFactory, null, null, null, interfaceContractMapper); - } - - public String getID() { - return "org.apache.tuscany.sca.assembly.builder.CompositePromotionBuilder"; - } - - 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. - * - * @param composite - * @param componentServices - * @param problems - */ - protected void connectCompositeReferencesAndServices(Composite composite, Monitor monitor){ - // Wire nested composites recursively - for (Component component : composite.getComponents()) { - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - connectCompositeReferencesAndServices((Composite)implementation, monitor); - } - } - - // Index components, services and references - Map<String, Component> components = new HashMap<String, Component>(); - Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>(); - Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>(); - indexComponentsServicesAndReferences(composite, components, componentServices, componentReferences); - - // Connect composite services and references to the component - // services and references that they promote - connectCompositeServices(composite, components, componentServices, monitor); - connectCompositeReferences(composite, components, componentReferences, monitor); - } - - /** - * Connect composite services to the component services that they promote. - * - * @param composite - * @param componentServices - * @param problems - */ - private void connectCompositeServices(Composite composite, - Map<String, Component> components, - Map<String, ComponentService> componentServices, - Monitor monitor) { - - // Propagate interfaces from inner composite components' services to - // their component services - for (Component component : composite.getComponents()) { - if (component.getImplementation() instanceof Composite) { - for (ComponentService componentService : component.getServices()) { - Service service = componentService.getService(); - if (service != null) { - if (componentService.getInterfaceContract() == null) { - componentService.setInterfaceContract(service.getInterfaceContract()); - } - } - } - } - } - - // 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 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(); - } - } 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(); - InterfaceContract promotedServiceInterfaceContract = promotedService.getInterfaceContract(); - if (compositeServiceInterfaceContract == null) { - compositeService.setInterfaceContract(promotedServiceInterfaceContract); - } else if (promotedServiceInterfaceContract != null) { - // Check the compositeServiceInterfaceContract and promotedServiceInterfaceContract - 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); - } - } - } - - } - - /** - * Resolves promoted references. - * - * @param composite - * @param componentReferences - * @param problems - */ - private void connectCompositeReferences(Composite composite, - Map<String, Component> components, - Map<String, ComponentReference> componentReferences, Monitor monitor) { - - // Propagate interfaces from inner composite components' references to - // their component references - for (Component component : composite.getComponents()) { - if (component.getImplementation() instanceof Composite) { - for (ComponentReference componentReference : component.getReferences()) { - Reference reference = componentReference.getReference(); - if (reference != null) { - if (componentReference.getInterfaceContract() == null) { - componentReference.setInterfaceContract(reference.getInterfaceContract()); - } - } - } - } - } - - // Connect composite references to the component references that they promote - for (Reference reference : composite.getReferences()) { - CompositeReference compositeReference = (CompositeReference)reference; - List<ComponentReference> promotedReferences = compositeReference.getPromotedReferences(); - for (int i = 0, n = promotedReferences.size(); i < n; i++) { - ComponentReference componentReference = promotedReferences.get(i); - if (componentReference.isUnresolved()) { - String componentReferenceName = componentReference.getName(); - componentReference = componentReferences.get(componentReferenceName); - if (componentReference != null) { - // Set the promoted component - Component promotedComponent = compositeReference.getPromotedComponents().get(i); - promotedComponent = components.get(promotedComponent.getName()); - compositeReference.getPromotedComponents().set(i, promotedComponent); - - 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(); - 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); - if (!isCompatible) { - warning(monitor, "ReferenceInterfaceNotSubSet", compositeReference, componentReferenceName); - } - } - } else { - warning(monitor, "PromotedReferenceNotFound", composite, composite.getName().toString(), componentReferenceName); - } - } - } - } - } -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.java deleted file mode 100644 index 07422ef9f2..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder.impl; - -import java.util.List; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.CompositeReference; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.builder.AutomaticBinding; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * A composite builder that handles the configuration of composite references. - * - * @version $Rev: 651179 $ $Date: 2008-04-24 08:21:13 +0100 (Thu, 24 Apr 2008) $ - */ -public class CompositeReferenceConfigurationBuilderImpl implements CompositeBuilder { - private AssemblyFactory assemblyFactory; - - public CompositeReferenceConfigurationBuilderImpl(AssemblyFactory assemblyFactory) { - this.assemblyFactory = assemblyFactory; - } - - public String getID() { - return "org.apache.tuscany.sca.assembly.builder.CompositeReferenceConfigurationBuilder"; - } - - public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { - - // Process nested composites recursively - configureNestedCompositeReferences(composite); - - // Process top level composite references - // TODO - In OASIS the treament of top level composite references is different so need to review - for (Reference reference : composite.getReferences()) { - CompositeReference compositeReference = (CompositeReference)reference; - - // Get the next lower level promoted reference - List<ComponentReference> promotedRefs = compositeReference.getPromotedReferences(); - if (!promotedRefs.isEmpty()) { - if (promotedRefs.size() == 1) { - ComponentReference promotedReference = promotedRefs.get(0); - - // Set the bindings using the top level bindings to override the lower level bindings - if (bindingsSpecifiedManually(compositeReference.getBindings())) { - compositeReference.setPromotionOverride(true); - } else if (bindingsSpecifiedManually(promotedReference.getBindings()) ) { - compositeReference.getBindings().clear(); - for (Binding binding : promotedReference.getBindings()) { - try { - compositeReference.getBindings().add((Binding)binding.clone()); - } catch (CloneNotSupportedException ex) { - // this binding can't be used in the promoted reference - } - } - } - if (compositeReference.getInterfaceContract() != null && - compositeReference.getInterfaceContract().getCallbackInterface() != null) { - if (compositeReference.getCallback() != null && - bindingsSpecifiedManually(compositeReference.getCallback().getBindings())) { - compositeReference.setPromotionOverride(true); - } else if (promotedReference.getCallback() != null && - bindingsSpecifiedManually(promotedReference.getCallback().getBindings())) { - if (compositeReference.getCallback() != null) { - compositeReference.getCallback().getBindings().clear(); - } else { - compositeReference.setCallback(assemblyFactory.createCallback()); - } - for (Binding binding : promotedReference.getCallback().getBindings()) { - try { - compositeReference.getCallback().getBindings().add((Binding)binding.clone()); - } catch (CloneNotSupportedException ex) { - // this binding can't be used in the promoted reference - } - } - } - } - } else { - // This composite reference promotes multiple component references. - // Because the component reference bindings can all be different, we don't - // copy any of them up to this composite reference, which will therefore always - // have its own binding, even if it's only the default SCA binding. - if (bindingsSpecifiedManually(compositeReference.getBindings()) || - (compositeReference.getCallback() != null && - bindingsSpecifiedManually(compositeReference.getCallback().getBindings()))) { - compositeReference.setPromotionOverride(true); - } - } - } - } - } - - private void configureNestedCompositeReferences(Composite composite) { - - // Process nested composites recursively - for (Component component : composite.getComponents()) { - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - - // First process nested composites - configureNestedCompositeReferences((Composite)implementation); - - // Process the component references declared on components in this composite - for (ComponentReference componentReference : component.getReferences()) { - Reference implReference = componentReference.getReference(); - if (implReference != null && implReference instanceof CompositeReference) { - CompositeReference compositeReference = (CompositeReference)implReference; - - // Get the next lower level promoted reference - List<ComponentReference> promotedRefs = compositeReference.getPromotedReferences(); - if (!promotedRefs.isEmpty()) { - if (promotedRefs.size() == 1) { - ComponentReference promotedReference = promotedRefs.get(0); - - // Set the bindings using the top level bindings to override the lower level bindings - if (!bindingsSpecifiedManually(compositeReference.getBindings()) && - bindingsSpecifiedManually(promotedReference.getBindings()) ) { - compositeReference.getBindings().clear(); - for (Binding binding : promotedReference.getBindings()) { - try { - compositeReference.getBindings().add((Binding)binding.clone()); - } catch (CloneNotSupportedException ex) { - // this binding can't be used in the promoted reference - } - } - } - if (bindingsSpecifiedManually(componentReference.getBindings())) { - componentReference.setPromotionOverride(true); - } else if (bindingsSpecifiedManually(compositeReference.getBindings()) ) { - componentReference.getBindings().clear(); - componentReference.getBindings().addAll(compositeReference.getBindings()); - } - if (componentReference.getInterfaceContract() != null && - componentReference.getInterfaceContract().getCallbackInterface() != null) { - if (!(compositeReference.getCallback() != null && - bindingsSpecifiedManually(compositeReference.getCallback().getBindings())) && - promotedReference.getCallback() != null && - bindingsSpecifiedManually(promotedReference.getCallback().getBindings())) { - if (compositeReference.getCallback() != null) { - compositeReference.getCallback().getBindings().clear(); - } else { - compositeReference.setCallback(assemblyFactory.createCallback()); - } - compositeReference.getCallback().getBindings().addAll( - promotedReference.getCallback().getBindings()); - } - if (componentReference.getCallback() != null && - bindingsSpecifiedManually(componentReference.getCallback().getBindings())) { - componentReference.setPromotionOverride(true); - } else if (compositeReference.getCallback() != null && - bindingsSpecifiedManually(compositeReference.getCallback().getBindings())) { - if (componentReference.getCallback() != null) { - componentReference.getCallback().getBindings().clear(); - } else { - componentReference.setCallback(assemblyFactory.createCallback()); - } - for (Binding binding : compositeReference.getCallback().getBindings()) { - try { - componentReference.getCallback().getBindings().add((Binding)binding.clone()); - } catch (CloneNotSupportedException ex) { - // this binding can't be used in the promoted reference - } - } - } - } - } else { - // This component reference promotes multiple lower-level component references. - // Because the lower-level component reference bindings can all be different, - // we don't copy any of them up to this component reference, which will therefore - // always have its own binding, even if it's only the default SCA binding. - if (bindingsSpecifiedManually(componentReference.getBindings()) || - (componentReference.getCallback() != null && - bindingsSpecifiedManually(componentReference.getCallback().getBindings()))) { - componentReference.setPromotionOverride(true); - } - } - } - } - } - } - } - } - - /** - * If the bindings are specified in the composite file return true as they should - * otherwise return false - * - * @param bindings - * @return true if the bindings were specified manually - */ - private boolean bindingsSpecifiedManually(List<Binding> bindings) { - - if (bindings.size() > 1) { - return true; - } else if (bindings.size() == 1 && - bindings.get(0) instanceof AutomaticBinding && - ((AutomaticBinding)bindings.get(0)).getIsAutomatic()) { - return false; - } else if (bindings.size() == 1) { - return true; - } else { - return false; - } - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java deleted file mode 100644 index 451b378941..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder.impl; - -import java.util.List; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.CompositeReference; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * A composite builder that wires composite references. - * - * @version $Rev$ $Date$ - */ -public class CompositeReferenceWireBuilderImpl implements CompositeBuilder { - private AssemblyFactory assemblyFactory; - - public CompositeReferenceWireBuilderImpl(AssemblyFactory assemblyFactory) { - this.assemblyFactory = assemblyFactory; - } - - public String getID() { - return "org.apache.tuscany.sca.assembly.builder.ComponentReferenceWireBuilder"; - } - - /** - * Wire composite references in a deployment composite. - * - * @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; - - // If the composite reference is a promotion override, override the - // configuration of the promoted reference. - //FIXME: Policy configuration or wiring of domain-level composite references - // doesn't cause a promotion override, unless the composite reference has - // additional bindings. Do we need to detect this and force an override? - if (compositeReference.isPromotionOverride()) { - List<ComponentReference> promotedReferences = - ReferenceConfigurationUtil.getPromotedComponentReferences(compositeReference); - for (ComponentReference promotedReference : promotedReferences) { - ReferenceConfigurationUtil.reconcileReferenceBindings( - compositeReference, promotedReference, assemblyFactory, monitor); - if (compositeReference.getInterfaceContract() != null && // can be null in unit tests - compositeReference.getInterfaceContract().getCallbackInterface() != null) { - SCABinding scaCallbackBinding = promotedReference.getCallbackBinding(SCABinding.class); - if (promotedReference.getCallback() != null) { - promotedReference.getCallback().getBindings().clear(); - } else { - promotedReference.setCallback(assemblyFactory.createCallback()); - } - if (scaCallbackBinding != null) { - promotedReference.getCallback().getBindings().add(scaCallbackBinding); - } - if (compositeReference.getCallback() != null) { - promotedReference.getCallback().getBindings().addAll(compositeReference.getCallback() - .getBindings()); - } - } - } - } - } - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceBindingBuilderImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceBindingBuilderImpl.java deleted file mode 100644 index 6a8da7241a..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceBindingBuilderImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder.impl; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.CompositeService; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.assembly.builder.BindingBuilderExtension; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * A composite builder that performs any additional building steps that - * composite service bindings may need. Used for WSDL generation. - * - * @version $Rev$ $Date$ - */ -public class CompositeServiceBindingBuilderImpl implements CompositeBuilder { - - public CompositeServiceBindingBuilderImpl() { - } - - public String getID() { - return "org.apache.tuscany.sca.assembly.builder.CompositeServiceBindingBuilder"; - } - - 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(); - if (implementation instanceof Composite) { - buildServiceBindings((Composite)implementation, monitor); - } - } - - // find all the composite service bindings - for (Service service : composite.getServices()) { - for (Binding binding : service.getBindings()) { - if (binding instanceof BindingBuilderExtension) { - Component component = ServiceConfigurationUtil.getPromotedComponent((CompositeService)service); - ((BindingBuilderExtension)binding).getBuilder().build(component, service, binding, monitor); - } - } - } - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java deleted file mode 100644 index 099996d244..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder.impl; - -import java.util.List; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.CompositeService; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.assembly.builder.AutomaticBinding; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * A composite builder that handles the configuration of composite services. - * - * @version $Rev$ $Date$ - */ -public class CompositeServiceConfigurationBuilderImpl implements CompositeBuilder { - private AssemblyFactory assemblyFactory; - - public CompositeServiceConfigurationBuilderImpl(AssemblyFactory assemblyFactory) { - this.assemblyFactory = assemblyFactory; - } - - public String getID() { - return "org.apache.tuscany.sca.assembly.builder.CompositeServiceConfigurationBuilder"; - } - - public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { - - // Process nested composites recursively - configureNestedCompositeServices(composite); - - // TODO - In OASIS the treatment of top level composite services it different - // Process top level composite services - for (Service service : composite.getServices()) { - CompositeService compositeService = (CompositeService)service; - - // Get the next lower level promoted service - ComponentService promotedService = compositeService.getPromotedService(); - if (promotedService != null) { - - // Set the bindings using the top level bindings to override the lower level bindings - if (!bindingsSpecifiedManually(compositeService.getBindings()) && - bindingsSpecifiedManually(promotedService.getBindings())) { - compositeService.getBindings().clear(); - for (Binding binding : promotedService.getBindings()) { - try { - compositeService.getBindings().add((Binding)binding.clone()); - } catch (CloneNotSupportedException ex) { - // this binding can't be used in the promoted service - } - } - } - if (compositeService.getInterfaceContract() != null && - compositeService.getInterfaceContract().getCallbackInterface() != null) { - if (!(compositeService.getCallback() != null && - bindingsSpecifiedManually(compositeService.getCallback().getBindings())) && - promotedService.getCallback() != null && - bindingsSpecifiedManually(promotedService.getCallback().getBindings())) { - if (compositeService.getCallback() != null) { - compositeService.getCallback().getBindings().clear(); - } else { - compositeService.setCallback(assemblyFactory.createCallback()); - } - for (Binding binding : promotedService.getCallback().getBindings()) { - try { - compositeService.getCallback().getBindings().add((Binding)binding.clone()); - } catch (CloneNotSupportedException ex) { - // this binding can't be used in the promoted service - } - } - } - } - } - } - } - - private void configureNestedCompositeServices(Composite composite) { - - // Process nested composites recursively - for (Component component : composite.getComponents()) { - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - - // First process nested composites - configureNestedCompositeServices((Composite)implementation); - - // Process the component services declared on components in this composite - for (ComponentService componentService : component.getServices()) { - Service implService = componentService.getService(); - if (implService != null && implService instanceof CompositeService) { - CompositeService compositeService = (CompositeService)implService; - - // Get the next lower level promoted service - ComponentService promotedService = compositeService.getPromotedService(); - if (promotedService != null) { - - // Set the bindings using the top level bindings to override the lower level bindings - if (!bindingsSpecifiedManually(compositeService.getBindings()) && - bindingsSpecifiedManually(promotedService.getBindings()) ) { - compositeService.getBindings().clear(); - for (Binding binding : promotedService.getBindings()) { - try { - compositeService.getBindings().add((Binding)binding.clone()); - } catch (CloneNotSupportedException ex) { - // this binding can't be used in the promoted service - } - } - } - if (!bindingsSpecifiedManually(componentService.getBindings()) && - bindingsSpecifiedManually(compositeService.getBindings()) ) { - componentService.getBindings().clear(); - componentService.getBindings().addAll(compositeService.getBindings()); - } - if (componentService.getInterfaceContract() != null && - componentService.getInterfaceContract().getCallbackInterface() != null) { - if (!(compositeService.getCallback() != null && - bindingsSpecifiedManually(compositeService.getCallback().getBindings())) && - promotedService.getCallback() != null && - bindingsSpecifiedManually(promotedService.getCallback().getBindings())) { - if (compositeService.getCallback() != null) { - compositeService.getCallback().getBindings().clear(); - } else { - compositeService.setCallback(assemblyFactory.createCallback()); - } - for (Binding binding : promotedService.getCallback().getBindings()) { - try { - compositeService.getCallback().getBindings().add((Binding)binding.clone()); - } catch (CloneNotSupportedException ex) { - // this binding can't be used in the promoted service - } - } - } - if (!(componentService.getCallback() != null && - bindingsSpecifiedManually(componentService.getCallback().getBindings())) && - compositeService.getCallback() != null && - bindingsSpecifiedManually(compositeService.getCallback().getBindings())) { - if (componentService.getCallback() != null) { - componentService.getCallback().getBindings().clear(); - } else { - componentService.setCallback(assemblyFactory.createCallback()); - } - componentService.getCallback().getBindings().addAll( - compositeService.getCallback().getBindings()); - } - } - } - } - } - } - } - } - - /** - * If the bindings are specified in the composite file return true as they should - * otherwise return false - * - * @param bindings - * @return true if the bindings were specified manually - */ - private boolean bindingsSpecifiedManually(List<Binding> bindings) { - - if (bindings.size() > 1) { - return true; - } else if (bindings.size() == 1 && - bindings.get(0) instanceof AutomaticBinding && - ((AutomaticBinding)bindings.get(0)).getIsAutomatic()) { - return false; - } else if (bindings.size() == 1) { - return true; - } else { - return false; - } - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServicePromotionBuilderImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServicePromotionBuilderImpl.java deleted file mode 100644 index 3004a9f590..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServicePromotionBuilderImpl.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.builder.impl; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.CompositeService; -import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * A composite builder that handles the creation of promoted composite services. - * - * @version $Rev$ $Date$ - */ -public class CompositeServicePromotionBuilderImpl implements CompositeBuilder { - private AssemblyFactory assemblyFactory; - - public CompositeServicePromotionBuilderImpl(AssemblyFactory assemblyFactory) { - this.assemblyFactory = assemblyFactory; - } - - public String getID() { - return "org.apache.tuscany.sca.assembly.builder.CompositeServicePromotionBuilder"; - } - - public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { - - // Process top level composite services - for (Service service : composite.getServices()) { - CompositeService compositeService = (CompositeService)service; - - // Get the innermost promoted service - ComponentService promotedService = ServiceConfigurationUtil.getPromotedComponentService(compositeService); - if (promotedService != null) { - Component promotedComponent = ServiceConfigurationUtil.getPromotedComponent(compositeService); - - // Create a new component service to represent this composite - // service on the promoted component - ComponentService newComponentService = assemblyFactory.createComponentService(); - newComponentService.setName("$promoted$" + compositeService.getName()); - promotedComponent.getServices().add(newComponentService); - newComponentService.setService(promotedService.getService()); - newComponentService.getBindings().addAll(compositeService.getBindings()); - newComponentService.setInterfaceContract(compositeService.getInterfaceContract()); - if (compositeService.getInterfaceContract() != null && - compositeService.getInterfaceContract().getCallbackInterface() != null) { - newComponentService.setCallback(assemblyFactory.createCallback()); - newComponentService.getCallback().getBindings() - .addAll(compositeService.getCallback().getBindings()); - } - - // Change the composite service to now promote the newly - // created component service directly - compositeService.setPromotedComponent(promotedComponent); - compositeService.setPromotedService(newComponentService); - } - } - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationException.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationException.java deleted file mode 100644 index 944cf2cf36..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationException.java +++ /dev/null @@ -1,38 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.assembly.builder.impl;
-
-/**
- * Exception to be throw for invalid policy intents / policysets
- *
- * @version $Rev$ $Date$
- */
-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/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java deleted file mode 100644 index a7a40e62e6..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java +++ /dev/null @@ -1,428 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.assembly.builder.impl;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.sca.assembly.Base;
-import org.apache.tuscany.sca.assembly.Binding;
-import org.apache.tuscany.sca.assembly.Component;
-import org.apache.tuscany.sca.assembly.Contract;
-import org.apache.tuscany.sca.assembly.Implementation;
-import org.apache.tuscany.sca.policy.ExtensionType;
-import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentMap;
-import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySubject;
-import org.apache.tuscany.sca.policy.util.PolicyComputationUtils;
-import org.apache.tuscany.sca.policy.util.PolicyValidationException;
-import org.apache.tuscany.sca.policy.util.PolicyValidationUtils;
-
-/**
- * This class contains policy computation methods common to computing implementation and binding policies
- *
- * @version $Rev$ $Date$
- */
-abstract class PolicyConfigurationUtil {
-
- private static List<Intent> computeInheritableIntents(ExtensionType attachPointType,
- List<Intent> inheritableIntents) throws PolicyValidationException {
- List<Intent> validInheritableIntents = new ArrayList<Intent>();
-
- //expand profile intents in inherited intents
- PolicyComputationUtils.expandProfileIntents(inheritableIntents);
-
- //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() ) {
- for (ExtensionType constrained : intent.getConstrainedTypes()) {
- if ( PolicyValidationUtils.isConstrained(constrained, attachPointType)) {
- validInheritableIntents.add(intent);
- break;
- }
- }
- } else {
- throw new PolicyValidationException("Policy Intent '" + intent.getName() + "' is not defined in this domain");
- }
- }
-
- return validInheritableIntents;
- }
-
- private static void normalizeIntents(PolicySubject intentAttachPoint) {
- //expand profile intents specified in the attachpoint (binding / implementation)
- PolicyComputationUtils.expandProfileIntents(intentAttachPoint.getRequiredIntents());
-
- //remove duplicates and ...
- //where qualified form of intent exists retain it and remove the qualifiable intent
- filterDuplicatesAndQualifiableIntents(intentAttachPoint);
- }
-
- private static void trimInherentlyProvidedIntents(ExtensionType attachPointType, List<Intent>intents) {
- //exclude intents that are inherently supported by the
- //attachpoint-type (binding-type / implementation-type)
- List<Intent> requiredIntents = new ArrayList<Intent>(intents);
- for ( Intent intent : requiredIntents ) {
- if ( isProvidedInherently(attachPointType, intent) ) {
- intents.remove(intent);
- }
- }
- }
-
-
- private static List<PolicySet> computeInheritablePolicySets(List<PolicySet> inheritablePolicySets)
- throws PolicyValidationException {
- // FIXME:
- return inheritablePolicySets;
- }
-
- private static void normalizePolicySets(PolicySubject subject ) {
- //get rid of duplicate entries
- Set<PolicySet> policySetTable = new HashSet<PolicySet>(subject.getPolicySets());
-
- subject.getPolicySets().clear();
- subject.getPolicySets().addAll(policySetTable);
-
- //expand profile intents
- for ( PolicySet policySet : subject.getPolicySets() ) {
- PolicyComputationUtils.expandProfileIntents(policySet.getProvidedIntents());
- }
- }
-
- private static void trimProvidedIntents(List<Intent> requiredIntents, List<PolicySet> policySets) {
- for ( PolicySet policySet : policySets ) {
- trimProvidedIntents(requiredIntents, policySet);
- }
- }
-
- private static void determineApplicableDomainPolicySets(List<PolicySet> applicablePolicySets,
- PolicySubject policySetAttachPoint,
- ExtensionType intentAttachPointType) {
-
- if (policySetAttachPoint.getRequiredIntents().size() > 0) {
-
- // form a list of all intents required by the attach point
- List<Intent> combinedTargetIntents = new ArrayList<Intent>();
- combinedTargetIntents.addAll(policySetAttachPoint.getRequiredIntents());
- for (PolicySet targetPolicySet : policySetAttachPoint.getPolicySets()) {
- combinedTargetIntents.addAll(PolicyComputationUtils.findAndExpandProfileIntents(targetPolicySet.getProvidedIntents()));
- }
-
- //since the set of applicable policysets for this attachpoint is known
- //we only need to check in that list if there is a policyset that matches
- for (PolicySet policySet : applicablePolicySets) {
- // do not use the policy set if it provides intents that conflict with required intents
- boolean conflict = false;
- List<Intent> providedIntents = PolicyComputationUtils.findAndExpandProfileIntents(policySet.getProvidedIntents());
- checkConflict: for (Intent intent : providedIntents) {
- for (Intent excluded : intent.getExcludedIntents()) {
- if (combinedTargetIntents.contains(excluded)) {
- conflict = true;
- break checkConflict;
- }
- }
- }
- if (conflict)
- continue;
- int prevSize = policySetAttachPoint.getRequiredIntents().size();
- trimProvidedIntents(policySetAttachPoint.getRequiredIntents(), policySet);
- // if any intent was trimmed off, then this policyset must
- // be attached to the intent attachpoint's policyset
- if (prevSize != policySetAttachPoint.getRequiredIntents().size()) {
- policySetAttachPoint.getPolicySets().add(policySet);
- }
- }
- }
- }
-
- 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) )
- ) );
- }
-
- private static void trimProvidedIntents(List<Intent> requiredIntents, PolicySet policySet) {
- for ( Intent providedIntent : policySet.getProvidedIntents() ) {
- if ( requiredIntents.contains(providedIntent) ) {
- requiredIntents.remove(providedIntent);
- }
- }
-
- for ( IntentMap intentMap : policySet.getIntentMaps() ) {
- if ( requiredIntents.contains(intentMap.getProvidedIntent()) ) {
- requiredIntents.remove(intentMap.getProvidedIntent());
- }
- }
- }
-
- private static void filterDuplicatesAndQualifiableIntents(PolicySubject intentAttachPoint) {
- //remove duplicates
- Map<QName, Intent> intentsTable = new HashMap<QName, Intent>();
- for ( Intent intent : intentAttachPoint.getRequiredIntents() ) {
- intentsTable.put(intent.getName(), intent);
- }
-
- //where qualified form of intent exists retain it and remove the qualifiable intent
- Map<QName, Intent> intentsTableCopy = new HashMap<QName, Intent>(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 ) {
- intentsTable.remove(intent.getQualifiableIntent().getName());
- }
- }
- }
- intentAttachPoint.getRequiredIntents().clear();
- intentAttachPoint.getRequiredIntents().addAll(intentsTable.values());
- }
-
- static void computeBindingIntentsAndPolicySets(Contract contract) throws PolicyValidationException {
- for (Binding binding : contract.getBindings()) {
- if (binding instanceof PolicySubject) {
- PolicySubject policiedBinding = (PolicySubject)binding;
- computeIntents((PolicySubject)binding, contract.getRequiredIntents());
-
- computePolicySets(policiedBinding, contract.getPolicySets());
-
- PolicyComputationUtils.checkForMutuallyExclusiveIntents(
- policiedBinding.getRequiredIntents(),
- policiedBinding.getPolicySets(),
- policiedBinding.getType(),
- contract.getName());
- }
- }
-
- if ( contract.getCallback() != null ) {
- for (Binding binding : contract.getCallback().getBindings()) {
- if (binding instanceof PolicySubject) {
- PolicySubject policiedBinding = (PolicySubject)binding;
- computeIntents((PolicySubject)binding, contract.getCallback().getRequiredIntents());
-
- computePolicySets(policiedBinding, contract.getCallback().getPolicySets());
-
- PolicyComputationUtils.checkForMutuallyExclusiveIntents(
- policiedBinding.getRequiredIntents(),
- policiedBinding.getPolicySets(),
- policiedBinding.getType(),
- contract.getName() + " callback");
-
- }
- }
- }
- }
-
- private static void computeIntents(PolicySubject policiedBinding, List<Intent> 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<Intent> prunedIntents = computeInheritableIntents(policiedBinding.getType(),
- inheritedIntents);
- policiedBinding.getRequiredIntents().addAll(prunedIntents);
-
- normalizeIntents(policiedBinding);
- }
-
- private static void computePolicySets(PolicySubject policiedBinding,
- List<PolicySet> inheritedPolicySets) throws PolicyValidationException {
-
- List<PolicySet> prunedPolicySets = computeInheritablePolicySets(inheritedPolicySets);
- policiedBinding.getPolicySets().addAll(prunedPolicySets);
- normalizePolicySets(policiedBinding);
- }
-
- static void determineApplicableBindingPolicySets(Contract source, Contract target) throws PolicyConfigurationException {
- List<Intent> intentsCopy = null;
- for (Binding aBinding : source.getBindings()) {
- if (aBinding instanceof PolicySubject) {
- PolicySubject policiedBinding = (PolicySubject)aBinding;
- ExtensionType bindingType = policiedBinding.getType();
-
-
- intentsCopy = new ArrayList<Intent>(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())) {
- policiedBinding.getRequiredIntents().add(intent);
- break;
- }
- }
- }
- }
- }
-
- trimInherentlyProvidedIntents(policiedBinding.getType(),
- policiedBinding.getRequiredIntents());
- trimProvidedIntents(policiedBinding.getRequiredIntents(), policiedBinding
- .getPolicySets());
-
- // determine additional policysets that match remaining intents
- // TODO: resolved to domain policy registry and attach suitable
- // policy sets to the binding
- // for now using the SCA Definitions instead of registry
- // if there are intents that are not provided by any policy set
- // throw a warning
- determineApplicableDomainPolicySets(source, policiedBinding);
-
- //the intents list could have been trimmed when matching for policysets
- //since the bindings may need the original set of intents we copy that back
- policiedBinding.getRequiredIntents().clear();
- policiedBinding.getRequiredIntents().addAll(intentsCopy);
-
- }
- }
- }
-
- private static void determineApplicableDomainPolicySets(Contract contract,
- PolicySubject policiedBinding)
- throws PolicyConfigurationException {
- // FIXME:
- /*
- //if ( domainPolicySets != null) {
- determineApplicableDomainPolicySets(policiedBinding.getApplicablePolicySets(),
- policiedBinding,
- policiedBinding.getType());
-
- if ( policiedBinding.getRequiredIntents().size() > 0 ) {
- if ( contract instanceof Service ) {
- throw new PolicyConfigurationException("The following are unfulfilled intents for " +
- "binding in service - " + contract.getName() + "\nUnfulfilled Intents = " +
- policiedBinding.getRequiredIntents());
- } else {
- throw new PolicyConfigurationException("The are unfulfilled intents for " +
- "binding in reference - " + contract.getName() + "\nUnfulfilled Intents = " +
- policiedBinding.getRequiredIntents());
- }
- }
- //}
- */
- }
-
- private static void aggregateAndPruneApplicablePolicySets(List<PolicySet> source, List<PolicySet> target) {
- target.addAll(source);
- //strip duplicates
- Hashtable<QName, PolicySet> policySetTable = new Hashtable<QName, PolicySet>();
- for ( PolicySet policySet : target ) {
- policySetTable.put(policySet.getName(), policySet);
- }
-
- target.clear();
- target.addAll(policySetTable.values());
- }
-
- static <C extends Contract> void inheritDefaultPolicies(Base parent, List<C> contracts) {
-
- 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());
- }
-
- // 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());
- }
-
- }
- }
-
- static void computeImplementationIntentsAndPolicySets(Implementation implementation, Component parent)
- 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<Intent> prunedIntents = computeInheritableIntents(policiedImplementation.getType(),
- parent.getRequiredIntents());
- parent.getRequiredIntents().clear();
- parent.getRequiredIntents().addAll(prunedIntents);
- normalizeIntents(parent);
-
- List<PolicySet> prunedPolicySets = computeInheritablePolicySets(parent.getPolicySets());
- parent.getPolicySets().clear();
- parent.getPolicySets().addAll(prunedPolicySets);
- normalizePolicySets(parent);
-
- PolicyComputationUtils.checkForMutuallyExclusiveIntents(
- parent.getRequiredIntents(),
- parent.getPolicySets(),
- policiedImplementation.getType(),
- parent.getName());
-
- determineApplicableImplementationPolicySets(parent);
-
- }
- }
-
- private static void determineApplicableImplementationPolicySets(Component component) throws PolicyConfigurationException {
- List<Intent> intentsCopy = null;
- if ( component.getImplementation() instanceof PolicySubject ) {
- PolicySubject policiedImplementation = (PolicySubject)component.getImplementation();
-
- intentsCopy = new ArrayList<Intent>(component.getRequiredIntents());
- trimInherentlyProvidedIntents(policiedImplementation.getType(),
- component.getRequiredIntents());
- trimProvidedIntents(component.getRequiredIntents(), component.getPolicySets());
-
- //determine additional policysets that match remaining intents
- //if there are intents that are not provided by any policy set throw a warning
- //TODO: resolved to domain policy registry and attach suitable policy sets to the implementation
- //...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());
- }
- //}
-
- //the intents list could have been trimmed when matching for policysets
- //since the bindings may need the original set of intents we copy that back
- component.getRequiredIntents().clear();
- component.getRequiredIntents().addAll(intentsCopy);
- }
- }
-}
diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PrintUtil.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PrintUtil.java deleted file mode 100644 index 3762cc6e77..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PrintUtil.java +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.builder.impl; - -import java.beans.BeanInfo; -import java.beans.IntrospectionException; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.w3c.dom.Node; - -/** - * A simple print utility class to help print model instances. - * - * @version $Rev$ $Date$ - */ -class PrintUtil { - private boolean useGetters = false; - private PrintWriter out; - private int indent; - - public PrintUtil(PrintWriter out, boolean useGetters) { - this.out = out; - this.useGetters = useGetters; - } - - public PrintUtil(OutputStream out) { - this.out = new PrintWriter(new OutputStreamWriter(out), true); - } - - void indent() { - for (int i = 0; i < indent; i++) { - out.print(" "); - } - } - - /** - * Print an object. - * - * @param object - */ - public void print(Object object) { - Set<Integer> objects = new HashSet<Integer>(); - print(object, objects); - } - - /** - * Print an object. - * - * @param object - */ - private void print(Object object, Set<Integer> printed) { - if (object == null) { - return; - } - int id = System.identityHashCode(object); - if (printed.contains(id)) { - - // If we've already printed an object, print just it's HashCode - indent(); - out.println(object.getClass().getName() + "@" + id); - } else { - printed.add(id); - try { - - // Print the object class name - indent(); - out.println(object.getClass().getSimpleName() + " {"); - - // Get the object's properties - ValueAccessor accessor = useGetters ? new PropertyAccessor(object) : new FieldAccessor(object); - for (int i = 0; i < accessor.size(); i++) { - try { - - // Get the value of each property - Object value = accessor.getValue(i); - if (value != null) { - - // Convert array value into a list - if (value.getClass().isArray()) { - value = Arrays.asList((Object[])value); - } - - // Print elements in a list - if (value instanceof List) { - if (!((List<?>)value).isEmpty()) { - indent++; - indent(); - out.println(accessor.getName(i) + "= ["); - - // Print each element, recursively - for (Object element : (List<?>)value) { - indent++; - print(element, printed); - indent--; - } - indent(); - out.println(" ]"); - indent--; - } - } else { - Class<?> valueClass = value.getClass(); - - // Print a primitive, java built in type or - // enum, using toString() - if (valueClass.isPrimitive() || valueClass.getName().startsWith("java.") - || valueClass.getName().startsWith("javax.") - || valueClass.isEnum()) { - if (!accessor.getName(i).equals("class")) { - if (!(Boolean.FALSE.equals(value))) { - indent++; - indent(); - out.println(accessor.getName(i) + "=" + value.toString()); - indent--; - } - } - } else if (value instanceof Node) { - indent++; - indent(); - out.println(accessor.getName(i) + "=" + value.toString()); - indent--; - } else { - - // Print an object, recursively - indent++; - indent(); - out.println(accessor.getName(i) + "= {"); - indent++; - print(value, printed); - indent--; - indent(); - out.println("}"); - indent--; - } - } - } - } catch (Exception e) { - } - } - indent(); - out.println("}"); - } catch (Exception e) { - indent(); - out.println(e); - } - } - } - - public static interface ValueAccessor { - int size(); - - String getName(int i); - - Object getValue(int i) throws Exception; - } - - /** - * Java field reflection based value accessor - */ - private static class FieldAccessor implements ValueAccessor { - - private Object object; - private List<Field> fields; - - public FieldAccessor(Object object) { - this.fields = getAllFields(object.getClass()); - this.object = object; - } - - public String getName(int i) { - return fields.get(i).getName(); - } - - public Object getValue(int i) throws Exception { - return fields.get(i).get(object); - } - - public int size() { - return fields.size(); - } - - } - - /** - * JavaBean-based value accessor - */ - private static class PropertyAccessor implements ValueAccessor { - - private Object object; - private PropertyDescriptor[] fields; - - public PropertyAccessor(Object object) throws IntrospectionException { - BeanInfo beanInfo = Introspector.getBeanInfo(object.getClass()); - this.fields = beanInfo.getPropertyDescriptors(); - this.object = object; - } - - public String getName(int i) { - return fields[i].getName(); - } - - public Object getValue(int i) throws Exception { - Method getter = fields[i].getReadMethod(); - if (getter != null) { - return getter.invoke(object); - } - return null; - } - - public int size() { - return fields.length; - } - - } - - /** - * Returns a collection of fields declared by a class - * or one of its supertypes - */ - private static List<Field> getAllFields(Class<?> clazz) { - return getAllFields(clazz, new ArrayList<Field>()); - } - - /** - * Recursively evaluates the type hierarchy to return all fields - */ - private static List<Field> getAllFields(Class<?> clazz, List<Field> fields) { - if (clazz == null || clazz.isArray() || Object.class.equals(clazz)) { - return fields; - } - fields = getAllFields(clazz.getSuperclass(), fields); - Field[] declaredFields = clazz.getDeclaredFields(); - for (final Field field : declaredFields) { - AccessController.doPrivileged(new PrivilegedAction<Object>() { - public Object run() { - field.setAccessible(true); // ignore Java accessibility - return null; - } - }); - fields.add(field); - } - return fields; - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyConfigurationUtil.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyConfigurationUtil.java deleted file mode 100644 index 0105d4af50..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyConfigurationUtil.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.builder.impl; - -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URL; -import java.net.URLConnection; -import java.util.Arrays; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import javax.xml.XMLConstants; -import javax.xml.namespace.NamespaceContext; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.Source; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMResult; -import javax.xml.transform.sax.SAXSource; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpression; -import javax.xml.xpath.XPathExpressionException; - -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentProperty; -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.xml.sax.InputSource; - -/** - * Utility class to deal with processing of component properties that are taking values from the parent - * composite's properties or an external file. - * - * @version $Rev$ $Date$ - */ -abstract class PropertyConfigurationUtil { - - 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); - if (result == null) { - return null; - } - - // TODO: How to wrap the result into a Document? - Document document = documentBuilderFactory.newDocumentBuilder().newDocument(); - if (result instanceof Document) { - return (Document)result; - } else { - //Element root = document.createElementNS(null, "value"); - //document.appendChild(root); - document.appendChild(document.importNode(result, true)); - return document; - } - } - - 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(); - URLConnection connection = url.openConnection(); - connection.setUseCaches(false); - 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"); - root.appendChild(document.getDocumentElement()); - document.appendChild(root); - return document; - } finally { - if (is != null) { - is.close(); - } - } - } - - static void sourceComponentProperties(Map<String, Property> compositeProperties, - Component componentDefinition, - DocumentBuilderFactory documentBuilderFactory, - TransformerFactory transformerFactory) throws CompositeBuilderException, - ParserConfigurationException, - XPathExpressionException, - TransformerException, - IOException { - - List<ComponentProperty> componentProperties = componentDefinition.getProperties(); - for (ComponentProperty aProperty : componentProperties) { - String source = aProperty.getSource(); - String file = aProperty.getFile(); - if (source != null) { - // $<name>/... - int index = source.indexOf('/'); - if (index == -1) { - // Tolerating $prop - source = source + "/"; - index = source.length() - 1; - } - if (source.charAt(0) == '$') { - 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); - } - - Document compositePropDefValues = (Document)compositeProp.getValue(); - - // FIXME: How to deal with namespaces? - Document node = evaluate(compositePropDefValues, aProperty.getSourceXPathExpression(), documentBuilderFactory); - - if (node != null) { - aProperty.setValue(node); - } - } else { - throw new CompositeBuilderException("The 'source' has an invalid value: " + source); - } - } else if (file != null) { - aProperty.setValue(loadFromFile(aProperty.getFile(), transformerFactory)); - - } - } - } - - private static class DOMNamespaceContext implements NamespaceContext { - private Node node; - - /** - * @param node - */ - public DOMNamespaceContext(Node node) { - super(); - this.node = node; - } - - public String getNamespaceURI(String prefix) { - if (prefix == null) { - throw new IllegalArgumentException("Prefix is null"); - } else if (XMLConstants.XML_NS_PREFIX.equals(prefix)) { - return XMLConstants.XML_NS_URI; - } else if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) { - return XMLConstants.XMLNS_ATTRIBUTE_NS_URI; - } - String ns = node.lookupNamespaceURI(prefix); - return ns == null ? XMLConstants.NULL_NS_URI : ns; - } - - public String getPrefix(String namespaceURI) { - if (namespaceURI == null) { - throw new IllegalArgumentException("Namespace URI is null"); - } else if (XMLConstants.XML_NS_URI.equals(namespaceURI)) { - return XMLConstants.XML_NS_PREFIX; - } else if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI)) { - return XMLConstants.XMLNS_ATTRIBUTE; - } - return node.lookupPrefix(namespaceURI); - } - - public Iterator<?> getPrefixes(String namespaceURI) { - // Not implemented - if (namespaceURI == null) { - throw new IllegalArgumentException("Namespace URI is null"); - } else if (XMLConstants.XML_NS_URI.equals(namespaceURI)) { - return Arrays.asList(XMLConstants.XML_NS_PREFIX).iterator(); - } else if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI)) { - return Arrays.asList(XMLConstants.XMLNS_ATTRIBUTE).iterator(); - } - String prefix = getPrefix(namespaceURI); - if (prefix == null) { - return Collections.emptyList().iterator(); - } - return Arrays.asList(prefix).iterator(); - } - - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java deleted file mode 100644 index 9f810a2c60..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.builder.impl; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.CompositeReference; -import org.apache.tuscany.sca.assembly.EndpointReference; -import org.apache.tuscany.sca.assembly.Multiplicity; -import org.apache.tuscany.sca.assembly.OptimizableBinding; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.monitor.Problem.Severity; - -/** - * This class encapsulates utility methods to deal with reference definitions - * - * @version $Rev$ $Date$ - */ -abstract class ReferenceConfigurationUtil { - - /** - * Report a warning. - * - * @param problems - * @param message - * @param model - */ - private static void warning(Monitor monitor, String message, Object model, String... messageParameters) { - if (monitor != null) { - Problem problem = monitor.createProblem(ReferenceConfigurationUtil.class.getName(), "assembly-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters); - monitor.problem(problem); - } - } - - static boolean isValidMultiplicityOverride(Multiplicity definedMul, Multiplicity overridenMul) { - if (definedMul != overridenMul) { - switch (definedMul) { - case ZERO_N: - return overridenMul == Multiplicity.ZERO_ONE; - case ONE_N: - return overridenMul == Multiplicity.ONE_ONE; - default: - return false; - } - } else { - return true; - } - } - - static boolean validateMultiplicityAndTargets(Multiplicity multiplicity, - List<?> targets, List<Binding> 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; - case ZERO_ONE: - if (count > 1) { - return false; - } - break; - case ONE_ONE: - if (count != 1) { - if (count == 0) { - for (Binding binding: bindings) { - if (!(binding instanceof OptimizableBinding) || binding.getURI()!=null) { - return true; - } - } - } - return false; - } - break; - case ONE_N: - if (count < 1) { - if (count == 0) { - for (Binding binding: bindings) { - if (!(binding instanceof OptimizableBinding) || binding.getURI()!=null) { - return true; - } - } - } - return false; - } - break; - } - return true; - } - - /** - * Follow a reference promotion chain down to the innermost (non composite) - * component references. - * - * @param compositeReference - * @return - */ - static List<ComponentReference> getPromotedComponentReferences(CompositeReference compositeReference) { - List<ComponentReference> componentReferences = new ArrayList<ComponentReference>(); - collectPromotedComponentReferences(compositeReference, componentReferences); - return componentReferences; - } - - /** - * Follow a reference promotion chain down to the innermost (non composite) - * component references. - * - * @param compositeReference - * @param componentReferences - * @return - */ - private static void collectPromotedComponentReferences(CompositeReference compositeReference, - List<ComponentReference> componentReferences) { - for (ComponentReference componentReference : compositeReference.getPromotedReferences()) { - Reference reference = componentReference.getReference(); - if (reference instanceof CompositeReference) { - - // Continue to follow the reference promotion chain - collectPromotedComponentReferences((CompositeReference)reference, componentReferences); - - } else if (reference != null) { - - // Found a non-composite reference - componentReferences.add(componentReference); - } - } - } - - /** - * Override the bindings for a promoted reference from an outer component reference - * - * @param reference - the outer level reference - * @param promotedReference - the inner level promoted reference - */ - static void reconcileReferenceBindings(Reference reference, - 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() > 1) { - 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); - } // end for - } // end if - - Set<Binding> callbackBindings = new HashSet<Binding>(); - if (promotedReference.getCallback() != null) { - callbackBindings.addAll(promotedReference.getCallback().getBindings()); - } - if (reference.getCallback() != null) { - callbackBindings.addAll(reference.getCallback().getBindings()); - } - promotedReference.setCallback(assemblyFactory.createCallback()); - for (Binding binding : callbackBindings) { - if ((!(binding instanceof OptimizableBinding)) || binding.getURI() != null) { - promotedReference.getCallback().getBindings().add(binding); - } // 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; - } // end copyHigherReference - -} // end class diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ServiceConfigurationUtil.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ServiceConfigurationUtil.java deleted file mode 100644 index 41a8b3f8ba..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ServiceConfigurationUtil.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.builder.impl; - -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.CompositeService; -import org.apache.tuscany.sca.assembly.Service; - -/** - * This class encapsulates utility methods to deal with service definitions. - * - * @version $Rev$ $Date$ - */ -abstract class ServiceConfigurationUtil { - - /** - * Follow a service promotion chain down to the inner most (non composite) - * component service. - * - * @param topCompositeService - * @return - */ - static ComponentService getPromotedComponentService(CompositeService compositeService) { - ComponentService componentService = compositeService.getPromotedService(); - if (componentService != null) { - Service service = componentService.getService(); - if (componentService.getName() != null && service instanceof CompositeService) { - - // Continue to follow the service promotion chain - return getPromotedComponentService((CompositeService)service); - - } else { - - // Found a non-composite service - return componentService; - } - } else { - - // No promoted service - return null; - } - } - - /** - * Follow a service promotion chain down to the innermost (non-composite) component. - * - * @param compositeService - * @return - */ - static Component getPromotedComponent(CompositeService compositeService) { - ComponentService componentService = compositeService.getPromotedService(); - if (componentService != null) { - Service service = componentService.getService(); - if (componentService.getName() != null && service instanceof CompositeService) { - - // Continue to follow the service promotion chain - return getPromotedComponent((CompositeService)service); - - } else { - - // Found a non-composite service - return compositeService.getPromotedComponent(); - } - } else { - - // No promoted service - return null; - } - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java deleted file mode 100644 index db4bcb0060..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.impl; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.AbstractProperty; - -/** - * Represents an abstract property. - * - * @version $Rev$ $Date$ - */ -public class AbstractPropertyImpl extends ExtensibleImpl implements AbstractProperty { - private Object value; - private String name; - private QName xsdType; - private QName xsdElement; - private boolean many; - private boolean mustSupply; - - /** - * Constructs a new abstract property. - */ - protected AbstractPropertyImpl() { - } - - public Object getValue() { - return value; - } - - public String getName() { - return name; - } - - public QName getXSDElement() { - return xsdElement; - } - - public QName getXSDType() { - return xsdType; - } - - public boolean isMany() { - return many; - } - - public boolean isMustSupply() { - return mustSupply; - } - - public void setValue(Object defaultValue) { - this.value = defaultValue; - } - - public void setMany(boolean many) { - this.many = many; - } - - public void setMustSupply(boolean mustSupply) { - this.mustSupply = mustSupply; - } - - public void setName(String name) { - this.name = name; - } - - public void setXSDElement(QName element) { - this.xsdElement = element; - } - - public void setXSDType(QName type) { - this.xsdType = type; - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java deleted file mode 100644 index d0ee3832c5..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.impl; - -import org.apache.tuscany.sca.assembly.AbstractReference; -import org.apache.tuscany.sca.assembly.Multiplicity; - -/** - * Represents an abstract reference - * - * @version $Rev$ $Date$ - */ -public class AbstractReferenceImpl extends ContractImpl implements AbstractReference { - private Multiplicity multiplicity = Multiplicity.ONE_ONE; - - /** - * Constructs a new abstract reference. - */ - protected AbstractReferenceImpl() { - } - - public Multiplicity getMultiplicity() { - return multiplicity; - } - - public void setMultiplicity(Multiplicity multiplicity) { - this.multiplicity = multiplicity; - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java deleted file mode 100644 index 346764b1b4..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.impl; - -import org.apache.tuscany.sca.assembly.AbstractService; - -/** - * Represents an abstract service - * - * @version $Rev$ $Date$ - */ -public class AbstractServiceImpl extends ContractImpl implements AbstractService { - - /** - * Constructs a new abstract service. - */ - protected AbstractServiceImpl() { - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java deleted file mode 100644 index ab43fc5b5d..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.impl; - -import org.apache.tuscany.sca.assembly.AbstractProperty; -import org.apache.tuscany.sca.assembly.AbstractReference; -import org.apache.tuscany.sca.assembly.AbstractService; -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Callback; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentProperty; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.ComponentType; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.CompositeReference; -import org.apache.tuscany.sca.assembly.CompositeService; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; -import org.apache.tuscany.sca.assembly.Extension; -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.assembly.Wire; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; - -/** - * A factory for the assembly model. - * - * @version $Rev$ $Date$ - */ -public abstract class AssemblyFactoryImpl implements AssemblyFactory { - - protected ExtensionPointRegistry registry; - protected AssemblyFactoryImpl(ExtensionPointRegistry registry) { - super(); - this.registry = registry; - } - - public AbstractProperty createAbstractProperty() { - return new AbstractPropertyImpl(); - } - - public AbstractReference createAbstractReference() { - return new AbstractReferenceImpl(); - } - - public AbstractService createAbstractService() { - return new AbstractServiceImpl(); - } - - public Callback createCallback() { - return new CallbackImpl(); - } - - public Component createComponent() { - return new ComponentImpl(); - } - - public ComponentProperty createComponentProperty() { - return new ComponentPropertyImpl(); - } - - public ComponentReference createComponentReference() { - return new ComponentReferenceImpl(); - } - - public ComponentService createComponentService() { - return new ComponentServiceImpl(); - } - - public ComponentType createComponentType() { - return new ComponentTypeImpl(); - } - - public Composite createComposite() { - return new CompositeImpl(); - } - - public CompositeReference createCompositeReference() { - return new CompositeReferenceImpl(); - } - - public CompositeService createCompositeService() { - return new CompositeServiceImpl(); - } - - public ConstrainingType createConstrainingType() { - return new ConstrainingTypeImpl(); - } - - public Property createProperty() { - return new PropertyImpl(); - } - - public Reference createReference() { - return new ReferenceImpl(); - } - - public Service createService() { - return new ServiceImpl(); - } - - public Wire createWire() { - return new WireImpl(); - } - - public Extension createExtension() { - return new ExtensionImpl(); - } - - public Endpoint createEndpoint() { - return new EndpointImpl(registry); - } - - public EndpointReference createEndpointReference() { - return new EndpointReferenceImpl(registry); - } -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java deleted file mode 100644 index 553e600bc9..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.impl; - -import org.apache.tuscany.sca.assembly.Base; - -/** - * Convenience base class for assembly model objects. - * - * @version $Rev$ $Date$ - */ -public abstract class BaseImpl implements Base { - private boolean unresolved; - - /** - * Constructs a new base model object. - */ - protected BaseImpl() { - } - - public boolean isUnresolved() { - return unresolved; - } - - public void setUnresolved(boolean undefined) { - this.unresolved = undefined; - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java deleted file mode 100644 index 1e69dfcc87..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.policy.ExtensionType; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; - -/** - * - */ -public abstract class BindingImpl extends ExtensibleImpl implements Binding { - private String name; - private ExtensionType type; - private String uri; - private List<Intent> requiredIntents = new ArrayList<Intent>(); - private List<PolicySet> policySets = new ArrayList<PolicySet>(); - - public List<Intent> getRequiredIntents() { - return requiredIntents; - } - - public List<PolicySet> getPolicySets() { - return policySets; - } - - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public ExtensionType getType() { - return type; - } - - public void setType(ExtensionType type) { - this.type = type; - } - - public String getURI() { - return uri; - } - - public void setURI(String uri) { - this.uri = uri; - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java deleted file mode 100644 index f8f856f1b4..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Callback; -import org.apache.tuscany.sca.policy.ExtensionType; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; - -/** - * Represents a reference. - * - * @version $Rev$ $Date$ - */ -public class CallbackImpl extends ExtensibleImpl implements Callback { - private List<Binding> bindings = new ArrayList<Binding>(); - private List<Intent> requiredIntents = new ArrayList<Intent>(); - private List<PolicySet> policySets = new ArrayList<PolicySet>(); - - public List<PolicySet> getPolicySets() { - return policySets; - } - - public List<Intent> getRequiredIntents() { - return requiredIntents; - } - - protected CallbackImpl() { - } - - public List<Binding> getBindings() { - return bindings; - } - - public ExtensionType getType() { - return null; - } - - public void setType(ExtensionType type) { - } - - public void setRequiredIntents(List<Intent> intents) { - this.requiredIntents = intents; - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java deleted file mode 100644 index d751d59f83..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentProperty; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.policy.ExtensionType; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; - -/** - * Represents a component. - * - * @version $Rev$ $Date$ - */ -public class ComponentImpl extends ExtensibleImpl implements Component, Cloneable { - private ConstrainingType constrainingType; - private Implementation implementation; - private String name; - private String uri; - private List<ComponentProperty> properties = new ArrayList<ComponentProperty>(); - private List<ComponentReference> references = new ArrayList<ComponentReference>(); - private List<ComponentService> services = new ArrayList<ComponentService>(); - private List<Intent> requiredIntents = new ArrayList<Intent>(); - private List<PolicySet> policySets = new ArrayList<PolicySet>(); - private Boolean autowire; - private ExtensionType type; - /** - * Constructs a new component. - */ - protected ComponentImpl() { - } - - @Override - public Object clone() throws CloneNotSupportedException { - ComponentImpl clone = (ComponentImpl)super.clone(); - - clone.properties = new ArrayList<ComponentProperty>(); - for (ComponentProperty property : getProperties()) { - clone.properties.add((ComponentProperty)property.clone()); - } - clone.references = new ArrayList<ComponentReference>(); - for (ComponentReference reference : getReferences()) { - clone.references.add((ComponentReference)reference.clone()); - } - clone.services = new ArrayList<ComponentService>(); - for (ComponentService service : getServices()) { - clone.services.add((ComponentService)service.clone()); - } - return clone; - } - - public String getURI() { - return uri; - } - - public void setURI(String uri) { - this.uri = uri; - } - - public ConstrainingType getConstrainingType() { - return constrainingType; - } - - public Implementation getImplementation() { - return implementation; - } - - public String getName() { - return name; - } - - public List<ComponentProperty> getProperties() { - return properties; - } - - public List<ComponentReference> getReferences() { - return references; - } - - public List<ComponentService> getServices() { - return services; - } - - public void setConstrainingType(ConstrainingType constrainingType) { - this.constrainingType = constrainingType; - } - - public void setImplementation(Implementation implementation) { - this.implementation = implementation; - } - - public void setName(String name) { - this.name = name; - } - - public List<Intent> getRequiredIntents() { - return requiredIntents; - } - - public List<PolicySet> getPolicySets() { - return policySets; - } - - public boolean isAutowire() { - return (autowire == null) ? false : autowire.booleanValue(); - } - - public void setAutowire(Boolean autowire) { - this.autowire = autowire; - } - - public Boolean getAutowire() { - return autowire; - } - - public ExtensionType getType() { - return type; - } - - public void setType(ExtensionType type) { - this.type = type; - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java deleted file mode 100644 index e2e7b59896..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.impl; - -import javax.xml.xpath.XPathExpression; - -import org.apache.tuscany.sca.assembly.ComponentProperty; -import org.apache.tuscany.sca.assembly.Property; - -/** - * Represents a component property. - * - * @version $Rev$ $Date$ - */ -public class ComponentPropertyImpl extends PropertyImpl implements ComponentProperty, Cloneable { - private String file; - 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() - @Override - public Object getValue() { - if (super.getValue() == null && property != null) { - return property.getValue(); - } else { - return super.getValue(); - } - } - - public String getFile() { - return file; - } - - public Property getProperty() { - return property; - } - - public String getSource() { - return source; - } - - public void setFile(String file) { - this.file = file; - } - - public void setProperty(Property property) { - this.property = property; - } - - public void setSource(String source) { - this.source = source; - } - - public XPathExpression getSourceXPathExpression() { - return sourceXPathExpression; - } - - public void setSourceXPathExpression(XPathExpression sourceXPathExpression) { - this.sourceXPathExpression = sourceXPathExpression; - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java deleted file mode 100644 index bb5b163762..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.CompositeReference; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; - -/** - * Represents a component reference - * - * @version $Rev$ $Date$ - */ -public class ComponentReferenceImpl extends ReferenceImpl implements ComponentReference, Cloneable { - private Reference reference; - private Boolean autowire; - private boolean nonOverridable; - private List<CompositeReference> promotedAs = new ArrayList<CompositeReference>(); - private ComponentService callbackService; - private boolean isPromoted = false; - - /** - * Constructs a new component reference. - */ - protected ComponentReferenceImpl() { - // Set multiplicity to null so that by default it'll inherit from the Reference - setMultiplicity(null); - } - - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - public Reference getReference() { - return reference; - } - - public void setReference(Reference reference) { - this.reference = reference; - } - - public boolean isAutowire() { - return (autowire == null) ? false : autowire.booleanValue(); - } - - public void setAutowire(Boolean autowire) { - this.autowire = autowire; - } - - public Boolean getAutowire() { - return autowire; - } - - public List<CompositeReference> promotedAs() { - return promotedAs; - } - - public ComponentService getCallbackService() { - return callbackService; - } - - 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){ - InterfaceContract interfaceContract = null; - - if (interfaceContract == null){ - interfaceContract = getInterfaceContract(); - } - return interfaceContract; - } - - public boolean isNonOverridable() { - return nonOverridable; - } - - public void setNonOverridable(boolean nonOverridable) { - this.nonOverridable = nonOverridable; - } - - public void setPromoted( boolean isPromoted ) { - this.isPromoted = isPromoted; - } // end method setPromoted - - public boolean isPromoted() { - return isPromoted; - } -} // end class ComponentReferenceImpl diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java deleted file mode 100644 index 0c78a2505f..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.CompositeService; -import org.apache.tuscany.sca.assembly.Service; - -/** - * Represents a component service - * - * @version $Rev$ $Date$ - */ -public class ComponentServiceImpl extends ServiceImpl implements ComponentService, Cloneable { - private Service service; - private List<CompositeService> promotedAs = new ArrayList<CompositeService>(); - private ComponentReference callbackReference; - - /** - * Constructs a new component service. - */ - protected ComponentServiceImpl() { - } - - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - public Service getService() { - return service; - } - - public void setService(Service service) { - this.service = service; - } - - public List<CompositeService> promotedAs() { - return promotedAs; - } - - public ComponentReference getCallbackReference() { - return callbackReference; - } - - public void setCallbackReference(ComponentReference callbackReference) { - this.callbackReference = callbackReference; - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java deleted file mode 100644 index c79aaf6b2e..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.assembly.ComponentType; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.policy.ExtensionType; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; - -/** - * Represents a component type. - * - * @version $Rev$ $Date$ - */ -public class ComponentTypeImpl extends ExtensibleImpl implements ComponentType, Cloneable { - private String uri; - private ConstrainingType constrainingType; - private List<Property> properties = new ArrayList<Property>(); - private List<Reference> references = new ArrayList<Reference>(); - private List<Service> services = new ArrayList<Service>(); - private List<Intent> requiredIntents = new ArrayList<Intent>(); - private List<PolicySet> policySets = new ArrayList<PolicySet>(); - /** - * Constructs a new component type. - */ - protected ComponentTypeImpl() { - } - - @Override - public Object clone() throws CloneNotSupportedException { - ComponentTypeImpl clone = (ComponentTypeImpl)super.clone(); - - clone.services = new ArrayList<Service>(); - for (Service service : getServices()) { - clone.services.add((Service)service.clone()); - } - clone.references = new ArrayList<Reference>(); - for (Reference reference : getReferences()) { - clone.references.add((Reference)reference.clone()); - } - clone.properties = new ArrayList<Property>(); - for (Property property : getProperties()) { - clone.properties.add((Property)property.clone()); - } - return clone; - } - - public String getURI() { - return uri; - } - - public void setURI(String uri) { - this.uri = uri; - } - - public ConstrainingType getConstrainingType() { - return constrainingType; - } - - public List<Property> getProperties() { - return properties; - } - - public List<Reference> getReferences() { - return references; - } - - public List<Service> getServices() { - return services; - } - - public void setConstrainingType(ConstrainingType constrainingType) { - this.constrainingType = constrainingType; - } - - @Override - public int hashCode() { - return String.valueOf(getURI()).hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else { - if (obj instanceof ComponentType) { - if (getURI() != null) { - return getURI().equals(((ComponentType)obj).getURI()); - } else { - return ((ComponentType)obj).getURI() == null; - } - } else { - return false; - } - } - } - - public List<Intent> getRequiredIntents() { - return requiredIntents; - } - - public List<PolicySet> getPolicySets() { - return policySets; - } - - public ExtensionType getType() { - return null; - } - - public void setType(ExtensionType type) { - } -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java deleted file mode 100644 index 4e14cf0e53..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.impl; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.CompositeReference; -import org.apache.tuscany.sca.assembly.CompositeService; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.assembly.Wire; - -/** - * Implementation of a Composite. - * - * @version $Rev$ $Date$ - */ -public class CompositeImpl extends ImplementationImpl implements Composite, Cloneable { - private String specVersion = "undefined"; - private List<Component> components = new ArrayList<Component>(); - private List<Composite> includes = new ArrayList<Composite>(); - private QName name; - private List<Wire> wires = new ArrayList<Wire>(); - private Boolean autowire; - private boolean local = true; - - /** - * Constructs a new composite. - */ - protected CompositeImpl() { - } - - @Override - public Object clone() throws CloneNotSupportedException { - CompositeImpl clone = (CompositeImpl)super.clone(); - - clone.components = new ArrayList<Component>(); - for (Component component : getComponents()) { - Component clonedComponent = (Component)component.clone(); - for (Service service : clone.getServices()) { - CompositeService compositeService = (CompositeService)service; - // Force the promoted component/service to be rebuilt against the clone - if (compositeService.getPromotedComponent() != null) { - compositeService.getPromotedComponent().setUnresolved(true); - } - if (compositeService.getPromotedService() != null) { - compositeService.getPromotedService().setUnresolved(true); - } - } - for (Reference reference : clone.getReferences()) { - CompositeReference compositeReference = (CompositeReference)reference; - for (ComponentReference ref : compositeReference.getPromotedReferences()) { - // Force the promoted reference to be rebuilt against the clone - ref.setUnresolved(true); - } - } - - clone.components.add(clonedComponent); - } - clone.wires = new ArrayList<Wire>(); - for (Wire wire : getWires()) { - clone.wires.add((Wire)wire.clone()); - } - return clone; - } - - public String getSpecVersion() { - return specVersion; - } - - public void setSpecVersion(String specVersion) { - this.specVersion = specVersion; - } - - public List<Component> getComponents() { - return components; - } - - public List<Composite> getIncludes() { - return includes; - } - - public QName getName() { - return name; - } - - public List<Wire> getWires() { - return wires; - } - - public boolean isLocal() { - return local; - } - - public void setLocal(boolean local) { - this.local = local; - } - - public boolean isAutowire() { - return (autowire == null) ? false : autowire.booleanValue(); - } - - public void setAutowire(Boolean autowire) { - this.autowire = autowire; - } - - public Boolean getAutowire() { - return autowire; - } - - public void setName(QName name) { - this.name = name; - } - - @Override - public int hashCode() { - return String.valueOf(getName()).hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else if (obj instanceof Composite) { - if (getName() != null) { - return getName().equals(((Composite)obj).getName()); - } else { - return ((Composite)obj).getName() == null; - } - } else { - return false; - } - } - - @Override - public String toString(){ - return ( this.name != null ) ? getName().toString() : "null"; - } -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java deleted file mode 100644 index 97b0db3bcc..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.CompositeReference; - -/** - * Represents a composite reference. - * - * @version $Rev$ $Date$ - */ -public class CompositeReferenceImpl extends ReferenceImpl implements CompositeReference, Cloneable { - private List<Component> promotedComponents = new ArrayList<Component>(); - private List<ComponentReference> promotedReferences = new ArrayList<ComponentReference>(); - - /** - * Constructs a new composite reference. - */ - protected CompositeReferenceImpl() { - } - - @Override - public Object clone() throws CloneNotSupportedException { - CompositeReferenceImpl copy = (CompositeReferenceImpl)super.clone(); - copy.promotedComponents = new ArrayList<Component>(promotedComponents); - copy.promotedReferences = new ArrayList<ComponentReference>(promotedReferences); - return copy; - } - - public List<ComponentReference> getPromotedReferences() { - return promotedReferences; - } - - public List<Component> getPromotedComponents() { - return promotedComponents; - } - - public String toString() { - return getName(); - } -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java deleted file mode 100644 index 6777a96982..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.impl; - -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.CompositeService; - -/** - * Represents a composite service - * - * @version $Rev$ $Date$ - */ -public class CompositeServiceImpl extends ServiceImpl implements CompositeService, Cloneable { - private ComponentService promotedService; - private Component promotedComponent; - - /** - * Constructs a new composite service. - */ - protected CompositeServiceImpl() { - } - - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - public ComponentService getPromotedService() { - return promotedService; - } - - public void setPromotedService(ComponentService promotedService) { - this.promotedService = promotedService; - } - - public Component getPromotedComponent() { - return promotedComponent; - } - - public void setPromotedComponent(Component promotedComponent) { - this.promotedComponent = promotedComponent; - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.java deleted file mode 100644 index 641e0f17df..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.impl; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.AbstractProperty; -import org.apache.tuscany.sca.assembly.AbstractReference; -import org.apache.tuscany.sca.assembly.AbstractService; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.policy.ExtensionType; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; - -/** - * Represents a constraining type. - * - * @version $Rev$ $Date$ - */ -public class ConstrainingTypeImpl extends ExtensibleImpl implements ConstrainingType { - private QName name; - private List<AbstractProperty> properties = new ArrayList<AbstractProperty>(); - private List<AbstractReference> references = new ArrayList<AbstractReference>(); - private List<AbstractService> services = new ArrayList<AbstractService>(); - private List<Intent> requiredIntents = new ArrayList<Intent>(); - private List<PolicySet> policySets = new ArrayList<PolicySet>(); - - /** - * Constructs a new ConstrainingType - */ - protected ConstrainingTypeImpl() { - } - - public QName getName() { - return name; - } - - public void setName(QName name) { - this.name = name; - } - - public List<AbstractProperty> getProperties() { - return properties; - } - - public List<AbstractReference> getReferences() { - return references; - } - - public List<AbstractService> getServices() { - return services; - } - - public List<Intent> getRequiredIntents() { - return requiredIntents; - } - - public List<PolicySet> getPolicySets() { - return policySets; - } - - @Override - public int hashCode() { - return String.valueOf(getName()).hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else if (obj instanceof ConstrainingType) { - if (getName() != null) { - return getName().equals(((ConstrainingType)obj).getName()); - } else { - return ((ConstrainingType)obj).getName() == null; - } - } else { - return false; - } - } - - public ExtensionType getType() { - return null; - } - - public void setType(ExtensionType type) { - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java deleted file mode 100644 index a121635323..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.assembly.AbstractContract; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.policy.ExtensionType; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; - -/** - * Implementation of a Contract. - * - * @version $Rev$ $Date$ - */ -public class ContractImpl extends ExtensibleImpl implements AbstractContract { - private InterfaceContract interfaceContract; - private String name; - private List<Intent> requiredIntents = new ArrayList<Intent>(); - private List<PolicySet> policySets = new ArrayList<PolicySet>(); - - private boolean isCallback = false; - - /** - * Constructs a new contract. - */ - protected ContractImpl() { - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public InterfaceContract getInterfaceContract() { - return interfaceContract; - } - - public void setInterfaceContract(InterfaceContract interfaceContract) { - this.interfaceContract = interfaceContract; - } - - public List<Intent> getRequiredIntents() { - return requiredIntents; - } - - public boolean isCallback() { - return isCallback; - } - - public void setIsCallback(boolean isCallback) { - this.isCallback = isCallback; - } - - public ExtensionType getType() { - return null; - } - - public void setType(ExtensionType type) { - } - - public List<PolicySet> getPolicySets() { - return policySets; - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/DistributedSCABindingImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/DistributedSCABindingImpl.java deleted file mode 100644 index 898aec0c42..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/DistributedSCABindingImpl.java +++ /dev/null @@ -1,70 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.assembly.impl;
-
-import org.apache.tuscany.sca.assembly.SCABinding;
-import org.apache.tuscany.sca.assembly.DistributedSCABinding;
-
-/**
- * The Distributed SCA binding wrapper for the SCA binding model object. This is currently
- * just used to locate the remote binding extension and pass the SCA binding to the remote
- * extension. It isn't used in the model itself
- *
- * @version $Rev: 564307 $ $Date: 2007-08-09 18:48:29 +0100 (Thu, 09 Aug 2007) $
- */
-public class DistributedSCABindingImpl implements DistributedSCABinding {
-
- private SCABinding scaBinding;
-
- public SCABinding getSCABinding(){
- return scaBinding;
- }
-
- public void setSCABinding(SCABinding scaBinding){
- this.scaBinding = scaBinding;
- }
-
- public String getURI(){
- return null;
- }
-
- public void setURI(String uri){
- }
-
- public String getName(){
- return null;
- }
-
- public void setName(String name){
-
- }
-
- public boolean isUnresolved(){
- return false;
- }
-
- public void setUnresolved(boolean unresolved){
-
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
-}
diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java deleted file mode 100644 index 1974113d1c..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.policy.ExtensionType; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySubject; - -/** - * The assembly model object for an endpoint. - * - * @version $Rev$ $Date$ - */ -public class EndpointImpl implements Endpoint { - private static final long serialVersionUID = 7344399683703812593L; - - protected ExtensionPointRegistry registry; - protected boolean unresolved; - protected String uri; - protected Component component; - protected ComponentService service; - protected Binding binding; - protected InterfaceContract interfaceContract; - protected List<EndpointReference> callbackEndpointReferences = new ArrayList<EndpointReference>(); - protected List<PolicySet> policySets = new ArrayList<PolicySet>(); - protected List<Intent> requiredIntents = new ArrayList<Intent>(); - - protected EndpointImpl(ExtensionPointRegistry registry) { - this.registry = registry; - } - - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - public boolean isUnresolved() { - return unresolved; - } - - public void setUnresolved(boolean unresolved) { - this.unresolved = unresolved; - } - - public Component getComponent() { - resolve(); - return component; - } - - public void setComponent(Component component) { - this.component = component; - reset(); - } - - public ComponentService getService() { - resolve(); - return service; - } - - public void setService(ComponentService service) { - this.service = service; - reset(); - } - - public Binding getBinding() { - resolve(); - return binding; - } - - public void setBinding(Binding binding) { - this.binding = binding; - reset(); - } - - public InterfaceContract getInterfaceContract() { - resolve(); - return interfaceContract; - } - - public void setInterfaceContract(InterfaceContract interfaceContract) { - this.interfaceContract = interfaceContract; - } - - /** - * Get the services callbacl enpoint references that - * represent endpoint references from which callbacks - * originate - * - * @return callbackEndpoint the reference callback endpoint - */ - public List<EndpointReference> getCallbackEndpointReferences(){ - resolve(); - return callbackEndpointReferences; - } - - public List<PolicySet> getPolicySets() { - resolve(); - return policySets; - } - - public List<Intent> getRequiredIntents() { - resolve(); - return requiredIntents; - } - - public ExtensionType getType() { - if (binding instanceof PolicySubject) { - return ((PolicySubject)binding).getType(); - } - return null; - } - - public void setType(ExtensionType type) { - throw new UnsupportedOperationException(); - } - - public String toString(){ - String output = "Endpoint: "; - - if (getURI() != null){ - output += " URI = " + uri; - } - - if (unresolved) { - output += " [Unresolved]"; - } - - return output; - } - - public String getURI() { - if (uri == null) { - if (component != null && service != null && binding != null) { - String bindingName = binding.getName(); - if (bindingName == null) { - bindingName = service.getName(); - } - uri = component.getURI() + "#service-binding(" + service.getName() + "/" + bindingName + ")"; - } else if (component != null && service != null) { - uri = component.getURI() + "#service(" + service.getName() + ")"; - } else if (component != null) { - uri = component.getURI(); - } - } - return uri; - } - - public void setURI(String uri) { - this.uri = uri; - } - - protected void resolve() { - } - - protected void reset() { - this.uri = null; - } - - public void setExtensionPointRegistry(ExtensionPointRegistry registry) { - this.registry = registry; - } -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java deleted file mode 100644 index aad851eb3b..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.policy.ExtensionType; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySubject; - -/** - * The assembly model object for an endpoint. - * - * @version $Rev$ $Date$ - */ -public class EndpointReferenceImpl implements EndpointReference { - private static final long serialVersionUID = 8838066441709300972L; - protected ExtensionPointRegistry registry; - protected boolean unresolved = true; - protected String uri; - protected Component component; - protected ComponentReference reference; - protected Binding binding; - protected List<PolicySet> policySets = new ArrayList<PolicySet>(); - protected List<Intent> requiredIntents = new ArrayList<Intent>(); - protected InterfaceContract interfaceContract; - protected boolean isRemoteReference = false; - - // the target of the endpoint reference - protected Endpoint targetEndpoint; - - // callback endpoint that messages across this reference - // will be directed toward - protected Endpoint callbackEndpoint; - - protected EndpointReferenceImpl(ExtensionPointRegistry registry){ - this.registry = registry; - } - - @Override - public Object clone() throws CloneNotSupportedException { - EndpointReference cloned = (EndpointReference)super.clone(); - - if (targetEndpoint != null){ - cloned.setTargetEndpoint((Endpoint)targetEndpoint.clone()); - } - - return cloned; - } - - public boolean isUnresolved() { - return unresolved; - } - - public void setUnresolved(boolean unresolved) { - this.unresolved = unresolved; - } - - public Component getComponent() { - resolve(); - return component; - } - - public void setComponent(Component component) { - this.component = component; - reset(); - } - - public ComponentReference getReference() { - resolve(); - return reference; - } - - public void setReference(ComponentReference reference) { - this.reference = reference; - reset(); - } - - public Binding getBinding() { - resolve(); - return binding; - } - - public void setBinding(Binding binding) { - this.binding = binding; - reset(); - } - - public Endpoint getTargetEndpoint() { - resolve(); - return targetEndpoint; - } - - public void setTargetEndpoint(Endpoint targetEndpoint) { - this.targetEndpoint = targetEndpoint; - reset(); - } - - public InterfaceContract getInterfaceContract() { - resolve(); - return interfaceContract; - } - - public void setInterfaceContract(InterfaceContract interfaceContract) { - this.interfaceContract = interfaceContract; - reset(); - } - - public List<PolicySet> getPolicySets() { - resolve(); - return policySets; - } - - public List<Intent> getRequiredIntents() { - resolve(); - return requiredIntents; - } - - public ExtensionType getType() { - if (binding instanceof PolicySubject) { - return ((PolicySubject)binding).getType(); - } - return null; - } - - public void setType(ExtensionType type) { - throw new UnsupportedOperationException(); - } - - public Endpoint getCallbackEndpoint() { - resolve(); - return callbackEndpoint; - } - - public void setCallbackEndpoint(Endpoint callbackEndpoint) { - this.callbackEndpoint = callbackEndpoint; - reset(); - } - - public String toString() { - String output = "Endpoint Reference: "; - - if (getURI() != null) { - output += " URI = " + uri; - } - - if (unresolved) { - output += " [Unresolved]"; - } - - if (targetEndpoint != null) { - output += " Target = " + targetEndpoint.toString(); - } - - return output; - } - - public String getURI() { - if (uri == null) { - if (component != null && reference != null && binding != null) { - String bindingName = binding.getName(); - if (bindingName == null) { - bindingName = reference.getName(); - } - uri = component.getURI() + "#reference-binding(" + reference.getName() + "/" + bindingName + ")"; - } else if (component != null && reference != null) { - uri = component.getURI() + "#reference(" + reference.getName() + ")"; - } else if (component != null) { - uri = component.getURI(); - } - } - return uri; - } - - public void setURI(String uri) { - this.uri = uri; - } - - public boolean getIsRemoteReference() { - return isRemoteReference; - } - - public void setIsRemoteReference(boolean isRemoteReference) { - this.isRemoteReference = isRemoteReference; - } - - protected void resolve() { - } - - protected void reset() { - this.uri = null; - } - - public void setExtensionPointRegistry(ExtensionPointRegistry registry) { - this.registry = registry; - } -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java deleted file mode 100644 index 761799a4d5..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.assembly.Extensible; -import org.apache.tuscany.sca.assembly.Extension; - -/** - * Convenience base class for extensible assembly model objects. - * - * @version $Rev$ $Date$ - */ -public abstract class ExtensibleImpl extends BaseImpl implements Extensible { - private List<Object> extensions = new ArrayList<Object>(); - private List<Extension> attributeExtensions = new ArrayList<Extension>(); - - /** - * Constructs a new base model object. - */ - protected ExtensibleImpl() { - } - - public List<Object> getExtensions() { - return extensions; - } - - public List<Extension> getAttributeExtensions() { - return attributeExtensions; - } -}
\ No newline at end of file diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java deleted file mode 100644 index 9befad9f2b..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.impl; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.Extension; - -public class ExtensionImpl implements Extension { - private QName qName; - private Object value; - boolean isAttribute = false; - - public ExtensionImpl() { - } - - public ExtensionImpl(QName qName, Object value, boolean isAttribute) { - this.qName = qName; - this.value = value; - this.isAttribute = isAttribute; - } - - public QName getQName() { - return qName; - } - - public void setQName(QName qName) { - this.qName = qName; - } - - public <T> T getValue() { - return (T) value; - } - - public <T> void setValue(T value) { - this.value = value; - } - - public boolean isAttribute() { - return isAttribute; - } - - public void setAttribute(boolean isAttribute) { - this.isAttribute = isAttribute; - } -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java deleted file mode 100644 index 1c28192b3a..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.policy.ExtensionType; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySubject; - -/** - * Base implementation class of Implementation model interface - * - * @version $Rev$ $Date$ - */ -public abstract class ImplementationImpl extends ComponentTypeImpl implements Implementation, PolicySubject { - private ExtensionType type; - private List<PolicySet> policySets = new ArrayList<PolicySet>(); - private List<Intent> requiredIntents = new ArrayList<Intent>(); - - protected ImplementationImpl() { - super(); - } - - public List<PolicySet> getPolicySets() { - return policySets; - } - - public List<Intent> getRequiredIntents() { - return requiredIntents; - } - - public ExtensionType getType() { - return type; - } - - public void setType(ExtensionType type) { - this.type = type; - } -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java deleted file mode 100644 index 0c1051199f..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.policy.PolicySet; - -/** - * Represents a property. - * - * @version $Rev$ $Date$ - */ -public class PropertyImpl extends AbstractPropertyImpl implements Property, Cloneable { - private List<PolicySet> policySets = new ArrayList<PolicySet>(); - private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>(); - - /** - * Constructs a new property. - */ - protected PropertyImpl() { - } - - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - public List<PolicySet> getPolicySets() { - return policySets; - } - - public void setPolicySets(List<PolicySet> policySets) { - this.policySets = policySets; - } - - public List<PolicySet> getApplicablePolicySets() { - return applicablePolicySets; - } -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java deleted file mode 100644 index 454a24225f..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Callback; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.EndpointReference; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; - -/** - * Represents a reference. - * - * @version $Rev$ $Date$ - */ -public class ReferenceImpl extends AbstractReferenceImpl implements Reference, Cloneable { - private List<Binding> bindings = new ArrayList<Binding>(); - private boolean wiredByImpl; - private List<ComponentService> targets = new ArrayList<ComponentService>(); - private Callback callback; - private boolean promotionOverride; - private List<EndpointReference> endpointReferences = new ArrayList<EndpointReference>(); - - /** - * Constructs a new reference. - */ - protected ReferenceImpl() { - } - - @Override - public Object clone() throws CloneNotSupportedException { - ReferenceImpl clone = (ReferenceImpl)super.clone(); - clone.bindings = new ArrayList<Binding>(bindings); - clone.targets = new ArrayList<ComponentService>(targets); - // clone the endpoint references themselves and set the reference pointer back to - // this new refrence - clone.endpointReferences = new ArrayList<EndpointReference>(); - - for (EndpointReference epr : endpointReferences){ - EndpointReference eprClone = (EndpointReference)epr.clone(); - eprClone.setReference((ComponentReference)clone); - clone.endpointReferences.add(eprClone); - } - return clone; - } - - public List<Binding> getBindings() { - return bindings; - } - - public <B> B getBinding(Class<B> bindingClass) { - for (Binding binding : bindings) { - if (bindingClass.isInstance(binding)) { - return bindingClass.cast(binding); - } - } - return null; - } - - public <B> B getCallbackBinding(Class<B> bindingClass) { - if (callback != null) { - for (Binding binding : callback.getBindings()) { - if (bindingClass.isInstance(binding)) { - return bindingClass.cast(binding); - } - } - } - return null; - } - - public boolean isWiredByImpl() { - return wiredByImpl; - } - - public void setWiredByImpl(boolean wiredByImpl) { - this.wiredByImpl = wiredByImpl; - } - - public boolean isPromotionOverride() { - return promotionOverride; - } - - public void setPromotionOverride(boolean promotionOverride) { - this.promotionOverride = promotionOverride; - } - - public List<ComponentService> getTargets() { - return targets; - } - - public Callback getCallback() { - return callback; - } - - public void setCallback(Callback callback) { - this.callback = callback; - } - - /** - * By default return the interface contract for the reference - */ - public InterfaceContract getInterfaceContract(Binding binding) { - return getInterfaceContract(); - } - - public List<EndpointReference> getEndpointReferences() { - return endpointReferences; - } - - public String toString() { - return getName(); - } -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java deleted file mode 100644 index 7e311d8312..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.impl; - -import org.apache.tuscany.sca.assembly.DistributedSCABinding; -import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.assembly.SCABindingFactory; - -/** - * A factory for the SCA binding model. - * - * @version $Rev$ $Date$ - */ -public class SCABindingFactoryImpl implements SCABindingFactory { - - public SCABindingFactoryImpl (){ - - } - - public SCABinding createSCABinding() { - return new SCABindingImpl(); - } - - public DistributedSCABinding createDistributedSCABinding() { - return new DistributedSCABindingImpl(); - } - -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java deleted file mode 100644 index 4a962db005..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Extensible; -import org.apache.tuscany.sca.assembly.Extension; -import org.apache.tuscany.sca.assembly.OptimizableBinding; -import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.assembly.builder.AutomaticBinding; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.ExtensionType; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySubject; - -/** - * The assembly mode object for an SCA binding. - * - * @version $Rev$ $Date$ - */ -public class SCABindingImpl implements SCABinding, Extensible, PolicySubject, OptimizableBinding, AutomaticBinding { - private String name; - private String uri; - private List<Object> extensions = new ArrayList<Object>(); - private List<Extension> attributeExtensions = new ArrayList<Extension>(); - private List<Intent> requiredIntents = new ArrayList<Intent>(); - private List<PolicySet> policySets = new ArrayList<PolicySet>(); - private ExtensionType intentAttachPointType; - - private Component targetComponent; - private ComponentService targetComponentService; - private Binding targetBinding; - private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>(); - - private boolean isAutomatic = false; - - public List<PolicySet> getApplicablePolicySets() { - return applicablePolicySets; - } - - /** - * Constructs a new SCA binding. - */ - protected SCABindingImpl() { - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - /** - * Getters for the binding URI. The computed URI for the - * service that the reference is targeting or which the service represents - * depending on whether the biding is associated with a reference or - * service - * - * @return the binding URI - */ - public String getURI() { - return uri; - } - - public void setURI(String uri) { - this.uri = uri; - } - - public List<Object> getExtensions() { - return extensions; - } - - public List<Extension> getAttributeExtensions() { - return attributeExtensions; - } - - public boolean isUnresolved() { - if (targetComponentService == null){ - return true; - } else { - return targetComponentService.isUnresolved(); - } - } - - public void setUnresolved(boolean unresolved) { - } - - public List<PolicySet> getPolicySets() { - return policySets; - } - - public List<Intent> getRequiredIntents() { - return requiredIntents; - } - - public ExtensionType getType() { - return intentAttachPointType; - } - - public void setType(ExtensionType intentAttachPointType) { - this.intentAttachPointType = intentAttachPointType; - } - - // Wireable binding operations - - public Component getTargetComponent() { - return targetComponent; - } - - public void setTargetComponent(Component targetComponent) { - this.targetComponent = targetComponent; - } - - public ComponentService getTargetComponentService() { - return targetComponentService; - } - - public void setTargetComponentService(ComponentService targetComponentService) { - this.targetComponentService = targetComponentService; - } - - public Binding getTargetBinding() { - return targetBinding; - } - - public void setTargetBinding(Binding targetBinding) { - this.targetBinding = targetBinding; - } - - public void setPolicySets(List<PolicySet> policySets) { - this.policySets = policySets; - } - - public void setRequiredIntents(List<Intent> intents) { - this.requiredIntents = intents; - } - - public void setIsAutomatic(boolean isAutomatic){ - this.isAutomatic = isAutomatic; - } - - public boolean getIsAutomatic(){ - return this.isAutomatic; - } - - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java deleted file mode 100644 index 8f1ce29fdb..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Callback; -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; - -/** - * Represents a reference. - * - * @version $Rev$ $Date$ - */ -public class ServiceImpl extends AbstractServiceImpl implements Service, Cloneable { - private List<Binding> bindings = new ArrayList<Binding>(); - private Callback callback; - private List<Endpoint> endpoints = new ArrayList<Endpoint>(); - - - /** - * Constructs a new service. - */ - protected ServiceImpl() { - } - - @Override - public Object clone() throws CloneNotSupportedException { - ServiceImpl clone = (ServiceImpl)super.clone(); - clone.bindings = new ArrayList<Binding>(); - clone.bindings.addAll(getBindings()); - return clone; - } - - public List<Binding> getBindings() { - return bindings; - } - - public <B> B getBinding(Class<B> bindingClass) { - for (Binding binding : bindings) { - if (bindingClass.isInstance(binding)) { - return bindingClass.cast(binding); - } - } - return null; - } - - public <B> B getCallbackBinding(Class<B> bindingClass) { - if (callback != null) { - for (Binding binding : callback.getBindings()) { - if (bindingClass.isInstance(binding)) { - return bindingClass.cast(binding); - } - } - } - return null; - } - - public Callback getCallback() { - return callback; - } - - public void setCallback(Callback callback) { - this.callback = callback; - } - - /** - * By default return the interface contract for the service - */ - public InterfaceContract getInterfaceContract(Binding binding){ - return getInterfaceContract(); - } - - public List<Endpoint> getEndpoints() { - return endpoints; - } -} diff --git a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java b/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java deleted file mode 100644 index 9f8af0907d..0000000000 --- a/branches/sca-java-2.0-M3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Wire; -import org.apache.tuscany.sca.policy.ExtensionType; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; - -/** - * Represents a wire - * - * @version $Rev$ $Date$ - */ -public class WireImpl extends ExtensibleImpl implements Wire, Cloneable { - private ComponentReference source; - private ComponentService target; - private boolean replace; - private List<Intent> requiredIntents = new ArrayList<Intent>(); - private List<PolicySet> policySets = new ArrayList<PolicySet>(); - private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>(); - - public List<PolicySet> getApplicablePolicySets() { - return applicablePolicySets; - } - - /** - * Constructs a new wire. - */ - protected WireImpl() { - } - - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - public ComponentReference getSource() { - return source; - } - - public ComponentService getTarget() { - return target; - } - - public void setSource(ComponentReference source) { - this.source = source; - } - - public void setTarget(ComponentService target) { - this.target = target; - } - - public List<Intent> getRequiredIntents() { - return requiredIntents; - } - - public List<PolicySet> getPolicySets() { - return policySets; - } - - public ExtensionType getType() { - return null; - } - - public void setType(ExtensionType type) { - } - - public void setPolicySets(List<PolicySet> policySets) { - this.policySets = policySets; - } - - public void setRequiredIntents(List<Intent> intents) { - this.requiredIntents = intents; - } - - public boolean isReplace() { - return replace; - } - - public void setReplace(boolean replace) { - this.replace = replace; - } -} |