1 23 24 29 30 package com.sun.enterprise.management.j2ee; 31 32 import java.util.Map ; 33 34 import javax.management.ObjectName ; 35 36 import com.sun.appserv.management.j2ee.J2EETypes; 37 38 import com.sun.appserv.management.base.XTypes; 39 import com.sun.appserv.management.base.AMX; 40 import com.sun.appserv.management.base.Util; 41 42 import com.sun.appserv.management.util.misc.MapUtil; 43 import com.sun.appserv.management.util.misc.CollectionUtil; 44 import com.sun.appserv.management.util.misc.ExceptionUtil; 45 import com.sun.appserv.management.util.misc.StringUtil; 46 import com.sun.appserv.management.util.jmx.AttributeNameMapper; 47 48 import com.sun.enterprise.management.support.Delegate; 49 import com.sun.enterprise.management.support.WebModuleSupport; 50 51 import com.sun.appserv.management.j2ee.WebModule; 52 import com.sun.appserv.management.j2ee.Servlet; 53 54 56 public final class WebModuleImpl extends J2EEModuleImplBase 57 { 59 public 60 WebModuleImpl( final Delegate delegate ) 61 { 62 super( delegate ); 63 } 64 65 70 protected String 71 getConfigPeerName() 72 { 73 final String compositeName = getName(); 74 75 final String webModuleName = WebModuleSupport.extractWebModuleName( compositeName ); 76 77 return( webModuleName ); 78 } 79 80 public boolean 81 isConfigProvider() 82 { 83 boolean isConfigProvider = super.isConfigProvider(); 84 if ( super.isConfigProvider() && getObjectName() != null ) 85 { 86 final String name = getConfigPeerName(); 87 88 92 if ( name.length() == 0 || name.equals( "asadmin" ) || 93 name.equals( "web1" ) ) 94 { 95 isConfigProvider = false; 96 } 97 98 } 99 100 return( isConfigProvider ); 101 } 102 103 protected WebModule 104 getSelfProxy() 105 { 106 return (WebModule)getSelf(); 107 } 108 109 public String [] 110 getservlets() 111 { 112 final Map <String ,Servlet> servlets = getSelfProxy().getServletMap(); 113 114 return( CollectionUtil.toStringArray( Util.toObjectNames( servlets ).values() ) ); 115 } 116 117 public Map 118 getServletObjectNameMap() 119 { 120 return( getContaineeObjectNameMap( J2EETypes.SERVLET ) ); 121 } 122 123 protected String 124 getMonitoringPeerJ2EEType() 125 { 126 return( XTypes.WEB_MODULE_VIRTUAL_SERVER_MONITOR ); 127 } 128 129 130 private final String 131 deduceModuleName() 132 { 133 final String workDir = getSelfProxy().getWorkDir(); 135 final int index1 = workDir.lastIndexOf( "/" ); 136 final int index2 = workDir.lastIndexOf( "\\" ); 137 final int index = index1 > index2 ? index1 : index2; 138 139 String result = null; 140 141 if (index > 0 ) 142 { 143 result = workDir.substring( index + 1, workDir.length() ); 144 } 145 146 return( result ); 147 } 148 149 protected ObjectName 150 queryConfigPeerFailed( final Map <String ,String > propsMap ) 151 { 152 final String potentialName = deduceModuleName(); 153 propsMap.put( AMX.NAME_KEY, potentialName ); 154 155 final ObjectName result = queryProps( propsMap ); 156 157 return( result ); 158 } 159 160 protected ObjectName 161 queryMonitoringPeerFailed( final Map <String ,String > propsMap ) 162 { 163 final String selfName = getName(); 164 165 final String virtualServerName = WebModuleSupport.extractVirtualServerName( selfName ); 166 167 ObjectName result = null; 168 169 final String potentialName = deduceModuleName(); 170 if ( potentialName != null ) 171 { 172 final String name = WebModuleSupport.formCompositeName( virtualServerName, potentialName ); 173 174 propsMap.put( AMX.NAME_KEY, name ); 175 result = queryProps( propsMap ); 176 } 177 178 return result; 179 } 180 } 181 | Popular Tags |