KickJava   Java API By Example, From Geeks To Geeks.

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


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
32 import com.sun.enterprise.admin.wsmgmt.config.spi.WebServiceConfig;
33 import com.sun.enterprise.admin.wsmgmt.config.spi.Constants;
34 import com.sun.enterprise.admin.wsmgmt.filter.spi.Filter;
35 import com.sun.enterprise.admin.wsmgmt.filter.spi.FilterRegistry;
36 import com.sun.enterprise.admin.wsmgmt.filter.impl.AggregateStatsFilter;
37 import com.sun.enterprise.admin.wsmgmt.stats.spi.StatsProviderManager;
38 import com.sun.enterprise.admin.wsmgmt.stats.spi.WebServiceEndpointStatsProvider;
39 import com.sun.enterprise.admin.wsmgmt.stats.impl.WebServiceEndpointStatsProviderImpl;
40 import com.sun.enterprise.admin.wsmgmt.stats.impl.WebServiceEndpointStatsImpl;
41 import com.sun.enterprise.admin.wsmgmt.WebServiceMgrBackEnd;
42 import com.sun.enterprise.admin.monitor.registry.MonitoringRegistrationException;
43 import com.sun.enterprise.admin.monitor.registry.MonitoringRegistry;
44 import com.sun.enterprise.admin.monitor.registry.MonitoringLevelListener;
45 import javax.management.j2ee.statistics.Stats JavaDoc;
46 import
47 com.sun.appserv.management.monitor.statistics.WebServiceEndpointAggregateStats;
48 import com.sun.enterprise.server.ApplicationServer;
49
50
51 /**
52  * Manages filters for each web service end point, according to their
53  * configuration and registers/unregisters the required dotted names.
54  *
55  * @author Satish Viswanatham
56  * @since J2SE 5.0
57  */

58 class EndpointRegistration {
59
60     /**
61      * Contructor
62      *
63      * @param name Name of the web service endpoint
64      * @param moduleName Name of the module (bundleName)
65      * @param boolean Indicates if this module is standalone or not
66      * @param vs Name of the virtual server
67      * @param j2eeAppName Name of the J2EE application
68      * @param isEjbModule true, if the module of ejb type
69      */

70      public EndpointRegistration(String JavaDoc n, String JavaDoc modName, String JavaDoc cRoot,
71      boolean isSA, String JavaDoc v, String JavaDoc appName, boolean isEjb) {
72
73         name = n;
74         moduleName = modName;
75         this.ctxRoot = cRoot;
76         if ((ctxRoot != null) && (ctxRoot.length() > 0) &&
77             (ctxRoot.charAt(0) != '/')) {
78             ctxRoot = "/" + ctxRoot;
79         }
80         if ("".equals(ctxRoot)) {
81             ctxRoot = "/";
82         }
83         isStandAlone = isSA;
84         vs = v;
85         j2eeAppName = appName;
86         isEjbModule = isEjb;
87         endpoint =
88         WebServiceMgrBackEnd.getManager().getFullyQualifiedName( j2eeAppName,
89             moduleName, name);
90
91      }
92
93     /**
94      * This method is used during initialization to install Filters required for
95      * Monitoring. This method is also called during Monitoring level change
96      * event and during deploy/un-deploy
97      *
98      * @throws
99      */

100     public void enableLOW() throws MonitoringRegistrationException {
101     
102             Filter f = new AggregateStatsFilter();
103             FilterRegistry.getInstance().registerFilter(
104                 Filter.PRE_PROCESS_REQUEST, endpoint, f);
105             FilterRegistry.getInstance().registerFilter(
106                 Filter.POST_PROCESS_RESPONSE, endpoint, f);
107
108             // register corresponding stats provider
109
WebServiceEndpointStatsProvider prov = new
110             WebServiceEndpointStatsProviderImpl();
111
112             StatsProviderManager.getInstance().
113                 registerEndpointStatsProvider(endpoint, prov);
114
115             MonitoringLevelListener listener = new
116             WSMonitoringLevelListener(name, moduleName, ctxRoot, isStandAlone,
117                 vs, j2eeAppName, isEjbModule);
118             Stats JavaDoc stats = new WebServiceEndpointStatsImpl(prov);
119
120             String JavaDoc appName = null;
121             if ( isStandAlone == true) {
122                 appName = null;
123             } else {
124                 appName = j2eeAppName;
125             }
126
127             if ( isEjbModule ) {
128                 registry.registerWSAggregateStatsForEjb(stats,
129                     name, moduleName, appName, listener);
130             } else {
131                 registry.registerWSAggregateStatsForWeb(stats,
132                     name, moduleName, ctxRoot, appName, vs, listener);
133             }
134     }
135
136     public void disableLOW()
137         throws MonitoringRegistrationException {
138
139             FilterRegistry.getInstance().unregisterFilterByName(
140             Filter.PRE_PROCESS_REQUEST, endpoint,
141             Constants.AGGREGATE_STATS_FILTER );
142             FilterRegistry.getInstance().unregisterFilterByName(
143             Filter.POST_PROCESS_RESPONSE, endpoint,
144             Constants.AGGREGATE_STATS_FILTER );
145             if ( isEjbModule ) {
146                registry.unregisterWSAggregateStatsForEjb(
147                     name, moduleName, j2eeAppName);
148             } else {
149                 registry.unregisterWSAggregateStatsForWeb(
150                     name, moduleName, ctxRoot, j2eeAppName, vs);
151             }
152             StatsProviderManager.getInstance().unregisterEndpointStatsProvider(
153                 endpoint);
154     }
155
156     private static MonitoringRegistry registry = ApplicationServer.
157                 getServerContext().getMonitoringRegistry();;
158
159     // PRIVATE VARIABLES
160
private String JavaDoc ctxRoot = null;
161     String JavaDoc name = null;
162     String JavaDoc moduleName = null;
163     boolean isStandAlone = false;
164     String JavaDoc vs = null;
165     String JavaDoc j2eeAppName = null;
166     boolean isEjbModule = false;
167     String JavaDoc endpoint = null;
168 }
169
Popular Tags