Adding and deleting listeners to a free-form project

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.

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

Steps

  1. 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.
  2. The following activities occur when you drop a listener into the free-form project:
    1. If necessary, the listener class is generated and mapped to the imported_classes directory of the Web module project. The rapid deployment tools will 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:
      • This graphic is a Windows icon. On Windows:wrd.bat -monitor
      • This graphic is a UNIX icon. On UNIX:wrd.sh -monitor
    2. 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). The following is an example of the entries in web.xml:
      <listener>
      	<display-name>MyListener</display-name>
      	<listener-class>MyListener</listener-class>
      </listener>
    3. The application is synchronized with the server.
  3. 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.
  4. The following activities occur when you remove a listener from the free-form project:
    1. 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
    2. The application is synchronized with the server.

Feedback