FileDocCategorySizeDatePackage
StatsFactory.javaAPI DocGlassfish v2 API9701Fri May 04 22:30:52 BST 2007com.sun.appserv.management.j2ee.statistics

StatsFactory

public final class StatsFactory extends Object
Factory to create Stats subclasses of any kind, based on supplied interface type and a Map or CompositeData containing the Statistics.

Fields Summary
Constructors Summary
private StatsFactory()

Methods Summary
public static java.util.MapcompositeDataToMap(javax.management.openmbean.CompositeData data)

		return( TypeCast.asMap( OpenMBeanUtil.compositeDataToMap( data ) ) );
	
public static Statscreate(java.lang.Class theInterface, javax.management.openmbean.CompositeData data)
Create a new Stats using the specified CompositeData

param
theInterface interface which the Stats should implement, must extend Stats

	    final Map<String,Statistic> statistics  = TypeCast.asMap( compositeDataToMap( data ) );
	    
		return( createStats( theInterface, statistics ) );
	
public static EJBStatscreateEJBStats(java.util.Map statistics)

		return( createStats( EJBStats.class, statistics ) );
	
public static EntityBeanStatscreateEntityBeanStats(java.util.Map statistics)

		return( createStats( EntityBeanStats.class, statistics ) );
	
public static JCAConnectionPoolStatscreateJCAConnectionPoolStats(java.util.Map statistics)

		return( createStats( JCAConnectionPoolStats.class, statistics ) );
	
public static JCAConnectionStatscreateJCAConnectionStats(java.util.Map statistics)

		return( createStats( JCAConnectionStats.class, statistics ) );
	
public static JCAStatscreateJCAStats(java.util.Map statistics)

		return( createStats( JCAStats.class, statistics ) );
	
public static JDBCConnectionPoolStatscreateJDBCConnectionPoolStats(java.util.Map statistics)

		return( createStats( JDBCConnectionPoolStats.class, statistics ) );
	
public static JDBCConnectionStatscreateJDBCConnectionStats(java.util.Map statistics)

		return( createStats( JDBCConnectionStats.class, statistics ) );
	
public static JDBCStatscreateJDBCStats(java.util.Map statistics)

		return( createStats( JDBCStats.class, statistics ) );
	
public static JMSConnectionStatscreateJMSConnectionStats(java.util.Map statistics)

		return( createStats( JMSConnectionStats.class, statistics ) );
	
public static JMSConsumerStatscreateJMSConsumerStats(java.util.Map statistics)

		return( createStats( JMSConsumerStats.class, statistics ) );
	
public static JMSEndpointStatscreateJMSEndpointStats(java.util.Map statistics)

		return( createStats( JMSEndpointStats.class, statistics ) );
	
public static JMSProducerStatscreateJMSProducerStats(java.util.Map statistics)

		return( createStats( JMSProducerStats.class, statistics ) );
	
public static JMSSessionStatscreateJMSSessionStats(java.util.Map statistics)

		return( createStats( JMSSessionStats.class, statistics ) );
	
public static JMSStatscreateJMSStats(java.util.Map statistics)

		return( createStats( JMSStats.class, statistics ) );
	
public static JTAStatscreateJTAStats(java.util.Map statistics)

		return( createStats( JTAStats.class, statistics ) );
	
public static JVMStatscreateJVMStats(java.util.Map statistics)

		return( createStats( JVMStats.class, statistics ) );
	
public static JavaMailStatscreateJavaMailStats(java.util.Map statistics)

	    // bizarre compiler error in JDK 1.5.0_06 forces us to inline the code here
	    final Class<JavaMailStats>  theInterface    = JavaMailStats.class;
		JavaMailStats	result	= null;
		
		// generate a proxy
		final MapGetterInvocationHandler	handler	=
		    new MapGetterInvocationHandler<Statistic>( statistics );
		final ClassLoader					classLoader	= theInterface.getClassLoader();
		
		final Class<JavaMailStats>[]    interfaces  = TypeCast.asArray( new Class[] { theInterface } );
		
		result	= (JavaMailStats)Proxy.newProxyInstance( classLoader, interfaces, handler);
		
		return result;
	
public static MessageDrivenBeanStatscreateMessageDrivenBeanStats(java.util.Map statistics)

		return( createStats( MessageDrivenBeanStats.class, statistics ) );
	
public static ServletStatscreateServletStats(java.util.Map statistics)

		return( createStats( ServletStats.class, statistics ) );
	
public static SessionBeanStatscreateSessionBeanStats(java.util.Map statistics)

		return( createStats( SessionBeanStats.class, statistics ) );
	
public static StatefulSessionBeanStatscreateStatefulSessionBeanStats(java.util.Map statistics)

		return( createStats( StatefulSessionBeanStats.class, statistics ) );
	
public static StatelessSessionBeanStatscreateStatelessSessionBeanStats(java.util.Map statistics)

		return( createStats( StatelessSessionBeanStats.class, statistics ) );
	
public static StatscreateStats(javax.management.openmbean.CompositeData data)
Create a Stats using Stats class found as data.getCompositeType().getTypeName(). If this interface is not available, a generic Stats interface will be used.

		final String	typeName		= data.getCompositeType().getTypeName();
		Class<? extends Stats>			theInterface	= null;
		
		try
		{
			theInterface	= TypeCast.asClass( ClassUtil.classForName( typeName ) );
		}
		catch( Exception e )
		{
			theInterface	= Stats.class;
		}
		
		return( create( theInterface, data ) );
	
public static TcreateStats(java.lang.Class theInterface, java.util.Map statistics)
Create a new Stats using the specified Map. The standard JSR 77 Statistic types are handled appropriately. Custom (non-standard) Stats may also be used; in this case a proxy is returned which implements the interface specified by theClass.

param
theInterface the Stats sub-interface which the resulting should implement
param
statistics a Map containing keys of type String and their Statistic values

		if ( ! Stats.class.isAssignableFrom( theInterface ) )
		{
			throw new IllegalArgumentException( theInterface.getName() );
		}

		// generate a proxy
		final MapGetterInvocationHandler	handler	=
		    new MapGetterInvocationHandler<Statistic>( statistics );
		final ClassLoader					classLoader	= theInterface.getClassLoader();
		
		final Class<T>[]    interfaces  = TypeCast.asArray( new Class[] { theInterface } );
		
		final Object proxy  = Proxy.newProxyInstance( classLoader, interfaces, handler);
		
		return theInterface.cast( proxy );
	
public static TcreateStats(java.lang.Class theInterface, Statistic[] statistics)
Calls createStats( theInterface, J2EEUtil.statisticsToMap( statistics ) )

	    final Map<String,Statistic>  statisticsMap  = J2EEUtil.statisticsToMap( statistics );
	    
		return( createStats( theInterface, statisticsMap ) );
	
public static URLStatscreateURLStats(java.util.Map statistics)

		return( createStats( URLStats.class, statistics ) );
	
private voidtest()

	    createStats( EJBStats.class, new java.util.HashMap<String,Statistic>() );