summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/assembly/src
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2011-12-01 16:45:57 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2011-12-01 16:45:57 +0000
commit959ac6c9a2ce735b02a2f9fb75234326423695ad (patch)
tree2a5bbfb8d868fc770f00916d5f51b3db514f8ccf /sca-java-2.x/trunk/modules/assembly/src
parentb69be18919d5d912b5ff3f518c3807a954aad9e9 (diff)
Add a mechanism for specifying default intents on policy subjects. This is a rewrite of the previous attempt after Greg pointed out a build order issue on the mail list.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1209146 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultIntent.java53
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultingPolicySubject.java48
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java6
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/DefaultIntentImpl.java60
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java4
5 files changed, 171 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultIntent.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultIntent.java
new file mode 100644
index 0000000000..7f3579a388
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultIntent.java
@@ -0,0 +1,53 @@
+/*
+ * 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.namespace.QName;
+
+/**
+ * Represents a default intent and the intents that must not be present in order
+ * for this default intent to come into force.
+ */
+public interface DefaultIntent {
+
+ /**
+ * Returns the default intent object
+ *
+ * @return the intent
+ */
+ Intent getIntent();
+
+ /**
+ * Sets the intent object
+ *
+ * @param the intent
+ */
+ void setIntent(Intent intent);
+
+ /**
+ * Returns the list of intent names that must not be present
+ * in order for the default intent to come into play.
+ *
+ * @return the list of mutually exclusive intent names
+ */
+ List<Intent> getMutuallyExclusiveIntents();
+
+}
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultingPolicySubject.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultingPolicySubject.java
new file mode 100644
index 0000000000..8f41d8fb71
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultingPolicySubject.java
@@ -0,0 +1,48 @@
+/*
+ * 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;
+
+/**
+ * A policy subject is an entity in the assembly with which a policy can be
+ * associated.
+ *
+ * This default extension provides a mechanism of associating default intents
+ * with a policy subject so that the framework will take default intents
+ * into account if no intents are specified by the user.
+ *
+ * Default intents are mainly applicable when an artifact defines mayProvides
+ * intents but the user specified no intents
+ */
+public interface DefaultingPolicySubject extends PolicySubject {
+
+ /**
+ * Default intents are mainly applicable when an
+ * artifact defines mayProvides intents but the
+ * user specified no intents. In some cases the
+ * artifact will implement a default intent so
+ * this collection provides the information for the
+ * framework to determine what those defaults are
+ *
+ * @return A list of default intent records
+ */
+ List<DefaultIntent> getDefaultIntents();
+}
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 b23060dafb..b553585c8d 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
@@ -69,4 +69,10 @@ public interface PolicyFactory {
* @return
*/
ExternalAttachment createExternalAttachment();
+
+ /**
+ * Create a new DefaultIntent
+ * @return
+ */
+ DefaultIntent createDefaultIntent();
}
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/DefaultIntentImpl.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/DefaultIntentImpl.java
new file mode 100644
index 0000000000..c7c2426d36
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/DefaultIntentImpl.java
@@ -0,0 +1,60 @@
+/*
+ * 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.namespace.QName;
+
+import org.apache.tuscany.sca.policy.DefaultIntent;
+import org.apache.tuscany.sca.policy.Intent;
+
+/**
+ * Represents a default policy intent and the
+ * intents that must not be present for it to
+ * be active
+ */
+public class DefaultIntentImpl implements DefaultIntent {
+
+ private Intent defaultIntent = null;
+ private List<Intent> mutuallyExclusiveIntents = new ArrayList<Intent>();
+
+ protected DefaultIntentImpl() {
+ }
+
+ @Override
+ public Intent getIntent() {
+ return defaultIntent;
+ }
+
+ @Override
+ public void setIntent(Intent defaultIntent) {
+ this.defaultIntent = defaultIntent;
+ }
+
+ @Override
+ public List<Intent> getMutuallyExclusiveIntents() {
+ return mutuallyExclusiveIntents;
+ }
+
+ public String toString() {
+ return String.valueOf(defaultIntent.getName());
+ }
+}
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 f700f7c41a..e1561a99b6 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
@@ -19,6 +19,7 @@
package org.apache.tuscany.sca.policy.impl;
import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.DefaultIntent;
import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.ImplementationType;
import org.apache.tuscany.sca.policy.Intent;
@@ -73,4 +74,7 @@ public abstract class PolicyFactoryImpl implements PolicyFactory {
return new ExternalAttachmentImpl();
}
+ public DefaultIntent createDefaultIntent() {
+ return new DefaultIntentImpl();
+ }
}