KickJava   Java API By Example, From Geeks To Geeks.

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


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.enterprise.admin.monitor.registry.MonitoringRegistrationException;
26 import com.sun.enterprise.admin.monitor.registry.MonitoringLevel;
27 import com.sun.enterprise.admin.wsmgmt.config.spi.WebServiceConfig;
28 import com.sun.enterprise.admin.monitor.registry.MonitoringLevel;
29
30
31 /**
32  * Installs filters for each web service end point, according to their
33  * configuration.
34  *
35  * @author Satish Viswanatham
36  * @since J2SE 5.0
37  */

38 class MonitoringLifeCycleImpl {
39
40
41     public void initializeMonitoring(String JavaDoc appId, String JavaDoc modName,
42         String JavaDoc ctxRoot, boolean isStandAlone, boolean isEjbModule, String JavaDoc vs,
43         WebServiceConfig wsConfig) throws MonitoringRegistrationException {
44
45       if ( wsConfig == null ) {
46         return;
47       }
48
49       String JavaDoc monLevel = wsConfig.getMonitoringLevel();
50
51       MonitoringLevel newLevel = MonitoringLevel.instance(monLevel);
52       if ( newLevel.equals(MonitoringLevel.OFF) ) {
53         // monitoring is off, just return
54
return;
55       }
56
57       instrumentMonitoring(wsConfig.getEndpointName(), modName, ctxRoot,
58                            isStandAlone, vs, appId, MonitoringLevel.OFF,
59                            newLevel, isEjbModule);
60     }
61
62     public void uninitializeMonitoring(String JavaDoc appId, String JavaDoc modName,
63         String JavaDoc ctxRoot, boolean isStandAlone, boolean isEjbModule, String JavaDoc vs,
64         WebServiceConfig wsConfig) throws MonitoringRegistrationException {
65
66       if (wsConfig == null) {
67         return;
68       }
69       
70       String JavaDoc monLevel = wsConfig.getMonitoringLevel();
71
72       MonitoringLevel oldLevel = MonitoringLevel.instance(monLevel);
73       if ( oldLevel.equals(MonitoringLevel.OFF) ) {
74         // monitoring is off, just return
75
return;
76       }
77
78       instrumentMonitoring(wsConfig.getEndpointName(),modName, ctxRoot,
79                            isStandAlone, vs, appId, oldLevel,
80                            MonitoringLevel.OFF, isEjbModule);
81     }
82
83     /**
84      * This method is used during initialization to install Filters required for
85      * Monitoring. This method is also called during Monitoring level change
86      * event and during deploy/un-deploy
87      *
88      * @param name Name of the web service endpoint
89      * @param moduleName Name of the module (bundleName)
90      * @param boolean Indicates if this module is standalone or not
91      * @param vs Name of the virtual server
92      * @param j2eeAppName Name of the J2EE application
93      * @param oldLevel Old Monitoring Level
94      * @param newLevel New Monitoring Level
95      * @param isEjbModule true, if the module of ejb type
96      *
97      * @throws
98      */

99     public void instrumentMonitoring(String JavaDoc name, String JavaDoc moduleName,
100         String JavaDoc ctxRoot, boolean isStandAlone, String JavaDoc vs, String JavaDoc j2eeAppName,
101         MonitoringLevel oldLevel, MonitoringLevel newLevel,
102         boolean isEjbModule)
103         throws MonitoringRegistrationException {
104     
105         if ( name == null) {
106             return;
107         }
108
109         EndpointRegistration epr = new EndpointRegistration( name, moduleName,
110             ctxRoot, isStandAlone, vs, j2eeAppName, isEjbModule);
111
112         // both Monitoring levels are same, so just return
113
if ( oldLevel == newLevel ) {
114             return;
115         }
116
117         if ( oldLevel == OFF ) {
118             if ( newLevel == LOW ) {
119                 epr.enableLOW();
120             }
121             if ( newLevel == HIGH ) {
122                 epr.enableLOW();
123                 // and enable high functionality too
124
}
125         }
126
127         if ( oldLevel == LOW ) {
128             if ( newLevel == HIGH) {
129                 // XXX not implemented yet
130
}
131             if ( newLevel == OFF ){
132                 epr.disableLOW();
133             }
134         }
135
136         if ( oldLevel == HIGH ) {
137             if ( newLevel == LOW ){
138                 // not implemented yet
139
// keep only LOW
140
}
141             if ( newLevel == OFF ){
142                 epr.disableLOW();
143             }
144         }
145     }
146
147     // -- PRIVATE VARIABLES ---
148
static MonitoringLifeCycleImpl flcm = null;
149
150     private static final MonitoringLevel OFF = MonitoringLevel.OFF;
151     private static final MonitoringLevel HIGH = MonitoringLevel.HIGH;
152     private static final MonitoringLevel LOW = MonitoringLevel.LOW;
153
154 }
155
Popular Tags