FileDocCategorySizeDatePackage
J2EEManagedObjectImplBase.javaAPI DocGlassfish v2 API14131Fri May 04 22:23:30 BST 2007com.sun.enterprise.management.j2ee

J2EEManagedObjectImplBase

public abstract class J2EEManagedObjectImplBase extends com.sun.enterprise.management.support.AMXNonConfigImplBase

Fields Summary
protected long
mStartTime
private static final Set
IGNORE_MISSING
We may (or may not) want to expose some of these at some point, though not necessarily with the same names.
private static final Map
ToConfigMap
Map from JSR77 j2eeType to our config j2eeType.
private static final Map
MON_MAP
Maps a j2eeType to its peer monitoring j2eeType
private static final Set
DEPLOYED_TYPES
Constructors Summary
public J2EEManagedObjectImplBase()

		this( null );
	
public J2EEManagedObjectImplBase(com.sun.enterprise.management.support.Delegate delegate)

		super( delegate );
		mStartTime	= 0;
	
protected J2EEManagedObjectImplBase(String j2eeType, com.sun.enterprise.management.support.Delegate delegate)

		super( j2eeType, delegate );
		mStartTime	= 0;
	
Methods Summary
protected java.lang.StringgetConfigPeerJ2EEType()

	
		 
	
	
		final String	configPeerJ2EEType	= (String)ToConfigMap.get( getSelfJ2EEType() );

		return( configPeerJ2EEType );
	
protected java.lang.StringgetConfigPeerName()

		return( getSelfName() );
	
public javax.management.ObjectNamegetConfigPeerObjectName()
Get the name of a config peer. Default behavior is to use the config peer j2eeType, together with the name of this MBean and GROUP_CONFIGURATION to locate a single MBean. A subclass not following this convention will have to override this method.

		ObjectName	configPeerObjectName	= null;
		
		if (isConfigProvider() )
		{
			final Map<String,String>	propsMap	= getConfigPeerProps( );
			if ( propsMap != null )
			{
				configPeerObjectName	= queryProps( propsMap );
				if ( configPeerObjectName == null )
				{
					configPeerObjectName	= queryConfigPeerFailed( propsMap );
				}
			}
		
		}
		
		return( configPeerObjectName );
	
protected java.util.MapgetConfigPeerProps()
If there is a config peer, return properties that uniquely identify it. This base implementation won't be sufficient for many MBeans, so subclasses should call super.getConfigPeerProps(), then tack on any additional ones.

		HashMap<String,String>	props	= null;
		final String	j2eeType = getConfigPeerJ2EEType();
		if ( j2eeType != null )
		{
			props	= new HashMap<String,String>();
			
			props.put( AMX.J2EE_TYPE_KEY, j2eeType );
			props.put( AMX.NAME_KEY, getConfigPeerName() );
		}
		return( props );
	
protected final java.lang.String[]getContaineeObjectNameStrings(java.lang.String j2eeType)

		final Set<ObjectName>	objectNames	= getContaineeObjectNameSet( j2eeType );
		
		final String[]	names	= GSetUtil.toStringArray( objectNames );
		
		return( names );
	
public java.util.SetgetDeployedObjectsObjectNameSet()

	
	
		 
	
	
		return( getContaineeObjectNameSet( DEPLOYED_TYPES ) );
	
protected java.util.SetgetDontMapAttributeNames()
Return a list of Attribute names which should not be mapped.

		// all mapped by default
		return( Collections.emptySet() );
	
public final java.lang.StringgetGroup()

		return( AMX.GROUP_JSR77 );
	
public com.sun.appserv.management.j2ee.J2EEServergetJ2EEServer()

	    return getProxyFactory().getProxy( getServerObjectName(), J2EEServer.class);
	
protected java.lang.StringgetMonitoringPeerJ2EEType()

	
		 
	
	
		final String	monPeerJ2EEType	= (String)MON_MAP.get( getSelfJ2EEType() );

		return( monPeerJ2EEType );
	
protected java.lang.StringgetMonitoringPeerName()

		return( getSelfName() );
	
public javax.management.ObjectNamegetMonitoringPeerObjectName()

		ObjectName	objectName	= null;
		
		final Map<String,String>	propsMap	= getMonitoringPeerProps();
		if ( propsMap != null && propsMap.keySet().size() != 0 )
		{
			debug( "getMonitoringPeerObjectName: my ObjectName = ", getObjectName(),
			    ", queryProps = ", MapUtil.toString( propsMap, ", " ) );
			objectName	= queryProps( propsMap );

			if ( objectName == null )
			{
				objectName	= queryMonitoringPeerFailed( propsMap );
			}
		}
		
		return( objectName );
	
