1 23 package com.sun.enterprise.management.j2ee; 24 25 import java.util.Map ; 26 import java.util.Set ; 27 28 import javax.management.ObjectName ; 29 import javax.management.j2ee.statistics.ServletStats ; 30 31 32 import com.sun.appserv.management.j2ee.Servlet; 33 import com.sun.appserv.management.j2ee.WebModule; 34 import com.sun.appserv.management.j2ee.J2EETypes; 35 36 import com.sun.appserv.management.base.XTypes; 37 import com.sun.appserv.management.base.Util; 38 39 40 import com.sun.appserv.management.util.misc.MapUtil; 41 import com.sun.appserv.management.util.misc.ExceptionUtil; 42 import com.sun.appserv.management.util.misc.GSetUtil; 43 import com.sun.appserv.management.util.misc.StringUtil; 44 import com.sun.appserv.management.util.misc.CollectionUtil; 45 46 import com.sun.enterprise.management.support.Delegate; 47 48 import com.sun.appserv.management.monitor.statistics.AltServletStats; 49 50 import com.sun.appserv.management.monitor.WebModuleVirtualServerMonitor; 51 import com.sun.appserv.management.monitor.ServletMonitor; 52 53 import com.sun.enterprise.management.support.WebModuleSupport; 54 55 57 public final class ServletImpl 58 extends J2EEManagedObjectImplBase 59 { 61 public 62 ServletImpl( final Delegate delegate ) 63 { 64 super( delegate ); 65 } 66 67 68 static private final Set <String > IGNORE_MISSING = 69 GSetUtil.newUnmodifiableStringSet( 70 "maxTimeMillis", "minTimeMillis", "processingTimeMillis", 71 "requestCount", "errorCount" 72 ); 73 74 77 protected void 78 handleMissingOriginals( final Set <String > missingOriginals ) 79 { 80 missingOriginals.removeAll( IGNORE_MISSING ); 81 82 super.handleMissingOriginals( missingOriginals ); 83 } 84 85 86 87 protected String 88 getMonitoringPeerJ2EEType() 89 { 90 return( XTypes.SERVLET_MONITOR ); 91 } 92 93 protected ObjectName 94 queryMonitoringPeerFailed( final Map <String ,String > propsMap ) 95 { 96 final WebModule webModule = (WebModule)getContainer(); 97 98 debug( "queryMonitoringPeerFailed: expecting to find " + 99 MapUtil.toString( propsMap ) ); 100 101 if ( webModule == null ) 102 { 103 logWarning( 104 "ServletImpl.queryMonitoringPeerFailed: " + 105 "Can't get containing WebModule, my ObjectName = " + getObjectName()); 106 } 107 108 ObjectName result = null; 109 110 try 111 { 112 final WebModuleVirtualServerMonitor webModuleVirtualServerMonitor = 113 (WebModuleVirtualServerMonitor)webModule.getMonitoringPeer(); 114 if ( webModuleVirtualServerMonitor == null ) 115 { 116 final ObjectName objectName = Util.getObjectName( webModule ); 117 118 final String msg = "ServletImpl.queryMonitoringPeerFailed: " + 119 "Can't get WebModuleVirtualServerMonitor for " + 120 quote( toString( objectName )); 121 debug( msg ); 122 logFine( msg ); 123 } 124 else 125 { 126 final Map <String ,ServletMonitor> servletMap = 127 webModuleVirtualServerMonitor.getServletMonitorMap(); 128 129 final ServletMonitor sm = servletMap.get( getName() ); 130 if ( sm != null ) 131 { 132 result = Util.getObjectName( sm ); 133 } 134 else 135 { 136 final String servletMonitorNames = CollectionUtil.toString( 137 Util.toObjectNames( servletMap ).values(), StringUtil.NEWLINE() ); 138 139 logWarning( 140 "ServletImpl.queryMonitoringPeerFailed: " + 141 "Can't find ServletMonitor, my ObjectName = " + 142 quote( toString( getObjectName() ) ) + 143 ", WebModuleVirtualServerMonitor " + 144 quote( toString( Util.getObjectName(webModuleVirtualServerMonitor) )) + 145 " ServletMonitor names:" + StringUtil.NEWLINE() + servletMonitorNames ); 146 } 147 } 148 } 149 catch( Exception e ) 150 { 151 logWarning( "ServletImpl.queryMonitoringPeerFailed: " + e); 152 debug( "ServletImpl.queryMonitoringPeerFailed: " + e + "\n" + 153 ExceptionUtil.getStackTrace( e ) ); 154 } 155 156 return result; 157 } 158 } 159 160 161 162 163 164 | Popular Tags |