From 1fb6a28a73ca17dbb8c4b3059db590e2f9620943 Mon Sep 17 00:00:00 2001 From: antelder Date: Wed, 3 Aug 2011 09:21:41 +0000 Subject: Correct tag name git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1153404 13f79535-47bb-0310-9956-ffa450edef68 --- .../assembly/xml/PolicyAttachPointProcessor.java | 257 --------------------- 1 file changed, 257 deletions(-) delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicyAttachPointProcessor.java (limited to 'sca-java-1.x/tags/1.6.1-TUSCANY-3909/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicyAttachPointProcessor.java') diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicyAttachPointProcessor.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicyAttachPointProcessor.java deleted file mode 100644 index 44be1b6de1..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicyAttachPointProcessor.java +++ /dev/null @@ -1,257 +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.assembly.xml; - -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.IntentAttachPoint; -import org.apache.tuscany.sca.policy.PolicyFactory; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; - -/** - * A Policy Attach Point processor. - * - * @version $Rev$ $Date$ - */ -public class PolicyAttachPointProcessor extends BaseStAXArtifactProcessor implements Constants { - - private PolicyFactory policyFactory; - - public PolicyAttachPointProcessor(PolicyFactory policyFactory) { - this.policyFactory = policyFactory; - } - - /** - * Read policy intents associated with an operation. - * @param attachPoint - * @param operation - * @param reader - */ - private void readIntents(Object attachPoint, Operation operation, XMLStreamReader reader) { - if (!(attachPoint instanceof IntentAttachPoint)) - return; - IntentAttachPoint intentAttachPoint = (IntentAttachPoint)attachPoint; - String value = reader.getAttributeValue(null, REQUIRES); - if (value != null) { - List requiredIntents = intentAttachPoint.getRequiredIntents(); - for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) { - QName qname = getQNameValue(reader, tokens.nextToken()); - Intent intent = policyFactory.createIntent(); - intent.setName(qname); - if (operation != null) { - //FIXME Don't we need to handle intent specification - // on an operation basis? - //intent.getOperations().add(operation); - } - requiredIntents.add(intent); - } - } - } - - /** - * Reads policy intents and policy sets associated with an operation. - * @param attachPoint - * @param operation - * @param reader - */ - public void readPolicies(Object attachPoint, Operation operation, XMLStreamReader reader) { - readIntents(attachPoint, operation, reader); - readPolicySets(attachPoint, operation, reader); - } - - /** - * Reads policy intents and policy sets. - * @param attachPoint - * @param reader - */ - public void readPolicies(Object attachPoint, XMLStreamReader reader) { - readPolicies(attachPoint, null, reader); - } - - /** - * Reads policy sets associated with an operation. - * @param attachPoint - * @param operation - * @param reader - */ - private void readPolicySets(Object attachPoint, Operation operation, XMLStreamReader reader) { - if (!(attachPoint instanceof PolicySetAttachPoint)) { - return; - } - PolicySetAttachPoint policySetAttachPoint = (PolicySetAttachPoint)attachPoint; - String value = reader.getAttributeValue(null, POLICY_SETS); - if (value != null) { - List policySets = policySetAttachPoint.getPolicySets(); - for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) { - QName qname = getQNameValue(reader, tokens.nextToken()); - PolicySet policySet = policyFactory.createPolicySet(); - policySet.setName(qname); - if (operation != null) { - //FIXME Don't we need to handle policySet specification - // on an operation basis? - //policySet.getOperations().add(operation); - } - policySets.add(policySet); - } - } - - value = reader.getAttributeValue(SCA10_TUSCANY_NS, APPLICABLE_POLICY_SETS); - if (value != null) { - List applicablePolicySets = policySetAttachPoint.getApplicablePolicySets(); - for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) { - QName qname = getQNameValue(reader, tokens.nextToken()); - PolicySet policySet = policyFactory.createPolicySet(); - policySet.setName(qname); - if (operation != null) { - //FIXME Don't we need to handle policySet specification - // on an operation basis? - //policySet.getOperations().add(operation); - } - applicablePolicySets.add(policySet); - } - } - } - - /** - * Write policies - * @param attachPoint - * @return - */ - XAttr writePolicies(Object attachPoint) throws XMLStreamException { - return writePolicies(attachPoint, (Operation)null); - } - - /** - * Write policies - * @param attachPoint - * @return - */ - public void writePolicyAttributes(Object attachPoint, XMLStreamWriter writer) throws XMLStreamException { - writePolicyAttributes(attachPoint, (Operation)null, writer); - } - - /** - * Write policies associated with an operation - * @param attachPoint - * @param operation - * @return - */ - XAttr writePolicies(Object attachPoint, Operation operation) { - List attrs =new ArrayList(); - attrs.add(writeIntents(attachPoint, operation)); - attrs.add(writePolicySets(attachPoint, operation)); - return new XAttr(null, attrs); - } - - /** - * Write policies - * @param attachPoint - * @return - */ - public void writePolicyAttributes(Object attachPoint, Operation operation, XMLStreamWriter writer) throws XMLStreamException { - XAttr attr = writePolicies(attachPoint, operation); - attr.write(writer); - } - - /** - * Write policies - * @param attachPoint - * @return - */ - public void writePolicyPrefixes(Object attachPoint, Operation operation, XMLStreamWriter writer) throws XMLStreamException { - XAttr attr = writePolicies(attachPoint, operation); - attr.writePrefix(writer); - } - - /** - * Write policy intents associated with an operation. - * @param attachPoint - * @param operation - */ - private XAttr writeIntents(Object attachPoint, Operation operation) { - if (!(attachPoint instanceof IntentAttachPoint)) { - return null; - } - IntentAttachPoint intentAttachPoint = (IntentAttachPoint)attachPoint; - List qnames = new ArrayList(); - for (Intent intent: intentAttachPoint.getRequiredIntents()) { - qnames.add(intent.getName()); - } - return new XAttr(Constants.REQUIRES, qnames); - } - - /** - * Write policy sets associated with an operation. - * @param attachPoint - * @param operation - */ - private XAttr writePolicySets(Object attachPoint, Operation operation) { - if (!(attachPoint instanceof PolicySetAttachPoint)) { - return null; - } - PolicySetAttachPoint policySetAttachPoint = (PolicySetAttachPoint)attachPoint; - List qnames = new ArrayList(); - for (PolicySet policySet: policySetAttachPoint.getPolicySets()) { - qnames.add(policySet.getName()); - } - return new XAttr(Constants.POLICY_SETS, qnames); - } - - public void resolvePolicies(Object attachPoint, ModelResolver resolver) { - if ( attachPoint instanceof PolicySetAttachPoint ) { - PolicySetAttachPoint policySetAttachPoint = (PolicySetAttachPoint)attachPoint; - - List requiredIntents = new ArrayList(); - Intent resolvedIntent = null; - - if ( policySetAttachPoint.getRequiredIntents() != null && policySetAttachPoint.getRequiredIntents().size() > 0 ) { - for ( Intent intent : policySetAttachPoint.getRequiredIntents() ) { - resolvedIntent = resolver.resolveModel(Intent.class, intent); - requiredIntents.add(resolvedIntent); - } - policySetAttachPoint.getRequiredIntents().clear(); - policySetAttachPoint.getRequiredIntents().addAll(requiredIntents); - } - - if ( policySetAttachPoint.getPolicySets() != null && policySetAttachPoint.getPolicySets().size() > 0 ) { - List resolvedPolicySets = new ArrayList(); - PolicySet resolvedPolicySet = null; - for ( PolicySet policySet : policySetAttachPoint.getPolicySets() ) { - resolvedPolicySet = resolver.resolveModel(PolicySet.class, policySet); - resolvedPolicySets.add(resolvedPolicySet); - } - policySetAttachPoint.getPolicySets().clear(); - policySetAttachPoint.getPolicySets().addAll(resolvedPolicySets); - } - } - } -} -- cgit v1.2.3