/** * Write the xml for a {@link Component}. * * @param component * @param contentHandler * @throws SAXException */ protected static void generateXML( final String namespace, final Component component, final ContentHandler contentHandler, final boolean isScrPrivateFile) throws SAXException { final AttributesImpl ai = new AttributesImpl(); IOUtils.addAttribute(ai, COMPONENT_ATTR_ENABLED, component.isEnabled()); IOUtils.addAttribute(ai, COMPONENT_ATTR_IMMEDIATE, component.isImmediate()); IOUtils.addAttribute(ai, COMPONENT_ATTR_NAME, component.getName()); IOUtils.addAttribute(ai, COMPONENT_ATTR_FACTORY, component.getFactory()); // attributes new in 1.1 if (NAMESPACE_URI_1_1.equals(namespace) || NAMESPACE_URI_1_1_FELIX.equals(namespace)) { IOUtils.addAttribute(ai, COMPONENT_ATTR_POLICY, component.getConfigurationPolicy()); IOUtils.addAttribute(ai, COMPONENT_ATTR_ACTIVATE, component.getActivate()); IOUtils.addAttribute(ai, COMPONENT_ATTR_DEACTIVATE, component.getDeactivate()); IOUtils.addAttribute(ai, COMPONENT_ATTR_MODIFIED, component.getModified()); } IOUtils.indent(contentHandler, 1); contentHandler.startElement( namespace, ComponentDescriptorIO.COMPONENT, ComponentDescriptorIO.COMPONENT_QNAME, ai); IOUtils.newline(contentHandler); generateXML(component.getImplementation(), contentHandler); if (component.getService() != null) { generateXML(component.getService(), contentHandler); } if (component.getProperties() != null) { for (final Property property : component.getProperties()) { generateXML(property, contentHandler, isScrPrivateFile); } } if (component.getReferences() != null) { for (final Reference reference : component.getReferences()) { generateXML(namespace, reference, contentHandler, isScrPrivateFile); } } IOUtils.indent(contentHandler, 1); contentHandler.endElement( namespace, ComponentDescriptorIO.COMPONENT, ComponentDescriptorIO.COMPONENT_QNAME); IOUtils.newline(contentHandler); }