protected java.util.MapgetMonitoringPeerProps(java.lang.String monitorJ2EEType, java.lang.String monitorName)

		final Map<String,String>	props	= new HashMap<String,String>();
		
		props.put( AMX.J2EE_TYPE_KEY, monitorJ2EEType );
		props.put( AMX.NAME_KEY, monitorName );
		
		for( final String j2eeType : MON_MAP.keySet() )
		{
			final String	j2eeMonType	= (String)MON_MAP.get( j2eeType );
			
			final String	name	= getKeyProperty( j2eeType );
			if ( name != null )
			{
				props.put( j2eeMonType, name );
			}
		}
		
		return( props );
	
protected java.util.MapgetMonitoringPeerProps()

		Map<String,String>	props	= null;
		
		final String	j2eeType	= getMonitoringPeerJ2EEType();
		if ( j2eeType != null )
		{
			props	= getMonitoringPeerProps( j2eeType, getMonitoringPeerName() );
		}
		return( props );
	
protected java.lang.StringgetServerName()

		return( getObjectName().getKeyProperty( "J2EEServer" ) );
	
public javax.management.ObjectNamegetServerObjectName()

		final ObjectName	selfObjectName	= getObjectName();
		
		ObjectName	serverObjectName	= null;
		
		final String	serverName	= selfObjectName.getKeyProperty( J2EETypes.J2EE_SERVER );
		if ( serverName != null )
		{
			final String	props	= Util.makeRequiredProps( J2EETypes.J2EE_SERVER, serverName );
			final Set<AMX>	candidates	= getQueryMgr().queryPatternSet( selfObjectName.getDomain(), props );
			
			serverObjectName	= Util.getObjectName( GSetUtil.getSingleton( candidates ) );
		}
		return( serverObjectName );
	
protected java.lang.StringgetServerXType()

		String	type	= null;
		
		final String	serverName	= getServerName();
		if ( serverName != null )
		{
			final Map<String,ServerConfig>	m	=
			    getDomainRoot().getDomainConfig().getServerConfigMap();
			
			final ServerConfig	serverConfig	= m.get( serverName );
			type	= serverConfig.getJ2EEType();
		}
		
		return( type );
	
protected javax.management.j2ee.statistics.StatsgetStatsGeneric()

		Stats	stats	= null;
		
		if ( isstatisticProvider() )
		{
			final ObjectName	mon	= getMonitoringPeerObjectName();
			if ( mon != null )
			{
				final AMX	monStats = getProxyFactory().getProxy( mon, AMX.class);
				try
				{
					final Extra	extra	= Util.getExtra( monStats );
					stats	= (Stats)extra.getAttribute( "stats" );
					
				}
				catch( Exception e )
				{
					// OK, ignore
				}
			}
		}
		
		return( stats );
	
public java.lang.String[]getdeployedObjects()

		final String[]	names	= GSetUtil.toStringArray( getDeployedObjectsObjectNameSet() );
		return( names );
	
public final java.lang.StringgetobjectName()
JSR 77 impl

return
String representation of the ObjectName

		return( getObjectName().toString() );
	
public longgetstartTime()

		return( mStartTime );
	
protected voidhandleMissingOriginals(java.util.Set missingOriginals)

	    
	     
	    
	
	    missingOriginals.removeAll( IGNORE_MISSING );
	    
        super.handleMissingOriginals( missingOriginals );
	
public booleanisConfigProvider()

		return( ToConfigMap.keySet().contains( getSelfJ2EEType() ) );
	
public booleaniseventProvider()

		return( false );
	
public booleanisstateManageable()

		return( false );
	
public booleanisstatisticProvider()

		return( getMonitoringPeerObjectName() != null );
	
public booleanisstatisticsProvider()

		return( isstatisticProvider() );
	
public voidpreRegisterDone()

	    super.preRegisterDone();
		mStartTime	= System.currentTimeMillis();
	
protected javax.management.ObjectNamequeryConfigPeerFailed(java.util.Map propsMap)
The usual method of finding the config peer has failed. This is an opportunity to try again.

	    debug( "queryConfigPeerFailed: " + MapUtil.toString( propsMap ) );
		return null;
	
protected javax.management.ObjectNamequeryMonitoringPeerFailed(java.util.Map propsMap)
The usual method of finding the monitoring peer has failed. This is an opportunity to try again.

		return null;
	
protected javax.management.ObjectNamequeryProps(java.util.Map propsMap)

		ObjectName	objectName	= null;
		
		final String	props	= MapUtil.toString( propsMap, "," );
			
		final Set<ObjectName> candidates	=
		    getQueryMgr().queryPropsObjectNameSet( props );
		if ( candidates.size() == 1 )
		{
			objectName	= GSetUtil.getSingleton( candidates );
		}
		else if ( candidates.size() > 1 )
		{
			throw new RuntimeException(
				"Unexpectedly found too many candidates for query pattern " + quote( props ) +
				" found: " +  toString( candidates ) );
		}
		
		return( objectName );
	
protected final voidsetstartTime(long startTime)

	     mStartTime = startTime;