From 9d5106bd197cebed36a5701a243f35d056dbc615 Mon Sep 17 00:00:00 2001 From: antelder Date: Tue, 26 Oct 2010 14:17:45 +0000 Subject: Tag rc1 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1027571 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tuscany/sca/policy/BindingType.java | 27 ++++ .../tuscany/sca/policy/DefaultPolicyFactory.java | 30 ++++ .../apache/tuscany/sca/policy/ExtensionType.java | 82 ++++++++++ .../tuscany/sca/policy/ExternalAttachment.java | 85 +++++++++++ .../tuscany/sca/policy/ImplementationType.java | 27 ++++ .../java/org/apache/tuscany/sca/policy/Intent.java | 161 ++++++++++++++++++++ .../org/apache/tuscany/sca/policy/IntentMap.java | 49 ++++++ .../tuscany/sca/policy/PolicyAttachment.java | 31 ++++ .../apache/tuscany/sca/policy/PolicyContainer.java | 37 +++++ .../tuscany/sca/policy/PolicyExpression.java | 66 ++++++++ .../apache/tuscany/sca/policy/PolicyFactory.java | 72 +++++++++ .../org/apache/tuscany/sca/policy/PolicySet.java | 159 +++++++++++++++++++ .../apache/tuscany/sca/policy/PolicySubject.java | 57 +++++++ .../org/apache/tuscany/sca/policy/Qualifier.java | 44 ++++++ .../tuscany/sca/policy/impl/BindingTypeImpl.java | 38 +++++ .../tuscany/sca/policy/impl/ExtensionTypeImpl.java | 97 ++++++++++++ .../sca/policy/impl/ExternalAttachmentImpl.java | 76 ++++++++++ .../sca/policy/impl/ImplementationTypeImpl.java | 39 +++++ .../apache/tuscany/sca/policy/impl/IntentImpl.java | 168 +++++++++++++++++++++ .../tuscany/sca/policy/impl/IntentMapImpl.java | 78 ++++++++++ .../sca/policy/impl/PolicyExpressionImpl.java | 87 +++++++++++ .../tuscany/sca/policy/impl/PolicyFactoryImpl.java | 76 ++++++++++ .../tuscany/sca/policy/impl/PolicySetImpl.java | 154 +++++++++++++++++++ .../tuscany/sca/policy/impl/QualifierImpl.java | 48 ++++++ .../tuscany/sca/policy/util/PolicyHelper.java | 130 ++++++++++++++++ 25 files changed, 1918 insertions(+) create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/BindingType.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultPolicyFactory.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExternalAttachment.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Intent.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyContainer.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExternalAttachmentImpl.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHelper.java (limited to 'sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy') diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/BindingType.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/BindingType.java new file mode 100644 index 0000000000..f43c428563 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/BindingType.java @@ -0,0 +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; + + +/** + * Definition of binding type which extends from sca:binding + */ +public interface BindingType extends ExtensionType { +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultPolicyFactory.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultPolicyFactory.java new file mode 100644 index 0000000000..2da41675a1 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultPolicyFactory.java @@ -0,0 +1,30 @@ +/* + * 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.PolicyFactoryImpl; + +/** + * A factory for the policy model. + * + * @version $Rev$ $Date$ + */ +public class DefaultPolicyFactory extends PolicyFactoryImpl implements PolicyFactory { + +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java new file mode 100644 index 0000000000..f8f8a48b06 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.policy; + +import java.util.List; + +import javax.xml.namespace.QName; + +/** + * Definition of extension type: binding or implementation + * @tuscany.spi.extension.asclient + */ +public interface ExtensionType { + QName BINDING_BASE = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200912", "binding"); + QName IMPLEMENTATION_BASE = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200912", "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 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 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/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExternalAttachment.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExternalAttachment.java new file mode 100644 index 0000000000..5bccf51b91 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExternalAttachment.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.policy; + +import java.util.List; + +import javax.xml.xpath.XPathExpression; + +/* + * Represents an external attachment element. See the Policy Framework specification for a + * description of this element. + * + * @version $Rev: 937291 $ $Date: 2010-04-23 06:41:24 -0700 (Fri, 23 Apr 2010) $ + * @tuscany.spi.extension.asclient + */ + + +public interface ExternalAttachment { + + /** + * Get the attachTo attribute + * @return + */ + String getAttachTo(); + + /** + * Set the attachTo attribute + * @param name + */ + void setAttachTo(String name); + + /** + * Get the compiled XPath attachTo expression + * @return + */ + XPathExpression getAttachToXPathExpression(); + + /** + * Set the compiled XPath attachTo expression + * @param expression + */ + void setAttachToXPathExpression(XPathExpression expression); + + /** + * Get the policy sets associated with this ExternalAttachment + * @return + */ + List getPolicySets(); + + /** + * Get the intents associated with this ExternalAttachment + * @return + */ + List getIntents(); + + /** + * Returns true if the model element is unresolved. + * + * @return true if the model element is unresolved. + */ + boolean isUnresolved(); + + /** + * Sets whether the model element is unresolved. + * + * @param unresolved whether the model element is unresolved + */ + void setUnresolved(boolean unresolved); +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java new file mode 100644 index 0000000000..d142015f57 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java @@ -0,0 +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; + + +/** + * Definition of an implementation type which extends from sca:implementation + */ +public interface ImplementationType extends ExtensionType { +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Intent.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Intent.java new file mode 100644 index 0000000000..b2578fab49 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Intent.java @@ -0,0 +1,161 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.policy; + +import java.util.List; + +import javax.xml.namespace.QName; + +/** + * Represents a policy intent. See the Policy Framework specification for a + * description of this element. + * + * @version $Rev$ $Date$ + * @tuscany.spi.extension.asclient + */ +public interface Intent { + enum Type { + interaction, implementation + }; + + /** + * Returns the intent name. + * + * @return the intent name + */ + QName getName(); + + /** + * Sets the intent name + * + * @param name the intent name + */ + void setName(QName name); + + /** + * 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 + */ + List getConstrainedTypes(); + + /** + * Return a list of required intents + * @return The list of required intents + */ + List getRequiredIntents(); + + /** + * Returns the list of intents which are mutually exclusive with this intent. + * + * @return the list of mutually exclusive intents. + */ + List getExcludedIntents(); + + /** + * Returns the list of qualified intents. + * + * @return the list of qualified intents. + */ + List getQualifiedIntents(); + + /** + * Get the default qualified intent + * + * @return + */ + Intent getDefaultQualifiedIntent(); + + /** + * Set the default qualified intent + * + * @param qualifiedIntent + */ + 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. + * + * @return the intent description + */ + String getDescription(); + + /** + * Sets the intent description. + * + * @param description the intent description + */ + void setDescription(String description); + + /** + * Returns true if the model element is unresolved. + * + * @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 getQualifiableIntent(); + + /** + * Set the parent intent for a qualified intent + * @param intent + */ + void setQualifiableIntent(Intent intent); + + boolean isUnresolved(); + + /** + * Sets whether the model element is unresolved. + * + * @param unresolved whether the model element is unresolved + */ + void setUnresolved(boolean unresolved); + +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java new file mode 100644 index 0000000000..5b401baeb3 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java @@ -0,0 +1,49 @@ +/* + * 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; + + +/** + * Map policies to the qualified intents + */ +public interface IntentMap { + /** + * Returns the intent realized by this intent map. + * + * @return the intent realized by this intent map + */ + Intent getProvidedIntent(); + + /** + * Sets the intent realized by this intent map. + * + * @param providedIntent the intent realized by this intent map + */ + void setProvidedIntent(Intent providedIntent); + + /** + * Get a list of qualifiers + * + * @return A list of qualifiers + */ + List getQualifiers(); +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java new file mode 100644 index 0000000000..ee4f5b5236 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java @@ -0,0 +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; + +/** + * Attach a policySet to a collection of policy subjects + */ +public interface PolicyAttachment { + PolicySet getPolicySet(); + void setPolicySet(PolicySet policySet); + List getPolicySubjects(); +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyContainer.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyContainer.java new file mode 100644 index 0000000000..6bb7244e05 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyContainer.java @@ -0,0 +1,37 @@ +/* + * 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; + +/** + * Base interface for policy models. Mainly allows policies to hold + * other policies + * + * @version $Rev$ $Date$ + * @tuscany.spi.extension.inheritfrom + */ +public interface PolicyContainer { + /** + * For complex policy models, such as ws-policy, + * a policy provider may only match against one of a + * number of child policy models + * + * @return the matching child policy object or null + */ + Object getChildPolicy(Class policyType); +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java new file mode 100644 index 0000000000..b7de263789 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java @@ -0,0 +1,66 @@ +/* + * 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$ + * @tuscany.spi.extension.asclient + */ +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 getPolicy(); + + /** + * Set the policy definition + * @param expression + */ + void setPolicy(T policy); + + /** + * + * @param unresolved + */ + void setUnresolved(boolean unresolved); + + /** + * + * @return + */ + boolean isUnresolved(); +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java new file mode 100644 index 0000000000..b23060dafb --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.policy; + +/** + * A factory for the policy model. + * + * @version $Rev$ $Date$ + * @tuscany.spi.extension.asclient + */ +public interface PolicyFactory { + + /** + * Create a new intent. + * + * @return a new intent + */ + Intent createIntent(); + + /** + * Create a new policy set. + * + * @return a new policy set + */ + PolicySet createPolicySet(); + + /** + * Create a new intent map. + * + * @return a new intent map + */ + IntentMap createIntentMap(); + + /** + * create a new Qualifier + * + * @return a Qualifier + */ + Qualifier createQualifier(); + + /** + * Create a new PolicyExpression + * @return + */ + PolicyExpression createPolicyExpression(); + + ExtensionType createExtensionType(); + BindingType createBindingType(); + ImplementationType createImplementationType(); + + /** + * Create a new ExternalAttachment + * @return + */ + ExternalAttachment createExternalAttachment(); +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java new file mode 100644 index 0000000000..230d635e76 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java @@ -0,0 +1,159 @@ +/* + * 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; +import javax.xml.xpath.XPathExpression; + +/** + * Represents a policy set. See the Policy Framework specification for a + * description of this element. + * + * @version $Rev$ $Date$ + * @tuscany.spi.extension.asclient + */ +public interface PolicySet { + + /** + * Returns the intent name. + * + * @return the intent name + */ + QName getName(); + + /** + * Sets the intent name + * + * @param name the intent name + */ + void setName(QName name); + + /** + * Returns the list of + * + * @return + */ + List getReferencedPolicySets(); + + /** + * Returns the list of provided intents + * + * @return + */ + List getProvidedIntents(); + + /** + * 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 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); + + /** + * Returns the XPath expression that is to be used to evaluate + * if this PolicySet applies to specific policy subject + * + * @return the XPath expression + */ + String getAppliesTo(); + + /** + * Sets the XPath expression that is to be used to evaluate + * if this PolicySet applies to specific policy subject + * + */ + void setAppliesTo(String xpath); + + /** + * 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 + */ + XPathExpression getAttachToXPathExpression(); + + /** + * Set the resolved XPathExpression for attachTo + * @param expression + */ + void setAttachToXPathExpression(XPathExpression expression); + + /** + * Returns the policies / policy attachments provided thro intent maps + * + * @return + */ + List getIntentMaps(); + + /** + * Get the XPath expression for the appliesTo attribute + * @return the XPath expression for the appliesTo attribute + */ + XPathExpression getAppliesToXPathExpression(); + + /** + * Set the XPath expression for the appliesTo attribute + * @param xpathExpression the XPath expression for the appliesTo attribute + */ + void setAppliesToXPathExpression(XPathExpression xpathExpression); + + /** + * Returns true if this PolicySet was attached via external attachment + * For unattached and directly attached PolicySets, returns false + * @return + */ + boolean isExternalAttachment(); + + /** + * Sets whether this PolicySet has been attached via external attachment or not + * @param value + */ + void setIsExternalAttachment(boolean value); +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java new file mode 100644 index 0000000000..e585fcf384 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.policy; + +import java.util.List; + +/** + * A policy subject is an entity in the assembly with which a policy can be + * associated. + * + * For example, a policy subject can be one of the following: + *
    + *
  • composite + *
  • component + *
  • implementation + *
  • service + *
  • reference + *
  • binding + *
  • interface + *
+ * @tuscany.spi.extension.inheritfrom + */ +public interface PolicySubject { + /** + * Get a list of required intents + * + * @return + */ + List getRequiredIntents(); + + /** + * Get a list of attached policySets + * + * @return A list of policySets + */ + List getPolicySets(); + + ExtensionType getExtensionType(); + void setExtensionType(ExtensionType type); +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java new file mode 100644 index 0000000000..c1862283c7 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java @@ -0,0 +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; + +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 getPolicies(); +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java new file mode 100644 index 0000000000..1a2a9c5bad --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java @@ -0,0 +1,38 @@ +/* + * 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.BindingType; + +/** + * Concrete implementation for a BindingType + * + * @version $Rev$ $Date$ + */ +public class BindingTypeImpl extends ExtensionTypeImpl implements BindingType { + protected BindingTypeImpl() { + super(); + } + + public QName getBaseType() { + return BINDING_BASE; + } +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java new file mode 100644 index 0000000000..97fbc19ced --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/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 alwaysProvides = new ArrayList(); + private List mayProvide = new ArrayList(); + private QName typeName; + private boolean unResolved = true; + + protected ExtensionTypeImpl() { + + } + + public List getAlwaysProvidedIntents() { + return alwaysProvides; + } + + public List 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/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExternalAttachmentImpl.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExternalAttachmentImpl.java new file mode 100644 index 0000000000..1e90e26324 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExternalAttachmentImpl.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.policy.impl; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.xpath.XPathExpression; + +import org.apache.tuscany.sca.policy.ExternalAttachment; + +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.PolicySet; + +/** + * An implementation of ExternalAttachment + * + */ +public class ExternalAttachmentImpl implements ExternalAttachment { + + private String attachTo; + private List intents = new ArrayList(); + private List policySets = new ArrayList(); + private XPathExpression xpath; + private boolean isUnresolved; + + + public String getAttachTo() { + return attachTo; + } + + public void setAttachTo(String attachTo) { + this.attachTo = attachTo; + } + + public List getPolicySets() { + return this.policySets; + } + + public List getIntents() { + return this.intents; + } + + public XPathExpression getAttachToXPathExpression() { + return this.xpath; + } + + public void setAttachToXPathExpression(XPathExpression expression) { + this.xpath = expression; + } + + public boolean isUnresolved() { + return this.isUnresolved; + } + + public void setUnresolved(boolean unresolved) { + this.isUnresolved = unresolved; + } + +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java new file mode 100644 index 0000000000..5c285e4d95 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java @@ -0,0 +1,39 @@ +/* + * 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.ImplementationType; + +/** + * Concrete implementation for a Implementation Type + * + * @version $Rev$ $Date$ + */ +public class ImplementationTypeImpl extends ExtensionTypeImpl implements ImplementationType { + protected ImplementationTypeImpl() { + super(); + } + + public QName getBaseType() { + return IMPLEMENTATION_BASE; + } + +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java new file mode 100644 index 0000000000..27a77f3ba8 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java @@ -0,0 +1,168 @@ +/* + * 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; + +/** + * Represents a policy intent. + * + * @version $Rev$ $Date$ + */ +public class IntentImpl implements Intent { + + private QName name; + private Type type; + private List constrainedTypes = new ArrayList(); + private String description; + private List qualifiedIntents = new ArrayList(); + private Intent defaultQualifiedIntent; + private Intent parent; + private List requiredIntents = new ArrayList(); + private List excludedIntents = new ArrayList(); + private boolean mutuallyExclusive; + private boolean unresolved = true; + + protected IntentImpl() { + } + + public QName getName() { + return name; + } + + public void setName(QName name) { + this.name = name; + } + + public List getConstrainedTypes() { + return constrainedTypes; + } + + public void setConstrainedTypes(List constrainedTypes) { + this.constrainedTypes = constrainedTypes; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Intent getQualifiableIntent() { + return parent; + } + + public void setQualifiableIntent(Intent parent) { + this.parent = parent; + } + + public List getQualifiedIntents() { + return qualifiedIntents; + } + + public void setQualifiedIntents(List qualifiedIntents) { + this.qualifiedIntents = qualifiedIntents; + } + + public List getRequiredIntents() { + return requiredIntents; + } + + public void setRequiredIntents(List requiredIntents) { + this.requiredIntents = requiredIntents; + } + + public List getExcludedIntents() { + return excludedIntents; + } + + public void setExcludedIntents(List excludedIntents) { + this.excludedIntents = excludedIntents; + } + + public boolean isUnresolved() { + return unresolved; + } + + public void setUnresolved(boolean unresolved) { + this.unresolved = unresolved; + } + + 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; + 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; + IntentImpl other = (IntentImpl)obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + public String toString() { + return String.valueOf(name); + } +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java new file mode 100644 index 0000000000..357b7afab4 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java @@ -0,0 +1,78 @@ +/* + * 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.IntentMap; +import org.apache.tuscany.sca.policy.Qualifier; + +/** + * Represents an intent map. + * + * @version $Rev$ $Date$ + */ +public class IntentMapImpl implements IntentMap { + + private boolean unresolved; + private Intent providedIntent; + private List qualifiers = new ArrayList(); + + protected IntentMapImpl() { + } + + public boolean isUnresolved() { + return unresolved; + } + + public void setUnresolved(boolean unresolved) { + this.unresolved = unresolved; + } + + public Intent getProvidedIntent() { + return providedIntent; + } + + public void setProvidedIntent(Intent providedIntent) { + this.providedIntent = providedIntent; + } + + public List getQualifiers() { + return qualifiers; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + IntentMapImpl other = (IntentMapImpl)obj; + if (providedIntent == null) { + if (other.providedIntent != null) + return false; + } else if (!providedIntent.equals(other.providedIntent)) + return false; + return true; + } +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java new file mode 100644 index 0000000000..b9f9fa5eb4 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java @@ -0,0 +1,87 @@ +/* + * 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; + } + + @SuppressWarnings("unchecked") + public T getPolicy() { + return (T)policy; + } + + public boolean isUnresolved() { + return unresolved; + } + + public void setName(QName name) { + this.name = name; + } + + public 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/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java new file mode 100644 index 0000000000..f700f7c41a --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.policy.impl; + +import 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.Qualifier; + +import org.apache.tuscany.sca.policy.ExternalAttachment; + +/** + * A factory for the policy model. + * + * @version $Rev$ $Date$ + */ +public abstract class PolicyFactoryImpl implements PolicyFactory { + + public Intent createIntent() { + return new IntentImpl(); + } + + public PolicySet createPolicySet() { + return new PolicySetImpl(); + } + + public IntentMap createIntentMap() { + return new IntentMapImpl(); + } + + 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 ExtensionType createExtensionType() { + return new ExtensionTypeImpl(); + } + + public ExternalAttachment createExternalAttachment() { + return new ExternalAttachmentImpl(); + } + +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java new file mode 100644 index 0000000000..22e6e4d4cf --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java @@ -0,0 +1,154 @@ +/* + * 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 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; + +/** + * Represents a policy set. + * + * @version $Rev$ $Date$ + */ +public class PolicySetImpl implements PolicySet { + + private QName name; + private String appliesTo; + private String attachTo; + private List providedIntents = new ArrayList(); + private List referencedPolicySets = new ArrayList(); + private boolean unresolved = true; + + private XPathExpression appliesToXPathExpression; + private XPathExpression attachToXPathExpression; + + private List intentMaps = new ArrayList(); + private List policies = new ArrayList(); + private boolean isExternalAttachment; + + public QName getName() { + return name; + } + + public void setName(QName name) { + this.name = name; + } + + public String getAppliesTo() { + return appliesTo; + } + + public void setAppliesTo(String appliesTo) { + this.appliesTo = appliesTo; + } + + public String getAttachTo() { + return attachTo; + } + + public void setAttachTo(String attachTo) { + this.attachTo = attachTo; + } + + public boolean isUnresolved() { + return unresolved; + } + + public void setUnresolved(boolean unresolved) { + this.unresolved = unresolved; + } + + public XPathExpression getAppliesToXPathExpression() { + return appliesToXPathExpression; + } + + public void setAppliesToXPathExpression(XPathExpression appliesToXPathExpression) { + this.appliesToXPathExpression = appliesToXPathExpression; + } + + public XPathExpression getAttachToXPathExpression() { + return attachToXPathExpression; + } + + public void setAttachToXPathExpression(XPathExpression attachToXPathExpression) { + this.attachToXPathExpression = attachToXPathExpression; + } + + public List getIntentMaps() { + return intentMaps; + } + + public List getProvidedIntents() { + return providedIntents; + } + + public List getReferencedPolicySets() { + return referencedPolicySets; + } + + public List 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; + } + + @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; + } + + public boolean isExternalAttachment() { + return this.isExternalAttachment; + } + + public void setIsExternalAttachment(boolean value) { + this.isExternalAttachment = value; + } + +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java new file mode 100644 index 0000000000..102bea8d41 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.policy.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 policies = new ArrayList(); + + protected QualifierImpl() { + } + + public Intent getIntent() { + return intent; + } + + public List getPolicies() { + return policies; + } + + public void setIntent(Intent intent) { + this.intent = intent; + } + +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHelper.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHelper.java new file mode 100644 index 0000000000..8a4adb3d7f --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHelper.java @@ -0,0 +1,130 @@ +/* + * 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.ArrayList; +import java.util.Collection; +import java.util.List; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.definitions.Definitions; +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.PolicyExpression; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySubject; + +/** + * A utility that helps to navigate the policy model + * @tuscany.spi.extension.asclient + */ +public class PolicyHelper { + public PolicySet getPolicySet(PolicySubject subject, QName policySetName) { + for (PolicySet ps : subject.getPolicySets()) { + if (ps.getName().equals(policySetName)) { + return ps; + } + } + return null; + } + + public Intent getIntent(Definitions subject, QName intentName) { + for (Intent i : subject.getIntents()) { + if (i.getName().equals(intentName)) { + return i; + } + } + return null; + } + + public PolicySet getPolicySet(Definitions subject, QName policySetName) { + for (PolicySet ps : subject.getPolicySets()) { + if (ps.getName().equals(policySetName)) { + return ps; + } + } + return null; + } + + public Intent getIntent(PolicySubject subject, QName intentName) { + for (Intent i : subject.getRequiredIntents()) { + if (i.getName().equals(intentName)) { + return i; + } + } + return null; + } + + public Collection getPolicyExpressions(PolicySubject subject, QName policyName) { + Collection policies = new ArrayList(); + for (PolicySet ps : subject.getPolicySets()) { + for (PolicyExpression exp : ps.getPolicies()) { + if (exp.getName().equals(policyName)) { + policies.add(exp); + } + } + } + return policies; + } + + public Collection getPolicies(PolicySubject subject, QName policyName) { + Collection policies = new ArrayList(); + for (PolicySet ps : subject.getPolicySets()) { + for (PolicyExpression exp : ps.getPolicies()) { + if (exp.getName().equals(policyName)) { + policies.add(exp.getPolicy()); + } + } + } + return policies; + } + + public static PolicySet getPolicySet(Binding wsBinding, QName intentName) { + PolicySet returnPolicySet = null; + + if (wsBinding instanceof PolicySubject) { + PolicySubject policiedBinding = (PolicySubject)wsBinding; + for (PolicySet policySet : policiedBinding.getPolicySets()) { + for (Intent intent : policySet.getProvidedIntents()) { + if (intent.getName().equals(intentName)) { + returnPolicySet = policySet; + break; + } + } + } + } + + return returnPolicySet; + } + + public static boolean isIntentRequired(Binding wsBinding, QName intent) { + if (wsBinding instanceof PolicySubject) { + List intents = ((PolicySubject)wsBinding).getRequiredIntents(); + for (Intent i : intents) { + if (intent.equals(i.getName())) { + return true; + } + } + } + return getPolicySet(wsBinding, intent) != null; + } + +} -- cgit v1.2.3