org.ow2.jonas.generators.genbase.utils
Class XMLUtils

java.lang.Object
  extended by org.ow2.jonas.generators.genbase.utils.XMLUtils

public class XMLUtils
extends Object

XML Utils Class. Holds methods for easier DOM parsing, XML modifications, ...

Author:
Guillaume Sauthier

Method Summary
static void addClient(Document app, Archive client)
          Add a client module in an application Document
static void addEjb(Document app, Archive ejbjar)
          Add an ejb module in an application Document
static void addWebApp(Document app, Archive webapp, String ctx)
          Add an web module in an application Document
static void cleanDummyApplication(Document doc)
          default application.xml contains a fake ejb module needed to be parsed without error but not needed for a normal application.
static Element getBeanElement(Element base, String bName)
          Returns the session/entity/ message-driven XML Element with given name.
static Element getJonasServiceRef(Element base, String srName)
          Returns the jonas-service-ref XML Element with given name.
static Element getServletElement(Element base, String sName)
          Returns the matching servlet XML Element with given name.
static boolean isWebModuleAlreadyDeclared(Document app, String name)
          Check if the web module name is already declared in the application.xml Document
static Document newDocument(InputStream is, String name, boolean isDTDsAllowed)
          Creates a new Document from a given InputStream.
static Document newDocument(InputStream is, String name, boolean isDTDsAllowed, boolean validate)
          Creates a new Document from a given InputStream.
static Document newJonasClient()
          Creates a new XML Document for an empty jonas-client.xml.
static Document newJonasWeb()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newDocument

public static Document newDocument(InputStream is,
                                   String name,
                                   boolean isDTDsAllowed)
                            throws ParserConfigurationException,
                                   SAXException,
                                   IOException,
                                   NoJ2EEWebservicesException
Creates a new Document from a given InputStream. Validate the file.

Parameters:
is - the InputStream to be parsed
name - filename
isDTDsAllowed - if false, throw exception on DTD Doctype
Returns:
the Document instance.
Throws:
ParserConfigurationException - ParserConfigurationException
SAXException - SAXException
IOException - IOException
NoJ2EEWebservicesException - NoJ2EEWebservicesException

newDocument

public static Document newDocument(InputStream is,
                                   String name,
                                   boolean isDTDsAllowed,
                                   boolean validate)
                            throws NoJ2EEWebservicesException,
                                   ParserConfigurationException,
                                   SAXException,
                                   IOException
Creates a new Document from a given InputStream.

Parameters:
is - the InputStream to be parsed
name - filename
isDTDsAllowed - if false, throw exception on DTD Doctype
validate - if the file is to be validated
Returns:
the Document instance.
Throws:
ParserConfigurationException - ParserConfigurationException
SAXException - SAXException
IOException - IOException
NoJ2EEWebservicesException - NoJ2EEWebservicesException

getBeanElement

public static Element getBeanElement(Element base,
                                     String bName)
Returns the session/entity/ message-driven XML Element with given name.

Parameters:
base - jonas-ejb-jar Element.
bName - the bean name to be found.
Returns:
the session/entity/ message-driven XML Element.

getServletElement

public static Element getServletElement(Element base,
                                        String sName)
Returns the matching servlet XML Element with given name.

Parameters:
base - web-app Element.
sName - the servlet name to be found.
Returns:
the matching servlet XML Element.

getJonasServiceRef

public static Element getJonasServiceRef(Element base,
                                         String srName)
Returns the jonas-service-ref XML Element with given name.

Parameters:
base - web-app/ bean Element containing jonas-service-ref Element(s).
srName - the service-ref name to be found.
Returns:
the jonas-service-ref XML Element.

cleanDummyApplication

public static void cleanDummyApplication(Document doc)
default application.xml contains a fake ejb module needed to be parsed without error but not needed for a normal application. Than we remove it.

Parameters:
doc - application.xml document

addEjb

public static void addEjb(Document app,
                          Archive ejbjar)
Add an ejb module in an application Document

Parameters:
app - application.xml Document
ejbjar - EJBJar archive

addClient

public static void addClient(Document app,
                             Archive client)
Add a client module in an application Document

Parameters:
app - application.xml Document
client - Client archive

addWebApp

public static void addWebApp(Document app,
                             Archive webapp,
                             String ctx)
Add an web module in an application Document

Parameters:
app - application.xml Document
webapp - WebApp archive
ctx - context-root

newJonasClient

public static Document newJonasClient()
Creates a new XML Document for an empty jonas-client.xml.

Returns:
Returns a new XML Document for an empty jonas-client.xml.

newJonasWeb

public static Document newJonasWeb()
Returns:
Returns an empty jonas-web-app Document

isWebModuleAlreadyDeclared

public static boolean isWebModuleAlreadyDeclared(Document app,
                                                 String name)
Check if the web module name is already declared in the application.xml Document

Parameters:
app - the application.xml Doc
name - web application name
Returns:
Returns true if the module is already declared, false otherwise.


Copyright © 2010 OW2 Consortium. All Rights Reserved.