*/
private void enableHttpMonitoring(){
String vsId;
int port;
HttpService httpService;
ServerContext sc = getServerContext();
ConfigContext cc = sc.getConfigContext();
MonitoringRegistry mReg = sc.getMonitoringRegistry();
try {
httpService = ServerBeansFactory.getHttpServiceBean(cc);
} catch(ConfigException ce) {
_logger.log(Level.WARNING,
"Unable to find HttpServiceBean in config",
ce);
return;
}
// keep-alive
try {
mReg.registerPWCKeepAliveStats(
new PWCKeepAliveStatsImpl(sc.getDefaultDomainName()),
null);
} catch (MonitoringRegistrationException mre) {
String msg = _logger.getResourceBundle().getString(
"web.monitoringRegistrationError");
msg = MessageFormat.format(msg,
new Object[] { "PWCKeepAliveStats" });
_logger.log(Level.WARNING, msg, mre);
}
// file-cache
try {
mReg.registerPWCFileCacheStats(
new PWCFileCacheStatsImpl(sc.getDefaultDomainName()),null);
} catch (MonitoringRegistrationException mre) {
String msg = _logger.getResourceBundle().getString(
"web.monitoringRegistrationError");
msg = MessageFormat.format(msg,
new Object[] { "PWCFileCacheStats" });
_logger.log(Level.WARNING, msg, mre);
}
// pwc-thread-pool
try {
mReg.registerPWCThreadPoolStats(
new PWCThreadPoolStatsImpl(sc.getDefaultDomainName()),
null);
} catch (MonitoringRegistrationException mre) {
String msg = _logger.getResourceBundle().getString(
"web.monitoringRegistrationError");
msg = MessageFormat.format(msg,
new Object[] { "PWCThreadPoolStats" });
_logger.log(Level.WARNING, msg, mre);
}
// connection-queue
try {
mReg.registerPWCConnectionQueueStats(
new PWCConnectionQueueStatsImpl(sc.getDefaultDomainName()),
null);
} catch (MonitoringRegistrationException mre) {
String msg = _logger.getResourceBundle().getString(
"web.monitoringRegistrationError");
msg = MessageFormat.format(msg,
new Object[] { "PWCConnectionQueueStats" });
_logger.log(Level.WARNING, msg, mre);
}
com.sun.enterprise.config.serverbeans.VirtualServer[] vs
= httpService.getVirtualServer();
HttpListener currentListener;
for(int i = 0; i<vs.length ; i++) {
vsId = vs[i].getId();
if(!vsId.equalsIgnoreCase(VirtualServer.ADMIN_VS)) {
VirtualServer virtualServer =
(VirtualServer)getEngines()[0].findChild(vsId);
if (virtualServer == null){
_logger.log(Level.WARNING,
"Invalid virtual-server: " + vsId);
continue;
}
List listeners = StringUtils.parseStringList(
vs[i].getHttpListeners(), ",");
if(listeners != null) {
ListIterator iter = listeners.listIterator();
while(iter.hasNext()) {
currentListener = httpService.getHttpListenerById
(iter.next().toString());
if (currentListener == null)
continue;