FileDocCategorySizeDatePackage
TypesMapper.javaAPI DocGlassfish v2 API3800Fri May 04 22:30:30 BST 2007com.sun.appserv.management.base

TypesMapper

public class TypesMapper extends Object
Map all types from XTypes to their respective MBean interfaces.
see
AllTypesMapper
see
com.sun.appserv.management.j2ee.J2EETypesMapper

Fields Summary
private final Map
mMap
Constructors Summary
public TypesMapper(Class[] interfaces)

		mMap	= init( interfaces );
	
Methods Summary
public java.util.SetgetClasses()

	    final Set<Class>    classes = new HashSet<Class>();
	    classes.addAll( mMap.values() );
	    return Collections.unmodifiableSet( classes );
	
public java.lang.ClassgetInterfaceForType(java.lang.String type)
Return the Class associated with a given type.

		final Class theClass	= mMap.get( type );
		
		return( theClass );
	
public java.util.SetgetJ2EETypes()

	    return Collections.unmodifiableSet( mMap.keySet() );
	
private java.util.Mapinit(java.lang.Class[] interfaces)
Map all types to interfaces.

		final Map<String,Class>	m	= new HashMap<String,Class>();

		for( int i = 0; i < interfaces.length; ++i )
		{
			final Class	theInterface	= interfaces[ i ];
			
			try
			{
				final Field	field	= theInterface.getField( "J2EE_TYPE" );
				final String value	= (String)field.get( theInterface );
				if ( m.containsKey( value ) )
				{
					final String	msg	=
						"TypesMapper: key already present: " +
						value + " for " + theInterface.getName();
					
					assert(  false ): msg;
					throw new RuntimeException( msg );
				}
				m.put( value, theInterface );
			}
			catch( Exception e )
			{
				e.printStackTrace();
				assert( false );
				throw new IllegalArgumentException( theInterface.getName() );
			}
		}
		
		return( m );