FileDocCategorySizeDatePackage
LoaderOfOld77.javaAPI DocGlassfish v2 API10983Fri May 04 22:23:42 BST 2007com.sun.enterprise.management.support

LoaderOfOld77

public final class LoaderOfOld77 extends LoaderOfOld
Loads MBeans.

Fields Summary
private final String
mAMXJMXDomain
private final boolean
mIsDAS
Whether this process is the DAS.
public static final Set
SYNC_TYPES
private static final String[]
CONTAINMENT_KEYS_77
Containment keys specified by JSR 77 ObjectNames which we must preserve from old to new ObjectName
Constructors Summary
LoaderOfOld77(Loader loader)

		super( loader );
		
		mAMXJMXDomain	= loader.getAMXJMXDomainName();
		
		final SystemInfo	systemInfo	= loader.getDomainRoot().getSystemInfo();
		mIsDAS	= systemInfo.supportsFeature( SystemInfo.RUNNING_IN_DAS_FEATURE );
	
Methods Summary
public java.util.SetfindAllOldCandidates()

		final ObjectName	pattern	= JMXUtil.newObjectName( "com.sun.appserv", JMXUtil.WILD_ALL );
		final Set<ObjectName>	all	= JMXUtil.queryNames( getMBeanServer(), pattern, null );
		
		final Set<ObjectName>	results	= new HashSet<ObjectName>();
		for( final ObjectName objectName : all )
		{
			if ( shouldSync( objectName ) )
			{
				results.add( objectName );
			}
		}
		
		return( results );
	
protected java.util.SetgetIgnoreTypes()

		return( Collections.EMPTY_SET );
	
protected java.lang.ClassgetImplClass(javax.management.ObjectName newObjectName, javax.management.ObjectName oldObjectName)

		Class	implClass	= super.getImplClass( newObjectName, oldObjectName );
		
		final boolean	isJ2EEServer	=
			Util.getJ2EEType( newObjectName ).equals( J2EETypes.J2EE_SERVER );
		if ( isJ2EEServer )
		{
			// it's a J2EEServer; determine if it's running in the DAS itself
			// in which case we need a different impl
			final String	serverName	= Util.getName( newObjectName );
			final boolean	isAdminServer	= serverRunningInDAS( serverName );
			if ( isAdminServer )
			{
			
				try
				{
					implClass = 
					ClassUtil.getClassFromName( "com.sun.enterprise.management.j2ee.DASJ2EEServerImpl");
				}
				catch (ClassNotFoundException cnfe)
				{
					try
					{
					implClass	= ClassUtil.getClassFromName(
						"com.sun.enterprise.management.j2ee.J2EEServerImpl" );
					}
					catch( ClassNotFoundException e )
					{
						throw new RuntimeException( e );
					}
				}
			}
			getLogger().fine(
			    "LoaderOfOld77.getImplClass: Using J2EEServer impl of class: " +
			    implClass.getName() +
				" for server " + serverName );
			
		}
		
		return( implClass );
	
protected java.util.SetgetNeedsSupport()

	
	
	
		 
	
	
		return( Collections.EMPTY_SET );
	
private java.util.MapgetOld77Props(javax.management.ObjectName oldObjectName)

	
		 
	  	 
	
		final Map<String,String>	m	= new HashMap<String,String>();
		
		for( int i = 0; i < CONTAINMENT_KEYS_77.length; ++i )
		{
			final String	key	= CONTAINMENT_KEYS_77[ i ];
			
			final String	value	= oldObjectName.getKeyProperty( key );
			if ( value != null )
			{
				m.put( key, value );
			}
		}
		
		return( m );
	
