Lifecycle notification

From Resin 3.0

Jump to: navigation, search

Resin's <server>, <host>, and <web-app> send JMX Notifications when the server starts, stops or restarts.

Notification Events

The notification events are:

notification type description
caucho.lifecycle.after-start called after the server starts
caucho.lifecycle.before-stop called before the server stops

resin.conf configuration

The resin.conf provides a straightforward way of configuring MBean listeners. An MBean listener is a <bean> that listens for events. Because the bean is an MBean, it needs to have an mbean-name.

<resin xmlns:resin="">

       <bean mbean-name="type=MyListener,name=test"

         <mbean-listener mbean-name="resin:type=Server,name=default"/>


The <mbean-listener> tag registers MyListener as a listener of the MBean with the given mbean-name, i.e. the <server>. The <server> has an MBean name of "default" because it has no @id attribute.

Sample Listener

To listen for notification events, create a JMX NotificationListener and register it with the <server>. The notification listener will look like:

package example;


public class MyListener implements MyListenerMBean {

    public void handleNotification(Notification notif, Object handback)


And the corresponding MBean is

package example;

public interface MyListenerMBean extends NotificationListener {
Personal tools