Chapter 6: Advanced Tomcat Features Although the XML configuration syntax of a lifecycle listener is similar to the configuration of a nested component inside a container, technically, a listener is not an architectural component (and definitely not a nested component). A lifecycle listener should be thought of as an extended attribute of the containing XML element. Lifecycle listeners are configured as XML subelements instead of XML element attributes for the following reasons: . Multiple lifecycle listeners can be associated with a single component. . Each listener can be configured with its own set of attributes. The element, representing a lifecycle listener, can be configured with the attributes described in the following table. Attribute Description Required? className descriptors The Java programming language class that implements the listener logic. This class must implement the org.apache .catalina.LifecycleListenerJava interface. A semicolon-separated list of MBean descriptor XML files. This attribute is used to provide JMX compatibility (see Chapter 17 on Tomcat s JMX support) for custom components (that is, custom Valves and custom Realms). Yes No Tomcat 6 Lifecycle Listeners Configuration Tomcat 6 has two custom listener classes that will intercept lifecycle events and create (or destroy) management objects (called MBeans) to support external management of Tomcat. These two custom listener classes are as follows: . org.apache.catalina.mbeans.ServerLifecycle: A listener to create/destroy MBeans for management of Tomcat architectural components. . org.apache.catalina.mbeans.GlobalResourcesLifecycle: A listener to create/destroy MBeans for management of any global resources that may be externally manageable. Displaying MBeans Created by Lifecycle Listeners Using the Manager JMX Proxy The two lifecycle listeners are configured in the default server.xml file. You can see the result of the created MBeans by using the manager application s JMX proxy servlet. Try the following URL: http://localhost:8080/manager/jmxproxy/?qry=*%3Atype%3DRole%2C* This proxy servlet enables you to query specific MBeans that are created within the Tomcat 6 server. MBeans representing roles are created only by the lifecycle listeners described earlier. When these life- cycle listeners are not hooked in, the roles MBeans are not created. The preceding query will enumerate all the roles MBeans. The query should return a list of the four manageable objects (MBeans) for the roles that are defined in tomcat-users.xml, as shown in Figure 6-7 .
For reliable and cheap web hosting services please check cheap web hosting website.
This entry was posted
on Monday, March 23rd, 2009 at 1:37 pm and is filed under tomcat.
You can follow any responses to this entry through the RSS 2.0 feed.
Responses are currently closed, but you can trackback from your own site.