users@glassfish.java.net

Re: developing lifecycle module(urgent pls )

From: <glassfish_at_javadesktop.org>
Date: Mon, 07 Jun 2010 10:36:27 PDT

hello hzhang_jn ,thank you very much, problem was solved by below code:



/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author alisha
 */
import java.util.Properties;
import java.util.logging.Level;
import com.sun.appserv.server.LifecycleEventContext;
import com.sun.appserv.server.ServerLifecycleException;
import com.sun.appserv.server.LifecycleEvent;
import com.sun.appserv.server.LifecycleListener;
 /**
  * LifecycleListenerImpl is a dummy implementation for the LifecycleListener
  * interface.
  * This implementation stubs out various lifecycle interface methods.
  */
public class test_class implements LifecycleListener {
/* * receive a server lifecycle event
* @param event associated event
* @throws <code>ServerLifecycleException</code> for exception condition.
*
*/
public void handleEvent(LifecycleEvent event) throws ServerLifecycleException
{

LifecycleEventContext ctx=event.getLifecycleEventContext();

ctx.log("got event" + event.getEventType() + "event data:" +
event.getData());

Properties props;

if (LifecycleEvent.INIT_EVENT == event.getEventType()) {
System.out.println("LifecycleListener: INIT_EVENT");
ctx.log("LifecycleListener: INIT_EVENTalisha");
props = (Properties) event.getData();

//handle INIT_EVENT
return;
}

if (LifecycleEvent.STARTUP_EVENT == event.getEventType()) {
    ctx.log("LifecycleListener: START_EVENTalisha");
System.out.println("LifecycleListener: START_EVENT");
//handle STARTUP_EVENT
return;
}
if (LifecycleEvent.READY_EVENT == event.getEventType()) {
    ctx.log("LifecycleListener: READy_EVENTalisha");
System.out.println("LifecycleListener: READY_EVENT");
//handle READY_EVENT
return;
}

if (LifecycleEvent.SHUTDOWN_EVENT == event.getEventType()) {
    ctx.log("LifecycleListener: SHUTDOWN_EVENTalisha");
System.out.println("LifecycleListener: SHUTDOWN_EVENT");
//handle SHUTDOWN_EVENT
return;
} if (LifecycleEvent.TERMINATION_EVENT == event.getEventType()) {
    ctx.log("LifecycleListener: TERMINATE_EVENTalisha");
System.out.println("LifecycleListener: TERMINATION_EVENT");
//handle TERMINATION_EVENT
return;
 }
 }
}
[Message sent by forum member 'alishacse']

http://forums.java.net/jive/thread.jspa?messageID=473184