KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > support > AMXLifecycleModule


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 package com.sun.enterprise.management.support;
24
25 import java.util.Properties JavaDoc;
26
27 import javax.management.ObjectName JavaDoc;
28
29 import com.sun.appserv.management.util.misc.StringUtil;
30 import com.sun.appserv.management.util.misc.MapUtil;
31
32
33 import com.sun.appserv.server.LifecycleListener;
34 import com.sun.appserv.server.LifecycleEvent;
35 import static com.sun.appserv.server.LifecycleEvent.*;
36 import com.sun.appserv.server.LifecycleEventContext;
37 import com.sun.appserv.server.ServerLifecycleException;
38
39
40 /**
41  */

42 public final class AMXLifecycleModule implements LifecycleListener
43 {
44     private final String JavaDoc NEWLINE;
45     
46         public
47     AMXLifecycleModule()
48     {
49         NEWLINE = System.getProperty( "line.separator" );
50     }
51     
52         private void
53     init(
54         final LifecycleEventContext context,
55         final Properties JavaDoc props )
56     {
57         context.log( "AMXLifecycleModule: init" );
58     }
59     
60         private void
61     startup(
62         final LifecycleEventContext context,
63         final Properties JavaDoc props )
64     {
65         context.log( "AMXLifecycleModule: startup" );
66     }
67     
68         private void
69     ready(
70         final LifecycleEventContext context,
71         final Properties JavaDoc props )
72     {
73         context.log( "AMXLifecycleModule: ready" );
74     }
75     
76         private void
77     shutdown(
78         final LifecycleEventContext context,
79         final Properties JavaDoc props )
80     {
81         context.log( "AMXLifecycleModule: shutdown" );
82     }
83     
84         private void
85     terminate(
86         final LifecycleEventContext context,
87         final Properties JavaDoc props )
88     {
89         context.log( "AMXLifecycleModule: terminate" );
90     }
91     
92         private void
93     dumpInfo(
94         final int eventType,
95         final LifecycleEventContext context,
96         final Properties JavaDoc props )
97     {
98         final String JavaDoc msg = "AMXLifecycleModule: " + eventType + NEWLINE +
99             "InstallRoot: " + context.getInstallRoot() + NEWLINE +
100             "InstanceName: " + context.getInstanceName() + NEWLINE +
101             "CmdLineArgs: " + StringUtil.toString( " ", (Object JavaDoc[])context.getCmdLineArgs() ) + NEWLINE +
102             "Properties: " + NEWLINE +
103             MapUtil.toString( props, NEWLINE ) + NEWLINE;
104         
105         context.log( msg );
106             
107     }
108     
109     
110         public void
111     handleEvent(LifecycleEvent event)
112         throws ServerLifecycleException
113     {
114         final int type = event.getEventType();
115         
116         final Properties JavaDoc props = (Properties JavaDoc)event.getData();
117         final LifecycleEventContext context = event.getLifecycleEventContext();
118         
119         dumpInfo( type, context, props );
120         
121         if ( type == INIT_EVENT )
122         {
123             init( context, props );
124         }
125         else if ( type == STARTUP_EVENT )
126         {
127             startup( context, props );
128         }
129         else if ( type == READY_EVENT )
130         {
131             ready( context, props );
132         }
133         else if ( type == SHUTDOWN_EVENT )
134         {
135             shutdown( context, props );
136         }
137         else if ( type == TERMINATION_EVENT )
138         {
139             terminate( context, props );
140         }
141         else
142         {
143             throw new IllegalArgumentException JavaDoc( "eventType: " + type );
144         }
145     }
146 }
147
148
149
150
151
152
153
154
155
Popular Tags