You can add or delete servlet listener source code, annotated
source, or compiled class files for various J2EE listener types related
to servlet context and session events and attributes to or from a
free-form project.
Before you begin
Restriction: You can use the rapid deployment
tools for packaging applications at J2EE 1.3 or 1.4 specification-levels.
However, the rapid deployment tools do not support Java EE 5.0 nor J2EE 1.2 specification-level.
Prerequisites
The
listener class must be an implementation of the following types:
javax.servlet.ServletContextListener
javax.servlet.ServletContextAttributesListener
javax.servlet.http.HttpSessionListener
javax.servlet.http.HttpSessionAttributesListener
Procedure
- To add listeners to a free-form project, use your file
management system to properly place your listener artifacts into the
free-form project. The directory name of the free-form project has
the same string value you had provided for the -project parameter
used in the wrd-config command.
- The following activities occur when you drop a listener
into the free-form project:
- If necessary, the listener class is generated and mapped
to the imported_classes directory of the Web
module project. The rapid deployment tools then copy the class files
to its appropriate J2EE location which is WebContent/WEB-INF/classes folder
of the Web module project. The console output can look like this example
when adding a listener Java source
file (called MyListener.java) to a free-form project (called MyProject):
[07:58:31 PM] [/MyProject/MyListener.java] Added
[07:58:31 PM] [/MyProject/bin/MyListener.class] copied to project [MyProjectWeb]
[07:58:31 PM] Listener added to web.xml: MyListener
Tip: If you want to monitor the
rapid deployment activity, run your rapid deployment session with
console output. You can complete this by running the rapid deployment
launch tool as follows:
wrd.bat -monitor
wrd.sh -monitor
- A new listener entry is created in the Web deployment
descriptor (found in the WebContent\WEB-INF\web.xml file
in the Web module project). Example of the entries in web.xml:
<listener>
<display-name>MyListener</display-name>
<listener-class>MyListener</listener-class>
</listener>
- The application is synchronized with the server.
- To delete listeners from a free-form project, use your
file management system to properly remove your listener artifacts
from the free-form project. The directory name of the free-form project
has the same string value you had provided for the -project parameter
used in the wrd-config command.
- The following activities occur when you remove a listener
from the free-form project:
- The console output can look like this example when
removing a listener Java source
file (called MyListener.java) from a free-form project (called MyProject):
[08:00:23 PM] [/MyProject/MyListener.java] Deleted
[08:00:23 PM] [/MyProject/bin/MyListener.class] Deleted
[08:00:23 PM] Listener removed from web.xml: MyListener
- The application is synchronized with the server.