summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/policy/src
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-02-20 20:10:37 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-02-20 20:10:37 +0000
commit3a8a64103bcc4891fb1a1f4cc4538f9d5b62a7ba (patch)
treeccd8919c277ad88c032acb3167fdd4645586cb07 /java/sca/modules/policy/src
parent7b9fa54dced70baffa6578b0be902b06092584a7 (diff)
Start to implement the SCA policy framework 1.1 spec draft from OASIS OpenCSA
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@746356 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/policy/src')
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/BindingType.java (renamed from java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/DefaultIntentAttachPointTypeFactory.java)56
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java (renamed from java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentAttachPointType.java)152
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java (renamed from java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Policy.java)60
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Intent.java82
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentAttachPointTypeFactory.java43
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java56
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java (renamed from java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ProfileIntent.java)67
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyContext.java38
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java (renamed from java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySetReference.java)108
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java23
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyResolver.java (renamed from java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySetAttachPoint.java)41
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java65
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java (renamed from java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentAttachPoint.java)44
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java (renamed from java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/QualifiedIntent.java)85
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java64
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java97
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java61
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentAttachPointTypeFactoryImpl.java39
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java123
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java30
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyContextImpl.java93
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java86
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java32
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java122
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetReferenceImpl.java48
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/QualifiedIntentImpl.java50
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java (renamed from java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ProfileIntentImpl.java)87
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java134
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandler.java38
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerDefinitionsLoader.java87
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerTuple.java91
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerUtils.java64
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java53
-rw-r--r--java/sca/modules/policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory18
34 files changed, 897 insertions, 1440 deletions
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/DefaultIntentAttachPointTypeFactory.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/BindingType.java
index 6ca4fe72ec..f43c428563 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/DefaultIntentAttachPointTypeFactory.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/BindingType.java
@@ -1,29 +1,27 @@
-/*
- * 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 org.apache.tuscany.sca.policy.impl.IntentAttachPointTypeFactoryImpl;
-
-/**
- * Default implementation for IntentAttachPointTypeFactory
- *
- * @version $Rev$ $Date$
- */
-public class DefaultIntentAttachPointTypeFactory extends IntentAttachPointTypeFactoryImpl implements IntentAttachPointTypeFactory{
-}
+/*
+ * 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;
+
+
+/**
+ * Definition of binding type which extends from sca:binding
+ */
+public interface BindingType extends ExtensionType {
+}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentAttachPointType.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java
index 6db529c7f0..828d0a9966 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentAttachPointType.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java
@@ -1,71 +1,81 @@
-/*
- * 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;
-
-/**
- * Base interface for representing the model type of assembly model objects that can be have policy intents
- * attached to them.
- *
- * @version $Rev$ $Date$
- */
-public interface IntentAttachPointType {
-
- /**
- * Returns the name of the extension type defined by this instance e.g. implementation.java, binding.ws
- * @return the extension type QName
- */
- QName getName();
-
- /**
- * Sets the name of the extension type
- * @param type the name of the extension type
- */
- void setName(QName type);
-
- /**
- * Returns the list of names of policy intents that will always be provided by this Extension Type
- * @return list of Policy Intent names
- */
- List<Intent> getAlwaysProvidedIntents();
-
- /**
- * Returns the list of names of policy intents that may be provided by this Extension Type thro
- * appropriate configuration
- * @return list of Policy Intent names
- */
- List<Intent> getMayProvideIntents();
-
- /**
- * 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);
-}
+/*
+ * 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;
+
+/**
+ * Definition of extension type: binding or implementation
+ */
+public interface ExtensionType {
+ QName BINDING_BASE = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200712", "binding");
+ QName IMPLEMENTATION_BASE = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200712", "implementation");
+
+ /**
+ * The name of the extension type (binding or implementation). The extension type name
+ * attribute MUST be the QName of an XSD global element definition used for
+ * binding/implementation elements of that type
+ *
+ * @return The QName of this type
+ */
+ QName getType();
+
+ /**
+ * Set the QName for this type
+ * @param type The QName of this type
+ */
+ void setType(QName type);
+
+ QName getBaseType();
+
+ /**
+ * A set of intents. The intents in the alwaysProvides set are always
+ * provided by this extension type, whether the intents are attached
+ * to the using component or not.
+ *
+ * @return A list of intents that are always provided by this type
+ */
+ List<Intent> getAlwaysProvidedIntents();
+
+ /**
+ * a set of intents. The intents in the mayProvide set are provided by this
+ * extension type if the intent in question is attached to the using
+ * component.
+ *
+ * @return A list of intents that may be provided by this type
+ */
+ List<Intent> getMayProvidedIntents();
+ /**
+ * 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/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Policy.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java
index c6393e2ada..d142015f57 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Policy.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java
@@ -1,33 +1,27 @@
-/*
- * 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 javax.xml.namespace.QName;
-
-/**
- * Interface that will abstract various types of policy specifications
- * and attachments for example WS-Policy
- *
- * @version $Rev$ $Date$
- */
-public interface Policy {
- QName getSchemaName();
- void setUnresolved(boolean unresolved);
- boolean isUnresolved();
-}
+/*
+ * 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;
+
+
+/**
+ * Definition of an implementation type which extends from sca:implementation
+ */
+public interface ImplementationType extends ExtensionType {
+}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Intent.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Intent.java
index 22f328f643..78ce04e9c9 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Intent.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Intent.java
@@ -29,6 +29,9 @@ import javax.xml.namespace.QName;
* @version $Rev$ $Date$
*/
public interface Intent {
+ enum Type {
+ interaction, implementation
+ };
/**
* Returns the intent name.
@@ -45,45 +48,72 @@ public interface Intent {
void setName(QName name);
/**
- * Get the intent domain (the root intent name before any qualifiers)
- * @return the domain
+ * Returns the list of SCA constructs that this intent is meant to
+ * configure.
+ *
+ * @return the list of SCA constructs that this intent is meant to configure
*/
- String getDomain();
+ List<ExtensionType> getConstrainedTypes();
/**
- * Get the intent qualifiers
- * @return the domain
+ * Return a list of required intents
+ * @return The list of required intents
*/
- String[] getQualifiedNames();
+ List<Intent> getRequiredIntents();
/**
- * Returns the list of operations that this intent applies to.
+ * Returns the list of intents which are mutually exclusive with this intent.
*
- * @return
+ * @return the list of mutually exclusive intents.
*/
- //List<Operation> getOperations();
+ List<Intent> getExcludedIntents();
/**
- * Returns the list of SCA constructs that this intent is meant to
- * configure.
+ * Returns the list of qualified intents.
*
- * @return the list of SCA constructs that this intent is meant to configure
+ * @return the list of qualified intents.
*/
- List<QName> getConstrains();
+ List<Intent> getQualifiedIntents();
/**
- * Returns the list of intents which are mutually exclusive with this intent.
+ * Get the default qualified intent
*
- * @return the list of mutually exclusive intents.
+ * @return
*/
- List<Intent> getExcludedIntents();
+ Intent getDefaultQualifiedIntent();
/**
- * Returns the list of children qualified intents.
+ * Set the default qualified intent
*
- * @return the list of children qualified intents.
+ * @param qualifiedIntent
*/
- List<Intent> getQualifiedIntents();
+ void setDefaultQualifiedIntent(Intent qualifiedIntent);
+
+ /**
+ * Get the intent type: Interaction or Implementation
+ * @return
+ */
+ Type getType();
+
+ /**
+ * Set the intent type
+ * @param type: Interaction or Implementation
+ */
+ void setType(Type type);
+
+ /**
+ * If this attribute is present and has a value of true it indicates that
+ * the qualified intents defined for this intent are mutually exclusive
+ *
+ * @return
+ */
+ boolean isMutuallyExclusive();
+
+ /**
+ * Set the value of mutuallyExclusive
+ * @param mutuallyExclusive
+ */
+ void setMutuallyExclusive(boolean mutuallyExclusive);
/**
* Returns the intent description.
@@ -104,6 +134,20 @@ public interface Intent {
*
* @return true if the model element is unresolved.
*/
+
+ /**
+ * Get the parent intent for a qualified intent. If an intent is not qualified,
+ * return null.
+ * @return The parent intent or null if this intent is not qualified
+ */
+ Intent getParent();
+
+ /**
+ * Set the parent intent for a qualified intent
+ * @param intent
+ */
+ void setParent(Intent intent);
+
boolean isUnresolved();
/**
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentAttachPointTypeFactory.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentAttachPointTypeFactory.java
deleted file mode 100644
index ee67006875..0000000000
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentAttachPointTypeFactory.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.policy;
-
-/**
- * Factory interface for creating extension types meta data
- *
- * @version $Rev$ $Date$
- */
-public interface IntentAttachPointTypeFactory {
-
- /**
- * Creates an ImplementationTypeImpl instance to hold metadata related to
- * a particular implementation extension in the SCA Domain
- *
- * @return an instance of IntentAttachPointType
- */
- IntentAttachPointType createImplementationType();
-
- /**
- * Creates an BindingTypeImpl instance to hold metadata related to
- * a particular binding extension in the SCA Domain
- *
- * @return an instance of IntentAttachPointType
- */
- IntentAttachPointType createBindingType();
-}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java
index 1b225bc918..efed4bfdb1 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java
@@ -16,18 +16,18 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package org.apache.tuscany.sca.policy;
import java.util.List;
+import org.apache.tuscany.sca.policy.Intent;
+
+
/**
- * Represents a policy intent map. See the Policy Framework specification for a
- * description of this element.
- *
- * @version $Rev$ $Date$
+ * Map policies to the qualified intents
*/
public interface IntentMap {
-
/**
* Returns the intent realized by this intent map.
*
@@ -41,49 +41,11 @@ public interface IntentMap {
* @param providedIntent the intent realized by this intent map
*/
void setProvidedIntent(Intent providedIntent);
-
- /**
- * Returns the default qualified intent map.
- *
- * @return the default qualified intent map
- */
- IntentMap getDefaultQualifiedIntentMap();
-
- /**
- * Sets the default qualified intent map.
- *
- * @param defaultQualifiedIntentMap the default qualified intent map
- */
- void setDefaultQualifiedIntentMap(IntentMap defaultQualifiedIntentMap);
-
+
/**
- * Returns the list of children qualified intent maps.
+ * Get a list of qualifiers
*
- * @return
+ * @return A list of qualifiers
*/
- List<IntentMap> getQualifiedIntentMaps();
-
- /**
- * Returns the list of concrete policies, either WS-Policy policy
- * attachments, policy references, or policies expressed in another policy
- * language.
- *
- * @return the list of concrete policies
- */
- List<Object> getPolicies();
-
- /**
- * 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);
-
+ List<Qualifier> getQualifiers();
}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ProfileIntent.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java
index 28ff9d09d3..ee4f5b5236 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ProfileIntent.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java
@@ -1,36 +1,31 @@
-/*
- * 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;
-
-/**
- * Interface that abstracts a profile intent
- *
- * @version $Rev$ $Date$
- */
-public interface ProfileIntent extends Intent {
- /**
- * Returns the list of required intents.
- *
- * @return the list of required intents
- */
- List<Intent> getRequiredIntents();
-
-}
+/*
+ * 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;
+
+/**
+ * Attach a policySet to a collection of policy subjects
+ */
+public interface PolicyAttachment {
+ PolicySet getPolicySet();
+ void setPolicySet(PolicySet policySet);
+ List<PolicySubject> getPolicySubjects();
+}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyContext.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyContext.java
deleted file mode 100644
index 65c39803d2..0000000000
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyContext.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.policy;
-
-import java.util.List;
-
-/**
- * A context container for policies.
- *
- * @version $Rev$ $Date$
- */
-public interface PolicyContext {
- List<Intent> getIntents(Object key);
- List<PolicySet> getPolicySets(Object key);
- void addIntents(Object key, List<Intent> intents);
- void addPolicySets(Object key, List<PolicySet> policySets);
- void addIntent(Object key, Intent intent);
- void addPolicySet(Object key, PolicySet policySet);
- void clearIntents(Object key);
- void clearPolicySets(Object key);
-}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySetReference.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java
index caa0d04fe3..a29f214f98 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySetReference.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java
@@ -1,43 +1,65 @@
-/*
- * 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 javax.xml.namespace.QName;
-
-/**
- * Interface that abstracts a PolicySet Reference
- *
- * @version $Rev$ $Date$
- */
-public interface PolicySetReference {
-
- /**
- * Returns the name of the policyset being referred to
- *
- * @return the QName of the referred policyset
- */
- QName getReferredPolicySetName();
-
- /**
- * @param refPolicySetName the name of the policyset being referred to
- *
- */
- void setReferredPolicySetName(QName refPolicySetName);
-
-}
+/*
+ * 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 javax.xml.namespace.QName;
+
+/**
+ * Interface that will abstract various types of policy specifications
+ * and attachments for example WS-Policy
+ *
+ * @version $Rev$ $Date$
+ */
+public interface PolicyExpression {
+ /**
+ * Get the QName of the policy expression
+ * @return the QName of the policy expression
+ */
+ QName getName();
+
+ /**
+ * Set the QName of the policy expression
+ * @param name
+ */
+ void setName(QName name);
+
+ /**
+ * Get the policy definition in the type of the specific domain
+ * @return
+ */
+ <T> T getPolicy();
+
+ /**
+ * Set the policy definition
+ * @param expression
+ */
+ <T> void setPolicy(T policy);
+
+ /**
+ *
+ * @param unresolved
+ */
+ void setUnresolved(boolean unresolved);
+
+ /**
+ *
+ * @return
+ */
+ boolean isUnresolved();
+}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java
index 49bcbae1ae..9e7de2f6da 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java
@@ -47,23 +47,20 @@ public interface PolicyFactory {
IntentMap createIntentMap();
/**
- * create a new Profile Intent
+ * create a new Qualifier
*
- * @return a ProfileIntent instance
+ * @return a Qualifier
*/
- ProfileIntent createProfileIntent();
+ Qualifier createQualifier();
/**
- * create a new QualifiedIntent
- *
- * @return a QualifiedIntent instance
+ * Create a new PolicyExpression
+ * @return
*/
- QualifiedIntent createQualifiedIntent();
+ PolicyExpression createPolicyExpression();
- /**
- * create a new PolicySetReference
- *
- * @return a PolicySetReference instance
- */
- PolicySetReference createPolicySetReference();
+ ExtensionType createExtensionType();
+ BindingType createBindingType();
+ ImplementationType createImplementationType();
+
}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySetAttachPoint.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyResolver.java
index f4156fc2e6..b04641bdf5 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySetAttachPoint.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyResolver.java
@@ -16,33 +16,38 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package org.apache.tuscany.sca.policy;
import java.util.List;
/**
- * Base interface for all assembly model objects that can have policy sets
- * attached to them.
- *
- * @version $Rev$ $Date$
+ *
*/
-public interface PolicySetAttachPoint extends IntentAttachPoint {
+public interface PolicyResolver {
+ /**
+ * Attach a policySet to a given policy subject
+ * @param policySet
+ * @param policySubject
+ * @return
+ */
+ PolicyAttachment attach(PolicySet policySet, PolicySubject policySubject);
/**
- * Returns a list of policy sets. See the Policy Framework specification for
- * a description of this attribute.
- *
- * @return a list of policy sets.
+ * Apply the policySet against the SCA domain composite to
+ * @param policySet
+ * @param domainComposite
+ * @return
*/
- List<PolicySet> getPolicySets();
-
-
+ List<PolicyAttachment> apply(PolicySet policySet, PolicySubject domainComposite);
+
/**
- * Returns a list of policy sets defined in the domain, that are applicable to this
- * PolicySetAttachPoint. An applicable PolicySet is one that include this PolicySetAttachPoint
- * as part of its 'appliesTo' XPath attribute.
- *
- * @return a list of policy sets applicable to this PolicySetAttachPoint
+ * Calculate a list of effective policies for a given policy subject
+ * @param policySubject
+ * @return
*/
- List<PolicySet> getApplicablePolicySets();
+ List<PolicyExpression> getEffectivePolicies(PolicySubject policySubject);
+
+ boolean isIntentProvidedBy(PolicySet policySet, Intent intent);
+ List<PolicyExpression> getPolicies(Intent intent);
}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java
index b16072c214..2b5b8458d5 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java
@@ -19,7 +19,6 @@
package org.apache.tuscany.sca.policy;
import java.util.List;
-import java.util.Map;
import javax.xml.namespace.QName;
import javax.xml.xpath.XPathExpression;
@@ -47,12 +46,6 @@ public interface PolicySet {
void setName(QName name);
/**
- * Returns the list of operations that this policy set applies to.
- *
- * @return
- */
- //List<Operation> getOperations();
- /**
* Returns the list of
*
* @return
@@ -73,7 +66,7 @@ public interface PolicySet {
*
* @return the list of concrete policies
*/
- List<Object> getPolicies();
+ List<PolicyExpression> getPolicies();
/**
* Returns true if the model element is unresolved.
@@ -91,7 +84,7 @@ public interface PolicySet {
/**
* Returns the XPath expression that is to be used to evaluate
- * if this PolicySet applies to specific attachment point
+ * if this PolicySet applies to specific policy subject
*
* @return the XPath expression
*/
@@ -99,35 +92,45 @@ public interface PolicySet {
/**
* Sets the XPath expression that is to be used to evaluate
- * if this PolicySet applies to specific attachment point
+ * if this PolicySet applies to specific policy subject
*
*/
void setAppliesTo(String xpath);
-
+
/**
- * Returns the policies / policy attachments provided thro intent maps
+ * A string which is an XPath 1.0 expression identifying one or more
+ * elements (policy subject) in the Domain. It is used to declare which
+ * set of elements the policySet is actually attached to.
*
+ * @return The attachTo XPath
+ */
+ String getAttachTo();
+
+ /**
+ * Set the attachTo XPath
+ * @param xpath
+ */
+ void setAttachTo(String xpath);
+
+ /**
+ * Get the resolved XPathExpression for attachTo
* @return
*/
- Map<Intent, List<Object>> getMappedPolicies();
-
+ XPathExpression getAttachToXPathExpression();
+
/**
- * Gets the XPath expression that is to be used to evaluate
- * the SCA Artifacts that this policyset will always apply to
- * immaterial of an intent declared on the SCA Artifact
- *
- * @return the XPath expression
+ * Set the resolved XPathExpression for attachTo
+ * @param expression
*/
- String getAlwaysAppliesTo();
+ void setAttachToXPathExpression(XPathExpression expression);
/**
- * Sets the XPath expression that is to be used to evaluate
- * the SCA Artifacts that this policyset will always apply to
- * immaterial of an intent declared on the SCA Artifact
+ * Returns the policies / policy attachments provided thro intent maps
*
+ * @return
*/
- void setAlwaysAppliesTo(String xpath);
-
+ List<IntentMap> getIntentMaps();
+
/**
* Get the XPath expression for the appliesTo attribute
* @return the XPath expression for the appliesTo attribute
@@ -140,16 +143,4 @@ public interface PolicySet {
*/
void setAppliesToXPathExpression(XPathExpression xpathExpression);
- /**
- * Get the XPath expression for the alwaysAppliesTo attribute
- * @return the XPath expression for the alwaysAppliesTo attribute
- */
- XPathExpression getAlwaysAppliesToXPathExpression();
-
- /**
- * Set the XPath expression for the alwaysAppliesTo attribute
- * @param xpathExpression the XPath expression for the alwaysAppliesTo attribute
- */
- void setAlwaysAppliesToXPathExpression(XPathExpression xpathExpression);
-
}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentAttachPoint.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java
index bf2cfca924..41847bad79 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentAttachPoint.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java
@@ -16,37 +16,41 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package org.apache.tuscany.sca.policy;
import java.util.List;
/**
- * Base interface for all assembly model objects that can be have policy intents
- * attached to them.
- *
- * @version $Rev$ $Date$
+ * A policy subject is an entity in the assembly with which a policy can be
+ * associated.
+ *
+ * For example, a policy subject can be one of the following:
+ * <ul>
+ * <li>composite
+ * <li>component
+ * <li>implementation
+ * <li>service
+ * <li>reference
+ * <li>binding
+ * <li>interface
+ * </ul>
*/
-public interface IntentAttachPoint {
-
+public interface PolicySubject {
/**
- * Returns a list of policy intents. See the Policy Framework specification
- * for a description of this attribute.
+ * Get a list of required intents
*
- * @return a list of policy intents.
- */
- List<Intent> getRequiredIntents();
-
-
- /**
- * Returns the type of the attach point such as a BindingType or an ImplementationType and so on
* @return
*/
- IntentAttachPointType getType();
-
+ List<Intent> getRequiredIntents();
+
/**
+ * Get a list of attached policySets
*
- * Sets the type of the attach point such as a BindingType or an ImplementationType and so on
- * @param type
+ * @return A list of policySets
*/
- void setType(IntentAttachPointType type);
+ List<PolicySet> getPolicySets();
+
+ ExtensionType getType();
+ void setType(ExtensionType type);
}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/QualifiedIntent.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java
index 0f43221dd6..c1862283c7 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/QualifiedIntent.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java
@@ -1,41 +1,44 @@
-/*
- * 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;
-
-/**
- * Abstracts a qualified policy intent
- *
- * @version $Rev$ $Date$
- */
-public interface QualifiedIntent extends Intent {
-
- /**
- * Returns the intent qualified by this intent
- *
- * @return
- */
- Intent getQualifiableIntent();
-
- /**
- * sets the qualifiable intent for this Qualified intent instance
- *
- * @param qualifiableIntent
- */
- void setQualifiableIntent(Intent qualifiableIntent);
-}
+/*
+ * 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 qualifier provides a list of policies for a qualified intent within the IntentMap
+ */
+public interface Qualifier {
+ /**
+ * Get the qualified intent for this qualifier
+ * @return The intent
+ */
+ Intent getIntent();
+
+ /**
+ * Set the qualified intent for this qualifier
+ */
+ void setIntent(Intent intent);
+
+ /**
+ * Get the list of policies provided by this qualifier
+ * @return A list of policies
+ */
+ List<PolicyExpression> getPolicies();
+}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java
index 0f8b1ae00a..53c6684d11 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java
@@ -18,73 +18,21 @@
*/
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.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.BindingType;
/**
* Concrete implementation for a BindingType
*
* @version $Rev$ $Date$
*/
-public class BindingTypeImpl implements IntentAttachPointType {
-
- private List<Intent> alwaysProvides = new ArrayList<Intent>();
- private List<Intent> mayProvides = new ArrayList<Intent>();
- private QName typeName;
- private boolean unResolved = true;
-
- public List<Intent> getAlwaysProvidedIntents() {
- return alwaysProvides;
- }
-
- public List<Intent> getMayProvideIntents() {
- return mayProvides;
- }
-
- public QName getName() {
- return typeName;
+public class BindingTypeImpl extends ExtensionTypeImpl implements BindingType {
+ protected BindingTypeImpl() {
+ super();
}
- public void setName(QName type) {
- this.typeName = type;
- }
-
- public boolean isUnresolved() {
- return unResolved;
- }
-
- public void setUnresolved(boolean unresolved) {
- this.unResolved = unresolved;
- }
-
- @Override
- public int hashCode() {
- return String.valueOf(getName()).hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- } else if (obj instanceof BindingTypeImpl ) {
- if (getName() != null) {
- return getName().equals(((BindingTypeImpl)obj).getName());
- } else {
- return ((BindingTypeImpl)obj).getName() == null;
- }
- } else {
- return false;
- }
- }
-
- @Override
- public String toString() {
- return ( this.typeName != null ) ? getName().toString() : "null";
+ public QName getBaseType() {
+ return BINDING_BASE;
}
}
-; \ No newline at end of file
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java
new file mode 100644
index 0000000000..97fbc19ced
--- /dev/null
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java
@@ -0,0 +1,97 @@
+/*
+ * 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.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+
+/**
+ * Concrete implementation for a BindingType
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExtensionTypeImpl implements ExtensionType {
+
+ private List<Intent> alwaysProvides = new ArrayList<Intent>();
+ private List<Intent> mayProvide = new ArrayList<Intent>();
+ private QName typeName;
+ private boolean unResolved = true;
+
+ protected ExtensionTypeImpl() {
+
+ }
+
+ public List<Intent> getAlwaysProvidedIntents() {
+ return alwaysProvides;
+ }
+
+ public List<Intent> getMayProvidedIntents() {
+ return mayProvide;
+ }
+
+ public QName getType() {
+ return typeName;
+ }
+
+ public void setType(QName type) {
+ this.typeName = type;
+ }
+
+ public boolean isUnresolved() {
+ return unResolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unResolved = unresolved;
+ }
+
+ @Override
+ public int hashCode() {
+ return String.valueOf(getType()).hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else if (obj instanceof ExtensionTypeImpl) {
+ if (getType() != null) {
+ return getType().equals(((ExtensionTypeImpl)obj).getType());
+ } else {
+ return ((ExtensionTypeImpl)obj).getType() == null;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return (this.typeName != null) ? getType().toString() : "null";
+ }
+
+ public QName getBaseType() {
+ return null;
+ }
+};
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java
index 7861fd79f9..169ca29833 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java
@@ -18,71 +18,22 @@
*/
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.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.ImplementationType;
/**
* Concrete implementation for a Implementation Type
*
* @version $Rev$ $Date$
*/
-public class ImplementationTypeImpl implements IntentAttachPointType {
- private List<Intent> alwaysProvides = new ArrayList<Intent>();
- private List<Intent> mayProvides = new ArrayList<Intent>();
- private QName typeName;
- private boolean unResolved = true;
-
- public List<Intent> getAlwaysProvidedIntents() {
- return alwaysProvides;
- }
-
- public List<Intent> getMayProvideIntents() {
- return mayProvides;
- }
-
- public QName getName() {
- return typeName;
+public class ImplementationTypeImpl extends ExtensionTypeImpl implements ImplementationType {
+ protected ImplementationTypeImpl() {
+ super();
}
- public void setName(QName type) {
- this.typeName = type;
- }
-
- public boolean isUnresolved() {
- return unResolved;
+ public QName getBaseType() {
+ return IMPLEMENTATION_BASE;
}
- public void setUnresolved(boolean unresolved) {
- this.unResolved = unresolved;
- }
-
- @Override
- public int hashCode() {
- return String.valueOf(getName()).hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- } else if (obj instanceof ImplementationTypeImpl ) {
- if (getName() != null) {
- return getName().equals(((ImplementationTypeImpl)obj).getName());
- } else {
- return ((ImplementationTypeImpl)obj).getName() == null;
- }
- } else {
- return false;
- }
- }
-
- @Override
- public String toString() {
- return ( this.typeName != null ) ? getName().toString() : "null";
- }
}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentAttachPointTypeFactoryImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentAttachPointTypeFactoryImpl.java
deleted file mode 100644
index aa6e27c240..0000000000
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentAttachPointTypeFactoryImpl.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.policy.impl;
-
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
-import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
-
-/**
- * Default implementation for IntentAttachPointTypeFactory
- *
- * @version $Rev$ $Date$
- */
-public class IntentAttachPointTypeFactoryImpl implements IntentAttachPointTypeFactory {
-
- public IntentAttachPointType createBindingType() {
- return new BindingTypeImpl();
- }
-
- public IntentAttachPointType createImplementationType() {
- return new ImplementationTypeImpl();
- }
-
-}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java
index 2d6bd0eb6f..3c87c78af9 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java
@@ -23,6 +23,7 @@ import java.util.List;
import javax.xml.namespace.QName;
+import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.Intent;
/**
@@ -32,18 +33,17 @@ import org.apache.tuscany.sca.policy.Intent;
*/
public class IntentImpl implements Intent {
- private static final String QUALIFIED_SEPARATOR = ".";
- private static final String DOMAIN_SEPARATOR = ".";
private QName name;
- //private List<Operation> operations = new ArrayList<Operation>();
- private List<QName> constrains = new ArrayList<QName>();
+ private Type type;
+ private List<ExtensionType> constrainedTypes = new ArrayList<ExtensionType>();
private String description;
private List<Intent> qualifiedIntents = new ArrayList<Intent>();
- // private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private Intent defaultQualifiedIntent;
+ private Intent parent;
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
private List<Intent> excludedIntents = new ArrayList<Intent>();
+ private boolean mutuallyExclusive;
private boolean unresolved = true;
- private String domain;
- private String[] qualifiedNames;
protected IntentImpl() {
}
@@ -54,33 +54,14 @@ public class IntentImpl implements Intent {
public void setName(QName name) {
this.name = name;
- String iname = name.getLocalPart();
- int domainIdx = iname.indexOf(DOMAIN_SEPARATOR);
- if (domainIdx > -1) {
- domain = iname.substring(0, domainIdx);
- String qualifNamesStr = iname.substring(domainIdx + 1);
- String pattern = "\\" + QUALIFIED_SEPARATOR;
- qualifiedNames = qualifNamesStr.split(pattern);
- } else
- domain = iname;
}
- public String getDomain() {
- return domain;
+ public List<ExtensionType> getConstrainedTypes() {
+ return constrainedTypes;
}
- public String[] getQualifiedNames() {
- String[] results = new String[qualifiedNames.length];
- System.arraycopy(qualifiedNames, 0, results, 0, qualifiedNames.length);
- return results;
- }
-
- /*public List<Operation> getOperations() {
- return operations;
- }*/
-
- public List<QName> getConstrains() {
- return constrains;
+ public void setConstrainedTypes(List<ExtensionType> constrainedTypes) {
+ this.constrainedTypes = constrainedTypes;
}
public String getDescription() {
@@ -91,14 +72,38 @@ public class IntentImpl implements Intent {
this.description = description;
}
+ public Intent getParent() {
+ return parent;
+ }
+
+ public void setParent(Intent parent) {
+ this.parent = parent;
+ }
+
public List<Intent> getQualifiedIntents() {
return qualifiedIntents;
}
+ public void setQualifiedIntents(List<Intent> qualifiedIntents) {
+ this.qualifiedIntents = qualifiedIntents;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public void setRequiredIntents(List<Intent> requiredIntents) {
+ this.requiredIntents = requiredIntents;
+ }
+
public List<Intent> getExcludedIntents() {
return excludedIntents;
}
+ public void setExcludedIntents(List<Intent> excludedIntents) {
+ this.excludedIntents = excludedIntents;
+ }
+
public boolean isUnresolved() {
return unresolved;
}
@@ -107,45 +112,57 @@ public class IntentImpl implements Intent {
this.unresolved = unresolved;
}
- /**
- * @see java.lang.Object#hashCode()
- */
+ public Type getType() {
+ return type;
+ }
+
+ public void setType(Type type) {
+ this.type = type;
+ }
+
+ public boolean isMutuallyExclusive() {
+ return mutuallyExclusive;
+ }
+
+ public void setMutuallyExclusive(boolean mutuallyExclusive) {
+ this.mutuallyExclusive = mutuallyExclusive;
+ }
+
+ public Intent getDefaultQualifiedIntent() {
+ return defaultQualifiedIntent;
+ }
+
+ public void setDefaultQualifiedIntent(Intent defaultQualifiedIntent) {
+ this.defaultQualifiedIntent = defaultQualifiedIntent;
+ }
+
+
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
- QName intentName = getName();
- result = prime * result + ((intentName == null) ? 0 : intentName.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
- /**
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(Object obj) {
- if (this == obj) {
+ if (this == obj)
return true;
- }
- if (obj == null) {
+ if (obj == null)
return false;
- }
- if (!(obj instanceof IntentImpl)) {
+ if (getClass() != obj.getClass())
return false;
- }
- final IntentImpl other = (IntentImpl)obj;
- if (getName() == null) {
- if (other.getName() != null) {
+ IntentImpl other = (IntentImpl)obj;
+ if (name == null) {
+ if (other.name != null)
return false;
- }
- } else if (!getName().equals(other.getName())) {
+ } else if (!name.equals(other.name))
return false;
- }
return true;
}
-
- @Override
+
public String toString() {
- return String.valueOf(getName());
+ return String.valueOf(name);
}
}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java
index aab03281ba..6e2941ff5c 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java
@@ -18,10 +18,12 @@
*/
package org.apache.tuscany.sca.policy.impl;
+import java.util.ArrayList;
import java.util.List;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.Qualifier;
/**
* Represents an intent map.
@@ -31,43 +33,29 @@ import org.apache.tuscany.sca.policy.IntentMap;
public class IntentMapImpl implements IntentMap {
private boolean unresolved;
- private IntentMap defaultQualifiedIntentMap;
- private List<Object> policies;
private Intent providedIntent;
- private List<IntentMap> qualifiedIntentMaps;
+ private List<Qualifier> qualifiers = new ArrayList<Qualifier>();
protected IntentMapImpl() {
}
- public IntentMap getDefaultQualifiedIntentMap() {
- return defaultQualifiedIntentMap;
+ public boolean isUnresolved() {
+ return unresolved;
}
- public List<Object> getPolicies() {
- return policies;
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
}
public Intent getProvidedIntent() {
return providedIntent;
}
- public List<IntentMap> getQualifiedIntentMaps() {
- return qualifiedIntentMaps;
- }
-
- public void setDefaultQualifiedIntentMap(IntentMap defaultQualifiedIntentMap) {
- this.defaultQualifiedIntentMap = defaultQualifiedIntentMap;
- }
-
public void setProvidedIntent(Intent providedIntent) {
this.providedIntent = providedIntent;
}
- public boolean isUnresolved() {
- return unresolved;
- }
-
- public void setUnresolved(boolean unresolved) {
- this.unresolved = unresolved;
+ public List<Qualifier> getQualifiers() {
+ return qualifiers;
}
}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyContextImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyContextImpl.java
deleted file mode 100644
index a0e2f10f56..0000000000
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyContextImpl.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.policy.impl;
-
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.PolicyContext;
-import org.apache.tuscany.sca.policy.PolicySet;
-
-/**
- *
- * @version $Rev$ $Date$
- */
-public class PolicyContextImpl implements PolicyContext {
- private Map<Object, List<Intent>> intents = new Hashtable<Object , List<Intent>>();
- private Map<Object, List<PolicySet>> policySets = new Hashtable<Object, List<PolicySet>>();
-
- public void addIntent(Object key, Intent intent) {
- if ( intents.get(key) == null ) {
- intents.put(key, new ArrayList<Intent>());
- }
- intents.get(key).add(intent);
- }
-
- public void addIntents(Object key, List<Intent> intents) {
- if ( this.intents.get(key) == null ) {
- this.intents.put(key, new ArrayList<Intent>());
- }
- this.intents.get(key).addAll(intents);
- }
-
- public void addPolicySet(Object key, PolicySet policySet) {
- if ( policySets.get(key) == null ) {
- policySets.put(key, new ArrayList<PolicySet>());
- }
- policySets.get(key).add(policySet);
- }
-
- public void addPolicySets(Object key, List<PolicySet> policySets) {
- if ( this.policySets.get(key) == null ) {
- this.policySets.put(key, new ArrayList<PolicySet>());
- }
- this.policySets.get(key).addAll(policySets);
- }
-
- public List<Intent> getIntents(Object key) {
- if ( intents.get(key) == null ) {
- intents.put(key, new ArrayList<Intent>());
- }
- return intents.get(key);
- }
-
- public List<PolicySet> getPolicySets(Object key) {
- if ( policySets.get(key) == null ) {
- policySets.put(key, new ArrayList<PolicySet>());
- }
- return policySets.get(key);
- }
-
- public void clearIntents(Object key) {
- if ( intents.get(key) != null ) {
- intents.clear();
- }
- }
-
- public void clearPolicySets(Object key) {
- if ( policySets.get(key) != null ) {
- policySets.clear();
- }
- }
-
-}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java
new file mode 100644
index 0000000000..71e5eef6a7
--- /dev/null
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java
@@ -0,0 +1,86 @@
+/*
+ * 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 javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.PolicyExpression;
+
+public class PolicyExpressionImpl implements PolicyExpression {
+ private QName name;
+ private Object policy;
+ private boolean unresolved = true;
+
+ protected PolicyExpressionImpl() {
+ }
+
+ public QName getName() {
+ return name;
+ }
+
+ public <T> T getPolicy() {
+ return (T)policy;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setName(QName name) {
+ this.name = name;
+ }
+
+ public <T> void setPolicy(T policy) {
+ this.policy = policy;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public String toString() {
+ return String.valueOf(name);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ PolicyExpressionImpl other = (PolicyExpressionImpl)obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java
index 1db29b835e..c67ff1eab8 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java
@@ -18,13 +18,15 @@
*/
package org.apache.tuscany.sca.policy.impl;
+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.PolicyExpression;
import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetReference;
-import org.apache.tuscany.sca.policy.ProfileIntent;
-import org.apache.tuscany.sca.policy.QualifiedIntent;
+import org.apache.tuscany.sca.policy.Qualifier;
/**
* A factory for the policy model.
@@ -37,10 +39,6 @@ public abstract class PolicyFactoryImpl implements PolicyFactory {
return new IntentImpl();
}
- public PolicySetReference createPolicySetReference() {
- return new PolicySetReferenceImpl();
- }
-
public PolicySet createPolicySet() {
return new PolicySetImpl();
}
@@ -49,12 +47,24 @@ public abstract class PolicyFactoryImpl implements PolicyFactory {
return new IntentMapImpl();
}
- public ProfileIntent createProfileIntent() {
- return new ProfileIntentImpl();
+ public Qualifier createQualifier() {
+ return new QualifierImpl();
+ }
+
+ public PolicyExpression createPolicyExpression() {
+ return new PolicyExpressionImpl();
+ }
+
+ public BindingType createBindingType() {
+ return new BindingTypeImpl();
+ }
+
+ public ImplementationType createImplementationType() {
+ return new ImplementationTypeImpl();
}
- public QualifiedIntent createQualifiedIntent() {
- return new QualifiedIntentImpl();
+ public ExtensionType createExtensionType() {
+ return new ExtensionTypeImpl();
}
}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java
index 179a10cc1a..75d1229cd8 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java
@@ -19,14 +19,14 @@
package org.apache.tuscany.sca.policy.impl;
import java.util.ArrayList;
-import java.util.Hashtable;
import java.util.List;
-import java.util.Map;
import javax.xml.namespace.QName;
import javax.xml.xpath.XPathExpression;
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.PolicySet;
/**
@@ -37,29 +37,17 @@ import org.apache.tuscany.sca.policy.PolicySet;
public class PolicySetImpl implements PolicySet {
private QName name;
- //private List<Operation> operations = new ArrayList<Operation>();
- //private List<QName> appliesTo;
private String appliesTo;
+ private String attachTo;
private List<Intent> providedIntents = new ArrayList<Intent>();
private List<PolicySet> referencedPolicySets = new ArrayList<PolicySet>();
- private List<Object> policies = new ArrayList<Object>();
- Map<Intent, List<Object>> mappedPolicies = new Hashtable<Intent, List<Object>>();
private boolean unresolved = true;
- private String alwaysAppliesTo;
-
- private XPathExpression appliesToXPathExpression;
- private XPathExpression alwaysAppliesToXPathExpression;
-
- public String getAlwaysAppliesTo() {
- return alwaysAppliesTo;
- }
- public void setAlwaysAppliesTo(String alwaysAppliesTo) {
- this.alwaysAppliesTo = alwaysAppliesTo;
- }
+ private XPathExpression appliesToXPathExpression;
+ private XPathExpression attachToXPathExpression;
- protected PolicySetImpl() {
- }
+ private List<IntentMap> intentMaps = new ArrayList<IntentMap>();
+ private List<PolicyExpression> policies = new ArrayList<PolicyExpression>();
public QName getName() {
return name;
@@ -69,10 +57,6 @@ public class PolicySetImpl implements PolicySet {
this.name = name;
}
- /*public List<Operation> getOperations() {
- return operations;
- }*/
-
public String getAppliesTo() {
return appliesTo;
}
@@ -81,16 +65,12 @@ public class PolicySetImpl implements PolicySet {
this.appliesTo = appliesTo;
}
- public List<Intent> getProvidedIntents() {
- return providedIntents;
- }
-
- public List<PolicySet> getReferencedPolicySets() {
- return referencedPolicySets;
+ public String getAttachTo() {
+ return attachTo;
}
- public List<Object> getPolicies() {
- return policies;
+ public void setAttachTo(String attachTo) {
+ this.attachTo = attachTo;
}
public boolean isUnresolved() {
@@ -101,49 +81,65 @@ public class PolicySetImpl implements PolicySet {
this.unresolved = unresolved;
}
- public Map<Intent, List<Object>> getMappedPolicies() {
- return mappedPolicies;
+ public XPathExpression getAppliesToXPathExpression() {
+ return appliesToXPathExpression;
}
-
- @Override
- public int hashCode() {
- return String.valueOf(getName()).hashCode();
+
+ public void setAppliesToXPathExpression(XPathExpression appliesToXPathExpression) {
+ this.appliesToXPathExpression = appliesToXPathExpression;
}
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- } else if (obj instanceof PolicySet) {
- if (getName() != null) {
- return getName().equals(((PolicySet)obj).getName());
- } else {
- return ((PolicySet)obj).getName() == null;
- }
- } else {
- return false;
- }
+
+ public XPathExpression getAttachToXPathExpression() {
+ return attachToXPathExpression;
}
-
- @Override
- public String toString() {
- return ( this.name != null ) ? getName().toString() : "null";
+
+ public void setAttachToXPathExpression(XPathExpression attachToXPathExpression) {
+ this.attachToXPathExpression = attachToXPathExpression;
}
- public XPathExpression getAppliesToXPathExpression() {
- return appliesToXPathExpression;
+ public List<IntentMap> getIntentMaps() {
+ return intentMaps;
}
- public void setAppliesToXPathExpression(XPathExpression appliesToXPathExpression) {
- this.appliesToXPathExpression = appliesToXPathExpression;
+ public List<Intent> getProvidedIntents() {
+ return providedIntents;
+ }
+
+ public List<PolicySet> getReferencedPolicySets() {
+ return referencedPolicySets;
}
- public XPathExpression getAlwaysAppliesToXPathExpression() {
- return alwaysAppliesToXPathExpression;
+ public List<PolicyExpression> getPolicies() {
+ return policies;
+ }
+
+ public String toString() {
+ return String.valueOf(name);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
}
- public void setAlwaysAppliesToXPathExpression(XPathExpression alwaysAppliesToXPathExpression) {
- this.alwaysAppliesToXPathExpression = alwaysAppliesToXPathExpression;
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ PolicySetImpl other = (PolicySetImpl)obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
}
}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetReferenceImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetReferenceImpl.java
deleted file mode 100644
index 98a116fe7b..0000000000
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetReferenceImpl.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.policy.impl;
-
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.sca.policy.PolicySetReference;
-
-/**
- * Concrete implementation for a PolicySetReference
- *
- * @version $Rev$ $Date$
- */
-public class PolicySetReferenceImpl implements PolicySetReference {
-
- private QName referredPolicySetName = null;
-
- /*
- * @see org.apache.tuscany.sca.policy.PolicySetReference#getReferredPolicySetName()
- */
- public QName getReferredPolicySetName() {
- return referredPolicySetName;
- }
-
- /*
- * @see org.apache.tuscany.sca.policy.PolicySetReference#setReferredPolicySetName(javax.xml.namespace.QName)
- */
- public void setReferredPolicySetName(QName refPolicySetName) {
- referredPolicySetName = refPolicySetName;
- }
-
-}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/QualifiedIntentImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/QualifiedIntentImpl.java
deleted file mode 100644
index d6f65b1788..0000000000
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/QualifiedIntentImpl.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.policy.impl;
-
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.QualifiedIntent;
-
-/**
- * Models a concrete implementation of a Qualified Intent
- *
- * @version $Rev$ $Date$
- */
-public class QualifiedIntentImpl extends IntentImpl implements QualifiedIntent {
- private Intent qualifiableIntent = null;
-
- public Intent getQualifiableIntent() {
- return qualifiableIntent;
- }
-
- public void setQualifiableIntent(Intent qualifiableIntent) {
- this.qualifiableIntent = qualifiableIntent;
- }
-
- @Override
- public List<QName> getConstrains() {
- return getQualifiableIntent().getConstrains();
- }
-
-
-}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ProfileIntentImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java
index e5002d2cdc..102bea8d41 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ProfileIntentImpl.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java
@@ -1,39 +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.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.ProfileIntent;
-
-/**
- * Concrete implementation for Profile Intent
- *
- * @version $Rev$ $Date$
- */
-public class ProfileIntentImpl extends IntentImpl implements ProfileIntent {
- private List<Intent> requiredIntents = new ArrayList<Intent>();
-
- public List<Intent> getRequiredIntents() {
- return requiredIntents;
- }
-
-}
+/*
+ * 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 org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.Qualifier;
+
+public class QualifierImpl implements Qualifier {
+ private Intent intent;
+ private List<PolicyExpression> policies = new ArrayList<PolicyExpression>();
+
+ protected QualifierImpl() {
+ }
+
+ public Intent getIntent() {
+ return intent;
+ }
+
+ public List<PolicyExpression> getPolicies() {
+ return policies;
+ }
+
+ public void setIntent(Intent intent) {
+ this.intent = intent;
+ }
+
+}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java
index 2e4c6a9d78..077b71009f 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java
@@ -48,10 +48,9 @@ import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
+import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.ProfileIntent;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -66,9 +65,9 @@ public class PolicyComputationUtils {
private static final String POLICYSET_PREFIX = "tp_";
private static final String APPLICABLE_POLICYSET_ATTR_NS = "http://tuscany.apache.org/xmlns/sca/1.0";
private static final String APPLICABLE_POLICYSET_ATTR = "applicablePolicySets";
- private static final String POLICY_SETS_ATTR = "policySets";
+ private static final String POLICY_SETS_ATTR = "policySets";
private static final String APPLICABLE_POLICYSET_ATTR_PREFIX = "tuscany";
- private static final String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0";
+ private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200712";
/**
* This method unconditionally adds intents from the source list to the target list.
@@ -125,8 +124,7 @@ public class PolicyComputationUtils {
public static void addDefaultPolicies(List<Intent> sourceIntents,
List<PolicySet> sourcePolicySets,
List<Intent> targetIntents,
- List<PolicySet> targetPolicySets)
- {
+ List<PolicySet> targetPolicySets) {
// form a list of all intents required by the target
List<Intent> combinedTargetIntents = new ArrayList<Intent>();
combinedTargetIntents.addAll(findAndExpandProfileIntents(targetIntents));
@@ -167,14 +165,12 @@ public class PolicyComputationUtils {
}
- public static void checkForMutuallyExclusiveIntents(
- List<Intent> intents,
- List<PolicySet> policySets,
- IntentAttachPointType intentAttachPointType,
- String id) throws PolicyValidationException
- {
+ public static void checkForMutuallyExclusiveIntents(List<Intent> intents,
+ List<PolicySet> policySets,
+ ExtensionType intentAttachPointType,
+ String id) throws PolicyValidationException {
// gather all intents (keeping track of where they come from)
- Map<Intent, PolicySet> combinedIntents = new HashMap<Intent,PolicySet>();
+ Map<Intent, PolicySet> combinedIntents = new HashMap<Intent, PolicySet>();
for (PolicySet policySet : policySets) {
for (Intent providedIntent : findAndExpandProfileIntents(policySet.getProvidedIntents())) {
combinedIntents.put(providedIntent, policySet);
@@ -192,14 +188,21 @@ public class PolicyComputationUtils {
if (combinedIntents.get(intent) == null)
sIntent1 = intent.getName().toString();
else
- sIntent1 = intent.getName().toString() + " in policy set " + combinedIntents.get(intent).getName().toString();
+ sIntent1 =
+ intent.getName().toString() + " in policy set "
+ + combinedIntents.get(intent).getName().toString();
if (combinedIntents.get(excluded) == null)
sIntent2 = excluded.getName().toString();
else
- sIntent2 = excluded.getName().toString() + " in policy set " + combinedIntents.get(excluded).getName().toString();
- throw new PolicyValidationException(
- intentAttachPointType.getName() + " for " + id +
- " uses mutually-exclusive intents " + sIntent1 + " and " + sIntent2);
+ sIntent2 =
+ excluded.getName().toString() + " in policy set "
+ + combinedIntents.get(excluded).getName().toString();
+ throw new PolicyValidationException(intentAttachPointType.getType() + " for "
+ + id
+ + " uses mutually-exclusive intents "
+ + sIntent1
+ + " and "
+ + sIntent2);
}
}
}
@@ -207,7 +210,7 @@ public class PolicyComputationUtils {
public static void expandProfileIntents(List<Intent> intents) {
List<Intent> expandedIntents = null;
- if ( intents.size() > 0 ) {
+ if (intents.size() > 0) {
expandedIntents = findAndExpandProfileIntents(intents);
intents.clear();
intents.addAll(expandedIntents);
@@ -216,10 +219,9 @@ public class PolicyComputationUtils {
public static List<Intent> findAndExpandProfileIntents(List<Intent> intents) {
List<Intent> expandedIntents = new ArrayList<Intent>();
- for ( Intent intent : intents ) {
- if ( intent instanceof ProfileIntent ) {
- ProfileIntent profileIntent = (ProfileIntent)intent;
- List<Intent> requiredIntents = profileIntent.getRequiredIntents();
+ for (Intent intent : intents) {
+ if (!intent.getRequiredIntents().isEmpty()) {
+ List<Intent> requiredIntents = intent.getRequiredIntents();
expandedIntents.addAll(findAndExpandProfileIntents(requiredIntents));
} else {
expandedIntents.add(intent);
@@ -230,15 +232,11 @@ public class PolicyComputationUtils {
private static byte[] addApplicablePolicySets(Document doc, Collection<PolicySet> policySets)
throws XPathExpressionException, TransformerConfigurationException, TransformerException {
-
+
for (PolicySet policySet : policySets) {
if (policySet.getAppliesTo() != null) {
addApplicablePolicySets(policySet, doc);
}
-
- if (policySet.getAlwaysAppliesTo() != null) {
- addAlwaysApplicablePolicySets(policySet, doc);
- }
}
StringWriter sw = new StringWriter();
@@ -258,48 +256,11 @@ public class PolicyComputationUtils {
} catch (PrivilegedActionException e) {
throw (TransformerException)e.getException();
}
-
- return sw.toString().getBytes();
- }
-
- private static void addAlwaysApplicablePolicySets(PolicySet policySet,
- Document doc) throws XPathExpressionException {
- XPathExpression expression = policySet.getAlwaysAppliesToXPathExpression();
- NodeList result = (NodeList)expression.evaluate(doc, XPathConstants.NODESET);
-
- if (result != null) {
- for (int counter = 0; counter < result.getLength(); ++counter) {
- Node aResultNode = result.item(counter);
- String alwaysApplicablePolicySets = null;
-
- String policySetPrefix =
- declareNamespace((Element)aResultNode, policySet.getName().getNamespaceURI());
- String policySetsAttrPrefix =
- declareNamespace((Element)aResultNode, SCA10_NS);
- if (aResultNode.getAttributes().getNamedItem(POLICY_SETS_ATTR) != null) {
- alwaysApplicablePolicySets =
- aResultNode.getAttributes().getNamedItem(POLICY_SETS_ATTR).getNodeValue();
- }
-
- if (alwaysApplicablePolicySets != null && alwaysApplicablePolicySets.length() > 0) {
- alwaysApplicablePolicySets =
- alwaysApplicablePolicySets + " "
- + policySetPrefix
- + ":"
- + policySet.getName().getLocalPart();
- } else {
- alwaysApplicablePolicySets =
- policySetPrefix + ":" + policySet.getName().getLocalPart();
- }
-
- ((Element)aResultNode).setAttribute(POLICY_SETS_ATTR, alwaysApplicablePolicySets);
- }
- }
+ return sw.toString().getBytes();
}
- private static void addApplicablePolicySets(PolicySet policySet,
- Document doc) throws XPathExpressionException {
+ private static void addApplicablePolicySets(PolicySet policySet, Document doc) throws XPathExpressionException {
XPathExpression expression = policySet.getAppliesToXPathExpression();
NodeList result = (NodeList)expression.evaluate(doc, XPathConstants.NODESET);
@@ -309,46 +270,37 @@ public class PolicyComputationUtils {
String applicablePolicySets = null;
- String policySetPrefix =
- declareNamespace((Element)aResultNode, policySet.getName().getNamespaceURI());
- String appPolicyAttrPrefix =
- declareNamespace((Element)aResultNode,
- APPLICABLE_POLICYSET_ATTR_NS);
- if (aResultNode.getAttributes().getNamedItemNS(APPLICABLE_POLICYSET_ATTR_NS,
- APPLICABLE_POLICYSET_ATTR) != null) {
+ String policySetPrefix = declareNamespace((Element)aResultNode, policySet.getName().getNamespaceURI());
+ String appPolicyAttrPrefix = declareNamespace((Element)aResultNode, APPLICABLE_POLICYSET_ATTR_NS);
+ if (aResultNode.getAttributes().getNamedItemNS(APPLICABLE_POLICYSET_ATTR_NS, APPLICABLE_POLICYSET_ATTR) != null) {
applicablePolicySets =
aResultNode.getAttributes().getNamedItemNS(APPLICABLE_POLICYSET_ATTR_NS,
- APPLICABLE_POLICYSET_ATTR)
- .getNodeValue();
+ APPLICABLE_POLICYSET_ATTR).getNodeValue();
}
if (applicablePolicySets != null && applicablePolicySets.length() > 0) {
applicablePolicySets =
- applicablePolicySets + " "
- + policySetPrefix
- + ":"
- + policySet.getName().getLocalPart();
+ applicablePolicySets + " " + policySetPrefix + ":" + policySet.getName().getLocalPart();
} else {
- applicablePolicySets =
- policySetPrefix + ":" + policySet.getName().getLocalPart();
+ applicablePolicySets = policySetPrefix + ":" + policySet.getName().getLocalPart();
}
- ((Element)aResultNode).setAttributeNS(APPLICABLE_POLICYSET_ATTR_NS,
- appPolicyAttrPrefix + ":"
- + APPLICABLE_POLICYSET_ATTR,
- applicablePolicySets);
+ ((Element)aResultNode).setAttributeNS(APPLICABLE_POLICYSET_ATTR_NS, appPolicyAttrPrefix + ":"
+ + APPLICABLE_POLICYSET_ATTR, applicablePolicySets);
}
}
}
- public static byte[] addApplicablePolicySets(InputStream is, Collection<PolicySet> domainPolicySets, DocumentBuilderFactory documentBuilderFactory) throws Exception {
+ public static byte[] addApplicablePolicySets(InputStream is,
+ Collection<PolicySet> domainPolicySets,
+ DocumentBuilderFactory documentBuilderFactory) throws Exception {
documentBuilderFactory.setNamespaceAware(true);
DocumentBuilder db = documentBuilderFactory.newDocumentBuilder();
Document doc = db.parse(is);
is.close();
return addApplicablePolicySets(doc, domainPolicySets);
}
-
+
private static class DOMNamespaceContext implements NamespaceContext {
private Node node;
@@ -373,7 +325,7 @@ public class PolicyComputationUtils {
}
}
-
+
private static String declareNamespace(Element element, String ns) {
if (ns == null) {
ns = "";
@@ -382,7 +334,7 @@ public class PolicyComputationUtils {
String prefix = "";
boolean declared = false;
while (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
- if ( node.lookupPrefix(ns) != null ) {
+ if (node.lookupPrefix(ns) != null) {
prefix = node.lookupPrefix(ns);
declared = true;
break;
@@ -401,7 +353,7 @@ public class PolicyComputationUtils {
}
if (!declared) {
// Find an available prefix
- for (int i=1; ; i++) {
+ for (int i = 1;; i++) {
prefix = POLICYSET_PREFIX + i;
if (element.lookupNamespaceURI(prefix) == null) {
break;
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandler.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandler.java
deleted file mode 100644
index 1f91710f95..0000000000
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandler.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.policy.util;
-
-import org.apache.tuscany.sca.policy.PolicySet;
-
-/**
- * @deprecated This interface is replaced by PolicyProviderFactory/PolicyProvider SPIs
- * Handler interface for handling policies defined in policysets
- *
- * @version $Rev$ $Date$
- */
-@Deprecated
-public interface PolicyHandler {
- PolicySet getApplicablePolicySet();
- void setApplicablePolicySet(PolicySet policySet);
- void setUp(Object... context);
- void cleanUp(Object... context);
- void beforeInvoke(Object... context);
- void afterInvoke(Object... context);
-}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerDefinitionsLoader.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerDefinitionsLoader.java
deleted file mode 100644
index e9af4912a3..0000000000
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerDefinitionsLoader.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.policy.util;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
-import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
-
-/**
- * Utility class for loading policy handler definitions from META-INF/services directories
- *
- * @version $Rev$ $Date$
- */
-public class PolicyHandlerDefinitionsLoader {
-
- public static List<PolicyHandlerTuple> loadPolicyHandlerClassnames() {
- // Get the processor service declarations
- Set<ServiceDeclaration> sds;
- try {
- sds = ServiceDiscovery.getInstance().getServiceDeclarations(PolicyHandler.class.getName());
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
-
- List<PolicyHandlerTuple> handlerTupleList = new ArrayList<PolicyHandlerTuple>();
-
- Map<Object, List<PolicyHandlerTuple>> handlerTuples = new Hashtable<Object, List<PolicyHandlerTuple>>();
- for (ServiceDeclaration sd : sds) {
- Map<String, String> attributes = sd.getAttributes();
- String intentName = attributes.get("intent");
- QName intentQName = getQName(intentName);
- String policyModelClassName = attributes.get("model");
- String appliesTo = attributes.get("appliesTo");
- if ( appliesTo != null && !appliesTo.startsWith("/") ) {
- appliesTo = "//" + appliesTo;
- }
- handlerTupleList.add(new PolicyHandlerTuple(sd, sd.getClassName(), intentQName, policyModelClassName, appliesTo));
- }
-
- return handlerTupleList;
- }
-
- private static QName getQName(String qname) {
- if (qname == null) {
- return null;
- }
- qname = qname.trim();
- if (qname.startsWith("{")) {
- int h = qname.indexOf('}');
- if (h != -1) {
- return new QName(qname.substring(1, h), qname.substring(h + 1));
- }
- } else {
- int h = qname.indexOf('#');
- if (h != -1) {
- return new QName(qname.substring(0, h), qname.substring(h + 1));
- }
- }
- throw new IllegalArgumentException("Invalid qname: " + qname);
- }
-
-}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerTuple.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerTuple.java
deleted file mode 100644
index c80e68a0be..0000000000
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerTuple.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.policy.util;
-
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
-
-/**
- * PolicyHanlder tuples stored in policy handler services files
- *
- * @version $Rev$ $Date$
- */
-public class PolicyHandlerTuple {
- private ServiceDeclaration declaration;
- private String policyHandlerClassName;
- private QName providedIntentName;
- private String policyModelClassName;
- private String appliesTo;
-
- public PolicyHandlerTuple(ServiceDeclaration declaration,
- String handlerClassName,
- QName providedIntentName,
- String policyModelClassName,
- String appliesTo) {
- this.declaration = declaration;
- this.policyHandlerClassName = handlerClassName;
- this.providedIntentName = providedIntentName;
- this.policyModelClassName = policyModelClassName;
- this.appliesTo = appliesTo;
- }
-
- public ServiceDeclaration getDeclaration() {
- return declaration;
- }
-
- public void setDeclaration(ServiceDeclaration declaration) {
- this.declaration = declaration;
- }
-
- public String getAppliesTo() {
- return appliesTo;
- }
-
- public void setAppliesTo(String appliesTo) {
- this.appliesTo = appliesTo;
- }
-
-
- public String getPolicyHandlerClassName() {
- return policyHandlerClassName;
- }
- public void setPolicyHandlerClassName(String policyHandlerClassName) {
- this.policyHandlerClassName = policyHandlerClassName;
- }
- public String getPolicyModelClassName() {
- return policyModelClassName;
- }
- public void setPolicyModelClassName(String policyModelClassName) {
- this.policyModelClassName = policyModelClassName;
- }
- public QName getProvidedIntentName() {
- return providedIntentName;
- }
- public void setProvidedIntentName(QName providedIntentName) {
- this.providedIntentName = providedIntentName;
- }
-
- @Override
- public String toString() {
- return policyHandlerClassName + ", " + providedIntentName + ", " + policyModelClassName + ", " + appliesTo;
- }
-
-}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerUtils.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerUtils.java
deleted file mode 100644
index 6d6420017f..0000000000
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerUtils.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.policy.util;
-
-import java.util.List;
-
-import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.PolicySet;
-
-/**
- * Utility methods to deal with PolicyHandlers
- *
- * @version $Rev$ $Date$
- */
-public class PolicyHandlerUtils {
- public static PolicyHandler findPolicyHandler(PolicySet policySet, List<PolicyHandlerTuple> policyHandlerClassNames)
- throws IllegalAccessException, ClassNotFoundException, InstantiationException {
-
- PolicyHandler handler = null;
-
- for (PolicyHandlerTuple handlerTuple : policyHandlerClassNames) {
- //System.out.println(handlerTuple);
- for (Intent intent : policySet.getProvidedIntents()) {
- if (intent.getName().equals(handlerTuple.getProvidedIntentName())) {
- for (Object policy : policySet.getPolicies()) {
- if (policy.getClass().getName().equals(handlerTuple.getPolicyModelClassName())) {
- if (handlerTuple.getAppliesTo() != null) {
- if (handlerTuple.getAppliesTo().equals(policySet.getAppliesTo())) {
- handler = (PolicyHandler)handlerTuple.getDeclaration().loadClass().newInstance();
- handler.setApplicablePolicySet(policySet);
- return handler;
- }
- } else {
- handler = (PolicyHandler)handlerTuple.getDeclaration().loadClass().newInstance();
- handler.setApplicablePolicySet(policySet);
- return handler;
- }
- }
- }
- }
- }
- }
-
- return handler;
- }
-
-}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java
index afb3c035ae..c8fe89f364 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java
@@ -21,27 +21,22 @@ package org.apache.tuscany.sca.policy.util;
import java.util.List;
-import javax.xml.namespace.QName;
-
+import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPoint;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
/**
* @version $Rev$ $Date$
*/
public class PolicyValidationUtils {
- public static boolean isConstrained(QName constrained, IntentAttachPointType attachPointType) {
- return (attachPointType != null && attachPointType.getName().getNamespaceURI()
- .equals(constrained.getNamespaceURI()) && attachPointType.getName().getLocalPart()
- .startsWith(constrained.getLocalPart()));
+ public static boolean isConstrained(ExtensionType constrained, ExtensionType attachPointType) {
+ return (attachPointType != null
+ && (attachPointType.equals(constrained)) || (attachPointType.getBaseType().equals(constrained)));
}
- public static void validateIntents(IntentAttachPoint attachPoint,
- IntentAttachPointType attachPointType)
+ public static void validateIntents(PolicySubject attachPoint, ExtensionType attachPointType)
throws PolicyValidationException {
boolean found = false;
if (attachPointType != null) {
@@ -50,7 +45,7 @@ public class PolicyValidationUtils {
found = false;
for (Intent intent : attachPoint.getRequiredIntents()) {
if (!intent.isUnresolved()) {
- for (QName constrained : intent.getConstrains()) {
+ for (ExtensionType constrained : intent.getConstrainedTypes()) {
if (isConstrained(constrained, attachPointType)) {
found = true;
break;
@@ -60,7 +55,7 @@ public class PolicyValidationUtils {
if (!found) {
throw new PolicyValidationException("Policy Intent '" + intent.getName()
+ "' does not constrain extension type "
- + attachPointType.getName());
+ + attachPointType.getType());
}
} else {
throw new PolicyValidationException("Policy Intent '" + intent.getName()
@@ -70,36 +65,28 @@ public class PolicyValidationUtils {
}
}
- public static void validatePolicySets(PolicySetAttachPoint policySetAttachPoint)
- throws PolicyValidationException {
- validatePolicySets(policySetAttachPoint,
- policySetAttachPoint.getType(),
- policySetAttachPoint.getApplicablePolicySets());
+ public static void validatePolicySets(PolicySubject subject) throws PolicyValidationException {
+ // validatePolicySets(subject, subject.getType(), subject.getAttachedPolicySets());
}
-
- public static void validatePolicySets(PolicySetAttachPoint policySetAttachPoint,
- IntentAttachPointType attachPointType)
+
+ public static void validatePolicySets(PolicySubject subject, ExtensionType attachPointType)
throws PolicyValidationException {
- validatePolicySets(policySetAttachPoint,
- attachPointType,
- policySetAttachPoint.getApplicablePolicySets());
+ validatePolicySets(subject, attachPointType, subject.getPolicySets());
}
- public static void validatePolicySets(PolicySetAttachPoint policySetAttachPoint,
- IntentAttachPointType attachPointType,
- List<PolicySet> applicablePolicySets)
- throws PolicyValidationException {
- // Since the applicablePolicySets in a policySetAttachPoint will already
+ public static void validatePolicySets(PolicySubject subject,
+ ExtensionType attachPointType,
+ List<PolicySet> applicablePolicySets) throws PolicyValidationException {
+ // Since the applicablePolicySets in a subject will already
// have the list of policysets that might ever be applicable to this attachPoint,
// just check if the defined policysets feature in the list of applicable
// policysets
- for (PolicySet definedPolicySet : policySetAttachPoint.getPolicySets()) {
+ for (PolicySet definedPolicySet : subject.getPolicySets()) {
if (!definedPolicySet.isUnresolved()) {
if (!applicablePolicySets.contains(definedPolicySet)) {
- throw new PolicyValidationException("Policy Set '" + definedPolicySet
- .getName()
+ throw new PolicyValidationException("Policy Set '" + definedPolicySet.getName()
+ "' does not apply to extension type "
- + attachPointType.getName());
+ + attachPointType.getType());
}
} else {
throw new PolicyValidationException("Policy Set '" + definedPolicySet.getName()
diff --git a/java/sca/modules/policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory b/java/sca/modules/policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory
deleted file mode 100644
index a0e56c1822..0000000000
--- a/java/sca/modules/policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory
+++ /dev/null
@@ -1,18 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-org.apache.tuscany.sca.policy.DefaultIntentAttachPointTypeFactory \ No newline at end of file