summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java8
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java6
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java2
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExternalAttachment.java85
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java5
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExternalAttachmentImpl.java76
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java6
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java18
8 files changed, 206 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java
index 7a63bbedc5..9ae5e6f26f 100644
--- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java
+++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java
@@ -26,6 +26,8 @@ import org.apache.tuscany.sca.policy.ImplementationType;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.ExternalAttachment;
+
/**
* Represents SCA Definitions.
@@ -81,4 +83,10 @@ public interface Definitions {
* @return a list of domain wide binding definition objects
*/
List<Binding> getBindings();
+
+ /**
+ * Returns a list of external attachments
+ * @return
+ */
+ List<ExternalAttachment> getExternalAttachments();
}
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java
index 224bc0a69a..e58261cda2 100644
--- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java
+++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java
@@ -25,6 +25,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.definitions.Definitions;
import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ExternalAttachment;
import org.apache.tuscany.sca.policy.ImplementationType;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.PolicySet;
@@ -41,6 +42,7 @@ public class DefinitionsImpl implements Definitions {
private List<BindingType> bindingTypes = new CopyOnWriteArrayList<BindingType>();
private List<ImplementationType> implementationTypes = new CopyOnWriteArrayList<ImplementationType>();
private List<Binding> bindings = new CopyOnWriteArrayList<Binding>();
+ private List<ExternalAttachment> externalAttachments = new CopyOnWriteArrayList<ExternalAttachment>();
public List<BindingType> getBindingTypes() {
@@ -70,4 +72,8 @@ public class DefinitionsImpl implements Definitions {
public List<Binding> getBindings() {
return bindings;
}
+
+ public List<ExternalAttachment> getExternalAttachments() {
+ return externalAttachments ;
+ }
}
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java
index eb74677236..452c3bf883 100644
--- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java
+++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java
@@ -103,6 +103,8 @@ public class DefinitionsUtil {
}
target.getBindings().addAll(source.getBindings());
+
+ target.getExternalAttachments().addAll(source.getExternalAttachments());
}
}
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExternalAttachment.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExternalAttachment.java
new file mode 100644
index 0000000000..5bccf51b91
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExternalAttachment.java
@@ -0,0 +1,85 @@
+/*
+ * 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;
+
+import java.util.List;
+
+import javax.xml.xpath.XPathExpression;
+
+/*
+ * Represents an external attachment element. See the Policy Framework specification for a
+ * description of this element.
+ *
+ * @version $Rev: 937291 $ $Date: 2010-04-23 06:41:24 -0700 (Fri, 23 Apr 2010) $
+ * @tuscany.spi.extension.asclient
+ */
+
+
+public interface ExternalAttachment {
+
+ /**
+ * Get the attachTo attribute
+ * @return
+ */
+ String getAttachTo();
+
+ /**
+ * Set the attachTo attribute
+ * @param name
+ */
+ void setAttachTo(String name);
+
+ /**
+ * Get the compiled XPath attachTo expression
+ * @return
+ */
+ XPathExpression getAttachToXPathExpression();
+
+ /**
+ * Set the compiled XPath attachTo expression
+ * @param expression
+ */
+ void setAttachToXPathExpression(XPathExpression expression);
+
+ /**
+ * Get the policy sets associated with this ExternalAttachment
+ * @return
+ */
+ List<PolicySet> getPolicySets();
+
+ /**
+ * Get the intents associated with this ExternalAttachment
+ * @return
+ */
+ List<Intent> getIntents();
+
+ /**
+ * Returns true if the model element is unresolved.
+ *
+ * @return true if the model element is unresolved.
+ */
+ boolean isUnresolved();
+
+ /**
+ * Sets whether the model element is unresolved.
+ *
+ * @param unresolved whether the model element is unresolved
+ */
+ void setUnresolved(boolean unresolved);
+}
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java
index b2ac5ca409..b23060dafb 100644
--- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java
+++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java
@@ -64,4 +64,9 @@ public interface PolicyFactory {
BindingType createBindingType();
ImplementationType createImplementationType();
+ /**
+ * Create a new ExternalAttachment
+ * @return
+ */
+ ExternalAttachment createExternalAttachment();
}
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExternalAttachmentImpl.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExternalAttachmentImpl.java
new file mode 100644
index 0000000000..1e90e26324
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExternalAttachmentImpl.java
@@ -0,0 +1,76 @@
+/*
+ * 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.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.xpath.XPathExpression;
+
+import org.apache.tuscany.sca.policy.ExternalAttachment;
+
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * An implementation of ExternalAttachment
+ *
+ */
+public class ExternalAttachmentImpl implements ExternalAttachment {
+
+ private String attachTo;
+ private List<Intent> intents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private XPathExpression xpath;
+ private boolean isUnresolved;
+
+
+ public String getAttachTo() {
+ return attachTo;
+ }
+
+ public void setAttachTo(String attachTo) {
+ this.attachTo = attachTo;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return this.policySets;
+ }
+
+ public List<Intent> getIntents() {
+ return this.intents;
+ }
+
+ public XPathExpression getAttachToXPathExpression() {
+ return this.xpath;
+ }
+
+ public void setAttachToXPathExpression(XPathExpression expression) {
+ this.xpath = expression;
+ }
+
+ public boolean isUnresolved() {
+ return this.isUnresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.isUnresolved = unresolved;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java
index c67ff1eab8..f700f7c41a 100644
--- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java
+++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java
@@ -28,6 +28,8 @@ import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.policy.PolicySet;
import org.apache.tuscany.sca.policy.Qualifier;
+import org.apache.tuscany.sca.policy.ExternalAttachment;
+
/**
* A factory for the policy model.
*
@@ -66,5 +68,9 @@ public abstract class PolicyFactoryImpl implements PolicyFactory {
public ExtensionType createExtensionType() {
return new ExtensionTypeImpl();
}
+
+ public ExternalAttachment createExternalAttachment() {
+ return new ExternalAttachmentImpl();
+ }
}
diff --git a/sca-java-2.x/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java b/sca-java-2.x/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java
index 2775c4ac71..569366ad1b 100644
--- a/sca-java-2.x/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java
+++ b/sca-java-2.x/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java
@@ -52,4 +52,22 @@ public class PolicyFactoryTestCase {
policySet.setName(new QName("http://test", "reliability"));
assertEquals(policySet.getName(), new QName("http://test", "reliability"));
}
+
+ @Test
+ public void testCreateExternalAttachment() {
+ ExternalAttachment attachment = factory.createExternalAttachment();
+ attachment.setAttachTo("sca:component");
+
+ Intent intent = factory.createIntent();
+ intent.setName(new QName("http://test", "reliability"));
+ attachment.getIntents().add(intent);
+
+ PolicySet policySet = factory.createPolicySet();
+ policySet.setName(new QName("http://test", "reliability"));
+ attachment.getPolicySets().add(policySet);
+
+ assertEquals("sca:component", attachment.getAttachTo());
+ assertEquals(intent, attachment.getIntents().get(0));
+ assertEquals(policySet, attachment.getPolicySets().get(0));
+ }
}