diff options
Diffstat (limited to 'branches/sca-java-0.91/modules/host-embedded')
33 files changed, 0 insertions, 3470 deletions
diff --git a/branches/sca-java-0.91/modules/host-embedded/.checkstyle b/branches/sca-java-0.91/modules/host-embedded/.checkstyle deleted file mode 100644 index ea05637a07..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/.checkstyle +++ /dev/null @@ -1,24 +0,0 @@ -<?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/host-embedded/.pmd b/branches/sca-java-0.91/modules/host-embedded/.pmd deleted file mode 100644 index aa1ce3e754..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/.pmd +++ /dev/null @@ -1,21 +0,0 @@ -<?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/host-embedded/.ruleset b/branches/sca-java-0.91/modules/host-embedded/.ruleset deleted file mode 100644 index a7ff3be272..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/.ruleset +++ /dev/null @@ -1,190 +0,0 @@ -<?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/host-embedded/DISCLAIMER b/branches/sca-java-0.91/modules/host-embedded/DISCLAIMER deleted file mode 100644 index d68a410903..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/DISCLAIMER +++ /dev/null @@ -1,8 +0,0 @@ -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/host-embedded/LICENSE b/branches/sca-java-0.91/modules/host-embedded/LICENSE deleted file mode 100644 index 8aa906c321..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/LICENSE +++ /dev/null @@ -1,205 +0,0 @@ - - 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/host-embedded/NOTICE b/branches/sca-java-0.91/modules/host-embedded/NOTICE deleted file mode 100644 index 94481d6cfa..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/NOTICE +++ /dev/null @@ -1,6 +0,0 @@ -${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/host-embedded/pom.xml b/branches/sca-java-0.91/modules/host-embedded/pom.xml deleted file mode 100644 index e4a59f4428..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ -<?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-host-embedded</artifactId> - <name>Apache Tuscany Embedded Runtime Host</name> - - <dependencies> - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-core</artifactId> - <version>0.91-incubating-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-assembly-xml</artifactId> - <version>0.91-incubating-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-contribution-impl</artifactId> - <version>0.91-incubating-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-interface-java-runtime</artifactId> - <version>0.91-incubating-SNAPSHOT</version> - <scope>runtime</scope> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-interface-wsdl-runtime</artifactId> - <version>0.91-incubating-SNAPSHOT</version> - <scope>runtime</scope> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-core-databinding</artifactId> - <version>0.91-incubating-SNAPSHOT</version> - <scope>runtime</scope> - </dependency> - - </dependencies> -</project> diff --git a/branches/sca-java-0.91/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java b/branches/sca-java-0.91/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java deleted file mode 100644 index dac8d6ce7b..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.host.embedded; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.lang.reflect.Constructor; -import java.security.AccessController; -import java.security.PrivilegedAction; - -import org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain; -import org.osoa.sca.CallableReference; -import org.osoa.sca.ServiceReference; -import org.osoa.sca.ServiceRuntimeException; - -/** - * A handle to an SCA domain. - * - * @version $Rev$ $Date$ - */ -public abstract class SCADomain { - - final static String LOCAL_DOMAIN_URI = "http://localhost"; - - /** - * Static variable to hold the most recent instance of SCADomain - */ - // TODO: Temporary support for SCADomain.connect() API - private static SCADomain theDomain; - - - /** - * Returns a new instance of a local SCA domain. - * - * @return - */ - public static SCADomain newInstance() { - return createNewInstance(LOCAL_DOMAIN_URI, null); - } - - /** - * Returns a new instance of a local SCA domain. The specified deployable - * composite will be included in the SCA domain. - * - * @param composite the deployable composite to include in the SCA domain. - * @return - */ - public static SCADomain newInstance(String composite) { - return createNewInstance(LOCAL_DOMAIN_URI, "/", composite); - } - - /** - * Returns a new instance of a local SCA domain. The specified deployable - * composites will be included in the SCA domain. - * - * @param domainURI the URI of the SCA domain - * @param contributionLocation the location of an SCA contribution - * @param composites the deployable composites to include in the SCA domain. - * @return - */ - public static SCADomain newInstance(String domainURI, String contributionLocation, String... composites) { - return createNewInstance(domainURI, contributionLocation, composites); - } - - /** - * Removes the specified local SCA Domain instance - * - * @param domainInstance the instance to be removed - */ - // FIXME: Adding this as temporary support for the "connect" API - public static void removeInstance(SCADomain domainInstance) { - theDomain = null; - } - - /** - * Returns an SCADomain representing a remote SCA domain. - * - * @param domainURI the URI of the SCA domain - * @return - */ - // FIXME : this is a temporary implementation to get the capability working - public static SCADomain connect(String domainURI) { - return theDomain; - } - - /** - * Close the SCA domain. - */ - public void close() { - // TODO: temporary to support initial SCADomain.connect capability - SCADomain.removeInstance(this); - } - - /** - * Returns the URI of the SCA Domain. - * - * @return the URI of the SCA Domain - */ - public abstract String getURI(); - - /** - * Cast a type-safe reference to a CallableReference. Converts a type-safe - * reference to an equivalent CallableReference; if the target refers to a - * service then a ServiceReference will be returned, if the target refers to - * a callback then a CallableReference will be returned. - * - * @param target a reference proxy provided by the SCA runtime - * @param <B> the Java type of the business interface for the reference - * @param <R> the type of reference to be returned - * @return a CallableReference equivalent for the proxy - * @throws IllegalArgumentException if the supplied instance is not a - * reference supplied by the SCA runtime - */ - public abstract <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException; - - /** - * Returns a proxy for a service provided by a component in the SCA domain. - * - * @param businessInterface the interface that will be used to invoke the - * service - * @param serviceName the name of the service - * @param <B> the Java type of the business interface for the service - * @return an object that implements the business interface - */ - public abstract <B> B getService(Class<B> businessInterface, String serviceName); - - /** - * Returns a ServiceReference for a service provided by a component in the - * SCA domain. - * - * @param businessInterface the interface that will be used to invoke the - * service - * @param serviceName the name of the service - * @param <B> the Java type of the business interface for the service - * @return a ServiceReference for the designated service - */ - public abstract <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName); - - /** - * Read the service name from a configuration file - * - * @param classLoader - * @param name The name of the service class - * @return A class name which extends/implements the service class - * @throws IOException - */ - private static String getServiceName(ClassLoader classLoader, String name) throws IOException { - InputStream is = classLoader.getResourceAsStream("META-INF/services/" + name); - if (is == null) { - return null; - } - BufferedReader reader = null; - try { - reader = new BufferedReader(new InputStreamReader(is)); - while (true) { - String line = reader.readLine(); - if (line == null) { - break; - } else if (!line.startsWith("#")) { - return line.trim(); - } - } - } finally { - if (reader != null) { - reader.close(); - } - } - return null; - } - - /** - * Returns an SCADomain instance. If the system property - * "org.apache.tuscany.sca.host.embedded.SCADomain" is set, its value is used as - * the name of the implementation class. Otherwise, if the resource - * "META-INF/services/org.apache.tuscany.sca.host.embedded.SCADomain" can be - * loaded from the supplied classloader. Otherwise, it will use - * "org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain" as the default. - * The named class is loaded from the supplied classloader. - * - * @param classLoader - * @param domainURI - * @param contributionLocation - * @param composites - * @return - */ - static SCADomain createNewInstance(String domainURI, String contributionLocation, String... composites) { - - SCADomain domain = null; - - try { - // Determine the runtime and application classloader - final ClassLoader runtimeClassLoader = SCADomain.class.getClassLoader(); - final ClassLoader applicationClassLoader = Thread.currentThread().getContextClassLoader(); - - // Discover the SCADomain implementation - final String name = SCADomain.class.getName(); - String className = AccessController.doPrivileged(new PrivilegedAction<String>() { - public String run() { - return System.getProperty(name); - } - }); - - if (className == null) { - className = getServiceName(runtimeClassLoader, name); - } - - if (className == null) { - - // Create a default SCA domain implementation - domain = - new DefaultSCADomain(runtimeClassLoader, - applicationClassLoader, - domainURI, - contributionLocation, - composites); - } else { - - // Create an instance of the discovered SCA domain implementation - Class cls = Class.forName(className, true, runtimeClassLoader); - Constructor<?> constructor = null; - try { - constructor = cls.getConstructor(ClassLoader.class, ClassLoader.class, - String.class, String.class, String[].class); - } catch (NoSuchMethodException e) {} - if (constructor != null) { - domain = (SCADomain)constructor.newInstance(runtimeClassLoader, - applicationClassLoader, - domainURI, - contributionLocation, - composites); - } else { - - constructor = cls.getConstructor(ClassLoader.class, String.class); - domain = (SCADomain)constructor.newInstance(runtimeClassLoader, domainURI); - } - } - - // FIXME: temporary support for connect() API - theDomain = domain; - - return domain; - - } catch (Exception e) { - throw new ServiceRuntimeException(e); - } - } - -} diff --git a/branches/sca-java-0.91/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomainBean.java b/branches/sca-java-0.91/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomainBean.java deleted file mode 100644 index 5dd3803ed2..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomainBean.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.host.embedded; - -import org.osoa.sca.CallableReference; -import org.osoa.sca.ServiceReference; - -public class SCADomainBean extends SCADomain { - - private SCADomain instance; - - private String uri = LOCAL_DOMAIN_URI; - private String location = "/"; - private String[] composites; - - /** - * Constructs a new SCA domain - */ - public SCADomainBean() { - } - - public String getURI() { - return uri; - } - - public void setURI(String uri) { - this.uri = uri; - } - - public void setContributionLocation(String contributionLocation) { - this.location = contributionLocation; - } - - public String getContributionLocation() { - return location; - } - - public void setDeployableComposite(String composite) { - setDeployableComposites(composite); - } - - public void setDeployableComposites(String... composites) { - this.composites = composites; - } - - public String[] getDeployableComposites() { - return composites; - } - - @SuppressWarnings("unchecked") - @Override - public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException { - if (instance == null) { - instance = SCADomain.createNewInstance(uri, location, composites); - } - Object result = instance.cast(target); - return (R) result; - } - - @Override - public void close() { - if (instance == null) { - instance = SCADomain.createNewInstance(uri, location, composites); - } - instance.close(); - instance = null; - } - - @Override - public <B> B getService(Class<B> businessInterface, String serviceName) { - if (instance == null) { - instance = SCADomain.createNewInstance(uri, location, composites); - } - return instance.getService(businessInterface, serviceName); - } - - @Override - public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName) { - if (instance == null) { - instance = SCADomain.createNewInstance(uri, location, composites); - } - return instance.getServiceReference(businessInterface, referenceName); - } - - @Override - protected void finalize() throws Throwable { - - // Make sure that the SCA domain is closed - if (instance != null) { - instance.close(); - instance = null; - } - } -} diff --git a/branches/sca-java-0.91/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCATestCaseRunner.java b/branches/sca-java-0.91/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCATestCaseRunner.java deleted file mode 100644 index c133bad38e..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCATestCaseRunner.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.host.embedded; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.net.URL; -import java.net.URLClassLoader; - -/** - * A helper class that can be used to run an SCA JUnit test case. The test case will run in an isolated class loader. - * - * @version $Rev$ $Date$ - */ -public class SCATestCaseRunner { - - private ClassLoader classLoader; - private Class<?> testSuiteClass; - private Object testSuite; - private Class<?> testResultClass; - private Class<?> testCaseClass; - private Object testCase; - - private Class<?> beforeAnnotation; - private Class<?> beforeClassAnnotation; - private Class<?> afterAnnotation; - private Class<?> afterClassAnnotation; - private Class<?> junit4AdapterClass; - private Class<?> junit3TestCaseClass; - - /** - * Constructs a new TestCase runner. - * - * @param testClass - */ - public SCATestCaseRunner(Class testClass) { - try { - classLoader = (URLClassLoader)testClass.getClassLoader(); - if (classLoader instanceof URLClassLoader) { - URL[] urls = ((URLClassLoader)classLoader).getURLs(); - classLoader = new URLClassLoader(urls, classLoader.getParent()); - } else { - classLoader = new URLClassLoader(new URL[0], classLoader); - } - - ClassLoader tccl = Thread.currentThread().getContextClassLoader(); - try { - Thread.currentThread().setContextClassLoader(classLoader); - - testCaseClass = Class.forName(testClass.getName(), true, classLoader); - testCase = testCaseClass.newInstance(); - - junit3TestCaseClass = Class.forName("junit.framework.TestCase", true, classLoader); - - testSuiteClass = Class.forName("junit.framework.TestSuite", true, classLoader); - Constructor testSuiteConstructor = testSuiteClass.getConstructor(Class.class); - testSuite = testSuiteConstructor.newInstance(testCaseClass); - - testResultClass = Class.forName("junit.framework.TestResult", true, classLoader); - - try { - beforeAnnotation = Class.forName("org.junit.Before", true, classLoader); - afterAnnotation = Class.forName("org.junit.After", true, classLoader); - beforeClassAnnotation = Class.forName("org.junit.BeforeClass", true, classLoader); - afterClassAnnotation = Class.forName("org.junit.AfterClass", true, classLoader); - junit4AdapterClass = Class.forName("junit.framework.JUnit4TestAdapter", true, classLoader); - } catch (Exception e) { - // Unexpected - throw new AssertionError(e); - } - - } finally { - Thread.currentThread().setContextClassLoader(tccl); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * Run the test case - */ - public void run() { - ClassLoader tccl = Thread.currentThread().getContextClassLoader(); - try { - Thread.currentThread().setContextClassLoader(classLoader); - - if (junit3TestCaseClass.isAssignableFrom(testCaseClass)) { - Object testResult = testResultClass.newInstance(); - Method runMethod = testSuiteClass.getMethod("run", testResultClass); - runMethod.invoke(testSuite, testResult); - } else { - Object junit4Adapter = junit4AdapterClass.getConstructor(Class.class).newInstance(testCaseClass); - Object testResult = testResultClass.newInstance(); - Method runMethod = junit4AdapterClass.getMethod("run", testResultClass); - runMethod.invoke(junit4Adapter, testResult); - } - } catch (Exception e) { - throw new RuntimeException(e); - } finally { - Thread.currentThread().setContextClassLoader(tccl); - } - } - - /** - * Invoke the setUp method - */ - public void setUp() { - execute("setUp"); - } - - /** - * Invoke the before methods - */ - public void before() { - execute(beforeAnnotation); - } - - /** - * Invoke the beforeClass methods - */ - public void beforeClass() { - execute(beforeClassAnnotation); - } - - /** - * Invoke the tearDown method - */ - public void tearDown() { - execute("tearDown"); - } - - /** - * Invoke the after methods - */ - public void after() { - execute(afterAnnotation); - } - - /** - * Invoke the afterClass methods - */ - public void afterClass() { - execute(afterClassAnnotation); - } - - /** - * Invoke the specified test method. - */ - public void run(String methodName) { - execute(methodName); - } - - /** - * Invoke the methods annotated with the specified annotation. - */ - private void execute(Class<?> annotationClass) { - if (annotationClass == null) { - throw new RuntimeException(new NoSuchMethodException()); - } - ClassLoader tccl = Thread.currentThread().getContextClassLoader(); - try { - Thread.currentThread().setContextClassLoader(classLoader); - - for (Method method : testCaseClass.getDeclaredMethods()) { - for (Annotation annotation : method.getAnnotations()) { - if (annotation.annotationType() == annotationClass) { - method.invoke(testCase); - } - } - } - } catch (Exception e) { - throw new RuntimeException(e); - } finally { - Thread.currentThread().setContextClassLoader(tccl); - } - } - - /** - * Invoke the specified method - */ - private void execute(String methodName) { - ClassLoader tccl = Thread.currentThread().getContextClassLoader(); - try { - Thread.currentThread().setContextClassLoader(classLoader); - Method setUpMethod = testCaseClass.getDeclaredMethod(methodName); - setUpMethod.setAccessible(true); - setUpMethod.invoke(testCase); - } catch (Exception e) { - throw new RuntimeException(e); - } finally { - Thread.currentThread().setContextClassLoader(tccl); - } - } - -} diff --git a/branches/sca-java-0.91/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomain.java b/branches/sca-java-0.91/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomain.java deleted file mode 100644 index 1db2aecc26..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomain.java +++ /dev/null @@ -1,351 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.host.embedded.impl; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.CompositeService; -import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.contribution.Contribution; -import org.apache.tuscany.sca.contribution.DeployedArtifact; -import org.apache.tuscany.sca.contribution.resolver.impl.ModelResolverImpl; -import org.apache.tuscany.sca.contribution.service.ContributionException; -import org.apache.tuscany.sca.contribution.service.ContributionService; -import org.apache.tuscany.sca.contribution.service.util.FileHelper; -import org.apache.tuscany.sca.core.runtime.ActivationException; -import org.apache.tuscany.sca.core.runtime.CompositeActivator; -import org.apache.tuscany.sca.host.embedded.SCADomain; -import org.osoa.sca.CallableReference; -import org.osoa.sca.ComponentContext; -import org.osoa.sca.Constants; -import org.osoa.sca.ServiceReference; -import org.osoa.sca.ServiceRuntimeException; - -/** - * A default SCA domain facade implementation. - * - * @version $Rev$ $Date$ - */ -public class DefaultSCADomain extends SCADomain { - - private String uri; - private String location; - private String[] composites; - private Composite domainComposite; - private Contribution contribution; - private Map<String, Component> components = new HashMap<String, Component>(); - private ReallySmallRuntime runtime; - - /** - * Constructs a new domain facade. - * - * @param domainURI - * @param contributionLocation - * @param composites - */ - public DefaultSCADomain(ClassLoader runtimeClassLoader, - ClassLoader applicationClassLoader, - String domainURI, - String contributionLocation, - String... composites) { - this.uri = domainURI; - this.location = contributionLocation; - this.composites = composites; - - // Create and start the runtime - runtime = new ReallySmallRuntime(runtimeClassLoader); - try { - runtime.start(); - - } catch (ActivationException e) { - throw new ServiceRuntimeException(e); - } - - // Contribute the given contribution to an in-memory repository - ContributionService contributionService = runtime.getContributionService(); - URL contributionURL; - try { - contributionURL = getContributionLocation(applicationClassLoader, location, this.composites); - } catch (MalformedURLException e) { - throw new ServiceRuntimeException(e); - } - - try { - ModelResolverImpl modelResolver = new ModelResolverImpl(applicationClassLoader); - String contributionURI = FileHelper.getName(contributionURL.getPath()); - contribution = contributionService.contribute(contributionURI, contributionURL, modelResolver, false); - } catch (ContributionException e) { - throw new ServiceRuntimeException(e); - } catch (IOException e) { - throw new ServiceRuntimeException(e); - } - - // Create an in-memory domain level composite - AssemblyFactory assemblyFactory = runtime.getAssemblyFactory(); - domainComposite = assemblyFactory.createComposite(); - domainComposite.setName(new QName(Constants.SCA_NS, "domain")); - domainComposite.setURI(domainURI); - - //when the deployable composites were specified when initializing the runtime - if (composites != null && composites.length > 0 && composites[0].length() > 0) { - // Include all specified deployable composites in the SCA domain - Map<String, Composite> compositeArtifacts = new HashMap<String, Composite>(); - for (DeployedArtifact artifact : contribution.getArtifacts()) { - if (artifact.getModel() instanceof Composite) { - compositeArtifacts.put(artifact.getURI(), (Composite)artifact.getModel()); - } - } - for (String compositePath : composites) { - Composite composite = compositeArtifacts.get(compositePath); - if (composite == null) { - throw new ServiceRuntimeException("Composite not found: " + compositePath); - } - domainComposite.getIncludes().add(composite); - } - } else { - // in this case, a sca-contribution.xml should have been specified - for(Composite composite : contribution.getDeployables()) { - domainComposite.getIncludes().add(composite); - } - - } - - - // Activate and start the SCA domain composite - CompositeActivator compositeActivator = runtime.getCompositeActivator(); - try { - compositeActivator.activate(domainComposite); - compositeActivator.start(domainComposite); - } catch (ActivationException e) { - throw new ServiceRuntimeException(e); - } - - // Index the top level components - for (Component component : domainComposite.getComponents()) { - components.put(component.getName(), component); - } - } - - @Override - public void close() { - - super.close(); - - // Remove the contribution from the in-memory repository - ContributionService contributionService = runtime.getContributionService(); - try { - contributionService.remove(contribution.getURI()); - } catch (ContributionException e) { - throw new ServiceRuntimeException(e); - } - - // Stop the SCA domain composite - CompositeActivator compositeActivator = runtime.getCompositeActivator(); - try { - compositeActivator.stop(domainComposite); - } catch (ActivationException e) { - throw new ServiceRuntimeException(e); - - } - - // Stop the runtime - try { - runtime.stop(); - } catch (ActivationException e) { - throw new ServiceRuntimeException(e); - } - } - - /** - * Determine the location of a contribution, given a contribution path and a - * list of composites. - * - * @param contributionPath - * @param composites - * @param classLoader - * @return - * @throws MalformedURLException - */ - private URL getContributionLocation(ClassLoader classLoader, String contributionPath, String[] composites) - throws MalformedURLException { - if (contributionPath != null && contributionPath.length() > 0) { - URI contributionURI = URI.create(contributionPath); - if (contributionURI.isAbsolute() || composites.length == 0) { - return new URL(contributionPath); - } - } - - String contributionArtifactPath = null; - URL contributionArtifactURL = null; - if (composites != null && composites.length > 0 && composites[0].length() > 0) { - - // Here the SCADomain was started with a reference to a composite file - contributionArtifactPath = composites[0]; - contributionArtifactURL = classLoader.getResource(contributionArtifactPath); - if (contributionArtifactURL == null) { - throw new IllegalArgumentException("Composite not found: " + contributionArtifactPath); - } - } else { - - // Here the SCADomain was started without any reference to a composite file - // We are going to look for an sca-contribution.xml or sca-contribution-generated.xml - - // Look for META-INF/sca-contribution.xml - contributionArtifactPath = Contribution.SCA_CONTRIBUTION_META; - contributionArtifactURL = classLoader.getResource(contributionArtifactPath); - - // Look for META-INF/sca-contribution-generated.xml - if( contributionArtifactURL == null ) { - contributionArtifactPath = Contribution.SCA_CONTRIBUTION_GENERATED_META; - contributionArtifactURL = classLoader.getResource(contributionArtifactPath); - } - - // Look for META-INF/sca-deployables directory - if (contributionArtifactURL == null) { - contributionArtifactPath = Contribution.SCA_CONTRIBUTION_DEPLOYABLES; - contributionArtifactURL = classLoader.getResource(contributionArtifactPath); - } - } - - if (contributionArtifactURL == null) { - throw new IllegalArgumentException("Can't determine contribution deployables. Either specify a composite file, or use an sca-contribution.xml file to specify the deployables."); - } - - URL contributionURL = null; - // "jar:file://....../something.jar!/a/b/c/app.composite" - try { - String url = contributionArtifactURL.toExternalForm(); - String protocol = contributionArtifactURL.getProtocol(); - if ("file".equals(protocol)) { - // directory contribution - if (url.endsWith(contributionArtifactPath)) { - String location = url.substring(0, url.lastIndexOf(contributionArtifactPath)); - // workaround from evil url/uri form maven - contributionURL = FileHelper.toFile(new URL(location)).toURI().toURL(); - } - - } else if ("jar".equals(protocol)) { - // jar contribution - String location = url.substring(4, url.lastIndexOf("!/")); - // workaround for evil url/uri from maven - contributionURL = FileHelper.toFile(new URL(location)).toURI().toURL(); - } - } catch (MalformedURLException mfe) { - throw new IllegalArgumentException(mfe); - } - - return contributionURL; - } - - @Override - public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException { - // TODO Auto-generated method stub - return null; - } - - @Override - public <B> B getService(Class<B> businessInterface, String serviceName) { - ServiceReference<B> serviceReference = getServiceReference(businessInterface, serviceName); - if (serviceReference == null) { - throw new ServiceRuntimeException("Service not found: " + serviceName); - } - return serviceReference.getService(); - } - - @Override - public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String name) { - - // Extract the component name - String componentName; - String serviceName; - int i = name.indexOf('/'); - if (i != -1) { - componentName = name.substring(0, i); - serviceName = name.substring(i + 1); - - } else { - componentName = name; - serviceName = null; - } - - // Lookup the component in the domain - Component component = components.get(componentName); - if (component == null) { - throw new ServiceRuntimeException("Component not found: " + componentName); - } - ComponentContext componentContext = null; - - // If the component is a composite, then we need to find the - // non-composite - // component that provides the requested service - if (component.getImplementation() instanceof Composite) { - ComponentService promotedService = null; - for (ComponentService componentService : component.getServices()) { - if (serviceName == null || serviceName.equals(componentService.getName())) { - - CompositeService compositeService = (CompositeService)componentService.getService(); - if (compositeService != null) { - promotedService = compositeService.getPromotedService(); - SCABinding scaBinding = promotedService.getBinding(SCABinding.class); - if (scaBinding != null) { - Component promotedComponent = scaBinding.getComponent(); - if (serviceName != null) { - serviceName = "$promoted$." + serviceName; - } - componentContext = (ComponentContext)promotedComponent; - } - } - break; - } - } - if (componentContext == null) { - throw new ServiceRuntimeException("Composite service not found: " + name); - } - } else { - componentContext = (ComponentContext)component; - } - - ServiceReference<B> serviceReference; - if (serviceName != null) { - serviceReference = componentContext.createSelfReference(businessInterface, serviceName); - } else { - serviceReference = componentContext.createSelfReference(businessInterface); - } - return serviceReference; - - } - - @Override - public String getURI() { - return uri; - } - -} diff --git a/branches/sca-java-0.91/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java b/branches/sca-java-0.91/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java deleted file mode 100644 index f6d5d8377b..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.host.embedded.impl; - -import java.util.HashMap; -import java.util.Map; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.CompositeService; -import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.contribution.service.ContributionService; -import org.apache.tuscany.sca.core.runtime.ActivationException; -import org.apache.tuscany.sca.core.runtime.CompositeActivator; -import org.apache.tuscany.sca.host.embedded.SCADomain; -import org.osoa.sca.CallableReference; -import org.osoa.sca.ComponentContext; -import org.osoa.sca.Constants; -import org.osoa.sca.ServiceReference; -import org.osoa.sca.ServiceRuntimeException; - -/** - * An SCA domain facade implementation. - * - * @version $Rev$ $Date$ - */ -public class EmbeddedSCADomain extends SCADomain { - - private String uri; - private Composite domainComposite; - private ReallySmallRuntime runtime; - private Map<String, Component> components = new HashMap<String, Component>(); - private DomainCompositeHelper domainCompositeHelper; - - public class DomainCompositeHelper { - - /** - * Add a composite to the domain - * @param composite - * @return - */ - public Composite addComposite(Composite composite) throws ActivationException { - domainComposite.getIncludes().add(composite); - //CompositeActivator compositeActivator = runtime.getCompositeActivator(); - //compositeActivator.activate(composite); - //for (Component component : composite.getComponents()) { - // components.put(component.getName(), component); - //} - return composite; - } - - /** - * Remove a composite from the domain - * @param composite - * @throws ActivationException - */ - public void removeComposite(Composite composite) throws ActivationException { - CompositeActivator compositeActivator = runtime.getCompositeActivator(); - compositeActivator.deactivate(composite); - domainComposite.getIncludes().remove(composite); - for (Component component : composite.getComponents()) { - components.remove(component.getName()); - } - } - - /** - * Start a composite - * @deprecated - * @param composite - * @throws ActivationException - */ - public void startComposite(Composite composite) throws ActivationException { - CompositeActivator compositeActivator = runtime.getCompositeActivator(); - compositeActivator.start(composite); - } - - /** - * Stop a composite - * @deprecated - * @param composite - * @throws ActivationException - */ - public void stopComposite(Composite composite) throws ActivationException { - CompositeActivator compositeActivator = runtime.getCompositeActivator(); - compositeActivator.stop(composite); - } - - /** - * Get a reference to a component by name - * @param componentName - * @return - */ - public Component getComponent(String componentName){ - return (Component) components.get(componentName); - } - - /** - * Start a component - * @param component - * @throws ActivationException - */ - public void startComponent(Component component) throws ActivationException { - CompositeActivator compositeActivator = runtime.getCompositeActivator(); - compositeActivator.start(component); - } - - /** - * Stop a component - * @param component - * @throws ActivationException - */ - public void stopComponent(Component component) throws ActivationException { - CompositeActivator compositeActivator = runtime.getCompositeActivator(); - compositeActivator.stop(component); - } - - /** - * Activate SCA Domain - * @throws ActivationException - */ - public void activateDomain() throws ActivationException { - CompositeActivator compositeActivator = runtime.getCompositeActivator(); - compositeActivator.activate(domainComposite); - for (Component component : domainComposite.getComponents()) { - components.put(component.getName(), component); - } - - } - } - - /** - * Constructs a new domain facade. - * - * @param runtimeClassLoader - * @param domainURI - */ - public EmbeddedSCADomain(ClassLoader runtimeClassLoader, - String domainURI) { - this.uri = domainURI; - - // Create a runtime - runtime = new ReallySmallRuntime(runtimeClassLoader); - } - - public void start() throws ActivationException { - - // Start the runtime - runtime.start(); - - // Create an in-memory domain level composite - AssemblyFactory assemblyFactory = runtime.getAssemblyFactory(); - domainComposite = assemblyFactory.createComposite(); - domainComposite.setName(new QName(Constants.SCA_NS, "domain")); - domainComposite.setURI(uri); - - // Create a domain composite helper - domainCompositeHelper = new DomainCompositeHelper(); - } - - public void stop() throws ActivationException { - - // Stop the runtime - runtime.stop(); - - // Cleanup - domainComposite = null; - domainCompositeHelper = null; - } - - public ContributionService getContributionService() { - return runtime.getContributionService(); - } - - public DomainCompositeHelper getDomainCompositeHelper() { - return domainCompositeHelper; - } - - @Override - public void close() { - super.close(); - } - - @Override - public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException { - // TODO Auto-generated method stub - return null; - } - - @Override - public <B> B getService(Class<B> businessInterface, String serviceName) { - ServiceReference<B> serviceReference = getServiceReference(businessInterface, serviceName); - if (serviceReference == null) { - throw new ServiceRuntimeException("Service not found: " + serviceName); - } - return serviceReference.getService(); - } - - @Override - public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String name) { - - // Extract the component name - String componentName; - String serviceName; - int i = name.indexOf('/'); - if (i != -1) { - componentName = name.substring(0, i); - serviceName = name.substring(i + 1); - - } else { - componentName = name; - serviceName = null; - } - - // Lookup the component in the domain - Component component = components.get(componentName); - if (component == null) { - throw new ServiceRuntimeException("Component not found: " + componentName); - } - ComponentContext componentContext = null; - - // If the component is a composite, then we need to find the - // non-composite - // component that provides the requested service - if (component.getImplementation() instanceof Composite) { - ComponentService promotedService = null; - for (ComponentService componentService : component.getServices()) { - if (serviceName == null || serviceName.equals(componentService.getName())) { - - CompositeService compositeService = (CompositeService)componentService.getService(); - if (compositeService != null) { - promotedService = compositeService.getPromotedService(); - SCABinding scaBinding = promotedService.getBinding(SCABinding.class); - if (scaBinding != null) { - Component promotedComponent = scaBinding.getComponent(); - if (serviceName != null) { - serviceName = "$promoted$." + serviceName; - } - componentContext = (ComponentContext)promotedComponent; - } - } - break; - } - } - if (componentContext == null) { - throw new ServiceRuntimeException("Composite service not found: " + name); - } - } else { - componentContext = (ComponentContext)component; - } - - ServiceReference<B> serviceReference; - if (serviceName != null) { - serviceReference = componentContext.createSelfReference(businessInterface, serviceName); - } else { - serviceReference = componentContext.createSelfReference(businessInterface); - } - return serviceReference; - - } - - @Override - public String getURI() { - return uri; - } - -} diff --git a/branches/sca-java-0.91/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java b/branches/sca-java-0.91/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java deleted file mode 100644 index dd25585d73..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.host.embedded.impl; - -import java.util.List; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.DefaultSCABindingFactory; -import org.apache.tuscany.sca.assembly.SCABindingFactory; -import org.apache.tuscany.sca.contribution.ContributionFactory; -import org.apache.tuscany.sca.contribution.impl.ContributionFactoryImpl; -import org.apache.tuscany.sca.contribution.service.ContributionService; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.DefaultModelFactoryExtensionPoint; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.core.ModuleActivator; -import org.apache.tuscany.sca.core.invocation.MessageFactoryImpl; -import org.apache.tuscany.sca.core.invocation.ProxyFactory; -import org.apache.tuscany.sca.core.runtime.ActivationException; -import org.apache.tuscany.sca.core.runtime.CompositeActivator; -import org.apache.tuscany.sca.core.runtime.RuntimeAssemblyFactory; -import org.apache.tuscany.sca.core.work.ThreadPoolWorkManager; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl; -import org.apache.tuscany.sca.invocation.MessageFactory; -import org.apache.tuscany.sca.policy.DefaultPolicyFactory; -import org.apache.tuscany.sca.policy.PolicyFactory; -import org.apache.tuscany.sca.scope.ScopeRegistry; - -public class ReallySmallRuntime { - - private List<ModuleActivator> modules; - private ExtensionPointRegistry registry; - - private ClassLoader classLoader; - private AssemblyFactory assemblyFactory; - private ContributionService contributionService; - private CompositeActivator compositeActivator; - private ThreadPoolWorkManager workManager; - private ScopeRegistry scopeRegistry; - - public ReallySmallRuntime(ClassLoader classLoader) { - this.classLoader = classLoader; - } - - public void start() throws ActivationException { - - // Create our extension point registry - registry = new DefaultExtensionPointRegistry(); - - // Create a work manager - workManager = new ThreadPoolWorkManager(10); - - // Create an interface contract mapper - InterfaceContractMapper mapper = new InterfaceContractMapperImpl(); - - // Create factory extension point - ModelFactoryExtensionPoint factories = new DefaultModelFactoryExtensionPoint(); - registry.addExtensionPoint(factories); - - // Create Message factory - MessageFactory messageFactory = new MessageFactoryImpl(); - factories.addFactory(messageFactory); - - // Create a proxy factory - ProxyFactory proxyFactory = ReallySmallRuntimeBuilder.createProxyFactory(registry, mapper, messageFactory); - - // Create model factories - assemblyFactory = new RuntimeAssemblyFactory(mapper, proxyFactory); - factories.addFactory(assemblyFactory); - PolicyFactory policyFactory = new DefaultPolicyFactory(); - factories.addFactory(policyFactory); - SCABindingFactory scaBindingFactory = new DefaultSCABindingFactory(); - factories.addFactory(scaBindingFactory); - ContributionFactory contributionFactory = new ContributionFactoryImpl(); - factories.addFactory(contributionFactory); - - // Create a contribution service - contributionService = ReallySmallRuntimeBuilder.createContributionService(registry, - contributionFactory, - assemblyFactory, - policyFactory, - mapper); - - // Create the ScopeRegistry - scopeRegistry = ReallySmallRuntimeBuilder.createScopeRegistry(registry); - - // Create a composite activator - compositeActivator = ReallySmallRuntimeBuilder.createCompositeActivator(registry, - assemblyFactory, - scaBindingFactory, - mapper, - scopeRegistry, - workManager); - - // Start the runtime modules - modules = startModules(registry, classLoader); - - } - - public void stop() throws ActivationException { - - // Stop the runtime modules - stopModules(registry, modules); - - // Stop and destroy the work manager - workManager.destroy(); - - // Cleanup - modules = null; - registry = null; - assemblyFactory = null; - contributionService = null; - compositeActivator = null; - workManager = null; - scopeRegistry = null; - } - - public ContributionService getContributionService() { - return contributionService; - } - - public CompositeActivator getCompositeActivator() { - return compositeActivator; - } - - public AssemblyFactory getAssemblyFactory() { - return assemblyFactory; - } - - @SuppressWarnings("unchecked") - private List<ModuleActivator> startModules(ExtensionPointRegistry registry, ClassLoader classLoader) - throws ActivationException { - - // Load and instantiate the modules found on the classpath - List<ModuleActivator> modules = ReallySmallRuntimeBuilder.getServices(classLoader, ModuleActivator.class); - for (ModuleActivator module : modules) { - Object[] extensionPoints = module.getExtensionPoints(); - if (extensionPoints != null) { - for (Object e : extensionPoints) { - registry.addExtensionPoint(e); - } - } - } - - // Start all the extension modules - for (ModuleActivator activator : modules) { - activator.start(registry); - } - - return modules; - } - - private void stopModules(ExtensionPointRegistry registry, List<ModuleActivator> modules) { - for (ModuleActivator module : modules) { - module.stop(registry); - } - } - -} diff --git a/branches/sca-java-0.91/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java b/branches/sca-java-0.91/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java deleted file mode 100644 index fab6ca9af1..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.host.embedded.impl; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.SCABindingFactory; -import org.apache.tuscany.sca.assembly.xml.ComponentTypeDocumentProcessor; -import org.apache.tuscany.sca.assembly.xml.ComponentTypeProcessor; -import org.apache.tuscany.sca.assembly.xml.CompositeDocumentProcessor; -import org.apache.tuscany.sca.assembly.xml.CompositeProcessor; -import org.apache.tuscany.sca.assembly.xml.ConstrainingTypeDocumentProcessor; -import org.apache.tuscany.sca.assembly.xml.ConstrainingTypeProcessor; -import org.apache.tuscany.sca.contribution.ContributionFactory; -import org.apache.tuscany.sca.contribution.processor.DefaultPackageProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.DefaultURLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensiblePackageProcessor; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.PackageProcessor; -import org.apache.tuscany.sca.contribution.processor.PackageProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.impl.FolderContributionProcessor; -import org.apache.tuscany.sca.contribution.processor.impl.JarContributionProcessor; -import org.apache.tuscany.sca.contribution.service.ContributionRepository; -import org.apache.tuscany.sca.contribution.service.ContributionService; -import org.apache.tuscany.sca.contribution.service.impl.ContributionRepositoryImpl; -import org.apache.tuscany.sca.contribution.service.impl.ContributionServiceImpl; -import org.apache.tuscany.sca.contribution.service.impl.PackageTypeDescriberImpl; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.invocation.ExtensibleWireProcessor; -import org.apache.tuscany.sca.core.invocation.JDKProxyService; -import org.apache.tuscany.sca.core.invocation.ProxyFactory; -import org.apache.tuscany.sca.core.runtime.ActivationException; -import org.apache.tuscany.sca.core.runtime.CompositeActivator; -import org.apache.tuscany.sca.core.runtime.CompositeActivatorImpl; -import org.apache.tuscany.sca.core.runtime.RuntimeSCABindingProviderFactory; -import org.apache.tuscany.sca.core.scope.CompositeScopeContainerFactory; -import org.apache.tuscany.sca.core.scope.RequestScopeContainerFactory; -import org.apache.tuscany.sca.core.scope.ScopeRegistryImpl; -import org.apache.tuscany.sca.core.scope.StatelessScopeContainerFactory; -import org.apache.tuscany.sca.core.work.Jsr237WorkScheduler; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.invocation.MessageFactory; -import org.apache.tuscany.sca.policy.PolicyFactory; -import org.apache.tuscany.sca.provider.DefaultProviderFactoryExtensionPoint; -import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint; -import org.apache.tuscany.sca.runtime.DefaultWireProcessorExtensionPoint; -import org.apache.tuscany.sca.runtime.RuntimeWireProcessor; -import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint; -import org.apache.tuscany.sca.scope.ScopeContainerFactory; -import org.apache.tuscany.sca.scope.ScopeRegistry; -import org.apache.tuscany.sca.work.WorkScheduler; - -import commonj.work.WorkManager; - -public class ReallySmallRuntimeBuilder { - - public static ProxyFactory createProxyFactory(ExtensionPointRegistry registry, InterfaceContractMapper mapper, MessageFactory messageFactory) { - - // Create a proxy factory - ProxyFactory proxyFactory = new JDKProxyService(messageFactory, mapper); - - // FIXME remove this - registry.addExtensionPoint(proxyFactory); - registry.addExtensionPoint(mapper); - - return proxyFactory; - } - - public static CompositeActivator createCompositeActivator(ExtensionPointRegistry registry, - AssemblyFactory assemblyFactory, - SCABindingFactory scaBindingFactory, - InterfaceContractMapper mapper, - ScopeRegistry scopeRegistry, - WorkManager workManager) { - - // Create a work scheduler - WorkScheduler workScheduler = new Jsr237WorkScheduler(workManager); - registry.addExtensionPoint(workScheduler); - - // Create a wire post processor extension point - RuntimeWireProcessorExtensionPoint wireProcessors = new DefaultWireProcessorExtensionPoint(); - registry.addExtensionPoint(wireProcessors); - RuntimeWireProcessor wireProcessor = new ExtensibleWireProcessor(wireProcessors); - - // Create a provider factory extension point - ProviderFactoryExtensionPoint providerFactories = new DefaultProviderFactoryExtensionPoint(); - registry.addExtensionPoint(providerFactories); - providerFactories.addProviderFactory(new RuntimeSCABindingProviderFactory()); - - // Create the composite activator - CompositeActivator compositeActivator = new CompositeActivatorImpl( - assemblyFactory, scaBindingFactory, - mapper, scopeRegistry, - workScheduler, wireProcessor, - providerFactories); - - return compositeActivator; - } - - /** - * Create the contribution service used by this domain. - * - * @throws ActivationException - */ - public static ContributionService createContributionService(ExtensionPointRegistry registry, - ContributionFactory contributionFactory, - AssemblyFactory assemblyFactory, - PolicyFactory policyFactory, - InterfaceContractMapper mapper) - throws ActivationException { - - XMLInputFactory xmlFactory = XMLInputFactory.newInstance(); - - // Create STAX artifact processor extension point - DefaultStAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(); - registry.addExtensionPoint(staxProcessors); - - // Create and register STAX processors for SCA assembly XML - ExtensibleStAXArtifactProcessor staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, xmlFactory, - XMLOutputFactory - .newInstance()); - staxProcessors.addArtifactProcessor(new CompositeProcessor(assemblyFactory, policyFactory, mapper, - staxProcessor)); - staxProcessors.addArtifactProcessor(new ComponentTypeProcessor(assemblyFactory, policyFactory, staxProcessor)); - staxProcessors - .addArtifactProcessor(new ConstrainingTypeProcessor(assemblyFactory, policyFactory, staxProcessor)); - - // Create URL artifact processor extension point - // FIXME use the interface instead of the class - DefaultURLArtifactProcessorExtensionPoint documentProcessors = new DefaultURLArtifactProcessorExtensionPoint(); - registry.addExtensionPoint(documentProcessors); - - // Create and register document processors for SCA assembly XML - XMLInputFactory inputFactory = XMLInputFactory.newInstance(); - documentProcessors.addArtifactProcessor(new CompositeDocumentProcessor(staxProcessor, inputFactory)); - documentProcessors.addArtifactProcessor(new ComponentTypeDocumentProcessor(staxProcessor, inputFactory)); - documentProcessors.addArtifactProcessor(new ConstrainingTypeDocumentProcessor(staxProcessor, inputFactory)); - - // Create contribution package processor extension point - PackageTypeDescriberImpl describer = new PackageTypeDescriberImpl(); - PackageProcessorExtensionPoint packageProcessors = new DefaultPackageProcessorExtensionPoint(); - PackageProcessor packageProcessor = new ExtensiblePackageProcessor(packageProcessors, describer); - registry.addExtensionPoint(packageProcessors); - - // Register base package processors - packageProcessors.addPackageProcessor(new JarContributionProcessor()); - packageProcessors.addPackageProcessor(new FolderContributionProcessor()); - - // Create a contribution repository - ContributionRepository repository; - try { - repository = new ContributionRepositoryImpl("target"); - } catch (IOException e) { - throw new ActivationException(e); - } - - ExtensibleURLArtifactProcessor documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors); - ContributionService contributionService = new ContributionServiceImpl(repository, packageProcessor, - documentProcessor, assemblyFactory, - contributionFactory, xmlFactory); - return contributionService; - } - - public static ScopeRegistry createScopeRegistry(ExtensionPointRegistry registry) { - ScopeRegistry scopeRegistry = new ScopeRegistryImpl(); - ScopeContainerFactory[] factories = new ScopeContainerFactory[] {new CompositeScopeContainerFactory(), - new StatelessScopeContainerFactory(), - new RequestScopeContainerFactory(), - // new ConversationalScopeContainer(monitor), - // new HttpSessionScopeContainer(monitor) - }; - for (ScopeContainerFactory f : factories) { - scopeRegistry.register(f); - } - - registry.addExtensionPoint(scopeRegistry); - - return scopeRegistry; - } - - /** - * Read the service name from a configuration file - * - * @param classLoader - * @param name The name of the service class - * @return A class name which extends/implements the service class - * @throws IOException - */ - private static Set<String> getServiceClassNames(ClassLoader classLoader, String name) throws IOException { - Set<String> set = new HashSet<String>(); - Enumeration<URL> urls = classLoader.getResources("META-INF/services/" + name); - while (urls.hasMoreElements()) { - URL url = urls.nextElement(); - Set<String> service = getServiceClassNames(url); - if (service != null) { - set.addAll(service); - - } - } - return set; - } - - private static Set<String> getServiceClassNames(URL url) throws IOException { - Set<String> names = new HashSet<String>(); - InputStream is = url.openStream(); - BufferedReader reader = null; - try { - reader = new BufferedReader(new InputStreamReader(is)); - while (true) { - String line = reader.readLine(); - if (line == null) { - break; - } - line = line.trim(); - if (!line.startsWith("#") && !"".equals(line)) { - names.add(line.trim()); - } - } - } finally { - if (reader != null) { - reader.close(); - } - - if (is != null){ - try { - is.close(); - } catch( IOException ioe) { - //ignore - } - } - } - return names; - } - - public static <T> List<T> getServices(final ClassLoader classLoader, Class<T> serviceClass) { - List<T> instances = new ArrayList<T>(); - try { - Set<String> services = getServiceClassNames(classLoader, serviceClass.getName()); - for (String className : services) { - Class cls = Class.forName(className, true, classLoader); - instances.add(serviceClass.cast(cls.newInstance())); - } - } catch (Exception e) { - throw new IllegalStateException(e); - } - return instances; - } - -} diff --git a/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/CRUD.java b/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/CRUD.java deleted file mode 100644 index e33396adfc..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/CRUD.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package crud; - -/** - * The service interface of the single CRUD service provided by CRUD components. - * - * @version $Rev$ $Date$ - */ -public interface CRUD { - - /** - * Create a new resource. - * @param resource - * @return - */ - String create(Object resource); - - /** - * Retrieve a resource. - * @param id - * @return - */ - Object retrieve(String id); - - /** - * Update a resource. - * @param id - * @param resource - * @return - */ - Object update(String id, Object resource); - - /** - * Delete a resource. - * @param id - */ - void delete(String id); - -} diff --git a/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/CRUDImplementation.java b/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/CRUDImplementation.java deleted file mode 100644 index 1f156c3261..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/CRUDImplementation.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package crud; - -import org.apache.tuscany.sca.assembly.Implementation; - -/** - * The model representing a sample CRUD implementation in an SCA assembly model. - * The sample CRUD implementation is not a full blown implementation, it only - * supports a subset of what a component implementation can support: - a single - * fixed service (as opposed to a list of services typed by different - * interfaces) - a directory attribute used to specify where a CRUD component is - * going to persist resources - no references or properties - no policy intents - * or policy sets - * - * @version $$Rev$$ $$Date: 2007-04-23 19:18:54 -0700 (Mon, 23 Apr - * 2007) $$ - */ -public interface CRUDImplementation extends Implementation { - - /** - * Returns the directory used by CRUD implementations to persist resources. - * - * @return the directory used to persist resources - */ - public String getDirectory(); - - /** - * Sets the directory used by CRUD implementations to persist resources. - * - * @param directory the directory used to persist resources - */ - public void setDirectory(String directory); - -} diff --git a/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/CRUDImplementationFactory.java b/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/CRUDImplementationFactory.java deleted file mode 100644 index 430754a8b1..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/CRUDImplementationFactory.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package crud; - -/** - * A factory for the sample CRUD implementation model. - * - * @version $Rev$ $Date$ - */ -public interface CRUDImplementationFactory { - - /** - * Creates a new CRUD implementation. - * - * @return - */ - CRUDImplementation createCRUDImplementation(); - -} diff --git a/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/DefaultCRUDImplementationFactory.java b/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/DefaultCRUDImplementationFactory.java deleted file mode 100644 index 3cc3482bd7..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/DefaultCRUDImplementationFactory.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package crud; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; -import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceIntrospector; - -import crud.impl.CRUDImplementationImpl; - -/** - * A default factory for the CRUD implementation model. - * - * @version $Rev$ $Date$ - */ -public class DefaultCRUDImplementationFactory implements CRUDImplementationFactory { - - private AssemblyFactory assemblyFactory; - private JavaInterfaceFactory javaFactory; - private JavaInterfaceIntrospector introspector; - - public DefaultCRUDImplementationFactory(AssemblyFactory assemblyFactory, - JavaInterfaceFactory javaFactory, - JavaInterfaceIntrospector introspector) { - this.assemblyFactory = assemblyFactory; - this.javaFactory = javaFactory; - this.introspector = introspector; - } - - public CRUDImplementation createCRUDImplementation() { - return new CRUDImplementationImpl(assemblyFactory, javaFactory, introspector); - } - -} diff --git a/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/backend/ResourceManager.java b/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/backend/ResourceManager.java deleted file mode 100644 index 8badd6c409..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/backend/ResourceManager.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package crud.backend; - -import java.util.HashMap; -import java.util.Map; - -/** - * A fake resource manager implementation used as a backend by the sample - * CRUD component implementation. - * - * @version $Rev$ $Date$ - */ -public class ResourceManager { - private static int counter; - private static final Map<String, Object> store = new HashMap<String, Object>(); - private String directory; - - /** - * Constructs a new resource manager. - * - * @param directory the directory where to persist resources - */ - public ResourceManager(String directory) { - super(); - this.directory = directory; - } - - /** - * Creates a new resource. - * - * @param resource - * @return - */ - public String createResource(Object resource) { - System.out.println("create(" + resource + ") in " + directory); - String key = String.valueOf(counter++); - store.put(key, resource); - return key; - } - - /** - * Deletes a resource. - * - * @param id - */ - public void deleteResource(String id) { - System.out.println("delete(" + id + ")"); - store.remove(id); - } - - /** - * Retrieves a resource. - * - * @param id - * @return - */ - public Object retrieveResource(String id) { - System.out.println("retrieve(" + id + ")"); - return store.get(id); - } - - /** - * Updates a resource. - * - * @param id - * @param resource - * @return - */ - public Object updateResource(String id, Object resource) { - System.out.println("update(" + id + ")"); - return store.put(id, resource); - } - -} diff --git a/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/impl/CRUDImplementationImpl.java b/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/impl/CRUDImplementationImpl.java deleted file mode 100644 index 5bc3a0204c..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/impl/CRUDImplementationImpl.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package crud.impl; - -import java.util.Collections; -import java.util.List; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -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.interfacedef.InvalidInterfaceException; -import org.apache.tuscany.sca.interfacedef.java.JavaInterface; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; -import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceIntrospector; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; - -import crud.CRUD; -import crud.CRUDImplementation; - -/** - * The model representing a sample CRUD implementation in an SCA assembly model. - * - * @version $$Rev$$ $$Date: 2007-04-23 19:18:54 -0700 (Mon, 23 Apr - * 2007) $$ - */ -public class CRUDImplementationImpl implements CRUDImplementation { - - private Service crudService; - private String directory; - - /** - * Constructs a new CRUD implementation. - */ - public CRUDImplementationImpl(AssemblyFactory assemblyFactory, - JavaInterfaceFactory javaFactory, - JavaInterfaceIntrospector introspector) { - - // CRUD implementation always provide a single service exposing - // the CRUD interface, and have no references and properties - crudService = assemblyFactory.createService(); - crudService.setName("CRUD"); - JavaInterface javaInterface; - try { - javaInterface = introspector.introspect(CRUD.class); - } catch (InvalidInterfaceException e) { - throw new IllegalArgumentException(e); - } - JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract(); - interfaceContract.setInterface(javaInterface); - crudService.setInterfaceContract(interfaceContract); - } - - public String getDirectory() { - return directory; - } - - public void setDirectory(String directory) { - this.directory = directory; - } - - public ConstrainingType getConstrainingType() { - // The sample CRUD implementation does not support constrainingTypes - return null; - } - - public List<Property> getProperties() { - // The sample CRUD implementation does not support properties - return Collections.emptyList(); - } - - public List<Service> getServices() { - // The sample CRUD implementation provides a single fixed CRUD service - return Collections.singletonList(crudService); - } - - public List<Reference> getReferences() { - // The sample CRUD implementation does not support properties - return Collections.emptyList(); - } - - public String getURI() { - // The sample CRUD implementation does not have a URI - return null; - } - - public void setConstrainingType(ConstrainingType constrainingType) { - // The sample CRUD implementation does not support constrainingTypes - } - - public void setURI(String uri) { - // The sample CRUD implementation does not have a URI - } - - public List<PolicySet> getPolicySets() { - // The sample CRUD implementation does not support policy sets - return Collections.emptyList(); - } - - public List<Intent> getRequiredIntents() { - // The sample CRUD implementation does not support intents - return Collections.emptyList(); - } - - public List<Object> getExtensions() { - // The sample CRUD implementation does not support extensions - return Collections.emptyList(); - } - - public boolean isUnresolved() { - // The sample CRUD implementation is always resolved - return false; - } - - public void setUnresolved(boolean unresolved) { - // The sample CRUD implementation is always resolved - } - -} diff --git a/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/impl/CRUDImplementationProcessor.java b/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/impl/CRUDImplementationProcessor.java deleted file mode 100644 index 32b9a6be84..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/impl/CRUDImplementationProcessor.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package crud.impl; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; -import org.apache.tuscany.sca.contribution.service.ContributionWriteException; - -import crud.CRUDImplementation; -import crud.CRUDImplementationFactory; - -/** - * Implements a STAX artifact processor for CRUD implementations. - * - * The artifact processor is responsible for processing <implementation.crud> - * elements in SCA assembly XML composite files and populating the CRUD - * implementation model, resolving its references to other artifacts in the SCA - * contribution, and optionally write the model back to SCA assembly XML. - * - * @version $Rev$ $Date$ - */ -public class CRUDImplementationProcessor implements StAXArtifactProcessor<CRUDImplementation> { - private static final QName IMPLEMENTATION_CRUD = new QName("http://crud", "implementation.crud"); - - private CRUDImplementationFactory crudFactory; - - public CRUDImplementationProcessor(CRUDImplementationFactory crudFactory) { - this.crudFactory = crudFactory; - } - - public QName getArtifactType() { - // Returns the qname of the XML element processed by this processor - return IMPLEMENTATION_CRUD; - } - - public Class<CRUDImplementation> getModelType() { - // Returns the type of model processed by this processor - return CRUDImplementation.class; - } - - public CRUDImplementation read(XMLStreamReader reader) throws ContributionReadException { - assert IMPLEMENTATION_CRUD.equals(reader.getName()); - - // Read an <implementation.crud> element - try { - // Read the directory attribute. This is where the sample - // CRUD implementation will persist resources. - String directory = reader.getAttributeValue(null, "directory"); - - // Create an initialize the CRUD implementation model - CRUDImplementation implementation = crudFactory.createCRUDImplementation(); - implementation.setDirectory(directory); - - // Skip to end element - while (reader.hasNext()) { - if (reader.next() == END_ELEMENT && IMPLEMENTATION_CRUD.equals(reader.getName())) { - break; - } - } - - return implementation; - } catch (XMLStreamException e) { - throw new ContributionReadException(e); - } - } - - public void resolve(CRUDImplementation impl, ModelResolver resolver) throws ContributionResolveException { - } - - public void write(CRUDImplementation model, XMLStreamWriter outputSource) throws ContributionWriteException { - } -} diff --git a/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/module/CRUDModuleActivator.java b/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/module/CRUDModuleActivator.java deleted file mode 100644 index 67ecd0e649..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/module/CRUDModuleActivator.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package crud.module; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.core.ModuleActivator; -import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; -import org.apache.tuscany.sca.interfacedef.java.introspect.ExtensibleJavaInterfaceIntrospector; -import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceIntrospector; -import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceIntrospectorExtensionPoint; -import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint; - -import crud.CRUDImplementationFactory; -import crud.DefaultCRUDImplementationFactory; -import crud.impl.CRUDImplementationProcessor; -import crud.provider.CRUDImplementationProviderFactory; - -/** - * Implements a module activator for the CRUD implementation extension module. - * The module activator is responsible for contributing the CRUD implementation - * extensions and plugging them in the extension points defined by the Tuscany - * runtime. - * - * @version $Rev$ $Date$ - */ -public class CRUDModuleActivator implements ModuleActivator { - - public Object[] getExtensionPoints() { - // This module extension does not contribute any new - // extension point - return null; - } - - public void start(ExtensionPointRegistry registry) { - - // Create the CRUD implementation factory - ModelFactoryExtensionPoint factories = registry.getExtensionPoint(ModelFactoryExtensionPoint.class); - AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class); - JavaInterfaceFactory javaFactory = new DefaultJavaInterfaceFactory(); - JavaInterfaceIntrospectorExtensionPoint visitors = registry.getExtensionPoint(JavaInterfaceIntrospectorExtensionPoint.class); - JavaInterfaceIntrospector introspector = new ExtensibleJavaInterfaceIntrospector(javaFactory, visitors); - CRUDImplementationFactory crudFactory = new DefaultCRUDImplementationFactory(assemblyFactory, javaFactory, introspector); - factories.addFactory(crudFactory); - - // Add the CRUD implementation extension to the StAXArtifactProcessor - // extension point - StAXArtifactProcessorExtensionPoint processors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - CRUDImplementationProcessor implementationArtifactProcessor = new CRUDImplementationProcessor(crudFactory); - processors.addArtifactProcessor(implementationArtifactProcessor); - - // Add the CRUD provider factory to the ProviderFactory extension point - ProviderFactoryExtensionPoint providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class); - providerFactories.addProviderFactory(new CRUDImplementationProviderFactory()); - } - - public void stop(ExtensionPointRegistry registry) { - } -} diff --git a/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/provider/CRUDImplementationProvider.java b/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/provider/CRUDImplementationProvider.java deleted file mode 100644 index f81165f564..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/provider/CRUDImplementationProvider.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package crud.provider; - -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.provider.ImplementationProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; - -import crud.CRUDImplementation; -import crud.backend.ResourceManager; - -/** - * The model representing a sample CRUD implementation in an SCA assembly model. - * The sample CRUD implementation is not a full blown implementation, it only - * supports a subset of what a component implementation can support: - a single - * fixed service (as opposed to a list of services typed by different - * interfaces) - a directory attribute used to specify where a CRUD component is - * going to persist resources - no references or properties - no policy intents - * or policy sets - * - * @version $$Rev$$ $$Date: 2007-04-23 19:18:54 -0700 (Mon, 23 Apr - * 2007) $$ - */ -public class CRUDImplementationProvider implements ImplementationProvider { - - private RuntimeComponent component; - private CRUDImplementation implementation; - - /** - * Constructs a new CRUD implementation. - */ - public CRUDImplementationProvider(RuntimeComponent component, CRUDImplementation implementation) { - this.component = component; - this.implementation = implementation; - } - - public Invoker createInvoker(RuntimeComponentService service, Operation operation) { - CRUDInvoker invoker = new CRUDInvoker(operation, new ResourceManager(implementation.getDirectory())); - return invoker; - } - - public Invoker createCallbackInvoker(Operation operation) { - CRUDInvoker invoker = new CRUDInvoker(operation, new ResourceManager(implementation.getDirectory())); - return invoker; - } - - public void start() { - System.out.println("Starting " + component.getName()); - } - - public void stop() { - System.out.println("Stopping " + component.getName()); - } - -} diff --git a/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/provider/CRUDImplementationProviderFactory.java b/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/provider/CRUDImplementationProviderFactory.java deleted file mode 100644 index 9eb5fdeb61..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/provider/CRUDImplementationProviderFactory.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package crud.provider; - -import org.apache.tuscany.sca.provider.ImplementationProvider; -import org.apache.tuscany.sca.provider.ImplementationProviderFactory; -import org.apache.tuscany.sca.runtime.RuntimeComponent; - -import crud.CRUDImplementation; - -/** - * The model representing a sample CRUD implementation in an SCA assembly model. - * - * @version $$Rev$$ $$Date: 2007-04-23 19:18:54 -0700 (Mon, 23 Apr - * 2007) $$ - */ -public class CRUDImplementationProviderFactory implements ImplementationProviderFactory<CRUDImplementation> { - - /** - * Constructs a new CRUD implementation. - */ - public CRUDImplementationProviderFactory() { - } - - public ImplementationProvider createImplementationProvider(RuntimeComponent component, CRUDImplementation implementation) { - return new CRUDImplementationProvider(component, implementation); - } - - public Class<CRUDImplementation> getModelType() { - return CRUDImplementation.class; - } -} diff --git a/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/provider/CRUDInvoker.java b/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/provider/CRUDInvoker.java deleted file mode 100644 index 2299ce8b0c..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/test/java/crud/provider/CRUDInvoker.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package crud.provider; - -import java.lang.reflect.InvocationTargetException; - -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; - -import crud.backend.ResourceManager; - -/** - * Implements a target invoker for CRUD component implementations. - * - * The target invoker is responsible for dispatching invocations to the particular - * component implementation logic. In this example we are simply delegating the - * CRUD operation invocations to the corresponding methods on our fake - * resource manager. - * - * @version $Rev$ $Date$ - */ -public class CRUDInvoker implements Invoker { - private Operation operation; - private ResourceManager resourceManager; - - public CRUDInvoker(Operation operation, ResourceManager resourceManager) { - this.operation = operation; - this.resourceManager = resourceManager; - } - - public Message invoke(Message msg) { - try { - Object[] args = msg.getBody(); - Object resp = doTheWork(args); - msg.setBody(resp); - } catch (InvocationTargetException e) { - msg.setFaultBody(e.getCause()); - } - return msg; - } - - public Object doTheWork(Object[] args) throws InvocationTargetException { - if (operation.getName().equals("create")) { - return resourceManager.createResource(args[0]); - - } else if (operation.getName().equals("retrieve")) { - return resourceManager.retrieveResource((String)args[0]); - - } else if (operation.getName().equals("update")) { - return resourceManager.updateResource((String)args[0], args[1]); - - } else if (operation.getName().equals("delete")) { - resourceManager.deleteResource((String)args[0]); - return null; - - } else { - return null; - } - } - -} diff --git a/branches/sca-java-0.91/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/SCADomainBeanTestCase.java b/branches/sca-java-0.91/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/SCADomainBeanTestCase.java deleted file mode 100644 index 817a151374..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/SCADomainBeanTestCase.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.host.embedded; - -import junit.framework.TestCase; - -import org.osoa.sca.ServiceReference; - -import crud.CRUD; - -/** - * @version $Rev$ $Date$ - */ -public class SCADomainBeanTestCase extends TestCase { - - private SCADomainBean domain; - - protected void setUp() throws Exception { - domain = new SCADomainBean(); - domain.setDeployableComposites("crud.composite"); - } - - public void testStart() throws Exception { - ServiceReference<CRUD> serviceReference = domain.getServiceReference(CRUD.class, "CRUDServiceComponent"); - assertNotNull(serviceReference); - CRUD service = serviceReference.getService(); - String id = service.create("ABC"); - Object result = service.retrieve(id); - assertEquals("ABC", result); - service.update(id, "EFG"); - result = service.retrieve(id); - assertEquals("EFG", result); - service.delete(id); - result = service.retrieve(id); - assertNull(result); - } - - /** - * @throws java.lang.Exception - */ - protected void tearDown() throws Exception { - domain.close(); - } - -} diff --git a/branches/sca-java-0.91/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/SCADomainTestCase.java b/branches/sca-java-0.91/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/SCADomainTestCase.java deleted file mode 100644 index 297858ea9b..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/SCADomainTestCase.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.host.embedded; - -import junit.framework.TestCase; - -import org.osoa.sca.ServiceReference; - -import crud.CRUD; - -/** - * @version $Rev$ $Date$ - */ -public class SCADomainTestCase extends TestCase { - - private SCADomain domain; - - protected void setUp() throws Exception { - domain = SCADomain.newInstance("crud.composite"); - } - - public void testStart() throws Exception { - ServiceReference<CRUD> serviceReference = domain.getServiceReference(CRUD.class, "CRUDServiceComponent"); - assertNotNull(serviceReference); - CRUD service = serviceReference.getService(); - String id = service.create("ABC"); - Object result = service.retrieve(id); - assertEquals("ABC", result); - service.update(id, "EFG"); - result = service.retrieve(id); - assertEquals("EFG", result); - service.delete(id); - result = service.retrieve(id); - assertNull(result); - } - - /** - * @throws java.lang.Exception - */ - protected void tearDown() throws Exception { - domain.close(); - } - -} diff --git a/branches/sca-java-0.91/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomainTestCase.java b/branches/sca-java-0.91/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomainTestCase.java deleted file mode 100644 index 9ad6fd3920..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomainTestCase.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.host.embedded.impl; - -import junit.framework.TestCase; -import crud.CRUD; - -/** - * @version $Rev$ $Date$ - */ -public class DefaultSCADomainTestCase extends TestCase { - private DefaultSCADomain domain; - - /** - * @throws java.lang.Exception - */ - protected void setUp() throws Exception { - domain = new DefaultSCADomain(getClass().getClassLoader(), getClass().getClassLoader(), - "http://localhost", ".", "crud.composite"); - } - - public void testStart() throws Exception { - CRUD service = domain.getService(CRUD.class, "CRUDServiceComponent"); - assertNotNull(service); - } - - /** - * @throws java.lang.Exception - */ - protected void tearDown() throws Exception { - domain.close(); - } - -} diff --git a/branches/sca-java-0.91/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomainTestCase.java b/branches/sca-java-0.91/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomainTestCase.java deleted file mode 100644 index 4d4c020d1c..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomainTestCase.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.host.embedded.impl; - -import java.net.URL; - -import javax.xml.namespace.QName; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.contribution.Contribution; -import org.apache.tuscany.sca.contribution.service.ContributionService; - -import crud.CRUD; - -/** - * @version $Rev$ $Date$ - */ -public class EmbeddedSCADomainTestCase extends TestCase { - private EmbeddedSCADomain domain; - - /** - * @throws java.lang.Exception - */ - protected void setUp() throws Exception { - - // Create a test embedded SCA domain - domain = new EmbeddedSCADomain(getClass().getClassLoader(), "http://localhost"); - } - - public void testDomain() throws Exception { - // Start the domain - domain.start(); - - // Determine my class loader and my test SCA contribution location - ClassLoader myClassLoader = getClass().getClassLoader(); - String url = myClassLoader.getResource("test.txt").toString(); - url = url.substring(0, url.length()-8); - - // Contribute the SCA contribution - TestModelResolver myResolver = new TestModelResolver(myClassLoader); - ContributionService contributionService = domain.getContributionService(); - Contribution contribution = contributionService.contribute("http://test/contribution", new URL(url), myResolver, false); - assertNotNull(contribution); - - // Decide which SCA composite I want to deploy - Composite myComposite = myResolver.getComposite(new QName("http://sample/crud", "crud")); - - // Add the deployable composite to the domain - EmbeddedSCADomain.DomainCompositeHelper domainHelper = domain.getDomainCompositeHelper(); - domainHelper.addComposite(myComposite); - - // Activate the SCA Domain - domainHelper.activateDomain(); - - // Start the components in my composite - domainHelper.startComponent(domainHelper.getComponent("CRUDServiceComponent")); - - // At this point the domain contains my contribution, my composite and - // it's started, my application code can start using it - - // Get the CRUDServiceComponent service - CRUD service = domain.getService(CRUD.class, "CRUDServiceComponent"); - - // Invoke the service - String id = service.create("ABC"); - Object result = service.retrieve(id); - assertEquals("ABC", result); - service.update(id, "EFG"); - result = service.retrieve(id); - assertEquals("EFG", result); - service.delete(id); - result = service.retrieve(id); - assertNull(result); - - // Stop my composite - domainHelper.stopComposite(myComposite); - - // Remove my composite - domainHelper.removeComposite(myComposite); - - // Remove my contribution - contributionService.remove("http://test/contribution"); - - // Stop the domain - domain.stop(); - } - - /** - * @throws java.lang.Exception - */ - protected void tearDown() throws Exception { - domain.close(); - } - -} diff --git a/branches/sca-java-0.91/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/TestModelResolver.java b/branches/sca-java-0.91/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/TestModelResolver.java deleted file mode 100644 index 6969cba054..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/TestModelResolver.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.host.embedded.impl; - -import java.lang.ref.WeakReference; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.contribution.resolver.ClassReference; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; - - -/** - * A test model resolver, based on a map. - * - * @version $Rev$ $Date$ - */ -public class TestModelResolver implements ModelResolver { - private static final long serialVersionUID = -7826976465762296634L; - - private Map<Object, Object> map = new HashMap<Object, Object>(); - private WeakReference<ClassLoader> classLoader; - - private Map<QName, Composite> composites = new HashMap<QName, Composite>(); - - public TestModelResolver(ClassLoader classLoader) { - this.classLoader = new WeakReference<ClassLoader>(classLoader); - } - - public <T> T resolveModel(Class<T> modelClass, T unresolved) { - Object resolved = map.get(unresolved); - if (resolved != null) { - - // Return the resolved object - return modelClass.cast(resolved); - - } else if (unresolved instanceof ClassReference) { - - // Load a class on demand - ClassReference classReference = (ClassReference)unresolved; - Class clazz; - try { - clazz = Class.forName(classReference.getClassName(), true, classLoader.get()); - } catch (ClassNotFoundException e) { - - // Return the unresolved object - return unresolved; - } - - // Store a new ClassReference wrappering the loaded class - resolved = new ClassReference(clazz); - map.put(resolved, resolved); - - // Return the resolved ClassReference - return modelClass.cast(resolved); - - } else { - - // Return the unresolved object - return unresolved; - } - } - - public void addModel(Object resolved) { - map.put(resolved, resolved); - if (resolved instanceof Composite) { - Composite composite = (Composite)resolved; - composites.put(composite.getName(), composite); - } - } - - public Object removeModel(Object resolved) { - if (resolved instanceof Composite) { - Composite composite = (Composite)resolved; - composites.remove(composite.getName()); - } - return map.remove(resolved); - } - - public Composite getComposite(QName qname) { - return composites.get(qname); - } - -} diff --git a/branches/sca-java-0.91/modules/host-embedded/src/test/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator b/branches/sca-java-0.91/modules/host-embedded/src/test/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator deleted file mode 100644 index 266d53ffc8..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/test/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-# Implementation class for the ExtensionActivator
-crud.module.CRUDModuleActivator
diff --git a/branches/sca-java-0.91/modules/host-embedded/src/test/resources/crud.composite b/branches/sca-java-0.91/modules/host-embedded/src/test/resources/crud.composite deleted file mode 100644 index 65f24ec93c..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/test/resources/crud.composite +++ /dev/null @@ -1,30 +0,0 @@ -<?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.
--->
-<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
- targetNamespace="http://sample/crud"
- xmlns:sc="http://sample/crud"
- xmlns:c="http://crud"
- name="crud">
-
- <component name="CRUDServiceComponent">
- <c:implementation.crud directory="tmp" />
- </component>
-
-</composite>
diff --git a/branches/sca-java-0.91/modules/host-embedded/src/test/resources/test.txt b/branches/sca-java-0.91/modules/host-embedded/src/test/resources/test.txt deleted file mode 100644 index 287f9b1f65..0000000000 --- a/branches/sca-java-0.91/modules/host-embedded/src/test/resources/test.txt +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License.
\ No newline at end of file |