summaryrefslogtreecommitdiffstats
path: root/java/sca
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-10-02 10:28:14 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-10-02 10:28:14 +0000
commit2d422d53d6060cc32649f94f5d1953c821547bc4 (patch)
tree1146c47c3e9bb97a54159ed34305c39f23f07c80 /java/sca
parent5ad7410d70e93aa58ad9bc8689bf88f02561c6a0 (diff)
Merge policy-xml and definitions-xml into assembly-xml
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@820951 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca')
-rw-r--r--java/sca/features/core/pom.xml12
-rw-r--r--java/sca/features/webservice/pom.xml6
-rw-r--r--java/sca/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java4
-rw-r--r--java/sca/modules/assembly-xml/META-INF/MANIFEST.MF8
-rw-r--r--java/sca/modules/assembly-xml/pom.xml14
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java (renamed from java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java)0
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java (renamed from java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java)0
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsExtensionPoint.java (renamed from java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsExtensionPoint.java)0
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java (renamed from java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java)0
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java67
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java251
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java67
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentProcessor.java391
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java74
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java518
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunction.java158
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolver.java72
-rw-r--r--java/sca/modules/assembly-xml/src/main/resources/META-INF/sca-policy-1.1-intents-definitions-cd02.xml (renamed from java/sca/modules/definitions-xml/src/main/resources/META-INF/sca-policy-1.1-intents-definitions-cd02.xml)0
-rw-r--r--java/sca/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor5
-rw-r--r--java/sca/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor1
-rw-r--r--java/sca/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver1
-rw-r--r--java/sca/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions (renamed from java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions)0
-rw-r--r--java/sca/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.DefinitionsExtensionPoint (renamed from java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.DefinitionsExtensionPoint)0
-rw-r--r--java/sca/modules/assembly-xml/src/main/resources/definitions-xml-validation-messages.properties (renamed from java/sca/modules/definitions-xml/src/main/resources/definitions-xml-validation-messages.properties)0
-rw-r--r--java/sca/modules/assembly-xml/src/main/resources/policy-xml-validation-messages.properties45
-rw-r--r--java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/MockPolicy.java (renamed from java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/MockPolicy.java)0
-rw-r--r--java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/ReadDocumentTestCase.java (renamed from java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/ReadDocumentTestCase.java)0
-rw-r--r--java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/TestPolicyProcessor.java (renamed from java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/TestPolicyProcessor.java)0
-rw-r--r--java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java136
-rw-r--r--java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java295
-rw-r--r--java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java82
-rw-r--r--java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/definitions/xml/test_definitions.xml (renamed from java/sca/modules/definitions-xml/src/test/resources/org/apache/tuscany/sca/definitions/xml/test_definitions.xml)0
-rw-r--r--java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite49
-rw-r--r--java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml204
-rw-r--r--java/sca/modules/binding-ws-axis2/pom.xml7
-rw-r--r--java/sca/modules/builder/pom.xml7
-rw-r--r--java/sca/modules/definitions-xml/LICENSE253
-rw-r--r--java/sca/modules/definitions-xml/META-INF/MANIFEST.MF28
-rw-r--r--java/sca/modules/definitions-xml/NOTICE12
-rw-r--r--java/sca/modules/definitions-xml/pom.xml60
-rw-r--r--java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor19
-rw-r--r--java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor19
-rw-r--r--java/sca/modules/implementation-java/pom.xml14
-rw-r--r--java/sca/modules/node-impl/pom.xml14
-rw-r--r--java/sca/modules/policy-xml-ws/pom.xml2
-rw-r--r--java/sca/modules/pom.xml2
-rw-r--r--java/sca/modules/scdl/pom.xml2
-rw-r--r--java/sca/pom.xml45
48 files changed, 2471 insertions, 473 deletions
diff --git a/java/sca/features/core/pom.xml b/java/sca/features/core/pom.xml
index c4bee1dd69..b7ae602bd1 100644
--- a/java/sca/features/core/pom.xml
+++ b/java/sca/features/core/pom.xml
@@ -120,13 +120,6 @@
<version>2.0-SNAPSHOT</version>
</dependency-->
- <!-- Policy definitions -->
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-definitions-xml</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
-
<!-- Core Extensibility -->
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
@@ -225,11 +218,6 @@
<artifactId>tuscany-policy-security-jsr250</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency-->
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-policy-xml</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
<!-- XMLSchema support -->
<dependency>
diff --git a/java/sca/features/webservice/pom.xml b/java/sca/features/webservice/pom.xml
index 75d9e6679b..b20c62eb29 100644
--- a/java/sca/features/webservice/pom.xml
+++ b/java/sca/features/webservice/pom.xml
@@ -117,12 +117,6 @@
<version>2.0-SNAPSHOT</version>
</dependency>
- <!-- Policy models -->
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-policy-xml-ws</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
</dependencies>
</project>
diff --git a/java/sca/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java b/java/sca/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java
index 27ab099091..edb6ec85e6 100644
--- a/java/sca/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java
+++ b/java/sca/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java
@@ -44,14 +44,12 @@ import org.junit.Test;
* tuscany-common-java-2.0-SNAPSHOT.jar
* tuscany-common-xml-2.0-SNAPSHOT.jar
* tuscany-contribution-2.0-SNAPSHOT.jar
- * tuscany-definitions-xml-2.0-SNAPSHOT.jar
* tuscany-extensibility-2.0-SNAPSHOT.jar
* tuscany-implementation-bpel-2.0-SNAPSHOT.jar
* tuscany-implementation-java-2.0-SNAPSHOT.jar
* tuscany-interface-java-2.0-SNAPSHOT.jar
* tuscany-interface-wsdl-2.0-SNAPSHOT.jar
* tuscany-monitor-2.0-SNAPSHOT.jar
- * tuscany-policy-xml-2.0-SNAPSHOT.jar
* tuscany-sca-api-2.0-SNAPSHOT.jar
* tuscany-scdl-2.0-SNAPSHOT.jar
* tuscany-xsd-2.0-SNAPSHOT.jar
@@ -70,6 +68,6 @@ public class ValidateDependenciesTestCase {
Assert.assertTrue(dependenciesDir.exists());
File[] dependencyFiles = dependenciesDir.listFiles();
- Assert.assertEquals(27, dependencyFiles.length);
+ Assert.assertEquals(25, dependencyFiles.length);
}
}
diff --git a/java/sca/modules/assembly-xml/META-INF/MANIFEST.MF b/java/sca/modules/assembly-xml/META-INF/MANIFEST.MF
index 12d6e6d4fc..a2e386e51e 100644
--- a/java/sca/modules/assembly-xml/META-INF/MANIFEST.MF
+++ b/java/sca/modules/assembly-xml/META-INF/MANIFEST.MF
@@ -8,7 +8,9 @@ Export-Package: org.apache.tuscany.sca.assembly.xml;uses:="org.apache.
tion,org.apache.tuscany.sca.monitor,org.w3c.dom,org.apache.tuscany.sc
a.interfacedef,org.apache.tuscany.sca.contribution.namespace,javax.xm
l.xpath,javax.xml.transform,org.apache.tuscany.sca.contribution.proce
- ssor,org.apache.tuscany.sca.interfacedef.impl";version="2.0.0"
+ ssor,org.apache.tuscany.sca.interfacedef.impl";version="2.0.0",org.ap
+ ache.tuscany.sca.definitions.xml;version="2.0.0";org.apache.tuscany.s
+ ca.policy.xml;version="2.0.0"
Tool: Bnd-0.0.255
Bundle-Name: Apache Tuscany SCA XML Assembly Model
Created-By: 1.6.0_07 (Sun Microsystems Inc.)
@@ -37,10 +39,14 @@ Import-Package: javax.xml.namespace,
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.definitions.util;version="2.0.0",
+ org.apache.tuscany.sca.definitions.xml;version="2.0.0",
+ org.apache.tuscany.sca.extensibility;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.impl;version="2.0.0",
org.apache.tuscany.sca.policy.util;version="2.0.0",
org.w3c.dom,
org.xml.sax;resolution:=optional
diff --git a/java/sca/modules/assembly-xml/pom.xml b/java/sca/modules/assembly-xml/pom.xml
index bb0f6cc5ed..25bb479962 100644
--- a/java/sca/modules/assembly-xml/pom.xml
+++ b/java/sca/modules/assembly-xml/pom.xml
@@ -71,20 +71,6 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-definitions-xml</artifactId>
- <version>2.0-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-policy-xml</artifactId>
- <version>2.0-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-assembly-xsd</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>runtime</scope>
diff --git a/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java
index 01bf8ceb2c..01bf8ceb2c 100644
--- a/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java
diff --git a/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java
index 3691212960..3691212960 100644
--- a/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java
diff --git a/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsExtensionPoint.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsExtensionPoint.java
index 3058b1f5b6..3058b1f5b6 100644
--- a/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsExtensionPoint.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsExtensionPoint.java
diff --git a/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java
index 7b80a750d2..7b80a750d2 100644
--- a/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java
new file mode 100644
index 0000000000..38c7b57f12
--- /dev/null
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+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.monitor.Monitor;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+/**
+ * Processor for handling XML models of BindingType meta data definitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class BindingTypeProcessor extends ExtensionTypeProcessor {
+
+ public BindingTypeProcessor(PolicyFactory policyFactory,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ Monitor monitor) {
+ super(policyFactory, extensionProcessor, monitor);
+ }
+
+ public BindingTypeProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ Monitor monitor) {
+ super(modelFactories.getFactory(PolicyFactory.class), extensionProcessor, monitor);
+ }
+
+ public QName getArtifactType() {
+ return BINDING_TYPE_QNAME;
+ }
+
+ @Override
+ protected ExtensionType resolveExtensionType(ExtensionType extnType, ModelResolver resolver)
+ throws ContributionResolveException {
+ if (extnType instanceof BindingType) {
+ BindingType bindingType = (BindingType)extnType;
+ return resolver.resolveModel(BindingType.class, bindingType);
+ } else {
+ return extnType;
+ }
+
+ }
+}
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java
new file mode 100644
index 0000000000..f437b5d599
--- /dev/null
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java
@@ -0,0 +1,251 @@
+/*
+ * 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.policy.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.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.resolver.ModelResolver;
+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.BindingType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+/**
+ * Processor for handling XML models of ExtensionType meta data definitions
+ *
+ * @version $Rev$ $Date$
+ */
+abstract class ExtensionTypeProcessor extends BaseStAXArtifactProcessor implements
+ StAXArtifactProcessor<ExtensionType>, PolicyConstants {
+
+ private PolicyFactory policyFactory;
+ private Monitor monitor;
+
+ protected abstract ExtensionType resolveExtensionType(ExtensionType extnType, ModelResolver resolver)
+ throws ContributionResolveException;
+
+ public ExtensionTypeProcessor(PolicyFactory policyFactory,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ Monitor monitor) {
+ this.policyFactory = policyFactory;
+ this.monitor = monitor;
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "policy-xml-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ public ExtensionType read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+ QName extType = getArtifactType();
+ QName type = getQName(reader, "type");
+
+ if (type != null) {
+ ExtensionType extensionType = null;
+ if (BINDING_TYPE_QNAME.equals(extType)) {
+ extensionType = policyFactory.createBindingType();
+ } else if (IMPLEMENTATION_TYPE_QNAME.equals(extType)) {
+ extensionType = policyFactory.createImplementationType();
+ } else {
+ error("UnrecognizedExtensionType", reader, type);
+ return null;
+ //throw new ContributionReadException("Unrecognized ExtensionType - " + type);
+ }
+ extensionType.setType(type);
+ extensionType.setUnresolved(true);
+
+ readAlwaysProvidedIntents(extensionType, reader);
+ readMayProvideIntents(extensionType, reader);
+ return extensionType;
+
+ } else {
+ error("RequiredAttributeMissing", reader, extType);
+ //throw new ContributionReadException("Required attribute '" + TYPE +
+ //"' missing from BindingType Definition");
+ }
+ return null;
+ }
+
+ private void readAlwaysProvidedIntents(ExtensionType extnType, XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, ALWAYS_PROVIDES);
+ if (value != null) {
+ List<Intent> alwaysProvided = extnType.getAlwaysProvidedIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent intent = policyFactory.createIntent();
+ intent.setName(qname);
+ alwaysProvided.add(intent);
+ }
+ }
+ }
+
+ private void readMayProvideIntents(ExtensionType extnType, XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, MAY_PROVIDE);
+ if (value != null) {
+ List<Intent> mayProvide = extnType.getMayProvidedIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent intent = policyFactory.createIntent();
+ intent.setName(qname);
+ mayProvide.add(intent);
+ }
+ }
+ }
+
+ public void write(ExtensionType extnType, XMLStreamWriter writer) throws ContributionWriteException,
+ XMLStreamException {
+
+ // Write an <sca:bindingType or sca:implementationType>
+ if (extnType instanceof BindingType) {
+ writer.writeStartElement(SCA11_NS, BINDING_TYPE);
+ } else if (extnType instanceof ImplementationType) {
+ writer.writeStartElement(SCA11_NS, IMPLEMENTATION_TYPE);
+ }
+
+ writeAlwaysProvidesIntentsAttribute(extnType, writer);
+ writeMayProvideIntentsAttribute(extnType, writer);
+
+ writer.writeEndElement();
+ }
+
+ private void writeMayProvideIntentsAttribute(ExtensionType extnType, XMLStreamWriter writer)
+ throws XMLStreamException {
+ StringBuffer sb = new StringBuffer();
+ for (Intent intent : extnType.getMayProvidedIntents()) {
+ writer.writeNamespace(intent.getName().getPrefix(), intent.getName().getNamespaceURI());
+ sb.append(intent.getName().getPrefix() + COLON + intent.getName().getLocalPart());
+ sb.append(WHITE_SPACE);
+ }
+
+ if (sb.length() > 0) {
+ writer.writeAttribute(MAY_PROVIDE, sb.toString());
+ }
+ }
+
+ private void writeAlwaysProvidesIntentsAttribute(ExtensionType extnType, XMLStreamWriter writer)
+ throws XMLStreamException {
+ StringBuffer sb = new StringBuffer();
+ for (Intent intent : extnType.getAlwaysProvidedIntents()) {
+ writer.writeNamespace(intent.getName().getPrefix(), intent.getName().getNamespaceURI());
+ sb.append(intent.getName().getPrefix() + COLON + intent.getName().getLocalPart());
+ sb.append(WHITE_SPACE);
+ }
+
+ if (sb.length() > 0) {
+ writer.writeAttribute(ALWAYS_PROVIDES, sb.toString());
+
+ }
+ }
+
+ public void resolve(ExtensionType extnType, ModelResolver resolver) throws ContributionResolveException {
+
+ if (extnType != null && extnType.isUnresolved()) {
+ resolveAlwaysProvidedIntents(extnType, resolver);
+ resolveMayProvideIntents(extnType, resolver);
+ extnType.setUnresolved(false);
+ //resolveExtensionType(extnType, resolver);
+ }
+ }
+
+ private void resolveAlwaysProvidedIntents(ExtensionType extensionType, ModelResolver resolver)
+ throws ContributionResolveException {
+ if (extensionType != null) {
+ // resolve all provided intents
+ List<Intent> alwaysProvided = new ArrayList<Intent>();
+ for (Intent providedIntent : extensionType.getAlwaysProvidedIntents()) {
+ if (providedIntent.isUnresolved()) {
+ providedIntent = resolver.resolveModel(Intent.class, providedIntent);
+ if (!providedIntent.isUnresolved()) {
+ alwaysProvided.add(providedIntent);
+ } else {
+ error("AlwaysProvidedIntentNotFound", resolver, providedIntent, extensionType);
+ //throw new ContributionResolveException("Always Provided Intent - " + providedIntent
+ //+ " not found for ExtensionType "
+ //+ extensionType);
+ }
+ } else {
+ alwaysProvided.add(providedIntent);
+ }
+ }
+ extensionType.getAlwaysProvidedIntents().clear();
+ extensionType.getAlwaysProvidedIntents().addAll(alwaysProvided);
+ }
+ }
+
+ private void resolveMayProvideIntents(ExtensionType extensionType, ModelResolver resolver)
+ throws ContributionResolveException {
+ if (extensionType != null) {
+ // resolve all provided intents
+ List<Intent> mayProvide = new ArrayList<Intent>();
+ for (Intent providedIntent : extensionType.getMayProvidedIntents()) {
+ if (providedIntent.isUnresolved()) {
+ providedIntent = resolver.resolveModel(Intent.class, providedIntent);
+ if (!providedIntent.isUnresolved()) {
+ mayProvide.add(providedIntent);
+ } else {
+ error("MayProvideIntentNotFound", resolver, providedIntent, extensionType);
+ //throw new ContributionResolveException("May Provide Intent - " + providedIntent
+ //+ " not found for ExtensionType "
+ //+ extensionType);
+ }
+ } else {
+ mayProvide.add(providedIntent);
+ }
+ }
+ extensionType.getMayProvidedIntents().clear();
+ extensionType.getMayProvidedIntents().addAll(mayProvide);
+ }
+ }
+
+ public Class<ExtensionType> getModelType() {
+ return ExtensionType.class;
+ }
+}
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java
new file mode 100644
index 0000000000..41e2af3809
--- /dev/null
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+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.monitor.Monitor;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+/**
+ * Processor for handling XML models of ImplementationType meta data definitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class ImplementationTypeProcessor extends ExtensionTypeProcessor {
+
+ public ImplementationTypeProcessor(PolicyFactory policyFactory,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ Monitor monitor) {
+ super(policyFactory, extensionProcessor, monitor);
+ }
+
+ public ImplementationTypeProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ Monitor monitor) {
+ super(modelFactories.getFactory(PolicyFactory.class), extensionProcessor, monitor);
+ }
+
+ public QName getArtifactType() {
+ return IMPLEMENTATION_TYPE_QNAME;
+ }
+
+ @Override
+ protected ExtensionType resolveExtensionType(ExtensionType extnType, ModelResolver resolver)
+ throws ContributionResolveException {
+ if (extnType instanceof ImplementationType) {
+ ImplementationType implType = (ImplementationType)extnType;
+ return resolver.resolveModel(ImplementationType.class, implType);
+ } else {
+ return extnType;
+ }
+
+ }
+}
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentProcessor.java
new file mode 100644
index 0000000000..a6f5bb58ea
--- /dev/null
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentProcessor.java
@@ -0,0 +1,391 @@
+/*
+ * 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.policy.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+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.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.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+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.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.Intent.Type;
+
+/**
+ * Processor for handling XML models of PolicyIntent definitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class IntentProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<Intent>,
+ PolicyConstants {
+
+ private PolicyFactory policyFactory;
+ private Monitor monitor;
+
+ public IntentProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) {
+ this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.monitor = monitor;
+ }
+
+ public IntentProcessor(PolicyFactory policyFactory, Monitor monitor) {
+ this.policyFactory = policyFactory;
+ this.monitor = monitor;
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "policy-xml-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ private void warn(String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "policy-xml-validation-messages",
+ Severity.WARNING,
+ model,
+ message,
+ messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ public Intent read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+ Intent intent = null;
+ String intentLocalName = reader.getAttributeValue(null, NAME);
+ if (intentLocalName == null) {
+ error("IntentNameMissing", reader);
+ return null;
+ }
+
+ String intentType = reader.getAttributeValue(null, INTENT_TYPE);
+ if (intentType == null) {
+ intentType = Intent.Type.interaction.name();
+ }
+
+ intent = policyFactory.createIntent();
+
+ // [rfeng] the target namespace is not available, set the local part for now
+ // This will be changed in the definitions processor
+ intent.setName(new QName(intentLocalName));
+ intent.setType(Type.valueOf(intentType));
+
+ readRequiredIntents(intent, reader);
+ readExcludedIntents(intent, reader);
+
+ readConstrainedTypes(intent, reader);
+
+ Intent current = intent;
+ int event = reader.getEventType();
+ QName name = null;
+ while (reader.hasNext()) {
+ event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT: {
+ name = reader.getName();
+ if (DESCRIPTION_QNAME.equals(name)) {
+ String text = reader.getElementText();
+ if (text != null) {
+ text = text.trim();
+ }
+ current.setDescription(text);
+ } else if (INTENT_QUALIFIER_QNAME.equals(name)) {
+ String qualifierName = reader.getAttributeValue(null, NAME);
+ String defaultQ = reader.getAttributeValue(null, DEFAULT);
+ boolean isDefault = defaultQ == null ? false : Boolean.parseBoolean(defaultQ);
+ String qualifiedIntentName = intentLocalName + QUALIFIER + qualifierName;
+ Intent qualified = policyFactory.createIntent();
+ qualified.setType(intent.getType());
+ qualified.setName(new QName(qualifiedIntentName));
+ if (isDefault) {
+ intent.setDefaultQualifiedIntent(qualified);
+ }
+ intent.getQualifiedIntents().add(qualified);
+ qualified.setQualifiableIntent(intent);
+ current = qualified;
+ }
+ break;
+ }
+ case END_ELEMENT: {
+ name = reader.getName();
+ if (INTENT_QUALIFIER_QNAME.equals(name)) {
+ current = intent;
+ }
+ break;
+ }
+ }
+ if (event == END_ELEMENT && POLICY_INTENT_QNAME.equals(reader.getName())) {
+ break;
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ // REVIEW: [rfeng] What's going to happen if there is only one qualified intent
+ if (intent.getQualifiedIntents().size() == 1) {
+ intent.setDefaultQualifiedIntent(intent.getQualifiedIntents().get(0));
+ }
+ return intent;
+ }
+
+ public void write(Intent intent, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+ // Write an <sca:intent>
+ writer.writeStartElement(PolicyConstants.SCA11_NS, INTENT);
+ writer.writeNamespace(intent.getName().getPrefix(), intent.getName().getNamespaceURI());
+ writer.writeAttribute(PolicyConstants.NAME, intent.getName().getPrefix() + COLON
+ + intent.getName().getLocalPart());
+ if (intent.getRequiredIntents() != null && intent.getRequiredIntents().size() > 0) {
+ StringBuffer sb = new StringBuffer();
+ for (Intent requiredIntents : intent.getRequiredIntents()) {
+ sb.append(requiredIntents.getName());
+ sb.append(" ");
+ }
+ writer.writeAttribute(PolicyConstants.REQUIRES, sb.toString());
+ }
+
+ if (intent.getExcludedIntents() != null && intent.getExcludedIntents().size() > 0) {
+ StringBuffer sb = new StringBuffer();
+ for (Intent excludedIntents : intent.getExcludedIntents()) {
+ sb.append(excludedIntents.getName());
+ sb.append(" ");
+ }
+ writer.writeAttribute(PolicyConstants.EXCLUDES, sb.toString());
+ }
+
+ if (intent.getConstrainedTypes() != null && intent.getConstrainedTypes().size() > 0) {
+ StringBuffer sb = new StringBuffer();
+ for (ExtensionType contrainedArtifact : intent.getConstrainedTypes()) {
+ sb.append(contrainedArtifact.getType().getPrefix());
+ sb.append(':').append(contrainedArtifact.getType().getLocalPart());
+ sb.append(" ");
+ }
+ writer.writeAttribute(CONSTRAINS, sb.toString());
+ }
+
+ if (intent.getDescription() != null && intent.getDescription().length() > 0) {
+ writer.writeStartElement(PolicyConstants.SCA11_NS, DESCRIPTION);
+ writer.writeCData(intent.getDescription());
+ writer.writeEndElement();
+ }
+
+ writer.writeEndElement();
+ }
+
+ private void resolveContrainedTypes(Intent intent, ModelResolver resolver) throws ContributionResolveException {
+ Collection<ExtensionType> resolvedTypes = new HashSet<ExtensionType>();
+ for (ExtensionType extensionType : intent.getConstrainedTypes()) {
+ if (ExtensionType.BINDING_BASE.equals(extensionType.getType()) || ExtensionType.IMPLEMENTATION_BASE
+ .equals(extensionType.getType())) {
+ // HACK: Mark sca:binding and sca:implementation as resolved
+ extensionType.setUnresolved(false);
+ resolvedTypes.add(extensionType);
+ } else {
+ ExtensionType resolved = resolver.resolveModel(ExtensionType.class, extensionType);
+ if (!resolved.isUnresolved() || resolved != extensionType) {
+ resolvedTypes.add(resolved);
+ } else {
+ warn("ConstrainedTypeNotFound", intent, extensionType, intent);
+ }
+ }
+ }
+ intent.getConstrainedTypes().clear();
+ intent.getConstrainedTypes().addAll(resolvedTypes);
+ }
+
+ private void resolveProfileIntent(Intent intent, ModelResolver resolver) throws ContributionResolveException {
+ // FIXME: Need to check for cyclic references first i.e an A requiring B
+ // and then B requiring A...
+ if (intent != null && !intent.getRequiredIntents().isEmpty()) {
+ // resolve all required intents
+ List<Intent> requiredIntents = new ArrayList<Intent>();
+ for (Intent required : intent.getRequiredIntents()) {
+ if (required.isUnresolved()) {
+ Intent resolved = resolver.resolveModel(Intent.class, required);
+ // At this point, when the required intent is not resolved, it does not mean
+ // its undeclared, chances are that their dependency are not resolved yet.
+ // Lets try to resolve them first.
+ if (resolved.isUnresolved()) {
+ if (((resolved).getRequiredIntents()).contains(intent)) {
+ error("CyclicReferenceFound", resolver, required, intent);
+ return;
+ }
+ }
+
+ if (!resolved.isUnresolved() || resolved != required) {
+ requiredIntents.add(resolved);
+ } else {
+ error("RequiredIntentNotFound", resolver, required, intent);
+ return;
+ //throw new ContributionResolveException("Required Intent - " + requiredIntent
+ //+ " not found for Intent " + policyIntent);
+ }
+ } else {
+ requiredIntents.add(required);
+ }
+ }
+ intent.getRequiredIntents().clear();
+ intent.getRequiredIntents().addAll(requiredIntents);
+ }
+ }
+
+ private void resolveQualifiedIntent(Intent qualifed, ModelResolver resolver) throws ContributionResolveException {
+ if (qualifed != null) {
+ //resolve the qualifiable intent
+ Intent parent = qualifed.getQualifiableIntent();
+ if (parent == null) {
+ return;
+ }
+ if (parent.isUnresolved()) {
+ Intent resolved = resolver.resolveModel(Intent.class, parent);
+ // At this point, when the qualifiable intent is not resolved, it does not mean
+ // its undeclared, chances are that their dependency are not resolved yet.
+ // Lets try to resolve them first.
+
+ if (!resolved.isUnresolved() || resolved != qualifed) {
+ qualifed.setQualifiableIntent(resolved);
+ } else {
+ error("QualifiableIntentNotFound", resolver, parent, qualifed);
+ //throw new ContributionResolveException("Qualifiable Intent - " + qualifiableIntent
+ //+ " not found for Intent " + policyIntent);
+ }
+ }
+ }
+ }
+
+ public void resolve(Intent intent, ModelResolver resolver) throws ContributionResolveException {
+ resolveProfileIntent(intent, resolver);
+ resolveExcludedIntents(intent, resolver);
+ resolveQualifiedIntent(intent, resolver);
+ resolveContrainedTypes(intent, resolver);
+ intent.setUnresolved(false);
+ }
+
+ public QName getArtifactType() {
+ return POLICY_INTENT_QNAME;
+ }
+
+ private void readConstrainedTypes(Intent policyIntent, XMLStreamReader reader) throws ContributionReadException {
+ String value = reader.getAttributeValue(null, CONSTRAINS);
+ if (value != null) {
+ List<ExtensionType> constrainedTypes = policyIntent.getConstrainedTypes();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ ExtensionType extensionType = policyFactory.createExtensionType();
+ extensionType.setType(qname);
+ constrainedTypes.add(extensionType);
+ }
+ }
+ }
+
+ private void readRequiredIntents(Intent intent, XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, REQUIRES);
+ if (value != null) {
+ List<Intent> requiredIntents = intent.getRequiredIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent required = policyFactory.createIntent();
+ required.setName(qname);
+ required.setUnresolved(true);
+ requiredIntents.add(required);
+ }
+ }
+ }
+
+ private void readExcludedIntents(Intent intent, XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, EXCLUDES);
+ if (value != null) {
+ List<Intent> excludedIntents = intent.getExcludedIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent excluded = policyFactory.createIntent();
+ excluded.setName(qname);
+ excluded.setUnresolved(true);
+ excludedIntents.add(excluded);
+ }
+ }
+ }
+
+ private void resolveExcludedIntents(Intent policyIntent, ModelResolver resolver)
+ throws ContributionResolveException {
+ if (policyIntent != null) {
+ // resolve all excluded intents
+ List<Intent> excludedIntents = new ArrayList<Intent>();
+ for (Intent excludedIntent : policyIntent.getExcludedIntents()) {
+ if (excludedIntent.isUnresolved()) {
+ Intent resolvedExcludedIntent = resolver.resolveModel(Intent.class, excludedIntent);
+ if (!resolvedExcludedIntent.isUnresolved() || resolvedExcludedIntent != excludedIntent) {
+ excludedIntents.add(resolvedExcludedIntent);
+ } else {
+ error("ExcludedIntentNotFound", resolver, excludedIntent, policyIntent);
+ return;
+ //throw new ContributionResolveException("Excluded Intent " + excludedIntent
+ //+ " not found for intent " + policyIntent);
+ }
+ } else {
+ excludedIntents.add(excludedIntent);
+ }
+ }
+ policyIntent.getExcludedIntents().clear();
+ policyIntent.getExcludedIntents().addAll(excludedIntents);
+ }
+ }
+
+ public Class<Intent> getModelType() {
+ return Intent.class;
+ }
+
+}
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
new file mode 100644
index 0000000000..979dad3c8b
--- /dev/null
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
@@ -0,0 +1,74 @@
+/*
+ * 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.policy.xml;
+
+import javax.xml.namespace.QName;
+
+/**
+ * constants related to policy framework
+ *
+ * @version $Rev$ $Date$
+ */
+public interface PolicyConstants {
+ String WHITE_SPACE = " ";
+ String COLON = ":";
+ String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903";
+ String TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+ String INTENT = "intent";
+ String POLICY_SET = "policySet";
+ String POLICY_SET_REFERENCE = "policySetReference";
+ String INTENT_MAP = "intentMap";
+ String NAME = "name";
+ String TARGET_NAMESPACE = "targetNamespace";
+ String SCA_DEFINITIONS = "definitions";
+ String CONSTRAINS = "constrains";
+ String DESCRIPTION = "description";
+ String PROVIDES = "provides";
+ String APPLIES_TO = "appliesTo";
+ String ATTACH_TO = "attachTo";
+ String ALWAYS_APPLIES_TO = "alwaysAppliesTo";
+ String QUALIFIER = ".";
+ String INTENT_QUALIFIER = "qualifier";
+ String INTENT_MAP_QUALIFIER = "qualifier";
+ String REQUIRES = "requires";
+ String EXCLUDES = "excludes";
+ String DEFAULT = "default";
+
+ String ALWAYS_PROVIDES = "alwaysProvides";
+ String MAY_PROVIDE = "mayProvide";
+ String INTENT_TYPE = "intentType";
+ String IMPLEMENTATION_TYPE = "implementationType";
+ String BINDING_TYPE = "bindingType";
+ QName IMPLEMENTATION_TYPE_QNAME = new QName(SCA11_NS, IMPLEMENTATION_TYPE);
+ QName BINDING_TYPE_QNAME = new QName(SCA11_NS, BINDING_TYPE);
+ String BINDING = "binding";
+ String IMPLEMENTATION = "implementation";
+
+ QName POLICY_INTENT_QNAME = new QName(SCA11_NS, INTENT);
+ QName POLICY_SET_QNAME = new QName(SCA11_NS, POLICY_SET);
+ QName POLICY_INTENT_MAP_QNAME = new QName(SCA11_NS, INTENT_MAP);
+ QName SCA_DEFINITIONS_QNAME = new QName(SCA11_NS, SCA_DEFINITIONS);
+ QName DESCRIPTION_QNAME = new QName(SCA11_NS, DESCRIPTION);
+ QName POLICY_INTENT_MAP_QUALIFIER_QNAME = new QName(SCA11_NS, INTENT_MAP_QUALIFIER);
+ QName POLICY_SET_REFERENCE_QNAME = new QName(SCA11_NS, POLICY_SET_REFERENCE);
+ QName INTENT_QUALIFIER_QNAME = new QName(SCA11_NS, INTENT_QUALIFIER);
+
+ String QUALIFIED_INTENT_CONSTRAINS_ERROR = " - Qualified Intents must not specify 'constrains' attribute";
+
+}
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java
new file mode 100644
index 0000000000..a6ee5efde6
--- /dev/null
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java
@@ -0,0 +1,518 @@
+/*
+ * 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.policy.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+
+import org.apache.tuscany.sca.common.xml.xpath.XPathHelper;
+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.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+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.IntentMap;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.Qualifier;
+
+/**
+ * Processor for handling XML models of PolicySet definitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<PolicySet>,
+ PolicyConstants {
+
+ private PolicyFactory policyFactory;
+ private StAXArtifactProcessor<Object> extensionProcessor;
+ private XPathHelper xpathHelper;
+ // private XPathFactory xpathFactory;
+ private Monitor monitor;
+
+ public PolicySetProcessor(ExtensionPointRegistry registry,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ Monitor monitor) {
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.extensionProcessor = extensionProcessor;
+ this.monitor = monitor;
+ this.xpathHelper = XPathHelper.getInstance(registry);
+ // this.xpathFactory = modelFactories.getFactory(XPathFactory.class);
+ }
+
+ /*
+ public PolicySetProcessor(PolicyFactory policyFactory,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ Monitor monitor) {
+ this.policyFactory = policyFactory;
+ this.extensionProcessor = extensionProcessor;
+ this.monitor = monitor;
+ }
+ */
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "policy-xml-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ ex);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "policy-xml-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ public PolicySet read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+ PolicySet policySet = null;
+
+ String policySetName = reader.getAttributeValue(null, NAME);
+ String appliesTo = reader.getAttributeValue(null, APPLIES_TO);
+ if (policySetName == null || appliesTo == null) {
+ if (policySetName == null)
+ error("PolicySetNameMissing", reader);
+ if (appliesTo == null)
+ error("PolicySetAppliesToMissing", reader);
+ return policySet;
+ }
+
+ policySet = policyFactory.createPolicySet();
+ policySet.setName(new QName(policySetName));
+
+ //TODO: with 1.0 version of specs the applies to xpath is given related to the immediate
+ //parent whereas the runtime evaluates the xpath aginst the composite element. What the runtime
+ //is doing is what the future version of the specs could be tending towards. When that happens
+ //this 'if' must be deleted
+ if (appliesTo != null && !appliesTo.startsWith("/")) {
+ appliesTo = "//" + appliesTo;
+ }
+
+ policySet.setAppliesTo(appliesTo);
+
+ if (appliesTo != null) {
+ try {
+ XPath path = xpathHelper.newXPath();
+ NamespaceContext context = xpathHelper.getNamespaceContext(appliesTo, reader.getNamespaceContext());
+ // path.setXPathFunctionResolver(new PolicyXPathFunctionResolver(context));
+ XPathExpression expression = xpathHelper.compile(path, context, appliesTo);
+ policySet.setAppliesToXPathExpression(expression);
+ } catch (XPathExpressionException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error("ContributionReadException", policySet, ce);
+ //throw ce;
+ }
+ }
+
+ String attachTo = reader.getAttributeValue(null, ATTACH_TO);
+ if (attachTo != null) {
+ try {
+ XPath path = xpathHelper.newXPath();
+ NamespaceContext context = xpathHelper.getNamespaceContext(attachTo, reader.getNamespaceContext());
+ path.setXPathFunctionResolver(new PolicyXPathFunctionResolver(context));
+ XPathExpression expression = xpathHelper.compile(path, context, attachTo);
+ policySet.setAttachTo(attachTo);
+ policySet.setAttachToXPathExpression(expression);
+ } catch (XPathExpressionException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error("ContributionReadException", policySet, ce);
+ //throw ce;
+ }
+
+ }
+
+ readProvidedIntents(policySet, reader);
+
+ int event = reader.getEventType();
+ QName name = null;
+ reader.next();
+ while (reader.hasNext()) {
+ event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT: {
+ name = reader.getName();
+ if (POLICY_INTENT_MAP_QNAME.equals(name)) {
+ Intent mappedIntent = policyFactory.createIntent();
+ String provides = reader.getAttributeValue(null, PROVIDES);
+ if (provides != null) {
+ mappedIntent.setName(getQName(reader, PROVIDES));
+ if (policySet.getProvidedIntents().contains(mappedIntent)) {
+ readIntentMap(reader, policySet, mappedIntent);
+ } else {
+ error("IntentNotSpecified", policySet, policySetName);
+ //throw new ContributionReadException("Intent Map provides for Intent not specified as provided by parent PolicySet - " + policySetName);
+ }
+ } else {
+ error("IntentMapProvidesMissing", reader, policySetName);
+ }
+ } else if (POLICY_SET_REFERENCE_QNAME.equals(name)) {
+ PolicySet referredPolicySet = policyFactory.createPolicySet();
+ String referencename = reader.getAttributeValue(null, NAME);
+ if (referencename != null) {
+ referredPolicySet.setName(getQName(reader, NAME));
+ policySet.getReferencedPolicySets().add(referredPolicySet);
+ } else {
+ error("PolicySetReferenceNameMissing", reader, policySetName);
+ }
+ } /*else if ( WS_POLICY_QNAME.equals(name) ) {
+ OMElement policyElement = loadElement(reader);
+ org.apache.neethi.Policy wsPolicy = PolicyEngine.getPolicy(policyElement);
+ policySet.getPolicies().add(wsPolicy);
+ } */else {
+ Object extension = extensionProcessor.read(reader);
+ if (extension != null) {
+ PolicyExpression exp = policyFactory.createPolicyExpression();
+ exp.setName(name);
+ exp.setPolicy(extension);
+ policySet.getPolicies().add(exp);
+ }
+ }
+ break;
+ }
+ }
+ if (event == END_ELEMENT) {
+ if (POLICY_SET_QNAME.equals(reader.getName())) {
+ break;
+ }
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ return policySet;
+ }
+
+ public void readIntentMap(XMLStreamReader reader, PolicySet policySet, Intent mappedIntent)
+ throws ContributionReadException {
+ QName name = reader.getName();
+ if (POLICY_INTENT_MAP_QNAME.equals(name)) {
+
+ IntentMap intentMap = policyFactory.createIntentMap();
+ QName intentName = getQName(reader, INTENT_MAP);
+ intentMap.setProvidedIntent(mappedIntent);
+
+ policySet.getIntentMaps().add(intentMap);
+
+ String qualifierName = null;
+ String qualfiedIntentName = null;
+ Intent qualifiedIntent = null;
+
+ Qualifier qualifier = null;
+
+ int event = reader.getEventType();
+ try {
+ reader.next();
+ while (reader.hasNext()) {
+ event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT: {
+ name = reader.getName();
+ if (POLICY_INTENT_MAP_QUALIFIER_QNAME.equals(name)) {
+ qualifierName = getString(reader, NAME);
+ if (qualifierName != null) {
+ qualfiedIntentName =
+ mappedIntent.getName().getLocalPart() + QUALIFIER + qualifierName;
+ qualifiedIntent = policyFactory.createIntent();
+ qualifiedIntent.setName(new QName(mappedIntent.getName().getNamespaceURI(),
+ qualfiedIntentName));
+ qualifier = policyFactory.createQualifier();
+ qualifier.setIntent(qualifiedIntent);
+ intentMap.getQualifiers().add(qualifier);
+
+ } else {
+ error("QualifierNameMissing", reader, policySet.getName());
+ }
+ } else if (POLICY_INTENT_MAP_QNAME.equals(name)) {
+ QName providedIntent = getQName(reader, PROVIDES);
+ if (qualifierName.equals(providedIntent.getLocalPart())) {
+ readIntentMap(reader, policySet, qualifiedIntent);
+ } else {
+ error("IntentMapDoesNotMatch",
+ providedIntent,
+ providedIntent,
+ qualifierName,
+ policySet);
+ //throw new ContributionReadException("Intent provided by IntentMap " +
+ //providedIntent + " does not match parent qualifier " + qualifierName +
+ //" in policyset - " + policySet);
+ }
+ } else {
+ Object extension = extensionProcessor.read(reader);
+ if (extension != null && qualifier != null) {
+ PolicyExpression exp = policyFactory.createPolicyExpression();
+ exp.setName(name);
+ exp.setPolicy(extension);
+ qualifier.getPolicies().add(exp);
+ }
+ }
+ break;
+ }
+ }
+ if (event == END_ELEMENT && POLICY_INTENT_MAP_QNAME.equals(reader.getName())) {
+ break;
+ }
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ } catch (XMLStreamException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error("ContributionReadException", reader, ce);
+ throw ce;
+ }
+ }
+ }
+
+ public void write(PolicySet policySet, XMLStreamWriter writer) throws ContributionWriteException,
+ XMLStreamException {
+
+ // Write an <sca:policySet>
+ writer.writeStartElement(SCA11_NS, POLICY_SET);
+ writer.writeNamespace(policySet.getName().getPrefix(), policySet.getName().getNamespaceURI());
+ writer.writeAttribute(NAME, policySet.getName().getPrefix() + COLON + policySet.getName().getLocalPart());
+ writer.writeAttribute(APPLIES_TO, policySet.getAppliesTo());
+ writer.writeAttribute(ATTACH_TO, policySet.getAttachTo());
+
+ writeProvidedIntents(policySet, writer);
+
+ writer.writeEndElement();
+ }
+
+ private void readProvidedIntents(PolicySet policySet, XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, PROVIDES);
+ if (value != null) {
+ List<Intent> providedIntents = policySet.getProvidedIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent intent = policyFactory.createIntent();
+ intent.setName(qname);
+ providedIntents.add(intent);
+ }
+ }
+ }
+
+ private void writeProvidedIntents(PolicySet policySet, XMLStreamWriter writer) throws XMLStreamException {
+ if (!policySet.getProvidedIntents().isEmpty()) {
+ StringBuffer sb = new StringBuffer();
+ for (Intent providedIntents : policySet.getProvidedIntents()) {
+ sb.append(getQualifiedName(providedIntents.getName(), writer));
+ sb.append(" ");
+ }
+ // Remove the last space
+ sb.deleteCharAt(sb.length() - 1);
+ writer.writeAttribute(PolicyConstants.PROVIDES, sb.toString());
+ }
+ }
+
+ private String getQualifiedName(QName name, XMLStreamWriter writer) throws XMLStreamException {
+ String local = name.getLocalPart();
+ String prefix = writer.getPrefix(name.getNamespaceURI());
+ if (prefix != null && prefix.length() > 0) {
+ return prefix + ':' + local;
+ } else {
+ return local;
+ }
+ }
+
+ private void resolvePolicies(PolicySet policySet, ModelResolver resolver) throws ContributionResolveException {
+ boolean unresolved = false;
+ if (policySet != null) {
+ for (Object o : policySet.getPolicies()) {
+ extensionProcessor.resolve(o, resolver);
+ /*if ( o instanceof Policy && ((Policy)o).isUnresolved() ) {
+ unresolved = true;
+ }*/
+ }
+ policySet.setUnresolved(unresolved);
+ }
+ }
+
+ public QName getArtifactType() {
+ return POLICY_SET_QNAME;
+ }
+
+ public Class<PolicySet> getModelType() {
+ return PolicySet.class;
+ }
+
+ private void resolveProvidedIntents(PolicySet policySet, ModelResolver resolver)
+ throws ContributionResolveException {
+ if (policySet != null) {
+ //resolve all provided intents
+ List<Intent> providedIntents = new ArrayList<Intent>();
+ for (Intent providedIntent : policySet.getProvidedIntents()) {
+ if (providedIntent.isUnresolved()) {
+ Intent resolved = resolver.resolveModel(Intent.class, providedIntent);
+ if (!resolved.isUnresolved() || resolved != providedIntent) {
+ providedIntents.add(resolved);
+ } else {
+ error("ProvidedIntentNotFound", policySet, providedIntent, policySet);
+ return;
+ //throw new ContributionResolveException("Provided Intent - " + providedIntent
+ //+ " not found for PolicySet " + policySet);
+ }
+ } else {
+ providedIntents.add(providedIntent);
+ }
+ }
+ policySet.getProvidedIntents().clear();
+ policySet.getProvidedIntents().addAll(providedIntents);
+ }
+ }
+
+ private void resolveIntentsInMappedPolicies(PolicySet policySet, ModelResolver resolver)
+ throws ContributionResolveException {
+ for (IntentMap intentMap : policySet.getIntentMaps()) {
+ Intent intent = intentMap.getProvidedIntent();
+ if (intent.isUnresolved()) {
+ Intent resolved = resolver.resolveModel(Intent.class, intent);
+ if (!resolved.isUnresolved() || resolved != intent) {
+ intentMap.setProvidedIntent(resolved);
+ } else {
+ error("MappedIntentNotFound", policySet, intent, policySet);
+ return;
+ //throw new ContributionResolveException("Mapped Intent - " + mappedIntent
+ //+ " not found for PolicySet " + policySet);
+ }
+ }
+ for (Qualifier qualifier : intentMap.getQualifiers()) {
+ intent = qualifier.getIntent();
+ if (intent.isUnresolved()) {
+ Intent resolved = resolver.resolveModel(Intent.class, intent);
+ if (!resolved.isUnresolved() || resolved != intent) {
+ qualifier.setIntent(resolved);
+ } else {
+ error("MappedIntentNotFound", policySet, intent, policySet);
+ return;
+ //throw new ContributionResolveException("Mapped Intent - " + mappedIntent
+ //+ " not found for PolicySet " + policySet);
+ }
+ }
+ for (PolicyExpression exp : qualifier.getPolicies()) {
+ // FIXME: How to resolve the policies?
+ }
+ }
+ }
+
+ }
+
+ private void resolveReferredPolicySets(PolicySet policySet, ModelResolver resolver)
+ throws ContributionResolveException {
+
+ List<PolicySet> referredPolicySets = new ArrayList<PolicySet>();
+ for (PolicySet referredPolicySet : policySet.getReferencedPolicySets()) {
+ if (referredPolicySet.isUnresolved()) {
+ PolicySet resolved = resolver.resolveModel(PolicySet.class, referredPolicySet);
+ if (!resolved.isUnresolved() || resolved != referredPolicySet) {
+ referredPolicySets.add(resolved);
+ } else {
+ error("ReferredPolicySetNotFound", policySet, referredPolicySet, policySet);
+ return;
+ //throw new ContributionResolveException("Referred PolicySet - " + referredPolicySet
+ //+ "not found for PolicySet - " + policySet);
+ }
+ } else {
+ referredPolicySets.add(referredPolicySet);
+ }
+ }
+ policySet.getReferencedPolicySets().clear();
+ policySet.getReferencedPolicySets().addAll(referredPolicySets);
+ }
+
+ private void includeReferredPolicySets(PolicySet policySet, PolicySet referredPolicySet) {
+ for (PolicySet furtherReferredPolicySet : referredPolicySet.getReferencedPolicySets()) {
+ includeReferredPolicySets(referredPolicySet, furtherReferredPolicySet);
+ }
+ policySet.getPolicies().addAll(referredPolicySet.getPolicies());
+ policySet.getIntentMaps().addAll(referredPolicySet.getIntentMaps());
+ }
+
+ public void resolve(PolicySet policySet, ModelResolver resolver) throws ContributionResolveException {
+ resolveProvidedIntents(policySet, resolver);
+ resolveIntentsInMappedPolicies(policySet, resolver);
+ resolveReferredPolicySets(policySet, resolver);
+
+ for (PolicySet referredPolicySet : policySet.getReferencedPolicySets()) {
+ includeReferredPolicySets(policySet, referredPolicySet);
+ }
+
+ if (policySet.isUnresolved()) {
+ //resolve the policy attachments
+ resolvePolicies(policySet, resolver);
+
+ /*if ( !policySet.isUnresolved() ) {
+ resolver.addModel(policySet);
+ }*/
+ }
+
+ policySet.setUnresolved(false);
+ }
+}
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunction.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunction.java
new file mode 100644
index 0000000000..10f142c67b
--- /dev/null
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunction.java
@@ -0,0 +1,158 @@
+/*
+ * 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.policy.xml;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.xpath.XPathFunction;
+import javax.xml.xpath.XPathFunctionException;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * The SCA-defined XPath function
+ */
+public class PolicyXPathFunction implements XPathFunction {
+ private static Logger logger = Logger.getLogger(PolicyXPathFunction.class.getName());
+
+ static final QName InterfaceRef = new QName(PolicyConstants.SCA11_NS, "InterfaceRef");
+ static final QName OperationRef = new QName(PolicyConstants.SCA11_NS, "OperationRef");
+ static final QName MessageRef = new QName(PolicyConstants.SCA11_NS, "MessageRef");
+ static final QName IntentRefs = new QName(PolicyConstants.SCA11_NS, "IntentRefs");
+ static final QName URIRef = new QName(PolicyConstants.SCA11_NS, "URIRef");
+
+ static final Set<QName> functions =
+ new HashSet<QName>(Arrays.asList(InterfaceRef, OperationRef, MessageRef, IntentRefs, URIRef));
+
+ private NamespaceContext namespaceContext;
+ private final QName functionName;
+
+ public PolicyXPathFunction(NamespaceContext namespaceContext, QName functionName) {
+ super();
+ this.namespaceContext = namespaceContext;
+ this.functionName = functionName;
+ }
+
+ private Node getContextNode(List args) {
+ if (args.size() >= 2) {
+ NodeList nodeList = (NodeList)args.get(1);
+ if (nodeList.getLength() > 0) {
+ return nodeList.item(0);
+ }
+ }
+ return null;
+ }
+
+ public Object evaluate(List args) throws XPathFunctionException {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine(functionName + "(" + args + ")");
+ }
+
+ String arg = (String)args.get(0);
+ Node node = getContextNode(args);
+ if (InterfaceRef.equals(functionName)) {
+ return evaluateInterface(arg, node);
+ } else if (OperationRef.equals(functionName)) {
+ String[] params = arg.split("/");
+ if (params.length != 2) {
+ throw new IllegalArgumentException("Invalid argument: " + arg);
+ }
+ String interfaceName = params[0];
+ String operationName = params[1];
+ return evaluateOperation(interfaceName, operationName, node);
+ } else if (MessageRef.equals(functionName)) {
+ String[] params = arg.split("/");
+ if (params.length != 3) {
+ throw new IllegalArgumentException("Invalid argument: " + arg);
+ }
+ String interfaceName = params[0];
+ String operationName = params[1];
+ String messageName = params[2];
+ return evaluateMessage(interfaceName, operationName, messageName, node);
+ } else if (URIRef.equals(functionName)) {
+ return evaluateURI(arg, node);
+ } else if (IntentRefs.equals(functionName)) {
+ String[] intents = arg.split("(\\s)+");
+ return evaluateIntents(intents, node);
+ } else {
+ return Boolean.FALSE;
+ }
+ }
+
+ private Boolean evaluateInterface(String interfaceName, Node node) {
+ return Boolean.FALSE;
+ }
+
+ private Boolean evaluateOperation(String interfaceName, String operationName, Node node) {
+ return Boolean.FALSE;
+ }
+
+ private Boolean evaluateMessage(String interfaceName, String operationName, String messageName, Node node) {
+ return Boolean.FALSE;
+ }
+
+ private Boolean evaluateURI(String uri, Node node) {
+ return Boolean.FALSE;
+ }
+
+ private Boolean evaluateIntents(String[] intents, Node node) {
+ return Boolean.FALSE;
+ }
+
+ private static Pattern FUNCTION;
+ static {
+ String functionPattern = "(URIRef|InterfaceRef|OperationRef|MessageRef|IntentRefs)\\s*\\((.*)\\)";
+ FUNCTION = Pattern.compile(functionPattern);
+ }
+
+ public static String normalize(String attachTo) {
+ Matcher matcher = FUNCTION.matcher(attachTo);
+ boolean result = matcher.find();
+ if (result) {
+ StringBuffer sb = new StringBuffer();
+ do {
+ String function = matcher.group(1);
+ String args = matcher.group(2);
+ String replacement = null;
+ if (args.trim().length() > 0) {
+ replacement = function + "(" + args + "," + "self::node())";
+ } else {
+ replacement = function + "(self::node())";
+ }
+ matcher.appendReplacement(sb, replacement);
+ result = matcher.find();
+ } while (result);
+ matcher.appendTail(sb);
+ return sb.toString();
+ }
+ return attachTo;
+ }
+
+}
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolver.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolver.java
new file mode 100644
index 0000000000..ca44667903
--- /dev/null
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolver.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.xml;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.xpath.XPathFunction;
+import javax.xml.xpath.XPathFunctionResolver;
+
+/**
+ * A resolver that handles SCA-defined XPath functions
+ *
+ * Interface Related Functions
+ * <ul>
+ * <li>InterfaceRef( InterfaceName )
+ * <li>OperationRef( InterfaceName/OperationName )
+ * <li>MessageRef( InterfaceName/OperationName/MessageName )
+ * </ul>
+ *
+ * Intent Related Functions
+ * <ul>
+ * <li>IntentRefs( IntentList )
+ * </ul>
+ *
+ * URI Based Function
+ * <ul>
+ * <li>URIRef( URI )
+ * </ul>
+ */
+public class PolicyXPathFunctionResolver implements XPathFunctionResolver {
+ private NamespaceContext namespaceContext;
+
+ public PolicyXPathFunctionResolver(NamespaceContext namespaceContext) {
+ super();
+ this.namespaceContext = namespaceContext;
+ }
+
+ public XPathFunction resolveFunction(QName functionName, int arity) {
+ if (functionName == null) {
+ throw new NullPointerException("Function name is null");
+ }
+ if (PolicyXPathFunction.functions.contains(functionName)) {
+ if (arity >= 1) {
+ // We are relaxing the arity here so that we can pass in the context node
+ // by modifying the original xpath so that sca functions take self::node()
+ // as the 2nd argument
+ return new PolicyXPathFunction(namespaceContext, functionName);
+ } else {
+ throw new IllegalArgumentException("Invalid number of arguments: " + arity);
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/java/sca/modules/definitions-xml/src/main/resources/META-INF/sca-policy-1.1-intents-definitions-cd02.xml b/java/sca/modules/assembly-xml/src/main/resources/META-INF/sca-policy-1.1-intents-definitions-cd02.xml
index c3b1115cbd..c3b1115cbd 100644
--- a/java/sca/modules/definitions-xml/src/main/resources/META-INF/sca-policy-1.1-intents-definitions-cd02.xml
+++ b/java/sca/modules/assembly-xml/src/main/resources/META-INF/sca-policy-1.1-intents-definitions-cd02.xml
diff --git a/java/sca/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/java/sca/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
index ee6538124e..34226922a3 100644
--- a/java/sca/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
+++ b/java/sca/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -22,3 +22,8 @@ org.apache.tuscany.sca.assembly.xml.CompositeProcessor;qname=http://docs.oasis-o
org.apache.tuscany.sca.assembly.xml.SCABindingProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#binding.sca,model=org.apache.tuscany.sca.assembly.SCABinding
org.apache.tuscany.sca.assembly.xml.EndpointProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#binding.rmi#endpoint,model=org.apache.tuscany.sca.assembly.Endpoint
org.apache.tuscany.sca.assembly.xml.EndpointReferenceProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#binding.rmi#endpointReference,model=org.apache.tuscany.sca.assembly.EndpointReference
+org.apache.tuscany.sca.definitions.xml.DefinitionsProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#definitions,model=org.apache.tuscany.sca.definitions.Definitions
+org.apache.tuscany.sca.policy.xml.BindingTypeProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#bindingType,model=org.apache.tuscany.sca.policy.BindingType
+org.apache.tuscany.sca.policy.xml.ImplementationTypeProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#implementationType,model=org.apache.tuscany.sca.policy.ImplementationType
+org.apache.tuscany.sca.policy.xml.IntentProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#intent,model=org.apache.tuscany.sca.policy.Intent
+org.apache.tuscany.sca.policy.xml.PolicySetProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#policySet,model=org.apache.tuscany.sca.policy.PolicySet
diff --git a/java/sca/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/java/sca/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
index 403c049b48..7aea528fd6 100644
--- a/java/sca/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
+++ b/java/sca/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
@@ -19,3 +19,4 @@
org.apache.tuscany.sca.assembly.xml.ComponentTypeDocumentProcessor;type=.componentType,model=org.apache.tuscany.sca.assembly.ComponentType
org.apache.tuscany.sca.assembly.xml.ConstrainingTypeDocumentProcessor;type=.constrainingType,model=org.apache.tuscany.sca.assembly.ConstrainingType
org.apache.tuscany.sca.assembly.xml.CompositeDocumentProcessor;type=.composite,model=org.apache.tuscany.sca.assembly.Composite
+org.apache.tuscany.sca.definitions.xml.DefinitionsDocumentProcessor;type=/META-INF/definitions.xml,model=org.apache.tuscany.sca.definitions.Definitions
diff --git a/java/sca/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/java/sca/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
index ecc34942f1..9be95191d4 100644
--- a/java/sca/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
+++ b/java/sca/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
@@ -18,3 +18,4 @@
org.apache.tuscany.sca.assembly.xml.CompositeModelResolver;model=org.apache.tuscany.sca.assembly.Composite
org.apache.tuscany.sca.assembly.xml.ConstrainingTypeModelResolver;model=org.apache.tuscany.sca.assembly.ConstrainingType
org.apache.tuscany.sca.assembly.xml.ComponentTypeModelResolver;model=org.apache.tuscany.sca.assembly.ComponentType
+org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;model=org.apache.tuscany.sca.policy.Intent
diff --git a/java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/java/sca/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
index 895b5ebdd5..895b5ebdd5 100644
--- a/java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
+++ b/java/sca/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
diff --git a/java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.DefinitionsExtensionPoint b/java/sca/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.DefinitionsExtensionPoint
index 22c2a0549c..22c2a0549c 100644
--- a/java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.DefinitionsExtensionPoint
+++ b/java/sca/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.DefinitionsExtensionPoint
diff --git a/java/sca/modules/definitions-xml/src/main/resources/definitions-xml-validation-messages.properties b/java/sca/modules/assembly-xml/src/main/resources/definitions-xml-validation-messages.properties
index 857887ec3f..857887ec3f 100644
--- a/java/sca/modules/definitions-xml/src/main/resources/definitions-xml-validation-messages.properties
+++ b/java/sca/modules/assembly-xml/src/main/resources/definitions-xml-validation-messages.properties
diff --git a/java/sca/modules/assembly-xml/src/main/resources/policy-xml-validation-messages.properties b/java/sca/modules/assembly-xml/src/main/resources/policy-xml-validation-messages.properties
new file mode 100644
index 0000000000..d092b5959a
--- /dev/null
+++ b/java/sca/modules/assembly-xml/src/main/resources/policy-xml-validation-messages.properties
@@ -0,0 +1,45 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+ReferredPolicySetNotFound = Referred PolicySet - {0} not found for PolicySet - {1}
+MappedIntentNotFound = Mapped Intent - {0} not found for PolicySet {1}
+ProvidedIntentNotFound = Provided Intent - {0} not found for PolicySet {1}
+UnableToMapPolicies = Unable to map policies for default qualifier in IntentMap for - {0} in policy set - {1}
+IntentMapDoesNotMatch = Intent provided by IntentMap {0} does not match parent qualifier {1} in policyset - {2}
+IntentNotSpecified = Intent Map provides for Intent not specified as provided by parent PolicySet - {0}
+ContrainsAttributeMissing = Constrains attribute missing from Policy Intent Definition {0}
+RequiredIntentNotFound = Required Intent - {0} not found for ProfileIntent {1}
+QualifiableIntentNotFound = Qualifiable Intent - {0} not found for QualifiedIntent {1}
+ErrorInPolicyIntentDefinition = Error in PolicyIntent Definition - {0} {1}
+ExcludedIntentNotFound = Excluded Intent {0} not found for intent {1}
+UnrecognizedIntentAttachPointType = Unrecognized IntentAttachPointType - {0}
+RequiredAttributeMissing = Required attribute {0} missing from extension type definition
+AlwaysProvidedIntentNotFound = Always Provided Intent - {0} not found for ExtensionType {1}
+MayProvideIntentNotFound = May Provide Intent - {0} not found for ExtensionType {1}
+ContributionReadException = ContributionReadException occurred due to: {0}
+CyclicReferenceFound = Cyclic reference detected in required attributes of ProfileIntents {0} and {1}
+IntentNameMissing = Required attribute "name" missing for Intent Definition
+PolicySetReferenceNameMissing = Required attribute "name" missing for PolicySetReference in PolicySet : {0}
+PolicySetNameMissing = Required attribute "name" missing for PolicySet Definition
+PolicySetAppliesToMissing = Required attribute "appliesTo" missing for PolicySet Definition
+IntentMapProvidesMissing = Required attribute "provides" missing for IntentMap in PolicySet : {0}
+QualifierNameMissing = Required attribute "name" missing for qualifier definition in PolicySet : {0}
+ConstrainedTypeNotFound = Unable to find the extension type {0} constrained by intent: {1}
+
diff --git a/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/MockPolicy.java b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/MockPolicy.java
index 58e6e534b9..58e6e534b9 100644
--- a/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/MockPolicy.java
+++ b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/MockPolicy.java
diff --git a/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/ReadDocumentTestCase.java b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/ReadDocumentTestCase.java
index 7b9400b300..7b9400b300 100644
--- a/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/ReadDocumentTestCase.java
+++ b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/ReadDocumentTestCase.java
diff --git a/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/TestPolicyProcessor.java b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/TestPolicyProcessor.java
index 89ec2d0ee9..89ec2d0ee9 100644
--- a/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/TestPolicyProcessor.java
+++ b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/TestPolicyProcessor.java
diff --git a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java
new file mode 100644
index 0000000000..f0bd5d8bde
--- /dev/null
+++ b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.xml;
+
+import static org.apache.tuscany.sca.policy.xml.PolicyXPathFunction.normalize;
+
+import java.util.Collections;
+import java.util.Iterator;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathFactory;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+/**
+ *
+ */
+public class PolicyXPathFunctionResolverTestCase {
+ private static XPath xpath;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ XPathFactory factory = XPathFactory.newInstance();
+ xpath = factory.newXPath();
+ xpath.setNamespaceContext(new NamespaceContextImpl());
+ xpath.setXPathFunctionResolver(new PolicyXPathFunctionResolver(xpath.getNamespaceContext()));
+ }
+
+ @Test
+ public void testIntentsRef() throws Exception {
+ InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
+ String str = "//sca:composite/sca:component[sca:IntentRefs('sca:confidentiality')]";
+ str = normalize(str);
+ // Test the rewrite of xpath so that the self:node() is passed into the SCA function
+ XPathExpression exp = xpath.compile(str);
+ Object result = exp.evaluate(xml, XPathConstants.NODESET);
+ Assert.assertTrue(result instanceof NodeList);
+ NodeList nodes = (NodeList)result;
+ // Assert.assertEquals(1, nodes.getLength());
+ }
+
+ @Test
+ public void testURIRef() throws Exception {
+ InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
+ XPathExpression exp = xpath.compile(normalize("sca:composite/sca:component[sca:URIRef('AddServiceComponent')]"));
+ Object result = exp.evaluate(xml, XPathConstants.NODESET);
+ Assert.assertTrue(result instanceof NodeList);
+ NodeList nodes = (NodeList)result;
+ // Assert.assertEquals(1, nodes.getLength());
+ }
+
+ @Test
+ public void testInterfaceRef() throws Exception {
+ InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
+ XPathExpression exp = xpath.compile(normalize("//sca:composite/sca:component/sca:service[sca:InterfaceRef('AddService')]"));
+ Object result = exp.evaluate(xml, XPathConstants.NODESET);
+ Assert.assertTrue(result instanceof NodeList);
+ NodeList nodes = (NodeList)result;
+ // Assert.assertEquals(1, nodes.getLength());
+ }
+
+ @Test
+ public void testOperationRef() throws Exception {
+ InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
+ XPathExpression exp = xpath.compile(normalize("//sca:composite/sca:component/sca:reference[sca:OperationRef('AddService/add')]"));
+ Object result = exp.evaluate(xml, XPathConstants.NODESET);
+ Assert.assertTrue(result instanceof NodeList);
+ NodeList nodes = (NodeList)result;
+ // Assert.assertEquals(1, nodes.getLength());
+ }
+
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+ private static class NamespaceContextImpl implements NamespaceContext {
+
+ private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903";
+
+ public String getNamespaceURI(String prefix) {
+ if ("sca".equals(prefix)) {
+ return SCA11_NS;
+ } else {
+ return null;
+ }
+ }
+
+ public String getPrefix(String namespaceURI) {
+ if (SCA11_NS.equals(namespaceURI)) {
+ return "sca";
+ }
+ return null;
+ }
+
+ public Iterator getPrefixes(String namespaceURI) {
+ if (SCA11_NS.equals(namespaceURI)) {
+ return Collections.singleton("sca").iterator();
+ }
+ return null;
+ }
+
+ }
+
+}
diff --git a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java
new file mode 100644
index 0000000000..fd11a944c7
--- /dev/null
+++ b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java
@@ -0,0 +1,295 @@
+/*
+ * 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.policy.xml;
+
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+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.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.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.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+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.BindingType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.Qualifier;
+import org.apache.tuscany.sca.policy.impl.ImplementationTypeImpl;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test reading SCA XML assembly documents.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadDocumentTestCase {
+
+ private ModelResolver resolver;
+ private StAXArtifactProcessor<Object> staxProcessor;
+ private Monitor monitor;
+
+ private static final QName elementToProcess =
+ new QName("http://docs.oasis-open.org/ns/opencsa/sca/200903", "implementationType");
+
+ private Map<QName, Intent> intentTable = new Hashtable<QName, Intent>();
+ private Map<QName, PolicySet> policySetTable = new Hashtable<QName, PolicySet>();
+ private Map<QName, BindingType> bindingTypesTable = new Hashtable<QName, BindingType>();
+ private Map<QName, ImplementationType> implTypesTable = new Hashtable<QName, ImplementationType>();
+ private static final String scaNamespace = "http://docs.oasis-open.org/ns/opencsa/sca/200903";
+ private static final String namespace = "http://test";
+
+ private static final QName confidentiality = new QName(namespace, "confidentiality");
+ private static final QName integrity = new QName(namespace, "integrity");
+ private static final QName messageProtection = new QName(namespace, "messageProtection");
+ private static final QName confidentiality_transport = new QName(namespace, "confidentiality.transport");
+ private static final QName confidentiality_message = new QName(namespace, "confidentiality.message");
+ private static final QName secureReliablePolicy = new QName(namespace, "SecureReliablePolicy");
+ private static final QName secureMessagingPolicies = new QName(namespace, "SecureMessagingPolicies");
+ private static final QName securityPolicy = new QName(namespace, "SecurityPolicy");
+ private static final QName basicAuthMsgProtSecurity = new QName(namespace, "BasicAuthMsgProtSecurity");
+ private static final QName wsBinding = new QName(scaNamespace, "binding.ws");
+ private static final QName javaImpl = new QName(scaNamespace, "implementation.java");
+
+ @Before
+ public void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ resolver = new DefaultModelResolver();
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ // Create a monitor
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ MonitorFactory monitorFactory = new DefaultMonitorFactory();
+ if (monitorFactory != null) {
+ monitor = monitorFactory.createMonitor();
+ utilities.addUtility(monitorFactory);
+ }
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, monitor);
+ staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
+
+ URL url = getClass().getResource("test_definitions.xml");
+ InputStream urlStream = url.openStream();
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(urlStream);
+ reader.next();
+
+ //position on the right element qname to get processed
+ while (reader.hasNext()) {
+ reader.next();
+ int event = reader.getEventType();
+ if (event == START_ELEMENT && reader.getName().equals(elementToProcess)) {
+ break;
+ }
+ }
+ while (true) {
+ int event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT: {
+ Object artifact = staxProcessor.read(reader);
+ if (artifact instanceof PolicySet) {
+ PolicySet policySet = (PolicySet)artifact;
+ policySet.setName(new QName(namespace, policySet.getName().getLocalPart()));
+ policySetTable.put(policySet.getName(), policySet);
+ } else if (artifact instanceof Intent) {
+ Intent intent = (Intent)artifact;
+ intent.setName(new QName(namespace, intent.getName().getLocalPart()));
+ intentTable.put(intent.getName(), intent);
+ for (Intent i : intent.getQualifiedIntents()) {
+ i.setName(new QName(namespace, i.getName().getLocalPart()));
+ intentTable.put(i.getName(), i);
+ resolver.addModel(i);
+ }
+ } else if (artifact instanceof BindingType) {
+ BindingType bindingType = (BindingType)artifact;
+ bindingTypesTable.put(bindingType.getType(), bindingType);
+ } else if (artifact instanceof ImplementationTypeImpl) {
+ ImplementationType implType = (ImplementationType)artifact;
+ implTypesTable.put(implType.getType(), implType);
+ }
+
+ if (artifact != null) {
+ resolver.addModel(artifact);
+ }
+
+ break;
+ }
+ }
+ if (reader.hasNext()) {
+ reader.next();
+ } else {
+ break;
+ }
+ }
+ urlStream.close();
+ }
+
+ @Test
+ public void testReadSCADefinitions() throws Exception {
+ assertNotNull(intentTable.get(confidentiality));
+ assertNotNull(intentTable.get(messageProtection));
+ assertNotNull(intentTable.get(confidentiality_transport));
+ assertTrue(intentTable.get(confidentiality).getDescription().length() > 0);
+
+ assertNotNull(policySetTable.get(secureReliablePolicy));
+ assertTrue(policySetTable.get(secureReliablePolicy).getProvidedIntents().size() == 2);
+ assertTrue(policySetTable.get(secureReliablePolicy).getPolicies().size() == 2);
+
+ assertNotNull(policySetTable.get(secureMessagingPolicies));
+ assertEquals(2, policySetTable.get(secureMessagingPolicies).getIntentMaps().get(0).getQualifiers().get(0).getPolicies().size());
+
+ assertEquals(bindingTypesTable.size(), 1);
+ assertNotNull(bindingTypesTable.get(wsBinding));
+ assertEquals(implTypesTable.size(), 1);
+ assertNotNull(implTypesTable.get(javaImpl));
+ }
+
+ private int getNumberOfQualifiedPolicies(PolicySet policySet) {
+ int count = 0;
+ for(IntentMap intentMap: policySet.getIntentMaps()) {
+ for(Qualifier q: intentMap.getQualifiers()) {
+ count += q.getPolicies().size();
+ }
+ }
+ return count;
+ }
+
+ @Test
+ public void testResolution() throws Exception {
+ assertTrue(!intentTable.get(messageProtection).getRequiredIntents().isEmpty());
+ Intent profileIntent = intentTable.get(new QName(namespace, "messageProtection"));
+ assertNull(profileIntent.getRequiredIntents().get(0).getDescription());
+
+ QName confidentiality_transport = new QName(namespace, "confidentiality.transport");
+ assertTrue(intentTable.get(confidentiality_transport) instanceof Intent);
+ Intent qualifiedIntent = (Intent)intentTable.get(new QName(namespace, "confidentiality.transport"));
+ assertNull(qualifiedIntent.getDescription());
+ assertNotNull(qualifiedIntent.getQualifiableIntent().getDescription());
+
+ PolicySet secureReliablePolicySet = policySetTable.get(secureReliablePolicy);
+ PolicySet secureMessagingPolicySet = policySetTable.get(secureMessagingPolicies);
+ PolicySet securityPolicySet = policySetTable.get(securityPolicy);
+
+ assertEquals(secureReliablePolicySet.getProvidedIntents().get(1).getName(), integrity);
+ assertNull(secureReliablePolicySet.getProvidedIntents().get(1).getDescription());
+ assertTrue(secureMessagingPolicySet.isUnresolved());
+ assertEquals(2, getNumberOfQualifiedPolicies(securityPolicySet));
+
+ //testing to ensure that inclusion of referred policy sets has not happened
+ PolicySet basicAuthMsgProtSecurityPolicySet = policySetTable.get(basicAuthMsgProtSecurity);
+ assertTrue(basicAuthMsgProtSecurityPolicySet.getPolicies().isEmpty());
+ assertTrue(basicAuthMsgProtSecurityPolicySet.getIntentMaps().isEmpty());
+
+ ExtensionType wsBindingType = bindingTypesTable.get(wsBinding);
+ assertNull(wsBindingType.getAlwaysProvidedIntents().get(0).getDescription());
+ assertNull(wsBindingType.getMayProvidedIntents().get(0).getDescription());
+
+ ExtensionType javaImplType = implTypesTable.get(javaImpl);
+ assertNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
+ assertNull(javaImplType.getMayProvidedIntents().get(0).getDescription());
+
+ List<Intent> intents = new ArrayList<Intent>(intentTable.values());
+
+ for (Intent intent : intents) {
+ staxProcessor.resolve(intent, resolver);
+ }
+
+ for (PolicySet policySet : policySetTable.values()) {
+ if (policySet.getReferencedPolicySets().isEmpty())
+ staxProcessor.resolve(policySet, resolver);
+ }
+
+ for (PolicySet policySet : policySetTable.values()) {
+ if (!policySet.getReferencedPolicySets().isEmpty())
+ staxProcessor.resolve(policySet, resolver);
+ }
+
+ for (ExtensionType bindingType : bindingTypesTable.values()) {
+ staxProcessor.resolve(bindingType, resolver);
+ }
+
+ for (ExtensionType implType : implTypesTable.values()) {
+ staxProcessor.resolve(implType, resolver);
+ }
+
+ //testing if policy intents have been linked have property been linked up
+ assertNotNull(profileIntent.getRequiredIntents().get(0).getDescription());
+ assertNotNull(qualifiedIntent.getQualifiableIntent().getDescription());
+ assertEquals(secureReliablePolicySet.getProvidedIntents().get(1).getName(), integrity);
+ assertNotNull(secureReliablePolicySet.getProvidedIntents().get(1).getDescription());
+
+ //testing if policysets have been properly linked up with intents
+ assertFalse(secureMessagingPolicySet.isUnresolved());
+ assertTrue(isRealizedBy(secureMessagingPolicySet, intentTable.get(confidentiality)));
+ assertTrue(isRealizedBy(secureMessagingPolicySet, intentTable.get(confidentiality_transport)));
+
+ //testing if intent maps have been properly mapped to policies
+ assertFalse(securityPolicySet.isUnresolved());
+ assertTrue(isRealizedBy(securityPolicySet, intentTable.get(confidentiality)));
+ assertTrue(isRealizedBy(securityPolicySet, intentTable.get(confidentiality_message)));
+
+ //testing for inclusion of referred policysets
+ assertFalse(basicAuthMsgProtSecurityPolicySet.getPolicies().isEmpty());
+ assertFalse(basicAuthMsgProtSecurityPolicySet.getIntentMaps().isEmpty());
+ assertTrue(isRealizedBy(basicAuthMsgProtSecurityPolicySet, intentTable.get(confidentiality_transport)));
+
+ assertNotNull(wsBindingType.getAlwaysProvidedIntents().get(0).getDescription());
+ assertNotNull(wsBindingType.getMayProvidedIntents().get(0).getDescription());
+
+ assertNotNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
+ assertNotNull(javaImplType.getMayProvidedIntents().get(0).getDescription());
+ }
+
+ private boolean isRealizedBy(PolicySet policySet, Intent intent) {
+ if (intent.getName().getLocalPart().indexOf('.') == -1) {
+ return policySet.getProvidedIntents().contains(intent);
+ }
+ for (IntentMap map : policySet.getIntentMaps()) {
+ for (Qualifier q : map.getQualifiers()) {
+ if (q.getIntent().equals(intent)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
diff --git a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java
new file mode 100644
index 0000000000..08a2b3b2eb
--- /dev/null
+++ b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java
@@ -0,0 +1,82 @@
+/*
+ * 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.policy.xml;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.processor.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;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestPolicyProcessor implements StAXArtifactProcessor<PolicyExpression> {
+
+ 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<PolicyExpression> getModelType() {
+ // TODO Auto-generated method stub
+ return PolicyExpression.class;
+ }
+
+ public void resolve(PolicyExpression arg0, ModelResolver arg1) throws ContributionResolveException {
+
+ }
+
+ public class MockPolicyImplOne implements PolicyExpression {
+ public <T> T getPolicy() {
+ return null;
+ }
+
+ public void setName(QName name) {
+ }
+
+ public <T> 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/modules/definitions-xml/src/test/resources/org/apache/tuscany/sca/definitions/xml/test_definitions.xml b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/definitions/xml/test_definitions.xml
index dac8e384e3..dac8e384e3 100644
--- a/java/sca/modules/definitions-xml/src/test/resources/org/apache/tuscany/sca/definitions/xml/test_definitions.xml
+++ b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/definitions/xml/test_definitions.xml
diff --git a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite
new file mode 100644
index 0000000000..d6082a936d
--- /dev/null
+++ b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent" requires="confidentiality">
+ <implementation.java class="calculator.CalculatorServiceImpl" xmlns:test="http://test" requiers="test:TestIntentOne"/>
+ <reference name="addService" target="AddServiceComponent" />
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent" />
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml
new file mode 100644
index 0000000000..b4857c499f
--- /dev/null
+++ b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml
@@ -0,0 +1,204 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * 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.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" targetNamespace="http://test"
+ xmlns:test="http://test" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+
+ <!-- Extension Types Metadata -->
+ <implementationType type="sca:implementation.java" alwaysProvides="test:logging" mayProvide="test:tracing" />
+ <bindingType type="sca:binding.ws" alwaysProvides="test:confidentiality" mayProvide="test:integrity" />
+
+ <!-- Intents and Policysets to assume targetnamespace -->
+ <intent name="TestIntentOne" constrains="sca:binding">
+ <description>
+ Test Intent
+ </description>
+ </intent>
+
+ <intent name="TestIntentTwo" constrains="sca:binding" requires="test:TestIntentOne">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <policySet name="TestPolicySetOne" provides="test:TestIntentOne" appliesTo="sca:binding.ws"
+ attachTo = "//sca:component[@name='CalculatorServiceComponent']/sca:reference[@name='addService']"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <!-- POLICY SETS -->
+ <policySet name="SecureReliablePolicy" provides="test:confidentiality.transport test:integrity" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="SecureMessagingPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport" alternative -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message" alternative" -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecurityPolicy" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for body encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for transport encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="BasicAuthMsgProtSecurity" provides="test:authentication test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+ <policySetReference name="test:AuthenticationPolicies" />
+ <policySetReference name="test:ConfidentialityPolicies" />
+ </policySet>
+
+ <policySet name="AuthenticationPolicies" provides="test:authentication" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "basic
+ authentication" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="ConfidentialityPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport"
+ alternative -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message"
+ alternative" -->
+ ...
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecureWSPolicy" provides="test:confidentiality" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:Policy>
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SecurityToken>
+ <sp:TokenType>sp:X509v3</sp:TokenType>
+ </sp:SecurityToken>
+ <sp:UsernameToken />
+ <sp:SignedParts />
+ <sp:EncryptedParts>
+ <sp:Body />
+ </sp:EncryptedParts>
+ <sp:TransportBinding>
+ <sp:IncludeTimeStamp />
+ </sp:TransportBinding>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </policySet>
+
+ <!-- profile intent -->
+ <intent name="reliableMessageProtection" constrains="sca:binding" requires="test:messageProtection">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <intent name="messageProtection" constrains="sca:binding" requires="test:confidentiality test:integrity">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <!-- simple intent -->
+ <intent name="confidentiality" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized users from reading the messages.
+ </description>
+ <qualifier name="transport" />
+ <qualifier name="message" default="true" />
+ </intent>
+
+ <intent name="integrity" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized modification of the messages.
+ </description>
+ </intent>
+
+ <intent name="authentication" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding required
+ Authentication.
+ </description>
+ </intent>
+
+ <intent name="logging" constrains="sca:implementation">
+ <description>
+ All messages to and from this implementation must be logged
+ </description>
+ </intent>
+
+ <intent name="tracing" constrains="sca:implementation.java">
+ <description>
+ Need to figure out some description for this
+ </description>
+ </intent>
+
+</definitions> \ No newline at end of file
diff --git a/java/sca/modules/binding-ws-axis2/pom.xml b/java/sca/modules/binding-ws-axis2/pom.xml
index ad8bb5f4d4..b9d56c6e70 100644
--- a/java/sca/modules/binding-ws-axis2/pom.xml
+++ b/java/sca/modules/binding-ws-axis2/pom.xml
@@ -59,13 +59,6 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-policy-xml</artifactId>
- <version>2.0-SNAPSHOT</version>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-binding-ws</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
diff --git a/java/sca/modules/builder/pom.xml b/java/sca/modules/builder/pom.xml
index 33db479180..9968fff015 100644
--- a/java/sca/modules/builder/pom.xml
+++ b/java/sca/modules/builder/pom.xml
@@ -45,13 +45,6 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-definitions-xml</artifactId>
- <version>2.0-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-contribution</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
diff --git a/java/sca/modules/definitions-xml/LICENSE b/java/sca/modules/definitions-xml/LICENSE
deleted file mode 100644
index 9100141e4e..0000000000
--- a/java/sca/modules/definitions-xml/LICENSE
+++ /dev/null
@@ -1,253 +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.
-
-=================================================================================================================
-
-This module also includes files under the following license:
-
-Copyright OASIS 2005, 2009. All Rights Reserved.
-All capitalized terms in the following text have the meanings assigned to them in the OASIS Intellectual
-Property Rights Policy (the "OASIS IPR Policy"). The full Policy may be found at the OASIS website.
-This document and translations of it may be copied and furnished to others, and derivative works that
-comment on or otherwise explain it or assist in its implementation may be prepared, copied, published,
-and distributed, in whole or in part, without restriction of any kind, provided that the above copyright
-notice and this section are included on all such copies and derivative works. However, this document
-itself may not be modified in any way, including by removing the copyright notice or references to OASIS,
-except as needed for the purpose of developing any document or deliverable produced by an OASIS
-Technical Committee (in which case the rules applicable to copyrights, as set forth in the OASIS IPR
-Policy, must be followed) or as required to translate it into languages other than English.
-The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors
-or assigns.
-This document and the information contained herein is provided on an "AS IS" basis and OASIS
-DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY
-WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP
-RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
-PURPOSE.
-OASIS requests that any OASIS Party or any other party that believes it has patent claims that would
-necessarily be infringed by implementations of this OASIS Committee Specification or OASIS Standard,
-to notify OASIS TC Administrator and provide an indication of its willingness to grant patent licenses to
-such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that
-produced this specification.
-OASIS invites any party to contact the OASIS TC Administrator if it is aware of a claim of ownership of
-any patent claims that would necessarily be infringed by implementations of this specification by a patent
-holder that is not willing to provide a license to such patent claims in a manner consistent with the IPR
-Mode of the OASIS Technical Committee that produced this specification. OASIS may include such
-claims on its website, but disclaims any obligation to do so.
-OASIS takes no position regarding the validity or scope of any intellectual property or other rights that
-might be claimed to pertain to the implementation or use of the technology described in this document or
-the extent to which any license under such rights might or might not be available; neither does it represent
-that it has made any effort to identify any such rights. Information on OASIS' procedures with respect to
-rights in any document or deliverable produced by an OASIS Technical Committee can be found on the
-OASIS website. Copies of claims of rights made available for publication and any assurances of licenses
-to be made available, or the result of an attempt made to obtain a general license or permission for the use
-of such proprietary rights by implementers or users of this OASIS Committee Specification or OASIS
-Standard, can be obtained from the OASIS TC Administrator. OASIS makes no representation that any
-information or list of intellectual property rights will at any time be complete, or that any claims in such list
-are, in fact, Essential Claims.
-The names "OASIS", are trademarks of OASIS, the owner and developer of this specification, and should
-be used only to refer to the organization and its official outputs. OASIS welcomes reference to, and
-implementation and use of, specifications, while reserving the right to enforce its marks against misleading
-uses. Please see http://www.oasis-open.org/who/trademark.php for above guidance.
-
-
-
diff --git a/java/sca/modules/definitions-xml/META-INF/MANIFEST.MF b/java/sca/modules/definitions-xml/META-INF/MANIFEST.MF
deleted file mode 100644
index b9e4e04b91..0000000000
--- a/java/sca/modules/definitions-xml/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,28 +0,0 @@
-Manifest-Version: 1.0
-Private-Package: org.apache.tuscany.sca.definitions.xml;version="2.0.0"
-Tool: Bnd-0.0.255
-Bundle-Name: Apache Tuscany SCA Definitions XML Model
-Created-By: 1.6.0_07 (Sun Microsystems Inc.)
-Bundle-Vendor: The Apache Software Foundation
-Bundle-Version: 2.0.0
-Bnd-LastModified: 1225397117406
-Bundle-ManifestVersion: 2
-Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
-Bundle-Description: Apache Tuscany SCA Definitions XML Model
-Import-Package: javax.xml.namespace,
- javax.xml.stream,
- org.apache.tuscany.sca.assembly;version="2.0.0",
- org.apache.tuscany.sca.common.java.io;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.definitions.util;version="2.0.0",
- org.apache.tuscany.sca.definitions.xml;version="2.0.0",
- org.apache.tuscany.sca.extensibility;version="2.0.0",
- org.apache.tuscany.sca.monitor;version="2.0.0",
- org.apache.tuscany.sca.policy;version="2.0.0"
-Bundle-SymbolicName: org.apache.tuscany.sca.definitions.xml
-Bundle-DocURL: http://www.apache.org/
-Export-Package: org.apache.tuscany.sca.definitions.xml;version="2.0.0"
-Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/java/sca/modules/definitions-xml/NOTICE b/java/sca/modules/definitions-xml/NOTICE
deleted file mode 100644
index bc1a8c6d74..0000000000
--- a/java/sca/modules/definitions-xml/NOTICE
+++ /dev/null
@@ -1,12 +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/).
-
-This product also includes software under the OASIS specification License
-with the following copyright:
-
-Copyright(C) OASIS(R) 2005,2009. All Rights Reserved.
-OASIS trademark, IPR and other policies apply.
-
diff --git a/java/sca/modules/definitions-xml/pom.xml b/java/sca/modules/definitions-xml/pom.xml
deleted file mode 100644
index 8863ae2cb2..0000000000
--- a/java/sca/modules/definitions-xml/pom.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
--->
-<project>
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-modules</artifactId>
- <version>2.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
- <artifactId>tuscany-definitions-xml</artifactId>
- <name>Apache Tuscany SCA Definitions XML Model</name>
-
- <dependencies>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-assembly</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-policy-xml</artifactId>
- <version>2.0-SNAPSHOT</version>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-contribution</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-assembly-xsd</artifactId>
- <version>2.0-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
deleted file mode 100644
index 024953e255..0000000000
--- a/java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
+++ /dev/null
@@ -1,19 +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.definitions.xml.DefinitionsProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#definitions,model=org.apache.tuscany.sca.definitions.Definitions
diff --git a/java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
deleted file mode 100644
index c0350c8189..0000000000
--- a/java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
+++ /dev/null
@@ -1,19 +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.definitions.xml.DefinitionsDocumentProcessor;type=/META-INF/definitions.xml,model=org.apache.tuscany.sca.definitions.Definitions
diff --git a/java/sca/modules/implementation-java/pom.xml b/java/sca/modules/implementation-java/pom.xml
index 7b246debf7..16b19b16ae 100644
--- a/java/sca/modules/implementation-java/pom.xml
+++ b/java/sca/modules/implementation-java/pom.xml
@@ -80,20 +80,6 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-policy-xml</artifactId>
- <version>2.0-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-definitions-xml</artifactId>
- <version>2.0-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-binding-sca-runtime</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>test</scope>
diff --git a/java/sca/modules/node-impl/pom.xml b/java/sca/modules/node-impl/pom.xml
index 87d3910b7f..513fb8ebf5 100644
--- a/java/sca/modules/node-impl/pom.xml
+++ b/java/sca/modules/node-impl/pom.xml
@@ -64,13 +64,6 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-definitions-xml</artifactId>
- <version>2.0-SNAPSHOT</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-builder</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>runtime</scope>
@@ -85,13 +78,6 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-policy-xml</artifactId>
- <version>2.0-SNAPSHOT</version>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-core-databinding</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>runtime</scope>
diff --git a/java/sca/modules/policy-xml-ws/pom.xml b/java/sca/modules/policy-xml-ws/pom.xml
index d1cc161867..2075bbe047 100644
--- a/java/sca/modules/policy-xml-ws/pom.xml
+++ b/java/sca/modules/policy-xml-ws/pom.xml
@@ -37,7 +37,7 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-policy-xml</artifactId>
+ <artifactId>tuscany-assembly-xml</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
diff --git a/java/sca/modules/pom.xml b/java/sca/modules/pom.xml
index ec78eb5b8a..ce716d5881 100644
--- a/java/sca/modules/pom.xml
+++ b/java/sca/modules/pom.xml
@@ -58,7 +58,6 @@
<module>databinding-axiom</module>
<module>databinding-jaxb</module>
<module>databinding-jaxb-axiom</module>
- <module>definitions-xml</module>
<module>domain-node</module>
<module>endpoint-tribes</module>
<module>endpoint-wrapper</module>
@@ -87,7 +86,6 @@
<module>node-launcher</module>
<module>node-launcher-equinox</module>
<module>policy-security</module>
- <module>policy-xml</module>
<module>policy-xml-ws</module>
<module>policy-logging</module>
<module>sca-api</module>
diff --git a/java/sca/modules/scdl/pom.xml b/java/sca/modules/scdl/pom.xml
index ffbb03f4ee..de13920bb0 100644
--- a/java/sca/modules/scdl/pom.xml
+++ b/java/sca/modules/scdl/pom.xml
@@ -63,7 +63,7 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-definitions-xml</artifactId>
+ <artifactId>tuscany-assembly-xml</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
diff --git a/java/sca/pom.xml b/java/sca/pom.xml
index 0bd42865be..e59f75e538 100644
--- a/java/sca/pom.xml
+++ b/java/sca/pom.xml
@@ -519,6 +519,51 @@
</profile>
<profile>
+ <id>base</id>
+ <modules>
+ <module>modules/assembly</module>
+ <module>modules/assembly-xml</module>
+ <module>modules/assembly-xsd</module>
+ <module>modules/binding-sca-runtime</module>
+ <module>modules/binding-ws</module>
+ <module>modules/binding-ws-axis2-policy</module>
+ <module>modules/binding-ws-wsdlgen</module>
+ <module>modules/builder</module>
+ <module>modules/common-java</module>
+ <module>modules/common-xml</module>
+ <module>modules/contribution</module>
+ <module>modules/core</module>
+ <module>modules/core-databinding</module>
+ <module>modules/core-spi</module>
+ <module>modules/databinding</module>
+ <module>modules/databinding-axiom</module>
+ <module>modules/databinding-jaxb</module>
+ <module>modules/definitions-xml</module>
+ <module>modules/domain-node</module>
+ <module>modules/endpoint-tribes</module>
+ <module>modules/endpoint-wrapper</module>
+ <module>modules/extensibility</module>
+ <module>modules/host-http</module>
+ <module>modules/host-webapp</module>
+ <module>modules/implementation-java</module>
+ <module>modules/implementation-java-runtime</module>
+ <module>modules/implementation-web</module>
+ <module>modules/implementation-web-runtime</module>
+ <module>modules/interface-java</module>
+ <module>modules/interface-java-jaxws</module>
+ <module>modules/interface-wsdl</module>
+ <module>modules/monitor</module>
+ <module>modules/interface-wsdl</module>
+ <module>modules/node-api</module>
+ <module>modules/node-impl</module>
+ <module>modules/policy-xml</module>
+ <module>modules/policy-security</module>
+ <module>modules/sca-api</module>
+ <module>modules/sca-client-impl</module>
+ <module>modules/xsd</module>
+ </modules>
+ </profile>
+ <profile>
<id>jms</id>
<modules>
<module>modules/binding-jms</module>