1 23 24 package com.sun.enterprise.management.model; 25 26 import javax.management.ObjectName ; 27 import java.util.Set ; 28 import java.util.Map ; 29 import java.io.Serializable ; 30 import com.sun.enterprise.admin.wsmgmt.msg.MessageTraceMgr; 31 import com.sun.appserv.management.ext.wsmgmt.MessageTrace; 32 import com.sun.appserv.management.util.misc.TypeCast; 33 import com.sun.enterprise.admin.wsmgmt.stats.spi.StatsProviderManager; 34 import com.sun.enterprise.admin.wsmgmt.stats.spi.WebServiceEndpointStatsProvider; 35 36 42 public abstract class WebServiceEndpointMdl extends J2EEManagedObjectMdl { 43 44 private static String MANAGED_OBJECT_TYPE = "WebServiceEndpoint"; 45 protected static String WEB_MBEAN = "ServletWebServiceEndpoint"; 46 protected static String EJB_MBEAN = "EJBWebServiceEndpoint"; 47 48 private String moduleName = null; 49 private String registrationName = null; 50 private String applicationName = null; 51 private String epName = null; 52 private boolean isEjb = false; 53 private boolean isStandAlone = false; 54 private String mbeanName = null; 55 56 66 WebServiceEndpointMdl(String name, String mName, String regName, 67 boolean isVirtual, boolean isejb) { 68 super(name,false, false, false); 69 this.moduleName = mName; 70 this.applicationName = regName; 71 this.registrationName = regName; 72 this.isStandAlone = isVirtual; 73 this.epName = name; 74 this.isEjb = isejb; 75 if (isejb == true) { 76 mbeanName = EJB_MBEAN; 77 } else { 78 mbeanName = WEB_MBEAN; 79 } 80 } 81 82 93 WebServiceEndpointMdl(String name, String moduleName, 94 String regName, String serverName, boolean isVirtual, 95 boolean isejb) { 96 97 super(name, serverName, false, false, false); 98 this.moduleName = moduleName; 99 this.applicationName = regName; 100 this.registrationName = regName; 101 this.epName = name; 102 this.isEjb = isejb; 103 if (isejb == true) { 104 mbeanName = EJB_MBEAN; 105 } else { 106 mbeanName = WEB_MBEAN; 107 } 108 this.isStandAlone = isVirtual; 109 } 110 111 116 public String getModule(){ 117 return this.moduleName; 118 } 119 120 125 public String getJ2EEApplication(){ 126 return this.applicationName; 127 } 128 129 135 public String getImplementationType() { 136 if (isEjb) { 137 return "EJB"; 138 } else { 139 return "SERVLET"; 140 } 141 } 142 143 148 public Map <String ,Serializable >[] getMessagesInHistory() { 149 String partialEpName = null; 150 151 if (isStandAlone) { 152 partialEpName = this.epName; 154 } else { 155 partialEpName = this.moduleName+ "#" + this.epName; 156 } 157 158 Map <String ,Serializable >[] maps = null; 159 MessageTrace[] result = 160 MessageTraceMgr.getInstance().getMessages(this.registrationName, 161 partialEpName); 162 if ( result == null) { 163 return null; 164 } 165 if ( result.length > 0 ) { 166 maps = new Map [result.length]; 167 for ( int idx =0; idx < result.length; idx++) { 168 maps[idx] = result[idx].asMap(); 169 TypeCast.checkSerializable( maps[ idx] ); 170 } 171 } 172 return maps; 173 174 } 175 176 183 public String getobjectName() { 184 Set s = null; 185 186 if ( isEjb ) { 187 s = findNames("j2eeType="+getj2eeType()+",name="+this.epName+ 188 ",EJBModule="+this.getModule()+",J2EEApplication="+ 189 this.getJ2EEApplication()+",J2EEServer="+this.getJ2EEServer()); 190 } else { 191 s = findNames("j2eeType="+getj2eeType()+",name="+this.epName+ 192 ",WebModule="+this.getModule()+",J2EEApplication="+ 193 this.getJ2EEApplication()+",J2EEServer="+this.getJ2EEServer()); 194 } 195 Object [] objs = s.toArray(); 196 if (objs.length > 0) { 197 String name = ((ObjectName )objs[0]).toString(); 198 return name; 199 } else { 200 return null; 201 } 202 } 203 204 211 public String getj2eeType() { 212 return MANAGED_OBJECT_TYPE; 213 } 214 215 222 public abstract String getMBeanName(); 223 224 227 private WebServiceEndpointStatsProvider getWSProvider() { 228 final String NS = "#"; 229 StatsProviderManager spMgr = StatsProviderManager.getInstance(); 230 231 String fqName = null; 232 if (isStandAlone == false) { 233 fqName = registrationName + NS + moduleName + NS + epName; 234 } else { 235 fqName = registrationName + NS + epName; 236 } 237 WebServiceEndpointStatsProvider provider = 238 spMgr.getEndpointStatsProvider(fqName); 239 240 return provider; 241 } 242 243 246 public void resetStats() { 247 WebServiceEndpointStatsProvider provider = getWSProvider(); 248 if (provider != null) { 249 provider.reset(); 250 } 251 } 252 253 258 public long getLastResetTime() { 259 long resetTime = 0; 260 WebServiceEndpointStatsProvider provider = getWSProvider(); 261 if (provider != null) { 262 resetTime = provider.getLastResetTime(); 263 } 264 265 return resetTime; 266 } 267 } 268 | Popular Tags |