summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-0.91/modules/assembly
diff options
context:
space:
mode:
Diffstat (limited to 'branches/sca-java-0.91/modules/assembly')
-rw-r--r--branches/sca-java-0.91/modules/assembly/.checkstyle24
-rw-r--r--branches/sca-java-0.91/modules/assembly/.pmd21
-rw-r--r--branches/sca-java-0.91/modules/assembly/.ruleset190
-rw-r--r--branches/sca-java-0.91/modules/assembly/DISCLAIMER8
-rw-r--r--branches/sca-java-0.91/modules/assembly/LICENSE205
-rw-r--r--branches/sca-java-0.91/modules/assembly/NOTICE6
-rw-r--r--branches/sca-java-0.91/modules/assembly/pom.xml44
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java62
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java122
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java43
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.java28
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java156
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java51
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java58
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java40
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java133
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java80
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java64
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java49
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java80
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java108
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java37
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java42
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConstrainingType.java72
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java63
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.java31
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultSCABindingFactory.java31
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java28
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.java49
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java41
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java64
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java32
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java36
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java37
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Visitable.java37
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Visitor.java36
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java67
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ComponentPreProcessor.java28
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java40
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java45
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderMonitor.java36
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/Problem.java45
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java1344
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ProblemImpl.java98
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyUtil.java189
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceUtil.java94
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java102
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java46
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java36
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java121
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java58
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java62
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java157
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java78
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java72
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java60
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java151
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java136
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java51
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java51
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.java116
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java59
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java51
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java95
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java36
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java91
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java79
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java76
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/util/PrintUtil.java172
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java212
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java69
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java62
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java42
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java41
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java31
-rw-r--r--branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderTestCase.java135
76 files changed, 6742 insertions, 0 deletions
diff --git a/branches/sca-java-0.91/modules/assembly/.checkstyle b/branches/sca-java-0.91/modules/assembly/.checkstyle
new file mode 100644
index 0000000000..e3c216986d
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/.checkstyle
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<fileset-config file-format-version="1.2.0" simple-config="true">
+ <fileset name="all" enabled="true" check-config-name="Tuscany Checks" local="false">
+ <file-match-pattern match-pattern="." include-pattern="true"/>
+ </fileset>
+</fileset-config>
diff --git a/branches/sca-java-0.91/modules/assembly/.pmd b/branches/sca-java-0.91/modules/assembly/.pmd
new file mode 100644
index 0000000000..aa1ce3e754
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/.pmd
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+
+<pmd><useProjectRuleSet>true</useProjectRuleSet><rules/><includeDerivedFiles>false</includeDerivedFiles></pmd> \ No newline at end of file
diff --git a/branches/sca-java-0.91/modules/assembly/.ruleset b/branches/sca-java-0.91/modules/assembly/.ruleset
new file mode 100644
index 0000000000..ba9b5ce886
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/.ruleset
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<!--<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>-->
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/branches/sca-java-0.91/modules/assembly/DISCLAIMER b/branches/sca-java-0.91/modules/assembly/DISCLAIMER
new file mode 100644
index 0000000000..d68a410903
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/DISCLAIMER
@@ -0,0 +1,8 @@
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
diff --git a/branches/sca-java-0.91/modules/assembly/LICENSE b/branches/sca-java-0.91/modules/assembly/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/LICENSE
@@ -0,0 +1,205 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
+
+
diff --git a/branches/sca-java-0.91/modules/assembly/NOTICE b/branches/sca-java-0.91/modules/assembly/NOTICE
new file mode 100644
index 0000000000..94481d6cfa
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2007 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/branches/sca-java-0.91/modules/assembly/pom.xml b/branches/sca-java-0.91/modules/assembly/pom.xml
new file mode 100644
index 0000000000..8d167daa6a
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/pom.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>0.91-incubating-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-assembly</artifactId>
+ <name>Apache Tuscany Assembly Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy</artifactId>
+ <version>0.91-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface</artifactId>
+ <version>0.91-incubating-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java
new file mode 100644
index 0000000000..8f371defde
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java
@@ -0,0 +1,62 @@
+/*
+ * 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.IntentAttachPoint;
+
+/**
+ * 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, IntentAttachPoint {
+
+ /**
+ * 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();
+
+
+ /**
+ * Returns the interface contract defining the interface and callback
+ * interface for the contract.
+ *
+ * @param interfaceContract the interface contract
+ */
+ void setInterfaceContract(InterfaceContract interfaceContract);
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java
new file mode 100644
index 0000000000..35c5da4123
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java
@@ -0,0 +1,122 @@
+/*
+ * 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;
+
+import org.apache.tuscany.sca.policy.IntentAttachPoint;
+
+/**
+ * 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.
+ */
+public interface AbstractProperty extends Base, IntentAttachPoint {
+
+ /**
+ * 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 ths property
+ */
+ Object getValue();
+
+ /**
+ * Sets the default value of the property.
+ *
+ * @param defaultValue the default value of ths 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 type the element defining the type of this property
+ */
+ void setXSDElement(QName element);
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java
new file mode 100644
index 0000000000..a9ef26bbb9
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java
@@ -0,0 +1,43 @@
+/*
+ * 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-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.java
new file mode 100644
index 0000000000..9ae511c07b
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.java
@@ -0,0 +1,28 @@
+/*
+ * 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-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java
new file mode 100644
index 0000000000..3937d34f92
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java
@@ -0,0 +1,156 @@
+/*
+ * 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.Operation;
+
+/**
+ * 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 a new operation.
+ *
+ * @return a new operation
+ */
+ Operation createOperation();
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java
new file mode 100644
index 0000000000..9681ff0c40
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java
@@ -0,0 +1,51 @@
+/*
+ * 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 all assembly model objects.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface 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 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-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java
new file mode 100644
index 0000000000..8d7d6958be
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java
@@ -0,0 +1,58 @@
+/*
+ * 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.IntentAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+
+/**
+ * Represents a binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Binding extends Base, IntentAttachPoint, PolicySetAttachPoint {
+
+ /**
+ * 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);
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java
new file mode 100644
index 0000000000..b50e4ec06b
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java
@@ -0,0 +1,40 @@
+/*
+ * 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.IntentAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+
+/**
+ * Represents a callback object describing the bindings to use for callbacks.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Callback extends Base, IntentAttachPoint, PolicySetAttachPoint {
+
+ /**
+ * Returns the bindings supported for callbacks.
+ *
+ * @return the bindings supported for callbacks
+ */
+ List<Binding> getBindings();
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java
new file mode 100644
index 0000000000..72ee71de8c
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java
@@ -0,0 +1,133 @@
+/*
+ * 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.IntentAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+
+/**
+ * Represents a component. A component is a configured instance of an
+ * implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Component extends Base, IntentAttachPoint, PolicySetAttachPoint, Visitable {
+
+ /**
+ * 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);
+
+ /**
+ * Returns true if the component references should be autowired.
+ *
+ * @return whether component references should be autowired.
+ */
+ boolean isAutowire();
+
+ /**
+ * 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-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java
new file mode 100644
index 0000000000..9a344afb09
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java
@@ -0,0 +1,80 @@
+/*
+ * 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 configured property of a component.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ComponentProperty extends Property, Cloneable {
+
+ /**
+ * Returns the property defined by the component implementation.
+ *
+ * @return the property defined by the component implementation
+ */
+ Property getProperty();
+
+ /**
+ * Sets the property type that defines this property.
+ *
+ * @param type the property that defines this property
+ */
+ 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);
+
+ /**
+ * 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);
+
+ /**
+ * Clone the component property.
+ *
+ * @return a clone of the component property
+ */
+ Object clone() throws CloneNotSupportedException;
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java
new file mode 100644
index 0000000000..1f4b4f0801
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java
@@ -0,0 +1,64 @@
+/*
+ * 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
+ */
+ Reference getReference();
+
+ /**
+ * Sets the reference defined by the implementation for this reference.
+ *
+ * @param reference
+ */
+ void setReference(Reference reference);
+
+ /**
+ * Returns true if the reference should be autowired.
+ *
+ * @return whether the reference should be autowired.
+ */
+ boolean isAutowire();
+
+ /**
+ * Sets whether the reference should be autowired.
+ *
+ * @param autowire whether the reference should be autowired
+ */
+ void setAutowire(boolean autowire);
+
+
+ /**
+ * Clone the component reference.
+ *
+ * @return a clone of the component reference
+ */
+ Object clone() throws CloneNotSupportedException;
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java
new file mode 100644
index 0000000000..c0e42dbb93
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java
@@ -0,0 +1,49 @@
+/*
+ * 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);
+
+ /**
+ * Clone the component service.
+ *
+ * @return a clone of the component service
+ */
+ Object clone() throws CloneNotSupportedException;
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java
new file mode 100644
index 0000000000..ffdef42aed
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java
@@ -0,0 +1,80 @@
+/*
+ * 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.IntentAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+
+/**
+ * Describes an implementation and represents its configurable aspects.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ComponentType extends Base, IntentAttachPoint, PolicySetAttachPoint {
+
+ /**
+ * 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-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java
new file mode 100644
index 0000000000..1fe402d829
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java
@@ -0,0 +1,108 @@
+/*
+ * 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;
+
+
+/**
+ * Represents a composite.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Composite extends Implementation, Visitable {
+
+ /**
+ * 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);
+
+ /**
+ * Returns true if autowiring is enabled in the composite.
+ *
+ * @return true if autowiring is enabled in the composite
+ */
+ boolean isAutowire();
+
+ /**
+ * Sets whether autowiring is enabled in the composite.
+ *
+ * @param autowire whether autowiring is enabled in the composite
+ */
+ 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-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java
new file mode 100644
index 0000000000..d3fa80ba74
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java
@@ -0,0 +1,37 @@
+/*
+ * 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 composite references.
+ *
+ * @return the promoted composite references
+ */
+ List<ComponentReference> getPromotedReferences();
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java
new file mode 100644
index 0000000000..757e2bda2e
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java
@@ -0,0 +1,42 @@
+/*
+ * 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 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-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConstrainingType.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConstrainingType.java
new file mode 100644
index 0000000000..4119d0a268
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConstrainingType.java
@@ -0,0 +1,72 @@
+/*
+ * 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.IntentAttachPoint;
+
+/**
+ * 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, IntentAttachPoint {
+
+ /**
+ * 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-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java
new file mode 100644
index 0000000000..830ede478a
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java
@@ -0,0 +1,63 @@
+/*
+ * 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.PolicySetAttachPoint;
+
+/**
+ * Represents a contract. A contract can be either a service or a reference.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Contract extends AbstractContract, PolicySetAttachPoint {
+
+ /**
+ * 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 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);
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.java
new file mode 100644
index 0000000000..5dd256e3c4
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.java
@@ -0,0 +1,31 @@
+/*
+ * 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;
+
+/**
+ * A factory for the assembly model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultAssemblyFactory extends AssemblyFactoryImpl implements AssemblyFactory {
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultSCABindingFactory.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultSCABindingFactory.java
new file mode 100644
index 0000000000..793a8f960b
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultSCABindingFactory.java
@@ -0,0 +1,31 @@
+/*
+ * 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.SCABindingFactoryImpl;
+
+/**
+ * A factory for the SCA binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultSCABindingFactory extends SCABindingFactoryImpl implements SCABindingFactory {
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java
new file mode 100644
index 0000000000..e79f9bccdb
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java
@@ -0,0 +1,28 @@
+/*
+ * 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-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.java
new file mode 100644
index 0000000000..5d15ce9938
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.java
@@ -0,0 +1,49 @@
+/*
+ * 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-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java
new file mode 100644
index 0000000000..98089d66cb
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java
@@ -0,0 +1,41 @@
+/*
+ * 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.PolicySetAttachPoint;
+
+/**
+ * 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, PolicySetAttachPoint {
+
+ /**
+ * Returns a clone of the property.
+ *
+ * @return a clone of the property
+ * @throws CloneNotSupportedException
+ */
+ Object clone() throws CloneNotSupportedException;
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java
new file mode 100644
index 0000000000..3b2d2b124c
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java
@@ -0,0 +1,64 @@
+/*
+ * 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 the targets of this reference.
+ *
+ * @return the targets of this reference.
+ */
+ List<ComponentService> getTargets();
+
+ /**
+ * Returns a clone of the reference.
+ *
+ * @return a clone of the reference
+ * @throws CloneNotSupportedException
+ */
+ Object clone() throws CloneNotSupportedException;
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java
new file mode 100644
index 0000000000..eaf60aa6d9
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java
@@ -0,0 +1,32 @@
+/*
+ * 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 {
+
+ Component getComponent();
+
+ void setComponent(Component component);
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java
new file mode 100644
index 0000000000..0abfd13d10
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java
@@ -0,0 +1,36 @@
+/*
+ * 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();
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java
new file mode 100644
index 0000000000..ea32efb769
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java
@@ -0,0 +1,37 @@
+/*
+ * 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. 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 a clone of the service.
+ *
+ * @return a clone of the service
+ * @throws CloneNotSupportedException
+ */
+ Object clone() throws CloneNotSupportedException;
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Visitable.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Visitable.java
new file mode 100644
index 0000000000..6d3998b79e
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Visitable.java
@@ -0,0 +1,37 @@
+/*
+ * 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;
+
+/**
+ * This interface is implemented by object that can accept a visitor.
+ */
+public interface Visitable {
+
+ /**
+ * Accepts the given visitor. The visitor's visit method is called with this
+ * model object. If the visitor returns true, this method visits this
+ * object's children.
+ *
+ * @param visitor
+ * @return true if the model object's chidren should be visited, false if
+ * they should be skipped
+ */
+ boolean accept(Visitor visitor);
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Visitor.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Visitor.java
new file mode 100644
index 0000000000..a15354e401
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Visitor.java
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+
+/**
+ * This interface is implemented by objects that visit assembly model trees.
+ */
+public interface Visitor {
+
+ /**
+ * Visits the given assembly model object.
+ *
+ * @param object
+ * @return true if the model object's chidren should be visited, false if
+ * they should be skipped
+ */
+ boolean visit(Base object);
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java
new file mode 100644
index 0000000000..58562eb5ad
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java
@@ -0,0 +1,67 @@
+/*
+ * 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.IntentAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+
+/**
+ * Represents a wire.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Wire extends Base, IntentAttachPoint, PolicySetAttachPoint {
+
+ /**
+ * 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);
+
+ /**
+ * Returns a clone of the wire.
+ *
+ * @return a clone of the wire
+ * @throws CloneNotSupportedException
+ */
+ Object clone() throws CloneNotSupportedException;
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ComponentPreProcessor.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ComponentPreProcessor.java
new file mode 100644
index 0000000000..5f5856d051
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ComponentPreProcessor.java
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+public interface ComponentPreProcessor {
+
+ void preProcess(Component component);
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java
new file mode 100644
index 0000000000..26bdc3cffa
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java
@@ -0,0 +1,40 @@
+/*
+ * 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;
+
+/**
+ * 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 {
+
+ /**
+ * Build, configure and wire a composite.
+ *
+ * @param composite
+ * @throws CompositeBuilderException
+ */
+ void build(Composite composite) throws CompositeBuilderException;
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java
new file mode 100644
index 0000000000..5a2015f55e
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java
@@ -0,0 +1,45 @@
+/*
+ * 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-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderMonitor.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderMonitor.java
new file mode 100644
index 0000000000..aecdf417f2
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderMonitor.java
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+/**
+ * A monitor for the composite builder.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface CompositeBuilderMonitor {
+
+ /**
+ * Reports a build problem.
+ *
+ * @param problem
+ */
+ void problem(Problem problem);
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/Problem.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/Problem.java
new file mode 100644
index 0000000000..8965410438
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/Problem.java
@@ -0,0 +1,45 @@
+/*
+ * 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 assembly problem.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Problem {
+
+ public enum Severity {
+ INFO,
+ WARNING,
+ ERROR
+ }
+
+ Severity getSeverity();
+
+ String getMessage();
+
+ Object getModel();
+
+ Object getResource();
+
+ Exception getCause();
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
new file mode 100644
index 0000000000..6234aed284
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
@@ -0,0 +1,1344 @@
+/*
+ * 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.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.Multiplicity;
+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.Wire;
+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.assembly.builder.CompositeBuilderMonitor;
+import org.apache.tuscany.sca.assembly.builder.Problem;
+import org.apache.tuscany.sca.assembly.builder.Problem.Severity;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+
+/**
+ * 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 AssemblyFactory assemblyFactory;
+ private SCABindingFactory scaBindingFactory;
+ private InterfaceContractMapper interfaceContractMapper;
+ private CompositeBuilderMonitor monitor;
+
+ /**
+ * Constructs a new composite util.
+ *
+ * @param assemblyFactory
+ * @param interfaceContractMapper
+ */
+ public CompositeBuilderImpl(AssemblyFactory assemblyFactory,
+ SCABindingFactory scaBindingFactory,
+ InterfaceContractMapper interfaceContractMapper,
+ CompositeBuilderMonitor monitor) {
+ this.assemblyFactory = assemblyFactory;
+ this.scaBindingFactory = scaBindingFactory;
+ this.interfaceContractMapper = interfaceContractMapper;
+
+ if (monitor != null) {
+ this.monitor = monitor;
+ } else {
+ // Create a default monitor that does nothing.
+ this.monitor = new CompositeBuilderMonitor() {
+ public void problem(Problem problem) {
+ }
+ };
+ }
+ }
+
+ public void build(Composite composite) throws CompositeBuilderException {
+
+ // Collect and fuse includes
+ fuseIncludes(composite);
+
+ // Expand nested composites
+ expandComposites(composite);
+
+ // Configure all components
+ configureComponents(composite);
+
+ // Wire the composite
+ wireComposite(composite);
+
+ // Activate composite services
+ activateCompositeServices(composite);
+
+ // Wire composite references
+ wireCompositeReferences(composite);
+ }
+
+ /**
+ * Collect all includes in a graph of includes.
+ *
+ * @param composite
+ * @param includes
+ */
+ private void collectIncludes(Composite composite, List<Composite> includes) {
+ for (Composite include : composite.getIncludes()) {
+ includes.add(include);
+ collectIncludes(include, includes);
+ }
+ }
+
+ /**
+ * Copy a list of includes into a composite.
+ *
+ * @param composite
+ * @param includes
+ */
+ protected void fuseIncludes(Composite composite) {
+
+ // First collect all includes
+ List<Composite> includes = new ArrayList<Composite>();
+ collectIncludes(composite, includes);
+
+ // 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();
+ }
+
+ /**
+ * Reconcile component services and services defined on the component type.
+ *
+ * @param component
+ * @param services
+ * @param componentServices
+ * @param problems
+ */
+ private void reconcileServices(Component component,
+ Map<String, Service> services,
+ Map<String, ComponentService> componentServices) {
+
+ // Connect each component service to the corresponding service
+ for (ComponentService componentService : component.getServices()) {
+ Service service = services.get(componentService.getName());
+ if (service != null) {
+ componentService.setService(service);
+ } else {
+ warning("Service not found for component service: " + component.getName() + "/" + componentService.getName(), component);
+ }
+ }
+
+ // 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.setName(service.getName());
+ componentService.setService(service);
+ component.getServices().add(componentService);
+ }
+ }
+ }
+
+ // Reconcile each component service with its service
+ for (ComponentService componentService : component.getServices()) {
+ Service service = componentService.getService();
+ if (service != null) {
+
+ // Reconcile interface
+ if (componentService.getInterfaceContract() != null) {
+ if (!componentService.getInterfaceContract().equals(service.getInterfaceContract())) {
+ if (!interfaceContractMapper.isCompatible(componentService.getInterfaceContract(), service
+ .getInterfaceContract())) {
+ warning("Component service interface incompatible with service interface: " + component.getName() + "/" + componentService.getName(), component);
+ }
+ }
+ } else {
+ componentService.setInterfaceContract(service.getInterfaceContract());
+ }
+
+ // Reconcile bindings
+ if (componentService.getBindings().isEmpty()) {
+ componentService.getBindings().addAll(service.getBindings());
+ }
+ }
+
+ }
+ }
+
+ /**
+ * Reconcile component references with the references defined on the
+ * component type.
+ *
+ * @param component
+ * @param references
+ * @param componentReferences
+ * @param problems
+ */
+ private void reconcileReferences(Component component,
+ Map<String, Reference> references,
+ Map<String, ComponentReference> componentReferences) {
+
+ // Connect each component reference to the corresponding reference
+ for (ComponentReference componentReference : component.getReferences()) {
+ Reference reference = references.get(componentReference.getName());
+ if (reference != null) {
+ componentReference.setReference(reference);
+ } else {
+ if (!componentReference.getName().startsWith("$self$.")) {
+ warning("Reference not found for component reference: " + component.getName() + "/" + componentReference.getName(), component);
+ }
+ }
+ }
+
+ // Create a component reference for each reference
+ if (component.getImplementation() != null) {
+ for (Reference reference : component.getImplementation().getReferences()) {
+ if (!componentReferences.containsKey(reference.getName())) {
+ ComponentReference componentReference = assemblyFactory.createComponentReference();
+ 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 (!ReferenceUtil.isValidMultiplicityOverride(reference.getMultiplicity(), componentReference
+ .getMultiplicity())) {
+ warning("Component reference multiplicity incompatible with reference multiplicity: " + component.getName() + "/" + componentReference.getName(), component);
+ }
+ } else {
+ componentReference.setMultiplicity(reference.getMultiplicity());
+ }
+
+ // Reconcile interface
+ if (componentReference.getInterfaceContract() != null) {
+ if (!componentReference.getInterfaceContract().equals(reference.getInterfaceContract())) {
+ if (!interfaceContractMapper.isCompatible(reference.getInterfaceContract(), componentReference
+ .getInterfaceContract())) {
+ warning("Component reference interface incompatible with reference interface: " + component.getName() + "/" + componentReference.getName(), component);
+ }
+ }
+ } else {
+ componentReference.setInterfaceContract(reference.getInterfaceContract());
+ }
+
+ // Reconcile bindings
+ if (componentReference.getBindings().isEmpty()) {
+ componentReference.getBindings().addAll(reference.getBindings());
+ }
+
+ // Propagate autowire setting from the component
+ if (component.isAutowire()) {
+ componentReference.setAutowire(true);
+ }
+
+ // Reconcile targets
+ if (componentReference.getTargets().isEmpty()) {
+ componentReference.getTargets().addAll(reference.getTargets());
+ }
+ }
+ }
+ }
+
+ /**
+ * Reconcile component properties and the properties defined by the
+ * component type.
+ *
+ * @param component
+ * @param properties
+ * @param componentProperties
+ * @param problems
+ */
+ private void reconcileProperties(Component component,
+ Map<String, Property> properties,
+ Map<String, ComponentProperty> componentProperties) {
+
+ // 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("Property not found for component property: " + component.getName() + "/" + componentProperty.getName(), component);
+ }
+ }
+
+ // 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("Component property mustSupply attribute incompatible with property: " + component.getName() + "/" + componentProperty.getName(), component);
+ }
+
+ // 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());
+ }
+
+ // Check that a value is supplied
+ if (componentProperty.getValue() == null && property.isMustSupply()) {
+ warning("No value configured on a mustSupply property: " + component.getName() + "/" + componentProperty.getName(), component);
+ }
+
+ // Check that a a component property does not override the
+ // many attribute
+ if (!property.isMany() && componentProperty.isMany()) {
+ warning("Component property many attribute incompatible with property: " + component.getName() + "/" + componentProperty.getName(), component);
+ }
+
+ // 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("No type specified on component property: " + component.getName() + "/" + componentProperty.getName(), component);
+ }
+ }
+ }
+ }
+
+ /**
+ * Configure components in the composite.
+ *
+ * @param composite
+ * @param problems
+ */
+ protected void configureComponents(Composite composite) {
+ configureComponents(composite, null);
+ }
+
+ private void indexImplementationPropertiesServicesAndReferences(Component component,
+ Map<String, Service> services,
+ Map<String, Reference> references,
+ Map<String, Property> properties) {
+ // First check that the component has a resolved implementation
+ Implementation implementation = component.getImplementation();
+ if (implementation == null) {
+
+ // A component must have an implementation
+ warning("No implementation for component: " + component.getName(), component);
+
+ } else if (implementation.isUnresolved()) {
+
+ // The implementation must be fully resolved
+ warning("Component implementation not found: " + component.getName()
+ + " : "
+ + implementation.getURI(), component);
+
+ } else {
+
+ // Index properties, services and references, also check for
+ // duplicates
+ for (Property property : implementation.getProperties()) {
+ if (properties.containsKey(property.getName())) {
+ warning("Duplicate property name: " + component.getName()
+ + "/"
+ + property.getName(), component);
+ } else {
+ properties.put(property.getName(), property);
+ }
+ }
+ for (Service service : implementation.getServices()) {
+ if (services.containsKey(service.getName())) {
+ warning("Duplicate service name: " + component.getName()
+ + "/"
+ + service.getName(), component);
+ } else {
+ services.put(service.getName(), service);
+ }
+ }
+ for (Reference reference : implementation.getReferences()) {
+ if (references.containsKey(reference.getName())) {
+ warning("Duplicate reference name: " + component.getName()
+ + "/"
+ + reference.getName(), component);
+ } else {
+ references.put(reference.getName(), reference);
+ }
+ }
+ }
+
+ }
+
+ private void indexComponentPropertiesServicesAndReferences(Component component,
+ Map<String, ComponentService> componentServices,
+ Map<String, ComponentReference> componentReferences,
+ Map<String, ComponentProperty> componentProperties) {
+ for (ComponentService componentService : component.getServices()) {
+ if (componentServices.containsKey(componentService.getName())) {
+ warning("Duplicate component service name: " + component.getName()
+ + "/"
+ + componentService.getName(), component);
+ } else {
+ componentServices.put(componentService.getName(), componentService);
+ }
+
+ // Initialize binding names
+ for (Binding binding : componentService.getBindings()) {
+ if (binding.getName() == null) {
+ binding.setName(componentService.getName());
+ }
+ }
+ }
+ for (ComponentReference componentReference : component.getReferences()) {
+ if (componentReferences.containsKey(componentReference.getName())) {
+ warning("Duplicate component reference name: " + component.getName()
+ + "/"
+ + componentReference.getName(), component);
+ } else {
+ componentReferences.put(componentReference.getName(), componentReference);
+ }
+
+ // Initialize binding names
+ for (Binding binding : componentReference.getBindings()) {
+ if (binding.getName() == null) {
+ binding.setName(componentReference.getName());
+ }
+ }
+ }
+ for (ComponentProperty componentProperty : component.getProperties()) {
+ if (componentProperties.containsKey(componentProperty.getName())) {
+ warning("Duplicate component property name: " + component.getName()
+ + "/"
+ + componentProperty.getName(), component);
+ } else {
+ componentProperties.put(componentProperty.getName(), componentProperty);
+ }
+ }
+
+ }
+
+ /**
+ * Configure components in the composite.
+ *
+ * @param composite
+ * @param uri
+ * @param problems
+ */
+ private void configureComponents(Composite composite, String uri) {
+
+ // Process nested composites recursively
+ for (Component component : composite.getComponents()) {
+
+ // Initialize component URI
+ String componentURI;
+ if (uri == null) {
+ componentURI = component.getName();
+ } else {
+ componentURI = uri + "/" + component.getName();
+ }
+ component.setURI(componentURI);
+
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+
+ // Process nested composite
+ configureComponents((Composite)implementation, componentURI);
+ }
+ }
+
+ // Set default binding names
+ for (Service service : composite.getServices()) {
+ for (Binding binding : service.getBindings()) {
+ if (binding.getName() == null) {
+ binding.setName(service.getName());
+ }
+ }
+ }
+ for (Reference reference : composite.getReferences()) {
+ for (Binding binding : reference.getBindings()) {
+ if (binding.getName() == null) {
+ binding.setName(reference.getName());
+ }
+ }
+ }
+
+ // 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())) {
+ warning("Duplicate component name: " + composite.getName() + " : " + component.getName(), composite);
+ } else {
+ components.put(component.getName(), component);
+ }
+
+ // Propagate the autowire flag from the composite to components
+ if (composite.isAutowire()) {
+ component.setAutowire(true);
+ }
+
+ if (component.getImplementation() instanceof ComponentPreProcessor) {
+ ((ComponentPreProcessor)component.getImplementation()).preProcess(component);
+ }
+
+ Map<String, Service> services = new HashMap<String, Service>();
+ Map<String, Reference> references = new HashMap<String, Reference>();
+ Map<String, Property> properties = new HashMap<String, Property>();
+ //Index properties, services and references
+ indexImplementationPropertiesServicesAndReferences(component, services, references, properties);
+
+ Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
+ Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
+ Map<String, ComponentProperty> componentProperties = new HashMap<String, ComponentProperty>();
+ //Index component services, references and properties
+ // Also check for duplicates
+ indexComponentPropertiesServicesAndReferences(component, componentServices, componentReferences, componentProperties);
+
+ // 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);
+ reconcileReferences(component, references, componentReferences);
+ reconcileProperties(component, properties, componentProperties);
+
+ // Create self references to the component's services
+ if (!(component.getImplementation() instanceof Composite)) {
+ createSelfReferences(component);
+ }
+ }
+ }
+
+ /**
+ * Create SCA bindings for component services and references.
+ *
+ * @param composite
+ * @param componentServices
+ * @param componentReferences
+ * @param problems
+ */
+ private void createSCABindings(Composite composite,
+ Map<String, ComponentService> componentServices,
+ Map<String, ComponentReference> componentReferences) {
+
+ for (Component component : composite.getComponents()) {
+ int i = 0;
+ for (ComponentService componentService : component.getServices()) {
+ String uri = component.getName() + '/' + componentService.getName();
+ componentServices.put(uri, componentService);
+ if (i == 0) {
+ componentServices.put(component.getName(), componentService);
+ }
+ i++;
+
+ // Create and configure an SCA binding for the service
+ SCABinding scaBinding = componentService.getBinding(SCABinding.class);
+ if (scaBinding == null) {
+ scaBinding = scaBindingFactory.createSCABinding();
+ scaBinding.setName(componentService.getName());
+ componentService.getBindings().add(scaBinding);
+ }
+ scaBinding.setURI(uri);
+ scaBinding.setComponent(component);
+ }
+ for (ComponentReference componentReference : component.getReferences()) {
+ String uri = component.getName() + '/' + componentReference.getName();
+ componentReferences.put(uri, componentReference);
+
+ // Create and configure an SCA binding for the reference
+ SCABinding scaBinding = componentReference.getBinding(SCABinding.class);
+ if (scaBinding == null) {
+ scaBinding = scaBindingFactory.createSCABinding();
+ scaBinding.setName(componentReference.getName());
+ componentReference.getBindings().add(scaBinding);
+ }
+ scaBinding.setURI(uri);
+ scaBinding.setComponent(component);
+ }
+ }
+
+ }
+
+ /**
+ * Connect composite services to the component services that they promote.
+ *
+ * @param composite
+ * @param componentServices
+ * @param problems
+ */
+ private void connectCompositeServices(Composite composite,
+ Map<String, ComponentService> componentServices) {
+
+ // 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()) {
+ ComponentService promotedService = componentServices.get(componentService.getName());
+ if (promotedService != null) {
+
+ // 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
+ if (compositeService.getInterfaceContract() == null) {
+ compositeService.setInterfaceContract(promotedService.getInterfaceContract());
+ }
+
+ } else {
+ warning("Promoted component service not found: " + componentService.getName(), composite);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Resolves promoted references.
+ *
+ * @param composite
+ * @param componentReferences
+ * @param problems
+ */
+ private void connectCompositeReferences(Composite composite,
+ Map<String, ComponentReference> componentReferences) {
+
+ // 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) {
+
+ // 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
+ if (compositeReference.getInterfaceContract() == null) {
+ compositeReference.setInterfaceContract(componentReference.getInterfaceContract());
+ }
+
+ } else {
+ warning("Promoted component reference not found: " + componentReferenceName, composite);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Connect references to their targets.
+ *
+ * @param composite
+ * @param componentServices
+ * @param componentReferences
+ * @param problems
+ */
+ private void connectComponentReferences(Composite composite,
+ Map<String, ComponentService> componentServices,
+ Map<String, ComponentReference> componentReferences) {
+
+ for (ComponentReference componentReference : componentReferences.values()) {
+ List<ComponentService> targets = componentReference.getTargets();
+
+ if (componentReference.isAutowire()) {
+
+ // Find suitable targets in the current composite for an
+ // autowired reference
+ Multiplicity multiplicity = componentReference.getMultiplicity();
+ for (Component component : composite.getComponents()) {
+ for (ComponentService componentService : component.getServices()) {
+ if (componentReference.getInterfaceContract() == null || interfaceContractMapper
+ .isCompatible(componentReference.getInterfaceContract(), componentService
+ .getInterfaceContract())) {
+
+ targets.add(componentService);
+ if (multiplicity == Multiplicity.ZERO_ONE || multiplicity == Multiplicity.ONE_ONE) {
+ break;
+ }
+ }
+ }
+ }
+
+ } else if (!targets.isEmpty()) {
+
+ // Resolve targets specified on the component reference
+ for (int i = 0, n = targets.size(); i < n; i++) {
+ ComponentService target = targets.get(i);
+ if (target.isUnresolved()) {
+ ComponentService resolved = componentServices.get(target.getName());
+ if (resolved != null) {
+
+ // Check that the target component service provides
+ // a superset of
+ // the component reference interface
+ if (componentReference.getInterfaceContract() == null || interfaceContractMapper
+ .isCompatible(componentReference.getInterfaceContract(), resolved
+ .getInterfaceContract())) {
+
+ targets.set(i, resolved);
+ } else {
+ warning("Incompatible interfaces on component reference and target: " + componentReference.getName() + " : " + target.getName(), composite);
+ }
+ } else {
+ warning("Component reference target not found: " + target.getName(), composite);
+ }
+ }
+ }
+ } else if (componentReference.getReference() != null) {
+
+ // Resolve targets from the corresponding reference in the
+ // componentType
+ for (ComponentService target : componentReference.getReference().getTargets()) {
+ if (target.isUnresolved()) {
+ ComponentService resolved = componentServices.get(target.getName());
+ if (resolved != null) {
+
+ // Check that the target component service provides
+ // a superset of
+ // the component reference interface
+ if (componentReference.getInterfaceContract() == null || interfaceContractMapper
+ .isCompatible(componentReference.getInterfaceContract(), resolved
+ .getInterfaceContract())) {
+
+ targets.add(resolved);
+ } else {
+ warning("Incompatible interfaces on component reference and target: " + componentReference.getName() + " : " + target.getName(), composite);
+ }
+ } else {
+ warning("Reference target not found: " + target.getName(), composite);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * 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) {
+
+ // 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("Wire source not found: " + source.getName(), composite);
+ }
+ } 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("Wire target not found: " + source.getName(), composite);
+ }
+ } 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);
+ } else {
+ warning("Incompatible interfaces on wire source and target: " + source.getName() + " : " + target.getName(), composite);
+ }
+ }
+ }
+
+ // Clear the list of wires
+ composite.getWires().clear();
+ }
+
+ /**
+ * Follow a service promotion chain down to the inner most (non composite)
+ * component service.
+ *
+ * @param topCompositeService
+ * @return
+ */
+ private 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 reference promotion chain down to the inner most (non composite)
+ * component references.
+ *
+ * @param compositeReference
+ * @return
+ */
+ private List<ComponentReference> getPromotedComponentReferences(CompositeReference compositeReference) {
+ List<ComponentReference> componentReferences = new ArrayList<ComponentReference>();
+ collectPromotedComponentReferences(compositeReference, componentReferences);
+ return componentReferences;
+ }
+
+ /**
+ * Follow a reference promotion chain down to the inner most (non composite)
+ * component references.
+ *
+ * @param compositeReference
+ * @param componentReferences
+ * @return
+ */
+ private void collectPromotedComponentReferences(CompositeReference compositeReference,
+ List<ComponentReference> componentReferences) {
+ for (ComponentReference componentReference : compositeReference.getPromotedReferences()) {
+ Reference reference = componentReference.getReference();
+ if (reference instanceof CompositeReference) {
+
+ // Continue to follow the reference promotion chain
+ collectPromotedComponentReferences((CompositeReference)reference, componentReferences);
+
+ } else if (reference != null) {
+
+ // Found a non-composite reference
+ componentReferences.add(componentReference);
+ }
+ }
+ }
+
+ /**
+ * Activate composite services in nested composites.
+ *
+ * @param composite
+ * @param problems
+ */
+ protected void activateCompositeServices(Composite composite) {
+
+ // Process nested composites recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+
+ // First process nested composites
+ activateCompositeServices((Composite)implementation);
+
+ // Process the component services declared on components
+ // in this composite
+ for (ComponentService componentService : component.getServices()) {
+ CompositeService compositeService = (CompositeService)componentService.getService();
+ if (compositeService != null) {
+
+ // Get the inner most promoted service
+ ComponentService promotedService = getPromotedComponentService(compositeService);
+ if (promotedService != null) {
+
+ // Default to use the interface from the promoted service
+ if (compositeService.getInterfaceContract() == null) {
+ compositeService.setInterfaceContract(promotedService.getInterfaceContract());
+ }
+ if (componentService.getInterfaceContract() == null) {
+ componentService.setInterfaceContract(promotedService.getInterfaceContract());
+ }
+
+ // Create a new component service to represent this composite
+ // service on the promoted component
+ SCABinding scaBinding = promotedService.getBinding(SCABinding.class);
+ if (scaBinding != null) {
+ Component promotedComponent = scaBinding.getComponent();
+ ComponentService newComponentService = assemblyFactory.createComponentService();
+ newComponentService.setName("$promoted$." + compositeService.getName());
+ //newComponentService.setService(compositeService);
+ promotedComponent.getServices().add(newComponentService);
+ newComponentService.getBindings().add(scaBinding);
+ newComponentService.getBindings().addAll(compositeService.getBindings());
+ newComponentService.setInterfaceContract(compositeService.getInterfaceContract());
+ newComponentService.setCallback(compositeService.getCallback());
+
+ // FIXME: [rfeng] Set the service to promoted
+ newComponentService.setService(promotedService.getService());
+
+ // Change the composite service to now promote the newly
+ // created component service directly
+ compositeService.setPromotedService(newComponentService);
+
+ } else {
+ warning("Promoted component service not found: " + promotedService.getName(), composite);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Process composite services declared in this composite
+ for (Service service : composite.getServices()) {
+ CompositeService compositeService = (CompositeService)service;
+
+ // Get the inner most promoted service
+ ComponentService promotedService = getPromotedComponentService(compositeService);
+ if (promotedService != null) {
+
+ // Default to use the interface from the promoted service
+ if (compositeService.getInterfaceContract() == null && promotedService.getInterfaceContract() != null) {
+ compositeService.setInterfaceContract(promotedService.getInterfaceContract());
+ }
+
+ // Create a new component service to represent this composite
+ // service on the promoted component
+ SCABinding scaBinding = promotedService.getBinding(SCABinding.class);
+ if (scaBinding != null) {
+ Component promotedComponent = scaBinding.getComponent();
+ ComponentService newComponentService = assemblyFactory.createComponentService();
+ newComponentService.setName("$promoted$." + compositeService.getName());
+ //newComponentService.setService(compositeService);
+ promotedComponent.getServices().add(newComponentService);
+ newComponentService.getBindings().add(scaBinding);
+ newComponentService.getBindings().addAll(compositeService.getBindings());
+ newComponentService.setInterfaceContract(compositeService.getInterfaceContract());
+ newComponentService.setCallback(compositeService.getCallback());
+
+ // FIXME: [rfeng] Set the service to promoted
+ newComponentService.setService(promotedService.getService());
+
+ // Change the composite service to now promote the newly
+ // created component service directly
+ compositeService.setPromotedService(newComponentService);
+ } else {
+ warning("Promoted component service not found: " + promotedService.getName(), composite);
+ }
+ }
+ }
+ }
+
+ /**
+ * Wire composite references in nested composites.
+ *
+ * @param composite
+ * @param problems
+ */
+ protected void wireCompositeReferences(Composite composite) {
+
+ // Process nested composites recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ wireCompositeReferences((Composite)implementation);
+ }
+ }
+
+ // Process composite references declared in this composite
+ for (Reference reference : composite.getReferences()) {
+ CompositeReference compositeReference = (CompositeReference)reference;
+ List<ComponentReference> promotedReferences = getPromotedComponentReferences(compositeReference);
+ for (ComponentReference promotedReference : promotedReferences) {
+
+ // Override the configuration of the promoted reference
+ SCABinding scaBinding = promotedReference.getBinding(SCABinding.class);
+ promotedReference.getBindings().clear();
+ promotedReference.getBindings().add(scaBinding);
+ promotedReference.getBindings().addAll(compositeReference.getBindings());
+ }
+ }
+
+ // Process the component references declared on components
+ // in this composite
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ for (ComponentReference componentReference : component.getReferences()) {
+ CompositeReference compositeReference = (CompositeReference)componentReference.getReference();
+ if (compositeReference != null) {
+ List<ComponentReference> promotedReferences = getPromotedComponentReferences(compositeReference);
+ for (ComponentReference promotedReference : promotedReferences) {
+
+ // Override the configuration of the promoted
+ // reference
+ SCABinding scaBinding = promotedReference.getBinding(SCABinding.class);
+ promotedReference.getBindings().clear();
+ promotedReference.getBindings().add(scaBinding);
+ promotedReference.getBindings().addAll(componentReference.getBindings());
+
+ // Wire the promoted reference to the actual
+ // non-composite component services
+ 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();
+ ComponentService componentService = compositeService.getPromotedService();
+ if (componentService != null) {
+ promotedReference.getTargets().add(componentService);
+ }
+ } else {
+
+ // Wire to a non-composite target service
+ promotedReference.getTargets().add(target);
+ }
+ }
+ }
+ }
+ }
+ } else {
+ for (ComponentReference componentReference : component.getReferences()) {
+
+ // Wire the component reference to the actual
+ // non-composite component services
+ List<ComponentService> targets = componentReference.getTargets();
+ for (int i = 0, n = targets.size(); i<n; i++) {
+ ComponentService target = targets.get(i);
+ if (target.getService() instanceof CompositeService) {
+
+ // Wire to the actual component service
+ // promoted by a composite service
+ CompositeService compositeService = (CompositeService)target.getService();
+ ComponentService componentService = compositeService.getPromotedService();
+ if (componentService != null) {
+ targets.set(i, componentService);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Wire component references to component services and connect promoted
+ * services/references to component services/references inside a composite.
+ *
+ * @param composite
+ * @param problems
+ */
+ protected void wireComposite(Composite composite) {
+
+ // Wire nested composites recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ wireComposite((Composite)implementation);
+ }
+ }
+
+ // Index and bind all component services and references
+ Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
+ Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
+
+ // Create SCA bindings on all component services and references
+ createSCABindings(composite, componentServices, componentReferences);
+
+ // Connect composite services and references to the component
+ // services and references that they promote
+ connectCompositeServices(composite, componentServices);
+ connectCompositeReferences(composite, componentReferences);
+
+ // Connect component references to their targets
+ connectComponentReferences(composite, componentServices, componentReferences);
+
+ // Connect component references as described in wires
+ connectWires(composite, componentServices, componentReferences);
+
+ // Resolve sourced properties
+ resolveSourcedProperties(composite, null);
+
+ // Validate that references are wired or promoted, according
+ // to their multiplicity
+ for (ComponentReference componentReference : componentReferences.values()) {
+ if (!ReferenceUtil.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) {
+ warning("No targets for reference: " + componentReference.getName(), composite);
+ }
+ } else {
+ warning("Too many targets on reference: " + componentReference.getName(), composite);
+ }
+ }
+ }
+ }
+
+ private ComponentProperty getComponentPropertyByName(String propertyName, List<ComponentProperty> properties) {
+ if (properties != null) {
+ for (ComponentProperty aProperty : properties) {
+ if (aProperty.getName().equals(propertyName)) {
+ return aProperty;
+ }
+ }
+ }
+ return null;
+ }
+
+
+ /**
+ * @param composite
+ */
+ private void resolveSourcedProperties(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 {
+ PropertyUtil.sourceComponentProperties(compositeProperties, component);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ Implementation impl = component.getImplementation();
+ if (impl instanceof Composite) {
+ resolveSourcedProperties((Composite)impl, component.getProperties());
+ }
+ }
+ }
+
+
+ /**
+ * Expand composite component implementations.
+ *
+ * @param composite
+ * @param problems
+ */
+ protected void expandComposites(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);
+ expandComposites(clone);
+ }
+ }
+ }
+
+ /**
+ * For all the services, create a corresponding self-reference.
+ *
+ * @param component
+ */
+ private void createSelfReferences(Component component) {
+ for (ComponentService service : component.getServices()) {
+ ComponentReference componentReference = assemblyFactory.createComponentReference();
+ componentReference.setName("$self$." + service.getName());
+ componentReference.getBindings().addAll(service.getBindings());
+ ComponentService componentService = assemblyFactory.createComponentService();
+ componentService.setName(component.getName() + "/" + service.getName());
+ componentService.setUnresolved(true);
+ componentReference.getTargets().add(componentService);
+ componentReference.getPolicySets().addAll(service.getPolicySets());
+ componentReference.getRequiredIntents().addAll(service.getRequiredIntents());
+ componentReference.setInterfaceContract(service.getInterfaceContract());
+ componentReference.setMultiplicity(Multiplicity.ONE_ONE);
+ component.getReferences().add(componentReference);
+ }
+ }
+
+ /**
+ * Report an error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ @SuppressWarnings("unused")
+ private void error(String message, Object model) {
+ monitor.problem(new ProblemImpl(Severity.ERROR, message, model));
+ }
+
+ /**
+ * Report a warning.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void warning(String message, Object model) {
+ monitor.problem(new ProblemImpl(Severity.WARNING, message, model));
+ }
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ProblemImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ProblemImpl.java
new file mode 100644
index 0000000000..2b85cec9fa
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ProblemImpl.java
@@ -0,0 +1,98 @@
+/*
+ * 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.builder.Problem;
+
+
+/**
+ * Reports a composite assembly problem.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ProblemImpl implements Problem {
+
+ private String message;
+ private Severity severity;
+ private Object model;
+ private Object resource;
+ private Exception cause;
+
+ /**
+ * Constructs a new problem.
+ *
+ * @param severity
+ * @param message
+ * @param model
+ */
+ public ProblemImpl(Severity severity, String message, Object model) {
+ this.severity = severity;
+ this.message = message;
+ this.model = model;
+ }
+
+ /**
+ * Constructs a new problem.
+ *
+ * @param severity
+ * @param message
+ * @param model
+ * @param resource
+ */
+ public ProblemImpl(Severity severity, String message, Object model, Object resource) {
+ this.severity = severity;
+ this.message = message;
+ this.model = model;
+ this.resource = resource;
+ }
+
+ /**
+ * Constructs a new problem.
+ *
+ * @param severity
+ * @param message
+ * @param cause
+ */
+ public ProblemImpl(Severity severity, String message, Exception cause) {
+ this.severity = severity;
+ this.message = message;
+ this.cause = cause;
+ }
+
+ public Severity getSeverity() {
+ return severity;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public Object getModel() {
+ return model;
+ }
+
+ public Object getResource() {
+ return resource;
+ }
+
+ public Exception getCause() {
+ return cause;
+ }
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyUtil.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyUtil.java
new file mode 100644
index 0000000000..71be058795
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyUtil.java
@@ -0,0 +1,189 @@
+/*
+ * 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.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+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.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+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.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.
+ */
+public class PropertyUtil {
+ private static final XPathFactory XPATH_FACTORY = XPathFactory.newInstance();
+ private static final DocumentBuilderFactory DOC_BUILDER_FACTORY = DocumentBuilderFactory.newInstance();
+ private static final TransformerFactory TRANSFORMER_FACTORY = TransformerFactory.newInstance();
+
+ static private Document evaluate(NamespaceContext nsContext, Node node, String xPathExpression)
+ throws XPathExpressionException, ParserConfigurationException {
+ XPath path = XPATH_FACTORY.newXPath();
+
+ if (nsContext != null) {
+ path.setNamespaceContext(nsContext);
+ } else {
+ path.setNamespaceContext(new DOMNamespaceContext(node));
+ }
+
+ XPathExpression expression = path.compile(xPathExpression);
+ Node result = (Node)expression.evaluate(node, XPathConstants.NODE);
+ if (result == null) {
+ return null;
+ }
+
+ // TODO: How to wrap the result into a Document?
+ Document document = DOC_BUILDER_FACTORY.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;
+ }
+ }
+
+ static private Document loadFromFile(String file) throws MalformedURLException, IOException,
+ TransformerException, ParserConfigurationException {
+ URI uri = URI.create(file);
+ URL url = null;
+ if (!uri.isAbsolute()) {
+ url = Thread.currentThread().getContextClassLoader().getResource(file);
+ } else {
+ url = uri.toURL();
+ }
+ InputStream is = url.openStream();
+
+ Source streamSource = new SAXSource(new InputSource(is));
+ DOMResult result = new DOMResult();
+ javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
+ transformer.transform(streamSource, result);
+ is.close();
+
+ return (Document)result.getNode();
+ }
+
+ static void sourceComponentProperties(Map<String, Property> compositeProperties,
+ Component componentDefinition) 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();
+
+ // Adding /value because the document root is "value"
+ String path = source.substring(index);
+ String xpath = null;
+
+ if ("/".equals(path)) {
+ // trailing / is not legal for xpath
+ xpath = "/value";
+ } else {
+ xpath = "/value" + path;
+ }
+
+ // FIXME: How to deal with namespaces?
+ Document node = evaluate(null, compositePropDefValues, xpath);
+
+ 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()));
+
+ }
+ }
+ }
+
+ private static class DOMNamespaceContext implements NamespaceContext {
+ private Node node;
+
+ /**
+ * @param node
+ */
+ public DOMNamespaceContext(Node node) {
+ super();
+ this.node = node;
+ }
+
+ public String getNamespaceURI(String prefix) {
+ return node.lookupNamespaceURI(prefix);
+ }
+
+ public String getPrefix(String namespaceURI) {
+ return node.lookupPrefix(namespaceURI);
+ }
+
+ public Iterator<?> getPrefixes(String namespaceURI) {
+ return null;
+ }
+
+ }
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceUtil.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceUtil.java
new file mode 100644
index 0000000000..9802e9ba63
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceUtil.java
@@ -0,0 +1,94 @@
+/*
+ * 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.Binding;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.SCABinding;
+
+/**
+ * This class encapsulates utility methods to deal with reference definitions
+ *
+ */
+class ReferenceUtil {
+ 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 SCABinding)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ break;
+ case ONE_N:
+ if (count < 1) {
+ if (count == 0) {
+ for (Binding binding: bindings) {
+ if (!(binding instanceof SCABinding)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ break;
+ }
+ return true;
+ }
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java
new file mode 100644
index 0000000000..989aea1237
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java
@@ -0,0 +1,102 @@
+/*
+ * 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.policy.Intent;
+
+/**
+ * Represents an abstract property.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AbstractPropertyImpl extends BaseImpl implements AbstractProperty {
+ private Object value;
+ private String name;
+ private QName xsdType;
+ private QName xsdElement;
+ private boolean many;
+ private boolean mustSupply;
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+
+ /**
+ * 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;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java
new file mode 100644
index 0000000000..d0ee3832c5
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java
@@ -0,0 +1,46 @@
+/*
+ * 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-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java
new file mode 100644
index 0000000000..346764b1b4
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java
@@ -0,0 +1,36 @@
+/*
+ * 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-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java
new file mode 100644
index 0000000000..1e623d35f2
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java
@@ -0,0 +1,121 @@
+/*
+ * 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.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.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
+
+/**
+ * A factory for the assembly model.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AssemblyFactoryImpl implements AssemblyFactory {
+
+ 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 Operation createOperation() {
+ return new OperationImpl();
+ }
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java
new file mode 100644
index 0000000000..40c07d2e4f
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java
@@ -0,0 +1,58 @@
+/*
+ * 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.Base;
+import org.apache.tuscany.sca.assembly.Visitable;
+import org.apache.tuscany.sca.assembly.Visitor;
+
+/**
+ * Convenience base class for assembly model objects.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class BaseImpl implements Base, Visitable {
+ private List<Object> extensions = new ArrayList<Object>();
+ private boolean unresolved;
+
+ /**
+ * Constructs a new base model object.
+ */
+ protected BaseImpl() {
+ }
+
+ public List<Object> getExtensions() {
+ return extensions;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean undefined) {
+ this.unresolved = undefined;
+ }
+
+ public boolean accept(Visitor visitor) {
+ return visitor.visit(this);
+ }
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java
new file mode 100644
index 0000000000..87ef907a80
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java
@@ -0,0 +1,62 @@
+/*
+ * 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.Visitor;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a reference.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CallbackImpl extends BaseImpl implements Callback {
+ private List<Binding> bindings = new ArrayList<Binding>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+
+ protected CallbackImpl() {
+ }
+
+ public List<Binding> getBindings() {
+ return bindings;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public boolean accept(Visitor visitor) {
+ if (!super.accept(visitor)) {
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java
new file mode 100644
index 0000000000..ec837c060c
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java
@@ -0,0 +1,157 @@
+/*
+ * 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.assembly.Visitor;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a component.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentImpl extends BaseImpl 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;
+
+ /**
+ * 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;
+ }
+
+ public void setAutowire(boolean autowire) {
+ this.autowire = autowire;
+ }
+
+ public boolean accept(Visitor visitor) {
+ if (!super.accept(visitor)) {
+ return false;
+ }
+ for (ComponentProperty property : properties) {
+ if (!visitor.visit(property)) {
+ return false;
+ }
+ }
+ for (ComponentReference reference : references) {
+ if (!visitor.visit(reference)) {
+ return false;
+ }
+ }
+ for (ComponentService service : services) {
+ if (!visitor.visit(service)) {
+ return false;
+ }
+ }
+ return true;
+ }
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java
new file mode 100644
index 0000000000..8a9b8e446d
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java
@@ -0,0 +1,78 @@
+/*
+ * 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.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;
+
+ /**
+ * Constructs a new component property.
+ */
+ protected ComponentPropertyImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ 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;
+ }
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java
new file mode 100644
index 0000000000..bd593f7502
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java
@@ -0,0 +1,72 @@
+/*
+ * 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.CompositeReference;
+import org.apache.tuscany.sca.assembly.Reference;
+
+/**
+ * Represents a component reference
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentReferenceImpl extends ReferenceImpl implements ComponentReference, Cloneable {
+ private Reference reference;
+ private boolean autowire;
+ private List<CompositeReference> promotedAs = new ArrayList<CompositeReference>();
+
+ /**
+ * 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;
+ }
+
+ public void setAutowire(boolean autowire) {
+ this.autowire = autowire;
+ }
+
+ public List<CompositeReference> promotedAs() {
+ return promotedAs;
+ }
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java
new file mode 100644
index 0000000000..66883133d7
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java
@@ -0,0 +1,60 @@
+/*
+ * 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.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>();
+
+ /**
+ * 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;
+ }
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java
new file mode 100644
index 0000000000..e57f25551a
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java
@@ -0,0 +1,151 @@
+/*
+ * 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.assembly.Visitor;
+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 BaseImpl 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;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public boolean accept(Visitor visitor) {
+ if (!super.accept(visitor)) {
+ return false;
+ }
+ for (Property property : properties) {
+ if (!visitor.visit(property)) {
+ return false;
+ }
+ }
+ for (Reference reference : references) {
+ if (!visitor.visit(reference)) {
+ return false;
+ }
+ }
+ for (Service service : services) {
+ if (!visitor.visit(service)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @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;
+ }
+ }
+ }
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java
new file mode 100644
index 0000000000..5c40f9445b
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java
@@ -0,0 +1,136 @@
+/*
+ * 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.Composite;
+import org.apache.tuscany.sca.assembly.Visitor;
+import org.apache.tuscany.sca.assembly.Wire;
+
+public class CompositeImpl extends ComponentTypeImpl implements Composite, Cloneable {
+ 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()) {
+ clone.components.add((Component)component.clone());
+ }
+ clone.wires = new ArrayList<Wire>();
+ for (Wire wire: getWires()) {
+ clone.wires.add((Wire)wire.clone());
+ }
+ return clone;
+ }
+
+ 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 isAutowire() {
+ return autowire;
+ }
+
+ public boolean isLocal() {
+ return local;
+ }
+
+ public void setAutowire(boolean autowire) {
+ this.autowire = autowire;
+ }
+
+ public void setLocal(boolean local) {
+ this.local = local;
+ }
+
+ public void setName(QName name) {
+ this.name = name;
+ }
+
+ @Override
+ public boolean accept(Visitor visitor) {
+ boolean result = super.accept(visitor);
+ if (!result) {
+ return false;
+ }
+
+ for (Component component: components) {
+ if (!component.accept(visitor)) {
+ return false;
+ }
+ }
+
+ for (Wire wire: wires) {
+ if (!visitor.visit(wire))
+ return false;
+ }
+ return true;
+ }
+
+ @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;
+ }
+ }
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java
new file mode 100644
index 0000000000..4348e08fcb
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java
@@ -0,0 +1,51 @@
+/*
+ * 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.CompositeReference;
+
+/**
+ * Represents a composite reference.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeReferenceImpl extends ReferenceImpl implements CompositeReference, Cloneable {
+ private List<ComponentReference> promotedReferences = new ArrayList<ComponentReference>();
+
+ /**
+ * Constructs a new composite reference.
+ */
+ protected CompositeReferenceImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public List<ComponentReference> getPromotedReferences() {
+ return promotedReferences;
+ }
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java
new file mode 100644
index 0000000000..19a6ed56c2
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java
@@ -0,0 +1,51 @@
+/*
+ * 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.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;
+
+ /**
+ * 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;
+ }
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.java
new file mode 100644
index 0000000000..f9fbae6659
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.java
@@ -0,0 +1,116 @@
+/*
+ * 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.assembly.Visitor;
+import org.apache.tuscany.sca.policy.Intent;
+
+/**
+ * Represents a constraining type.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConstrainingTypeImpl extends BaseImpl 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>();
+
+ /**
+ * 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 boolean accept(Visitor visitor) {
+ if (!super.accept(visitor)) {
+ return false;
+ }
+ for (AbstractProperty property : properties) {
+ if (!visitor.visit(property)) {
+ return false;
+ }
+ }
+ for (AbstractReference reference : references) {
+ if (!visitor.visit(reference)) {
+ return false;
+ }
+ }
+ for (AbstractService service : services) {
+ if (!visitor.visit(service)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @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;
+ }
+ }
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java
new file mode 100644
index 0000000000..d295384305
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java
@@ -0,0 +1,59 @@
+/*
+ * 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.Intent;
+
+public class ContractImpl extends BaseImpl implements AbstractContract {
+ private InterfaceContract interfaceContract;
+ private String name;
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+
+ /**
+ * 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;
+ }
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java
new file mode 100644
index 0000000000..ebdcdf580b
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java
@@ -0,0 +1,51 @@
+/*
+ * 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>();
+
+ /**
+ * Constructs a new property.
+ */
+ protected PropertyImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java
new file mode 100644
index 0000000000..5ceb5bb950
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java
@@ -0,0 +1,95 @@
+/*
+ * 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.ComponentService;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * 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<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<ComponentService> targets = new ArrayList<ComponentService>();
+ private Callback callback;
+
+ /**
+ * Constructs a new reference.
+ */
+ protected ReferenceImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ ReferenceImpl clone = (ReferenceImpl)super.clone();
+ clone.bindings = new ArrayList<Binding>();
+ clone.bindings.addAll(getBindings());
+ clone.targets = new ArrayList<ComponentService>();
+ clone.targets.addAll(getTargets());
+ 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 boolean isWiredByImpl() {
+ return wiredByImpl;
+ }
+
+ public void setWiredByImpl(boolean wiredByImpl) {
+ this.wiredByImpl = wiredByImpl;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<ComponentService> getTargets() {
+ return targets;
+ }
+
+ public Callback getCallback() {
+ return callback;
+ }
+
+ public void setCallback(Callback callback) {
+ this.callback = callback;
+ }
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java
new file mode 100644
index 0000000000..402b90706d
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java
@@ -0,0 +1,36 @@
+/*
+ * 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.SCABindingFactory;
+
+/**
+ * A factory for the SCA binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class SCABindingFactoryImpl implements SCABindingFactory {
+
+ public SCABinding createSCABinding() {
+ return new SCABindingImpl();
+ }
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java
new file mode 100644
index 0000000000..93b7d7a88f
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java
@@ -0,0 +1,91 @@
+/*
+ * 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.SCABinding;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents an SCA binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCABindingImpl implements SCABinding {
+ private String name;
+ private String uri;
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<Object> extensions = new ArrayList<Object>();
+
+ private Component component;
+
+ /**
+ * Constructs a new SCA binding.
+ */
+ protected SCABindingImpl() {
+ }
+
+ public Component getComponent() {
+ return component;
+ }
+
+ public void setComponent(Component component) {
+ this.component = component;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<Object> getExtensions() {
+ return extensions;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java
new file mode 100644
index 0000000000..c5bf3a10d0
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java
@@ -0,0 +1,79 @@
+/*
+ * 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.Service;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a reference.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServiceImpl extends AbstractServiceImpl implements Service, Cloneable {
+ private List<Binding> bindings = new ArrayList<Binding>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private Callback callback;
+
+ /**
+ * 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 List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public Callback getCallback() {
+ return callback;
+ }
+
+ public void setCallback(Callback callback) {
+ this.callback = callback;
+ }
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java
new file mode 100644
index 0000000000..06db488fba
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java
@@ -0,0 +1,76 @@
+/*
+ * 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.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a wire
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireImpl extends BaseImpl implements Wire, Cloneable {
+ private ComponentReference source;
+ private ComponentService target;
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+
+ /**
+ * 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;
+ }
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/util/PrintUtil.java b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/util/PrintUtil.java
new file mode 100644
index 0000000000..08b39f976b
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/util/PrintUtil.java
@@ -0,0 +1,172 @@
+/*
+ * 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.util;
+
+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.Method;
+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$
+ */
+public class PrintUtil {
+
+ private PrintWriter out;
+ private int indent;
+
+ 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
+ BeanInfo beanInfo = Introspector.getBeanInfo(object.getClass());
+ for (PropertyDescriptor propertyDescriptor : beanInfo.getPropertyDescriptors()) {
+ try {
+
+ // Get the value of each property
+ Method getter = propertyDescriptor.getReadMethod();
+ if (getter == null) {
+ continue;
+ }
+ Object value = getter.invoke(object);
+ 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(propertyDescriptor.getName() + "= [");
+
+ // 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 (!propertyDescriptor.getName().equals("class")) {
+ if (!(Boolean.FALSE.equals(value))) {
+ indent++;
+ indent();
+ out.println(propertyDescriptor.getName() + "=" + value.toString());
+ indent--;
+ }
+ }
+ } else if (value instanceof Node) {
+ indent++;
+ indent();
+ out.println(propertyDescriptor.getName() + "=" + value.toString());
+ indent--;
+ } else {
+
+ // Print an object, recursively
+ indent++;
+ indent();
+ out.println(propertyDescriptor.getName() + "= {");
+ indent++;
+ print(value, printed);
+ indent--;
+ indent();
+ out.println("}");
+ indent--;
+ }
+ }
+ }
+ } catch (Exception e) {
+ }
+ }
+ indent();
+ out.println("}");
+ } catch (IntrospectionException e) {
+ indent();
+ out.println(e);
+ }
+ }
+ }
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java b/branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java
new file mode 100644
index 0000000000..cde42cbc62
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java
@@ -0,0 +1,212 @@
+/*
+ * 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;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Test building of assembly model instances using the assembly factory.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AssemblyFactoryTestCase extends TestCase {
+
+ AssemblyFactory factory;
+
+ public void setUp() throws Exception {
+ factory = new DefaultAssemblyFactory();
+ }
+
+ public void tearDown() throws Exception {
+ factory = null;
+ }
+
+ public void testCreateComponent() {
+ createComponent("AccountServiceComponent1");
+ }
+
+ public void testCreateComponentType() {
+ createComponentType();
+ }
+
+ public void testCreateComposite() {
+ createComposite();
+ }
+
+ public void testCreateConstrainingType() {
+ createConstrainingType();
+ }
+
+ /**
+ * Create a composite
+ */
+ Composite createComposite() {
+ Composite c = factory.createComposite();
+
+ Component c1 = createComponent("AccountServiceComponent1");
+ c.getComponents().add(c1);
+ Component c2 = createComponent("AccountServiceComponent2");
+ c.getComponents().add(c2);
+
+ Wire w = factory.createWire();
+ w.setSource(c1.getReferences().get(0));
+ w.setTarget(c2.getServices().get(0));
+ c.getWires().add(w);
+
+ CompositeService cs = factory.createCompositeService();
+ cs.setName("AccountService");
+ cs.setPromotedService(c1.getServices().get(0));
+ cs.setInterfaceContract(new TestInterfaceContract(factory));
+ c.getServices().add(cs);
+ cs.getBindings().add(new TestBinding(factory));
+
+ CompositeReference cr = factory.createCompositeReference();
+ cr.setName("StockQuoteService");
+ cr.getPromotedReferences().add(c2.getReferences().get(1));
+ cr.setInterfaceContract(new TestInterfaceContract(factory));
+ c.getReferences().add(cr);
+ cr.getBindings().add(new TestBinding(factory));
+
+ return c;
+ }
+
+ /**
+ * Create a new component
+ */
+ Component createComponent(String name) {
+ Component c = factory.createComponent();
+ c.setName(name);
+
+ ConstrainingType constraint = createConstrainingType();
+ c.setConstrainingType(constraint);
+
+ Implementation i = new TestImplementation(factory);
+ c.setImplementation(i);
+
+ ComponentProperty p = factory.createComponentProperty();
+ p.setName("currency");
+ p.setValue("USD");
+ p.setMustSupply(true);
+ p.setXSDType(new QName("", ""));
+ p.setProperty(i.getProperties().get(0));
+ c.getProperties().add(p);
+
+ ComponentReference ref1 = factory.createComponentReference();
+ ref1.setName("accountDataService");
+ ref1.setMultiplicity(Multiplicity.ONE_ONE);
+ ref1.setInterfaceContract(new TestInterfaceContract(factory));
+ ref1.setReference(i.getReferences().get(0));
+ c.getReferences().add(ref1);
+ ref1.getBindings().add(new TestBinding(factory));
+
+ ComponentReference ref2 = factory.createComponentReference();
+ ref2.setName("stockQuoteService");
+ ref2.setMultiplicity(Multiplicity.ONE_ONE);
+ ref2.setInterfaceContract(new TestInterfaceContract(factory));
+ ref2.setReference(i.getReferences().get(1));
+ c.getReferences().add(ref2);
+ ref2.getBindings().add(new TestBinding(factory));
+
+ ComponentService s = factory.createComponentService();
+ s.setName("AccountService");
+ s.setInterfaceContract(new TestInterfaceContract(factory));
+ s.setService(i.getServices().get(0));
+ c.getServices().add(s);
+ s.getBindings().add(new TestBinding(factory));
+
+ return c;
+ }
+
+ /**
+ * Create a new component type
+ *
+ * @return
+ */
+ ComponentType createComponentType() {
+ ComponentType ctype = factory.createComponentType();
+
+ Property p = factory.createProperty();
+ p.setName("currency");
+ p.setValue("USD");
+ p.setMustSupply(true);
+ p.setXSDType(new QName("", ""));
+ ctype.getProperties().add(p);
+
+ Reference ref1 = factory.createReference();
+ ref1.setName("accountDataService");
+ ref1.setInterfaceContract(new TestInterfaceContract(factory));
+ ref1.setMultiplicity(Multiplicity.ONE_ONE);
+ ctype.getReferences().add(ref1);
+ ref1.getBindings().add(new TestBinding(factory));
+
+ Reference ref2 = factory.createReference();
+ ref2.setName("stockQuoteService");
+ ref2.setInterfaceContract(new TestInterfaceContract(factory));
+ ref2.setMultiplicity(Multiplicity.ONE_ONE);
+ ctype.getReferences().add(ref2);
+ ref2.getBindings().add(new TestBinding(factory));
+
+ Service s = factory.createService();
+ s.setName("AccountService");
+ s.setInterfaceContract(new TestInterfaceContract(factory));
+ ctype.getServices().add(s);
+ s.getBindings().add(new TestBinding(factory));
+
+ return ctype;
+ }
+
+ /**
+ * Create a new constraining type
+ *
+ * @return
+ */
+ ConstrainingType createConstrainingType() {
+ ConstrainingType ctype = factory.createConstrainingType();
+
+ AbstractProperty p = factory.createAbstractProperty();
+ p.setName("currency");
+ p.setValue("USD");
+ p.setMustSupply(true);
+ p.setXSDType(new QName("", ""));
+ ctype.getProperties().add(p);
+
+ AbstractReference ref1 = factory.createAbstractReference();
+ ref1.setName("accountDataService");
+ ref1.setInterfaceContract(new TestInterfaceContract(factory));
+ ref1.setMultiplicity(Multiplicity.ONE_ONE);
+ ctype.getReferences().add(ref1);
+
+ AbstractReference ref2 = factory.createAbstractReference();
+ ref2.setName("stockQuoteService");
+ ref2.setInterfaceContract(new TestInterfaceContract(factory));
+ ref2.setMultiplicity(Multiplicity.ONE_ONE);
+ ctype.getReferences().add(ref2);
+
+ AbstractService s = factory.createAbstractService();
+ s.setName("AccountService");
+ s.setInterfaceContract(new TestInterfaceContract(factory));
+ ctype.getServices().add(s);
+
+ return ctype;
+ }
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java b/branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java
new file mode 100644
index 0000000000..9b3ac4c2d4
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java
@@ -0,0 +1,69 @@
+/*
+ * 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.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * A test interface model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestBinding implements Binding {
+
+ public TestBinding(AssemblyFactory factory) {
+ setURI("http://test");
+ }
+
+ public String getName() {
+ return null;
+ }
+
+ public String getURI() {
+ return "http://test";
+ }
+
+ public void setName(String name) {
+ }
+
+ public void setURI(String uri) {
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return null;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return null;
+ }
+
+ public List<Object> getExtensions() {
+ return null;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java b/branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java
new file mode 100644
index 0000000000..9e34fafb05
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+import org.apache.tuscany.sca.assembly.impl.ComponentTypeImpl;
+
+/**
+ * A test component implementation model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestImplementation extends ComponentTypeImpl implements Implementation {
+
+ public TestImplementation(AssemblyFactory factory) {
+
+ Property p = factory.createProperty();
+ p.setName("currency");
+ p.setValue("USD");
+ p.setMustSupply(true);
+ p.setXSDType(new QName("", ""));
+ getProperties().add(p);
+
+ Reference ref1 = factory.createReference();
+ ref1.setName("accountDataService");
+ ref1.setMultiplicity(Multiplicity.ONE_ONE);
+ getReferences().add(ref1);
+ ref1.getBindings().add(new TestBinding(factory));
+
+ Reference ref2 = factory.createReference();
+ ref2.setName("stockQuoteService");
+ ref2.setMultiplicity(Multiplicity.ONE_ONE);
+ ref2.setInterfaceContract(new TestInterfaceContract(factory));
+ getReferences().add(ref2);
+ ref2.getBindings().add(new TestBinding(factory));
+
+ Service s = factory.createService();
+ s.setName("AccountService");
+ s.setInterfaceContract(new TestInterfaceContract(factory));
+ getServices().add(s);
+ s.getBindings().add(new TestBinding(factory));
+
+ }
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java b/branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java
new file mode 100644
index 0000000000..dbe0cb8225
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java
@@ -0,0 +1,42 @@
+/*
+ * 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.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.InterfaceImpl;
+
+/**
+ * A test interface model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestInterface extends InterfaceImpl implements Interface {
+
+ public TestInterface(AssemblyFactory factory) {
+
+ setRemotable(true);
+
+ Operation operation = new TestOperation();
+ operation.setName("test");
+ getOperations().add(operation);
+
+ }
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java b/branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java
new file mode 100644
index 0000000000..ee6b95edc9
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java
@@ -0,0 +1,41 @@
+/*
+ * 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.interfacedef.impl.InterfaceContractImpl;
+
+/**
+ * A test interface contract model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestInterfaceContract extends InterfaceContractImpl implements InterfaceContract {
+
+ public TestInterfaceContract(AssemblyFactory factory) {
+
+ TestInterface testInterface = new TestInterface(factory);
+ setInterface(testInterface);
+
+ TestInterface testCallbackInterface = new TestInterface(factory);
+ setCallbackInterface(testCallbackInterface);
+
+ }
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java b/branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java
new file mode 100644
index 0000000000..460672c1ef
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java
@@ -0,0 +1,31 @@
+/*
+ * 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.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
+
+/**
+ * A test operation model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestOperation extends OperationImpl implements Operation {
+
+}
diff --git a/branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderTestCase.java b/branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderTestCase.java
new file mode 100644
index 0000000000..aeb076a392
--- /dev/null
+++ b/branches/sca-java-0.91/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderTestCase.java
@@ -0,0 +1,135 @@
+/*
+ * 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 javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Component;
+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.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.assembly.DefaultSCABindingFactory;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl;
+
+public class CompositeBuilderTestCase extends TestCase {
+
+ private CompositeBuilderImpl compositeUtil;
+ private AssemblyFactory assemblyFactory;
+ private SCABindingFactory scaBindingFactory;
+
+ protected void setUp() throws Exception {
+ assemblyFactory = new DefaultAssemblyFactory();
+ scaBindingFactory = new DefaultSCABindingFactory();
+
+ compositeUtil = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, new InterfaceContractMapperImpl(), null);
+ }
+
+ protected void tearDown() throws Exception {
+ compositeUtil = null;
+ assemblyFactory = null;
+ }
+
+ public void testFuseIncludes() {
+ Composite c1 = assemblyFactory.createComposite();
+ c1.setName(new QName("http://foo", "C1"));
+ Component a = assemblyFactory.createComponent();
+ a.setName("a");
+ c1.getComponents().add(a);
+ CompositeService s = assemblyFactory.createCompositeService();
+ s.setName("s");
+ c1.getServices().add(s);
+ CompositeReference r = assemblyFactory.createCompositeReference();
+ r.setName("r");
+ c1.getReferences().add(r);
+
+ Composite c2 = assemblyFactory.createComposite();
+ c2.setName(new QName("http://foo", "C2"));
+ c1.getIncludes().add(c2);
+ Component b = assemblyFactory.createComponent();
+ b.setName("b");
+ c2.getComponents().add(b);
+
+ Composite c = assemblyFactory.createComposite();
+ c.setName(new QName("http://foo", "C"));
+ c.getIncludes().add(c1);
+
+ compositeUtil.fuseIncludes(c);
+
+ assertTrue(c.getComponents().get(0).getName().equals("a"));
+ assertTrue(c.getComponents().get(1).getName().equals("b"));
+ assertTrue(c.getServices().get(0).getName().equals("s"));
+ assertTrue(c.getReferences().get(0).getName().equals("r"));
+ }
+
+ public void testExpandComposites() {
+ Composite c1 = assemblyFactory.createComposite();
+ c1.setName(new QName("http://foo", "C1"));
+ Component a = assemblyFactory.createComponent();
+ a.setName("a");
+ c1.getComponents().add(a);
+ CompositeService s = assemblyFactory.createCompositeService();
+ s.setName("s");
+ c1.getServices().add(s);
+ CompositeReference r = assemblyFactory.createCompositeReference();
+ r.setName("r");
+ c1.getReferences().add(r);
+
+ Composite c2 = assemblyFactory.createComposite();
+ c2.setName(new QName("http://foo", "C2"));
+ Component b = assemblyFactory.createComponent();
+ b.setName("b");
+ c2.getComponents().add(b);
+
+ Composite c = assemblyFactory.createComposite();
+ c.setName(new QName("http://foo", "C"));
+ Component x = assemblyFactory.createComponent();
+ x.setName("x");
+ x.setImplementation(c1);
+ c.getComponents().add(x);
+ Component y = assemblyFactory.createComponent();
+ y.setName("y");
+ y.setImplementation(c2);
+ c.getComponents().add(y);
+ Component z = assemblyFactory.createComponent();
+ z.setName("z");
+ z.setImplementation(c1);
+ c.getComponents().add(z);
+
+ compositeUtil.expandComposites(c);
+
+ assertTrue(c.getComponents().get(0).getImplementation() != c1);
+ assertTrue(c.getComponents().get(1).getImplementation() != c2);
+ assertTrue(c.getComponents().get(2).getImplementation() != c1);
+
+ Composite i = (Composite)c.getComponents().get(0).getImplementation();
+ assertTrue(i.getComponents().get(0) != a);
+ assertTrue(i.getComponents().get(0).getName().equals("a"));
+ assertTrue(i.getServices().get(0).getName().equals("s"));
+ assertTrue(i.getServices().get(0) != s);
+ assertTrue(i.getReferences().get(0).getName().equals("r"));
+ assertTrue(i.getReferences().get(0) != r);
+ }
+
+}