* @param metaObj The metadata object to export.
* @throws Exception If an error occurs.
*/
protected void executeExport(MetadataObject metaObj) throws Exception
{
XSDMessageExporter exporter = new XSDMessageExporter(m_context);
String sFile;
File file;
if (hasProperty("xsd.file"))
{
sFile = getProperty("xsd.file");
exporter.setOutputMode(XSDMessageExporter.OUTMODE_XSD);
}
else if (hasProperty("wsdl.file"))
{
sFile = getProperty("wsdl.file");
exporter.setOutputMode(XSDMessageExporter.OUTMODE_WSDL);
if (hasProperty("wsdl.host"))
{
exporter.setHostName(getProperty("wsdl.host"));
}
else
{
exporter.setHostName(URIUtil.getHostPort(m_metadata.getHTTPRoot()));
}
if (hasProperty("wsdl.httpRoot"))
{
exporter.setContextRoot(getProperty("wsdl.httpRoot"));
}
else
{
exporter.setContextRoot(m_metadata.getHTTPContextRoot());
}
}
else
{
throw new IllegalArgumentException("Missing required property xsd.file or wsdl.file");
}
if (URLUtil.isURL(sFile))
{
file = URLUtil.fileFromURL(new URL(sFile));
}
else
{
file = new File(sFile);
}
Writer writer = null;
try
{
writer = IOUtil.openBufferedWriter(file, XMLUtil.ENCODING);
if (metaObj instanceof Channel)
{
exporter.export((Channel)metaObj, writer);
}
else if (metaObj instanceof Interface)
{
exporter.export((Interface)metaObj, writer);
}
else if (metaObj instanceof Message)
{
exporter.export((Message)metaObj, writer);
}
else
{
throw new IllegalArgumentException();
}