public void write(T bean, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException { try { // Write the bean properties as attributes List<XAttr> attrs = new ArrayList<XAttr>(); for (Map.Entry<String, Method> entry: getterMethods.entrySet()) { if (entry.getValue().getReturnType() == String.class) { String value = (String)entry.getValue().invoke(bean); attrs.add(new XAttr(entry.getKey(), value)); } } // Write element writeStart(writer, artifactType.getNamespaceURI(), artifactType.getLocalPart(), policyProcessor.writePolicies(bean), new XAttr(null, attrs)); writeEnd(writer); } catch (Exception e) { ContributionWriteException ce = new ContributionWriteException(e); error(context.getMonitor(), "ContributionWriteException", writer, ce); throw ce; } }
str = writeQNameValue(writer, (QName)value); ((XAttr)v).write(writer); continue; buffer.append(writeQNameValue(writer, (QName)v)); } else {
new XAttr(TARGET_NAMESPACE, composite.getName().getNamespaceURI()), new XAttr(NAME, composite.getName().getLocalPart()), new XAttr(LOCAL, composite.isLocal() ? Boolean.TRUE : null), new XAttr(AUTOWIRE, composite.getAutowire()), policyProcessor.writePolicies(composite)); writeStart(writer, INCLUDE, new XAttr(NAME, include.getName()), new XAttr(URI, uri)); new XAttr(NAME, service.getName()), new XAttr(PROMOTE, promote), policyProcessor.writePolicies(service)); writeStart(writer, COMPONENT, new XAttr(NAME, component.getName()), new XAttr(URI, component.getURI()), new XAttr(AUTOWIRE, component.getAutowire()), policyProcessor.writePolicies(component)); writeStart(writer, IMPLEMENTATION_COMPOSITE, new XAttr(NAME, ((Composite)implementation).getName()), policyProcessor.writePolicies(implementation)); writeStart(writer, SERVICE, new XAttr(NAME, service.getName()), policyProcessor.writePolicies(service)); writeStart(writer, REFERENCE, new XAttr(NAME, reference.getName()), new XAttr(AUTOWIRE, reference.getAutowire()), (reference.isNonOverridable() ? new XAttr(NONOVERRIDABLE, true) : null), writeMultiplicity(reference),
new XAttr(TARGET_NAMESPACE, composite.getName().getNamespaceURI()), new XAttr(NAME, composite.getName().getLocalPart()), new XAttr(LOCAL, composite.isLocal() ? Boolean.TRUE : null), new XAttr(AUTOWIRE, composite.getAutowire()), policyProcessor.writePolicies(composite)); writeStart(writer, INCLUDE, new XAttr(NAME, include.getName()), new XAttr(URI, uri)); new XAttr(NAME, service.getName()), new XAttr(PROMOTE, promote), policyProcessor.writePolicies(service)); writeStart(writer, COMPONENT, new XAttr(NAME, component.getName()), new XAttr(URI, component.getURI()), new XAttr(AUTOWIRE, component.getAutowire()), policyProcessor.writePolicies(component)); writeStart(writer, IMPLEMENTATION_COMPOSITE, new XAttr(NAME, ((Composite)implementation).getName()), policyProcessor.writePolicies(implementation)); writeStart(writer, SERVICE, new XAttr(NAME, service.getName()), policyProcessor.writePolicies(service)); writeStart(writer, REFERENCE, new XAttr(NAME, reference.getName()), new XAttr(AUTOWIRE, reference.getAutowire()), (reference.isNonOverridable() ? new XAttr(NONOVERRIDABLE, true) : null), writeMultiplicity(reference),
writeStart(writer, SERVICE, new XAttr(NAME, service.getName()), policyProcessor.writePolicies(service)); new XAttr(NAME, reference.getName()), writeMultiplicity(reference), writeTargets(reference), writeStart(writer, PROPERTY, new XAttr(NAME, property.getName()), new XAttr(MUST_SUPPLY, property.isMustSupply()), new XAttr(MANY, property.isMany()), new XAttr(TYPE, property.getXSDType()), new XAttr(ELEMENT, property.getXSDElement()), policyProcessor.writePolicies(property));
writeStart(writer, SERVICE, new XAttr(NAME, service.getName()), policyProcessor.writePolicies(service)); new XAttr(NAME, reference.getName()), writeMultiplicity(reference), writeTargets(reference), writeStart(writer, PROPERTY, new XAttr(NAME, property.getName()), new XAttr(MUST_SUPPLY, property.isMustSupply()), new XAttr(MANY, property.isMany()), new XAttr(TYPE, property.getXSDType()), new XAttr(ELEMENT, property.getXSDElement()), policyProcessor.writePolicies(property));
NODE.getNamespaceURI(), NODE.getLocalPart(), new XAttr("uri", node.getURI()), new XAttr("domainRegistry", node.getDomainRegistryURI()), new XAttr("domain", node.getDomainURI())); CONTRIBUTION.getNamespaceURI(), CONTRIBUTION.getLocalPart(), new XAttr("uri", c.getURI()), new XAttr("location", c.getLocation())); for (DeploymentComposite dc : c.getDeploymentComposites()) { writeStart(writer, DEPLOYMENT_COMPOSITE.getNamespaceURI(), DEPLOYMENT_COMPOSITE.getLocalPart(), new XAttr("location", dc.getLocation()), new XAttr("contribution", dc.getContributionURI())); if (dc.getContent() != null) { XMLStreamReader reader = helper.createXMLStreamReader(new StringReader(dc.getContent())); BINDING.getNamespaceURI(), BINDING.getLocalPart(), new XAttr("name", b.getBindingType()), new XAttr("baseURIs", baseURIs)); writeEnd(writer);
str = writeQNameValue(writer, (QName)value); ((XAttr)v).write(writer); continue; buffer.append(writeQNameValue(writer, (QName)v)); } else {
NODE.getNamespaceURI(), NODE.getLocalPart(), new XAttr("uri", node.getURI()), new XAttr("domainRegistry", node.getDomainRegistryURI()), new XAttr("domain", node.getDomainURI())); CONTRIBUTION.getNamespaceURI(), CONTRIBUTION.getLocalPart(), new XAttr("uri", c.getURI()), new XAttr("location", c.getLocation())); for (DeploymentComposite dc : c.getDeploymentComposites()) { writeStart(writer, DEPLOYMENT_COMPOSITE.getNamespaceURI(), DEPLOYMENT_COMPOSITE.getLocalPart(), new XAttr("location", dc.getLocation()), new XAttr("contribution", dc.getContributionURI())); if (dc.getContent() != null) { XMLStreamReader reader = helper.createXMLStreamReader(new StringReader(dc.getContent())); BINDING.getNamespaceURI(), BINDING.getLocalPart(), new XAttr("name", b.getBindingType()), new XAttr("baseURIs", baseURIs)); writeEnd(writer);
public void write(ContributionMetadata contribution, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException { // Write <contribution> writeStartDocument(writer, CONTRIBUTION_QNAME.getNamespaceURI(), CONTRIBUTION_QNAME.getLocalPart()); writeExtendedAttributes(writer, contribution, attributeProcessor, context); // Write <import> for (Import imp : contribution.getImports()) { extensionProcessor.write(imp, writer, context); } // Write <export> for (Export export : contribution.getExports()) { extensionProcessor.write(export, writer, context); } // Write <deployable> for (Composite deployable : contribution.getDeployables()) { writeStart(writer, DEPLOYABLE_QNAME.getNamespaceURI(), DEPLOYABLE_QNAME.getLocalPart(), new XAttr("composite", deployable.getName())); writeEnd(writer); } writeEndDocument(writer); }
public void write(ContributionMetadata contribution, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException { // Write <contribution> writeStartDocument(writer, CONTRIBUTION_QNAME.getNamespaceURI(), CONTRIBUTION_QNAME.getLocalPart()); writeExtendedAttributes(writer, contribution, attributeProcessor, context); // Write <import> for (Import imp : contribution.getImports()) { extensionProcessor.write(imp, writer, context); } // Write <export> for (Export export : contribution.getExports()) { extensionProcessor.write(export, writer, context); } // Write <deployable> for (Composite deployable : contribution.getDeployables()) { writeStart(writer, DEPLOYABLE_QNAME.getNamespaceURI(), DEPLOYABLE_QNAME.getLocalPart(), new XAttr("composite", deployable.getName())); writeEnd(writer); } writeEndDocument(writer); }
public void write(Definitions definitions, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException { writeStartDocument(writer, SCA11_NS, DEFINITIONS, new XAttr(TARGET_NAMESPACE, definitions.getTargetNamespace())); for (Intent policyIntent : definitions.getIntents()) { extensionProcessor.write(policyIntent, writer, context); } for (PolicySet policySet : definitions.getPolicySets()) { extensionProcessor.write(policySet, writer, context); } for (Binding binding : definitions.getBindings()) { extensionProcessor.write(binding, writer, context); } for (BindingType bindingType : definitions.getBindingTypes()) { extensionProcessor.write(bindingType, writer, context); } for (ImplementationType implType : definitions.getImplementationTypes()) { extensionProcessor.write(implType, writer, context); } writeEndDocument(writer); }
protected XAttr writeMultiplicity(AbstractReference reference) { Multiplicity multiplicity = reference.getMultiplicity(); if (multiplicity != null) { String value = null; if (Multiplicity.ZERO_ONE.equals(multiplicity)) { value = ZERO_ONE; } else if (Multiplicity.ONE_N.equals(multiplicity)) { value = ONE_N; } else if (Multiplicity.ZERO_N.equals(multiplicity)) { value = ZERO_N; } else if (Multiplicity.ONE_ONE.equals(multiplicity)) { value = ONE_ONE; return null; } return new XAttr(MULTIPLICITY, value); } return null; }
public void write(Definitions definitions, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException { writeStartDocument(writer, SCA11_NS, DEFINITIONS, new XAttr(TARGET_NAMESPACE, definitions.getTargetNamespace())); for (Intent policyIntent : definitions.getIntents()) { extensionProcessor.write(policyIntent, writer, context); } for (PolicySet policySet : definitions.getPolicySets()) { extensionProcessor.write(policySet, writer, context); } for (Binding binding : definitions.getBindings()) { extensionProcessor.write(binding, writer, context); } for (BindingType bindingType : definitions.getBindingTypes()) { extensionProcessor.write(bindingType, writer, context); } for (ImplementationType implType : definitions.getImplementationTypes()) { extensionProcessor.write(implType, writer, context); } writeEndDocument(writer); }
public void write(SCAConfig definitions, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException { writeStartDocument(writer, SCA_CONFIG_QNAME.getNamespaceURI(), SCA_CONFIG_QNAME.getLocalPart(), new XAttr("targetNamespace", definitions.getTargetNamespace())); for (Binding binding : definitions.getBindings()) { processor.write(binding, writer, context); } for (Intent policyIntent : definitions.getIntents()) { processor.write(policyIntent, writer, context); } for (PolicySet policySet : definitions.getPolicySets()) { processor.write(policySet, writer, context); } writeEndDocument(writer); }
protected XAttr writeMultiplicity(AbstractReference reference) { Multiplicity multiplicity = reference.getMultiplicity(); if (multiplicity != null) { String value = null; if (Multiplicity.ZERO_ONE.equals(multiplicity)) { value = ZERO_ONE; } else if (Multiplicity.ONE_N.equals(multiplicity)) { value = ONE_N; } else if (Multiplicity.ZERO_N.equals(multiplicity)) { value = ZERO_N; } else if (Multiplicity.ONE_ONE.equals(multiplicity)) { value = ONE_ONE; return null; } return new XAttr(MULTIPLICITY, value); } return null; }
public void write(T bean, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException { try { // Write the bean properties as attributes List<XAttr> attrs = new ArrayList<XAttr>(); for (Map.Entry<String, Method> entry: getterMethods.entrySet()) { if (entry.getValue().getReturnType() == String.class) { String value = (String)entry.getValue().invoke(bean); attrs.add(new XAttr(entry.getKey(), value)); } } // Write element writeStart(writer, artifactType.getNamespaceURI(), artifactType.getLocalPart(), policyProcessor.writePolicies(bean), new XAttr(null, attrs)); writeEnd(writer); } catch (Exception e) { ContributionWriteException ce = new ContributionWriteException(e); error(context.getMonitor(), "ContributionWriteException", writer, ce); throw ce; } }
/** * Write policy sets associated with an operation. * @param subject * @param operation */ private XAttr writePolicySets(Object subject, Operation operation) { if (!(subject instanceof PolicySubject)) { return null; } PolicySubject policySetAttachPoint = (PolicySubject)subject; List<QName> qnames = new ArrayList<QName>(); for (PolicySet policySet: policySetAttachPoint.getPolicySets()) { qnames.add(policySet.getName()); } return new XAttr(Constants.POLICY_SETS, qnames); }