1 23 24 package com.sun.enterprise.management.monitor; 25 26 import java.util.Map ; 27 import java.util.Set ; 28 import java.util.Collections ; 29 30 import javax.management.ObjectName ; 31 import javax.management.JMException ; 32 33 import com.sun.appserv.management.base.XTypes; 34 import com.sun.appserv.management.base.Util; 35 import com.sun.appserv.management.base.AMX; 36 import com.sun.appserv.management.j2ee.J2EETypes; 37 import com.sun.appserv.management.util.misc.GSetUtil; 38 39 import com.sun.appserv.management.monitor.ServerRootMonitor; 40 import com.sun.appserv.management.monitor.CallFlowMonitor; 41 42 import com.sun.enterprise.management.support.ObjectNames; 43 import com.sun.enterprise.management.support.BootUtil; 44 45 46 47 49 public final class ServerRootMonitorImpl 50 extends MonitoringImplBase 51 { 53 public ServerRootMonitorImpl() 54 { 55 super( XTypes.SERVER_ROOT_MONITOR ); 56 } 57 58 59 public Map <String ,ObjectName > 60 getORBConnectionManagerMonitorObjectNameMap() 61 { 62 return( getContaineeObjectNameMap( XTypes.CONNECTION_MANAGER_MONITOR ) ); 63 } 64 65 66 private static final Set <String > NOT_SUPERFLUOUS = 67 GSetUtil.newUnmodifiableStringSet( 68 "getCallFlowMonitorObjectName", 69 "getORBConnectionManagerMonitorObjectNameMap" 70 ); 71 protected final Set <String > 72 getNotSuperfluousMethods() 73 { 74 return GSetUtil.newSet( super.getNotSuperfluousMethods(), NOT_SUPERFLUOUS ); 75 } 76 77 78 protected void 79 registerMisc() 80 { 81 super.registerMisc(); 82 83 if ( getLoader().isDAS() ) 84 { 85 if ( ( BootUtil.getInstance().getServerName().equals( getName() ) ) ) 86 { 87 registerCallFlow(); 89 } 90 } 91 else 92 { 93 throw new RuntimeException ( "ServerRootMonitorImpl expected in DAS only" ); 96 } 97 98 } 99 100 public final ObjectName 101 getCallFlowMonitorObjectName() 102 { 103 return getContaineeObjectName( XTypes.CALL_FLOW_MONITOR ); 104 } 105 106 protected void 107 unregisterMisc() 108 { 109 if ( getLoader().isDAS() ) 110 { 111 try 112 { 113 getMBeanServer().unregisterMBean( getCallFlowMonitorObjectName() ); 114 } 115 catch( JMException e ) 116 { 117 logWarning( "ServerRootMonitorImpl: exception unregistering CallFlowMonitor: " + e); 118 } 119 } 120 } 121 122 protected final void 123 registerCallFlow() 124 { 125 final ObjectNames objectNames = ObjectNames.getInstance( getJMXDomain() ); 126 final ObjectName childObjectName = 127 objectNames.buildContaineeObjectName( getObjectName(), 128 getFullType(), XTypes.CALL_FLOW_MONITOR, 129 getName() ); 130 131 final CallFlowMonitorImpl callFlow = new CallFlowMonitorImpl(); 132 try 133 { 134 debug( "Loading CallFlowMonitor for DAS: " + childObjectName ); 135 getMBeanServer().registerMBean( callFlow, childObjectName ); 136 } 137 catch( JMException e ) 138 { 139 logWarning( "ServerRootMonitor: Can't load CallFlow" ); 140 } 141 } 142 143 final Set <String > FAUX_CONTAINEE_TYPES = 144 GSetUtil.newUnmodifiableStringSet( 145 XTypes.EJB_MODULE_MONITOR, 146 XTypes.WEB_MODULE_VIRTUAL_SERVER_MONITOR 147 ); 148 149 protected Set <String > 150 getFauxChildTypes() 151 { 152 return( FAUX_CONTAINEE_TYPES ); 153 } 154 155 156 157 161 public final Set <ObjectName > 162 getContaineeObjectNameSet( final String childJ2EEType ) 163 { 164 final Set <ObjectName > result = super.getContaineeObjectNameSet( childJ2EEType ); 165 166 if ( getFauxChildTypes().contains( childJ2EEType ) ) 167 { 168 final String nullAppMonitorProp = Util.makeProp( XTypes.APPLICATION_MONITOR, AMX.NULL_NAME ); 169 170 final Set <ObjectName > fauxContainees = getFauxContaineeObjectNameSet( childJ2EEType, nullAppMonitorProp); 171 result.addAll( fauxContainees ); 172 } 173 174 return( result ); 175 } 176 } 177 | Popular Tags |