JRun provides integration with XDoclet, an open-source tool that generates code and deployment descriptors for EJBs, web applications, and JSP tag libraries.
XDoclet generates the web.xml and jrun-web.xml files using the settings in the WebDoclet task defined in the XDoclet configuration file. It uses your comments in servlets to create servlet definitions, filters, mappings, and other settings. In addition, you can merge files into the deployment descriptors that define session persistence settings and virtual mappings.
JRun supports basic XDoclet tags, which generate elements in the web.xml file and JRun-specific XDoclet tags, which generate elements in the jrun-web.xml file.
XDoclet uses Apache's Ant and its configuration file resembles build.xml files. XDoclet's configuration file is jrun_root/lib/xdoclet.xml.
For more information, see the XDoclet website at http://sourceforge.net/projects/xdoclet/.
You enable XDoclet using the XDocletService section of the jrun.xml file.
warSourceFiles attribute in the XDocletService section of the JRun server's jrun.xml file, or add a warSourceFiles attribute that matches your servlet's filename.The default naming conventions are:
*Servlet.java
*Tag.java*Filter.javaThese default naming conventions match all servlets whose names end with Servlet, Tag, or Filter and have a .java extension.
watchedWARDirectory attribute of the XDocletService section of the JRun server's jrun.xml file.The default directory is:
jrun_root/default-ear/default-war
This directory is commented out by default. You must uncomment the watchedWARDirectory attribute to watch it. You can also add additional directories for JRun to watch.
JRun generates entries for the servlet in the web application's deployment descriptors.
You configure XDoclet resources in the jrun_root/lib/xdoclet.xml. You can assign XDoclet to be part of the build with a JRun subtask. The JRun subtask is represented in the xdoclet.xml file as <jrunwebxml/>. The following table lists the attributes of the <jrunwebxml/> subtask:
For an example of the <jrunwebxml/> task, see "XDoclet configuration example".
You can define merge files that are used by XDoclet when building the deployment descriptors. You can define settings such as session persistence and virtual mappings in these external merge files. These merge files are named session-config.xml and virtual-mapping.xml. You define the location of these merge files in the XDoclet configuration file.
You use a combination of jrun.xml attributes and JavaDoc-style comments in your servlet class files to control the processing performed by XDoclet. This section describes the standard XDoclet tags and JRun-specific tags in your source code that are used by XDoclet.
XDoclet comments start with the @ sign.
Basic XDoclet tags start with the @jsp: or @web: prefix. These tags are part of the basic XDoclet architecture. When you use these tags in your source files, XDoclet uses them to create entries in the web application's web.xml file.
The following table describes the standard XDoclet tags used for web application components:
For more information, including a complete list of tags and their parameters, see the XDoclet website at http://xdoclet.sourceforge.net/.
JRun-specific XDoclet tags start with the @jrun: prefix. When you use these tags in your source files, XDoclet uses them to create entries in the jrun-web.xml file. All of these tags are class-level tags. The following table lists JRun-specific XDoclet tags:
For more information on JRun-specific XDoclet tags, see the online descriptor documentation, available from the documentation home page. For online examples of EJBs that use XDoclet, see the samples JRun server.
This section shows Java source files that use XDoclet tags and of the xdoclet.xml configuration file.
The following example shows a simple servlet that uses XDoclet to define the servlet's url-pattern mapping and initialization parameters:
import javax.servlet.http.*;
import javax.servlet.*; import java.io.*;
/**
�* A hello world. �* �* @web:servlet name="SimpleServlet" display-name="Simple Servlet" load-on-startup="1" �* @web:servlet-init-param name="param1" value="value1" �* @web:servlet-init-param name="param2" value="value2" �* @web:servlet-mapping url-pattern="/hellaworld/*" �* �* @author�����Macromedia �* @created ���Mar 14, 2002 �* @version����$1.0 $ �**/
public class SimpleServlet extends HttpServlet {
��public void doGet( HttpServletRequest request, HttpServletResponse response )
throws IOException, ServletException {
����PrintWriter out = response.getWriter()
����out.println("Hella World");
��}
}
The following example shows a filter servlet that uses XDoclet to add a filter definition, map the filter to all XML files, and define the filter's initialization parameters:
import javax.servlet.*;
import javax.servlet.http.*; import java.util.*;
/**
�* Tests adding filters to web.xml using xdoclet. �* �* @web:filter name="XDocletFilter" display-name="XDoclet Test Filter" �* @web:filter-init-param name="param1" value="value1" �* @web:filter-init-param name="param2" value="value2" �* @web:filter-mapping url-pattern="/*.xml" �* �* @author�����Macromedia �* @created ���Mar 14, 2002 �* @version����$1.0 $ �**/
public class XDocletFilter extends GenericFilter {
��public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
throws java.io.IOException, javax.servlet.ServletException {
����chain.doFilter(req, resp);
��}
}
The following example defines the WebDoclet task in the xdoclet.xml file:
<webdoclet
��sourcepath="${xdoclet.working.dir}"
��destdir="${xdoclet.working.dir}"
��classpathref="project.class.path">
��<!-- Include Struts Support -->
��<fileset dir="${xdoclet.working.dir}">
����<include name="**/*Servlet.java" />
����<include name="**/*Filter.java" />
����<include name="**/*Tag.java" />
����<include name="**/*Action.java" />
��</fileset>
��<deploymentdescriptor servletspec="2.3" destdir="${war.meta.dir}" />
��<jsptaglib jspversion="1.2"
����destdir="${war.meta.dir}/tlds"
����shortname="j2ee"
��/>
��<jrunwebxml
����destdir="${war.meta.dir}"
����contextRoot="webapp"
����reload="true"
����compile="true"
����loadSystemClassesFirst="false"
��/>
</webdoclet>
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/jrun/4/Programmers_Guide/servletxml8.htm