List of usage examples for javax.xml.stream XMLStreamWriter writeCharacters
public void writeCharacters(String text) throws XMLStreamException;
From source file:org.tolven.assembler.facesconfig.FacesConfigAssembler.java
/** * Add the global template if-clause for converterId * /*from w w w . j av a2 s . co m*/ * @param converterId * @param converterClass * @param xmlStreamWriter * @throws XMLStreamException */ protected void addGlobalConverter(String converterId, String converterClass, XMLStreamWriter xmlStreamWriter) throws XMLStreamException { xmlStreamWriter.writeStartElement("xsl:if"); xmlStreamWriter.writeAttribute("test", "count(tp:converter[tp:converter-id = '" + converterId + "']) = 0"); xmlStreamWriter.writeStartElement("converter"); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("converter-id"); xmlStreamWriter.writeCharacters(converterId); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); if (converterClass != null) { xmlStreamWriter.writeStartElement("converter-class"); xmlStreamWriter.writeCharacters(converterClass); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); } xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); }
From source file:org.tolven.assembler.facesconfig.FacesConfigAssembler.java
protected boolean addLifeCycleTemplates(PluginDescriptor pluginDescriptor, XMLStreamWriter xmlStreamWriter) throws XMLStreamException { boolean added = false; xmlStreamWriter.writeStartElement("xsl:template"); xmlStreamWriter.writeAttribute("name", "addLifeCycles"); xmlStreamWriter.writeCharacters("\n"); for (Extension extension : getExtensions(pluginDescriptor, "lifecycle")) { Parameter phaseListener = extension.getParameter("phase-listener"); String phaseListenerString = null; if (phaseListener != null) { phaseListenerString = phaseListener.valueAsString(); }// w w w .j a va 2 s . co m addLifeCycle(phaseListenerString, xmlStreamWriter); added = true; } xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); return added; }
From source file:org.tolven.assembler.facesconfig.FacesConfigAssembler.java
protected void addLifeCycle(String phaseListener, XMLStreamWriter xmlStreamWriter) throws XMLStreamException { xmlStreamWriter.writeStartElement("xsl:if"); xmlStreamWriter.writeAttribute("test", "count(tp:lifecycle[tp:phase-listener = '" + phaseListener + "']) = 0"); xmlStreamWriter.writeStartElement("lifecycle"); if (phaseListener != null) { xmlStreamWriter.writeStartElement("phase-listener"); xmlStreamWriter.writeCharacters(phaseListener); xmlStreamWriter.writeEndElement(); }//from w ww . j a v a2 s .com xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); }
From source file:org.tolven.assembler.facesconfig.FacesConfigAssembler.java
protected boolean addNavigationRuleTemplates(PluginDescriptor warPluginDescriptor, XMLStreamWriter xmlStreamWriter) throws XMLStreamException { boolean added = false; xmlStreamWriter.writeStartElement("xsl:template"); xmlStreamWriter.writeAttribute("name", "addNavigationRules"); xmlStreamWriter.writeCharacters("\n"); Map<String, Map<String, Object>> navigationRuleMap = new HashMap<String, Map<String, Object>>(); for (Extension defaultExtension : getNavigationRuleExtensions(warPluginDescriptor, true)) { String fromViewId = defaultExtension.getParameter("from-view-id").valueAsString(); Map<String, Object> map = new HashMap<String, Object>(); map.put("navigationRuleExtension", defaultExtension); navigationRuleMap.put(fromViewId, map); added = true;/*ww w .j a va2 s. co m*/ } for (Extension nonDefaultExtension : getNavigationRuleExtensions(warPluginDescriptor, false)) { String fromViewId = nonDefaultExtension.getParameter("from-view-id").valueAsString(); Extension navigationRuleExtension = null; Map<String, Object> map = (Map<String, Object>) navigationRuleMap.get(fromViewId); if (map == null) { map = new HashMap<String, Object>(); navigationRuleMap.put(fromViewId, map); } else { navigationRuleExtension = (Extension) map.get("navigationRuleExtension"); if (nonDefaultExtension.getParameter("override") == null) { throw new RuntimeException( nonDefaultExtension.getUniqueId() + " requires an override parameter to override " + navigationRuleExtension.getUniqueId()); } logger.debug( nonDefaultExtension.getUniqueId() + " overrides " + navigationRuleExtension.getUniqueId()); } navigationRuleMap.get(fromViewId).put("navigationRuleExtension", nonDefaultExtension); added = true; } for (String fromViewId : navigationRuleMap.keySet()) { Map<String, Object> map = navigationRuleMap.get(fromViewId); Extension navigationRuleExtension = (Extension) map.get("navigationRuleExtension"); Map<String, Parameter> caseParameterMap = new HashMap<String, Parameter>(); for (Parameter parameter : navigationRuleExtension.getParameters("navigation-case")) { String fromAction = null; Parameter fromActionParameter = parameter.getSubParameter("from-action"); if (fromActionParameter == null) { fromAction = null; } else { fromAction = fromActionParameter.valueAsString(); } String fromOutcome = null; Parameter fromOutcomeParameter = parameter.getSubParameter("from-outcome"); if (fromOutcomeParameter == null) { fromOutcome = null; } else { fromOutcome = fromOutcomeParameter.valueAsString(); } Parameter toViewIdParameter = parameter.getSubParameter("to-view-id"); //caseParameter map has key which is concatentation of fromAction, fromOutcomeParameter and toViewIdParameter caseParameterMap.put(fromAction + fromOutcome + toViewIdParameter.valueAsString(), parameter); } map.put("caseParameterMap", caseParameterMap); added = true; } for (Extension navigationRuleContributionExtension : getNavigationRuleContributionExtensions( warPluginDescriptor)) { String fromViewId = navigationRuleContributionExtension.getParameter("from-view-id").valueAsString(); Map<String, Object> map = navigationRuleMap.get(fromViewId); Extension navigationRuleExtension = (Extension) map.get("navigationRuleExtension"); Map<String, Parameter> caseParameterMap = (Map<String, Parameter>) map.get("caseParameterMap"); if (navigationRuleExtension == null) { throw new RuntimeException(navigationRuleContributionExtension.getUniqueId() + " refers to a navigation-rule that does not exist with from-view-id: " + fromViewId); } Parameter contributingCaseParameter = navigationRuleContributionExtension .getParameter("navigation-case"); Parameter contributingFromActionParameter = contributingCaseParameter.getSubParameter("from-action"); String contributingFromAction = null; if (contributingFromActionParameter == null) { contributingFromAction = ""; } else { contributingFromAction = contributingFromActionParameter.valueAsString(); } Parameter contributingFromOutcomeParameter = contributingCaseParameter.getSubParameter("from-outcome"); String contributingFromOutcome = null; if (contributingFromOutcomeParameter == null) { contributingFromOutcome = ""; } else { contributingFromOutcome = contributingFromOutcomeParameter.valueAsString(); } String key = contributingFromAction + fromViewId + contributingFromOutcome; Parameter caseParameter = caseParameterMap.get(key); if (caseParameter != null) { if (navigationRuleContributionExtension.getParameter("override") == null) { throw new RuntimeException(navigationRuleContributionExtension.getUniqueId() + " requires an override parameter to override navigation-case in: " + navigationRuleExtension.getUniqueId()); } logger.debug(navigationRuleContributionExtension.getUniqueId() + " overrides navigation-case in: " + navigationRuleExtension.getUniqueId()); } caseParameterMap.put(key, contributingCaseParameter); added = true; } Comparator<String> navigationRuleComparator = new Comparator<String>() { public int compare(String string1, String string2) { return string1.compareTo(string2); }; }; List<String> fromViewIdList = new ArrayList<String>(); fromViewIdList.addAll(navigationRuleMap.keySet()); Collections.sort(fromViewIdList, navigationRuleComparator); for (String fromViewId : fromViewIdList) { Map<String, Object> map = navigationRuleMap.get(fromViewId); Extension navigationRuleExtension = (Extension) map.get("navigationRuleExtension"); xmlStreamWriter.writeStartElement("xsl:if"); xmlStreamWriter.writeAttribute("test", "count(tp:navigation-rule[tp:from-view-id = '" + fromViewId + "']) = 0"); xmlStreamWriter.writeStartElement("navigation-rule"); xmlStreamWriter.writeCharacters("\n"); Parameter descriptionParameter = navigationRuleExtension.getParameter("description"); if (descriptionParameter != null) { xmlStreamWriter.writeStartElement("description"); xmlStreamWriter.writeCharacters(descriptionParameter.valueAsString()); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); } xmlStreamWriter.writeStartElement("from-view-id"); xmlStreamWriter.writeCharacters(fromViewId); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); Map<String, Parameter> caseParameterMap = (Map<String, Parameter>) map.get("caseParameterMap"); List<Parameter> caseParameterList = new ArrayList<Parameter>(); caseParameterList.addAll(caseParameterMap.values()); Comparator<Parameter> caseParameterComparator = new Comparator<Parameter>() { public int compare(Parameter p1, Parameter p2) { Parameter p1FromActionParameter = p1.getSubParameter("from-action"); Parameter p1FromOutcomeParameter = p1.getSubParameter("from-outcome"); Parameter p1RedirectParameter = p1.getSubParameter("redirect"); Parameter p2FromActionParameter = p2.getSubParameter("from-action"); Parameter p2FromOutcomeParameter = p2.getSubParameter("from-outcome"); Parameter p2RedirectParameter = p2.getSubParameter("redirect"); String s1 = (p1FromActionParameter == null ? "null" : p1FromActionParameter.valueAsString()) + (p1FromOutcomeParameter == null ? "null" : p1FromOutcomeParameter.valueAsString()) + (p1RedirectParameter == null ? "null" : p1RedirectParameter.valueAsString()); String s2 = (p2FromActionParameter == null ? "null" : p2FromActionParameter.valueAsString()) + (p2FromOutcomeParameter == null ? "null" : p2FromOutcomeParameter.valueAsString()) + (p2RedirectParameter == null ? "null" : p2RedirectParameter.valueAsString()); return s1.compareTo(s2); }; }; Collections.sort(caseParameterList, caseParameterComparator); for (Parameter parameter : caseParameterList) { xmlStreamWriter.writeStartElement("navigation-case"); xmlStreamWriter.writeCharacters("\n"); Parameter fromActionParameter = parameter.getSubParameter("from-action"); if (fromActionParameter != null) { xmlStreamWriter.writeStartElement("from-action"); xmlStreamWriter.writeCharacters(fromActionParameter.valueAsString()); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); } Parameter fromOutcomeParameter = parameter.getSubParameter("from-outcome"); if (fromOutcomeParameter != null) { xmlStreamWriter.writeStartElement("from-outcome"); xmlStreamWriter.writeCharacters(fromOutcomeParameter.valueAsString()); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); } xmlStreamWriter.writeStartElement("to-view-id"); xmlStreamWriter.writeCharacters(parameter.getSubParameter("to-view-id").valueAsString()); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); Parameter redirectParameter = parameter.getSubParameter("redirect"); if (redirectParameter != null) { xmlStreamWriter.writeEmptyElement("redirect"); xmlStreamWriter.writeCharacters("\n"); } xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); } xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); added = true; } xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); return added; }
From source file:org.tolven.assembler.facesconfig.FacesConfigAssembler.java
/** * Add managed bean templates./*w w w . j a v a2 s .c om*/ * * @param warPluginDescriptor * @param xmlStreamWriter * @throws XMLStreamException */ protected boolean addManagedBeanTemplates(PluginDescriptor warPluginDescriptor, XMLStreamWriter xmlStreamWriter) throws XMLStreamException { boolean added = false; xmlStreamWriter.writeStartElement("xsl:template"); xmlStreamWriter.writeAttribute("name", "addManagedBeans"); xmlStreamWriter.writeCharacters("\n"); Map<String, Extension> managedBeanMap = new HashMap<String, Extension>(); for (Extension defaultExtension : getManagedBeanExtensions(warPluginDescriptor, true)) { String beanName = defaultExtension.getParameter("managed-bean-name").valueAsString(); managedBeanMap.put(beanName, defaultExtension); added = true; } for (Extension nonDefaultExtension : getManagedBeanExtensions(warPluginDescriptor, false)) { String beanName = nonDefaultExtension.getParameter("managed-bean-name").valueAsString(); Extension managedBeanExtension = managedBeanMap.get(beanName); if (managedBeanExtension != null) { if (nonDefaultExtension.getParameter("override") == null) { throw new RuntimeException(nonDefaultExtension.getUniqueId() + " requires an override parameter to override " + managedBeanExtension.getUniqueId()); } logger.debug( nonDefaultExtension.getUniqueId() + " overrides " + managedBeanExtension.getUniqueId()); } managedBeanMap.put(beanName, nonDefaultExtension); added = true; } for (Extension extension : managedBeanMap.values()) { Parameter descriptionParameter = extension.getParameter("description"); String descsription = null; if (descriptionParameter != null) { descsription = descriptionParameter.valueAsString(); } String managedBeanName = extension.getParameter("managed-bean-name").valueAsString(); String managedBeanClass = extension.getParameter("managed-bean-class").valueAsString(); String managedBeanScope = extension.getParameter("managed-bean-scope").valueAsString(); Collection<Parameter> managedBeanProperties = extension.getParameters("managed-property"); addManagedBean(descsription, managedBeanName, managedBeanClass, managedBeanScope, managedBeanProperties, xmlStreamWriter); added = true; } xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); return added; }
From source file:org.tolven.assembler.facesconfig.FacesConfigAssembler.java
/** * Add a managed bean template if-clause for managedBeanName * /*from w ww. ja v a2 s . c o m*/ * @param description * @param managedBeanName * @param managedBeanClass * @param managedBeanScope * @param xmlStreamWriter * @throws XMLStreamException */ protected void addManagedBean(String description, String managedBeanName, String managedBeanClass, String managedBeanScope, Collection<Parameter> managedBeanProperties, XMLStreamWriter xmlStreamWriter) throws XMLStreamException { xmlStreamWriter.writeStartElement("xsl:if"); xmlStreamWriter.writeAttribute("test", "count(tp:managed-bean[tp:managed-bean-name = '" + managedBeanName + "']) = 0"); xmlStreamWriter.writeStartElement("managed-bean"); xmlStreamWriter.writeCharacters("\n"); if (description != null) { xmlStreamWriter.writeStartElement("description"); xmlStreamWriter.writeCharacters(description); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); } xmlStreamWriter.writeStartElement("managed-bean-name"); xmlStreamWriter.writeCharacters(managedBeanName); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("managed-bean-class"); xmlStreamWriter.writeCharacters(managedBeanClass); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("managed-bean-scope"); xmlStreamWriter.writeCharacters(managedBeanScope); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); for (Parameter managedProperty : managedBeanProperties) { xmlStreamWriter.writeStartElement("managed-property"); String propertyName = managedProperty.getSubParameter("property-name").valueAsString(); if (propertyName == null || propertyName.trim().length() == 0) { throw new RuntimeException("property-name parameter of a managed-property requires a value"); } xmlStreamWriter.writeStartElement("property-name"); xmlStreamWriter.writeCharacters(propertyName); xmlStreamWriter.writeEndElement(); if (managedProperty.getSubParameter("value") != null) { String propertyClass = managedProperty.getSubParameter("property-class").valueAsString(); xmlStreamWriter.writeStartElement("property-class"); xmlStreamWriter.writeCharacters(propertyClass); xmlStreamWriter.writeEndElement(); } String value = managedProperty.getSubParameter("value").valueAsString(); xmlStreamWriter.writeStartElement("value"); xmlStreamWriter.writeCharacters(value); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); } xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); }
From source file:org.tolven.assembler.tomcatserver.TomcatServerXMLAssembler.java
protected String getXSLT(ExtensionPoint connectorExtensionPoint) throws XMLStreamException, IOException { StringWriter xslt = new StringWriter(); XMLOutputFactory factory = XMLOutputFactory.newInstance(); XMLStreamWriter xmlStreamWriter = null; try {/*from w w w. j av a 2s . c o m*/ xmlStreamWriter = factory.createXMLStreamWriter(xslt); xmlStreamWriter.writeStartDocument("UTF-8", "1.0"); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("xsl:stylesheet"); xmlStreamWriter.writeAttribute("version", "2.0"); xmlStreamWriter.writeNamespace("xsl", "http://www.w3.org/1999/XSL/Transform"); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("xsl:output"); xmlStreamWriter.writeAttribute("method", "xml"); xmlStreamWriter.writeAttribute("indent", "yes"); xmlStreamWriter.writeAttribute("encoding", "UTF-8"); xmlStreamWriter.writeAttribute("omit-xml-declaration", "no"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); addMainTemplate(xmlStreamWriter); addServiceTemplate(connectorExtensionPoint, xmlStreamWriter); xmlStreamWriter.writeEndDocument(); xmlStreamWriter.writeEndDocument(); } finally { if (xmlStreamWriter != null) { xmlStreamWriter.close(); } } return xslt.toString(); }
From source file:org.tolven.assembler.tomcatserver.TomcatServerXMLAssembler.java
protected void addServiceTemplate(ExtensionPoint connectorExtensionPoint, XMLStreamWriter xmlStreamWriter) throws XMLStreamException, IOException { xmlStreamWriter.writeStartElement("xsl:template"); xmlStreamWriter.writeAttribute("match", "Service"); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("xsl:element"); xmlStreamWriter.writeAttribute("name", "{name()}"); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("xsl:for-each"); xmlStreamWriter.writeAttribute("select", "@*"); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("xsl:attribute"); xmlStreamWriter.writeAttribute("name", "{name()}"); xmlStreamWriter.writeStartElement("xsl:value-of"); xmlStreamWriter.writeAttribute("select", "."); xmlStreamWriter.writeEndElement();// w w w. jav a 2s. c o m xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("xsl:value-of"); xmlStreamWriter.writeAttribute("select", "text()"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); Extension extension = getDescriptor().getExtension(EXTENSION_TOMCATSERVERXML_ASSEMBLY); String connectorPluginId = extension.getExtendedPluginId(); PluginDescriptor connectorPluginDescriptor = getManager().getRegistry() .getPluginDescriptor(connectorPluginId); ExtensionPoint tomcatserverxmlAssemblyExtensionPoint = getManager().getRegistry() .getExtensionPoint(connectorPluginDescriptor.getId(), extension.getExtendedPointId()); String webserverCredentialDirname = (String) evaluate(tomcatserverxmlAssemblyExtensionPoint .getParameterDefinition("webserverCredentialDirectory").getDefaultValue(), tomcatserverxmlAssemblyExtensionPoint.getDeclaringPluginDescriptor()); File webserverCredentialDir = new File(webserverCredentialDirname); if (!isAbsoluteFilePath(webserverCredentialDir)) { throw new RuntimeException( "The webserver credential must be an absolute path " + webserverCredentialDir.getPath()); } webserverCredentialDir.mkdirs(); logger.debug("WebServer credential directory will be: " + webserverCredentialDir.getPath()); String webserverDeploymentDirname = (String) evaluate(tomcatserverxmlAssemblyExtensionPoint .getParameterDefinition("webserverDeploymentDirectory").getDefaultValue(), tomcatserverxmlAssemblyExtensionPoint.getDeclaringPluginDescriptor()); File webserverDeploymentDir = new File(webserverDeploymentDirname); if (!isAbsoluteFilePath(webserverDeploymentDir)) { throw new RuntimeException("The webserver deployment directory must be an absolute path " + webserverDeploymentDir.getPath()); } logger.debug( "WebServer deployment directory in the server.xml will be: " + webserverDeploymentDir.getPath()); for (Extension connectorExtension : connectorExtensionPoint.getConnectedExtensions()) { addConnectorTemplate(connectorExtension, webserverCredentialDir, webserverDeploymentDir, xmlStreamWriter); } xmlStreamWriter.writeStartElement("xsl:copy-of"); xmlStreamWriter.writeAttribute("select", "*"); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("xsl:apply-templates"); xmlStreamWriter.writeAttribute("select", "* | @* | text() | comment()"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); }
From source file:org.tolven.assembler.war.WARAssembler.java
protected void addTagConverter(PluginDescriptor pd, XMLStreamWriter writer) throws XMLStreamException { ExtensionPoint converterExnPt = pd.getExtensionPoint("tagConverter"); if (converterExnPt != null) { for (Extension extension : converterExnPt.getConnectedExtensions()) { writer.writeStartElement("tag"); writer.writeCharacters("\n"); writer.writeStartElement("tag-name"); writer.writeCharacters(extension.getParameter("tag-name").valueAsString()); writer.writeEndElement();/* ww w.j a va 2s.c o m*/ writer.writeCharacters("\n"); writer.writeStartElement("converter"); writer.writeCharacters("\n"); writer.writeStartElement("converter-id"); writer.writeCharacters(extension.getParameter("converter-id").valueAsString()); writer.writeEndElement(); writer.writeCharacters("\n"); Parameter handlerClass = extension.getParameter("handler-class"); if (handlerClass != null) { writer.writeStartElement("handler-class"); writer.writeCharacters(handlerClass.valueAsString()); writer.writeEndElement(); writer.writeCharacters("\n"); } writer.writeEndElement(); writer.writeCharacters("\n"); writer.writeEndElement(); writer.writeCharacters("\n"); } } }
From source file:org.tolven.assembler.war.WARAssembler.java
protected void addTagInfo(Extension taglibExn, File myWARPluginDir) throws IOException, XMLStreamException { File metaInfTagDir = new File(myWARPluginDir.getPath() + "/META-INF/tags"); metaInfTagDir.mkdirs();// ww w.ja va2s. c om StringWriter tagLibWriter = new StringWriter(); XMLOutputFactory factory = XMLOutputFactory.newInstance(); XMLStreamWriter writer = null; try { writer = factory.createXMLStreamWriter(tagLibWriter); writer.writeStartDocument("UTF-8", "1.0"); writer.writeCharacters("\n"); writer.writeDTD( "<!DOCTYPE facelet-taglib PUBLIC \"-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN\" \"http://java.sun.com/dtd/facelet-taglib_1_0.dtd\">"); writer.writeCharacters("\n"); writer.writeStartElement("facelet-taglib"); writer.writeCharacters("\n"); String namespace = taglibExn.getParameter("namespace").valueAsString(); writer.writeStartElement("namespace"); writer.writeCharacters(namespace); writer.writeEndElement(); writer.writeCharacters("\n"); PluginDescriptor taglibPD = taglibExn.getDeclaringPluginDescriptor(); addTagSource(taglibPD, metaInfTagDir, writer); addTagValidator(taglibPD, writer); addTagConverter(taglibPD, writer); writer.writeEndElement(); writer.writeCharacters("\n"); writer.writeEndDocument(); } finally { if (writer != null) { writer.close(); } } String tagFilename = taglibExn.getParameter("tag-filename").valueAsString(); File metaInfTagFile = new File(metaInfTagDir, tagFilename); logger.debug("Write tagLib string to " + metaInfTagFile.getPath()); FileUtils.writeStringToFile(metaInfTagFile, tagLibWriter.toString()); }