diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-20 00:53:01 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-20 00:53:01 +0000 |
commit | a3c182d923b874384be0be21e900e205a2692cba (patch) | |
tree | 206bba14e8f0fe943f91f034be87230bd3c50ba1 /java | |
parent | 765e058d13c4ad1ba0e3e68ca2820cc6dd514036 (diff) |
Add <requires> and <policySetAttachment> support for the composite (binding and implementation levels need be to implemented by binding/impl processors)
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@882372 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
3 files changed, 83 insertions, 40 deletions
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java index 3930ed9f67..e5df0a145e 100644 --- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java +++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java @@ -34,17 +34,20 @@ import static org.apache.tuscany.sca.assembly.xml.Constants.IMPLEMENTATION_COMPO import static org.apache.tuscany.sca.assembly.xml.Constants.IMPLEMENTATION_COMPOSITE_QNAME; import static org.apache.tuscany.sca.assembly.xml.Constants.INCLUDE; import static org.apache.tuscany.sca.assembly.xml.Constants.INCLUDE_QNAME; +import static org.apache.tuscany.sca.assembly.xml.Constants.INTENTS; import static org.apache.tuscany.sca.assembly.xml.Constants.LOCAL; import static org.apache.tuscany.sca.assembly.xml.Constants.MANY; import static org.apache.tuscany.sca.assembly.xml.Constants.MUST_SUPPLY; import static org.apache.tuscany.sca.assembly.xml.Constants.NAME; import static org.apache.tuscany.sca.assembly.xml.Constants.NONOVERRIDABLE; +import static org.apache.tuscany.sca.assembly.xml.Constants.POLICY_SET_ATTACHMENT_QNAME; import static org.apache.tuscany.sca.assembly.xml.Constants.PROMOTE; import static org.apache.tuscany.sca.assembly.xml.Constants.PROPERTY; import static org.apache.tuscany.sca.assembly.xml.Constants.PROPERTY_QNAME; import static org.apache.tuscany.sca.assembly.xml.Constants.REFERENCE; import static org.apache.tuscany.sca.assembly.xml.Constants.REFERENCE_QNAME; import static org.apache.tuscany.sca.assembly.xml.Constants.REPLACE; +import static org.apache.tuscany.sca.assembly.xml.Constants.REQUIRES_QNAME; import static org.apache.tuscany.sca.assembly.xml.Constants.SCA11_NS; import static org.apache.tuscany.sca.assembly.xml.Constants.SERVICE; import static org.apache.tuscany.sca.assembly.xml.Constants.SERVICE_QNAME; @@ -99,7 +102,9 @@ import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.policy.ExtensionType; +import org.apache.tuscany.sca.policy.Intent; import org.apache.tuscany.sca.policy.PolicyFactory; +import org.apache.tuscany.sca.policy.PolicySet; import org.apache.tuscany.sca.policy.PolicySubject; import org.w3c.dom.Document; @@ -464,6 +469,37 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt component.setImplementation(implementation); policyProcessor.readPolicies(implementation, reader); + } else if (REQUIRES_QNAME.equals(name)) { + List<QName> intents = getQNames(reader, INTENTS); + for (QName i : intents) { + Intent intent = policyFactory.createIntent(); + intent.setName(i); + if (composite != null) { + composite.getRequiredIntents().add(intent); + } else if (component != null) { + component.getRequiredIntents().add(intent); + } else if (contract != null) { + contract.getRequiredIntents().add(intent); + } else if (callback != null) { + callback.getRequiredIntents().add(intent); + } + } + } else if (POLICY_SET_ATTACHMENT_QNAME.equals(name)) { + QName ps = getQName(reader, NAME); + if (ps != null) { + PolicySet policySet = policyFactory.createPolicySet(); + policySet.setName(ps); + if (composite != null) { + composite.getPolicySets().add(policySet); + } else if (component != null) { + component.getPolicySets().add(policySet); + } else if (contract != null) { + contract.getPolicySets().add(policySet); + } else if (callback != null) { + callback.getPolicySets().add(policySet); + } + } + } else { // Read an extension element diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java index ad1e7cd83f..23399a7105 100644 --- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java +++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java @@ -71,13 +71,20 @@ public interface Constants { String NAME = "name"; String VALUE = "value"; - QName VALUE_QNAME = new QName(SCA11_NS, VALUE); + QName VALUE_QNAME = new QName(SCA11_NS, VALUE); + + String POLICY_SET_ATTACHMENT = "policySetAttachment"; + QName POLICY_SET_ATTACHMENT_QNAME = new QName(SCA11_NS, POLICY_SET_ATTACHMENT); + String TARGET_NAMESPACE = "targetNamespace"; String LOCAL = "local"; String AUTOWIRE = "autowire"; String NONOVERRIDABLE = "nonOverridable"; String REPLACE = "replace"; String REQUIRES = "requires"; + QName REQUIRES_QNAME = new QName(SCA11_NS, REQUIRES); + String INTENTS = "intents"; + String POLICY_SETS = "policySets"; String PROMOTE = "promote"; String TARGET = "target"; diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java index b47be74712..6fd12b21c4 100644 --- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java +++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java @@ -62,14 +62,14 @@ public class PolicySubjectProcessor extends BaseStAXArtifactProcessor { /** * Read policy intents associated with an operation. - * @param attachPoint + * @param subject * @param operation * @param reader */ - private void readIntents(Object attachPoint, Operation operation, XMLStreamReader reader) { - if (!(attachPoint instanceof PolicySubject)) + private void readIntents(Object subject, Operation operation, XMLStreamReader reader) { + if (!(subject instanceof PolicySubject)) return; - PolicySubject intentAttachPoint = (PolicySubject)attachPoint; + PolicySubject intentAttachPoint = (PolicySubject)subject; String value = reader.getAttributeValue(null, REQUIRES); if (value != null) { List<Intent> requiredIntents = intentAttachPoint.getRequiredIntents(); @@ -89,35 +89,35 @@ public class PolicySubjectProcessor extends BaseStAXArtifactProcessor { /** * Reads policy intents and policy sets associated with an operation. - * @param attachPoint + * @param subject * @param operation * @param reader */ - public void readPolicies(Object attachPoint, Operation operation, XMLStreamReader reader) { - readIntents(attachPoint, operation, reader); - readPolicySets(attachPoint, operation, reader); + public void readPolicies(Object subject, Operation operation, XMLStreamReader reader) { + readIntents(subject, operation, reader); + readPolicySets(subject, operation, reader); } /** * Reads policy intents and policy sets. - * @param attachPoint + * @param subject * @param reader */ - public void readPolicies(Object attachPoint, XMLStreamReader reader) { - readPolicies(attachPoint, null, reader); + public void readPolicies(Object subject, XMLStreamReader reader) { + readPolicies(subject, null, reader); } /** * Reads policy sets associated with an operation. - * @param attachPoint + * @param subject * @param operation * @param reader */ - private void readPolicySets(Object attachPoint, Operation operation, XMLStreamReader reader) { - if (!(attachPoint instanceof PolicySubject)) { + private void readPolicySets(Object subject, Operation operation, XMLStreamReader reader) { + if (!(subject instanceof PolicySubject)) { return; } - PolicySubject policySubject = (PolicySubject)attachPoint; + PolicySubject policySubject = (PolicySubject)subject; String value = reader.getAttributeValue(null, POLICY_SETS); if (value != null) { List<PolicySet> policySets = policySubject.getPolicySets(); @@ -137,55 +137,55 @@ public class PolicySubjectProcessor extends BaseStAXArtifactProcessor { /** * Write policies - * @param attachPoint + * @param subject * @return */ - XAttr writePolicies(Object attachPoint) throws XMLStreamException { - return writePolicies(attachPoint, (Operation)null); + XAttr writePolicies(Object subject) throws XMLStreamException { + return writePolicies(subject, (Operation)null); } /** * Write policies - * @param attachPoint + * @param subject * @return */ - public void writePolicyAttributes(Object attachPoint, XMLStreamWriter writer) throws XMLStreamException { - writePolicyAttributes(attachPoint, (Operation)null, writer); + public void writePolicyAttributes(Object subject, XMLStreamWriter writer) throws XMLStreamException { + writePolicyAttributes(subject, (Operation)null, writer); } /** * Write policies associated with an operation - * @param attachPoint + * @param subject * @param operation * @return */ - XAttr writePolicies(Object attachPoint, Operation operation) { + XAttr writePolicies(Object subject, Operation operation) { List<XAttr> attrs =new ArrayList<XAttr>(); - attrs.add(writeIntents(attachPoint, operation)); - attrs.add(writePolicySets(attachPoint, operation)); + attrs.add(writeIntents(subject, operation)); + attrs.add(writePolicySets(subject, operation)); return new XAttr(null, attrs); } /** * Write policies - * @param attachPoint + * @param subject * @return */ - public void writePolicyAttributes(Object attachPoint, Operation operation, XMLStreamWriter writer) throws XMLStreamException { - XAttr attr = writePolicies(attachPoint, operation); + public void writePolicyAttributes(Object subject, Operation operation, XMLStreamWriter writer) throws XMLStreamException { + XAttr attr = writePolicies(subject, operation); attr.write(writer); } /** * Write policy intents associated with an operation. - * @param attachPoint + * @param subject * @param operation */ - private XAttr writeIntents(Object attachPoint, Operation operation) { - if (!(attachPoint instanceof PolicySubject)) { + private XAttr writeIntents(Object subject, Operation operation) { + if (!(subject instanceof PolicySubject)) { return null; } - PolicySubject intentAttachPoint = (PolicySubject)attachPoint; + PolicySubject intentAttachPoint = (PolicySubject)subject; List<QName> qnames = new ArrayList<QName>(); for (Intent intent: intentAttachPoint.getRequiredIntents()) { qnames.add(intent.getName()); @@ -195,14 +195,14 @@ public class PolicySubjectProcessor extends BaseStAXArtifactProcessor { /** * Write policy sets associated with an operation. - * @param attachPoint + * @param subject * @param operation */ - private XAttr writePolicySets(Object attachPoint, Operation operation) { - if (!(attachPoint instanceof PolicySubject)) { + private XAttr writePolicySets(Object subject, Operation operation) { + if (!(subject instanceof PolicySubject)) { return null; } - PolicySubject policySetAttachPoint = (PolicySubject)attachPoint; + PolicySubject policySetAttachPoint = (PolicySubject)subject; List<QName> qnames = new ArrayList<QName>(); for (PolicySet policySet: policySetAttachPoint.getPolicySets()) { qnames.add(policySet.getName()); @@ -210,9 +210,9 @@ public class PolicySubjectProcessor extends BaseStAXArtifactProcessor { return new XAttr(Constants.POLICY_SETS, qnames); } - public void resolvePolicies(Object attachPoint, ModelResolver resolver, ProcessorContext context) { - if ( attachPoint instanceof PolicySubject ) { - PolicySubject policySetAttachPoint = (PolicySubject)attachPoint; + public void resolvePolicies(Object subject, ModelResolver resolver, ProcessorContext context) { + if ( subject instanceof PolicySubject ) { + PolicySubject policySetAttachPoint = (PolicySubject)subject; List<Intent> requiredIntents = new ArrayList<Intent>(); Intent resolvedIntent = null; |