private booleanhasValidWebModuleName(javax.management.ObjectName objectName)

		boolean	isValid	= true;
		
		final String	j2eeType	= Util.getJ2EEType( objectName );
			
		// Our WebModule names are of the form //<virtual-server-name>/<web-module-name>.
		// some of them are "defective" and lack a <web-module-name> part
		// no empty web-module names allowed (bug in underlying MBean naming), see bug #6180648
		if (  j2eeType.equals( J2EETypes.SERVLET ) )
		{
            final String	compositeName	= objectName.getKeyProperty( J2EETypes.WEB_MODULE );
            isValid	= isValidCompositeWebModuleName( compositeName );
        }
        else if (j2eeType.equals( J2EETypes.WEB_SERVICE_ENDPOINT))
        {
            // check if this web service endpoint belong to EJB module
            final String ejbModName = objectName.getKeyProperty( J2EETypes.EJB_MODULE);
            if (ejbModName != null)
            {
                isValid = true;
            }
            else
            {
                final String	compositeName	= objectName.getKeyProperty( J2EETypes.WEB_MODULE );
                isValid	= isValidCompositeWebModuleName( compositeName );
            }
		}
		else if ( j2eeType.equals( J2EETypes.WEB_MODULE ) )
		{
			final String	compositeName	= objectName.getKeyProperty( AMX.NAME_KEY );
			isValid	= isValidCompositeWebModuleName( compositeName );
		}
		
		return( isValid  );
	
private booleanisOld77ObjectName(javax.management.ObjectName objectName)

		final String	j2eeType	= objectName.getKeyProperty( "j2eeType" );
		
	    boolean ret = ( j2eeType != null &&
			! objectName.getDomain().equals( mAMXJMXDomain ) );

            return ret;
	
public booleanisOldMBean(javax.management.ObjectName objectName)

		boolean	shouldSync	= isOld77ObjectName( objectName );
		
		if ( shouldSync )
		{
			final String	j2eeType	= Util.getJ2EEType( objectName );
			shouldSync	= SYNC_TYPES.contains( j2eeType );
		
			if ( shouldSync && ! hasValidWebModuleName( objectName ) )
			{
			    // the MBean will load just fine, but other downstream problems will occur
				shouldSync	= false;
		
				getLogger().warning(
					"Not registering AMX MBean against old MBean " + StringUtil.quote( objectName ) +
					" due to malformed composite WebModule name." );
			}
		}
		
		return( shouldSync );
	
private booleanisValidCompositeWebModuleName(java.lang.String compositeName)

	    boolean valid   = false;
	    
	    try
	    {
		    final String	webModuleName	= WebModuleSupport.extractWebModuleName( compositeName );
		
		    // An empty name is valid, too, if it's the default web module.
		    valid   = true;
		}
		catch( Exception e )
		{
		}
		return valid;
	
protected javax.management.ObjectNameoldToNewObjectName(javax.management.ObjectName oldObjectName)
JSR77 has some inconsistent approaches to its containment hierarchy; it omits implied parents, which causes headaches for generic navigation. This routine accounts for those issues.

		final String		j2eeType	= Util.getJ2EEType( oldObjectName );
		final String		j2eeDomainName	= getAMXJMXDomainName();
		
		final Map<String,String>	propsMap	= getOld77Props( oldObjectName );
		if ( j2eeType.equals( J2EETypes.J2EE_DOMAIN ) )
		{
			// name must be changed to match domain
			propsMap.put( AMX.NAME_KEY, j2eeDomainName );
		}
		else if ( j2eeType.equals( J2EETypes.J2EE_SERVER ) )
		{
		}
		else
		{
			// everything else has a parent
		}

		
		final String	props	= JMXUtil.mapToProps( propsMap );
		
		final ObjectName	newName	= Util.newObjectName( j2eeDomainName, props );
		
		return( newName );
	
private final booleanserverRunningInDAS(java.lang.String serverName)

		boolean runningInDAS	= false;
		
		if ( mIsDAS )
		{
			// Simplifying assumption: only one server runs in DAS
			runningInDAS	= true;
		}
		
		return( runningInDAS );