From 28d9bc59aa4522f08b23baf37745fd8cd6b74d9d Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Sat, 13 Sep 2008 22:17:41 +0000 Subject: Renamed modules to match the structure in r643746 and make it possible to create a patch on top of that revision. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@695044 13f79535-47bb-0310-9956-ffa450edef68 --- .../modules/tuscany-assembly-xml/.classpath | 40 - .../modules/tuscany-assembly-xml/.project | 30 - .../.settings/org.eclipse.jdt.core.prefs | 5 - .../modules/tuscany-assembly-xml/DISCLAIMER | 8 - .../modules/tuscany-assembly-xml/LICENSE | 205 ----- .../modules/tuscany-assembly-xml/NOTICE | 6 - .../modules/tuscany-assembly-xml/pom.xml | 116 --- .../sca/assembly/xml/BaseAssemblyProcessor.java | 814 ----------------- .../xml/ComponentTypeDocumentProcessor.java | 122 --- .../assembly/xml/ComponentTypeModelResolver.java | 95 -- .../sca/assembly/xml/ComponentTypeProcessor.java | 355 -------- .../assembly/xml/CompositeDocumentProcessor.java | 174 ---- .../sca/assembly/xml/CompositeModelResolver.java | 83 -- .../sca/assembly/xml/CompositeProcessor.java | 989 --------------------- .../assembly/xml/ConfiguredOperationProcessor.java | 104 --- .../apache/tuscany/sca/assembly/xml/Constants.java | 95 -- .../xml/ConstrainingTypeDocumentProcessor.java | 121 --- .../xml/ConstrainingTypeModelResolver.java | 83 -- .../assembly/xml/ConstrainingTypeProcessor.java | 257 ------ .../assembly/xml/DefaultBeanModelProcessor.java | 246 ----- .../assembly/xml/PolicyAttachPointProcessor.java | 263 ------ ...tuscany.sca.contribution.resolver.ModelResolver | 20 - .../sca/assembly/xml/BuildPolicyTestCase.java | 166 ---- .../sca/assembly/xml/MockPolicyProcessor.java | 68 -- .../tuscany/sca/assembly/xml/ReadAllTestCase.java | 162 ---- .../sca/assembly/xml/ReadDocumentTestCase.java | 223 ----- .../tuscany/sca/assembly/xml/ReadTestCase.java | 99 --- .../sca/assembly/xml/ResolvePolicyTestCase.java | 198 ----- .../tuscany/sca/assembly/xml/ResolveTestCase.java | 111 --- .../sca/assembly/xml/TestModelResolver.java | 63 -- .../assembly/xml/TestSCABindingFactoryImpl.java | 35 - .../sca/assembly/xml/TestSCABindingImpl.java | 213 ----- .../tuscany/sca/assembly/xml/WireTestCase.java | 146 --- .../tuscany/sca/assembly/xml/WriteAllTestCase.java | 148 --- .../tuscany/sca/assembly/xml/Calculator.composite | 53 -- .../xml/CalculatorComponent.constrainingType | 34 - .../sca/assembly/xml/CalculatorImpl.componentType | 31 - .../sca/assembly/xml/JavaScriptReference.composite | 37 - .../sca/assembly/xml/RMIBindingTest.composite | 43 - .../sca/assembly/xml/TestAllCalculator.composite | 128 --- .../sca/assembly/xml/TestAllDivide.composite | 56 -- .../assembly/xml/TestAllPolicyCalculator.composite | 129 --- .../sca/assembly/xml/another_test_definitions.xml | 97 -- .../tuscany/sca/assembly/xml/test_definitions.xml | 175 ---- 44 files changed, 6646 deletions(-) delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/.classpath delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/.project delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/.settings/org.eclipse.jdt.core.prefs delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/DISCLAIMER delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/LICENSE delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/NOTICE delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/pom.xml delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConfiguredOperationProcessor.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeDocumentProcessor.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeModelResolver.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicyAttachPointProcessor.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MockPolicyProcessor.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestModelResolver.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/JavaScriptReference.composite delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml delete mode 100644 branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml (limited to 'branches/sca-android/modules/tuscany-assembly-xml') diff --git a/branches/sca-android/modules/tuscany-assembly-xml/.classpath b/branches/sca-android/modules/tuscany-assembly-xml/.classpath deleted file mode 100644 index 3f660b27c9..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/.classpath +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/branches/sca-android/modules/tuscany-assembly-xml/.project b/branches/sca-android/modules/tuscany-assembly-xml/.project deleted file mode 100644 index 975169eed5..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/.project +++ /dev/null @@ -1,30 +0,0 @@ - - tuscany-assembly-xml - Parent POM defining settings that can be used across Tuscany - - tuscany-assembly - tuscany-policy - tuscany-extensibility - tuscany-interface - tuscany-definitions - tuscany-assembly-xsd - tuscany-contribution - tuscany-contribution-impl - tuscany-contribution-xml - tuscany-contribution-java - tuscany-core-spi - tuscany-sca-api - tuscany-contribution-namespace - tuscany-contribution-resource - tuscany-definitions-xml - tuscany-policy-xml - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/branches/sca-android/modules/tuscany-assembly-xml/.settings/org.eclipse.jdt.core.prefs b/branches/sca-android/modules/tuscany-assembly-xml/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 33e67d2469..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -#Thu Mar 20 19:20:00 PDT 2008 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.source=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 diff --git a/branches/sca-android/modules/tuscany-assembly-xml/DISCLAIMER b/branches/sca-android/modules/tuscany-assembly-xml/DISCLAIMER deleted file mode 100644 index d68a410903..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/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-android/modules/tuscany-assembly-xml/LICENSE b/branches/sca-android/modules/tuscany-assembly-xml/LICENSE deleted file mode 100644 index 6e529a25c4..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/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-android/modules/tuscany-assembly-xml/NOTICE b/branches/sca-android/modules/tuscany-assembly-xml/NOTICE deleted file mode 100644 index 1325efd8bf..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/NOTICE +++ /dev/null @@ -1,6 +0,0 @@ -${pom.name} -Copyright (c) 2005 - 2008 The Apache Software Foundation - -This product includes software developed by -The Apache Software Foundation (http://www.apache.org/). - diff --git a/branches/sca-android/modules/tuscany-assembly-xml/pom.xml b/branches/sca-android/modules/tuscany-assembly-xml/pom.xml deleted file mode 100644 index 1580311fff..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/pom.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - - 4.0.0 - - org.apache.tuscany.sca - tuscany-modules - 2.0-incubating-SNAPSHOT - ../pom.xml - - tuscany-assembly-xml - Apache Tuscany SCA XML Assembly Model - - - - org.apache.tuscany.sca - tuscany-assembly - 2.0-incubating-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-definitions-xml - 2.0-incubating-SNAPSHOT - test - - - - org.apache.tuscany.sca - tuscany-definitions - 2.0-incubating-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-contribution - 2.0-incubating-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-contribution-namespace - 2.0-incubating-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-contribution-java - 2.0-incubating-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-contribution-impl - 2.0-incubating-SNAPSHOT - test - - - - org.apache.tuscany.sca - tuscany-policy - 2.0-incubating-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-policy-xml - 2.0-incubating-SNAPSHOT - test - - - - stax - stax-api - 1.0.1 - - - - org.codehaus.woodstox - wstx-asl - 3.2.1 - runtime - - - - xalan - xalan - 2.7.0 - - - - org.apache.tuscany.sca - tuscany-assembly-xsd - 2.0-incubating-SNAPSHOT - test - - - - diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java b/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java deleted file mode 100644 index b94d9e0927..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java +++ /dev/null @@ -1,814 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import static javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI; -import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI; - -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -import javax.xml.namespace.QName; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; -import javax.xml.transform.dom.DOMSource; - -import org.apache.tuscany.sca.assembly.AbstractContract; -import org.apache.tuscany.sca.assembly.AbstractProperty; -import org.apache.tuscany.sca.assembly.AbstractReference; -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Base; -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.ComponentType; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.ConfiguredOperation; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.Contract; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.Multiplicity; -import org.apache.tuscany.sca.assembly.OperationsConfigurator; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.contribution.ContributionFactory; -import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; -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.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.IntentAttachPoint; -import org.apache.tuscany.sca.policy.IntentAttachPointType; -import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory; -import org.apache.tuscany.sca.policy.PolicyFactory; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; -import org.apache.tuscany.sca.policy.impl.IntentAttachPointTypeFactoryImpl; -import org.apache.tuscany.sca.policy.util.PolicyValidationException; -import org.apache.tuscany.sca.policy.util.PolicyValidationUtils; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * A base class with utility methods for the other artifact processors in this module. - * - * @version $Rev: 643489 $ $Date: 2008-04-01 10:06:42 -0800 (Tue, 01 Apr 2008) $ - */ -abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor implements Constants { - - protected ContributionFactory contributionFactory; - protected AssemblyFactory assemblyFactory; - protected PolicyFactory policyFactory; - protected StAXArtifactProcessor extensionProcessor; - protected PolicyAttachPointProcessor policyProcessor; - private DocumentBuilderFactory documentBuilderFactory; - protected IntentAttachPointTypeFactory intentAttachPointTypeFactory; - - /** - * Constructs a new BaseArtifactProcessor. - * @param contribFactory - * @param factory - * @param policyFactory - */ - @SuppressWarnings("unchecked") - public BaseAssemblyProcessor(ContributionFactory contribFactory, - AssemblyFactory factory, - PolicyFactory policyFactory, - StAXArtifactProcessor extensionProcessor) { - this.assemblyFactory = factory; - this.policyFactory = policyFactory; - this.extensionProcessor = (StAXArtifactProcessor)extensionProcessor; - this.contributionFactory = contribFactory; - this.policyProcessor = new PolicyAttachPointProcessor(policyFactory); - this.intentAttachPointTypeFactory = new IntentAttachPointTypeFactoryImpl(); - } - - /** - * Constructs a new BaseArtifactProcessor. - * @param factory - * @param policyFactory - */ - @SuppressWarnings("unchecked") - public BaseAssemblyProcessor(AssemblyFactory factory, - PolicyFactory policyFactory, - StAXArtifactProcessor extensionProcessor) { - this.assemblyFactory = factory; - this.policyFactory = policyFactory; - this.extensionProcessor = (StAXArtifactProcessor)extensionProcessor; - this.policyProcessor = new PolicyAttachPointProcessor(policyFactory); - } - - /** - * Start an element. - * @param writer - * @param name - * @param attrs - * @throws XMLStreamException - */ - protected void writeStart(XMLStreamWriter writer, String name, XAttr... attrs) throws XMLStreamException { - writeStart(writer, SCA10_NS, name, attrs); - } - - /** - * Start a document. - * @param writer - * @throws XMLStreamException - */ - protected void writeStartDocument(XMLStreamWriter writer, String name, XAttr... attrs) throws XMLStreamException { - writer.writeStartDocument(); - writer.setDefaultNamespace(SCA10_NS); - writeStart(writer, SCA10_NS, name, attrs); - writer.writeDefaultNamespace(SCA10_NS); - } - - /** - * Read list of reference targets - * @param reference - * @param reader - */ - protected void readTargets(Reference reference, XMLStreamReader reader) { - String value = reader.getAttributeValue(null, TARGET); - ComponentService target = null; - if (value != null) { - for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) { - target = assemblyFactory.createComponentService(); - target.setUnresolved(true); - target.setName(tokens.nextToken()); - reference.getTargets().add(target); - } - } - } - - /** - * Write a list of targets into an attribute - * @param reference - * @return - */ - protected XAttr writeTargets(Reference reference) { - List targets = new ArrayList(); - for (Service target : reference.getTargets()) { - targets.add(target.getName()); - } - return new XAttr(TARGET, targets); - } - - /** - * Read a multiplicity attribute. - * @param reference - * @param reader - */ - protected void readMultiplicity(AbstractReference reference, XMLStreamReader reader) { - String value = reader.getAttributeValue(null, MULTIPLICITY); - if (ZERO_ONE.equals(value)) { - reference.setMultiplicity(Multiplicity.ZERO_ONE); - } else if (ONE_N.equals(value)) { - reference.setMultiplicity(Multiplicity.ONE_N); - } else if (ZERO_N.equals(value)) { - reference.setMultiplicity(Multiplicity.ZERO_N); - } - } - - /** - * Returns the value of a constrainingType attribute. - * @param reader - * @return - */ - protected ConstrainingType readConstrainingType(XMLStreamReader reader) { - QName constrainingTypeName = getQName(reader, Constants.CONSTRAINING_TYPE); - if (constrainingTypeName != null) { - ConstrainingType constrainingType = assemblyFactory.createConstrainingType(); - constrainingType.setName(constrainingTypeName); - constrainingType.setUnresolved(true); - return constrainingType; - } else { - return null; - } - } - - /** - * Reads an abstract property element. - * @param property - * @param reader - * @throws XMLStreamException - * @throws ContributionReadException - */ - protected void readAbstractProperty(AbstractProperty property, XMLStreamReader reader) throws XMLStreamException, - ContributionReadException { - - property.setName(getString(reader, NAME)); - property.setMany(getBoolean(reader, MANY)); - property.setMustSupply(getBoolean(reader, MUST_SUPPLY)); - property.setXSDElement(getQName(reader, ELEMENT)); - property.setXSDType(getQName(reader, TYPE)); - } - - /** - * Resolve an implementation. - * @param implementation - * @param resolver - * @return - * @throws ContributionResolveException - */ - protected Implementation resolveImplementation(Implementation implementation, ModelResolver resolver) - throws ContributionResolveException, PolicyValidationException { - if (implementation != null) { - if (implementation.isUnresolved()) { - implementation = resolver.resolveModel(Implementation.class, implementation); - - // Lazily resolve implementations - if (implementation.isUnresolved()) { - extensionProcessor.resolve(implementation, resolver); - if (!implementation.isUnresolved()) { - //resolve policies - if ( implementation instanceof PolicySetAttachPoint ) { - PolicySetAttachPoint policiedImpl = (PolicySetAttachPoint)implementation; - resolveIntents(policiedImpl.getRequiredIntents(), resolver); - PolicyValidationUtils.validateIntents(policiedImpl, policiedImpl.getType()); - - resolvePolicySets(policiedImpl.getPolicySets(), resolver); - PolicyValidationUtils.validatePolicySets(policiedImpl); - - if ( implementation instanceof OperationsConfigurator ) { - OperationsConfigurator opsConfigurator = (OperationsConfigurator)implementation; - for ( ConfiguredOperation implOp : opsConfigurator.getConfiguredOperations() ) { - resolveIntents(implOp.getRequiredIntents(), resolver); - PolicyValidationUtils.validateIntents(implOp, policiedImpl.getType()); - - resolvePolicySets(implOp.getPolicySets(), resolver); - PolicyValidationUtils.validatePolicySets(implOp, - policiedImpl.getType(), - policiedImpl.getApplicablePolicySets()); - } - } - - for ( Service service : implementation.getServices() ) { - resolveIntents(service.getRequiredIntents(), resolver); - resolvePolicySets(service.getPolicySets(), resolver); - - for ( ConfiguredOperation svcOp : service.getConfiguredOperations() ) { - resolveIntents(svcOp.getRequiredIntents(), resolver); - resolvePolicySets(svcOp.getPolicySets(), resolver); - } - } - - for ( Reference reference : implementation.getReferences() ) { - resolveIntents(reference.getRequiredIntents(), resolver); - resolvePolicySets(reference.getPolicySets(), resolver); - } - } - - resolver.addModel(implementation); - } - } - } - - if ( implementation instanceof IntentAttachPoint && - ((IntentAttachPoint)implementation).getType() != null && - ((IntentAttachPoint)implementation).getType().isUnresolved() ) { - ((IntentAttachPoint)implementation).setType( - resolver.resolveModel(IntentAttachPointType.class, - ((IntentAttachPoint)implementation).getType())); - } - } - return implementation; - } - - /** - * Resolve interface, callback interface and bindings on a list of contracts. - * @param contracts the list of contracts - * @param resolver the resolver to use to resolve models - */ - protected void resolveContracts(List contracts, ModelResolver resolver) - throws ContributionResolveException { - resolveContracts(null, contracts, resolver); - } - - - /** - * Resolve interface, callback interface and bindings on a list of contracts. - * @param parent element for the contracts - * @param contracts the list of contracts - * @param resolver the resolver to use to resolve models - */ - protected void resolveContracts(Base parent, List contracts, ModelResolver resolver) - throws ContributionResolveException { - - String parentName = (parent instanceof Composite) ? ((Composite)parent).getName().toString() : - (parent instanceof Component) ? ((Component)parent).getName().toString() : "UNKNOWN"; - - for (Contract contract : contracts) { - try { - //resolve the intents and policysets as they need to be copied over into the - //child binding elements - resolveIntents(contract.getRequiredIntents(), resolver); - resolvePolicySets(contract.getPolicySets(), resolver); - resolvePolicySets(contract.getApplicablePolicySets(), resolver); - - //inherit the composite / component level policy intents and policysets - if ( parent != null && parent instanceof PolicySetAttachPoint ) { - addInheritedIntents(((PolicySetAttachPoint)parent).getRequiredIntents(), contract.getRequiredIntents()); - addInheritedPolicySets(((PolicySetAttachPoint)parent).getPolicySets(), contract.getPolicySets()); - addInheritedPolicySets(((PolicySetAttachPoint)parent).getApplicablePolicySets(), contract.getApplicablePolicySets()); - } - - for ( ConfiguredOperation confOp : contract.getConfiguredOperations() ) { - resolveIntents(confOp.getRequiredIntents(), resolver); - resolvePolicySets(confOp.getPolicySets(), resolver); - resolvePolicySets(confOp.getApplicablePolicySets(), resolver); - - //inherit intents and policysets from parent contract - addInheritedIntents(contract.getRequiredIntents(), confOp.getRequiredIntents()); - addInheritedPolicySets(contract.getPolicySets(), confOp.getPolicySets()); - addInheritedPolicySets(contract.getApplicablePolicySets(), confOp.getApplicablePolicySets()); - } - - // Resolve the interface contract - InterfaceContract interfaceContract = contract.getInterfaceContract(); - if (interfaceContract != null) { - extensionProcessor.resolve(interfaceContract, resolver); - } - - // Resolve bindings - for (int i = 0, n = contract.getBindings().size(); i < n; i++) { - Binding binding = contract.getBindings().get(i); - extensionProcessor.resolve(binding, resolver); - - if (binding instanceof IntentAttachPoint) { - IntentAttachPoint policiedBinding = (IntentAttachPoint)binding; - - if ( policiedBinding.getType().isUnresolved() ) { - IntentAttachPointType resolved = - resolver.resolveModel(IntentAttachPointType.class, - policiedBinding.getType()); - policiedBinding.setType(resolved); - } - - resolveIntents(policiedBinding.getRequiredIntents(), resolver); - PolicyValidationUtils.validateIntents(policiedBinding, policiedBinding.getType()); - } - - if (binding instanceof PolicySetAttachPoint) { - PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding; - resolvePolicySets(policiedBinding.getPolicySets(), resolver); - //validate if attached policysets apply to the binding - resolvePolicySets(policiedBinding.getApplicablePolicySets(), resolver); - //inherit the applicable policysets from parent contract as whatever applies to that - //applies to the binding as well - addInheritedPolicySets(contract.getApplicablePolicySets(), policiedBinding.getApplicablePolicySets()); - PolicyValidationUtils.validatePolicySets(policiedBinding); - } - - if (binding instanceof OperationsConfigurator) { - OperationsConfigurator opConfigurator = (OperationsConfigurator)binding; - for (ConfiguredOperation confOp : opConfigurator.getConfiguredOperations()) { - resolveIntents(confOp.getRequiredIntents(), resolver); - PolicyValidationUtils.validateIntents(confOp, ((PolicySetAttachPoint)binding).getType()); - - resolvePolicySets(confOp.getPolicySets(), resolver); - resolvePolicySets(confOp.getApplicablePolicySets(), resolver); - //inherit the applicable policysets from parent binding as whatever applies to that - //applies to the binding as well - addInheritedPolicySets(((PolicySetAttachPoint)binding).getApplicablePolicySets(), - confOp.getApplicablePolicySets()); - PolicyValidationUtils.validatePolicySets(confOp, ((PolicySetAttachPoint)binding).getType()); - - addInheritedIntents(((PolicySetAttachPoint)binding).getRequiredIntents(), - confOp.getRequiredIntents()); - addInheritedPolicySets(((PolicySetAttachPoint)binding).getPolicySets(), - confOp.getPolicySets()); - } - } - } - - // Resolve callback bindings - if (contract.getCallback() != null) { - resolveIntents(contract.getCallback().getRequiredIntents(), resolver); - resolvePolicySets(contract.getCallback().getPolicySets(), resolver); - resolvePolicySets(contract.getCallback().getApplicablePolicySets(), resolver); - //inherit the contract's policy intents and policysets - addInheritedIntents(contract.getRequiredIntents(), contract.getCallback().getRequiredIntents()); - addInheritedPolicySets(contract.getPolicySets(), contract.getCallback().getPolicySets()); - addInheritedPolicySets(contract.getApplicablePolicySets(), contract.getCallback().getApplicablePolicySets()); - - for (int i = 0, n = contract.getCallback().getBindings().size(); i < n; i++) { - Binding binding = contract.getCallback().getBindings().get(i); - extensionProcessor.resolve(binding, resolver); - - if (binding instanceof IntentAttachPoint) { - IntentAttachPoint policiedBinding = (IntentAttachPoint)binding; - - if ( policiedBinding.getType().isUnresolved() ) { - IntentAttachPointType resolved = - resolver.resolveModel(IntentAttachPointType.class, - policiedBinding.getType()); - policiedBinding.setType(resolved); - } - - resolveIntents(policiedBinding.getRequiredIntents(), resolver); - PolicyValidationUtils.validateIntents(policiedBinding, policiedBinding.getType()); - } - - if (binding instanceof PolicySetAttachPoint) { - PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding; - resolvePolicySets(policiedBinding.getPolicySets(), resolver); - //validate if attached policysets apply to the binding - resolvePolicySets(policiedBinding.getApplicablePolicySets(), resolver); - //inherit the applicable policysets from parent contract as whatever applies to that - //applies to the binding as well - addInheritedPolicySets(contract.getApplicablePolicySets(), policiedBinding.getApplicablePolicySets()); - PolicyValidationUtils.validatePolicySets(policiedBinding); - } - - if (binding instanceof OperationsConfigurator) { - OperationsConfigurator opConfigurator = (OperationsConfigurator)binding; - for (ConfiguredOperation confOp : opConfigurator.getConfiguredOperations()) { - resolveIntents(confOp.getRequiredIntents(), resolver); - PolicyValidationUtils.validateIntents(confOp, ((PolicySetAttachPoint)binding).getType()); - - resolvePolicySets(confOp.getPolicySets(), resolver); - resolvePolicySets(confOp.getApplicablePolicySets(), resolver); - //inherit the applicable policysets from parent binding as whatever applies to that - //applies to the binding as well - addInheritedPolicySets(((PolicySetAttachPoint)binding).getApplicablePolicySets(), - confOp.getApplicablePolicySets()); - PolicyValidationUtils.validatePolicySets(confOp, ((PolicySetAttachPoint)binding).getType()); - } - } - } - } - } catch ( PolicyValidationException e ) { - throw new ContributionResolveException("PolicyValidation exceptions when processing service/reference '" - + contract.getName() + "' in '" + parentName + "'"); - } - } - } - - /** - * Resolve interface and callback interface on a list of abstract contracts. - * @param contracts the list of contracts - * @param resolver the resolver to use to resolve models - */ - protected void resolveAbstractContracts(List contracts, ModelResolver resolver) - throws ContributionResolveException { - for (AbstractContract contract : contracts) { - - // Resolve the interface contract - InterfaceContract interfaceContract = contract.getInterfaceContract(); - if (interfaceContract != null) { - extensionProcessor.resolve(interfaceContract, resolver); - } - } - } - - /** - * Returns a constrainingType attribute. - * @param componentType - * @return - */ - protected XAttr writeConstrainingType(ComponentType componentType) { - ConstrainingType constrainingType = componentType.getConstrainingType(); - if (constrainingType != null) - return new XAttr(Constants.CONSTRAINING_TYPE, constrainingType.getName()); - else - return null; - } - - /** - * Read a property value into a DOM document. - * @param element - * @param type - * @param reader - * @return - * @throws XMLStreamException - * @throws ContributionReadException - * @throws ParserConfigurationException - */ - protected Document readPropertyValue(QName element, QName type, XMLStreamReader reader) throws XMLStreamException, - ContributionReadException { - - Document document; - try { - if (documentBuilderFactory == null) { - documentBuilderFactory = DocumentBuilderFactory.newInstance(); - documentBuilderFactory.setNamespaceAware(true); - } - document = documentBuilderFactory.newDocumentBuilder().newDocument(); - } catch (ParserConfigurationException e) { - throw new ContributionReadException(e); - } - - // root element has no namespace and local name "value" - Element root = document.createElementNS(null, "value"); - if (type != null) { - org.w3c.dom.Attr xsi = document.createAttributeNS(XMLNS_ATTRIBUTE_NS_URI, "xmlns:xsi"); - xsi.setValue(W3C_XML_SCHEMA_INSTANCE_NS_URI); - root.setAttributeNodeNS(xsi); - - String prefix = type.getPrefix(); - if (prefix == null || prefix.length() == 0) { - prefix = "ns"; - } - - declareNamespace(root, prefix, type.getNamespaceURI()); - - org.w3c.dom.Attr xsiType = document.createAttributeNS(W3C_XML_SCHEMA_INSTANCE_NS_URI, "xsi:type"); - xsiType.setValue(prefix + ":" + type.getLocalPart()); - root.setAttributeNodeNS(xsiType); - } - document.appendChild(root); - - loadElement(reader, root); - return document; - } - - /** - * Create a DOM element - * @param document - * @param name - * @return - */ - private Element createElement(Document document, QName name) { - String prefix = name.getPrefix(); - String qname = - (prefix != null && prefix.length() > 0) ? prefix + ":" + name.getLocalPart() : name.getLocalPart(); - return document.createElementNS(name.getNamespaceURI(), qname); - } - - /** - * Declare a namespace. - * @param element - * @param prefix - * @param ns - */ - private void declareNamespace(Element element, String prefix, String ns) { - if (ns == null) { - ns = ""; - } - if (prefix == null) { - prefix = ""; - } - String qname = null; - if ("".equals(prefix)) { - qname = "xmlns"; - } else { - qname = "xmlns:" + prefix; - } - Node node = element; - boolean declared = false; - while (node != null && node.getNodeType() == Node.ELEMENT_NODE) { - NamedNodeMap attrs = node.getAttributes(); - if (attrs == null) { - break; - } - Node attr = attrs.getNamedItem(qname); - if (attr != null) { - declared = ns.equals(attr.getNodeValue()); - break; - } - node = node.getParentNode(); - } - if (!declared) { - org.w3c.dom.Attr attr = element.getOwnerDocument().createAttributeNS(XMLNS_ATTRIBUTE_NS_URI, qname); - attr.setValue(ns); - element.setAttributeNodeNS(attr); - } - } - - /** - * Load a property value specification from an StAX stream into a DOM - * Document. Only elements, text and attributes are processed; all comments - * and other whitespace are ignored. - * - * @param reader the stream to read from - * @param root the DOM node to load - * @throws javax.xml.stream.XMLStreamException - */ - private void loadElement(XMLStreamReader reader, Element root) throws XMLStreamException { - Document document = root.getOwnerDocument(); - Node current = root; - while (true) { - switch (reader.next()) { - case XMLStreamConstants.START_ELEMENT: - QName name = reader.getName(); - Element child = createElement(document, name); - - // push the new element and make it the current one - current.appendChild(child); - current = child; - - int count = reader.getNamespaceCount(); - for (int i = 0; i < count; i++) { - String prefix = reader.getNamespacePrefix(i); - String ns = reader.getNamespaceURI(i); - declareNamespace(child, prefix, ns); - } - - if (!"".equals(name.getNamespaceURI())) { - declareNamespace(child, name.getPrefix(), name.getNamespaceURI()); - } - - // add the attributes for this element - count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - String ns = reader.getAttributeNamespace(i); - String prefix = reader.getAttributePrefix(i); - String qname = reader.getAttributeLocalName(i); - String value = reader.getAttributeValue(i); - if (prefix != null && prefix.length() != 0) { - qname = prefix + ":" + qname; - } - child.setAttributeNS(ns, qname, value); - if (ns != null) { - declareNamespace(child, prefix, ns); - } - } - - break; - case XMLStreamConstants.CDATA: - current.appendChild(document.createCDATASection(reader.getText())); - break; - case XMLStreamConstants.CHARACTERS: - current.appendChild(document.createTextNode(reader.getText())); - break; - case XMLStreamConstants.END_ELEMENT: - // if we are back at the root then we are done - if (current == root) { - return; - } - - // pop the element off the stack - current = current.getParentNode(); - } - } - } - - /** - * Resolve policy intents attached to a specific SCA Artifact - * @param policyIntents list of policy intents - * @param resolver - */ - protected void resolveIntents(List policyIntents, ModelResolver resolver) { - List requiredIntents = new ArrayList(); - Intent resolvedIntent = null; - for (Intent intent : policyIntents) { - resolvedIntent = resolver.resolveModel(Intent.class, intent); - requiredIntents.add(resolvedIntent); - } - policyIntents.clear(); - policyIntents.addAll(requiredIntents); - } - - /** - * Resolve policy sets attached to a specific SCA Construct - * @param policySets list of attached policy sets - * @param resolver - */ - protected void resolvePolicySets(List policySets, ModelResolver resolver) { - List resolvedPolicySets = new ArrayList(); - PolicySet resolvedPolicySet = null; - for (PolicySet policySet : policySets) { - resolvedPolicySet = resolver.resolveModel(PolicySet.class, policySet); - resolvedPolicySets.add(resolvedPolicySet); - } - policySets.clear(); - policySets.addAll(resolvedPolicySets); - } - - /** - * Write the value of a property - * @param document - * @param element - * @param type - * @param writer - * @throws XMLStreamException - */ - protected void writePropertyValue(Object propertyValue, QName element, QName type, XMLStreamWriter writer) - throws XMLStreamException { - - if (propertyValue instanceof Document) { - Document document = (Document)propertyValue; - NodeList nodeList = document.getDocumentElement().getChildNodes(); - - for (int item = 0; item < nodeList.getLength(); ++item) { - Node node = nodeList.item(item); - int nodeType = node.getNodeType(); - if (nodeType == Node.ELEMENT_NODE) { - XMLStreamReader reader = - XMLInputFactory.newInstance().createXMLStreamReader(new DOMSource(node)); - - while (reader.hasNext()) { - switch (reader.next()) { - case XMLStreamConstants.START_ELEMENT: - QName name = reader.getName(); - writer.writeStartElement(name.getPrefix(), name.getLocalPart(), name.getNamespaceURI()); - - int namespaces = reader.getNamespaceCount(); - for (int i = 0; i < namespaces; i++) { - String prefix = reader.getNamespacePrefix(i); - String ns = reader.getNamespaceURI(i); - writer.writeNamespace(prefix, ns); - } - - if (!"".equals(name.getNamespaceURI())) { - writer.writeNamespace(name.getPrefix(), name.getNamespaceURI()); - } - - // add the attributes for this element - namespaces = reader.getAttributeCount(); - for (int i = 0; i < namespaces; i++) { - String ns = reader.getAttributeNamespace(i); - String prefix = reader.getAttributePrefix(i); - String qname = reader.getAttributeLocalName(i); - String value = reader.getAttributeValue(i); - - writer.writeAttribute(prefix, ns, qname, value); - } - - break; - case XMLStreamConstants.CDATA: - writer.writeCData(reader.getText()); - break; - case XMLStreamConstants.CHARACTERS: - writer.writeCharacters(reader.getText()); - break; - case XMLStreamConstants.END_ELEMENT: - writer.writeEndElement(); - break; - } - } - } else { - writer.writeCharacters(node.getTextContent()); - } - } - } - } - - protected void addInheritedIntents(List sourceList, List targetList) { - if (sourceList != null) { - targetList.addAll(sourceList); - } - } - - protected void addInheritedPolicySets(List sourceList, List targetList) { - if (sourceList != null) { - targetList.addAll(sourceList); - } - } - - - /*protected void validatePolicySets(PolicySetAttachPoint policySetAttachPoint) - throws ContributionResolveException { - validatePolicySets(policySetAttachPoint, policySetAttachPoint.getApplicablePolicySets()); - } - - - protected void validatePolicySets(PolicySetAttachPoint policySetAttachPoint, - List applicablePolicySets) throws ContributionResolveException { - //Since the applicablePolicySets in a policySetAttachPoint will already have the - //list of policysets that might ever be applicable to this attachPoint, just check - //if the defined policysets feature in the list of applicable policysets - IntentAttachPointType attachPointType = policySetAttachPoint.getType(); - for ( PolicySet definedPolicySet : policySetAttachPoint.getPolicySets() ) { - if ( !definedPolicySet.isUnresolved() ) { - if ( !applicablePolicySets.contains(definedPolicySet)) { - throw new ContributionResolveException("Policy Set '" + definedPolicySet.getName() - + "' does not apply to binding type " - + attachPointType.getName()); - } - } else { - throw new ContributionResolveException("Policy Set '" + definedPolicySet.getName() - + "' is not defined in this domain "); - - - } - } - }*/ -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java b/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java deleted file mode 100644 index 2950ef5a04..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.net.URL; -import java.net.URLConnection; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.sca.assembly.ComponentType; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; - -/** - * A componentType processor. - * - * @version $Rev: 635373 $ $Date: 2008-03-09 14:51:51 -0700 (Sun, 09 Mar 2008) $ - */ -public class ComponentTypeDocumentProcessor extends BaseAssemblyProcessor implements URLArtifactProcessor { - private XMLInputFactory inputFactory; - - /** - * Constructs a new componentType processor. - * @param factory - * @param policyFactory - * @param registry - */ - public ComponentTypeDocumentProcessor(StAXArtifactProcessor staxProcessor, XMLInputFactory inputFactory) { - super(null, null, staxProcessor); - this.inputFactory = inputFactory; - } - - public ComponentType read(URL contributionURL, URI uri, URL url) throws ContributionReadException { - InputStream urlStream = null; - try { - - // Create a stream reader - URLConnection connection = url.openConnection(); - connection.setUseCaches(false); - urlStream = connection.getInputStream(); - XMLStreamReader reader = inputFactory.createXMLStreamReader(url.toString(), urlStream); - reader.nextTag(); - - // Reader the componentType model - ComponentType componentType = (ComponentType)extensionProcessor.read(reader); - if (componentType != null) { - componentType.setURI(uri.toString()); - } - - // For debugging purposes, write it back to XML -// if (componentType != null) { -// try { -// ByteArrayOutputStream bos = new ByteArrayOutputStream(); -// XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); -// outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE); -// extensionProcessor.write(componentType, outputFactory.createXMLStreamWriter(bos)); -// Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(bos.toByteArray())); -// OutputFormat format = new OutputFormat(); -// format.setIndenting(true); -// format.setIndent(2); -// XMLSerializer serializer = new XMLSerializer(System.out, format); -// serializer.serialize(document); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// } - - return componentType; - - } catch (XMLStreamException e) { - throw new ContributionReadException(e); - } catch (IOException e) { - throw new ContributionReadException(e); - } finally { - try { - if (urlStream != null) { - urlStream.close(); - urlStream = null; - } - } catch (IOException ioe) { - //ignore - } - } - } - - public void resolve(ComponentType componentType, ModelResolver resolver) throws ContributionResolveException { - extensionProcessor.resolve(componentType, resolver); - } - - public String getArtifactType() { - return ".componentType"; - } - - public Class getModelType() { - return ComponentType.class; - } -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java b/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java deleted file mode 100644 index 241e18badf..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.sca.assembly.ComponentType; -import org.apache.tuscany.sca.contribution.Contribution; -import org.apache.tuscany.sca.contribution.Import; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.java.JavaImport; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; - -/** - * A Model Resolver for ComponentType models. - * - * @version $Rev: 631056 $ $Date: 2008-02-25 17:28:13 -0800 (Mon, 25 Feb 2008) $ - */ -public class ComponentTypeModelResolver implements ModelResolver { - private Contribution contribution; - private Map map = new HashMap(); - - public ComponentTypeModelResolver(Contribution contribution, ModelFactoryExtensionPoint modelFactories) { - this.contribution = contribution; - } - - public void addModel(Object resolved) { - ComponentType componentType = (ComponentType)resolved; - map.put(componentType.getURI(), componentType); - } - - public Object removeModel(Object resolved) { - return map.remove(((ComponentType)resolved).getURI()); - } - - public T resolveModel(Class modelClass, T unresolved) { - - //get componentType artifact URI - String uri = ((ComponentType)unresolved).getURI(); - if (uri == null) { - return (T)unresolved; - } - - //lookup the componentType - ComponentType resolved = (ComponentType) map.get(uri); - if (resolved != null) { - return modelClass.cast(resolved); - } - - //If not found, delegate the resolution to the imports (in this case based on the java imports) - //compute the package name from the componentType URI - if (unresolved instanceof ComponentType) { - //FIXME The core assembly model now depends on java imports to - // resolve componentTypes of all kinds, this is not right at all!!! - int s = uri.lastIndexOf('/'); - if (s != -1) { - String packageName = uri.substring(0, uri.lastIndexOf("/")); - for (Import import_ : this.contribution.getImports()) { - if (import_ instanceof JavaImport) { - JavaImport javaImport = (JavaImport)import_; - //check the import location against the computed package name from the componentType URI - if (javaImport.getPackage().equals(packageName)) { - // Delegate the resolution to the import resolver - resolved = javaImport.getModelResolver().resolveModel(ComponentType.class, (ComponentType)unresolved); - if (!resolved.isUnresolved()) { - return modelClass.cast(resolved); - } - } - } - } - } - } - - return (T)unresolved; - } - -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java b/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java deleted file mode 100644 index 760e202ed2..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java +++ /dev/null @@ -1,355 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_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.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Callback; -import org.apache.tuscany.sca.assembly.ComponentType; -import org.apache.tuscany.sca.assembly.Contract; -import org.apache.tuscany.sca.assembly.Extensible; -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.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 org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.interfacedef.impl.OperationImpl; -import org.apache.tuscany.sca.policy.IntentAttachPoint; -import org.apache.tuscany.sca.policy.PolicyFactory; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; -import org.w3c.dom.Document; - -/** - * A componentType processor. - * - * @version $Rev: 637192 $ $Date: 2008-03-14 11:13:01 -0700 (Fri, 14 Mar 2008) $ - */ -public class ComponentTypeProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor { - - /** - * Constructs a new componentType processor. - * @param factory - * @param policyFactory - * @param registry - */ - public ComponentTypeProcessor(AssemblyFactory factory, PolicyFactory policyFactory, StAXArtifactProcessor extensionProcessor) { - super(factory, policyFactory, extensionProcessor); - } - - public ComponentType read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - ComponentType componentType = null; - Service service = null; - Reference reference = null; - Contract contract = null; - Property property = null; - Callback callback = null; - QName name = null; - - // Read the componentType document - while (reader.hasNext()) { - int event = reader.getEventType(); - switch (event) { - case START_ELEMENT: - name = reader.getName(); - - if (Constants.COMPONENT_TYPE_QNAME.equals(name)) { - - // Read a - componentType = assemblyFactory.createComponentType(); - componentType.setConstrainingType(readConstrainingType(reader)); - - } else if (Constants.SERVICE_QNAME.equals(name)) { - - // Read a - service = assemblyFactory.createService(); - contract = service; - service.setName(getString(reader, Constants.NAME)); - componentType.getServices().add(service); - policyProcessor.readPolicies(service, reader); - - } else if (Constants.REFERENCE_QNAME.equals(name)) { - - // Read a - reference = assemblyFactory.createReference(); - contract = reference; - reference.setName(getString(reader, Constants.NAME)); - reference.setWiredByImpl(getBoolean(reader, Constants.WIRED_BY_IMPL)); - readMultiplicity(reference, reader); - readTargets(reference, reader); - componentType.getReferences().add(reference); - policyProcessor.readPolicies(reference, reader); - - } else if (Constants.PROPERTY_QNAME.equals(name)) { - - // Read a - property = assemblyFactory.createProperty(); - readAbstractProperty(property, reader); - policyProcessor.readPolicies(property, reader); - - // Read the property value - Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader); - property.setValue(value); - - componentType.getProperties().add(property); - - } else if (Constants.IMPLEMENTATION_QNAME.equals(name)) { - - // Read an element - policyProcessor.readPolicies(componentType, reader); - - } else if (Constants.CALLBACK_QNAME.equals(name)) { - - // Read a - callback = assemblyFactory.createCallback(); - contract.setCallback(callback); - policyProcessor.readPolicies(callback, reader); - - } else if (OPERATION.equals(name)) { - - // Read an - Operation operation = new OperationImpl(); - operation.setName(getString(reader, NAME)); - operation.setUnresolved(true); - if (callback != null) { - policyProcessor.readPolicies(callback, operation, reader); - } else { - policyProcessor.readPolicies(contract, operation, reader); - } - } else { - - // Read an extension element - Object extension = extensionProcessor.read(reader); - if (extension != null) { - if (extension instanceof InterfaceContract) { - - // and - contract.setInterfaceContract((InterfaceContract)extension); - - } else if (extension instanceof Binding) { - - // and - if (callback != null) { - callback.getBindings().add((Binding)extension); - } else { - contract.getBindings().add((Binding)extension); - } - } else { - - // Add the extension element to the current element - if (callback != null) { - callback.getExtensions().add(extension); - } else if (contract != null) { - contract.getExtensions().add(extension); - } else if (property != null) { - property.getExtensions().add(extension); - } else { - if (componentType instanceof Extensible) { - ((Extensible)componentType).getExtensions().add(extension); - } - } - } - } - } - break; - - case END_ELEMENT: - name = reader.getName(); - - // Clear current state when reading reaching end element - if (SERVICE_QNAME.equals(name)) { - service = null; - contract = null; - } else if (REFERENCE_QNAME.equals(name)) { - reference = null; - contract = null; - } else if (PROPERTY_QNAME.equals(name)) { - property = null; - } else if (CALLBACK_QNAME.equals(name)) { - callback = null; - } - break; - } - - // Read the next element - if (reader.hasNext()) { - reader.next(); - } - } - return componentType; - } - - public void write(ComponentType componentType, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { - - // Write element - writeStartDocument(writer, COMPONENT_TYPE, - writeConstrainingType(componentType)); - - // Write elements - for (Service service : componentType.getServices()) { - writeStart(writer, SERVICE, new XAttr(NAME, service.getName()), - policyProcessor.writePolicies(service)); - - if (service.getInterfaceContract() != null) { - extensionProcessor.write(service.getInterfaceContract(), writer); - } - - for (Binding binding: service.getBindings()) { - extensionProcessor.write(binding, writer); - } - - if (service.getCallback() != null) { - Callback callback = service.getCallback(); - writeStart(writer, CALLBACK, policyProcessor.writePolicies(callback)); - - for (Binding binding: callback.getBindings()) { - extensionProcessor.write(binding, writer); - } - for (Object extension: callback.getExtensions()) { - extensionProcessor.write(extension, writer); - } - - writeEnd(writer); - } - - for (Object extension: service.getExtensions()) { - extensionProcessor.write(extension, writer); - } - - writeEnd(writer); - } - - // Write elements - for (Reference reference : componentType.getReferences()) { - - writeStart(writer, REFERENCE, - new XAttr(NAME, reference.getName()), - writeTargets(reference), - policyProcessor.writePolicies(reference)); - - extensionProcessor.write(reference.getInterfaceContract(), writer); - - for (Binding binding: reference.getBindings()) { - extensionProcessor.write(binding, writer); - } - - if (reference.getCallback() != null) { - Callback callback = reference.getCallback(); - writeStart(writer, CALLBACK, - policyProcessor.writePolicies(callback)); - - for (Binding binding: callback.getBindings()) { - extensionProcessor.write(binding, writer); - } - for (Object extension: callback.getExtensions()) { - extensionProcessor.write(extension, writer); - } - - writeEnd(writer); - } - - for (Object extension: reference.getExtensions()) { - extensionProcessor.write(extension, writer); - } - - writeEnd(writer); - } - - // Write elements - for (Property property : componentType.getProperties()) { - writeStart(writer, - PROPERTY, - new XAttr(NAME, property.getName()), - new XAttr(MUST_SUPPLY, property.isMustSupply()), - new XAttr(MANY, property.isMany()), - new XAttr(TYPE, property.getXSDType()), - new XAttr(ELEMENT, property.getXSDElement()), - policyProcessor.writePolicies(property)); - - // Write property value - writePropertyValue(property.getValue(), property.getXSDElement(), property.getXSDType(), writer); - - // Write extensions - for (Object extension : property.getExtensions()) { - extensionProcessor.write(extension, writer); - } - - writeEnd(writer); - } - - // Write extension elements - if (componentType instanceof Extensible) { - for (Object extension: ((Extensible)componentType).getExtensions()) { - extensionProcessor.write(extension, writer); - } - } - - // Write elements if the componentType has - // any intents or policySets - boolean writeImplementation = false; - if (componentType instanceof IntentAttachPoint) { - if (!((IntentAttachPoint)componentType).getRequiredIntents().isEmpty()) { - writeImplementation = true; - } - } - if (componentType instanceof PolicySetAttachPoint) { - if (!((PolicySetAttachPoint)componentType).getPolicySets().isEmpty()) { - writeImplementation = true; - } - } - if (writeImplementation) { - writeStart(writer, IMPLEMENTATION, - policyProcessor.writePolicies(componentType)); - } - - writeEndDocument(writer); - } - - public void resolve(ComponentType componentType, ModelResolver resolver) throws ContributionResolveException { - - // Resolve component type services and references - resolveContracts(componentType.getServices(), resolver); - resolveContracts(componentType.getReferences(), resolver); - if ( componentType instanceof PolicySetAttachPoint ) { - resolveIntents(((PolicySetAttachPoint)componentType).getRequiredIntents(), resolver); - resolvePolicySets(((PolicySetAttachPoint)componentType).getPolicySets(), resolver); - } - } - - public QName getArtifactType() { - return COMPONENT_TYPE_QNAME; - } - - public Class getModelType() { - return ComponentType.class; - } -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java b/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java deleted file mode 100644 index 2f3f66e14f..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.net.URL; -import java.net.URLConnection; -import java.util.Collection; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; -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.definitions.SCADefinitions; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.util.PolicyComputationUtils; - -/** - * A composite processor. - * - * @version $Rev: 643489 $ $Date: 2008-04-01 10:06:42 -0800 (Tue, 01 Apr 2008) $ - */ -public class CompositeDocumentProcessor extends BaseAssemblyProcessor implements URLArtifactProcessor { - private XMLInputFactory inputFactory; - private List scaDefnSink; - private Collection domainPolicySets = null; - private int scaDefnsCount = 0; - - /** - * Construct a new composite processor - * @param assemblyFactory - * @param policyFactory - * @param staxProcessor - */ - public CompositeDocumentProcessor(StAXArtifactProcessor staxProcessor, XMLInputFactory inputFactory, List scaDefnsSink) { - super(null, null, staxProcessor); - this.inputFactory = inputFactory; - this.scaDefnSink = scaDefnsSink; - } - - public Composite read(URL contributionURL, URI uri, URL url) throws ContributionReadException { - InputStream scdlStream = null; - try { - if (scaDefnSink != null ) { - fillDomainPolicySets(scaDefnSink); - } - - - byte[] transformedArtifactContent = null; - try { - if ( domainPolicySets != null ) { - transformedArtifactContent = - PolicyComputationUtils.addApplicablePolicySets(url, domainPolicySets); - scdlStream = new ByteArrayInputStream(transformedArtifactContent); - } else { - URLConnection connection = url.openConnection(); - connection.setUseCaches(false); - scdlStream = connection.getInputStream(); - } - } catch ( Exception e ) { - throw new ContributionReadException(e); - } - - XMLStreamReader reader = inputFactory.createXMLStreamReader(scdlStream); - - reader.nextTag(); - - // Read the composite model - Composite composite = (Composite)extensionProcessor.read(reader); - if (composite != null) { - composite.setURI(uri.toString()); - } - - // For debugging purposes, write it back to XML -// if (composite != null) { -// try { -// ByteArrayOutputStream bos = new ByteArrayOutputStream(); -// XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); -// outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE); -// extensionProcessor.write(composite, outputFactory.createXMLStreamWriter(bos)); -// Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(bos.toByteArray())); -// OutputFormat format = new OutputFormat(); -// format.setIndenting(true); -// format.setIndent(2); -// XMLSerializer serializer = new XMLSerializer(System.out, format); -// serializer.serialize(document); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// } - - return composite; - - } catch (XMLStreamException e) { - throw new ContributionReadException(e); - } finally { - try { - if (scdlStream != null) { - scdlStream.close(); - scdlStream = null; - } - } catch (IOException ioe) { - //ignore - } - } - } - - public void resolve(Composite composite, ModelResolver resolver) throws ContributionResolveException { - extensionProcessor.resolve(composite, resolver); - } - - public String getArtifactType() { - return ".composite"; - } - - public Class getModelType() { - return Composite.class; - } - - private void fillDomainPolicySets(List scaDefnsSink) { - Map domainPolicySetMap = null; - if ( scaDefnsSink.size() > scaDefnsCount ) { - //if ( !scaDefnsSink.isEmpty() ) { - domainPolicySetMap = new Hashtable(); - - if ( domainPolicySets != null ) { - for ( PolicySet policySet : domainPolicySets ) { - domainPolicySetMap.put(policySet.getName(), policySet); - } - } - - for ( Object object : scaDefnsSink ) { - if ( object instanceof SCADefinitions ) { - for ( PolicySet policySet : ((SCADefinitions)object).getPolicySets() ) { - domainPolicySetMap.put( policySet.getName(), policySet); - } - } - } - domainPolicySets = domainPolicySetMap.values(); - //scaDefnsSink.clear(); - scaDefnsCount = scaDefnsSink.size(); - } - } -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java b/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java deleted file mode 100644 index e939fe2c05..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -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.Contribution; -import org.apache.tuscany.sca.contribution.Import; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.namespace.NamespaceImport; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; - -/** - * A Model Resolver for Composite models. - * - * @version $Rev: 572482 $ $Date: 2007-09-03 18:28:31 -0700 (Mon, 03 Sep 2007) $ - */ -public class CompositeModelResolver implements ModelResolver { - - private Contribution contribution; - private Map map = new HashMap(); - - public CompositeModelResolver(Contribution contribution, ModelFactoryExtensionPoint modelFactories) { - this.contribution = contribution; - } - - public void addModel(Object resolved) { - Composite composite = (Composite)resolved; - map.put(composite.getName(), composite); - } - - public Object removeModel(Object resolved) { - return map.remove(((Composite)resolved).getName()); - } - - public T resolveModel(Class modelClass, T unresolved) { - - // Lookup a definition for the given namespace - QName qname = ((Composite)unresolved).getName(); - Composite resolved = (Composite) map.get(qname); - if (resolved != null) { - return modelClass.cast(resolved); - } - - // No definition found, delegate the resolution to the imports - for (Import import_ : this.contribution.getImports()) { - if (import_ instanceof NamespaceImport) { - NamespaceImport namespaceImport = (NamespaceImport)import_; - if (namespaceImport.getNamespace().equals(qname.getNamespaceURI())) { - - // Delegate the resolution to the import resolver - resolved = namespaceImport.getModelResolver().resolveModel(Composite.class, (Composite)unresolved); - if (!resolved.isUnresolved()) { - return modelClass.cast(resolved); - } - } - } - } - return (T)unresolved; - } - -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java b/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java deleted file mode 100644 index c74c5bfb5b..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java +++ /dev/null @@ -1,989 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; - -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Callback; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentProperty; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.CompositeReference; -import org.apache.tuscany.sca.assembly.CompositeService; -import org.apache.tuscany.sca.assembly.ConfiguredOperation; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.Contract; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.OperationsConfigurator; -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.assembly.Wire; -import org.apache.tuscany.sca.contribution.Artifact; -import org.apache.tuscany.sca.contribution.ContributionFactory; -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 org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.IntentAttachPointType; -import org.apache.tuscany.sca.policy.PolicyFactory; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; -import org.apache.tuscany.sca.policy.util.PolicyValidationException; -import org.apache.tuscany.sca.policy.util.PolicyValidationUtils; -import org.w3c.dom.Document; - -/** - * A composite processor. - * - * @version $Rev: 639226 $ $Date: 2008-03-20 02:45:37 -0700 (Thu, 20 Mar 2008) $ - */ -public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor { - // FIXME: to be refactored - // private XPathFactory xPathFactory = XPathFactory.newInstance(); - - /** - * Construct a new composite processor - * - * @param contributionFactory - * @param assemblyFactory - * @param policyFactory - * @param extensionProcessor - */ - public CompositeProcessor(ContributionFactory contributionFactory, - AssemblyFactory factory, - PolicyFactory policyFactory, - InterfaceContractMapper interfaceContractMapper, - StAXArtifactProcessor extensionProcessor) { - super(contributionFactory, factory, policyFactory, extensionProcessor); - - } - - /** - * Construct a new composite processor - * - * @param contributionFactory - * @param assemblyFactory - * @param policyFactory - * @param extensionProcessor - */ - public CompositeProcessor(ContributionFactory contributionFactory, - AssemblyFactory factory, - PolicyFactory policyFactory, - StAXArtifactProcessor extensionProcessor) { - super(contributionFactory, factory, policyFactory, extensionProcessor); - } - - public Composite read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - Composite composite = null; - Composite include = null; - Component component = null; - Property property = null; - ComponentService componentService = null; - ComponentReference componentReference = null; - ComponentProperty componentProperty = null; - CompositeService compositeService = null; - CompositeReference compositeReference = null; - Contract contract = null; - Wire wire = null; - Callback callback = null; - QName name = null; - - // Read the composite document - while (reader.hasNext()) { - int event = reader.getEventType(); - switch (event) { - case START_ELEMENT: - name = reader.getName(); - - if (COMPOSITE_QNAME.equals(name)) { - - // Read a - composite = assemblyFactory.createComposite(); - composite.setName(new QName(getString(reader, TARGET_NAMESPACE), getString(reader, NAME))); - if(isSet(reader, AUTOWIRE)) { - composite.setAutowire(getBoolean(reader, AUTOWIRE)); - } - composite.setLocal(getBoolean(reader, LOCAL)); - composite.setConstrainingType(readConstrainingType(reader)); - policyProcessor.readPolicies(composite, reader); - - } else if (INCLUDE_QNAME.equals(name)) { - - // Read an - include = assemblyFactory.createComposite(); - include.setName(getQName(reader, NAME)); - include.setURI(getString(reader, URI)); - include.setUnresolved(true); - composite.getIncludes().add(include); - - } else if (SERVICE_QNAME.equals(name)) { - if (component != null) { - - // Read a - componentService = assemblyFactory.createComponentService(); - contract = componentService; - componentService.setName(getString(reader, NAME)); - component.getServices().add(componentService); - policyProcessor.readPolicies(contract, reader); - } else { - - // Read a - compositeService = assemblyFactory.createCompositeService(); - contract = compositeService; - compositeService.setName(getString(reader, NAME)); - - String promoted = getString(reader, PROMOTE); - String promotedComponentName; - String promotedServiceName; - int s = promoted.indexOf('/'); - if (s == -1) { - promotedComponentName = promoted; - promotedServiceName = null; - } else { - promotedComponentName = promoted.substring(0, s); - promotedServiceName = promoted.substring(s + 1); - } - - Component promotedComponent = assemblyFactory.createComponent(); - promotedComponent.setUnresolved(true); - promotedComponent.setName(promotedComponentName); - compositeService.setPromotedComponent(promotedComponent); - - ComponentService promotedService = assemblyFactory.createComponentService(); - promotedService.setUnresolved(true); - promotedService.setName(promotedServiceName); - compositeService.setPromotedService(promotedService); - - composite.getServices().add(compositeService); - policyProcessor.readPolicies(contract, reader); - } - - } else if (REFERENCE_QNAME.equals(name)) { - if (component != null) { - // Read a - componentReference = assemblyFactory.createComponentReference(); - contract = componentReference; - componentReference.setName(getString(reader, NAME)); - readMultiplicity(componentReference, reader); - if (isSet(reader, AUTOWIRE)) { - componentReference.setAutowire(getBoolean(reader, AUTOWIRE)); - } - readTargets(componentReference, reader); - componentReference.setWiredByImpl(getBoolean(reader, WIRED_BY_IMPL)); - component.getReferences().add(componentReference); - policyProcessor.readPolicies(contract, reader); - } else { - // Read a - compositeReference = assemblyFactory.createCompositeReference(); - contract = compositeReference; - compositeReference.setName(getString(reader, NAME)); - readMultiplicity(compositeReference, reader); - readTargets(compositeReference, reader); - String promote = reader.getAttributeValue(null, Constants.PROMOTE); - if (promote != null) { - for (StringTokenizer tokens = new StringTokenizer(promote); tokens.hasMoreTokens();) { - ComponentReference promotedReference = - assemblyFactory.createComponentReference(); - promotedReference.setUnresolved(true); - promotedReference.setName(tokens.nextToken()); - compositeReference.getPromotedReferences().add(promotedReference); - } - } - compositeReference.setWiredByImpl(getBoolean(reader, WIRED_BY_IMPL)); - composite.getReferences().add(compositeReference); - policyProcessor.readPolicies(contract, reader); - } - - } else if (PROPERTY_QNAME.equals(name)) { - if (component != null) { - - // Read a - componentProperty = assemblyFactory.createComponentProperty(); - property = componentProperty; - String source = getString(reader, SOURCE); - if(source!=null) { - source = source.trim(); - } - componentProperty.setSource(source); - if (source != null) { - // $/... - if (source.charAt(0) == '$') { - int index = source.indexOf('/'); - if (index == -1) { - // Tolerating $prop - source = source + "/"; - index = source.length() - 1; - } - source = source.substring(index + 1); - if ("".equals(source)) { - source = "."; - } - } - - throw new IllegalArgumentException("not implemented in Android!"); - - /* XPath xpath = xPathFactory.newXPath(); - xpath.setNamespaceContext(reader.getNamespaceContext()); - try { - componentProperty.setSourceXPathExpression(xpath.compile(source)); - } catch (XPathExpressionException e) { - throw new ContributionReadException(e); - }*/ - } - componentProperty.setFile(getString(reader, FILE)); - policyProcessor.readPolicies(property, reader); - readAbstractProperty(componentProperty, reader); - - // Read the property value - Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader); - property.setValue(value); - - component.getProperties().add(componentProperty); - } else { - - // Read a - property = assemblyFactory.createProperty(); - policyProcessor.readPolicies(property, reader); - readAbstractProperty(property, reader); - - // Read the property value - Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader); - property.setValue(value); - - composite.getProperties().add(property); - } - - // TUSCANY-1949 - // If the property doesn't have a value, the END_ELEMENT event is read by the readPropertyValue - if (reader.getEventType() == END_ELEMENT && PROPERTY_QNAME.equals(reader.getName())) { - property = null; - componentProperty = null; - } - - } else if (COMPONENT_QNAME.equals(name)) { - - // Read a - component = assemblyFactory.createComponent(); - component.setName(getString(reader, NAME)); - if (isSet(reader, AUTOWIRE)) { - component.setAutowire(getBoolean(reader, AUTOWIRE)); - } - if (isSet(reader, URI)) { - component.setURI(getString(reader, URI)); - } - component.setConstrainingType(readConstrainingType(reader)); - composite.getComponents().add(component); - policyProcessor.readPolicies(component, reader); - - } else if (WIRE_QNAME.equals(name)) { - - // Read a - wire = assemblyFactory.createWire(); - ComponentReference source = assemblyFactory.createComponentReference(); - source.setUnresolved(true); - source.setName(getString(reader, SOURCE)); - wire.setSource(source); - - ComponentService target = assemblyFactory.createComponentService(); - target.setUnresolved(true); - target.setName(getString(reader, TARGET)); - wire.setTarget(target); - - composite.getWires().add(wire); - policyProcessor.readPolicies(wire, reader); - - } else if (CALLBACK_QNAME.equals(name)) { - - // Read a - callback = assemblyFactory.createCallback(); - contract.setCallback(callback); - policyProcessor.readPolicies(callback, reader); - - } else if (OPERATION_QNAME.equals(name)) { - - // Read an - ConfiguredOperation operation = assemblyFactory.createConfiguredOperation(); - operation.setName(getString(reader, NAME)); - operation.setUnresolved(true); - if (callback != null) { - policyProcessor.readPolicies(operation, reader); - } else { - policyProcessor.readPolicies(operation, reader); - } - - OperationsConfigurator opConfigurator = null; - if ( compositeService != null ) { - opConfigurator = compositeService; - } else if ( componentService != null ) { - opConfigurator = componentService; - } else if ( compositeReference != null ) { - opConfigurator = compositeReference; - } else if ( componentReference != null ) { - opConfigurator = componentReference; - } - - opConfigurator.getConfiguredOperations().add(operation); - } else if (IMPLEMENTATION_COMPOSITE_QNAME.equals(name)) { - - // Read an implementation.composite - Composite implementation = assemblyFactory.createComposite(); - implementation.setName(getQName(reader, NAME)); - implementation.setUnresolved(true); - component.setImplementation(implementation); - policyProcessor.readPolicies(implementation, reader); - } else { - - // Read an extension element - Object extension = extensionProcessor.read(reader); - if (extension != null) { - if (extension instanceof InterfaceContract) { - - // and - // - if (contract != null) { - contract.setInterfaceContract((InterfaceContract)extension); - } else { - if (name.getNamespaceURI().equals(SCA10_NS)) { - throw new ContributionReadException( - "Unexpected element found. It should appear inside a or element"); - } else { - composite.getExtensions().add(extension); - } - } - } else if (extension instanceof Binding) { - if ( extension instanceof PolicySetAttachPoint ) { - IntentAttachPointType bindingType = intentAttachPointTypeFactory.createBindingType(); - bindingType.setName(name); - bindingType.setUnresolved(true); - ((PolicySetAttachPoint)extension).setType(bindingType); - } - // and - // - if (callback != null) { - callback.getBindings().add((Binding)extension); - } else { - if (contract != null) { - contract.getBindings().add((Binding)extension); - } else { - if (name.getNamespaceURI().equals(SCA10_NS)) { - throw new ContributionReadException( - "Unexpected element found. It should appear inside a or element"); - } else { - composite.getExtensions().add(extension); - } - } - } - - } else if (extension instanceof Implementation) { - if ( extension instanceof PolicySetAttachPoint ) { - IntentAttachPointType implType = intentAttachPointTypeFactory.createImplementationType(); - implType.setName(name); - implType.setUnresolved(true); - ((PolicySetAttachPoint)extension).setType(implType); - } - // - if (component != null) { - component.setImplementation((Implementation)extension); - } else { - if (name.getNamespaceURI().equals(SCA10_NS)) { - throw new ContributionReadException( - "Unexpected element found. It should appear inside a element"); - } else { - composite.getExtensions().add(extension); - } - } - } else { - - // Add the extension element to the current - // element - if (callback != null) { - callback.getExtensions().add(extension); - } else if (contract != null) { - contract.getExtensions().add(extension); - } else if (property != null) { - property.getExtensions().add(extension); - } else if (component != null) { - component.getExtensions().add(extension); - } else { - composite.getExtensions().add(extension); - } - } - } - } - break; - - case XMLStreamConstants.CHARACTERS: - break; - - case END_ELEMENT: - name = reader.getName(); - - // Clear current state when reading reaching end element - if (SERVICE_QNAME.equals(name)) { - componentService = null; - compositeService = null; - contract = null; - } else if (INCLUDE_QNAME.equals(name)) { - include = null; - } else if (REFERENCE_QNAME.equals(name)) { - componentReference = null; - compositeReference = null; - contract = null; - } else if (PROPERTY_QNAME.equals(name)) { - componentProperty = null; - property = null; - } else if (COMPONENT_QNAME.equals(name)) { - component = null; - } else if (WIRE_QNAME.equals(name)) { - wire = null; - } else if (CALLBACK_QNAME.equals(name)) { - callback = null; - } - break; - } - - // Read the next element - if (reader.hasNext()) { - reader.next(); - } - } - return composite; - } - - public void write(Composite composite, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { - - // Write element - writeStartDocument(writer, - COMPOSITE, - writeConstrainingType(composite), - new XAttr(TARGET_NAMESPACE, composite.getName().getNamespaceURI()), - new XAttr(NAME, composite.getName().getLocalPart()), - new XAttr(AUTOWIRE, composite.getAutowire()), - policyProcessor.writePolicies(composite)); - - // Write elements - for (Composite include : composite.getIncludes()) { - String uri = include.isUnresolved()? include.getURI() : null; - writeStart(writer, - INCLUDE, - new XAttr(NAME, include.getName()), - new XAttr(URI, uri)); - writeEnd(writer); - } - - // Write elements - for (Service service : composite.getServices()) { - CompositeService compositeService = (CompositeService)service; - Component promotedComponent = compositeService.getPromotedComponent(); - ComponentService promotedService = compositeService.getPromotedService(); - String promote; - if (promotedService != null) { - if (promotedService.getName() != null) { - promote = promotedComponent.getName() + '/' + promotedService.getService(); - } else { - promote = promotedComponent.getName(); - } - } else { - promote = null; - } - writeStart(writer, SERVICE, new XAttr(NAME, service.getName()), new XAttr(PROMOTE, promote), - policyProcessor.writePolicies(service)); - - // Write service interface - extensionProcessor.write(service.getInterfaceContract(), writer); - - // Write bindings - for (Binding binding : service.getBindings()) { - extensionProcessor.write(binding, writer); - } - - // Write element - if (service.getCallback() != null) { - Callback callback = service.getCallback(); - writeStart(writer, CALLBACK, - policyProcessor.writePolicies(callback)); - - // Write callback bindings - for (Binding binding : callback.getBindings()) { - extensionProcessor.write(binding, writer); - } - - // Write extensions - for (Object extension : callback.getExtensions()) { - extensionProcessor.write(extension, writer); - } - - writeEnd(writer); - } - - // Write extensions - for (Object extension : service.getExtensions()) { - extensionProcessor.write(extension, writer); - } - - writeEnd(writer); - } - - // Write elements - for (Component component : composite.getComponents()) { - writeStart(writer, COMPONENT, new XAttr(NAME, component.getName()), - new XAttr(URI, component.getURI()), - new XAttr(AUTOWIRE, component.getAutowire()), - policyProcessor.writePolicies(component)); - - // Write the component implementation - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - writeStart(writer, IMPLEMENTATION_COMPOSITE, new XAttr(NAME, composite.getName())); - writeEnd(writer); - } else { - extensionProcessor.write(component.getImplementation(), writer); - } - - // Write elements - for (ComponentService service : component.getServices()) { - writeStart(writer, SERVICE, new XAttr(NAME, service.getName()), - policyProcessor.writePolicies(service)); - - // Write service interface - extensionProcessor.write(service.getInterfaceContract(), writer); - - // Write bindings - for (Binding binding : service.getBindings()) { - extensionProcessor.write(binding, writer); - } - - // Write element - if (service.getCallback() != null) { - Callback callback = service.getCallback(); - writeStart(writer, CALLBACK, policyProcessor.writePolicies(callback)); - - // Write bindings - for (Binding binding : callback.getBindings()) { - extensionProcessor.write(binding, writer); - } - - // Write extensions - for (Object extension : callback.getExtensions()) { - extensionProcessor.write(extension, writer); - } - - writeEnd(writer); - } - - // Write extensions - for (Object extension : service.getExtensions()) { - extensionProcessor.write(extension, writer); - } - - writeEnd(writer); - } - - // Write elements - for (ComponentReference reference : component.getReferences()) { - writeStart(writer, REFERENCE, new XAttr(NAME, reference.getName()), - new XAttr(AUTOWIRE, reference.getAutowire()), - writeTargets(reference), - policyProcessor.writePolicies(reference)); - - // Write reference interface - extensionProcessor.write(reference.getInterfaceContract(), writer); - - // Write bindings - for (Binding binding : reference.getBindings()) { - extensionProcessor.write(binding, writer); - } - - // Write callback - if (reference.getCallback() != null) { - Callback callback = reference.getCallback(); - writeStart(writer, CALLBACK, policyProcessor.writePolicies(callback)); - - // Write callback bindings - for (Binding binding : callback.getBindings()) { - extensionProcessor.write(binding, writer); - } - - // Write extensions - for (Object extensions : callback.getExtensions()) { - extensionProcessor.write(extensions, writer); - } - - writeEnd(writer); - } - - // Write extensions - for (Object extensions : reference.getExtensions()) { - extensionProcessor.write(extensions, writer); - } - - writeEnd(writer); - } - - // Write elements - for (ComponentProperty property : component.getProperties()) { - writeStart(writer, - PROPERTY, - new XAttr(NAME, property.getName()), - new XAttr(MUST_SUPPLY, property.isMustSupply()), - new XAttr(MANY, property.isMany()), - new XAttr(TYPE, property.getXSDType()), - new XAttr(ELEMENT, property.getXSDElement()), - new XAttr(SOURCE, property.getSource()), - new XAttr(FILE, property.getFile()), - policyProcessor.writePolicies(property)); - - // Write property value - writePropertyValue(property.getValue(), property.getXSDElement(), property.getXSDType(), writer); - - // Write extensions - for (Object extension : property.getExtensions()) { - extensionProcessor.write(extension, writer); - } - - writeEnd(writer); - } - - writeEnd(writer); - } - - // Write elements - for (Reference reference : composite.getReferences()) { - CompositeReference compositeReference = (CompositeReference)reference; - - // Write list of promoted references - List promote = new ArrayList(); - for (ComponentReference promoted: compositeReference.getPromotedReferences()) { - promote.add(promoted.getName()); - } - - // Write element - writeStart(writer, REFERENCE, new XAttr(NAME, reference.getName()), - new XAttr(PROMOTE, promote), - policyProcessor.writePolicies(reference)); - - // Write reference interface - extensionProcessor.write(reference.getInterfaceContract(), writer); - - // Write bindings - for (Binding binding : reference.getBindings()) { - extensionProcessor.write(binding, writer); - } - - // Write element - if (reference.getCallback() != null) { - Callback callback = reference.getCallback(); - writeStart(writer, CALLBACK); - - // Write callback bindings - for (Binding binding : callback.getBindings()) { - extensionProcessor.write(binding, writer); - } - - // Write extensions - for (Object extension : callback.getExtensions()) { - extensionProcessor.write(extension, writer); - } - - writeEnd(writer); - } - - // Write extensions - for (Object extension : reference.getExtensions()) { - extensionProcessor.write(extension, writer); - } - - writeEnd(writer); - } - - // Write elements - for (Property property : composite.getProperties()) { - writeStart(writer, - PROPERTY, - new XAttr(NAME, property.getName()), - new XAttr(MUST_SUPPLY, property.isMustSupply()), - new XAttr(MANY, property.isMany()), - new XAttr(TYPE, property.getXSDType()), - new XAttr(ELEMENT, property.getXSDElement()), - policyProcessor.writePolicies(property)); - - // Write property value - writePropertyValue(property.getValue(), property.getXSDElement(), property.getXSDType(), writer); - - // Write extensions - for (Object extension : property.getExtensions()) { - extensionProcessor.write(extension, writer); - } - - writeEnd(writer); - } - - // Write elements - for (Wire wire : composite.getWires()) { - writeStart(writer, WIRE, new XAttr(SOURCE, wire.getSource().getName()), new XAttr(TARGET, wire - .getTarget().getName())); - - // Write extensions - for (Object extension : wire.getExtensions()) { - extensionProcessor.write(extension, writer); - } - writeEnd(writer); - } - - for (Object extension : composite.getExtensions()) { - extensionProcessor.write(extension, writer); - } - - writeEndDocument(writer); - } - - public void resolve(Composite composite, ModelResolver resolver) throws ContributionResolveException { - - // Resolve constraining type - ConstrainingType constrainingType = composite.getConstrainingType(); - if (constrainingType != null) { - constrainingType = resolver.resolveModel(ConstrainingType.class, constrainingType); - composite.setConstrainingType(constrainingType); - } - - // Resolve includes in the composite - for (int i = 0, n = composite.getIncludes().size(); i < n; i++) { - Composite include = composite.getIncludes().get(i); - if (include != null) { - include = resolver.resolveModel(Composite.class, include); - composite.getIncludes().set(i, include); - } - } - - // Resolve extensions - for (Object extension : composite.getExtensions()) { - if (extension != null) { - extensionProcessor.resolve(extension, resolver); - } - } - - //resolve intents and policysets first as they are going to be copied over - //to child elements as and when the child elements are being resolved - List compositeIntents = null; - List compositePolicySets = null; - List compositeApplicablePolicySets = null; - if (composite instanceof PolicySetAttachPoint) { - resolveIntents(((PolicySetAttachPoint)composite).getRequiredIntents(), resolver); - resolvePolicySets(((PolicySetAttachPoint)composite).getPolicySets(), resolver); - resolvePolicySets(((PolicySetAttachPoint)composite).getApplicablePolicySets(), resolver); - compositeIntents = ((PolicySetAttachPoint)composite).getRequiredIntents(); - compositePolicySets = ((PolicySetAttachPoint)composite).getPolicySets(); - compositeApplicablePolicySets = ((PolicySetAttachPoint)composite).getApplicablePolicySets(); - } else { - compositeIntents = new ArrayList(); - compositePolicySets = new ArrayList(); - compositeApplicablePolicySets = new ArrayList(); - } - - //Resolve composite services and references - resolveContracts(composite, composite.getServices(), resolver); - resolveContracts(composite, composite.getReferences(), resolver); - - // Resolve component implementations, services and references - for (Component component : composite.getComponents()) { - constrainingType = component.getConstrainingType(); - if (constrainingType != null) { - constrainingType = resolver.resolveModel(ConstrainingType.class, constrainingType); - component.setConstrainingType(constrainingType); - } - - //resolve intents and policysets first as they are going to be copied over - //to child elements as and when the child elements are being resolved - resolveIntents(component.getRequiredIntents(), resolver); - resolvePolicySets(component.getPolicySets(), resolver); - resolvePolicySets(component.getApplicablePolicySets(), resolver); - - //inherit composite intents and policysets - addInheritedIntents(compositeIntents, component.getRequiredIntents()); - addInheritedPolicySets(compositePolicySets, component.getPolicySets()); - addInheritedPolicySets(compositeApplicablePolicySets, component.getApplicablePolicySets()); - - //resolve component services and references - resolveContracts(component, component.getServices(), resolver); - resolveContracts(component, component.getReferences(), resolver); - - for (ComponentProperty componentProperty : component.getProperties()) { - if (componentProperty.getFile() != null) { - Artifact artifact = contributionFactory.createArtifact(); - artifact.setURI(componentProperty.getFile()); - artifact = resolver.resolveModel(Artifact.class, artifact); - if (artifact.getLocation() != null) { - componentProperty.setFile(artifact.getLocation()); - } - } - } - - //resolve component implementation - Implementation implementation = component.getImplementation(); - if (implementation != null) { - try { - //resolve intents and policysets specified on this implementation - //before copying them over to the component. Before that, from the component - //copy over the applicablePolicySets alone as it might have to be - //used to validate the policysets specified on the implementation - - resolveImplIntentsAndPolicySets(implementation, - component.getApplicablePolicySets(), - resolver); - - copyPoliciesToComponent(component, implementation, resolver, true); - - //now resolve the implementation so that even if there is a shared instance - //for this that is resolved, the specified intents and policysets are safe in the - //component and not lost - implementation = resolveImplementation(implementation, resolver); - - //resolved implementation may contain intents and policysets specified at - //componentType (either in the componentType side file or in annotations if its a - //java implementation). This has to be consolidated in to the component. - copyPoliciesToComponent(component, implementation, resolver, false); - - component.setImplementation(implementation); - } catch ( PolicyValidationException e ) { - throw new ContributionResolveException("PolicyValidation exception when processing implementation of component '" - + component.getName() + "' due to " + e.getMessage(), e); - } - - } - } - } - - private void resolveImplIntentsAndPolicySets(Implementation implementation, - List inheritedApplicablePolicySets, - ModelResolver resolver) throws ContributionResolveException, - PolicyValidationException - { - if ( implementation instanceof PolicySetAttachPoint ) { - PolicySetAttachPoint policiedImpl = (PolicySetAttachPoint)implementation; - - policiedImpl.getApplicablePolicySets().addAll(inheritedApplicablePolicySets); - - resolveIntents(policiedImpl.getRequiredIntents(), resolver); - PolicyValidationUtils.validateIntents(policiedImpl, policiedImpl.getType()); - - resolvePolicySets(policiedImpl.getPolicySets(), resolver); - resolvePolicySets(policiedImpl.getApplicablePolicySets(), resolver); - - PolicyValidationUtils.validatePolicySets(policiedImpl); - - if ( implementation instanceof OperationsConfigurator ) { - for ( ConfiguredOperation implConfOp : ((OperationsConfigurator)implementation).getConfiguredOperations() ) { - resolveIntents(implConfOp.getRequiredIntents(), resolver); - PolicyValidationUtils.validateIntents(implConfOp, policiedImpl.getType()); - - resolvePolicySets(implConfOp.getPolicySets(), resolver); - resolvePolicySets(implConfOp.getApplicablePolicySets(), resolver); - //add the inherited applicablePolicysets - addInheritedPolicySets(policiedImpl.getApplicablePolicySets(), implConfOp.getApplicablePolicySets()); - - PolicyValidationUtils.validatePolicySets(implConfOp, policiedImpl.getType()); - - addInheritedIntents(((PolicySetAttachPoint)implementation).getRequiredIntents(), - implConfOp.getRequiredIntents()); - addInheritedPolicySets(((PolicySetAttachPoint)implementation).getPolicySets(), - implConfOp.getPolicySets()); - } - } - } - } - - private void copyPoliciesToComponent(Component component, - Implementation implementation, - ModelResolver resolver, - boolean clearImplSettings) throws ContributionResolveException { - if (implementation instanceof PolicySetAttachPoint) { - //add implementation policies into component... since implementation instance are - //reused and its likely that this implementation instance will not hold after its resolution - component.getRequiredIntents().addAll(((PolicySetAttachPoint)implementation).getRequiredIntents()); - component.getPolicySets().addAll(((PolicySetAttachPoint)implementation).getPolicySets()); - component.getApplicablePolicySets().addAll(((PolicySetAttachPoint)implementation).getApplicablePolicySets()); - - if ( implementation instanceof OperationsConfigurator ) { - boolean notFound; - List opsFromImplementation = new ArrayList(); - List implConfOperations = - new ArrayList(((OperationsConfigurator)implementation).getConfiguredOperations()); - for ( ConfiguredOperation implConfOp : implConfOperations ) { - notFound = true; - for ( ConfiguredOperation compConfOp : ((OperationsConfigurator)component).getConfiguredOperations() ) { - if ( implConfOp.getName().equals(compConfOp.getName()) ) { - notFound = false; - addInheritedIntents(implConfOp.getRequiredIntents(), compConfOp.getRequiredIntents()); - addInheritedPolicySets(implConfOp.getPolicySets(), compConfOp.getPolicySets()); - addInheritedPolicySets(implConfOp.getApplicablePolicySets(), compConfOp.getApplicablePolicySets()); - notFound = false; - } - } - - if ( notFound ) { - opsFromImplementation.add(implConfOp); - } - - if ( clearImplSettings ) { - ((OperationsConfigurator)implementation).getConfiguredOperations().remove(implConfOp); - } - } - ((OperationsConfigurator)component).getConfiguredOperations().addAll(opsFromImplementation); - } - - if ( clearImplSettings ) { - ((PolicySetAttachPoint)implementation).getRequiredIntents().clear(); - ((PolicySetAttachPoint)implementation).getPolicySets().clear(); - } - } - } - - - public QName getArtifactType() { - return COMPOSITE_QNAME; - } - - public Class getModelType() { - return Composite.class; - } -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConfiguredOperationProcessor.java b/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConfiguredOperationProcessor.java deleted file mode 100644 index 43e0242b7e..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConfiguredOperationProcessor.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.assembly.xml; - -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.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.ConfiguredOperation; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -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 org.apache.tuscany.sca.policy.PolicyFactory; - -/** - * Processor for dealing with 'operation' elements from composite definitions - */ -public class ConfiguredOperationProcessor implements StAXArtifactProcessor, Constants{ - - private AssemblyFactory assemblyFactory; - private PolicyAttachPointProcessor policyProcessor; - private PolicyFactory policyFactory; - - public ConfiguredOperationProcessor(ModelFactoryExtensionPoint modelFactories) { - this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); - this.policyFactory = modelFactories.getFactory(PolicyFactory.class); - this.policyProcessor = new PolicyAttachPointProcessor(policyFactory); - } - - public ConfiguredOperation read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - ConfiguredOperation configuredOp = assemblyFactory.createConfiguredOperation(); - - //Read an - configuredOp.setName(reader.getAttributeValue(null, NAME)); - configuredOp.setContractName(reader.getAttributeValue(null, SERVICE)); - configuredOp.setUnresolved(true); - - // Read policies - policyProcessor.readPolicies(configuredOp, reader); - - //Skip to end element - while (reader.hasNext()) { - if (reader.next() == END_ELEMENT && OPERATION_QNAME.equals(reader.getName())) { - break; - } - } - - return configuredOp; - } - - public void write(ConfiguredOperation configuredOperation, XMLStreamWriter writer) - throws ContributionWriteException, XMLStreamException { - - // Write an - policyProcessor.writePolicyPrefixes(configuredOperation, writer); - writer.writeStartElement(Constants.SCA10_NS, OPERATION); - policyProcessor.writePolicyAttributes(configuredOperation, writer); - - writer.writeAttribute(NAME, configuredOperation.getName()); - if ( configuredOperation.getContractName() != null ) { - writer.writeAttribute(SERVICE, configuredOperation.getContractName()); - } - writer.writeEndElement(); - } - - public void resolve(ConfiguredOperation configuredOperation, ModelResolver resolver) - throws ContributionResolveException { - } - - public QName getArtifactType() { - return OPERATION_QNAME; - } - - public Class getModelType() { - return ConfiguredOperation.class; - } - -} - - diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java b/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java deleted file mode 100644 index 3f471838fc..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import javax.xml.namespace.QName; - -/** - * Constants used in SCA assembly XML files. - */ -public interface Constants { - String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0"; - String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.0"; - - String COMPONENT_TYPE = "componentType"; - QName COMPONENT_TYPE_QNAME = new QName(SCA10_NS, COMPONENT_TYPE); - - String SERVICE = "service"; - QName SERVICE_QNAME = new QName(SCA10_NS, SERVICE); - - String REFERENCE = "reference"; - QName REFERENCE_QNAME = new QName(SCA10_NS, REFERENCE); - - String PROPERTY = "property"; - QName PROPERTY_QNAME = new QName(SCA10_NS, PROPERTY); - - String CONSTRAINING_TYPE = "constrainingType"; - QName CONSTRAINING_TYPE_QNAME = new QName(SCA10_NS, CONSTRAINING_TYPE); - - String COMPOSITE = "composite"; - QName COMPOSITE_QNAME = new QName(SCA10_NS, COMPOSITE); - - String INCLUDE = "include"; - QName INCLUDE_QNAME = new QName(SCA10_NS, INCLUDE); - - String COMPONENT = "component"; - QName COMPONENT_QNAME = new QName(SCA10_NS, COMPONENT); - - String WIRE = "wire"; - QName WIRE_QNAME = new QName(SCA10_NS, WIRE); - - String OPERATION = "operation"; - QName OPERATION_QNAME = new QName(SCA10_NS, OPERATION); - - String CALLBACK = "callback"; - QName CALLBACK_QNAME = new QName(SCA10_NS, CALLBACK); - - String IMPLEMENTATION_COMPOSITE = "implementation.composite"; - QName IMPLEMENTATION_COMPOSITE_QNAME = new QName(SCA10_NS, IMPLEMENTATION_COMPOSITE); - - String IMPLEMENTATION = "implementation"; - QName IMPLEMENTATION_QNAME = new QName(SCA10_NS, IMPLEMENTATION); - - String BINDING_SCA = "binding.sca"; - QName BINDING_SCA_QNAME = new QName(Constants.SCA10_NS, BINDING_SCA); - - String NAME = "name"; - String TARGET_NAMESPACE = "targetNamespace"; - String LOCAL = "local"; - String AUTOWIRE = "autowire"; - String REQUIRES = "requires"; - String POLICY_SETS = "policySets"; - String APPLICABLE_POLICY_SETS = "applicablePolicySets"; - String PROMOTE = "promote"; - String TARGET = "target"; - String WIRED_BY_IMPL = "wiredByImpl"; - String MULTIPLICITY = "multiplicity"; - String TYPE = "type"; - String ELEMENT = "element"; - String MANY = "many"; - String MUST_SUPPLY = "mustSupply"; - String SOURCE = "source"; - String FILE = "file"; - String URI = "uri"; - String ZERO_ONE = "0..1"; - String ZERO_N = "0..n"; - String ONE_ONE = "1..1"; - String ONE_N = "1..n"; -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeDocumentProcessor.java b/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeDocumentProcessor.java deleted file mode 100644 index 8e441f14d3..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeDocumentProcessor.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.net.URL; -import java.net.URLConnection; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.validation.Schema; - -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; - -/** - * A contrainingType content handler. - * - * @version $Rev: 635373 $ $Date: 2008-03-09 14:51:51 -0700 (Sun, 09 Mar 2008) $ - */ -public class ConstrainingTypeDocumentProcessor extends BaseAssemblyProcessor implements URLArtifactProcessor { - private XMLInputFactory inputFactory; - private Schema schema; - - /** - * Construct a new constrainingType processor. - * @param factory - * @param policyFactory - * @param staxProcessor - */ - public ConstrainingTypeDocumentProcessor(StAXArtifactProcessor staxProcessor, XMLInputFactory inputFactory) { - super(null, null, staxProcessor); - this.inputFactory = inputFactory; - } - - public ConstrainingType read(URL contributionURL, URI uri, URL url) throws ContributionReadException { - InputStream urlStream = null; - try { - - // Create a stream reader - URLConnection connection = url.openConnection(); - connection.setUseCaches(false); - urlStream = connection.getInputStream(); - XMLStreamReader reader = inputFactory.createXMLStreamReader(url.toString(), urlStream); - reader.nextTag(); - - // Read the constrainingType model - ConstrainingType constrainingType = (ConstrainingType)extensionProcessor.read(reader); - - // For debugging purposes, write it back to XML -// if (constrainingType != null) { -// try { -// ByteArrayOutputStream bos = new ByteArrayOutputStream(); -// XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); -// outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE); -// extensionProcessor.write(constrainingType, outputFactory.createXMLStreamWriter(bos)); -// Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(bos.toByteArray())); -// OutputFormat format = new OutputFormat(); -// format.setIndenting(true); -// format.setIndent(2); -// XMLSerializer serializer = new XMLSerializer(System.out, format); -// serializer.serialize(document); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// } - - return constrainingType; - - } catch (XMLStreamException e) { - throw new ContributionReadException(e); - } catch (IOException e) { - throw new ContributionReadException(e); - } finally { - try { - if (urlStream != null) { - urlStream.close(); - urlStream = null; - } - } catch (IOException ioe) { - //ignore - } - } - } - - public void resolve(ConstrainingType constrainingType, ModelResolver resolver) throws ContributionResolveException { - extensionProcessor.resolve(constrainingType, resolver); - } - - public String getArtifactType() { - return ".constrainingType"; - } - - public Class getModelType() { - return ConstrainingType.class; - } -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeModelResolver.java b/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeModelResolver.java deleted file mode 100644 index 8ba293d755..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeModelResolver.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import java.util.HashMap; -import java.util.Map; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.contribution.Contribution; -import org.apache.tuscany.sca.contribution.Import; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.namespace.NamespaceImport; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; - -/** - * A Model Resolver for ConstrainingType models. - * - * @version $Rev: 572482 $ $Date: 2007-09-03 18:28:31 -0700 (Mon, 03 Sep 2007) $ - */ -public class ConstrainingTypeModelResolver implements ModelResolver { - - private Contribution contribution; - private Map map = new HashMap(); - - public ConstrainingTypeModelResolver(Contribution contribution, ModelFactoryExtensionPoint modelFactories) { - this.contribution = contribution; - } - - public void addModel(Object resolved) { - ConstrainingType composite = (ConstrainingType)resolved; - map.put(composite.getName(), composite); - } - - public Object removeModel(Object resolved) { - return map.remove(((ConstrainingType)resolved).getName()); - } - - public T resolveModel(Class modelClass, T unresolved) { - - // Lookup a definition for the given namespace - QName qname = ((ConstrainingType)unresolved).getName(); - ConstrainingType resolved = (ConstrainingType) map.get(qname); - if (resolved != null) { - return modelClass.cast(resolved); - } - - // No definition found, delegate the resolution to the imports - for (Import import_ : this.contribution.getImports()) { - if (import_ instanceof NamespaceImport) { - NamespaceImport namespaceImport = (NamespaceImport)import_; - if (namespaceImport.getNamespace().equals(qname.getNamespaceURI())) { - - // Delegate the resolution to the import resolver - resolved = namespaceImport.getModelResolver().resolveModel(ConstrainingType.class, (ConstrainingType)unresolved); - if (!resolved.isUnresolved()) { - return modelClass.cast(resolved); - } - } - } - } - return (T)unresolved; - } - -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java b/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java deleted file mode 100644 index a4200a3881..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_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.assembly.AbstractContract; -import org.apache.tuscany.sca.assembly.AbstractProperty; -import org.apache.tuscany.sca.assembly.AbstractReference; -import org.apache.tuscany.sca.assembly.AbstractService; -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.ConstrainingType; -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 org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.interfacedef.impl.OperationImpl; -import org.apache.tuscany.sca.policy.PolicyFactory; -import org.w3c.dom.Document; - -/** - * A constrainingType processor. - * - * @version $Rev: 637192 $ $Date: 2008-03-14 11:13:01 -0700 (Fri, 14 Mar 2008) $ - */ -public class ConstrainingTypeProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor { - - /** - * Construct a new constrainingType processor. - * @param factory - * @param policyFactory - * @param extensionProcessor - */ - public ConstrainingTypeProcessor(AssemblyFactory factory, PolicyFactory policyFactory, StAXArtifactProcessor extensionProcessor) { - super(factory, policyFactory, extensionProcessor); - } - - public ConstrainingType read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - ConstrainingType constrainingType = null; - AbstractService abstractService = null; - AbstractReference abstractReference = null; - AbstractProperty abstractProperty = null; - AbstractContract abstractContract = null; - QName name = null; - - // Read the constrainingType document - while (reader.hasNext()) { - int event = reader.getEventType(); - switch (event) { - - case START_ELEMENT: - name = reader.getName(); - - // Read a - if (Constants.CONSTRAINING_TYPE_QNAME.equals(name)) { - constrainingType = assemblyFactory.createConstrainingType(); - constrainingType.setName(new QName(getString(reader, TARGET_NAMESPACE), getString(reader, NAME))); - policyProcessor.readPolicies(constrainingType, reader); - - } else if (Constants.SERVICE_QNAME.equals(name)) { - - // Read a - abstractService = assemblyFactory.createAbstractService(); - abstractContract = abstractService; - abstractService.setName(getString(reader, Constants.NAME)); - constrainingType.getServices().add(abstractService); - policyProcessor.readPolicies(abstractService, reader); - - } else if (Constants.REFERENCE_QNAME.equals(name)) { - - // Read a - abstractReference = assemblyFactory.createAbstractReference(); - abstractContract = abstractReference; - abstractReference.setName(getString(reader, Constants.NAME)); - readMultiplicity(abstractReference, reader); - constrainingType.getReferences().add(abstractReference); - policyProcessor.readPolicies(abstractReference, reader); - - } else if (Constants.PROPERTY_QNAME.equals(name)) { - - // Read a - abstractProperty = assemblyFactory.createAbstractProperty(); - readAbstractProperty(abstractProperty, reader); - - // Read the property value - Document value = readPropertyValue(abstractProperty.getXSDElement(), abstractProperty.getXSDType(), reader); - abstractProperty.setValue(value); - - constrainingType.getProperties().add(abstractProperty); - policyProcessor.readPolicies(abstractProperty, reader); - - } else if (OPERATION.equals(name)) { - - // Read an - Operation operation = new OperationImpl(); - operation.setName(getString(reader, NAME)); - operation.setUnresolved(true); - policyProcessor.readPolicies(abstractContract, operation, reader); - - } else { - - // Read an extension element - Object extension = extensionProcessor.read(reader); - if (extension instanceof InterfaceContract) { - - // and - abstractContract.setInterfaceContract((InterfaceContract)extension); - } else { - - // Add the extension element to the current element - if (abstractContract != null) { - abstractContract.getExtensions().add(extension); - } else { - constrainingType.getExtensions().add(extension); - } - - } - } - break; - - case END_ELEMENT: - name = reader.getName(); - - // Clear current state when reading reaching end element - if (SERVICE_QNAME.equals(name)) { - abstractService = null; - abstractContract = null; - } else if (REFERENCE_QNAME.equals(name)) { - abstractReference = null; - abstractContract = null; - } else if (PROPERTY_QNAME.equals(name)) { - abstractProperty = null; - } - break; - } - if (reader.hasNext()) { - reader.next(); - } - } - return constrainingType; - } - - public void write(ConstrainingType constrainingType, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { - - // Write element - writeStartDocument(writer, CONSTRAINING_TYPE, - new XAttr(TARGET_NAMESPACE, constrainingType.getName().getNamespaceURI()), - new XAttr(NAME, constrainingType.getName().getLocalPart()), - policyProcessor.writePolicies(constrainingType)); - - // Write elements - for (AbstractService service : constrainingType.getServices()) { - writeStart(writer, SERVICE, new XAttr(NAME, service.getName()), - policyProcessor.writePolicies(service)); - - extensionProcessor.write(service.getInterfaceContract(), writer); - - for (Object extension: service.getExtensions()) { - extensionProcessor.write(extension, writer); - } - - writeEnd(writer); - } - - // Write elements - for (AbstractReference reference : constrainingType.getReferences()) { - writeStart(writer, REFERENCE, new XAttr(NAME, reference.getName()), - policyProcessor.writePolicies(reference)); - - extensionProcessor.write(reference.getInterfaceContract(), writer); - - for (Object extension: reference.getExtensions()) { - extensionProcessor.write(extension, writer); - } - - writeEnd(writer); - } - - // Write elements - for (AbstractProperty abstractProperty : constrainingType.getProperties()) { - writeStart(writer, - PROPERTY, - new XAttr(NAME, abstractProperty.getName()), - new XAttr(MUST_SUPPLY, abstractProperty.isMustSupply()), - new XAttr(MANY, abstractProperty.isMany()), - new XAttr(TYPE, abstractProperty.getXSDType()), - new XAttr(ELEMENT, abstractProperty.getXSDElement()), - policyProcessor.writePolicies(abstractProperty)); - - // Write property value - writePropertyValue(abstractProperty.getValue(), abstractProperty.getXSDElement(), abstractProperty.getXSDType(), writer); - - // Write extensions - for (Object extension : abstractProperty.getExtensions()) { - extensionProcessor.write(extension, writer); - } - - writeEnd(writer); - } - - // Write extension elements - for (Object extension: constrainingType.getExtensions()) { - extensionProcessor.write(extension, writer); - } - - writeEndDocument(writer); - } - - public void resolve(ConstrainingType constrainingType, ModelResolver resolver) throws ContributionResolveException { - // Resolve component type services and references - resolveAbstractContracts(constrainingType.getServices(), resolver); - resolveAbstractContracts(constrainingType.getReferences(), resolver); - - resolveIntents(constrainingType.getRequiredIntents(), resolver); - for ( AbstractService service : constrainingType.getServices() ) { - resolveIntents(service.getRequiredIntents(), resolver); - } - - for ( AbstractReference reference : constrainingType.getReferences() ) { - resolveIntents(reference.getRequiredIntents(), resolver); - } - } - - public QName getArtifactType() { - return CONSTRAINING_TYPE_QNAME; - } - - public Class getModelType() { - return ConstrainingType.class; - } -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java b/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java deleted file mode 100644 index c862a6f127..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -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.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Base; -import org.apache.tuscany.sca.assembly.ComponentType; -import org.apache.tuscany.sca.assembly.Implementation; -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 org.apache.tuscany.sca.policy.PolicyFactory; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; - -public class DefaultBeanModelProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor { - - private QName artifactType; - private Class modelClass; - private Object modelFactory; - private Method factoryMethod; - private Map setterMethods = new HashMap(); - private Map getterMethods = new HashMap(); - - public DefaultBeanModelProcessor(AssemblyFactory assemblyFactory, - PolicyFactory policyFactory, - QName artifactType, - Class modelClass, - Object modelFactory) { - super(assemblyFactory, policyFactory, null); - this.artifactType = artifactType; - this.modelClass = modelClass; - this.modelFactory = modelFactory; - - // Introspect the factory class and bean model class - if (modelFactory != null) { - - // Find the model create method - for (Method method: modelFactory.getClass().getMethods()) { - if (method.getName().startsWith("create") && method.getReturnType() == modelClass) { - factoryMethod = method; - break; - } - } - } - - // Index the bean's setter methods - for (Method method: modelClass.getMethods()) { - Method getter; - String name = method.getName(); - if (name.startsWith("set") && name.length() > 3) { - - // Get the corresponding getter method - try { - getter = modelClass.getMethod("get" + name.substring(3)); - } catch (Exception e) { - getter = null; - continue; - } - - // Get the property name - name = name.substring(3); - if (name.length() > 1) { - if (!name.toUpperCase().equals(name)) { - name = name.substring(0, 1).toLowerCase() + name.substring(1); - } - } - } else { - continue; - } - - // Map an uppercase property name to a lowercase attribute name - if (name.toUpperCase().equals(name)) { - name = name.toLowerCase(); - } - - // Trim trailing _ from property names - if (name.endsWith("_")) { - name = name.substring(0, name.length()-1); - } - setterMethods.put(name, method); - getterMethods.put(name, getter); - } - } - - public Object read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - - // Read an element - try { - - // Create a new instance of the model - Object model; - if (modelFactory != null) { - // Invoke the factory create method - model = factoryMethod.invoke(modelFactory); - } else { - // Invoke the model bean class default constructor - model = modelClass.newInstance(); - } - - // Initialize the bean properties with the attributes found in the - // XML element - for (int i = 0, n = reader.getAttributeCount(); i < n; i++) { - String attributeName = reader.getAttributeLocalName(i); - Method setter = setterMethods.get(attributeName); - if (setter != null) { - String value = reader.getAttributeValue(i); - setter.invoke(model, value); - } - } - - // Read policies - policyProcessor.readPolicies(model, reader); - - // FIXME read extension elements - - // By default mark the model object unresolved - if (model instanceof Base) { - ((Base)model).setUnresolved(true); - } - - // Skip to end element - while (reader.hasNext()) { - if (reader.next() == END_ELEMENT && artifactType.equals(reader.getName())) { - break; - } - } - return model; - - } catch (Exception e) { - throw new ContributionReadException(e); - } - } - - public void write(Object bean, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { - try { - // Write the bean properties as attributes - List attrs = new ArrayList(); - for (Map.Entry entry: getterMethods.entrySet()) { - if (entry.getValue().getReturnType() == String.class) { - String value = (String)entry.getValue().invoke(bean); - attrs.add(new XAttr(entry.getKey(), value)); - } - } - - // Write element - writeStart(writer, artifactType.getNamespaceURI(), artifactType.getLocalPart(), - policyProcessor.writePolicies(bean), new XAttr(null, attrs)); - - writeEnd(writer); - - } catch (Exception e) { - throw new ContributionWriteException(e); - } - } - - public void resolve(Object bean, ModelResolver resolver) throws ContributionResolveException { - - // Resolve and merge the component type associated with an - // implementation model - if (bean instanceof Implementation) { - Implementation implementation = (Implementation)bean; - String uri = implementation.getURI(); - if (uri != null) { - int d = uri.lastIndexOf('.'); - if (d != -1) { - uri = uri.substring(0, d) + ".componentType"; - - // Resolve the component type - ComponentType componentType = assemblyFactory.createComponentType(); - componentType.setURI(uri); - componentType.setUnresolved(true); - - componentType = resolver.resolveModel(ComponentType.class, componentType); - if (componentType != null && !componentType.isUnresolved()) { - - // We found a component type, merge it into the implementation model - implementation.getServices().addAll(componentType.getServices()); - implementation.getReferences().addAll(componentType.getReferences()); - implementation.getProperties().addAll(componentType.getProperties()); - implementation.setConstrainingType(componentType.getConstrainingType()); - - if (implementation instanceof PolicySetAttachPoint && - componentType instanceof PolicySetAttachPoint ) - { - PolicySetAttachPoint policiedImpl = (PolicySetAttachPoint)implementation; - PolicySetAttachPoint policiedCompType = (PolicySetAttachPoint)componentType; - - if ( policiedImpl.getPolicySets() != null) { - policiedImpl.getPolicySets().addAll(policiedCompType.getPolicySets()); - } - if (policiedImpl.getRequiredIntents() != null) { - policiedImpl.getRequiredIntents().addAll(policiedCompType.getRequiredIntents()); - } - } - } - } - } - } - - // Mark the model resolved - if (bean instanceof Base) { - ((Base)bean).setUnresolved(false); - } - } - - public QName getArtifactType() { - return artifactType; - } - - public Class getModelType() { - return modelClass; - } - -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicyAttachPointProcessor.java b/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicyAttachPointProcessor.java deleted file mode 100644 index 7fd642221b..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicyAttachPointProcessor.java +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -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.assembly.Binding; -import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.IntentAttachPoint; -import org.apache.tuscany.sca.policy.IntentAttachPointType; -import org.apache.tuscany.sca.policy.PolicyFactory; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; - -public class PolicyAttachPointProcessor extends BaseStAXArtifactProcessor implements Constants { - - private PolicyFactory policyFactory; - - public PolicyAttachPointProcessor(PolicyFactory policyFactory) { - this.policyFactory = policyFactory; - } - - /** - * Read policy intents associated with an operation. - * @param attachPoint - * @param operation - * @param reader - */ - private void readIntents(Object attachPoint, Operation operation, XMLStreamReader reader) { - if (!(attachPoint instanceof IntentAttachPoint)) - return; - IntentAttachPoint intentAttachPoint = (IntentAttachPoint)attachPoint; - String value = reader.getAttributeValue(null, REQUIRES); - if (value != null) { - List requiredIntents = intentAttachPoint.getRequiredIntents(); - for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) { - QName qname = getQNameValue(reader, tokens.nextToken()); - Intent intent = policyFactory.createIntent(); - intent.setName(qname); - if (operation != null) { - //FIXME Don't we need to handle intent specification - // on an operation basis? - //intent.getOperations().add(operation); - } - requiredIntents.add(intent); - } - } - } - - /** - * Reads policy intents and policy sets associated with an operation. - * @param attachPoint - * @param operation - * @param reader - */ - public void readPolicies(Object attachPoint, Operation operation, XMLStreamReader reader) { - readIntents(attachPoint, operation, reader); - readPolicySets(attachPoint, operation, reader); - } - - /** - * Reads policy intents and policy sets. - * @param attachPoint - * @param reader - */ - public void readPolicies(Object attachPoint, XMLStreamReader reader) { - readPolicies(attachPoint, null, reader); - } - - /** - * Reads policy sets associated with an operation. - * @param attachPoint - * @param operation - * @param reader - */ - private void readPolicySets(Object attachPoint, Operation operation, XMLStreamReader reader) { - if (!(attachPoint instanceof PolicySetAttachPoint)) { - return; - } - PolicySetAttachPoint policySetAttachPoint = (PolicySetAttachPoint)attachPoint; - String value = reader.getAttributeValue(null, POLICY_SETS); - if (value != null) { - List policySets = policySetAttachPoint.getPolicySets(); - for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) { - QName qname = getQNameValue(reader, tokens.nextToken()); - PolicySet policySet = policyFactory.createPolicySet(); - policySet.setName(qname); - if (operation != null) { - //FIXME Don't we need to handle policySet specification - // on an operation basis? - //policySet.getOperations().add(operation); - } - policySets.add(policySet); - } - } - - value = reader.getAttributeValue(SCA10_TUSCANY_NS, APPLICABLE_POLICY_SETS); - if (value != null) { - List applicablePolicySets = policySetAttachPoint.getApplicablePolicySets(); - for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) { - QName qname = getQNameValue(reader, tokens.nextToken()); - PolicySet policySet = policyFactory.createPolicySet(); - policySet.setName(qname); - if (operation != null) { - //FIXME Don't we need to handle policySet specification - // on an operation basis? - //policySet.getOperations().add(operation); - } - applicablePolicySets.add(policySet); - } - } - } - - /** - * Write policies - * @param attachPoint - * @return - */ - XAttr writePolicies(Object attachPoint) throws XMLStreamException { - return writePolicies(attachPoint, (Operation)null); - } - - /** - * Write policies - * @param attachPoint - * @return - */ - public void writePolicyAttributes(Object attachPoint, XMLStreamWriter writer) throws XMLStreamException { - writePolicyAttributes(attachPoint, (Operation)null, writer); - } - - /** - * Write policies - * @param attachPoint - * @return - */ - public void writePolicyPrefixes(Object attachPoint, XMLStreamWriter writer) throws XMLStreamException { - writePolicyPrefixes(attachPoint, (Operation)null, writer); - } - - /** - * Write policies associated with an operation - * @param attachPoint - * @param operation - * @return - */ - XAttr writePolicies(Object attachPoint, Operation operation) { - List attrs =new ArrayList(); - attrs.add(writeIntents(attachPoint, operation)); - attrs.add(writePolicySets(attachPoint, operation)); - return new XAttr(null, attrs); - } - - /** - * Write policies - * @param attachPoint - * @return - */ - public void writePolicyAttributes(Object attachPoint, Operation operation, XMLStreamWriter writer) throws XMLStreamException { - XAttr attr = writePolicies(attachPoint, operation); - attr.write(writer); - } - - /** - * Write policies - * @param attachPoint - * @return - */ - public void writePolicyPrefixes(Object attachPoint, Operation operation, XMLStreamWriter writer) throws XMLStreamException { - XAttr attr = writePolicies(attachPoint, operation); - attr.writePrefix(writer); - } - - /** - * Write policy intents associated with an operation. - * @param attachPoint - * @param operation - */ - private XAttr writeIntents(Object attachPoint, Operation operation) { - if (!(attachPoint instanceof IntentAttachPoint)) { - return null; - } - IntentAttachPoint intentAttachPoint = (IntentAttachPoint)attachPoint; - List qnames = new ArrayList(); - for (Intent intent: intentAttachPoint.getRequiredIntents()) { - qnames.add(intent.getName()); - } - return new XAttr(Constants.REQUIRES, qnames); - } - - /** - * Write policy sets associated with an operation. - * @param attachPoint - * @param operation - */ - private XAttr writePolicySets(Object attachPoint, Operation operation) { - if (!(attachPoint instanceof PolicySetAttachPoint)) { - return null; - } - PolicySetAttachPoint policySetAttachPoint = (PolicySetAttachPoint)attachPoint; - List qnames = new ArrayList(); - for (PolicySet policySet: policySetAttachPoint.getPolicySets()) { - qnames.add(policySet.getName()); - } - return new XAttr(Constants.POLICY_SETS, qnames); - } - - public void resolvePolicies(Object attachPoint, ModelResolver resolver) { - if ( attachPoint instanceof PolicySetAttachPoint ) { - PolicySetAttachPoint policySetAttachPoint = (PolicySetAttachPoint)attachPoint; - - List requiredIntents = new ArrayList(); - Intent resolvedIntent = null; - - if ( policySetAttachPoint.getRequiredIntents() != null && policySetAttachPoint.getRequiredIntents().size() > 0 ) { - for ( Intent intent : policySetAttachPoint.getRequiredIntents() ) { - resolvedIntent = resolver.resolveModel(Intent.class, intent); - requiredIntents.add(resolvedIntent); - } - policySetAttachPoint.getRequiredIntents().clear(); - policySetAttachPoint.getRequiredIntents().addAll(requiredIntents); - } - - if ( policySetAttachPoint.getPolicySets() != null && policySetAttachPoint.getPolicySets().size() > 0 ) { - List resolvedPolicySets = new ArrayList(); - PolicySet resolvedPolicySet = null; - for ( PolicySet policySet : policySetAttachPoint.getPolicySets() ) { - resolvedPolicySet = resolver.resolveModel(PolicySet.class, policySet); - resolvedPolicySets.add(resolvedPolicySet); - } - policySetAttachPoint.getPolicySets().clear(); - policySetAttachPoint.getPolicySets().addAll(resolvedPolicySets); - } - } - } -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/branches/sca-android/modules/tuscany-assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver deleted file mode 100644 index ecc34942f1..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver +++ /dev/null @@ -1,20 +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. - -org.apache.tuscany.sca.assembly.xml.CompositeModelResolver;model=org.apache.tuscany.sca.assembly.Composite -org.apache.tuscany.sca.assembly.xml.ConstrainingTypeModelResolver;model=org.apache.tuscany.sca.assembly.ConstrainingType -org.apache.tuscany.sca.assembly.xml.ComponentTypeModelResolver;model=org.apache.tuscany.sca.assembly.ComponentType diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java b/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java deleted file mode 100644 index 360cfbbacc..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import java.net.URI; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; -import org.apache.tuscany.sca.assembly.OperationsConfigurator; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl; -import org.apache.tuscany.sca.contribution.DefaultContributionFactory; -import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.DefaultURLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.definitions.SCADefinitions; -import org.apache.tuscany.sca.definitions.xml.SCADefinitionsDocumentProcessor; -import org.apache.tuscany.sca.definitions.xml.SCADefinitionsProcessor; -import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl; -import org.apache.tuscany.sca.policy.DefaultIntentAttachPointTypeFactory; -import org.apache.tuscany.sca.policy.DefaultPolicyFactory; -import org.apache.tuscany.sca.policy.IntentAttachPoint; -import org.apache.tuscany.sca.policy.PolicyFactory; -import org.apache.tuscany.sca.policy.xml.PolicySetProcessor; -import org.apache.tuscany.sca.policy.xml.ProfileIntentProcessor; -import org.apache.tuscany.sca.policy.xml.QualifiedIntentProcessor; -import org.apache.tuscany.sca.policy.xml.SimpleIntentProcessor; - -/** - * Test reading SCA XML assembly documents. - * - * @version $Rev: 561254 $ $Date: 2007-07-31 13:16:27 +0530 (Tue, 31 Jul 2007) $ - */ -public class BuildPolicyTestCase extends TestCase { - private ExtensibleURLArtifactProcessor documentProcessor; - private TestModelResolver resolver; - private SCADefinitionsDocumentProcessor scaDefnDocProcessor; - private CompositeBuilder compositeBuilder; - private Composite composite; - - @Override - public void setUp() throws Exception { - List scaDefnSink = new ArrayList(); - AssemblyFactory factory = new DefaultAssemblyFactory(); - PolicyFactory policyFactory = new DefaultPolicyFactory(); - resolver = new TestModelResolver(); - compositeBuilder = new CompositeBuilderImpl(factory, new TestSCABindingFactoryImpl(), new DefaultIntentAttachPointTypeFactory(), new InterfaceContractMapperImpl(), null); - URLArtifactProcessorExtensionPoint documentProcessors = new DefaultURLArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); - documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors); - - // Create StAX processors - DefaultStAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); - ExtensibleStAXArtifactProcessor staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance()); - staxProcessors.addArtifactProcessor(new CompositeProcessor(new DefaultContributionFactory(), factory, policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new ComponentTypeProcessor(factory, policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new ConstrainingTypeProcessor(factory, policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new SCADefinitionsProcessor(policyFactory, staxProcessor, resolver)); - staxProcessors.addArtifactProcessor(new SimpleIntentProcessor(policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new ProfileIntentProcessor(policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new QualifiedIntentProcessor(policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new PolicySetProcessor(policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new MockPolicyProcessor()); - - XMLInputFactory inputFactory = XMLInputFactory.newInstance(); - - // Create document processors - documentProcessors.addArtifactProcessor(new CompositeDocumentProcessor(staxProcessor, inputFactory, scaDefnSink)); - documentProcessors.addArtifactProcessor(new ComponentTypeDocumentProcessor(staxProcessor, inputFactory)); - documentProcessors.addArtifactProcessor(new ConstrainingTypeDocumentProcessor(staxProcessor, inputFactory)); - scaDefnDocProcessor = new SCADefinitionsDocumentProcessor(staxProcessors, staxProcessor, inputFactory, policyFactory); - documentProcessors.addArtifactProcessor(scaDefnDocProcessor); - - URL url = getClass().getResource("CalculatorComponent.constrainingType"); - URI uri = URI.create("CalculatorComponent.constrainingType"); - ConstrainingType constrainingType = (ConstrainingType)documentProcessor.read(null, uri, url); - assertNotNull(constrainingType); - resolver.addModel(constrainingType); - - url = getClass().getResource("TestAllPolicyCalculator.composite"); - uri = URI.create("TestAllCalculator.constrainingType"); - composite = (Composite)documentProcessor.read(null, uri, url); - assertNotNull(composite); - - url = getClass().getResource("another_test_definitions.xml"); - uri = URI.create("another_test_definitions.xml"); - SCADefinitions scaDefns = (SCADefinitions)scaDefnDocProcessor.read(null, uri, url); - assertNotNull(scaDefns); - scaDefnSink.add(scaDefns); - - //preResolvePolicyTests(composite); - documentProcessor.resolve(scaDefns, resolver); - documentProcessor.resolve(composite, resolver); - //postResolvePolicyTests(composite); - - compositeBuilder.build(composite); - } - - @Override - public void tearDown() throws Exception { - documentProcessor = null; - resolver = null; - } - - public void testPolicyIntentInheritance() throws Exception { - String namespaceUri = "http://test"; - - IntentAttachPoint policiedComposite = (IntentAttachPoint)composite; - assertEquals(policiedComposite.getRequiredIntents().size(), 1); - assertEquals(policiedComposite.getRequiredIntents().get(0).getName(), new QName(namespaceUri, "tuscanyIntent_1")); - - //1 defined for composite, 2 defined for the service, 1 defined and 3 inherited for the promoted service (4) - assertEquals(composite.getServices().get(0).getRequiredIntents().size(), 7); - //1 from the operation defined in this service and 2 from the operation defined in the promoted service - assertEquals(composite.getServices().get(0).getConfiguredOperations().get(0).getRequiredIntents().size(), 5); - assertEquals(composite.getServices().get(0).getRequiredIntents().get(3).getName(), new QName(namespaceUri, "tuscanyIntent_3")); - //bindings will have only 2 intents since duplications will be cut out - assertEquals(((IntentAttachPoint)composite.getServices().get(0).getBindings().get(0)).getRequiredIntents().size(), 3); - assertEquals(((OperationsConfigurator)composite.getServices().get(0).getBindings().get(0)).getConfiguredOperations().size(), 1); - assertEquals(((OperationsConfigurator)composite.getServices().get(0).getBindings().get(0)).getConfiguredOperations().get(0).getRequiredIntents().size(), 5); - - assertEquals(composite.getReferences().get(0).getRequiredIntents().size(), 5); - assertEquals(composite.getReferences().get(0).getConfiguredOperations().size(), 1); - assertEquals(composite.getReferences().get(0).getConfiguredOperations().get(0).getRequiredIntents().size(), 4); - assertEquals(composite.getReferences().get(0).getRequiredIntents().get(1).getName(), new QName(namespaceUri, "tuscanyIntent_1")); - assertEquals(((IntentAttachPoint)composite.getReferences().get(0).getBindings().get(0)).getRequiredIntents().size(), 3); - - assertEquals(composite.getComponents().get(0).getRequiredIntents().size(), 3); - assertEquals(composite.getComponents().get(0).getRequiredIntents().get(2).getName(), new QName(namespaceUri, "tuscanyIntent_1")); - assertEquals(composite.getComponents().get(0).getServices().get(0).getRequiredIntents().size(), 4); - assertEquals(composite.getComponents().get(0).getServices().get(0).getCallback().getRequiredIntents().size(), 4); - assertEquals(composite.getComponents().get(0).getServices().get(0).getConfiguredOperations().get(0).getRequiredIntents().size(), 5); - assertEquals(composite.getComponents().get(0).getReferences().get(0).getRequiredIntents().size(), 5); - assertEquals(composite.getComponents().get(0).getReferences().get(0).getConfiguredOperations().get(0).getRequiredIntents().size(), 5); - } -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MockPolicyProcessor.java b/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MockPolicyProcessor.java deleted file mode 100644 index 2ee4abd99a..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MockPolicyProcessor.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.xml; - -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 org.apache.tuscany.sca.policy.Policy; - -public class MockPolicyProcessor implements StAXArtifactProcessor { - - public QName getArtifactType() { - return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment"); - } - - public Policy read(XMLStreamReader arg0) throws ContributionReadException, XMLStreamException { - return new MockPolicyImplOne(); - } - - public void write(Policy arg0, XMLStreamWriter arg1) throws ContributionWriteException, - XMLStreamException { - } - - public Class getModelType() { - return Policy.class; - } - - public void resolve(Policy arg0, ModelResolver arg1) throws ContributionResolveException { - } - - - public class MockPolicyImplOne implements Policy { - public QName getSchemaName() { - return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment"); - } - - public boolean isUnresolved() { - return false; - } - - public void setUnresolved(boolean unresolved) { - } - - } -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java b/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java deleted file mode 100644 index ffd88cc4a4..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import java.io.InputStream; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Callback; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.CompositeReference; -import org.apache.tuscany.sca.assembly.CompositeService; -import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.contribution.ContributionFactory; -import org.apache.tuscany.sca.contribution.DefaultContributionFactory; -import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.policy.DefaultPolicyFactory; -import org.apache.tuscany.sca.policy.PolicyFactory; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -/** - * Test reading SCA XML assemblies. - * - * @version $Rev: 638855 $ $Date: 2008-03-19 08:04:32 -0700 (Wed, 19 Mar 2008) $ - */ -public class ReadAllTestCase extends TestCase { - private ExtensibleStAXArtifactProcessor staxProcessor; - - @Override - public void setUp() throws Exception { - AssemblyFactory factory = new DefaultAssemblyFactory(); - PolicyFactory policyFactory = new DefaultPolicyFactory(); - ContributionFactory contributionFactory = new DefaultContributionFactory(); - - StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance()); - - staxProcessors.addArtifactProcessor(new CompositeProcessor(contributionFactory, factory, policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new ComponentTypeProcessor(factory, policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new ConstrainingTypeProcessor(factory, policyFactory, staxProcessor)); - } - - @Override - public void tearDown() throws Exception { - } - - public void testReadComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite"); - Composite composite = (Composite)staxProcessor.read(is, Composite.class); - assertNotNull(composite); - assertEquals(composite.getName(), new QName("http://calc", "TestAllCalculator")); - assertEquals(composite.getConstrainingType().getName(), new QName("http://calc", "CalculatorComponent")); - assertTrue(composite.isLocal()); - assertFalse(composite.getAutowire() == Boolean.TRUE); - assertEquals(((PolicySetAttachPoint)composite).getRequiredIntents().get(0).getName(), new QName("http://test", - "confidentiality")); - assertEquals(((PolicySetAttachPoint)composite).getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy")); - - Composite include = composite.getIncludes().get(0); - assertEquals(include.getName(), new QName("http://calc", "TestAllDivide")); - - CompositeService calcCompositeService = (CompositeService)composite.getServices().get(0); - assertEquals(calcCompositeService.getName(), "CalculatorService"); - assertTrue(calcCompositeService.getPromotedService().isUnresolved()); - assertEquals(calcCompositeService.getPromotedService().getName(), - "CalculatorService"); - assertEquals(calcCompositeService.getRequiredIntents().get(0).getName(), - new QName("http://test", "confidentiality")); - assertEquals(calcCompositeService.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy")); - // TODO test operations - Callback calcServiceCallback = calcCompositeService.getCallback(); - assertNotNull(calcServiceCallback); - assertEquals(calcServiceCallback.getRequiredIntents().get(0).getName(), - new QName("http://test", "confidentiality")); - assertEquals(calcServiceCallback.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy")); - // TODO test operations - - Component calcComponent = composite.getComponents().get(0); - assertEquals(calcComponent.getName(), "CalculatorServiceComponent"); - assertEquals(calcComponent.getAutowire(), Boolean.FALSE); - assertEquals(calcComponent.getConstrainingType().getName(), new QName("http://calc", - "CalculatorComponent")); - assertEquals(calcComponent.getRequiredIntents().get(0).getName(), new QName("http://test", - "confidentiality")); - assertEquals(calcComponent.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy")); - - ComponentService calcComponentService = calcComponent.getServices().get(0); - assertEquals(calcComponentService.getName(), "CalculatorService"); - assertEquals(calcComponentService.getRequiredIntents().get(0).getName(), - new QName("http://test", "confidentiality")); - assertEquals(calcComponentService.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy")); - // TODO test operations - - ComponentReference calcComponentReference = calcComponent.getReferences().get(0); - assertEquals(calcComponentReference.getName(), "addService"); - assertEquals(calcComponentReference.getAutowire(), Boolean.FALSE); - assertEquals(calcComponentReference.isWiredByImpl(), false); - assertEquals(calcComponentReference.getRequiredIntents().get(0).getName(), - new QName("http://test", "confidentiality")); - assertEquals(calcComponentReference.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy")); - // TODO test operations - - Property property = calcComponent.getProperties().get(0); - assertEquals(property.getName(), "round"); - Document doc = (Document) property.getValue(); - Element element = doc.getDocumentElement(); - String value = element.getTextContent(); - assertEquals(value, "true"); - assertEquals(property.getXSDType(), new QName("http://www.w3.org/2001/XMLSchema", "boolean")); - assertEquals(property.isMany(), false); - - CompositeReference calcCompositeReference = (CompositeReference)composite.getReferences().get(0); - assertEquals(calcCompositeReference.getName(), "MultiplyService"); - assertTrue(calcCompositeReference.getPromotedReferences().get(0).isUnresolved()); - assertEquals(calcCompositeReference.getPromotedReferences().get(0).getName(), - "CalculatorServiceComponent/multiplyService"); - assertEquals(calcCompositeReference.getRequiredIntents().get(0).getName(), - new QName("http://test", "confidentiality")); - assertEquals(calcCompositeReference.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy")); - // TODO test operations - Callback calcCallback = calcCompositeReference.getCallback(); - assertEquals(calcCompositeReference.getRequiredIntents().get(0).getName(), - new QName("http://test", "confidentiality")); - assertEquals(calcCompositeReference.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy")); - assertNotNull(calcCallback); - // TODO test operations - - //new PrintUtil(System.out).print(composite); - } - -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java b/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java deleted file mode 100644 index 4fe068142d..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import java.net.URI; -import java.net.URL; - -import javax.xml.XMLConstants; -import javax.xml.parsers.SAXParserFactory; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; -import javax.xml.validation.ValidatorHandler; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; -import org.apache.tuscany.sca.contribution.DefaultContributionFactory; -import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.DefaultURLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.DefaultValidatingXMLInputFactory; -import org.apache.tuscany.sca.contribution.processor.DefaultValidationSchemaExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint; -import org.apache.tuscany.sca.policy.DefaultPolicyFactory; -import org.apache.tuscany.sca.policy.PolicyFactory; -import org.xml.sax.InputSource; -import org.xml.sax.XMLReader; - -/** - * Test reading SCA XML assembly documents. - * - * @version $Rev: 639226 $ $Date: 2008-03-20 02:45:37 -0700 (Thu, 20 Mar 2008) $ - */ -public class ReadDocumentTestCase extends TestCase { - - private ExtensibleURLArtifactProcessor documentProcessor; - private TestModelResolver resolver; - private XMLInputFactory inputFactory; - private ExtensibleStAXArtifactProcessor staxProcessor; - - @Override - public void setUp() throws Exception { - AssemblyFactory factory = new DefaultAssemblyFactory(); - PolicyFactory policyFactory = new DefaultPolicyFactory(); - - URLArtifactProcessorExtensionPoint documentProcessors = new DefaultURLArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); - documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors); - - // Create StAX processors - DefaultStAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance()); - staxProcessors.addArtifactProcessor(new CompositeProcessor(new DefaultContributionFactory(), factory, policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new ComponentTypeProcessor(factory, policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new ConstrainingTypeProcessor(factory, policyFactory, staxProcessor)); - - inputFactory = XMLInputFactory.newInstance(); - documentProcessors.addArtifactProcessor(new CompositeDocumentProcessor(staxProcessor, inputFactory, null)); - documentProcessors.addArtifactProcessor(new ComponentTypeDocumentProcessor(staxProcessor, inputFactory)); - documentProcessors.addArtifactProcessor(new ConstrainingTypeDocumentProcessor(staxProcessor, inputFactory)); - - resolver = new TestModelResolver(); - } - - @Override - public void tearDown() throws Exception { - } - - public void testValidateAssembly() throws Exception { - - SchemaFactory schemaFactory; - try { - schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - } catch (Error e) { - // Some old JDKs don't support XMLSchema validation - return; - } catch (Exception e) { - // Some old JDKs don't support XMLSchema validation - return; - } - Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource("tuscany-sca.xsd")); - ValidatorHandler handler = schema.newValidatorHandler(); - - SAXParserFactory parserFactory = SAXParserFactory.newInstance(); - URL url = getClass().getResource("Calculator.composite"); - XMLReader reader = parserFactory.newSAXParser().getXMLReader(); - reader.setFeature("http://xml.org/sax/features/namespaces", true); - reader.setContentHandler(handler); - reader.parse(new InputSource(url.openStream())); - } - - public void testValidateImplementation() throws Exception { - - SchemaFactory schemaFactory; - try { - schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - } catch (Error e) { - // Some old JDKs don't support XMLSchema validation - return; - } catch (Exception e) { - // Some old JDKs don't support XMLSchema validation - return; - } - Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource("tuscany-sca.xsd")); - ValidatorHandler handler = schema.newValidatorHandler(); - - SAXParserFactory parserFactory = SAXParserFactory.newInstance(); - URL url = getClass().getResource("JavaScriptReference.composite"); - XMLReader reader = parserFactory.newSAXParser().getXMLReader(); - reader.setFeature("http://xml.org/sax/features/namespaces", true); - reader.setContentHandler(handler); - reader.parse(new InputSource(url.openStream())); - } - - public void testReadImplementation() throws Exception { - - ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint(); - schemas.addSchema(getClass().getClassLoader().getResource("tuscany-sca.xsd").toString()); - XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas); - CompositeDocumentProcessor compositeDocumentProcessor = new CompositeDocumentProcessor(staxProcessor, validatingInputFactory, null); - - URL url = getClass().getResource("JavaScriptReference.composite"); - URI uri = URI.create("JavaScriptReference.composite"); - Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url); - assertNotNull(composite); - } - - public void testValidateBinding() throws Exception { - - SchemaFactory schemaFactory; - try { - schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - } catch (Error e) { - // Some old JDKs don't support XMLSchema validation - return; - } catch (Exception e) { - // Some old JDKs don't support XMLSchema validation - return; - } - Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource("tuscany-sca.xsd")); - ValidatorHandler handler = schema.newValidatorHandler(); - - SAXParserFactory parserFactory = SAXParserFactory.newInstance(); - URL url = getClass().getResource("RMIBindingTest.composite"); - XMLReader reader = parserFactory.newSAXParser().getXMLReader(); - reader.setFeature("http://xml.org/sax/features/namespaces", true); - reader.setContentHandler(handler); - reader.parse(new InputSource(url.openStream())); - } - - public void testReadBinding() throws Exception { - - ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint(); - schemas.addSchema(getClass().getClassLoader().getResource("tuscany-sca.xsd").toString()); - XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas); - CompositeDocumentProcessor compositeDocumentProcessor = new CompositeDocumentProcessor(staxProcessor, validatingInputFactory, null); - - URL url = getClass().getResource("RMIBindingTest.composite"); - URI uri = URI.create("RMIBindingTest.composite"); - Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url); - assertNotNull(composite); - } - - public void testResolveConstrainingType() throws Exception { - - URL url = getClass().getResource("CalculatorComponent.constrainingType"); - URI uri = URI.create("CalculatorComponent.constrainingType"); - ConstrainingType constrainingType = (ConstrainingType)documentProcessor.read(null, uri, url); - assertNotNull(constrainingType); - resolver.addModel(constrainingType); - - url = getClass().getResource("TestAllCalculator.composite"); - uri = URI.create("TestAllCalculator.constrainingType"); - Composite composite = (Composite)documentProcessor.read(null, uri, url); - assertNotNull(composite); - - documentProcessor.resolve(composite, resolver); - - assertEquals(composite.getConstrainingType(), constrainingType); - assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType); - } - - public void testResolveComposite() throws Exception { - URL url = getClass().getResource("Calculator.composite"); - URI uri = URI.create("Calculator.composite"); - Composite nestedComposite = (Composite)documentProcessor.read(null, uri, url); - assertNotNull(nestedComposite); - resolver.addModel(nestedComposite); - - url = getClass().getResource("TestAllCalculator.composite"); - uri = URI.create("TestAllCalculator.composite"); - Composite composite = (Composite)documentProcessor.read(null, uri, url); - - documentProcessor.resolve(composite, resolver); - - assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite); - } - -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java b/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java deleted file mode 100644 index 5ead95df9d..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import java.io.InputStream; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamReader; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; -import org.apache.tuscany.sca.contribution.DefaultContributionFactory; -import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.policy.DefaultPolicyFactory; -import org.apache.tuscany.sca.policy.PolicyFactory; - -/** - * Test reading SCA XML assemblies. - * - * @version $Rev: 638855 $ $Date: 2008-03-19 08:04:32 -0700 (Wed, 19 Mar 2008) $ - */ -public class ReadTestCase extends TestCase { - - private XMLInputFactory inputFactory; - private DefaultStAXArtifactProcessorExtensionPoint staxProcessors; - private ExtensibleStAXArtifactProcessor staxProcessor; - private AssemblyFactory factory; - private PolicyFactory policyFactory; - - @Override - public void setUp() throws Exception { - factory = new DefaultAssemblyFactory(); - policyFactory = new DefaultPolicyFactory(); - inputFactory = XMLInputFactory.newInstance(); - staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance()); - } - - @Override - public void tearDown() throws Exception { - } - - public void testReadComponentType() throws Exception { - ComponentTypeProcessor componentTypeReader = new ComponentTypeProcessor(factory, policyFactory, staxProcessor); - InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - assertNotNull(componentTypeReader.read(reader)); - is.close(); - } - - public void testReadConstrainingType() throws Exception { - InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType"); - ConstrainingTypeProcessor constrainingTypeReader = new ConstrainingTypeProcessor(factory, policyFactory, staxProcessor); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - assertNotNull(constrainingTypeReader.read(reader)); - is.close(); - - } - - public void testReadComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("Calculator.composite"); - CompositeProcessor compositeReader = new CompositeProcessor(new DefaultContributionFactory(), factory, policyFactory, staxProcessor); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - assertNotNull(compositeReader.read(reader)); - is.close(); - - } - - public void testReadCompositeAndWireIt() throws Exception { - InputStream is = getClass().getResourceAsStream("Calculator.composite"); - CompositeProcessor compositeReader = new CompositeProcessor(new DefaultContributionFactory(), factory, policyFactory, staxProcessor); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - assertNotNull(compositeReader.read(reader)); - is.close(); - } - -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java b/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java deleted file mode 100644 index 6db364950a..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import java.net.URI; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; -import org.apache.tuscany.sca.contribution.DefaultContributionFactory; -import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.DefaultURLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.definitions.SCADefinitions; -import org.apache.tuscany.sca.definitions.xml.SCADefinitionsDocumentProcessor; -import org.apache.tuscany.sca.definitions.xml.SCADefinitionsProcessor; -import org.apache.tuscany.sca.policy.DefaultPolicyFactory; -import org.apache.tuscany.sca.policy.PolicyFactory; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; -import org.apache.tuscany.sca.policy.xml.PolicySetProcessor; -import org.apache.tuscany.sca.policy.xml.ProfileIntentProcessor; -import org.apache.tuscany.sca.policy.xml.QualifiedIntentProcessor; -import org.apache.tuscany.sca.policy.xml.SimpleIntentProcessor; - -/** - * Test reading SCA XML assembly documents. - * - * @version $Rev: 561254 $ $Date: 2007-07-31 13:16:27 +0530 (Tue, 31 Jul 2007) $ - */ -public class ResolvePolicyTestCase extends TestCase { - - private ExtensibleURLArtifactProcessor documentProcessor; - private TestModelResolver resolver; - SCADefinitionsDocumentProcessor scaDefnDocProcessor; - - @Override - public void setUp() throws Exception { - List scaDefnSink = new ArrayList(); - AssemblyFactory factory = new DefaultAssemblyFactory(); - PolicyFactory policyFactory = new DefaultPolicyFactory(); - resolver = new TestModelResolver(); - - URLArtifactProcessorExtensionPoint documentProcessors = new DefaultURLArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); - documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors); - - // Create StAX processors - DefaultStAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); - ExtensibleStAXArtifactProcessor staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance()); - staxProcessors.addArtifactProcessor(new CompositeProcessor(new DefaultContributionFactory(), factory, policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new ComponentTypeProcessor(factory, policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new ConstrainingTypeProcessor(factory, policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new SCADefinitionsProcessor(policyFactory, staxProcessor, resolver)); - staxProcessors.addArtifactProcessor(new SimpleIntentProcessor(policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new ProfileIntentProcessor(policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new QualifiedIntentProcessor(policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new PolicySetProcessor(policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new MockPolicyProcessor()); - - // Create document processors - XMLInputFactory inputFactory = XMLInputFactory.newInstance(); - documentProcessors.addArtifactProcessor(new CompositeDocumentProcessor(staxProcessor, inputFactory, scaDefnSink)); - documentProcessors.addArtifactProcessor(new ComponentTypeDocumentProcessor(staxProcessor, inputFactory)); - documentProcessors.addArtifactProcessor(new ConstrainingTypeDocumentProcessor(staxProcessor, inputFactory)); - scaDefnDocProcessor = new SCADefinitionsDocumentProcessor(staxProcessors, staxProcessor, inputFactory, policyFactory); - documentProcessors.addArtifactProcessor(scaDefnDocProcessor); - } - - @Override - public void tearDown() throws Exception { - } - - public void testResolveConstrainingType() throws Exception { - - URL url = getClass().getResource("CalculatorComponent.constrainingType"); - URI uri = URI.create("CalculatorComponent.constrainingType"); - ConstrainingType constrainingType = (ConstrainingType)documentProcessor.read(null, uri, url); - assertNotNull(constrainingType); - resolver.addModel(constrainingType); - - url = getClass().getResource("TestAllCalculator.composite"); - uri = URI.create("TestAllCalculator.constrainingType"); - Composite composite = (Composite)documentProcessor.read(null, uri, url); - assertNotNull(composite); - - url = getClass().getResource("test_definitions.xml"); - uri = URI.create("test_definitions.xml"); - SCADefinitions scaDefns = (SCADefinitions)scaDefnDocProcessor.read(null, uri, url); - assertNotNull(scaDefns); - - preResolvePolicyTests(composite); - documentProcessor.resolve(scaDefns, resolver); - documentProcessor.resolve(composite, resolver); - postResolvePolicyTests(composite); - - assertEquals(composite.getConstrainingType(), constrainingType); - assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType); - } - - private void preResolvePolicyTests(Composite composite) { - assertNull(((PolicySetAttachPoint)composite).getRequiredIntents().get(0).getDescription()); - assertTrue(((PolicySetAttachPoint)composite).getPolicySets().get(0).getProvidedIntents().isEmpty()); - - assertNull(composite.getServices().get(0).getRequiredIntents().get(0).getDescription()); - assertTrue(composite.getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNull(composite.getServices().get(0).getCallback().getRequiredIntents().get(0).getDescription()); - assertTrue(composite.getServices().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty()); - - assertNull(composite.getComponents().get(0).getRequiredIntents().get(0).getDescription()); - assertTrue(composite.getComponents().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNull(composite.getComponents().get(0).getServices().get(0).getRequiredIntents().get(0).getDescription()); - assertTrue(composite.getComponents().get(0).getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNull(composite.getComponents().get(0).getReferences().get(0).getRequiredIntents().get(0).getDescription()); - assertTrue(composite.getComponents().get(0).getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty()); - - assertNull(composite.getReferences().get(0).getRequiredIntents().get(0).getDescription()); - assertTrue(composite.getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNull(composite.getReferences().get(0).getCallback().getRequiredIntents().get(0).getDescription()); - assertTrue(composite.getReferences().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty()); - } - - private void postResolvePolicyTests(Composite composite) { - assertNotNull(((PolicySetAttachPoint)composite).getRequiredIntents().get(0).getDescription()); - assertFalse(((PolicySetAttachPoint)composite).getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNotNull(((PolicySetAttachPoint)composite).getPolicySets().get(0).getProvidedIntents().get(1).getDescription()); - - assertNotNull(composite.getServices().get(0).getRequiredIntents().get(0).getDescription()); - assertFalse(composite.getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNotNull(composite.getServices().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription()); - assertNotNull(composite.getServices().get(0).getCallback().getRequiredIntents().get(0).getDescription()); - assertFalse(composite.getServices().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNotNull(composite.getServices().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().get(1).getDescription()); - - assertNotNull(composite.getComponents().get(0).getRequiredIntents().get(0).getDescription()); - assertFalse(composite.getComponents().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNotNull(composite.getComponents().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription()); - assertNotNull(composite.getComponents().get(0).getServices().get(0).getRequiredIntents().get(0).getDescription()); - assertFalse(composite.getComponents().get(0).getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNotNull(composite.getComponents().get(0).getServices().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription()); - assertNotNull(composite.getComponents().get(0).getReferences().get(0).getRequiredIntents().get(0).getDescription()); - assertFalse(composite.getComponents().get(0).getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNotNull(composite.getComponents().get(0).getReferences().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription()); - - assertNotNull(composite.getReferences().get(0).getRequiredIntents().get(0).getDescription()); - assertFalse(composite.getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNotNull(composite.getReferences().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription()); - assertNotNull(composite.getReferences().get(0).getCallback().getRequiredIntents().get(0).getDescription()); - assertFalse(composite.getReferences().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNotNull(composite.getReferences().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().get(1).getDescription()); - - - } - - public void testResolveComposite() throws Exception { - URL url = getClass().getResource("Calculator.composite"); - URI uri = URI.create("Calculator.composite"); - Composite nestedComposite = (Composite)documentProcessor.read(null, uri, url); - assertNotNull(nestedComposite); - resolver.addModel(nestedComposite); - - url = getClass().getResource("TestAllCalculator.composite"); - uri = URI.create("TestAllCalculator.composite"); - Composite composite = (Composite)documentProcessor.read(null, uri, url); - - documentProcessor.resolve(composite, resolver); - - assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite); - } - -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java b/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java deleted file mode 100644 index 6f0ef3ad96..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.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.assembly.xml; - -import java.io.InputStream; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamReader; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; -import org.apache.tuscany.sca.contribution.DefaultContributionFactory; -import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.policy.DefaultPolicyFactory; -import org.apache.tuscany.sca.policy.PolicyFactory; - -/** - * Test resolving SCA XML assemblies. - * - * @version $Rev: 638855 $ $Date: 2008-03-19 08:04:32 -0700 (Wed, 19 Mar 2008) $ - */ -public class ResolveTestCase extends TestCase { - - private XMLInputFactory inputFactory; - private DefaultStAXArtifactProcessorExtensionPoint staxProcessors; - private ExtensibleStAXArtifactProcessor staxProcessor; - private TestModelResolver resolver; - private AssemblyFactory factory; - private PolicyFactory policyFactory; - - @Override - public void setUp() throws Exception { - factory = new DefaultAssemblyFactory(); - policyFactory = new DefaultPolicyFactory(); - inputFactory = XMLInputFactory.newInstance(); - staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance()); - resolver = new TestModelResolver(); - } - - @Override - public void tearDown() throws Exception { - } - - public void testResolveConstrainingType() throws Exception { - InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType"); - ConstrainingTypeProcessor constrainingTypeReader = new ConstrainingTypeProcessor(factory, policyFactory, staxProcessor); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - ConstrainingType constrainingType = constrainingTypeReader.read(reader); - is.close(); - assertNotNull(constrainingType); - resolver.addModel(constrainingType); - - is = getClass().getResourceAsStream("TestAllCalculator.composite"); - CompositeProcessor compositeReader = new CompositeProcessor(new DefaultContributionFactory(), factory, policyFactory, staxProcessor); - reader = inputFactory.createXMLStreamReader(is); - Composite composite = compositeReader.read(reader); - is.close(); - assertNotNull(composite); - - compositeReader.resolve(composite, resolver); - - assertEquals(composite.getConstrainingType(), constrainingType); - assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType); - } - - public void testResolveComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("Calculator.composite"); - CompositeProcessor compositeReader = new CompositeProcessor(new DefaultContributionFactory(), factory, policyFactory, staxProcessor); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Composite nestedComposite = compositeReader.read(reader); - is.close(); - assertNotNull(nestedComposite); - resolver.addModel(nestedComposite); - - is = getClass().getResourceAsStream("TestAllCalculator.composite"); - compositeReader = new CompositeProcessor(new DefaultContributionFactory(), factory, policyFactory, staxProcessor); - reader = inputFactory.createXMLStreamReader(is); - Composite composite = compositeReader.read(reader); - is.close(); - - compositeReader.resolve(composite, resolver); - - assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite); - } - -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestModelResolver.java b/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestModelResolver.java deleted file mode 100644 index 5b9292cb17..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestModelResolver.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; - - -/** - * A default implementation of an artifact resolver, based on a map. - * - * @version $Rev: 560306 $ $Date: 2007-07-27 09:31:44 -0700 (Fri, 27 Jul 2007) $ - */ -public class TestModelResolver implements ModelResolver { - private static final long serialVersionUID = -7826976465762296634L; - - private Map map = new HashMap(); - - public TestModelResolver() { - } - - public T resolveModel(Class modelClass, T unresolved) { - Object resolved = map.get(unresolved); - if (resolved != null) { - - // Return the resolved object - return modelClass.cast(resolved); - - } else { - - // Return the unresolved object - return unresolved; - } - } - - public void addModel(Object resolved) { - map.put(resolved, resolved); - } - - public Object removeModel(Object resolved) { - return map.remove(resolved); - } - -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java b/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java deleted file mode 100644 index b28a01e156..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.assembly.SCABindingFactory; - -/** - * A factory for the SCA binding model. - * - * @version $Rev: 563772 $ $Date: 2007-08-07 23:50:49 -0700 (Tue, 07 Aug 2007) $ - */ -public class TestSCABindingFactoryImpl implements SCABindingFactory { - public SCABinding createSCABinding() { - return new TestSCABindingImpl(); - } - -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java b/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java deleted file mode 100644 index acbd44dbc9..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.xml; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.ConfiguredOperation; -import org.apache.tuscany.sca.assembly.OperationsConfigurator; -import org.apache.tuscany.sca.assembly.OptimizableBinding; -import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.IntentAttachPointType; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; - -/** - * A test cheel for the SCA binding. - * - * @version $Rev: 620307 $ $Date: 2008-02-10 10:56:51 -0800 (Sun, 10 Feb 2008) $ - */ -public class TestSCABindingImpl implements SCABinding, OptimizableBinding, PolicySetAttachPoint, OperationsConfigurator { - private String name; - private String uri; - private List extensions = new ArrayList(); - - private Component targetComponent; - private ComponentService targetComponentService; - private Binding targetBinding; - - List requiredIntents = new ArrayList(); - List policySets = new ArrayList(); - IntentAttachPointType bindingType = new TestSCABindingType(); - List configuredOperations = new ArrayList(); - private List applicablePolicySets = new ArrayList(); - - /** - * Constructs a new SCA binding. - */ - protected TestSCABindingImpl() { - } - - public String getName() { - return name; - } - - public String getURI() { - return uri; - } - - public void setName(String name) { - this.name = name; - } - - public void setURI(String uri) { - this.uri = uri; - } - - public List getExtensions() { - return extensions; - } - - public boolean isUnresolved() { - return false; - } - - public void setUnresolved(boolean unresolved) { - } - - /** - * @see java.lang.Object#clone() - */ - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - /** - * @return the targetComponent - */ - public Component getTargetComponent() { - return targetComponent; - } - - /** - * @param targetComponent the targetComponent to set - */ - public void setTargetComponent(Component targetComponent) { - this.targetComponent = targetComponent; - } - - /** - * @return the targetComponentService - */ - public ComponentService getTargetComponentService() { - return targetComponentService; - } - - /** - * @param targetComponentService the targetComponentService to set - */ - public void setTargetComponentService(ComponentService targetComponentService) { - this.targetComponentService = targetComponentService; - } - - /** - * @return the targetBinding - */ - public Binding getTargetBinding() { - return targetBinding; - } - - /** - * @param targetBinding the targetBinding to set - */ - public void setTargetBinding(Binding targetBinding) { - this.targetBinding = targetBinding; - } - - public List getPolicySets() { - // TODO Auto-generated method stub - return policySets; - } - - public List getRequiredIntents() { - // TODO Auto-generated method stub - return requiredIntents; - } - - public IntentAttachPointType getType() { - // TODO Auto-generated method stub - return bindingType; - } - - public void setType(IntentAttachPointType type) { - this.bindingType = type; - } - - private class TestSCABindingType implements IntentAttachPointType { - private QName name = new QName("http://www.osoa.org/xmlns/sca/1.0","binding"); - - public List getAlwaysProvidedIntents() { - // TODO Auto-generated method stub - return null; - } - - public List getMayProvideIntents() { - // TODO Auto-generated method stub - return null; - } - - public QName getName() { - return name; - } - - public boolean isUnresolved() { - // TODO Auto-generated method stub - return false; - } - - public void setName(QName type) { - // TODO Auto-generated method stub - - } - - public void setUnresolved(boolean unresolved) { - // TODO Auto-generated method stub - - } - - } - - public void setPolicySets(List policySets) { - this.policySets = policySets; - } - - public void setRequiredIntents(List intents) { - this.requiredIntents = intents; - } - - public List getConfiguredOperations() { - return configuredOperations; - } - - public void setConfiguredOperations(List configuredOperations) { - this.configuredOperations = configuredOperations; - } - - public List getApplicablePolicySets() { - return applicablePolicySets; - } -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java b/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java deleted file mode 100644 index 8512dcefa1..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import java.io.InputStream; -import java.net.URI; -import java.net.URL; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamReader; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; -import org.apache.tuscany.sca.assembly.SCABindingFactory; -import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl; -import org.apache.tuscany.sca.contribution.DefaultContributionFactory; -import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.definitions.SCADefinitions; -import org.apache.tuscany.sca.definitions.xml.SCADefinitionsDocumentProcessor; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl; -import org.apache.tuscany.sca.policy.DefaultIntentAttachPointTypeFactory; -import org.apache.tuscany.sca.policy.DefaultPolicyFactory; -import org.apache.tuscany.sca.policy.PolicyFactory; - -/** - * Test the wiring of SCA XML assemblies. - * - * @version $Rev: 637129 $ $Date: 2008-03-14 08:11:59 -0700 (Fri, 14 Mar 2008) $ - */ -public class WireTestCase extends TestCase { - - private XMLInputFactory inputFactory; - private DefaultStAXArtifactProcessorExtensionPoint staxProcessors; - private ExtensibleStAXArtifactProcessor staxProcessor; - private TestModelResolver resolver; - private AssemblyFactory assemblyFactory; - private SCABindingFactory scaBindingFactory; - private PolicyFactory policyFactory; - private InterfaceContractMapper mapper; - private SCADefinitionsDocumentProcessor scaDefnDocProcessor; - - @Override - public void setUp() throws Exception { - inputFactory = XMLInputFactory.newInstance(); - staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance()); - resolver = new TestModelResolver(); - assemblyFactory = new DefaultAssemblyFactory(); - scaBindingFactory = new TestSCABindingFactoryImpl(); - policyFactory = new DefaultPolicyFactory(); - mapper = new InterfaceContractMapperImpl(); - - scaDefnDocProcessor = new SCADefinitionsDocumentProcessor(staxProcessors, staxProcessor, inputFactory, policyFactory); - - } - - @Override - public void tearDown() throws Exception { - } - - public void testResolveConstrainingType() throws Exception { - InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType"); - ConstrainingTypeProcessor constrainingTypeReader = new ConstrainingTypeProcessor(assemblyFactory, policyFactory, staxProcessor); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - ConstrainingType constrainingType = constrainingTypeReader.read(reader); - is.close(); - assertNotNull(constrainingType); - resolver.addModel(constrainingType); - - is = getClass().getResourceAsStream("TestAllCalculator.composite"); - CompositeProcessor compositeReader = new CompositeProcessor(new DefaultContributionFactory(), assemblyFactory, policyFactory, staxProcessor); - reader = inputFactory.createXMLStreamReader(is); - Composite composite = compositeReader.read(reader); - is.close(); - assertNotNull(composite); - - URL url = getClass().getResource("test_definitions.xml"); - URI uri = URI.create("test_definitions.xml"); - SCADefinitions scaDefns = (SCADefinitions)scaDefnDocProcessor.read(null, uri, url); - assertNotNull(scaDefns); - - scaDefnDocProcessor.resolve(scaDefns, resolver); - - compositeReader.resolve(composite, resolver); - CompositeBuilderImpl compositeUtil = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, new DefaultIntentAttachPointTypeFactory(), mapper, null); - compositeUtil.build(composite); - - assertEquals(composite.getConstrainingType(), constrainingType); - assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType); - } - - public void testResolveComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("Calculator.composite"); - CompositeProcessor compositeReader = new CompositeProcessor(new DefaultContributionFactory(), assemblyFactory, policyFactory, staxProcessor); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Composite nestedComposite = compositeReader.read(reader); - is.close(); - assertNotNull(nestedComposite); - resolver.addModel(nestedComposite); - - is = getClass().getResourceAsStream("TestAllCalculator.composite"); - compositeReader = new CompositeProcessor(new DefaultContributionFactory(), assemblyFactory, policyFactory, staxProcessor); - reader = inputFactory.createXMLStreamReader(is); - Composite composite = compositeReader.read(reader); - is.close(); - - URL url = getClass().getResource("test_definitions.xml"); - URI uri = URI.create("test_definitions.xml"); - SCADefinitions scaDefns = (SCADefinitions)scaDefnDocProcessor.read(null, uri, url); - assertNotNull(scaDefns); - - scaDefnDocProcessor.resolve(scaDefns, resolver); - - compositeReader.resolve(composite, resolver); - CompositeBuilderImpl compositeUtil = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, new DefaultIntentAttachPointTypeFactory(), mapper, null); - compositeUtil.build(composite); - - assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite); - } - -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java b/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java deleted file mode 100644 index aa95b98a31..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.net.URI; -import java.net.URL; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.ComponentType; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; -import org.apache.tuscany.sca.assembly.SCABindingFactory; -import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl; -import org.apache.tuscany.sca.contribution.DefaultContributionFactory; -import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.definitions.SCADefinitions; -import org.apache.tuscany.sca.definitions.xml.SCADefinitionsDocumentProcessor; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl; -import org.apache.tuscany.sca.policy.DefaultIntentAttachPointTypeFactory; -import org.apache.tuscany.sca.policy.DefaultPolicyFactory; -import org.apache.tuscany.sca.policy.PolicyFactory; - -/** - * Test writing SCA XML assemblies. - * - * @version $Rev: 637129 $ $Date: 2008-03-14 08:11:59 -0700 (Fri, 14 Mar 2008) $ - */ -public class WriteAllTestCase extends TestCase { - private DefaultStAXArtifactProcessorExtensionPoint staxProcessors; - private ExtensibleStAXArtifactProcessor staxProcessor; - private TestModelResolver resolver; - private AssemblyFactory assemblyFactory; - private SCABindingFactory scaBindingFactory; - private PolicyFactory policyFactory; - private InterfaceContractMapper mapper; - private CompositeBuilderImpl compositeUtil; - private SCADefinitionsDocumentProcessor scaDefnDocProcessor; - - - @Override - public void setUp() throws Exception { - assemblyFactory = new DefaultAssemblyFactory(); - scaBindingFactory = new TestSCABindingFactoryImpl(); - policyFactory = new DefaultPolicyFactory(); - mapper = new InterfaceContractMapperImpl(); - compositeUtil = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, new DefaultIntentAttachPointTypeFactory(), mapper, null); - staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance()); - staxProcessors.addArtifactProcessor(new CompositeProcessor(new DefaultContributionFactory(), assemblyFactory, policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new ComponentTypeProcessor(assemblyFactory, policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new ConstrainingTypeProcessor(assemblyFactory, policyFactory, staxProcessor)); - resolver = new TestModelResolver(); - scaDefnDocProcessor = new SCADefinitionsDocumentProcessor(staxProcessors, staxProcessor, XMLInputFactory.newInstance(), policyFactory); - } - - @Override - public void tearDown() throws Exception { - } - - public void testReadWriteComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite"); - Composite composite = staxProcessor.read(is, Composite.class); - - verifyComposite(composite); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(composite, bos); - bos.close(); - - ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); - composite = staxProcessor.read(bis, Composite.class); - - verifyComposite(composite); - - } - - public void testReadWireWriteComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite"); - Composite composite = staxProcessor.read(is, Composite.class); - - URL url = getClass().getResource("test_definitions.xml"); - URI uri = URI.create("test_definitions.xml"); - SCADefinitions scaDefns = (SCADefinitions)scaDefnDocProcessor.read(null, uri, url); - assertNotNull(scaDefns); - scaDefnDocProcessor.resolve(scaDefns, resolver); - - staxProcessor.resolve(composite, resolver); - compositeUtil.build(composite); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(composite, bos); - } - - public void testReadWriteComponentType() throws Exception { - InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType"); - ComponentType componentType = staxProcessor.read(is, ComponentType.class); - staxProcessor.resolve(componentType, resolver); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(componentType, bos); - } - - public void testReadWriteConstrainingType() throws Exception { - InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType"); - ConstrainingType constrainingType = staxProcessor.read(is, ConstrainingType.class); - staxProcessor.resolve(constrainingType, resolver); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(constrainingType, bos); - } - - private void verifyComposite(Composite composite) { - assertEquals(composite.getProperties().get(0).getName(),"prop1"); - assertEquals(composite.getProperties().get(0).isMany(), true); - assertEquals(composite.getProperties().get(1).getName(),"prop2"); - assertEquals(composite.getProperties().get(1).isMustSupply(), true); - assertEquals(composite.getProperties().get(0).getXSDType(), new QName("http://foo", "MyComplexType")); - assertEquals(composite.getProperties().get(1).getXSDElement(), new QName("http://www.osoa.org/xmlns/sca/1.0", "MyComplexPropertyValue1")); - } - -} diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite b/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite deleted file mode 100644 index 4546fddb2d..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType b/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType deleted file mode 100644 index 072fe8fde1..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType b/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType deleted file mode 100644 index 2dbecdabb7..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/JavaScriptReference.composite b/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/JavaScriptReference.composite deleted file mode 100644 index a313dd1e6d..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/JavaScriptReference.composite +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite b/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite deleted file mode 100644 index 2da2b56e8e..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite b/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite deleted file mode 100644 index 5091ff700b..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AValue - InterestingURI - - - BValue - BoringURI - - - - - - diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite b/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite deleted file mode 100644 index 0e7a48c698..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite b/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite deleted file mode 100644 index 7bc7ccdb83..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AValue - InterestingURI - - - BValue - BoringURI - - - - diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml b/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml deleted file mode 100644 index bcc8c54dc8..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - Sample Intent - - - - - - Sample Intent - - - - - - Sample Intent - - - - - - Sample Intent - - - - - - Sample Intent - - - - - - Sample Intent - - - - - - Sample Intent - - - - - - Sample Intent - - - - - - Sample Intent - - - - - - Sample Intent - - - - - - \ No newline at end of file diff --git a/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml b/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml deleted file mode 100644 index b79cb6b7b7..0000000000 --- a/branches/sca-android/modules/tuscany-assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml +++ /dev/null @@ -1,175 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - ... - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ... - - - - ... - - - - - - - - - Protect messages from unauthorized reading or modification - - - - - - Protect messages from unauthorized reading or modification - - - - - - - Communitcation thro this binding must prevent - unauthorized users from reading the messages. - - - - - - Communitcation thro this binding must prevent - unauthorized modification of the messages. - - - - - - Communitcation thro this binding required - Authentication. - - - - \ No newline at end of file -- cgit v1.2.3