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

TypeInfo

public final class TypeInfo extends Object
Information mapping a j2eeType to other necessary information.

Fields Summary
private final TypeData
mTypeData
private final Set
mChildJ2EETypes
private final Set
mNonChildJ2EETypes
private final Class
mInterface
private final Class
mImplClass
private static final String[]
IMPL_PACKAGES
private static final String
IMPL
private static final Map
INTERFACE_TO_IMPL
Constructors Summary
public TypeInfo(TypeData typeData)

		mTypeData			= typeData;
		mInterface			= deriveInterface( typeData.getJ2EEType() );
		mImplClass			= deriveImplClass( mInterface );
		
		mChildJ2EETypes		= new HashSet<String>();
		mNonChildJ2EETypes	= new HashSet<String>();
	
Methods Summary
public voidaddChildJ2EEType(java.lang.String j2eeType)

		assert( ! j2eeType.equals( getJ2EEType() ) );
		assert( ! mNonChildJ2EETypes.contains( j2eeType ) );
		
		mChildJ2EETypes.add( j2eeType );
	
public voidaddContaineeJ2EEType(java.lang.String j2eeType)

		assert( ! j2eeType.equals( getJ2EEType() ) );
		assert( ! mChildJ2EETypes.contains( j2eeType ) );
		
		mNonChildJ2EETypes.add( j2eeType );
	
private static java.lang.ClassderiveImplClass(java.lang.Class mbeanInterface)

        
		  
	    
		 
	
        final String fullyQualifiedName = mbeanInterface.getName();
		final String shortName	= getBaseName( fullyQualifiedName );
        
		Class	implClass	= null;
        
        // optimize for speed, calling locateImplClass() is very expensive
        // (4-5ms per class on a really fast machine)
        if ( fullyQualifiedName.startsWith( "com.sun.appserv.management.config" ) )
        {
            implClass   = locateImplClass( "com.sun.enterprise.management.config", shortName );
        }
        else if ( fullyQualifiedName.startsWith( "com.sun.appserv.management.monitor" ) )
        {
            implClass   = locateImplClass( "com.sun.enterprise.management.monitor", shortName );
        }
        else if ( fullyQualifiedName.startsWith( "com.sun.appserv.management.j2ee" ) )
        {
            implClass   = locateImplClass( "com.sun.enterprise.management.j2ee", shortName );
        }
        else if ( fullyQualifiedName.startsWith( "com.sun.appserv.management.base" ) )
        {
            implClass   = locateImplClass( "com.sun.enterprise.management.support", shortName );
        }
        else if ( INTERFACE_TO_IMPL.containsKey( fullyQualifiedName ) )
        {
            implClass   = ClassUtil.getClassFromName( INTERFACE_TO_IMPL.get( fullyQualifiedName ) );
        }
        else
        { 
            // as of 30 Nov 2006, there were only 5 exceptions, handled by INTERFACE_TO_IMPL map
           //System.out.println( "NEEDED: " + mbeanInterface );
        }
		
        if ( implClass == null )
        {
            for( int i = 0; i < IMPL_PACKAGES.length; ++i )
            {
                implClass	= locateImplClass( IMPL_PACKAGES[ i ], shortName );
                
                if ( implClass != null )
                {
                    break;
                }
            }
        }
		
		if ( implClass == null )
		{
			throw new ClassNotFoundException(
			    "Expected to find implementation class " + shortName + IMPL );
		}
		
		return( implClass );
	
private static java.lang.ClassderiveInterface(java.lang.String j2eeType)

		return( AllTypesMapper.getInstance().getInterfaceForType( j2eeType ) );
	
public booleanequals(java.lang.Object o)

		if ( o == this )
		{
			return( true );
		}
		else if ( ! (o instanceof TypeInfo ) )
		{
			return( false );
		}
		
		final TypeInfo	rhs	= (TypeInfo)o;
		boolean	equals	= false;
		if ( mTypeData.equals( rhs.mTypeData ) &&
			mInterface == rhs.mInterface &&
			mImplClass	== rhs.mImplClass &&
			mChildJ2EETypes.equals( rhs.mChildJ2EETypes ) &&
			getLegalParentJ2EETypes().equals( rhs.getLegalParentJ2EETypes() )
				)
		{
			equals	= true;
		}
		
		return( equals );
	
