Provides convenience methods for reading and writing enterprise application
deployment descriptors (application.xml).
| Method from org.apache.cactus.integration.ant.deployment.application.ApplicationXmlIo Detail: |
public static ApplicationXml parseApplicationXml(InputStream theInput,
EntityResolver theEntityResolver) throws IOException, SAXException, ParserConfigurationException {
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
factory.setValidating(false);
factory.setNamespaceAware(false);
DocumentBuilder builder = factory.newDocumentBuilder();
if (theEntityResolver != null)
{
builder.setEntityResolver(theEntityResolver);
}
else
{
builder.setEntityResolver(new ApplicationXmlEntityResolver());
}
return new DefaultApplicationXml(builder.parse(theInput));
}
Parses a deployment descriptor provided as input stream. |
public static ApplicationXml parseApplicationXmlFromFile(File theFile,
EntityResolver theEntityResolver) throws IOException, SAXException, ParserConfigurationException {
InputStream in = null;
try
{
in = new FileInputStream(theFile);
return parseApplicationXml(in, theEntityResolver);
}
finally
{
if (in != null)
{
try
{
in.close();
}
catch (IOException ioe)
{
// we'll pass on the original IO error, so ignore this one
}
}
}
}
Parses a deployment descriptor stored in a regular file. |
public static void writeApplicationXml(ApplicationXml theAppXml,
File theFile) throws IOException {
writeApplicationXml(theAppXml, theFile, null, false);
}
Writes the specified document to a file. |
public static void writeApplicationXml(ApplicationXml theAppXml,
File theFile,
String theEncoding) throws IOException {
writeApplicationXml(theAppXml, theFile, theEncoding, false);
}
Writes the specified document to a file. |
public static void writeApplicationXml(ApplicationXml theAppXml,
File theFile,
String theEncoding,
boolean isIndent) throws IOException {
OutputStream out = null;
try
{
out = new FileOutputStream(theFile);
writeApplicationXml(theAppXml, out, theEncoding, isIndent);
}
finally
{
if (out != null)
{
try
{
out.close();
}
catch (IOException ioe)
{
// we'll pass on the original IO error, so ignore this one
}
}
}
}
Writes the specified document to a file. |
public static void writeApplicationXml(ApplicationXml theAppXml,
OutputStream theOutput,
String theEncoding,
boolean isIndent) throws IOException {
OutputFormat outputFormat =
new OutputFormat(theAppXml.getDocument());
if (theEncoding != null)
{
outputFormat.setEncoding(theEncoding);
}
outputFormat.setIndenting(isIndent);
outputFormat.setPreserveSpace(false);
XMLSerializer serializer = new XMLSerializer(theOutput, outputFormat);
serializer.serialize(theAppXml.getDocument());
}
Writes the specified document to an output stream. |