KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > wsmgmt > lifecycle > AppServWSMgmtAdminLifeCycle


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.admin.wsmgmt.lifecycle;
24
25 import com.sun.appserv.server.ServerLifecycle;
26 import com.sun.appserv.server.ServerLifecycleImpl;
27 import com.sun.appserv.server.ServerLifecycleException;
28 import com.sun.enterprise.server.ServerContext;
29 import com.sun.enterprise.deployment.backend.DeploymentEventManager;
30 import com.sun.enterprise.admin.wsmgmt.repository.impl.cache.AppServDELImpl;
31 import com.sun.enterprise.admin.wsmgmt.agent.ListenerManager;
32 import com.sun.enterprise.admin.wsmgmt.msg.MessageTraceMgr;
33 import com.sun.enterprise.admin.event.AdminEventListenerRegistry;
34 import com.sun.enterprise.admin.event.wsmgmt.WebServiceEndpointEvent;
35 import com.sun.enterprise.admin.event.wsmgmt.TransformationRuleEvent;
36 import com.sun.enterprise.admin.event.wsmgmt.RegistryLocationEvent;
37 import com.sun.enterprise.admin.wsmgmt.lifecycle.reconfig.WebServiceEndpointEventListenerImpl;
38 import com.sun.enterprise.admin.wsmgmt.lifecycle.reconfig.TransformationRuleEventListenerImpl;
39 import com.sun.enterprise.admin.wsmgmt.lifecycle.reconfig.RegistryLocationEventListenerImpl;
40
41 import com.sun.enterprise.admin.monitor.registry.MonitoringLevel;
42
43 /**
44  * Lifecycle manager for web services management administration service.
45  *
46  * @author Nazrul Islam
47  * @since J2SE 5.0
48  */

49 public class AppServWSMgmtAdminLifeCycle extends ServerLifecycleImpl {
50
51     /**
52      * Constant denoting the status of ws mgmt admin service not started
53      */

54     public static final byte STATUS_NOT_STARTED = 0;
55
56     /**
57      * Constant denoting the status of ws mgmt admin service shutdown started
58      */

59     public static final byte STATUS_SHUTDOWN = 1;
60
61     /**
62      * Constant denoting the status of ws mgmt admin service initialized
63      */

64     public static final byte STATUS_INITED = 2;
65
66     /**
67      * Constant denoting the status of ws mgmt admin service started
68      */

69     public static final byte STATUS_STARTED = 4;
70
71     /**
72      * Constant denoting the status of ws mgmt admin service ready
73      */

74     public static final byte STATUS_READY = 8;
75
76     /**
77      * Constant denoting the status of ws mgmt admin service terminated
78      */

79     public static final byte STATUS_TERMINATED = 0;
80
81     private byte serverStatus;
82
83     /**
84      * Default constructor
85      */

86     public AppServWSMgmtAdminLifeCycle() {
87         serverStatus = STATUS_NOT_STARTED;
88     }
89
90     /**
91      * Server is initializing ws mgmt admin service and setting up the runtime
92      * environment.
93      *
94      * @param sc ServerContext the server runtime context.
95      *
96      * @exception IllegalStateException if this subsystem has already been
97      * started
98      * @exception ServerLifecycleException if this subsystem detects a fatal
99      * error that prevents this subsystem from being used
100      */

101     public void onInitialization(ServerContext sc)
102             throws ServerLifecycleException {
103
104         if ((serverStatus & STATUS_INITED) == STATUS_INITED) {
105             throw new IllegalStateException JavaDoc(
106                 "WS Mgmt Admin is already initialized");
107         }
108         DeploymentEventManager.addListener(new AppServDELImpl());
109
110         // register dynamic reconfig listeners
111
AdminEventListenerRegistry.addEventListener(
112             WebServiceEndpointEvent.eventType,
113             new WebServiceEndpointEventListenerImpl());
114
115         AdminEventListenerRegistry.addEventListener(
116             TransformationRuleEvent.eventType,
117             new TransformationRuleEventListenerImpl());
118         
119         AdminEventListenerRegistry.addEventListener(
120             RegistryLocationEvent.eventType,
121             new RegistryLocationEventListenerImpl());
122         
123
124         serverStatus = STATUS_INITED;
125     }
126
127     /**
128      * Server is starting up applications.
129      *
130      * @param sc ServerContext the server runtime context.
131      *
132      * @exception ServerLifecycleException if this subsystem detects a fatal
133      * error that prevents this subsystem from being used
134      */

135     public void onStartup(ServerContext sc) throws ServerLifecycleException {
136         serverStatus |= STATUS_STARTED;
137
138         // initializes message trace
139
MessageTraceMgr msgTraceMgr = MessageTraceMgr.getInstance();
140         if ( msgTraceMgr != null) {
141             msgTraceMgr.init();
142         }
143     }
144
145     /**
146      * Server has completed loading the services and is ready to serve requests.
147      *
148      * @param sc ServerContext the server runtime context.
149      *
150      * @exception ServerLifecycleException if this subsystem detects a fatal
151      * error that prevents this subsystem from being used
152      */

153     public void onReady(ServerContext sc) throws ServerLifecycleException {
154         serverStatus |= STATUS_READY;
155
156         // registers the global listener with jwsdp runtime
157
ListenerManager.getInstance().register();
158
159     }
160
161     /**
162      * Server is shutting down applications.
163      *
164      * @exception ServerLifecycleException if this subsystem detects a fatal
165      * error that prevents this subsystem from being used
166      */

167     public void onShutdown() throws ServerLifecycleException {
168         serverStatus |= STATUS_SHUTDOWN;
169         
170         // shuts down message trace
171
MessageTraceMgr msgTraceMgr = MessageTraceMgr.getInstance();
172         if ( msgTraceMgr != null) {
173             msgTraceMgr.stop();
174         }
175     }
176
177     /**
178      * Server is terminating the subsystems and the runtime environment.
179      * Gracefully terminate the active use of the public methods of this
180      * subsystem. This method should be the last one called on a given
181      * instance of this subsystem.
182      *
183      * @exception ServerLifecycleException if this subsystem detects a fatal
184      * error that prevents this subsystem from being used
185      */

186     public void onTermination() throws ServerLifecycleException {
187         serverStatus = STATUS_TERMINATED;
188     }
189 }
190
Popular Tags