Section 3.2. Application.xml

3.2. Application.xml

Just as a WAR file contains a web.xml deployment descriptor, an EAR file contains a file named application.xml. It is essentially a packing list, telling the J2EE server exactly what files the EAR contains and where you can find the files relative to the root of the EAR. The EAR file's META-INF directory stores application.xml.

Example 3-1 shows the JAW Motors application.xml file.

Example 3-1. application.xml
 <?xml version="1.0" encoding="UTF-8"?> <application xmlns=""          xmlns:xsi=""          xsi:schemaLocation="    "          version="1.4">   <display-name>JBossAtWorkEAR</display-name>     <module>       <web>           <web-uri>webapp.war</web-uri>           <context-root>jaw</context-root>       </web>   </module>     <module>       <java>common.jar</java>   </module>   </application> 

The elements in application.xml should be pretty self-explanatory. We are telling the application server the name of each JAR and what function it serves.

Notice that Web modules allow you to specify one other valuethe <context-root>. Recall from the previous chapter that the context root is your web site's URL. If you deploy a simple WAR file, the name of the WAR will be used as the URL. When your WAR file is deployed inside an EAR, this element allows you to override the physical name of the WAR and use whatever URL you'd like.

Although not shown in this example, <security-role> is another important element in application.xml. The <security-role> element describes (what else?) the security roles used throughout a J2EE application for both web and EJB components. Defining security roles in application.xml provides a single place to set up J2EE declarative security without duplicating it in web.xml and ejb-jar.xml. The Security chapter describes <security-role> in greater detail.

JBoss at Work. A Practical Guide
JBoss at Work: A Practical Guide
ISBN: 0596007345
EAN: 2147483647
Year: 2004
Pages: 197

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: