KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > appserv > server > LifecycleListenerImpl


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /**
25  * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
26  *
27  * Copyright 2000-2001 by iPlanet/Sun Microsystems, Inc.,
28  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
29  * All rights reserved.
30  */

31
32 package com.sun.appserv.server;
33
34 import java.util.Properties JavaDoc;
35
36 /**
37  * LifecycleListenerImpl is a dummy implementation for the LifecycleListener interface.
38  * This implementaion stubs out various lifecycle interface methods.
39  */

40 public class LifecycleListenerImpl implements LifecycleListener {
41
42     /** receive a server lifecycle event
43      * @param event associated event
44      * @throws <code>ServerLifecycleException</code> for exceptional condition.
45      *
46      * Configure this module as a lifecycle-module in server.xml:
47      *
48      * <applications>
49      * <lifecycle-module name="test"
50      * class-name="com.sun.appserv.server.LifecycleListenerImpl"
51                      is-failure-fatal="false">
52      * <property name="foo" value="fooval"/>
53      * </lifecycle-module>
54      * </applications>
55      *
56      * Set<code>is-failure-fatal</code>in server.xml to <code>true</code> for
57      * fatal conditions.
58      */

59     public void handleEvent(LifecycleEvent event) throws ServerLifecycleException {
60         LifecycleEventContext ctx = event.getLifecycleEventContext();
61
62         ctx.log("got event" + event.getEventType() + " event data: " + event.getData());
63
64         Properties JavaDoc props;
65
66         if (LifecycleEvent.INIT_EVENT == event.getEventType()) {
67             System.out.println("LifecycleListener: INIT_EVENT");
68
69             props = (Properties JavaDoc) event.getData();
70
71             // handle INIT_EVENT
72
return;
73         }
74
75         if (LifecycleEvent.STARTUP_EVENT == event.getEventType()) {
76             System.out.println("LifecycleListener: STARTUP_EVENT");
77
78             // handle STARTUP_EVENT
79
return;
80         }
81
82         if (LifecycleEvent.SHUTDOWN_EVENT== event.getEventType()) {
83             System.out.println("LifecycleListener: SHUTDOWN_EVENT");
84
85             // handle SHUTDOWN_EVENT
86
return;
87         }
88
89         if (LifecycleEvent.TERMINATION_EVENT == event.getEventType()) {
90             System.out.println("LifecycleListener: TERMINATE_EVENT");
91
92             // handle TERMINATION_EVENT
93
return;
94         }
95     }
96 }
97
Popular Tags