private static java.lang.StringgetBaseName(java.lang.String mbeanClassName)

		final String classname	= ClassUtil.stripPackageName( mbeanClassName );
		final String baseName	= classname;
		
		return( baseName );
	
public java.util.SetgetChildJ2EETypes()

		return( Collections.unmodifiableSet( mChildJ2EETypes ) );
	
public java.lang.StringgetContainedByJ2EEType()

		return( mTypeData.getContaineeByJ2EEType() );
	
public java.util.SetgetContaineeJ2EETypes()

		final Set<String>	all	=
		    GSetUtil.newSet( mChildJ2EETypes, mNonChildJ2EETypes );
		
		return( Collections.unmodifiableSet( all ) );
	
public java.lang.ClassgetImplClass()

		return( mImplClass );
	
public java.lang.ClassgetInterface()

		return( mInterface );
	
private static java.util.MapgetInterfaceToImplMap()
Individual cases.

        final Map<String,String>    m   = new HashMap<String,String>();
        
        m.put( "com.sun.appserv.management.DomainRoot", "com.sun.enterprise.management.DomainRootImpl" );
        m.put( "com.sun.appserv.management.ext.logging.Logging", "com.sun.enterprise.management.ext.logging.LoggingImpl" );
        m.put( "com.sun.appserv.management.deploy.DeploymentMgr", "com.sun.enterprise.management.deploy.DeploymentMgrImpl" );
        m.put( "com.sun.appserv.management.ext.lb.LoadBalancer", "com.sun.enterprise.management.ext.lb.LoadBalancerImpl" );
        m.put( "com.sun.appserv.management.ext.wsmgmt.WebServiceMgr", "com.sun.enterprise.management.ext.wsmgmt.WebServiceMgrImpl" );
        m.put( "com.sun.appserv.management.ext.update.UpdateStatus", "com.sun.enterprise.management.ext.update.UpdateStatusImpl" );
        
        return Collections.unmodifiableMap( m );
    
public java.lang.StringgetJ2EEType()

		return( mTypeData.getJ2EEType() );
	
public java.util.SetgetLegalParentJ2EETypes()

		return( mTypeData.getLegalParentJ2EETypes() );
	
public java.util.SetgetNonChildJ2EETypes()

		return( Collections.unmodifiableSet( mNonChildJ2EETypes ) );
	
public java.lang.StringgetParentJ2EEType()

		final Set<String>	legalParentJ2EETypes	= getLegalParentJ2EETypes();
		
		if ( legalParentJ2EETypes == null )
		{
			throw new IllegalArgumentException( "no legal parent types for: " + getJ2EEType() );
		}
		
		if ( legalParentJ2EETypes.size() != 1 )
		{
			throw new IllegalArgumentException( "expecting single parent for " +
			getJ2EEType() + ", have: " + toString( legalParentJ2EETypes ) );
		}
		
		return( GSetUtil.getSingleton( legalParentJ2EETypes ) );
	
public inthashCode()

 	    return ObjectUtil.hashCode(
 	            mTypeData, mInterface, mChildJ2EETypes, mNonChildJ2EETypes );
 	
public booleanisSubType()

		return( mTypeData.isSubType() );
	
private static java.lang.ClasslocateImplClass(java.lang.String packageName, java.lang.String baseName)

	
		  
	
		 	
		 	 
	
	    if ( ! packageName.startsWith( "com.sun.enterprise.management" ) )
	    {
	        throw new RuntimeException( "Illegal implementation package for AMX" );
	    }

		final String implClassname	= packageName + "." + baseName + IMPL;
		
		Class	implClass	= null;
		try
		{
			implClass	= ClassUtil.getClassFromName( implClassname );
		}
		catch( ClassNotFoundException e )
		{
			// ignore, we'll return null
		}
		
		return( implClass );
	
public java.lang.StringtoString()

		final StringBuffer	buf	= new StringBuffer();
		
		final String PR	= "\n  ";
		
		buf.append( getJ2EEType() + ": " );
		buf.append( PR + "parent type = " + SmartStringifier.toString( getLegalParentJ2EETypes() ) );
		buf.append( PR + "child types = " + SmartStringifier.toString( mChildJ2EETypes ) );
		buf.append( PR + "mbean = " + mInterface.getName() );
		buf.append( PR + "impl = " + mImplClass.getName() );
		buf.append( "\n" );
		
		return( buf.toString() );
	
private static java.lang.StringtoString(java.lang.Object o)

		return( SmartStringifier.toString( o ) );