From 9425990f532b1152c2d73db96c0f07ef5216a3d1 Mon Sep 17 00:00:00 2001 From: lresende Date: Thu, 12 Nov 2009 00:43:48 +0000 Subject: Moving 2.x contribs git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835178 13f79535-47bb-0310-9956-ffa450edef68 --- java/sca-contrib/modules/assembly-xml-osoa/LICENSE | 205 ---- .../modules/assembly-xml-osoa/META-INF/MANIFEST.MF | 58 -- java/sca-contrib/modules/assembly-xml-osoa/NOTICE | 6 - java/sca-contrib/modules/assembly-xml-osoa/pom.xml | 113 --- .../assembly/xml/osoa/BaseAssemblyProcessor.java | 759 -------------- .../assembly/xml/osoa/ComponentTypeProcessor.java | 383 -------- .../sca/assembly/xml/osoa/CompositeProcessor.java | 1031 -------------------- .../tuscany/sca/assembly/xml/osoa/Constants.java | 99 -- .../xml/osoa/ConstrainingTypeProcessor.java | 275 ------ .../assembly/xml/osoa/PolicySubjectProcessor.java | 253 ----- ...ca.contribution.processor.StAXArtifactProcessor | 21 - ...sca.contribution.processor.URLArtifactProcessor | 21 - ...tuscany.sca.contribution.resolver.ModelResolver | 20 - .../assembly-xml-validation-messages.properties | 29 - .../sca/assembly/xml/osoa/BuildPolicyTestCase.java | 143 --- .../xml/osoa/MultiplicityReadWriteTestCase.java | 86 -- .../sca/assembly/xml/osoa/ReadAllTestCase.java | 151 --- .../assembly/xml/osoa/ReadDocumentTestCase.java | 225 ----- .../sca/assembly/xml/osoa/ReadTestCase.java | 91 -- .../xml/osoa/ReadWriteAnyAttributeTestCase.java | 135 --- .../xml/osoa/ReadWriteAnyElementTestCase.java | 149 --- .../xml/osoa/ReadWriteLocalCompositeTestCase.java | 102 -- .../assembly/xml/osoa/ResolvePolicyTestCase.java | 171 ---- .../sca/assembly/xml/osoa/ResolveTestCase.java | 103 -- .../assembly/xml/osoa/TestAttributeProcessor.java | 61 -- .../sca/assembly/xml/osoa/TestPolicyProcessor.java | 82 -- .../xml/osoa/TestSCABindingFactoryImpl.java | 40 - .../sca/assembly/xml/osoa/TestSCABindingImpl.java | 186 ---- .../sca/assembly/xml/osoa/WireTestCase.java | 148 --- .../sca/assembly/xml/osoa/WriteAllTestCase.java | 158 --- .../assembly/xml/osoa/WriteNamespacesTestCase.java | 95 -- .../sca/assembly/xml/osoa/Calculator.composite | 59 -- .../xml/osoa/CalculatorComponent.constrainingType | 34 - .../assembly/xml/osoa/CalculatorImpl.componentType | 31 - .../xml/osoa/JavaScriptReference.composite | 37 - .../sca/assembly/xml/osoa/Multiplicity.composite | 30 - .../assembly/xml/osoa/NestedCalculator.composite | 29 - .../sca/assembly/xml/osoa/RMIBindingTest.composite | 43 - .../assembly/xml/osoa/TestAllCalculator.composite | 123 --- .../sca/assembly/xml/osoa/TestAllDivide.composite | 56 -- .../xml/osoa/TestAllPolicyCalculator.composite | 126 --- .../assembly/xml/osoa/another_test_definitions.xml | 96 -- .../tuscany/sca/assembly/xml/osoa/local.composite | 27 - .../sca/assembly/xml/osoa/test_definitions.xml | 206 ---- 44 files changed, 6296 deletions(-) delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/LICENSE delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/META-INF/MANIFEST.MF delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/NOTICE delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/pom.xml delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/BaseAssemblyProcessor.java delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/ComponentTypeProcessor.java delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/CompositeProcessor.java delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/Constants.java delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/ConstrainingTypeProcessor.java delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/PolicySubjectProcessor.java delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/main/resources/assembly-xml-validation-messages.properties delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/BuildPolicyTestCase.java delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/MultiplicityReadWriteTestCase.java delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadAllTestCase.java delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadDocumentTestCase.java delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadTestCase.java delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteAnyAttributeTestCase.java delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteAnyElementTestCase.java delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteLocalCompositeTestCase.java delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ResolvePolicyTestCase.java delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ResolveTestCase.java delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestAttributeProcessor.java delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestPolicyProcessor.java delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestSCABindingFactoryImpl.java delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestSCABindingImpl.java delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WireTestCase.java delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WriteAllTestCase.java delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WriteNamespacesTestCase.java delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/Calculator.composite delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/CalculatorComponent.constrainingType delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/CalculatorImpl.componentType delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/JavaScriptReference.composite delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/Multiplicity.composite delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/NestedCalculator.composite delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/RMIBindingTest.composite delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/TestAllCalculator.composite delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/TestAllDivide.composite delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/TestAllPolicyCalculator.composite delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/another_test_definitions.xml delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/local.composite delete mode 100644 java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/test_definitions.xml (limited to 'java/sca-contrib/modules/assembly-xml-osoa') diff --git a/java/sca-contrib/modules/assembly-xml-osoa/LICENSE b/java/sca-contrib/modules/assembly-xml-osoa/LICENSE deleted file mode 100644 index 8aa906c321..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/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/java/sca-contrib/modules/assembly-xml-osoa/META-INF/MANIFEST.MF b/java/sca-contrib/modules/assembly-xml-osoa/META-INF/MANIFEST.MF deleted file mode 100644 index 209391fa4d..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/META-INF/MANIFEST.MF +++ /dev/null @@ -1,58 +0,0 @@ -Manifest-Version: 1.0 -Export-Package: org.apache.tuscany.sca.assembly.xml.osoa;version="2.0.0"; - uses:="org.apache.tuscany.sca.definitions, - javax.xml.transform.dom, - org.apache.tuscany.sca.core, - org.apache.tuscany.sca.policy, - javax.xml.namespace, - org.apache.tuscany.sca.contribution.java, - javax.xml.stream, - org.apache.tuscany.sca.contribution.resolver, - org.apache.tuscany.sca.policy.util, - org.apache.tuscany.sca.assembly, - javax.xml.parsers, - org.apache.tuscany.sca.contribution, - org.apache.tuscany.sca.monitor, - org.w3c.dom, - org.apache.tuscany.sca.interfacedef, - org.apache.tuscany.sca.contribution.namespace, - javax.xml.xpath, - javax.xml.transform, - org.apache.tuscany.sca.contribution.processor, - org.apache.tuscany.sca.interfacedef.impl" -Tool: Bnd-0.0.255 -Bundle-Name: Apache Tuscany SCA 1.0 (OSOA) XML Assembly Model -Created-By: 1.6.0_07 (Sun Microsystems Inc.) -Bundle-Vendor: The Apache Software Foundation -Bundle-Version: 2.0.0 -Bnd-LastModified: 1225397124328 -Bundle-ManifestVersion: 2 -Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt -Bundle-Description: Apache Tuscany SCA XML Assembly Model -Import-Package: javax.xml.namespace, - javax.xml.parsers, - javax.xml.stream, - javax.xml.transform, - javax.xml.transform.dom, - javax.xml.validation;resolution:=optional, - javax.xml.xpath, - org.apache.tuscany.sca.assembly;version="2.0.0", - org.apache.tuscany.sca.assembly.builder;version="2.0.0";resolution:=optional, - org.apache.tuscany.sca.assembly.xml.osoa;version="2.0.0", - org.apache.tuscany.sca.contribution;version="2.0.0", - org.apache.tuscany.sca.contribution.java;version="2.0.0", - org.apache.tuscany.sca.contribution.namespace;version="2.0.0", - org.apache.tuscany.sca.contribution.processor;version="2.0.0", - org.apache.tuscany.sca.contribution.resolver;version="2.0.0", - org.apache.tuscany.sca.core;version="2.0.0", - org.apache.tuscany.sca.definitions;version="2.0.0", - org.apache.tuscany.sca.interfacedef;version="2.0.0", - org.apache.tuscany.sca.interfacedef.impl;version="2.0.0", - org.apache.tuscany.sca.monitor;version="2.0.0", - org.apache.tuscany.sca.policy;version="2.0.0", - org.apache.tuscany.sca.policy.util;version="2.0.0", - org.w3c.dom, - org.xml.sax;resolution:=optional -Bundle-SymbolicName: org.apache.tuscany.sca.assembly.xml.osoa -Bundle-DocURL: http://www.apache.org/ -Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6 diff --git a/java/sca-contrib/modules/assembly-xml-osoa/NOTICE b/java/sca-contrib/modules/assembly-xml-osoa/NOTICE deleted file mode 100644 index 25bb89c9b2..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/NOTICE +++ /dev/null @@ -1,6 +0,0 @@ -${pom.name} -Copyright (c) 2005 - 2009 The Apache Software Foundation - -This product includes software developed by -The Apache Software Foundation (http://www.apache.org/). - diff --git a/java/sca-contrib/modules/assembly-xml-osoa/pom.xml b/java/sca-contrib/modules/assembly-xml-osoa/pom.xml deleted file mode 100644 index 1cb0907928..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/pom.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - - 4.0.0 - - org.apache.tuscany.sca - tuscany-modules - 2.0-SNAPSHOT - ../pom.xml - - tuscany-assembly-xml-osoa - Apache Tuscany SCA Assembly XML Model based on OSOA Spec - - - - org.apache.tuscany.sca - tuscany-assembly - 2.0-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-assembly-xml - 2.0-SNAPSHOT - test - - - - org.apache.tuscany.sca - tuscany-definitions - 2.0-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-policy - 2.0-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-contribution - 2.0-SNAPSHOT - - - - - - org.apache.geronimo.specs - geronimo-stax-api_1.0_spec - 1.0.1 - compile - - - - org.codehaus.woodstox - wstx-asl - 3.2.4 - runtime - - - stax - stax-api - - - - - - org.apache.tuscany.sca - tuscany-definitions-xml - 2.0-SNAPSHOT - test - - - - org.apache.tuscany.sca - tuscany-policy-xml - 2.0-SNAPSHOT - test - - - - org.apache.tuscany.sca - tuscany-assembly-xsd-osoa - 2.0-SNAPSHOT - test - - - - diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/BaseAssemblyProcessor.java b/java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/BaseAssemblyProcessor.java deleted file mode 100644 index 4bb4d84316..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/BaseAssemblyProcessor.java +++ /dev/null @@ -1,759 +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.osoa; - -import static javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI; -import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.ELEMENT; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.MANY; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.MULTIPLICITY; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.MUST_SUPPLY; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.NAME; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.ONE_N; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.ONE_ONE; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.SCA10_NS; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.TARGET; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.TYPE; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.ZERO_N; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.ZERO_ONE; - -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.ConstrainingType; -import org.apache.tuscany.sca.assembly.Contract; -import org.apache.tuscany.sca.assembly.Extensible; -import org.apache.tuscany.sca.assembly.Extension; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.Multiplicity; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ContributionReadException; -import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; -import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.monitor.Problem.Severity; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicyFactory; -import org.apache.tuscany.sca.policy.PolicySet; -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$ $Date$ - */ -abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor { - - protected AssemblyFactory assemblyFactory; - protected PolicyFactory policyFactory; - protected StAXArtifactProcessor extensionProcessor; - protected PolicySubjectProcessor policyProcessor; - private DocumentBuilderFactory documentBuilderFactory; - private Monitor monitor; - - /** - * Constructs a new BaseArtifactProcessor. - * @param assemblyFactory - * @param policyFactory - */ - @SuppressWarnings("unchecked") - protected BaseAssemblyProcessor(AssemblyFactory assemblyFactory, - PolicyFactory policyFactory, - DocumentBuilderFactory documentBuilderFactory, - StAXArtifactProcessor extensionProcessor, - Monitor monitor) { - this.assemblyFactory = assemblyFactory; - this.policyFactory = policyFactory; - this.documentBuilderFactory = documentBuilderFactory; - this.extensionProcessor = (StAXArtifactProcessor)extensionProcessor; - this.policyProcessor = new PolicySubjectProcessor(policyFactory); - this.monitor = monitor; - } - - /** - * @param modelFactories - * @param staxProcessor - * @param monitor - */ - protected BaseAssemblyProcessor(FactoryExtensionPoint modelFactories, - StAXArtifactProcessor staxProcessor, - Monitor monitor) { - this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); - this.policyFactory = modelFactories.getFactory(PolicyFactory.class); - this.documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class); - this.extensionProcessor = (StAXArtifactProcessor)staxProcessor; - this.policyProcessor = new PolicySubjectProcessor(policyFactory); - this.monitor = monitor; - } - - /** - * Marshals warnings into the monitor - * - * @param message - * @param model - * @param messageParameters - */ - protected void warning(String message, Object model, String... messageParameters) { - if (monitor != null) { - Problem problem = - monitor.createProblem(this.getClass().getName(), - "assembly-xml-validation-messages", - Severity.WARNING, - model, - message, - (Object[])messageParameters); - monitor.problem(problem); - } - } - - /** - * Marshals errors into the monitor - * - * @param problems - * @param message - * @param model - */ - protected void error(String message, Object model, Object... messageParameters) { - if (monitor != null) { - Problem problem = - monitor.createProblem(this.getClass().getName(), - "assembly-xml-validation-messages", - Severity.ERROR, - model, - message, - (Object[])messageParameters); - monitor.problem(problem); - } - } - - /** - * Marshals exceptions into the monitor - * - * @param problems - * @param message - * @param model - */ - protected void error(String message, Object model, Exception ex) { - if (monitor != null) { - Problem problem = - monitor.createProblem(this.getClass().getName(), - "assembly-xml-validation-messages", - Severity.ERROR, - model, - message, - ex); - monitor.problem(problem); - } - } - - /** - * 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); - } else if (ONE_ONE.equals(value)) { - reference.setMultiplicity(Multiplicity.ONE_ONE); - } - } - - protected XAttr writeMultiplicity(AbstractReference reference) { - Multiplicity multiplicity = reference.getMultiplicity(); - if (multiplicity != null) { - String value = null; - if (Multiplicity.ZERO_ONE.equals(multiplicity)) { - value = ZERO_ONE; - } else if (Multiplicity.ONE_N.equals(multiplicity)) { - value = ONE_N; - } else if (Multiplicity.ZERO_N.equals(multiplicity)) { - value = ZERO_N; - } else if (Multiplicity.ONE_ONE.equals(multiplicity)) { - value = ONE_ONE; - return null; - } - return new XAttr(MULTIPLICITY, value); - } - return null; - } - - /** - * 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 { - 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()) { - resolver.addModel(implementation); - } - } - } - } - 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() : "UNKNOWN"; - - for (Contract contract : contracts) { - // 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); - - } - - // Resolve callback bindings - if (contract.getCallback() != null) { - - for (int i = 0, n = contract.getCallback().getBindings().size(); i < n; i++) { - Binding binding = contract.getCallback().getBindings().get(i); - extensionProcessor.resolve(binding, resolver); - } - } - } - } - - /** - * 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) { - ContributionReadException ce = new ContributionReadException(e); - error("ContributionReadException", documentBuilderFactory, ce); - throw ce; - } - - // 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(); - } - } - } - - /** - * 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); - } - } - - /** - * - * @param reader - * @param elementName - * @param estensibleElement - * @param extensionAttributeProcessor - * @throws ContributionReadException - * @throws XMLStreamException - */ - protected void readExtendedAttributes(XMLStreamReader reader, - QName elementName, - Extensible estensibleElement, - StAXAttributeProcessor extensionAttributeProcessor) - throws ContributionReadException, XMLStreamException { - for (int a = 0; a < reader.getAttributeCount(); a++) { - QName attributeName = reader.getAttributeName(a); - if (attributeName.getNamespaceURI() != null && attributeName.getNamespaceURI().length() > 0) { - if (!elementName.getNamespaceURI().equals(attributeName.getNamespaceURI())) { - Object attributeValue = extensionAttributeProcessor.read(attributeName, reader); - Extension attributeExtension; - if (attributeValue instanceof Extension) { - attributeExtension = (Extension)attributeValue; - } else { - attributeExtension = assemblyFactory.createExtension(); - attributeExtension.setAttribute(true); - attributeExtension.setQName(attributeName); - attributeExtension.setValue(attributeValue); - } - estensibleElement.getAttributeExtensions().add(attributeExtension); - } - } - } - } - - /** - * - * @param attributeModel - * @param writer - * @param extensibleElement - * @param extensionAttributeProcessor - * @throws ContributionWriteException - * @throws XMLStreamException - */ - protected void writeExtendedAttributes(XMLStreamWriter writer, - Extensible extensibleElement, - StAXAttributeProcessor extensionAttributeProcessor) - throws ContributionWriteException, XMLStreamException { - for (Extension extension : extensibleElement.getAttributeExtensions()) { - if (extension.isAttribute()) { - extensionAttributeProcessor.write(extension, writer); - } - } - } - - /*protected void validatePolicySets(PolicySubject policySetAttachPoint) - throws ContributionResolveException { - validatePolicySets(policySetAttachPoint, policySetAttachPoint.getApplicablePolicySets()); - } - - - protected void validatePolicySets(PolicySubject 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 - ExtensionType 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/java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/ComponentTypeProcessor.java b/java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/ComponentTypeProcessor.java deleted file mode 100644 index 643f5ab78d..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/ComponentTypeProcessor.java +++ /dev/null @@ -1,383 +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.osoa; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.CALLBACK; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.CALLBACK_QNAME; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.COMPONENT_TYPE; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.COMPONENT_TYPE_QNAME; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.ELEMENT; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.IMPLEMENTATION; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.MANY; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.MUST_SUPPLY; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.NAME; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.OPERATION_QNAME; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.PROPERTY; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.PROPERTY_QNAME; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.REFERENCE; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.REFERENCE_QNAME; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.SERVICE; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.SERVICE_QNAME; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.TYPE; - -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.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.assembly.xml.osoa.BaseAssemblyProcessor; -import org.apache.tuscany.sca.assembly.xml.osoa.Constants; -import org.apache.tuscany.sca.contribution.processor.ContributionReadException; -import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; -import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -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.monitor.Monitor; -import org.apache.tuscany.sca.policy.PolicySubject; -import org.w3c.dom.Document; - -/** - * A componentType processor. - * - * @version $Rev$ $Date$ - */ -public class ComponentTypeProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor { - - /** - * Constructs a new componentType processor. - * - * @param modelFactories - * @param extensionProcessor - * @param extensionAttributeProcessor - * @param monitor - */ - public ComponentTypeProcessor(FactoryExtensionPoint modelFactories, - StAXArtifactProcessor extensionProcessor, - StAXAttributeProcessor extensionAttributeProcessor, - Monitor monitor) { - super(modelFactories, extensionProcessor, monitor); - } - - public ComponentType read(XMLStreamReader reader) throws ContributionReadException { - ComponentType componentType = null; - Service service = null; - Reference reference = null; - Contract contract = null; - Property property = null; - Callback callback = null; - QName name = null; - - try { - // 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_QNAME.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(); - } - } - } - catch (XMLStreamException e) { - ContributionReadException ex = new ContributionReadException(e); - error("XMLStreamException", reader, ex); - } - - 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()), - writeMultiplicity(reference), - 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 PolicySubject) { - if (!((PolicySubject)componentType).getRequiredIntents().isEmpty()) { - writeImplementation = true; - } - } - if (componentType instanceof PolicySubject) { - if (!((PolicySubject)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); - } - - public QName getArtifactType() { - return COMPONENT_TYPE_QNAME; - } - - public Class getModelType() { - return ComponentType.class; - } -} diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/CompositeProcessor.java b/java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/CompositeProcessor.java deleted file mode 100644 index bfdd9fdac7..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/CompositeProcessor.java +++ /dev/null @@ -1,1031 +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.osoa; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.AUTOWIRE; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.CALLBACK; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.CALLBACK_QNAME; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.COMPONENT; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.COMPONENT_QNAME; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.COMPOSITE; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.COMPOSITE_QNAME; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.ELEMENT; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.FILE; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.IMPLEMENTATION_COMPOSITE; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.IMPLEMENTATION_COMPOSITE_QNAME; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.INCLUDE; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.INCLUDE_QNAME; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.LOCAL; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.MANY; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.MUST_SUPPLY; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.NAME; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.PROMOTE; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.PROPERTY; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.PROPERTY_QNAME; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.REFERENCE; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.REFERENCE_QNAME; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.SCA10_NS; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.SERVICE; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.SERVICE_QNAME; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.SOURCE; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.TARGET; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.TARGET_NAMESPACE; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.TYPE; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.URI; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.WIRE; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.WIRED_BY_IMPL; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.WIRE_QNAME; - -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.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.ConstrainingType; -import org.apache.tuscany.sca.assembly.Contract; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.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.ContributionReadException; -import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; -import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.resolver.ResolverExtension; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.core.UtilityExtensionPoint; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.monitor.MonitorFactory; -import org.apache.tuscany.sca.policy.ExtensionType; -import org.apache.tuscany.sca.policy.PolicyFactory; -import org.apache.tuscany.sca.policy.PolicySubject; -import org.w3c.dom.Document; - -/** - * A composite processor. - * - * @version $Rev$ $Date$ - */ -public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor { - private XPathFactory xPathFactory; - private PolicyFactory intentAttachPointTypeFactory; - private StAXAttributeProcessor extensionAttributeProcessor; - private ContributionFactory contributionFactory; - - - /** - * Construct a new composite processor - * - * @param extensionPoints - * @param extensionProcessor - */ - public CompositeProcessor(ExtensionPointRegistry extensionPoints, - StAXArtifactProcessor extensionProcessor, - StAXAttributeProcessor extensionAttributeProcessor, - Monitor monitor) { - - this(modelFactories(extensionPoints), - extensionProcessor, - extensionAttributeProcessor, - monitor(extensionPoints)); - - this.extensionAttributeProcessor = extensionAttributeProcessor; - } - - /** - * Constructs a new composite processor - * - * @param modelFactories - * @param extensionProcessor - * @param monitor - */ - private CompositeProcessor(FactoryExtensionPoint modelFactories, - StAXArtifactProcessor extensionProcessor, - StAXAttributeProcessor extensionAttributeProcessor, - Monitor monitor) { - - super(modelFactories, extensionProcessor, monitor); - this.intentAttachPointTypeFactory = modelFactories.getFactory(PolicyFactory.class); - this.xPathFactory = modelFactories.getFactory(XPathFactory.class); - this.contributionFactory = modelFactories.getFactory(ContributionFactory.class); - this.extensionAttributeProcessor = extensionAttributeProcessor; - - } - - public Composite read(XMLStreamReader reader) throws ContributionReadException { - 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; - - try { - // 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.setSpecVersion(SCA10_NS); - - composite.setName(new QName(getString(reader, TARGET_NAMESPACE), getString(reader, NAME))); - - if(!isSet(reader, TARGET_NAMESPACE)){ - // spec says that a composite must have a namespace - warning("NoCompositeNamespace", composite, composite.getName().toString()); - } - - if(isSet(reader, AUTOWIRE)) { - composite.setAutowire(getBoolean(reader, AUTOWIRE)); - } - - //handle extension attributes - this.readExtendedAttributes(reader, name, composite, extensionAttributeProcessor); - - 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)); - - //handle extension attributes - this.readExtendedAttributes(reader, name, componentService, extensionAttributeProcessor); - - 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); - if (promoted != null) { - 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); - } - - //handle extension attributes - this.readExtendedAttributes(reader, name, compositeService, extensionAttributeProcessor); - - 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)); - - //handle extension attributes - this.readExtendedAttributes(reader, name, componentReference, extensionAttributeProcessor); - - 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();) { - String refName = tokens.nextToken(); - Component promotedComponent = assemblyFactory.createComponent(); - int index = refName.indexOf('/'); - if (index == -1) { - error("Invalid reference name", compositeReference, refName); - } - String promotedComponentName = refName.substring(0, index); - promotedComponent.setName(promotedComponentName); - promotedComponent.setUnresolved(true); - compositeReference.getPromotedComponents().add(promotedComponent); - ComponentReference promotedReference = - assemblyFactory.createComponentReference(); - promotedReference.setUnresolved(true); - promotedReference.setName(refName); - compositeReference.getPromotedReferences().add(promotedReference); - } - } - compositeReference.setWiredByImpl(getBoolean(reader, WIRED_BY_IMPL)); - - //handle extension attributes - this.readExtendedAttributes(reader, name, compositeReference, extensionAttributeProcessor); - - 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 = "."; - } - } - XPath xpath = xPathFactory.newXPath(); - xpath.setNamespaceContext(reader.getNamespaceContext()); - try { - componentProperty.setSourceXPathExpression(xpath.compile(source)); - } catch (XPathExpressionException e) { - ContributionReadException ce = new ContributionReadException(e); - error("ContributionReadException", xpath, ce); - //throw ce; - } - } - componentProperty.setFile(getString(reader, FILE)); - - //handle extension attributes - this.readExtendedAttributes(reader, name, componentProperty, extensionAttributeProcessor); - - 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)); - } - - //handle extension attributes - this.readExtendedAttributes(reader, name, component, extensionAttributeProcessor); - - 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); - - //handle extension attributes - this.readExtendedAttributes(reader, name, wire, extensionAttributeProcessor); - - composite.getWires().add(wire); - policyProcessor.readPolicies(wire, reader); - - } else if (CALLBACK_QNAME.equals(name)) { - - // Read a - callback = assemblyFactory.createCallback(); - contract.setCallback(callback); - - //handle extension attributes - this.readExtendedAttributes(reader, name, callback, extensionAttributeProcessor); - - policyProcessor.readPolicies(callback, reader); - - } else if (IMPLEMENTATION_COMPOSITE_QNAME.equals(name)) { - - // Read an implementation.composite - Composite implementation = assemblyFactory.createComposite(); - implementation.setName(getQName(reader, NAME)); - implementation.setUnresolved(true); - - //handle extension attributes - this.readExtendedAttributes(reader, name, implementation, extensionAttributeProcessor); - - 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)) { - error("UnexpectedInterfaceElement", extension); - //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 PolicySubject ) { - ExtensionType bindingType = intentAttachPointTypeFactory.createBindingType(); - bindingType.setType(name); - bindingType.setUnresolved(true); - ((PolicySubject)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)) { - error("UnexpectedBindingElement", extension); - //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 PolicySubject ) { - ExtensionType implType = intentAttachPointTypeFactory.createImplementationType(); - implType.setType(name); - implType.setUnresolved(true); - ((PolicySubject)extension).setType(implType); - } - // - if (component != null) { - component.setImplementation((Implementation)extension); - } else { - if (name.getNamespaceURI().equals(SCA10_NS)) { - error("UnexpectedImplementationElement", extension); - //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(); - } - } - } - catch (XMLStreamException e) { - ContributionReadException ex = new ContributionReadException(e); - error("XMLStreamException", reader, ex); - } - - 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(LOCAL, composite.isLocal() ? Boolean.TRUE : null), - new XAttr(AUTOWIRE, composite.getAutowire()), - policyProcessor.writePolicies(composite)); - - //write extended attributes - this.writeExtendedAttributes(writer, composite, extensionAttributeProcessor); - - // 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)); - - //write extended attributes - this.writeExtendedAttributes(writer, include, extensionAttributeProcessor); - - 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.getName(); - } else { - promote = promotedComponent.getName(); - } - } else { - promote = null; - } - writeStart(writer, SERVICE, new XAttr(NAME, service.getName()), new XAttr(PROMOTE, promote), - policyProcessor.writePolicies(service)); - - //write extended attributes - this.writeExtendedAttributes(writer, service, extensionAttributeProcessor); - - - // 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 extended attributes - this.writeExtendedAttributes(writer, callback, extensionAttributeProcessor); - - // 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 extended attributes - this.writeExtendedAttributes(writer, component, extensionAttributeProcessor); - - // Write the component implementation - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - writeStart(writer, IMPLEMENTATION_COMPOSITE, new XAttr(NAME, ((Composite)implementation).getName())); - - //write extended attributes - this.writeExtendedAttributes(writer, (Composite)implementation, extensionAttributeProcessor); - - writeEnd(writer); - } else { - extensionProcessor.write(component.getImplementation(), writer); - } - - for (Object extension : component.getExtensions()) { - extensionProcessor.write(extension, writer); - } - - // Write elements - for (ComponentService service : component.getServices()) { - writeStart(writer, SERVICE, new XAttr(NAME, service.getName()), - policyProcessor.writePolicies(service)); - - //write extended attributes - this.writeExtendedAttributes(writer, service, extensionAttributeProcessor); - - // 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 extended attributes - this.writeExtendedAttributes(writer, callback, extensionAttributeProcessor); - - // 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()), - writeMultiplicity(reference), - writeTargets(reference), - policyProcessor.writePolicies(reference)); - - //write extended attributes - this.writeExtendedAttributes(writer, reference, extensionAttributeProcessor); - - // 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 extended attributes - this.writeExtendedAttributes(writer, callback, extensionAttributeProcessor); - - // 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 extended attributes - this.writeExtendedAttributes(writer, property, extensionAttributeProcessor); - - // 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), - writeMultiplicity(reference), - policyProcessor.writePolicies(reference)); - - //write extended attributes - this.writeExtendedAttributes(writer, reference, extensionAttributeProcessor); - - // 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 extended attributes - this.writeExtendedAttributes(writer, callback, extensionAttributeProcessor); - - // 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 extended attributes - this.writeExtendedAttributes(writer, property, extensionAttributeProcessor); - - // 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 extended attributes - this.writeExtendedAttributes(writer, wire, extensionAttributeProcessor); - - // 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 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 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) { - //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); - - component.setImplementation(implementation); - } - - //add model resolver to component - if (component instanceof ResolverExtension) { - ((ResolverExtension)component).setModelResolver(resolver); - } - } - - // Add model resolver to promoted components - for (Service service : composite.getServices()) { - CompositeService compositeService = (CompositeService)service; - Component promotedComponent = compositeService.getPromotedComponent(); - if (promotedComponent instanceof ResolverExtension) { - ((ResolverExtension)promotedComponent).setModelResolver(resolver); - } - } - } - - public QName getArtifactType() { - return COMPOSITE_QNAME; - } - - public Class getModelType() { - return Composite.class; - } - - /** - * Returns the model factory extension point to use. - * - * @param extensionPoints - * @return - */ - private static FactoryExtensionPoint modelFactories(ExtensionPointRegistry extensionPoints) { - return extensionPoints.getExtensionPoint(FactoryExtensionPoint.class); - } - - /** - * Returns the monitor to use. - * - * @param extensionPoints - * @return - */ - private static Monitor monitor(ExtensionPointRegistry extensionPoints) { - UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); - if (utilities != null) { - MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class); - if (monitorFactory != null) { - return monitorFactory.createMonitor(); - } - } - return null; - } - -} diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/Constants.java b/java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/Constants.java deleted file mode 100644 index 797d0bb47a..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/Constants.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.osoa; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.xml.osoa.Constants; - -/** - * Constants used in SCA assembly XML files. - * - * @version $Rev$ $Date$ - */ -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/java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/ConstrainingTypeProcessor.java b/java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/ConstrainingTypeProcessor.java deleted file mode 100644 index 125ee2970e..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/ConstrainingTypeProcessor.java +++ /dev/null @@ -1,275 +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.osoa; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.CONSTRAINING_TYPE; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.CONSTRAINING_TYPE_QNAME; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.ELEMENT; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.MANY; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.MUST_SUPPLY; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.NAME; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.OPERATION_QNAME; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.PROPERTY; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.PROPERTY_QNAME; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.REFERENCE; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.REFERENCE_QNAME; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.SERVICE; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.SERVICE_QNAME; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.TARGET_NAMESPACE; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.TYPE; - -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.ConstrainingType; -import org.apache.tuscany.sca.assembly.xml.osoa.BaseAssemblyProcessor; -import org.apache.tuscany.sca.assembly.xml.osoa.Constants; -import org.apache.tuscany.sca.contribution.processor.ContributionReadException; -import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; -import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -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.monitor.Monitor; -import org.w3c.dom.Document; - -/** - * A constrainingType processor. - * - * @version $Rev$ $Date$ - */ -public class ConstrainingTypeProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor { - - /** - * Constructs a new constrainingType processor. - * - * @param modelFactories - * @param extensionProcessor - */ - public ConstrainingTypeProcessor(FactoryExtensionPoint modelFactories, - StAXArtifactProcessor extensionProcessor, - Monitor monitor) { - super(modelFactories, extensionProcessor, monitor); - } - - public ConstrainingType read(XMLStreamReader reader) throws ContributionReadException { - ConstrainingType constrainingType = null; - AbstractService abstractService = null; - AbstractReference abstractReference = null; - AbstractProperty abstractProperty = null; - AbstractContract abstractContract = null; - QName name = null; - - try { - // 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_QNAME.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(); - } - } - } - catch (XMLStreamException e) { - ContributionReadException ex = new ContributionReadException(e); - error("XMLStreamException", reader, ex); - } - - 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()), - writeMultiplicity(reference), - 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); - } - - public QName getArtifactType() { - return CONSTRAINING_TYPE_QNAME; - } - - public Class getModelType() { - return ConstrainingType.class; - } -} diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/PolicySubjectProcessor.java b/java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/PolicySubjectProcessor.java deleted file mode 100644 index adb8655447..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/PolicySubjectProcessor.java +++ /dev/null @@ -1,253 +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.osoa; - -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.POLICY_SETS; -import static org.apache.tuscany.sca.assembly.xml.osoa.Constants.REQUIRES; - -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.xml.osoa.Constants; -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.PolicyFactory; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySubject; - -/** - * A Policy Attach Point processor. - * - * @version $Rev$ $Date$ - */ -public class PolicySubjectProcessor extends BaseStAXArtifactProcessor { - - private PolicyFactory policyFactory; - - public PolicySubjectProcessor(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 PolicySubject)) - return; - PolicySubject intentAttachPoint = (PolicySubject)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 PolicySubject)) { - return; - } - PolicySubject policySubject = (PolicySubject)attachPoint; - String value = reader.getAttributeValue(null, POLICY_SETS); - if (value != null) { - List policySets = policySubject.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); - } - } - } - - /** - * 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 PolicySubject)) { - return null; - } - PolicySubject intentAttachPoint = (PolicySubject)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 PolicySubject)) { - return null; - } - PolicySubject policySetAttachPoint = (PolicySubject)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 PolicySubject ) { - PolicySubject policySetAttachPoint = (PolicySubject)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/java/sca-contrib/modules/assembly-xml-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/java/sca-contrib/modules/assembly-xml-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor deleted file mode 100644 index e778ab7e3c..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor +++ /dev/null @@ -1,21 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# Implementation class for the artifact processor extension -org.apache.tuscany.sca.assembly.xml.osoa.ComponentTypeProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#componentType,model=org.apache.tuscany.sca.assembly.ComponentType -org.apache.tuscany.sca.assembly.xml.osoa.ConstrainingTypeProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#constrainingType,model=org.apache.tuscany.sca.assembly.ConstrainingType -org.apache.tuscany.sca.assembly.xml.osoa.CompositeProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#composite,model=org.apache.tuscany.sca.assembly.Composite diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/java/sca-contrib/modules/assembly-xml-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor deleted file mode 100644 index a363691a51..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor +++ /dev/null @@ -1,21 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# Implementation class for the artifact processor extension -# org.apache.tuscany.sca.assembly.xml.osoa.ComponentTypeDocumentProcessor;type=.componentType,model=org.apache.tuscany.sca.assembly.ComponentType -# org.apache.tuscany.sca.assembly.xml.osoa.ConstrainingTypeDocumentProcessor;type=.constrainingType,model=org.apache.tuscany.sca.assembly.ConstrainingType -# org.apache.tuscany.sca.assembly.xml.osoa.CompositeDocumentProcessor;type=.composite,model=org.apache.tuscany.sca.assembly.Composite diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/java/sca-contrib/modules/assembly-xml-osoa/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver deleted file mode 100644 index 05c965f40e..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/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.osoa.CompositeModelResolver;model=org.apache.tuscany.sca.assembly.Composite -# org.apache.tuscany.sca.assembly.xml.osoa.ConstrainingTypeModelResolver;model=org.apache.tuscany.sca.assembly.ConstrainingType -# org.apache.tuscany.sca.assembly.xml.osoa.ComponentTypeModelResolver;model=org.apache.tuscany.sca.assembly.ComponentType diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/main/resources/assembly-xml-validation-messages.properties b/java/sca-contrib/modules/assembly-xml-osoa/src/main/resources/assembly-xml-validation-messages.properties deleted file mode 100644 index 8cc5e5a5ec..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/main/resources/assembly-xml-validation-messages.properties +++ /dev/null @@ -1,29 +0,0 @@ -# -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# -NoCompositeNamespace = No namespace found: Composite = {0} -UnexpectedInterfaceElement = Unexpected element found. It should appear inside a or element. -UnexpectedBindingElement = Unexpected element found. It should appear inside a or element. -UnexpectedImplementationElement = Unexpected element found. It should appear inside a element. -PolicyImplValidationException = PolicyValidation exception when processing implementation of component {0} due to {1}. -PolicyServiceValidationException = PolicyValidation exceptions when processing service/reference {0} in {1}. Error is {2} -ContributionReadException = ContributionReadException occured due to : {0} -ContributionWriteException = ContributionWriteException occured due to : {0} -XMLStreamException = XMLStreamException occured due to : {0} diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/BuildPolicyTestCase.java b/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/BuildPolicyTestCase.java deleted file mode 100644 index 938cc7750d..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/BuildPolicyTestCase.java +++ /dev/null @@ -1,143 +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.osoa; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.net.URI; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.SCABindingFactory; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.DefaultURLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.core.UtilityExtensionPoint; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.monitor.DefaultMonitorFactory; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.monitor.MonitorFactory; -import org.apache.tuscany.sca.policy.PolicySubject; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; - -/** - * Test reading SCA XML assembly documents. - * - * @version $Rev$ $Date$ - */ -public class BuildPolicyTestCase { - private static URLArtifactProcessor documentProcessor; - private static URLArtifactProcessor policyDefinitionsProcessor; - private static ModelResolver resolver; - private static CompositeBuilder compositeBuilder; - private static Composite composite; - private static Monitor monitor; - - @BeforeClass - public static void setUp() throws Exception { - DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class); - SCABindingFactory scaBindingFactory = new TestSCABindingFactoryImpl(); - modelFactories.addFactory(scaBindingFactory); - compositeBuilder = extensionPoints.getExtensionPoint(CompositeBuilderExtensionPoint.class).getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeBuilder"); - - List policyDefinitions = new ArrayList(); - resolver = new DefaultModelResolver(); - - MonitorFactory monitorFactory = new DefaultMonitorFactory(); - monitor = monitorFactory.createMonitor(); - - UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); - InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class); - - URLArtifactProcessorExtensionPoint documentProcessors = new DefaultURLArtifactProcessorExtensionPoint(extensionPoints); - documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors, null); - policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class); - - StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - staxProcessors.addArtifactProcessor(new TestPolicyProcessor()); - - URL url = BuildPolicyTestCase.class.getResource("CalculatorComponent.constrainingType"); - URI uri = URI.create("CalculatorComponent.constrainingType"); - ConstrainingType constrainingType = (ConstrainingType)documentProcessor.read(null, uri, url); - assertNotNull(constrainingType); - resolver.addModel(constrainingType); - - url = BuildPolicyTestCase.class.getResource("TestAllPolicyCalculator.composite"); - uri = URI.create("TestAllCalculator.composite"); - composite = (Composite)documentProcessor.read(null, uri, url); - assertNotNull(composite); - - url = BuildPolicyTestCase.class.getResource("another_test_definitions.xml"); - uri = URI.create("another_test_definitions.xml"); - Definitions definitions = (Definitions)policyDefinitionsProcessor.read(null, uri, url); - assertNotNull(definitions); - policyDefinitions.add(definitions); - - documentProcessor.resolve(definitions, resolver); - documentProcessor.resolve(composite, resolver); - - compositeBuilder.build(composite, null, monitor); - } - - @Test - @Ignore("The inheritance will be calculated differently in OASIS SCA") - public void testPolicyIntentInheritance() throws Exception { - String namespaceUri = "http://test"; - - PolicySubject policiedComposite = (PolicySubject)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).getRequiredIntents().get(3).getName(), new QName(namespaceUri, "tuscanyIntent_3")); - //bindings will have only 2 intents since duplications will be cut out - assertEquals(((PolicySubject)composite.getServices().get(0).getBindings().get(0)).getRequiredIntents().size(), 3); - - assertEquals(composite.getReferences().get(0).getRequiredIntents().size(), 5); - assertEquals(composite.getReferences().get(0).getRequiredIntents().get(1).getName(), new QName(namespaceUri, "tuscanyIntent_1")); - assertEquals(((PolicySubject)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).getReferences().get(0).getRequiredIntents().size(), 5); - } -} diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/MultiplicityReadWriteTestCase.java b/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/MultiplicityReadWriteTestCase.java deleted file mode 100644 index 5d9b8e4556..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/MultiplicityReadWriteTestCase.java +++ /dev/null @@ -1,86 +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.osoa; - -import static org.junit.Assert.assertEquals; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.Multiplicity; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.junit.Before; -import org.junit.Test; - -/** - * Test writing SCA XML assemblies. - * - * TUSCANY-2662 - * - * @version $Rev$ $Date$ - */ -public class MultiplicityReadWriteTestCase { - private XMLInputFactory inputFactory; - private XMLOutputFactory outputFactory; - private ExtensibleStAXArtifactProcessor staxProcessor; - - - @Before - public void setUp() throws Exception { - DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - inputFactory = XMLInputFactory.newInstance(); - outputFactory = XMLOutputFactory.newInstance(); - StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, null); - } - - - @Test - public void testReadWriteComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("Multiplicity.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); - - } - - - private void verifyComposite(Composite composite) { - assertEquals(composite.getComponents().get(0).getReferences().get(0).getMultiplicity(), Multiplicity.ZERO_N); - assertEquals(composite.getReferences().get(0).getMultiplicity(), Multiplicity.ONE_N); - } - -} diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadAllTestCase.java b/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadAllTestCase.java deleted file mode 100644 index 4d981b8c4d..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadAllTestCase.java +++ /dev/null @@ -1,151 +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.osoa; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.InputStream; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLInputFactory; - -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.Property; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.policy.PolicySubject; -import org.junit.BeforeClass; -import org.junit.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -/** - * Test reading SCA XML assemblies. - * - * @version $Rev$ $Date$ - */ -public class ReadAllTestCase { - private static StAXArtifactProcessor staxProcessor; - private static XMLInputFactory inputFactory; - - @BeforeClass - public static void setUp() throws Exception { - DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - inputFactory = XMLInputFactory.newInstance(); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null); - } - - @Test - public void testReadComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite"); - Composite composite = (Composite)staxProcessor.read(inputFactory.createXMLStreamReader(is)); - 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(((PolicySubject)composite).getRequiredIntents().get(0).getName(), new QName("http://test", - "confidentiality")); - assertEquals(((PolicySubject)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 - - } - -} diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadDocumentTestCase.java b/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadDocumentTestCase.java deleted file mode 100644 index 94036c50cb..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadDocumentTestCase.java +++ /dev/null @@ -1,225 +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.osoa; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -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.validation.Schema; -import javax.xml.validation.SchemaFactory; -import javax.xml.validation.ValidatorHandler; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.xml.CompositeDocumentProcessor; -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.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint; -import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint; -import org.junit.BeforeClass; -import org.junit.Test; -import org.xml.sax.InputSource; -import org.xml.sax.XMLReader; - -/** - * Test reading SCA XML assembly documents. - * - * @version $Rev$ $Date$ - */ -public class ReadDocumentTestCase { - private static final String TUSCANY_10_XSD = "tuscany-sca.xsd"; - - private static URLArtifactProcessor documentProcessor; - private static ModelResolver resolver; - private static XMLInputFactory inputFactory; - private static StAXArtifactProcessor staxProcessor; - - @BeforeClass - public static void setUp() throws Exception { - DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); - documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors, null); - - StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - inputFactory = XMLInputFactory.newInstance(); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null); - - resolver = new DefaultModelResolver(); - } - - @Test - 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_10_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())); - - } - - @Test - 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_10_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())); - } - - @Test - public void testReadImplementation() throws Exception { - - ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint(); - schemas.addSchema(getClass().getClassLoader().getResource(TUSCANY_10_XSD).toString()); - XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas, null); - DefaultFactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry()); - factories.addFactory(validatingInputFactory); - - CompositeDocumentProcessor compositeDocumentProcessor = new CompositeDocumentProcessor(factories , staxProcessor, null); - - URL url = getClass().getResource("JavaScriptReference.composite"); - URI uri = URI.create("JavaScriptReference.composite"); - Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url); - assertNotNull(composite); - } - - @Test - 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_10_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())); - } - - @Test - public void testReadBinding() throws Exception { - - ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint(); - schemas.addSchema(getClass().getClassLoader().getResource(TUSCANY_10_XSD).toString()); - XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas, null); - DefaultFactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry()); - factories.addFactory(validatingInputFactory); - CompositeDocumentProcessor compositeDocumentProcessor = new CompositeDocumentProcessor(factories , staxProcessor, null); - - URL url = getClass().getResource("RMIBindingTest.composite"); - URI uri = URI.create("RMIBindingTest.composite"); - Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url); - assertNotNull(composite); - } - - @Test - 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.composite"); - 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); - } - - @Test - 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/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadTestCase.java b/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadTestCase.java deleted file mode 100644 index 98b8c81533..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadTestCase.java +++ /dev/null @@ -1,91 +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.osoa; - -import static org.junit.Assert.assertNotNull; - -import java.io.InputStream; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * Test reading SCA XML assemblies. - * - * @version $Rev$ $Date$ - */ -public class ReadTestCase { - - private static XMLInputFactory inputFactory; - private static StAXArtifactProcessor staxProcessor; - - @BeforeClass - public static void setUp() throws Exception { - ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - inputFactory = XMLInputFactory.newInstance(); - StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance(), null); - } - - - @Test - public void testReadComponentType() throws Exception { - InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - assertNotNull(staxProcessor.read(reader)); - is.close(); - } - - @Test - public void testReadConstrainingType() throws Exception { - InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - assertNotNull(staxProcessor.read(reader)); - is.close(); - - } - - @Test - public void testReadComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("Calculator.composite"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - assertNotNull(staxProcessor.read(reader)); - is.close(); - - } - - @Test - public void testReadCompositeAndWireIt() throws Exception { - InputStream is = getClass().getResourceAsStream("Calculator.composite"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - assertNotNull(staxProcessor.read(reader)); - is.close(); - } - -} diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteAnyAttributeTestCase.java b/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteAnyAttributeTestCase.java deleted file mode 100644 index b86907579e..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteAnyAttributeTestCase.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml.osoa; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.ByteArrayOutputStream; -import java.io.StringReader; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.junit.Ignore; -import org.junit.Test; - -/** - * Test reading SCA XML assemblies. - * - * @version $Rev$ $Date$ - */ -public class ReadWriteAnyAttributeTestCase { - - private static final QName EXTENDED_ATTRIBUTE = new QName("http://test", "customAttribute"); - - private static final String XML = ""+ - ""+ - ""+ - ""+ - ""+ - ""; - - private XMLInputFactory inputFactory; - private ExtensibleStAXArtifactProcessor staxProcessor; - - - /** - * Initialize the test environment - * This takes care to register attribute processors when provided - * - * @param attributeProcessor - * @throws Exception - */ - private void init(StAXAttributeProcessor attributeProcessor) throws Exception { - ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - inputFactory = XMLInputFactory.newInstance(); - StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - - if(attributeProcessor != null) { - StAXAttributeProcessorExtensionPoint staxAttributeProcessors = extensionPoints.getExtensionPoint(StAXAttributeProcessorExtensionPoint.class); - staxAttributeProcessors.addArtifactProcessor(attributeProcessor); - } - - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance(), null); - } - - /** - * Read and Write a composite that has a extended attribute - * and a particular attribute processor - * @throws Exception - */ - @Test - @Ignore("TBF: The processor needs to write the xml based on the QName of the elements") - public void testReadWriteCompositeWithAttributeProcessor() throws Exception { - init(new TestAttributeProcessor()); - - XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML)); - Composite composite = (Composite) staxProcessor.read(reader); - assertNotNull(composite); - reader.close(); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(composite, bos); - - // used for debug comparison - // System.out.println(XML); - // System.out.println(bos.toString()); - - assertEquals(XML, bos.toString()); - } - - /** - * Read and Write a composite that has a extended attribute - * but no particular processor for it - * @throws Exception - */ - @Test - @Ignore("TBF: The processor needs to write the xml based on the QName of the elements") - public void testDefaultReadWriteComposite() throws Exception { - init(null); - - XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML)); - Composite composite = (Composite) staxProcessor.read(reader); - assertNotNull(composite); - reader.close(); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(composite, bos); - - // used for debug comparison - // System.out.println(XML); - // System.out.println(bos.toString()); - - assertEquals(XML, bos.toString()); - } -} \ No newline at end of file diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteAnyElementTestCase.java b/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteAnyElementTestCase.java deleted file mode 100644 index d15bce9544..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteAnyElementTestCase.java +++ /dev/null @@ -1,149 +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.osoa; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.ByteArrayOutputStream; -import java.io.StringReader; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -public class ReadWriteAnyElementTestCase { - private static final String XML_RECURSIVE_EXTENDED_ELEMENT = - "" + - "" + - "" + - "" + - "" + - "" + - ""; - - private static final String XML_UNKNOWN_IMPL = - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - ""; - - private static final String XML_UNKNOWN_IMPL_WITH_INVALID_ATTRIBUTE = - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - ""; - - - private XMLInputFactory inputFactory; - private ExtensibleStAXArtifactProcessor staxProcessor; - - @Before - public void setUp() throws Exception { - ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class); - inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class); - - StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, XMLOutputFactory.newInstance(), null); - } - - @After - public void tearDown() throws Exception { - } - - @Test - @Ignore("TBF: The processor needs to write the xml based on the QName of the elements") - public void testReadWriteExtendedRecursiveElement() throws Exception { - XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML_RECURSIVE_EXTENDED_ELEMENT)); - Composite composite = (Composite)staxProcessor.read(reader); - assertNotNull(composite); - reader.close(); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(composite, bos); - - // used for debug comparison - // System.out.println(XML_RECURSIVE_EXTENDED_ELEMENT); - // System.out.println(bos.toString()); - - assertEquals(XML_RECURSIVE_EXTENDED_ELEMENT, bos.toString()); - bos.close(); - } - - @Test - @Ignore("TBF: The processor needs to write the xml based on the QName of the elements") - public void testReadWriteUnknwonImpl() throws Exception { - XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML_UNKNOWN_IMPL)); - Composite composite = (Composite)staxProcessor.read(reader); - assertNotNull(composite); - reader.close(); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(composite, bos); - - // used for debug comparison - // System.out.println(XML_UNKNOWN_IMPL); - // System.out.println(bos.toString()); - - assertEquals(XML_UNKNOWN_IMPL, bos.toString()); - bos.close(); - } - - // @Test - @Ignore() - public void testReadWriteInvalidAttribute() throws Exception { - XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML_UNKNOWN_IMPL_WITH_INVALID_ATTRIBUTE)); - Composite composite = (Composite)staxProcessor.read(reader); - assertNotNull(composite); - reader.close(); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(composite, bos); - - // used for debug comparison - // System.out.println(XML_UNKNOWN_IMPL); - // System.out.println(bos.toString()); - - assertEquals(XML_UNKNOWN_IMPL, bos.toString()); - bos.close(); - } -} \ No newline at end of file diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteLocalCompositeTestCase.java b/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteLocalCompositeTestCase.java deleted file mode 100644 index 77a199acc9..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadWriteLocalCompositeTestCase.java +++ /dev/null @@ -1,102 +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.osoa; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.ByteArrayOutputStream; -import java.io.InputStream; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - - -/** - * Test reading SCA XML assemblies. - * - * @version $Rev$ $Date$ - */ -public class ReadWriteLocalCompositeTestCase { - - private XMLInputFactory inputFactory; - private ExtensibleStAXArtifactProcessor staxProcessor; - - private static final String LOCAL_COMPOSITE_XML = ""+ - ""+ - ""; - - @Before - public void setUp() throws Exception { - ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - inputFactory = XMLInputFactory.newInstance(); - StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - - StAXAttributeProcessorExtensionPoint staxAttributeProcessors = extensionPoints.getExtensionPoint(StAXAttributeProcessorExtensionPoint.class); - staxAttributeProcessors.addArtifactProcessor(new TestAttributeProcessor()); - - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance(), null); - } - - @After - public void tearDown() throws Exception { - - } - - @Test - public void testReadComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("local.composite"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Composite composite = (Composite) staxProcessor.read(reader); - assertNotNull(composite); - assertTrue(composite.isLocal()); - is.close(); - } - - @Test - @Ignore("TBF: The processor needs to write the xml based on the QName of the elements") - public void testWriteComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("local.composite"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Composite composite = (Composite) staxProcessor.read(reader); - assertNotNull(composite); - assertTrue(composite.isLocal()); - is.close(); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(composite, bos); - System.out.println(bos.toString()); - - assertEquals(LOCAL_COMPOSITE_XML, bos.toString()); - } -} diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ResolvePolicyTestCase.java b/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ResolvePolicyTestCase.java deleted file mode 100644 index c242ce33fd..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ResolvePolicyTestCase.java +++ /dev/null @@ -1,171 +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.osoa; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.net.URI; -import java.net.URL; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.policy.PolicySubject; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * Test reading SCA XML assembly documents. - * - * @version $Rev$ $Date$ - */ -public class ResolvePolicyTestCase { - - private static URLArtifactProcessor documentProcessor; - private static ModelResolver resolver; - private static URLArtifactProcessor policyDefinitionsProcessor; - - @BeforeClass - public static void setUp() throws Exception { - DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - resolver = new DefaultModelResolver(); - - URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); - documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors, null); - policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class); - - // Create StAX processors - StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - staxProcessors.addArtifactProcessor(new TestPolicyProcessor()); - } - - @Test - 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.composite"); - Composite composite = (Composite)documentProcessor.read(null, uri, url); - assertNotNull(composite); - - url = getClass().getResource("test_definitions.xml"); - uri = URI.create("test_definitions.xml"); - Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url); - assertNotNull(scaDefns); - - preResolvePolicyTests(composite); - documentProcessor.resolve(scaDefns, resolver); - documentProcessor.resolve(composite, resolver); - - // Comment out the post resolving test - // postResolvePolicyTests(composite); - - assertEquals(composite.getConstrainingType(), constrainingType); - assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType); - } - - private void preResolvePolicyTests(Composite composite) { - assertNull(((PolicySubject)composite).getRequiredIntents().get(0).getDescription()); - assertTrue(((PolicySubject)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(((PolicySubject)composite).getRequiredIntents().get(0).getDescription()); - assertFalse(((PolicySubject)composite).getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNotNull(((PolicySubject)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()); - - - } - - @Test - 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/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ResolveTestCase.java b/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ResolveTestCase.java deleted file mode 100644 index 628cc6acd6..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ResolveTestCase.java +++ /dev/null @@ -1,103 +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.osoa; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.InputStream; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.junit.BeforeClass; -import org.junit.Test; - - -/** - * Test resolving SCA XML assemblies. - * - * @version $Rev$ $Date$ - */ -public class ResolveTestCase { - - private static XMLInputFactory inputFactory; - private static StAXArtifactProcessorExtensionPoint staxProcessors; - private static ModelResolver resolver; - - @BeforeClass - public static void setUp() throws Exception { - DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - inputFactory = XMLInputFactory.newInstance(); - staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - resolver = new DefaultModelResolver(); - } - - @Test - public void testResolveConstrainingType() throws Exception { - InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType"); - StAXArtifactProcessor constrainingTypeReader = staxProcessors.getProcessor(Constants.CONSTRAINING_TYPE_QNAME); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - ConstrainingType constrainingType = constrainingTypeReader.read(reader); - is.close(); - assertNotNull(constrainingType); - resolver.addModel(constrainingType); - - is = getClass().getResourceAsStream("TestAllCalculator.composite"); - StAXArtifactProcessor compositeReader = staxProcessors.getProcessor(Constants.COMPOSITE_QNAME); - 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); - } - - @Test - public void testResolveComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("Calculator.composite"); - StAXArtifactProcessor compositeReader = staxProcessors.getProcessor(Constants.COMPOSITE_QNAME); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Composite nestedComposite = compositeReader.read(reader); - is.close(); - assertNotNull(nestedComposite); - resolver.addModel(nestedComposite); - - is = getClass().getResourceAsStream("TestAllCalculator.composite"); - 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/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestAttributeProcessor.java b/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestAttributeProcessor.java deleted file mode 100644 index 173b987693..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestAttributeProcessor.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.xml.osoa; - -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.BaseStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ContributionReadException; -import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; -import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; -import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; - -/** - * A Policy Processor used for testing. - * - * @version $Rev$ $Date$ - */ -public class TestAttributeProcessor extends BaseStAXArtifactProcessor implements StAXAttributeProcessor { - private static final QName ATTRIBUTE = new QName("http://test", "customAttribute"); - - public QName getArtifactType() { - return ATTRIBUTE; - } - - public String read(QName attributeName, XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - return reader.getAttributeValue(attributeName.getNamespaceURI(), attributeName.getLocalPart()); - } - - public void write(String value, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { - writer.setPrefix(ATTRIBUTE.getPrefix(), ATTRIBUTE.getNamespaceURI()); - writer.writeAttribute(ATTRIBUTE.getLocalPart(), value); - } - - public Class getModelType() { - return String.class; - } - - public void resolve(String arg0, ModelResolver arg1) throws ContributionResolveException { - - } -} diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestPolicyProcessor.java b/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestPolicyProcessor.java deleted file mode 100644 index 911b8b3ffd..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestPolicyProcessor.java +++ /dev/null @@ -1,82 +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.osoa; - -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.ContributionReadException; -import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; -import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.policy.PolicyExpression; - -/** - * A PolicyExpression Processor used for testing. - * - * @version $Rev$ $Date$ - */ -public class TestPolicyProcessor implements StAXArtifactProcessor { - - public QName getArtifactType() { - return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment"); - } - - public PolicyExpression read(XMLStreamReader arg0) throws ContributionReadException, XMLStreamException { - return new MockPolicyImplOne(); - } - - public void write(PolicyExpression arg0, XMLStreamWriter arg1) throws ContributionWriteException, - XMLStreamException { - } - - public Class getModelType() { - return PolicyExpression.class; - } - - public void resolve(PolicyExpression arg0, ModelResolver arg1) throws ContributionResolveException { - } - - public class MockPolicyImplOne implements PolicyExpression { - public T getPolicy() { - return null; - } - - public void setName(QName name) { - } - - public void setPolicy(T policy) { - } - - public QName getName() { - 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/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestSCABindingFactoryImpl.java b/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestSCABindingFactoryImpl.java deleted file mode 100644 index 7d923d5483..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestSCABindingFactoryImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml.osoa; - -import org.apache.tuscany.sca.assembly.DistributedSCABinding; -import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.assembly.SCABindingFactory; - -/** - * A factory for the SCA binding model. - * - * @version $Rev$ $Date$ - */ -public class TestSCABindingFactoryImpl implements SCABindingFactory { - public SCABinding createSCABinding() { - return new TestSCABindingImpl(); - } - - public DistributedSCABinding createDistributedSCABinding() { - return null; - } - -} diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestSCABindingImpl.java b/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestSCABindingImpl.java deleted file mode 100644 index 5645a6b1c9..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/TestSCABindingImpl.java +++ /dev/null @@ -1,186 +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.osoa; - -import java.util.ArrayList; -import java.util.Collections; -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.OptimizableBinding; -import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.policy.ExtensionType; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySubject; - -/** - * A test cheel for the SCA binding. - * - * @version $Rev$ $Date$ - */ -public class TestSCABindingImpl implements SCABinding, OptimizableBinding, PolicySubject { - private String name; - private String uri; - private List extensions = new ArrayList(); - - private Component targetComponent; - private ComponentService targetComponentService; - private Binding targetBinding; - - private List requiredIntents = new ArrayList(); - private List policySets = new ArrayList(); - private ExtensionType bindingType = new TestSCABindingType(); - - /** - * 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 ExtensionType getType() { - // TODO Auto-generated method stub - return bindingType; - } - - public void setType(ExtensionType type) { - this.bindingType = type; - } - - private class TestSCABindingType implements ExtensionType { - private QName name = new QName("http://www.osoa.org/xmlns/sca/1.0","binding"); - public QName getBaseType() { - return BINDING_BASE; - } - - public QName getType() { - return name; - } - - public void setType(QName type) { - } - - public List getAlwaysProvidedIntents() { - return Collections.emptyList(); - } - - public List getMayProvidedIntents() { - return Collections.emptyList(); - } - - public boolean isUnresolved() { - return false; - } - - public void setUnresolved(boolean unresolved) { - } - } - -} diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WireTestCase.java b/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WireTestCase.java deleted file mode 100644 index ffc1ce9aa0..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WireTestCase.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.osoa; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.InputStream; -import java.net.URI; -import java.net.URL; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.SCABindingFactory; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.core.UtilityExtensionPoint; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.monitor.DefaultMonitorFactory; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.monitor.MonitorFactory; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * Test the wiring of SCA XML assemblies. - * - * @version $Rev$ $Date$ - */ -public class WireTestCase { - - private static XMLInputFactory inputFactory; - private static StAXArtifactProcessor staxProcessor; - private static ModelResolver resolver; - private static URLArtifactProcessor policyDefinitionsProcessor; - private static CompositeBuilder compositeBuilder; - private static Monitor monitor; - - @BeforeClass - public static void setUp() throws Exception { - DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - inputFactory = XMLInputFactory.newInstance(); - StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null); - resolver = new DefaultModelResolver(); - - MonitorFactory monitorFactory = new DefaultMonitorFactory(); - monitor = monitorFactory.createMonitor(); - - FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class); - SCABindingFactory scaBindingFactory = new TestSCABindingFactoryImpl(); - modelFactories.addFactory(scaBindingFactory); - compositeBuilder = extensionPoints.getExtensionPoint(CompositeBuilderExtensionPoint.class).getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeBuilder"); - - UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); - InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class); - - URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); - policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class); - } - - @Test - public void testResolveConstrainingType() throws Exception { - InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - ConstrainingType constrainingType = (ConstrainingType)staxProcessor.read(reader); - is.close(); - assertNotNull(constrainingType); - resolver.addModel(constrainingType); - - is = getClass().getResourceAsStream("TestAllCalculator.composite"); - reader = inputFactory.createXMLStreamReader(is); - Composite composite = (Composite)staxProcessor.read(reader); - is.close(); - assertNotNull(composite); - - URL url = getClass().getResource("test_definitions.xml"); - URI uri = URI.create("test_definitions.xml"); - Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url); - assertNotNull(scaDefns); - - policyDefinitionsProcessor.resolve(scaDefns, resolver); - - staxProcessor.resolve(composite, resolver); - compositeBuilder.build(composite, null, monitor); - - assertEquals(composite.getConstrainingType(), constrainingType); - assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType); - } - - @Test - public void testResolveComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("Calculator.composite"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Composite nestedComposite = (Composite)staxProcessor.read(reader); - is.close(); - assertNotNull(nestedComposite); - resolver.addModel(nestedComposite); - - is = getClass().getResourceAsStream("TestAllCalculator.composite"); - reader = inputFactory.createXMLStreamReader(is); - Composite composite = (Composite)staxProcessor.read(reader); - is.close(); - - URL url = getClass().getResource("test_definitions.xml"); - URI uri = URI.create("test_definitions.xml"); - Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url); - assertNotNull(scaDefns); - - policyDefinitionsProcessor.resolve(scaDefns, resolver); - - staxProcessor.resolve(composite, resolver); - compositeBuilder.build(composite, null, monitor); - - assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite); - } - -} diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WriteAllTestCase.java b/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WriteAllTestCase.java deleted file mode 100644 index c7d18f94ec..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WriteAllTestCase.java +++ /dev/null @@ -1,158 +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.osoa; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -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 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.SCABindingFactory; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.core.UtilityExtensionPoint; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.monitor.DefaultMonitorFactory; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.monitor.MonitorFactory; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * Test writing SCA XML assemblies. - * - * @version $Rev$ $Date$ - */ -public class WriteAllTestCase { - private static XMLInputFactory inputFactory; - private static XMLOutputFactory outputFactory; - private static ExtensibleStAXArtifactProcessor staxProcessor; - private static ModelResolver resolver; - private static CompositeBuilder compositeBuilder; - private static URLArtifactProcessor policyDefinitionsProcessor; - private static Monitor monitor; - - @BeforeClass - public static void setUp() throws Exception { - DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - inputFactory = XMLInputFactory.newInstance(); - outputFactory = XMLOutputFactory.newInstance(); - StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, null); - resolver = new DefaultModelResolver(); - - FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class); - SCABindingFactory scaBindingFactory = new TestSCABindingFactoryImpl(); - modelFactories.addFactory(scaBindingFactory); - compositeBuilder = extensionPoints.getExtensionPoint(CompositeBuilderExtensionPoint.class).getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeBuilder"); - - UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); - InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class); - - MonitorFactory monitorFactory = new DefaultMonitorFactory(); - monitor = monitorFactory.createMonitor(); - - URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); - policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class); - } - - @Test - 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); - - } - - @Test - 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"); - Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url); - assertNotNull(scaDefns); - policyDefinitionsProcessor.resolve(scaDefns, resolver); - - staxProcessor.resolve(composite, resolver); - compositeBuilder.build(composite, null, monitor); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(composite, bos); - } - - @Test - 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); - } - - @Test - 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/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WriteNamespacesTestCase.java b/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WriteNamespacesTestCase.java deleted file mode 100644 index 66ddf3b003..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/WriteNamespacesTestCase.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.osoa; - -import static org.junit.Assert.assertEquals; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * Test writing SCA XML assemblies. - * - * @version $Rev$ $Date$ - */ -public class WriteNamespacesTestCase { - private static StAXArtifactProcessor compositeProcessor; - private static XMLOutputFactory outputFactory; - private static XMLInputFactory inputFactory; - - @BeforeClass - public static void setUp() throws Exception { - ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class); - outputFactory = modelFactories.getFactory(XMLOutputFactory.class); - //outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE); - inputFactory = modelFactories.getFactory(XMLInputFactory.class); - - StAXArtifactProcessorExtensionPoint artifactProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - compositeProcessor = artifactProcessors.getProcessor(Constants.COMPOSITE_QNAME); - } - - @Test - public void testReadWriteComposite() throws Exception { - - // Read - InputStream is = getClass().getResourceAsStream("NestedCalculator.composite"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Composite composite = compositeProcessor.read(reader); - Component component = composite.getComponents().get(0); - Composite implementation = (Composite)component.getImplementation(); - QName qname = implementation.getName(); - - // Write - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - XMLStreamWriter writer = outputFactory.createXMLStreamWriter(bos); - compositeProcessor.write(composite, writer); - System.out.println(bos); - - // Read again - is = new ByteArrayInputStream(bos.toByteArray()); - reader = inputFactory.createXMLStreamReader(is); - composite = compositeProcessor.read(reader); - - // Compare - component = composite.getComponents().get(0); - implementation = (Composite)component.getImplementation(); - - assertEquals(qname, implementation.getName()); - } - -} diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/Calculator.composite b/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/Calculator.composite deleted file mode 100644 index 614489d2d5..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/Calculator.composite +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/CalculatorComponent.constrainingType b/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/CalculatorComponent.constrainingType deleted file mode 100644 index d6ec9b0ff0..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/CalculatorComponent.constrainingType +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/CalculatorImpl.componentType b/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/CalculatorImpl.componentType deleted file mode 100644 index 299eb8c197..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/CalculatorImpl.componentType +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/JavaScriptReference.composite b/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/JavaScriptReference.composite deleted file mode 100644 index 308ad8754b..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/JavaScriptReference.composite +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/Multiplicity.composite b/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/Multiplicity.composite deleted file mode 100644 index 369cbc00bf..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/Multiplicity.composite +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/NestedCalculator.composite b/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/NestedCalculator.composite deleted file mode 100644 index 6f71f0a7f1..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/NestedCalculator.composite +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/RMIBindingTest.composite b/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/RMIBindingTest.composite deleted file mode 100644 index 2a0bcf0f76..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/RMIBindingTest.composite +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/TestAllCalculator.composite b/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/TestAllCalculator.composite deleted file mode 100644 index c52c8f79a9..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/TestAllCalculator.composite +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AValue - InterestingURI - - - BValue - BoringURI - - - - - - diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/TestAllDivide.composite b/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/TestAllDivide.composite deleted file mode 100644 index d59e69209d..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/TestAllDivide.composite +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/TestAllPolicyCalculator.composite b/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/TestAllPolicyCalculator.composite deleted file mode 100644 index d0f66676e0..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/TestAllPolicyCalculator.composite +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AValue - InterestingURI - - - BValue - BoringURI - - - - diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/another_test_definitions.xml b/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/another_test_definitions.xml deleted file mode 100644 index be694f289f..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/another_test_definitions.xml +++ /dev/null @@ -1,96 +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/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/local.composite b/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/local.composite deleted file mode 100644 index abeab18a92..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/local.composite +++ /dev/null @@ -1,27 +0,0 @@ - - - - - diff --git a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/test_definitions.xml b/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/test_definitions.xml deleted file mode 100644 index 4616d07262..0000000000 --- a/java/sca-contrib/modules/assembly-xml-osoa/src/test/resources/org/apache/tuscany/sca/assembly/xml/osoa/test_definitions.xml +++ /dev/null @@ -1,206 +0,0 @@ - - - - - - - - - - - - Test Intent - - - - - - Protect messages from unauthorized reading or modification - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ... - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ... - - - - - ... - - - - - - - - - - - sp:X509v3 - - - - - - - - - - - - - - - - - - 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. - - - - - - All messages to and from this implementation must be logged - - - - - - Need to figure out some description for this - - - - \ No newline at end of file -- cgit v1.2.3