You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ad...@apache.org on 2008/05/03 22:52:58 UTC

svn commit: r653133 [9/33] - in /incubator/tuscany/sandbox/mobile-android: android-jdk-classes/ android-jdk-classes/src/ android-jdk-classes/src/javax/ android-jdk-classes/src/javax/xml/ android-jdk-classes/src/javax/xml/namespace/ android-jdk-classes/...

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/.classpath
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/.classpath?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/.classpath (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/.classpath Sat May  3 13:52:41 2008
@@ -0,0 +1,40 @@
+<classpath>
+  <classpathentry kind="src" path="src/main/java"/>
+  <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
+  <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
+  <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
+  <classpathentry kind="output" path="target/classes"/>
+  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/4.2/junit-4.2.jar"/>
+  <classpathentry kind="src" path="/tuscany-assembly"/>
+  <classpathentry kind="src" path="/tuscany-policy"/>
+  <classpathentry kind="src" path="/tuscany-extensibility"/>
+  <classpathentry kind="src" path="/tuscany-interface"/>
+  <classpathentry kind="src" path="/tuscany-definitions"/>
+  <classpathentry kind="src" path="/tuscany-assembly-xsd"/>
+  <classpathentry kind="src" path="/tuscany-contribution"/>
+  <classpathentry kind="var" path="M2_REPO/stax/stax-api/1.0.1/stax-api-1.0.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.3.03/xml-apis-1.3.03.jar"/>
+  <classpathentry kind="src" path="/tuscany-contribution-impl"/>
+  <classpathentry kind="src" path="/tuscany-contribution-xml"/>
+  <classpathentry kind="var" path="M2_REPO/org/codehaus/woodstox/wstx-asl/3.2.1/wstx-asl-3.2.1.jar"/>
+  <classpathentry kind="src" path="/tuscany-contribution-java"/>
+  <classpathentry kind="src" path="/tuscany-core-spi"/>
+  <classpathentry kind="src" path="/tuscany-sca-api"/>
+  <classpathentry kind="src" path="/tuscany-contribution-namespace"/>
+  <classpathentry kind="src" path="/tuscany-contribution-resource"/>
+  <classpathentry kind="src" path="/tuscany-definitions-xml"/>
+  <classpathentry kind="src" path="/tuscany-policy-xml"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/ws/commons/axiom/axiom-api/1.2.5/axiom-api-1.2.5.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jaxen/jaxen/1.1-beta-9/jaxen-1.1-beta-9.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.8.1/xercesImpl-2.8.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/neethi/neethi/2.0.2/neethi-2.0.2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/ws/commons/axiom/axiom-impl/1.2.5/axiom-impl-1.2.5.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1/commons-logging-1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.12/log4j-1.2.12.jar"/>
+  <classpathentry kind="var" path="M2_REPO/logkit/logkit/1.0.1/logkit-1.0.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/avalon-framework/avalon-framework/4.1.3/avalon-framework-4.1.3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/servlet/servlet-api/2.3/servlet-api-2.3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/easymock/easymock/2.2/easymock-2.2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xalan/xalan/2.7.0/xalan-2.7.0.jar"/>
+</classpath>
\ No newline at end of file

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/.project
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/.project?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/.project (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/.project Sat May  3 13:52:41 2008
@@ -0,0 +1,30 @@
+<projectDescription>
+  <name>tuscany-assembly-xml</name>
+  <comment>Parent POM defining settings that can be used across Tuscany</comment>
+  <projects>
+    <project>tuscany-assembly</project>
+    <project>tuscany-policy</project>
+    <project>tuscany-extensibility</project>
+    <project>tuscany-interface</project>
+    <project>tuscany-definitions</project>
+    <project>tuscany-assembly-xsd</project>
+    <project>tuscany-contribution</project>
+    <project>tuscany-contribution-impl</project>
+    <project>tuscany-contribution-xml</project>
+    <project>tuscany-contribution-java</project>
+    <project>tuscany-core-spi</project>
+    <project>tuscany-sca-api</project>
+    <project>tuscany-contribution-namespace</project>
+    <project>tuscany-contribution-resource</project>
+    <project>tuscany-definitions-xml</project>
+    <project>tuscany-policy-xml</project>
+  </projects>
+  <buildSpec>
+    <buildCommand>
+      <name>org.eclipse.jdt.core.javabuilder</name>
+    </buildCommand>
+  </buildSpec>
+  <natures>
+    <nature>org.eclipse.jdt.core.javanature</nature>
+  </natures>
+</projectDescription>
\ No newline at end of file

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/.settings/org.eclipse.jdt.core.prefs
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/.settings/org.eclipse.jdt.core.prefs?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/.settings/org.eclipse.jdt.core.prefs (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/.settings/org.eclipse.jdt.core.prefs Sat May  3 13:52:41 2008
@@ -0,0 +1,5 @@
+#Thu Mar 20 19:20:00 PDT 2008
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/DISCLAIMER
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/DISCLAIMER?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/DISCLAIMER (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/DISCLAIMER Sat May  3 13:52:41 2008
@@ -0,0 +1,8 @@
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/LICENSE
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/LICENSE?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/LICENSE (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/LICENSE Sat May  3 13:52:41 2008
@@ -0,0 +1,205 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+
+

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/NOTICE
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/NOTICE?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/NOTICE (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/NOTICE Sat May  3 13:52:41 2008
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/pom.xml?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/pom.xml (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/pom.xml Sat May  3 13:52:41 2008
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    * Licensed to the Apache Software Foundation (ASF) under one
+    * or more contributor license agreements.  See the NOTICE file
+    * distributed with this work for additional information
+    * regarding copyright ownership.  The ASF licenses this file
+    * to you under the Apache License, Version 2.0 (the
+    * "License"); you may not use this file except in compliance
+    * with the License.  You may obtain a copy of the License at
+    * 
+    *   http://www.apache.org/licenses/LICENSE-2.0
+    * 
+    * Unless required by applicable law or agreed to in writing,
+    * software distributed under the License is distributed on an
+    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    * KIND, either express or implied.  See the License for the
+    * specific language governing permissions and limitations
+    * under the License.    
+-->
+<project>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tuscany.sca</groupId>
+        <artifactId>tuscany-modules</artifactId>
+        <version>2.0-incubating-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <artifactId>tuscany-assembly-xml</artifactId>
+    <name>Apache Tuscany SCA XML Assembly Model</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-assembly</artifactId>
+            <version>2.0-incubating-SNAPSHOT</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-definitions-xml</artifactId>
+            <version>2.0-incubating-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-definitions</artifactId>
+            <version>2.0-incubating-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-contribution</artifactId>
+            <version>2.0-incubating-SNAPSHOT</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-contribution-namespace</artifactId>
+            <version>2.0-incubating-SNAPSHOT</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-contribution-java</artifactId>
+            <version>2.0-incubating-SNAPSHOT</version>
+        </dependency>        
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-contribution-impl</artifactId>
+            <version>2.0-incubating-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-policy</artifactId>
+            <version>2.0-incubating-SNAPSHOT</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-policy-xml</artifactId>
+            <version>2.0-incubating-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>stax</groupId>
+            <artifactId>stax-api</artifactId>
+            <version>1.0.1</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.codehaus.woodstox</groupId>
+            <artifactId>wstx-asl</artifactId>
+            <version>3.2.1</version>
+            <scope>runtime</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>xalan</groupId>
+            <artifactId>xalan</artifactId>
+            <version>2.7.0</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-assembly-xsd</artifactId>
+            <version>2.0-incubating-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        
+    </dependencies>
+</project>

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java Sat May  3 13:52:41 2008
@@ -0,0 +1,814 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import static javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
+import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.dom.DOMSource;
+
+import org.apache.tuscany.sca.assembly.AbstractContract;
+import org.apache.tuscany.sca.assembly.AbstractProperty;
+import org.apache.tuscany.sca.assembly.AbstractReference;
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.ConfiguredOperation;
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.OperationsConfigurator;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentAttachPoint;
+import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.impl.IntentAttachPointTypeFactoryImpl;
+import org.apache.tuscany.sca.policy.util.PolicyValidationException;
+import org.apache.tuscany.sca.policy.util.PolicyValidationUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * A base class with utility methods for the other artifact processors in this module. 
+ * 
+ * @version $Rev: 643489 $ $Date: 2008-04-01 10:06:42 -0800 (Tue, 01 Apr 2008) $
+ */
+abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor implements Constants {
+
+    protected ContributionFactory contributionFactory;
+    protected AssemblyFactory assemblyFactory;
+    protected PolicyFactory policyFactory;
+    protected StAXArtifactProcessor<Object> extensionProcessor;
+    protected PolicyAttachPointProcessor policyProcessor;
+    private DocumentBuilderFactory documentBuilderFactory;
+    protected IntentAttachPointTypeFactory intentAttachPointTypeFactory;
+
+    /**
+     * Constructs a new BaseArtifactProcessor.
+     * @param contribFactory
+     * @param factory
+     * @param policyFactory
+     */
+    @SuppressWarnings("unchecked")
+    public BaseAssemblyProcessor(ContributionFactory contribFactory,
+                                 AssemblyFactory factory,
+                                 PolicyFactory policyFactory,
+                                 StAXArtifactProcessor extensionProcessor) {
+        this.assemblyFactory = factory;
+        this.policyFactory = policyFactory;
+        this.extensionProcessor = (StAXArtifactProcessor<Object>)extensionProcessor;
+        this.contributionFactory = contribFactory;
+        this.policyProcessor = new PolicyAttachPointProcessor(policyFactory);
+        this.intentAttachPointTypeFactory = new IntentAttachPointTypeFactoryImpl();
+    }
+
+    /**
+     * Constructs a new BaseArtifactProcessor.
+     * @param factory
+     * @param policyFactory
+     */
+    @SuppressWarnings("unchecked")
+    public BaseAssemblyProcessor(AssemblyFactory factory,
+                                 PolicyFactory policyFactory,
+                                 StAXArtifactProcessor extensionProcessor) {
+        this.assemblyFactory = factory;
+        this.policyFactory = policyFactory;
+        this.extensionProcessor = (StAXArtifactProcessor<Object>)extensionProcessor;
+        this.policyProcessor = new PolicyAttachPointProcessor(policyFactory);
+    }
+
+    /**
+     * Start an element.
+     * @param writer
+     * @param name
+     * @param attrs
+     * @throws XMLStreamException
+     */
+    protected void writeStart(XMLStreamWriter writer, String name, XAttr... attrs) throws XMLStreamException {
+        writeStart(writer, SCA10_NS, name, attrs);
+    }
+
+    /**
+     * Start a document.
+     * @param writer
+     * @throws XMLStreamException
+     */
+    protected void writeStartDocument(XMLStreamWriter writer, String name, XAttr... attrs) throws XMLStreamException {
+        writer.writeStartDocument();
+        writer.setDefaultNamespace(SCA10_NS);
+        writeStart(writer, SCA10_NS, name, attrs);
+        writer.writeDefaultNamespace(SCA10_NS);
+    }
+
+    /**
+     * Read list of reference targets
+     * @param reference
+     * @param reader
+     */
+    protected void readTargets(Reference reference, XMLStreamReader reader) {
+        String value = reader.getAttributeValue(null, TARGET);
+        ComponentService target = null;
+        if (value != null) {
+            for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+                target = assemblyFactory.createComponentService();
+                target.setUnresolved(true);
+                target.setName(tokens.nextToken());
+                reference.getTargets().add(target);
+            }
+        }
+    }
+
+    /**
+     * Write a list of targets into an attribute
+     * @param reference
+     * @return
+     */
+    protected XAttr writeTargets(Reference reference) {
+        List<String> targets = new ArrayList<String>();
+        for (Service target : reference.getTargets()) {
+            targets.add(target.getName());
+        }
+        return new XAttr(TARGET, targets);
+    }
+
+    /**
+     * Read a multiplicity attribute.
+     * @param reference
+     * @param reader
+     */
+    protected void readMultiplicity(AbstractReference reference, XMLStreamReader reader) {
+        String value = reader.getAttributeValue(null, MULTIPLICITY);
+        if (ZERO_ONE.equals(value)) {
+            reference.setMultiplicity(Multiplicity.ZERO_ONE);
+        } else if (ONE_N.equals(value)) {
+            reference.setMultiplicity(Multiplicity.ONE_N);
+        } else if (ZERO_N.equals(value)) {
+            reference.setMultiplicity(Multiplicity.ZERO_N);
+        }
+    }
+
+    /**
+     * Returns the value of a constrainingType attribute.
+     * @param reader
+     * @return
+     */
+    protected ConstrainingType readConstrainingType(XMLStreamReader reader) {
+        QName constrainingTypeName = getQName(reader, Constants.CONSTRAINING_TYPE);
+        if (constrainingTypeName != null) {
+            ConstrainingType constrainingType = assemblyFactory.createConstrainingType();
+            constrainingType.setName(constrainingTypeName);
+            constrainingType.setUnresolved(true);
+            return constrainingType;
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Reads an abstract property element.
+     * @param property
+     * @param reader
+     * @throws XMLStreamException
+     * @throws ContributionReadException
+     */
+    protected void readAbstractProperty(AbstractProperty property, XMLStreamReader reader) throws XMLStreamException,
+        ContributionReadException {
+
+        property.setName(getString(reader, NAME));
+        property.setMany(getBoolean(reader, MANY));
+        property.setMustSupply(getBoolean(reader, MUST_SUPPLY));
+        property.setXSDElement(getQName(reader, ELEMENT));
+        property.setXSDType(getQName(reader, TYPE));
+    }
+
+    /**
+     * Resolve an implementation.
+     * @param implementation
+     * @param resolver
+     * @return
+     * @throws ContributionResolveException
+     */
+    protected Implementation resolveImplementation(Implementation implementation, ModelResolver resolver)
+        throws ContributionResolveException, PolicyValidationException {
+        if (implementation != null) {
+            if (implementation.isUnresolved()) {
+                implementation = resolver.resolveModel(Implementation.class, implementation);
+
+                // Lazily resolve implementations
+                if (implementation.isUnresolved()) {
+                    extensionProcessor.resolve(implementation, resolver);
+                    if (!implementation.isUnresolved()) {
+                        //resolve policies
+                        if ( implementation instanceof PolicySetAttachPoint ) {
+                            PolicySetAttachPoint policiedImpl = (PolicySetAttachPoint)implementation;
+                            resolveIntents(policiedImpl.getRequiredIntents(), resolver);
+                            PolicyValidationUtils.validateIntents(policiedImpl, policiedImpl.getType());
+                            
+                            resolvePolicySets(policiedImpl.getPolicySets(), resolver);
+                            PolicyValidationUtils.validatePolicySets(policiedImpl);
+                            
+                            if ( implementation instanceof OperationsConfigurator ) {
+                                OperationsConfigurator opsConfigurator = (OperationsConfigurator)implementation;
+                                for ( ConfiguredOperation implOp : opsConfigurator.getConfiguredOperations() ) {
+                                    resolveIntents(implOp.getRequiredIntents(), resolver);
+                                    PolicyValidationUtils.validateIntents(implOp, policiedImpl.getType());
+                                    
+                                    resolvePolicySets(implOp.getPolicySets(), resolver);
+                                    PolicyValidationUtils.validatePolicySets(implOp, 
+                                                                             policiedImpl.getType(),
+                                                                             policiedImpl.getApplicablePolicySets());
+                                }
+                            }
+                            
+                            for ( Service service : implementation.getServices() ) {
+                                resolveIntents(service.getRequiredIntents(), resolver);
+                                resolvePolicySets(service.getPolicySets(), resolver);
+                                
+                                for ( ConfiguredOperation svcOp : service.getConfiguredOperations() ) {
+                                    resolveIntents(svcOp.getRequiredIntents(), resolver);
+                                    resolvePolicySets(svcOp.getPolicySets(), resolver);
+                                }
+                            }
+                            
+                            for ( Reference reference : implementation.getReferences() ) {
+                                resolveIntents(reference.getRequiredIntents(), resolver);
+                                resolvePolicySets(reference.getPolicySets(), resolver);
+                            }
+                        }
+                        
+                        resolver.addModel(implementation);
+                    }
+                }
+            }
+            
+            if ( implementation instanceof IntentAttachPoint &&
+                ((IntentAttachPoint)implementation).getType() != null && 
+                ((IntentAttachPoint)implementation).getType().isUnresolved() ) {
+                ((IntentAttachPoint)implementation).setType(
+                               resolver.resolveModel(IntentAttachPointType.class, 
+                                                     ((IntentAttachPoint)implementation).getType()));
+            }
+        }
+        return implementation;
+    }
+    
+    /**
+     * Resolve interface, callback interface and bindings on a list of contracts.
+     * @param contracts the list of contracts
+     * @param resolver the resolver to use to resolve models
+     */
+    protected <C extends Contract> void resolveContracts(List<C> 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 <C extends Contract> void resolveContracts(Base parent, List<C> contracts, ModelResolver resolver)
+        throws ContributionResolveException {
+        
+        String parentName = (parent instanceof Composite) ? ((Composite)parent).getName().toString() :
+            (parent instanceof Component) ? ((Component)parent).getName().toString() : "UNKNOWN";
+        
+        for (Contract contract : contracts) {
+            try {
+                //resolve the intents and policysets as they need to be copied over into the
+                //child binding elements
+                resolveIntents(contract.getRequiredIntents(), resolver);
+                resolvePolicySets(contract.getPolicySets(), resolver);
+                resolvePolicySets(contract.getApplicablePolicySets(), resolver);
+                
+                //inherit the composite / component level policy intents and policysets
+                if ( parent != null && parent instanceof PolicySetAttachPoint )  {
+                    addInheritedIntents(((PolicySetAttachPoint)parent).getRequiredIntents(), contract.getRequiredIntents());
+                    addInheritedPolicySets(((PolicySetAttachPoint)parent).getPolicySets(), contract.getPolicySets());
+                    addInheritedPolicySets(((PolicySetAttachPoint)parent).getApplicablePolicySets(), contract.getApplicablePolicySets());
+                }
+                
+                for ( ConfiguredOperation confOp : contract.getConfiguredOperations() ) {
+                    resolveIntents(confOp.getRequiredIntents(), resolver);
+                    resolvePolicySets(confOp.getPolicySets(), resolver);
+                    resolvePolicySets(confOp.getApplicablePolicySets(), resolver);
+                    
+                    //inherit intents and policysets from parent contract
+                    addInheritedIntents(contract.getRequiredIntents(), confOp.getRequiredIntents());
+                    addInheritedPolicySets(contract.getPolicySets(), confOp.getPolicySets());
+                    addInheritedPolicySets(contract.getApplicablePolicySets(), confOp.getApplicablePolicySets());
+                }
+                                
+                // Resolve the interface contract
+                InterfaceContract interfaceContract = contract.getInterfaceContract();
+                if (interfaceContract != null) {
+                    extensionProcessor.resolve(interfaceContract, resolver);
+                }
+    
+                // Resolve bindings
+                for (int i = 0, n = contract.getBindings().size(); i < n; i++) {
+                    Binding binding = contract.getBindings().get(i);
+                    extensionProcessor.resolve(binding, resolver);
+                    
+                    if (binding instanceof IntentAttachPoint) {
+                        IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;
+                        
+                        if ( policiedBinding.getType().isUnresolved() ) {
+                            IntentAttachPointType resolved = 
+                                resolver.resolveModel(IntentAttachPointType.class, 
+                                                      policiedBinding.getType());
+                            policiedBinding.setType(resolved);
+                        }
+                        
+                        resolveIntents(policiedBinding.getRequiredIntents(), resolver);
+                        PolicyValidationUtils.validateIntents(policiedBinding, policiedBinding.getType());
+                    }
+                    
+                    if (binding instanceof PolicySetAttachPoint) {
+                        PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
+                        resolvePolicySets(policiedBinding.getPolicySets(), resolver);
+                        //validate if attached policysets apply to the binding
+                        resolvePolicySets(policiedBinding.getApplicablePolicySets(), resolver);
+                        //inherit the applicable policysets from parent contract as whatever applies to that
+                        //applies to the binding as well
+                        addInheritedPolicySets(contract.getApplicablePolicySets(), policiedBinding.getApplicablePolicySets());
+                        PolicyValidationUtils.validatePolicySets(policiedBinding);
+                    }
+                    
+                    if (binding instanceof OperationsConfigurator) {
+                        OperationsConfigurator opConfigurator = (OperationsConfigurator)binding;
+                        for (ConfiguredOperation confOp : opConfigurator.getConfiguredOperations()) {
+                            resolveIntents(confOp.getRequiredIntents(), resolver);
+                            PolicyValidationUtils.validateIntents(confOp, ((PolicySetAttachPoint)binding).getType());
+                            
+                            resolvePolicySets(confOp.getPolicySets(), resolver);
+                            resolvePolicySets(confOp.getApplicablePolicySets(), resolver);
+                            //inherit the applicable policysets from parent binding as whatever applies to that
+                            //applies to the binding as well
+                            addInheritedPolicySets(((PolicySetAttachPoint)binding).getApplicablePolicySets(), 
+                                                   confOp.getApplicablePolicySets());
+                            PolicyValidationUtils.validatePolicySets(confOp, ((PolicySetAttachPoint)binding).getType());
+                            
+                            addInheritedIntents(((PolicySetAttachPoint)binding).getRequiredIntents(), 
+                                                confOp.getRequiredIntents());
+                            addInheritedPolicySets(((PolicySetAttachPoint)binding).getPolicySets(), 
+                                                confOp.getPolicySets());
+                        }
+                    }
+                }
+    
+                // Resolve callback bindings
+                if (contract.getCallback() != null) {
+                    resolveIntents(contract.getCallback().getRequiredIntents(), resolver);
+                    resolvePolicySets(contract.getCallback().getPolicySets(), resolver);
+                    resolvePolicySets(contract.getCallback().getApplicablePolicySets(), resolver);
+                    //inherit the contract's policy intents and policysets
+                    addInheritedIntents(contract.getRequiredIntents(), contract.getCallback().getRequiredIntents());
+                    addInheritedPolicySets(contract.getPolicySets(), contract.getCallback().getPolicySets());
+                    addInheritedPolicySets(contract.getApplicablePolicySets(), contract.getCallback().getApplicablePolicySets());
+                    
+                    for (int i = 0, n = contract.getCallback().getBindings().size(); i < n; i++) {
+                        Binding binding = contract.getCallback().getBindings().get(i);
+                        extensionProcessor.resolve(binding, resolver);
+    
+                        if (binding instanceof IntentAttachPoint) {
+                            IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;
+                            
+                            if ( policiedBinding.getType().isUnresolved() ) {
+                                IntentAttachPointType resolved = 
+                                    resolver.resolveModel(IntentAttachPointType.class, 
+                                                          policiedBinding.getType());
+                                policiedBinding.setType(resolved);
+                            }
+                            
+                            resolveIntents(policiedBinding.getRequiredIntents(), resolver);
+                            PolicyValidationUtils.validateIntents(policiedBinding, policiedBinding.getType());
+                        }
+                        
+                        if (binding instanceof PolicySetAttachPoint) {
+                            PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
+                            resolvePolicySets(policiedBinding.getPolicySets(), resolver);
+                            //validate if attached policysets apply to the binding
+                            resolvePolicySets(policiedBinding.getApplicablePolicySets(), resolver);
+                            //inherit the applicable policysets from parent contract as whatever applies to that
+                            //applies to the binding as well
+                            addInheritedPolicySets(contract.getApplicablePolicySets(), policiedBinding.getApplicablePolicySets());
+                            PolicyValidationUtils.validatePolicySets(policiedBinding);
+                        }
+                        
+                        if (binding instanceof OperationsConfigurator) {
+                            OperationsConfigurator opConfigurator = (OperationsConfigurator)binding;
+                            for (ConfiguredOperation confOp : opConfigurator.getConfiguredOperations()) {
+                                resolveIntents(confOp.getRequiredIntents(), resolver);
+                                PolicyValidationUtils.validateIntents(confOp, ((PolicySetAttachPoint)binding).getType());
+                                
+                                resolvePolicySets(confOp.getPolicySets(), resolver);
+                                resolvePolicySets(confOp.getApplicablePolicySets(), resolver);
+                                //inherit the applicable policysets from parent binding as whatever applies to that
+                                //applies to the binding as well
+                                addInheritedPolicySets(((PolicySetAttachPoint)binding).getApplicablePolicySets(), 
+                                                       confOp.getApplicablePolicySets());
+                                PolicyValidationUtils.validatePolicySets(confOp, ((PolicySetAttachPoint)binding).getType());
+                            }
+                        }
+                    }
+                }
+            } catch ( PolicyValidationException e ) {
+                throw new ContributionResolveException("PolicyValidation exceptions when processing service/reference '" 
+                                                       + contract.getName() + "' in '" + parentName + "'");
+            }
+        }
+    }
+
+    /**
+     * Resolve interface and callback interface on a list of abstract contracts.
+     * @param contracts the list of contracts
+     * @param resolver the resolver to use to resolve models
+     */
+    protected <C extends AbstractContract> void resolveAbstractContracts(List<C> contracts, ModelResolver resolver)
+        throws ContributionResolveException {
+        for (AbstractContract contract : contracts) {
+
+            // Resolve the interface contract
+            InterfaceContract interfaceContract = contract.getInterfaceContract();
+            if (interfaceContract != null) {
+                extensionProcessor.resolve(interfaceContract, resolver);
+            }
+        }
+    }
+
+    /**
+     * Returns a constrainingType attribute.
+     * @param componentType
+     * @return
+     */
+    protected XAttr writeConstrainingType(ComponentType componentType) {
+        ConstrainingType constrainingType = componentType.getConstrainingType();
+        if (constrainingType != null)
+            return new XAttr(Constants.CONSTRAINING_TYPE, constrainingType.getName());
+        else
+            return null;
+    }
+
+    /**
+     * Read a property value into a DOM document.
+     * @param element
+     * @param type
+     * @param reader
+     * @return
+     * @throws XMLStreamException
+     * @throws ContributionReadException
+     * @throws ParserConfigurationException 
+     */
+    protected Document readPropertyValue(QName element, QName type, XMLStreamReader reader) throws XMLStreamException,
+        ContributionReadException {
+
+        Document document;
+        try {
+            if (documentBuilderFactory == null) {
+                documentBuilderFactory = DocumentBuilderFactory.newInstance();
+                documentBuilderFactory.setNamespaceAware(true);
+            }
+            document = documentBuilderFactory.newDocumentBuilder().newDocument();
+        } catch (ParserConfigurationException e) {
+            throw new ContributionReadException(e);
+        }
+
+        // root element has no namespace and local name "value"
+        Element root = document.createElementNS(null, "value");
+        if (type != null) {
+            org.w3c.dom.Attr xsi = document.createAttributeNS(XMLNS_ATTRIBUTE_NS_URI, "xmlns:xsi");
+            xsi.setValue(W3C_XML_SCHEMA_INSTANCE_NS_URI);
+            root.setAttributeNodeNS(xsi);
+
+            String prefix = type.getPrefix();
+            if (prefix == null || prefix.length() == 0) {
+                prefix = "ns";
+            }
+
+            declareNamespace(root, prefix, type.getNamespaceURI());
+
+            org.w3c.dom.Attr xsiType = document.createAttributeNS(W3C_XML_SCHEMA_INSTANCE_NS_URI, "xsi:type");
+            xsiType.setValue(prefix + ":" + type.getLocalPart());
+            root.setAttributeNodeNS(xsiType);
+        }
+        document.appendChild(root);
+
+        loadElement(reader, root);
+        return document;
+    }
+
+    /**
+     * Create a DOM element
+     * @param document
+     * @param name
+     * @return
+     */
+    private Element createElement(Document document, QName name) {
+        String prefix = name.getPrefix();
+        String qname =
+            (prefix != null && prefix.length() > 0) ? prefix + ":" + name.getLocalPart() : name.getLocalPart();
+        return document.createElementNS(name.getNamespaceURI(), qname);
+    }
+
+    /**
+     * Declare a namespace.
+     * @param element
+     * @param prefix
+     * @param ns
+     */
+    private void declareNamespace(Element element, String prefix, String ns) {
+        if (ns == null) {
+            ns = "";
+        }
+        if (prefix == null) {
+            prefix = "";
+        }
+        String qname = null;
+        if ("".equals(prefix)) {
+            qname = "xmlns";
+        } else {
+            qname = "xmlns:" + prefix;
+        }
+        Node node = element;
+        boolean declared = false;
+        while (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
+            NamedNodeMap attrs = node.getAttributes();
+            if (attrs == null) {
+                break;
+            }
+            Node attr = attrs.getNamedItem(qname);
+            if (attr != null) {
+                declared = ns.equals(attr.getNodeValue());
+                break;
+            }
+            node = node.getParentNode();
+        }
+        if (!declared) {
+            org.w3c.dom.Attr attr = element.getOwnerDocument().createAttributeNS(XMLNS_ATTRIBUTE_NS_URI, qname);
+            attr.setValue(ns);
+            element.setAttributeNodeNS(attr);
+        }
+    }
+
+    /**
+     * Load a property value specification from an StAX stream into a DOM
+     * Document. Only elements, text and attributes are processed; all comments
+     * and other whitespace are ignored.
+     * 
+     * @param reader the stream to read from
+     * @param root the DOM node to load
+     * @throws javax.xml.stream.XMLStreamException
+     */
+    private void loadElement(XMLStreamReader reader, Element root) throws XMLStreamException {
+        Document document = root.getOwnerDocument();
+        Node current = root;
+        while (true) {
+            switch (reader.next()) {
+                case XMLStreamConstants.START_ELEMENT:
+                    QName name = reader.getName();
+                    Element child = createElement(document, name);
+
+                    // push the new element and make it the current one
+                    current.appendChild(child);
+                    current = child;
+
+                    int count = reader.getNamespaceCount();
+                    for (int i = 0; i < count; i++) {
+                        String prefix = reader.getNamespacePrefix(i);
+                        String ns = reader.getNamespaceURI(i);
+                        declareNamespace(child, prefix, ns);
+                    }
+
+                    if (!"".equals(name.getNamespaceURI())) {
+                        declareNamespace(child, name.getPrefix(), name.getNamespaceURI());
+                    }
+
+                    // add the attributes for this element
+                    count = reader.getAttributeCount();
+                    for (int i = 0; i < count; i++) {
+                        String ns = reader.getAttributeNamespace(i);
+                        String prefix = reader.getAttributePrefix(i);
+                        String qname = reader.getAttributeLocalName(i);
+                        String value = reader.getAttributeValue(i);
+                        if (prefix != null && prefix.length() != 0) {
+                            qname = prefix + ":" + qname;
+                        }
+                        child.setAttributeNS(ns, qname, value);
+                        if (ns != null) {
+                            declareNamespace(child, prefix, ns);
+                        }
+                    }
+
+                    break;
+                case XMLStreamConstants.CDATA:
+                    current.appendChild(document.createCDATASection(reader.getText()));
+                    break;
+                case XMLStreamConstants.CHARACTERS:
+                    current.appendChild(document.createTextNode(reader.getText()));
+                    break;
+                case XMLStreamConstants.END_ELEMENT:
+                    // if we are back at the root then we are done
+                    if (current == root) {
+                        return;
+                    }
+
+                    // pop the element off the stack
+                    current = current.getParentNode();
+            }
+        }
+    }
+
+    /**
+     * Resolve policy intents attached to a specific SCA Artifact
+     * @param policyIntents list of policy intents
+     * @param resolver
+     */
+    protected void resolveIntents(List<Intent> policyIntents, ModelResolver resolver) {
+        List<Intent> requiredIntents = new ArrayList<Intent>();
+        Intent resolvedIntent = null;
+        for (Intent intent : policyIntents) {
+            resolvedIntent = resolver.resolveModel(Intent.class, intent);
+            requiredIntents.add(resolvedIntent);
+        }
+        policyIntents.clear();
+        policyIntents.addAll(requiredIntents);
+    }
+
+    /**
+     * Resolve policy sets attached to a specific SCA Construct
+     * @param policySets list of attached policy sets
+     * @param resolver
+     */
+    protected void resolvePolicySets(List<PolicySet> policySets, ModelResolver resolver) {
+        List<PolicySet> resolvedPolicySets = new ArrayList<PolicySet>();
+        PolicySet resolvedPolicySet = null;
+        for (PolicySet policySet : policySets) {
+            resolvedPolicySet = resolver.resolveModel(PolicySet.class, policySet);
+            resolvedPolicySets.add(resolvedPolicySet);
+        }
+        policySets.clear();
+        policySets.addAll(resolvedPolicySets);
+    }
+
+    /**
+     * Write the value of a property 
+     * @param document
+     * @param element
+     * @param type
+     * @param writer
+     * @throws XMLStreamException
+     */
+    protected void writePropertyValue(Object propertyValue, QName element, QName type, XMLStreamWriter writer)
+        throws XMLStreamException {
+
+        if (propertyValue instanceof Document) {
+            Document document = (Document)propertyValue;
+            NodeList nodeList = document.getDocumentElement().getChildNodes();
+
+            for (int item = 0; item < nodeList.getLength(); ++item) {
+                Node node = nodeList.item(item);
+                int nodeType = node.getNodeType();
+                if (nodeType == Node.ELEMENT_NODE) {
+                    XMLStreamReader reader =
+                        XMLInputFactory.newInstance().createXMLStreamReader(new DOMSource(node));
+
+                    while (reader.hasNext()) {
+                        switch (reader.next()) {
+                            case XMLStreamConstants.START_ELEMENT:
+                                QName name = reader.getName();
+                                writer.writeStartElement(name.getPrefix(), name.getLocalPart(), name.getNamespaceURI());
+
+                                int namespaces = reader.getNamespaceCount();
+                                for (int i = 0; i < namespaces; i++) {
+                                    String prefix = reader.getNamespacePrefix(i);
+                                    String ns = reader.getNamespaceURI(i);
+                                    writer.writeNamespace(prefix, ns);
+                                }
+
+                                if (!"".equals(name.getNamespaceURI())) {
+                                    writer.writeNamespace(name.getPrefix(), name.getNamespaceURI());
+                                }
+
+                                // add the attributes for this element
+                                namespaces = reader.getAttributeCount();
+                                for (int i = 0; i < namespaces; i++) {
+                                    String ns = reader.getAttributeNamespace(i);
+                                    String prefix = reader.getAttributePrefix(i);
+                                    String qname = reader.getAttributeLocalName(i);
+                                    String value = reader.getAttributeValue(i);
+
+                                    writer.writeAttribute(prefix, ns, qname, value);
+                                }
+
+                                break;
+                            case XMLStreamConstants.CDATA:
+                                writer.writeCData(reader.getText());
+                                break;
+                            case XMLStreamConstants.CHARACTERS:
+                                writer.writeCharacters(reader.getText());
+                                break;
+                            case XMLStreamConstants.END_ELEMENT:
+                                writer.writeEndElement();
+                                break;
+                        }
+                    }
+                } else {
+                    writer.writeCharacters(node.getTextContent());
+                }
+            }
+        }
+    }
+    
+    protected void addInheritedIntents(List<Intent> sourceList, List<Intent> targetList) {
+        if (sourceList != null) {
+            targetList.addAll(sourceList);
+        }
+    }
+    
+    protected  void addInheritedPolicySets(List<PolicySet> sourceList, List<PolicySet> targetList) {
+        if (sourceList != null) {
+            targetList.addAll(sourceList);
+        }
+    }
+    
+    
+    /*protected void validatePolicySets(PolicySetAttachPoint policySetAttachPoint) 
+                                                            throws ContributionResolveException {
+        validatePolicySets(policySetAttachPoint, policySetAttachPoint.getApplicablePolicySets());
+    }
+     
+    
+    protected void validatePolicySets(PolicySetAttachPoint policySetAttachPoint,
+                                      List<PolicySet> applicablePolicySets) throws ContributionResolveException {
+        //Since the applicablePolicySets in a policySetAttachPoint will already have the 
+        //list of policysets that might ever be applicable to this attachPoint, just check
+        //if the defined policysets feature in the list of applicable policysets
+        IntentAttachPointType attachPointType = policySetAttachPoint.getType();
+        for ( PolicySet definedPolicySet : policySetAttachPoint.getPolicySets() ) {
+            if ( !definedPolicySet.isUnresolved() ) {
+                if ( !applicablePolicySets.contains(definedPolicySet)) {
+                    throw new ContributionResolveException("Policy Set '" + definedPolicySet.getName()
+                                                           + "' does not apply to binding type  "
+                                                           + attachPointType.getName());
+                }
+            } else {
+                throw new ContributionResolveException("Policy Set '" + definedPolicySet.getName()
+                                                       + "' is not defined in this domain  ");
+                                                
+            
+            }
+        }
+    }*/
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java Sat May  3 13:52:41 2008
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+
+/**
+ * A componentType processor.
+ * 
+ * @version $Rev: 635373 $ $Date: 2008-03-09 14:51:51 -0700 (Sun, 09 Mar 2008) $
+ */
+public class ComponentTypeDocumentProcessor extends BaseAssemblyProcessor implements URLArtifactProcessor<ComponentType> {
+    private XMLInputFactory inputFactory;
+    
+    /**
+     * Constructs a new componentType processor.
+     * @param factory
+     * @param policyFactory
+     * @param registry
+     */
+    public ComponentTypeDocumentProcessor(StAXArtifactProcessor staxProcessor, XMLInputFactory inputFactory) {
+        super(null, null, staxProcessor);
+        this.inputFactory = inputFactory;
+    }
+    
+    public ComponentType read(URL contributionURL, URI uri, URL url) throws ContributionReadException {
+        InputStream urlStream = null;
+        try {
+            
+            // Create a stream reader
+            URLConnection connection = url.openConnection();
+            connection.setUseCaches(false);
+            urlStream = connection.getInputStream();
+            XMLStreamReader reader = inputFactory.createXMLStreamReader(url.toString(), urlStream);
+            reader.nextTag();
+            
+            // Reader the componentType model 
+            ComponentType componentType = (ComponentType)extensionProcessor.read(reader);
+            if (componentType != null) {
+                componentType.setURI(uri.toString());
+            }
+
+            // For debugging purposes, write it back to XML
+//            if (componentType != null) {
+//                try {
+//                    ByteArrayOutputStream bos = new ByteArrayOutputStream();
+//                    XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+//                    outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+//                    extensionProcessor.write(componentType, outputFactory.createXMLStreamWriter(bos));
+//                    Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(bos.toByteArray()));
+//                    OutputFormat format = new OutputFormat();
+//                    format.setIndenting(true);
+//                    format.setIndent(2);
+//                    XMLSerializer serializer = new XMLSerializer(System.out, format);
+//                    serializer.serialize(document);
+//                } catch (Exception e) {
+//                    e.printStackTrace();
+//                }
+//            }
+            
+            return componentType;
+            
+        } catch (XMLStreamException e) {
+            throw new ContributionReadException(e);
+        } catch (IOException e) {
+            throw new ContributionReadException(e);
+        } finally {
+            try {
+                if (urlStream != null) {
+                    urlStream.close();
+                    urlStream = null;
+                }
+            } catch (IOException ioe) {
+                //ignore
+            }
+        }
+    }
+    
+    public void resolve(ComponentType componentType, ModelResolver resolver) throws ContributionResolveException {
+        extensionProcessor.resolve(componentType, resolver);
+    }
+    
+    public String getArtifactType() {
+        return ".componentType";
+    }
+    
+    public Class<ComponentType> getModelType() {
+        return ComponentType.class;
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java Sat May  3 13:52:41 2008
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.assembly.xml;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.java.JavaImport;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * A Model Resolver for ComponentType models.
+ *
+ * @version $Rev: 631056 $ $Date: 2008-02-25 17:28:13 -0800 (Mon, 25 Feb 2008) $
+ */
+public class ComponentTypeModelResolver implements ModelResolver {
+	private Contribution contribution;
+    private Map<String, ComponentType> map = new HashMap<String, ComponentType>();
+    
+    public ComponentTypeModelResolver(Contribution contribution, ModelFactoryExtensionPoint modelFactories) {
+    	this.contribution = contribution;
+    }
+
+    public void addModel(Object resolved) {
+        ComponentType componentType = (ComponentType)resolved;
+        map.put(componentType.getURI(), componentType);
+    }
+    
+    public Object removeModel(Object resolved) {
+        return map.remove(((ComponentType)resolved).getURI());
+    }
+    
+    public <T> T resolveModel(Class<T> modelClass, T unresolved) {
+
+    	//get componentType artifact URI
+        String uri = ((ComponentType)unresolved).getURI();
+        if (uri == null) {
+        	return (T)unresolved;
+        }
+        
+        //lookup the componentType
+        ComponentType resolved = (ComponentType) map.get(uri);
+        if (resolved != null) {
+            return modelClass.cast(resolved);
+        } 
+        
+        //If not found, delegate the resolution to the imports (in this case based on the java imports)
+        //compute the package name from the componentType URI
+        if (unresolved instanceof ComponentType) {
+            //FIXME The core assembly model now depends on java imports to 
+            // resolve componentTypes of all kinds, this is not right at all!!!
+            int s = uri.lastIndexOf('/');
+            if (s != -1) {
+                String packageName = uri.substring(0, uri.lastIndexOf("/"));
+                for (Import import_ : this.contribution.getImports()) {
+                    if (import_ instanceof JavaImport) {
+                    	JavaImport javaImport = (JavaImport)import_;
+                    	//check the import location against the computed package name from the componentType URI
+                        if (javaImport.getPackage().equals(packageName)) {
+                            // Delegate the resolution to the import resolver
+                            resolved = javaImport.getModelResolver().resolveModel(ComponentType.class, (ComponentType)unresolved);
+                            if (!resolved.isUnresolved()) {
+                                return modelClass.cast(resolved);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        return (T)unresolved;
+    }
+    
+}