public String render ( ) { try { DocumentBuilderFactory docFactory = DocumentBuilderFactory . newInstance ( ) ; DocumentBuilder docBuilder = docFactory . newDocumentBuilder ( ) ; // root elements doc = docBuilder . newDocument ( ) ; rootElement = doc . createElement ( "application" ) ; Element element ; rootElement . setAttribute ( "xmlns" , "http://java.sun.com/xml/ns/javaee" ) ; rootElement . setAttribute ( "xmlns:xsi" , "http://www.w3.org/2001/XMLSchema-instance" ) ; rootElement . setAttribute ( "xsi:schemaLocation" , "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" ) ; rootElement . setAttribute ( "version" , "6" ) ; doc . appendChild ( rootElement ) ; element = doc . createElement ( "description" ) ; element . setTextContent ( "Autogenerated deployment for " + basename ) ; rootElement . appendChild ( element ) ; element = doc . createElement ( "display-name" ) ; element . setTextContent ( basename + "-full" ) ; rootElement . appendChild ( element ) ; for ( String filename : ejbs ) { writeEjbModule ( filename ) ; } for ( Map . Entry < String , String > entry : webs ) { writeWebModule ( entry . getKey ( ) , entry . getValue ( ) ) ; } element = doc . createElement ( "library-directory" ) ; element . setTextContent ( "lib" ) ; rootElement . appendChild ( element ) ; TransformerFactory transformerFactory = TransformerFactory . newInstance ( ) ; Transformer transformer = transformerFactory . newTransformer ( ) ; DOMSource source = new DOMSource ( doc ) ; ByteArrayOutputStream bytes = new ByteArrayOutputStream ( ) ; StreamResult result = new StreamResult ( bytes ) ; transformer . setOutputProperty ( OutputKeys . INDENT , "yes" ) ; transformer . setOutputProperty ( "{http://xml.apache.org/xslt}indent-amount" , "4" ) ; transformer . transform ( source , result ) ; return bytes . toString ( ) ; } catch ( TransformerException ex ) { throw new IllegalStateException ( ex ) ; } catch ( ParserConfigurationException ex ) { throw new IllegalStateException ( ex ) ; } }
Renders application . xml filr for application .