AppServWSMonitorLifeCycleProviderpublic class AppServWSMonitorLifeCycleProvider extends Object implements com.sun.enterprise.admin.monitor.WSMonitorLifeCycleProviderThis is the mechanism to initialize web service management functionality.
|
Fields Summary |
---|
private com.sun.enterprise.instance.AppsManager | appsMgr | private com.sun.enterprise.admin.wsmgmt.config.spi.ConfigProvider | cfgProv | private static final com.sun.enterprise.util.i18n.StringManager | _stringMgr | private static final Logger | _logger |
Constructors Summary |
---|
public AppServWSMonitorLifeCycleProvider()
try {
cfgProv = ConfigFactory.getConfigFactory().getConfigProvider();
InstanceEnvironment ienv =
ApplicationServer.getServerContext().getInstanceEnvironment();
appsMgr = new AppsManager(ienv);
} catch (Exception e) {
_logger.fine(" Exception during initialization of AppServWSMonitorLifeCycleProvider " + e.getMessage());
// log exception in FINE level. This excpetion should never occur.
}
|
Methods Summary |
---|
public java.lang.String | getProviderID()Returns the unique identifier for this RepositoryProvider object.
return WSMonitorLifeCycleFactory.WSMGMT_DEFAULT_PROVIDER;
| void | instrument(java.lang.String endpoint, java.lang.String modName, java.lang.String ctxRoot, boolean isStandAlone, java.lang.String appId, boolean isEjbModule, java.lang.String vs)Returns the list of Web Service Endpoint config in this application
WebServiceConfigImpl wsConfig = (WebServiceConfigImpl) cfgProv.
getWebServiceConfig( appId, modName, isStandAlone, endpoint) ;
if (wsConfig == null) {
return;
}
if (isStandAlone) {
modName = appId;
appId = null;
}
TransformMgr.getInstance().init(appId, wsConfig);
try {
new MonitoringLifeCycleImpl().initializeMonitoring(appId,
modName, ctxRoot, isStandAlone, isEjbModule, vs, wsConfig);
} catch ( Exception e) {
// log a warning
_logger.fine("Exception during monitoring initialization " +
e.getMessage());
}
| void | instrumentWebServiceEndpoints(java.lang.String appId, com.sun.enterprise.deployment.BundleDescriptor bd, boolean shouldRegister)Registers the web service endpoints in this application
boolean isEjb = false;
boolean isStandAlone = false;
String modName = null;
String ctxRoot = null;
String vs = WebServiceMgrBackEnd.DEFAULT_VIRTUAL_SERVER;
Server server = null;
try {
ServerContext sCtx = ApplicationServer.getServerContext();
server = ServerHelper.getServerByName(sCtx.getConfigContext(),
sCtx.getInstanceName());
ApplicationRef aRef = server.getApplicationRefByRef(appId);
if (aRef != null) {
vs = aRef.getVirtualServers();
if ((vs == null) || ( vs.length() == 0)) {
vs = WebServiceMgrBackEnd.DEFAULT_VIRTUAL_SERVER;
}
} else {
throw new IllegalArgumentException();
}
} catch( Exception e) {
throw new RuntimeException(e);
}
modName = bd.getModuleDescriptor().getArchiveUri();
if ( bd instanceof EjbBundleDescriptor ) {
isEjb = true;
} else if ( bd instanceof WebBundleDescriptor ) {
isEjb = false;
ctxRoot = ((WebBundleDescriptor) bd).getContextRoot();
} else {
return;
}
Application app = bd.getApplication();
if ( app == null) {
String msg = _stringMgr.getString("Application_NotFound", appId);
throw new RuntimeException(msg);
}
isStandAlone = app.isVirtual();
Collection wsCollec = bd.getWebServices().getWebServices();
Set wsSet = new HashSet();
for (Iterator i1 = wsCollec.iterator(); i1.hasNext();) {
WebService ws = (WebService) i1.next();
wsSet.addAll(ws.getEndpoints());
}
for (Iterator i2 = wsSet.iterator(); i2.hasNext();) {
com.sun.enterprise.deployment.WebServiceEndpoint wse =
(com.sun.enterprise.deployment.WebServiceEndpoint) i2.next();
String epName = wse.getEndpointName();
if ( shouldRegister == true ) {
instrument( epName, modName, ctxRoot, isStandAlone, appId,
isEjb, vs);
} else {
uninstrument( epName, modName, ctxRoot, isStandAlone, appId,
isEjb, vs);
}
}
| public void | reconfigureMonitoring(com.sun.enterprise.config.serverbeans.WebServiceEndpoint ep, java.lang.String appId, com.sun.enterprise.admin.monitor.registry.MonitoringLevel oldLevel, com.sun.enterprise.admin.monitor.registry.MonitoringLevel newLevel)
// There no work needed for LOW to HIGH or HIGH or LOW changes.
// because the monitoring stats collected are the same.
if ( (oldLevel != MonitoringLevel.OFF) &&
(newLevel != MonitoringLevel.OFF) ) {
return;
}
if ( ep == null) {
return;
}
boolean isEjb = false;
boolean isStandAlone = false;
String modName = null;
String ctxRoot = null;
String appName = null;
String epName = null;
String vs = WebServiceMgrBackEnd.DEFAULT_VIRTUAL_SERVER;
ConfigBean parent = (ConfigBean) ep.parent();
if (parent instanceof J2eeApplication) {
isStandAlone = false;
appName = appId;
modName =
WebServiceMgrBackEnd.getManager().getModuleName(ep.getName());
// set isEjb to true in case of ejb embedded module
if (modName.endsWith("jar")) {
isEjb = true;
} else {
if (appsMgr != null) {
Application app = null;
try {
app = appsMgr.getDescriptor(appId);
} catch (ConfigException ce) {
// log a warning
}
if (app != null) {
WebBundleDescriptor wbd
= app.getWebBundleDescriptorByUri(modName);
if (wbd != null) {
ctxRoot = wbd.getContextRoot();
}
}
}
}
} else if (parent instanceof WebModule) {
isStandAlone = true;
appName = null;
modName = appId;
ctxRoot = ((WebModule) parent).getContextRoot();
} else if (parent instanceof EjbModule) {
isStandAlone = true;
isEjb = true;
appName = null;
modName = appId;
}
epName= WebServiceMgrBackEnd.getManager().getEndpointName(ep.getName());
new MonitoringLifeCycleImpl().instrumentMonitoring(epName,
modName, ctxRoot, isStandAlone, vs, appName,
oldLevel, newLevel, isEjb);
| public void | registerWebServiceEndpoints(java.lang.String appId, com.sun.enterprise.deployment.BundleDescriptor bd)registers the web service endpoints in this application
instrumentWebServiceEndpoints(appId, bd, true);
| void | uninstrument(java.lang.String endpoint, java.lang.String modName, java.lang.String ctxRoot, boolean isStandAlone, java.lang.String appId, boolean isEjbModule, java.lang.String vs)Returns the list of Web Service Endpoint config in this application
try {
MessageTraceMgr.getInstance().disable(appId, endpoint);
} catch ( Exception e) {
// log a warning
_logger.fine("Exception while disabling trace" +
e.getMessage());
}
WebServiceConfigImpl wsConfig = (WebServiceConfigImpl) cfgProv.
getWebServiceConfig(appId, modName, isStandAlone, endpoint) ;
if (wsConfig == null) {
return;
}
if (isStandAlone) {
modName = appId;
appId = null;
}
TransformMgr.getInstance().stop(appId, wsConfig);
try {
new MonitoringLifeCycleImpl().uninitializeMonitoring(appId,
modName, ctxRoot, isStandAlone, isEjbModule, vs, wsConfig);
} catch ( Exception e) {
// log a warning
_logger.fine("Exception during monitoring shutdown " +
e.getMessage());
}
| public void | unregisterWebServiceEndpoints(java.lang.String appId, com.sun.enterprise.deployment.BundleDescriptor bd)un registers the web service endpoints in this application
instrumentWebServiceEndpoints(appId, bd, false);
|
|