diff options
Diffstat (limited to 'branches/sca-equinox/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/xml')
-rw-r--r-- | branches/sca-equinox/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/xml/GdataBindingProcessor.java | 83 |
1 files changed, 24 insertions, 59 deletions
diff --git a/branches/sca-equinox/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/xml/GdataBindingProcessor.java b/branches/sca-equinox/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/xml/GdataBindingProcessor.java index 18795837c4..660b96243e 100644 --- a/branches/sca-equinox/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/xml/GdataBindingProcessor.java +++ b/branches/sca-equinox/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/xml/GdataBindingProcessor.java @@ -18,9 +18,6 @@ */ package org.apache.tuscany.sca.binding.gdata.xml; -import java.util.ArrayList; -import java.util.List; - import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; @@ -34,27 +31,21 @@ import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; import org.apache.tuscany.sca.contribution.resolver.ModelResolver; import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.IntentAttachPointType; -import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; /** * A processor for <binding.gdata> elements. + * + * @version $Rev$ $Date$ */ public class GdataBindingProcessor implements StAXArtifactProcessor<GdataBinding> { private QName BINDING_GDATA = new QName("http://tuscany.apache.org/xmlns/sca/1.0", "binding.gdata"); private final GdataBindingFactory factory; - private IntentAttachPointTypeFactory intentAttachPointTypeFactory; - //private PolicyAttachPointProcessor policyProcessor; - public GdataBindingProcessor(FactoryExtensionPoint modelFactories) { this.factory = modelFactories.getFactory(GdataBindingFactory.class); - this.intentAttachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class); + System.out.println("[Debug Info]GdataBindingProcessor reached"); } public QName getArtifactType() { @@ -67,90 +58,64 @@ public class GdataBindingProcessor implements StAXArtifactProcessor<GdataBinding public GdataBinding read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { GdataBinding gdataBinding = factory.createGdataBinding(); - IntentAttachPointType bindingType = intentAttachPointTypeFactory.createBindingType(); - bindingType.setName(getArtifactType()); - bindingType.setUnresolved(true); - ((PolicySetAttachPoint)gdataBinding).setType(bindingType); String name = reader.getAttributeValue(null, "name"); if (name != null) { - gdataBinding.setName(name); + gdataBinding.setName(name); } String uri = reader.getAttributeValue(null, "uri"); if (uri != null) { - gdataBinding.setURI(uri); + gdataBinding.setURI(uri); } - + String serviceType = reader.getAttributeValue(null, "serviceType"); if (serviceType != null) { - gdataBinding.setServiceType(serviceType); + gdataBinding.setServiceType(serviceType); } - + String username = reader.getAttributeValue(null, "username"); if (username != null) { - gdataBinding.setUsername(username); + gdataBinding.setUsername(username); } - + String password = reader.getAttributeValue(null, "password"); if (password != null) { - gdataBinding.setPassword(password); + gdataBinding.setPassword(password); } - - //policyProcessor.readPolicies(echoBinding, reader); + return gdataBinding; } public void write(GdataBinding gdataBinding, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { - - //policyProcessor.writePolicyPrefixes(gdataBinding, writer); writer.writeStartElement(BINDING_GDATA.getNamespaceURI(), BINDING_GDATA.getLocalPart()); - //policyProcessor.writePolicyAttributes(gdataBinding, writer); - + if (gdataBinding.getName() != null) { - writer.writeAttribute("name", gdataBinding.getName()); + writer.writeAttribute("name", gdataBinding.getName()); } - + if (gdataBinding.getURI() != null) { - writer.writeAttribute("uri", gdataBinding.getURI()); + writer.writeAttribute("uri", gdataBinding.getURI()); } - + if (gdataBinding.getServiceType() != null) { - writer.writeAttribute("serviceType", gdataBinding.getServiceType()); + writer.writeAttribute("serviceType", gdataBinding.getServiceType()); } - + if (gdataBinding.getUsername() != null) { - writer.writeAttribute("username", gdataBinding.getUsername()); + writer.writeAttribute("username", gdataBinding.getUsername()); } - + if (gdataBinding.getPassword() != null) { - writer.writeAttribute("password", gdataBinding.getPassword()); + writer.writeAttribute("password", gdataBinding.getPassword()); } - + writer.writeEndElement(); } - //FIXME: Resolve the attached policySet, might not needed (the echo binding implementation example) public void resolve(GdataBinding gdataBinding, ModelResolver resolver) throws ContributionResolveException { - PolicySetAttachPoint policySetAttachPoint = (PolicySetAttachPoint)gdataBinding; - List<Intent> requiredIntents = new ArrayList<Intent>(); - Intent resolvedIntent = null; - for ( Intent intent : policySetAttachPoint.getRequiredIntents() ) { - resolvedIntent = resolver.resolveModel(Intent.class, intent); - requiredIntents.add(resolvedIntent); - } - policySetAttachPoint.getRequiredIntents().clear(); - policySetAttachPoint.getRequiredIntents().addAll(requiredIntents); - - List<PolicySet> resolvedPolicySets = new ArrayList<PolicySet>(); - PolicySet resolvedPolicySet = null; - for ( PolicySet policySet : policySetAttachPoint.getPolicySets() ) { - resolvedPolicySet = resolver.resolveModel(PolicySet.class, policySet); - resolvedPolicySets.add(resolvedPolicySet); - } - policySetAttachPoint.getPolicySets().clear(); - policySetAttachPoint.getPolicySets().addAll(resolvedPolicySets); + } } |