Fields Summary |
---|
private static final String | COUNT_STATISTIC |
private static final String | TIME_STATISTIC |
private static final String | RANGE_STATISTIC |
private static final String | BOUNDARY_STATISTIC |
private static final String | BOUNDED_RANGE_STATISTIC |
private static final String | STRING_STATISTIC |
private static final String | MAP_STATISTIC |
private static final String | NUMBER_STATISTIC |
private static final Class[] | KNOWN_STATISTICS |
private static final String | INTERNAL_STRING_STATISTIC_CLASSNAME |
Methods Summary |
---|
public static javax.management.j2ee.statistics.Statistic | create(java.lang.Class theInterface, javax.management.openmbean.CompositeData data)Create a new Statistic using the specified CompositeData
return( create( theInterface, OpenMBeanUtil.compositeDataToMap( data ) ) );
|
public static javax.management.j2ee.statistics.Statistic | create(javax.management.openmbean.CompositeData data)Create a new Statistic using the specified CompositeData.
The CompositeType of data must be an appropriate Statistic class.
final String typeName = data.getCompositeType().getTypeName();
Class<? extends Statistic> theInterface = null;
if ( typeName.equals( COUNT_STATISTIC ) )
{
theInterface = CountStatistic.class;
}
else if ( typeName.equals( TIME_STATISTIC ) )
{
theInterface = TimeStatistic.class;
}
else if ( typeName.equals( RANGE_STATISTIC ) )
{
theInterface = RangeStatistic.class;
}
else if ( typeName.equals( BOUNDARY_STATISTIC ) )
{
theInterface = BoundaryStatistic.class;
}
else if ( typeName.equals( BOUNDED_RANGE_STATISTIC ) )
{
theInterface = BoundedRangeStatistic.class;
}
else if ( typeName.equals( STRING_STATISTIC ) )
{
theInterface = StringStatistic.class;
}
else if ( typeName.equals( NUMBER_STATISTIC ) )
{
theInterface = NumberStatistic.class;
}
else if ( typeName.equals( MAP_STATISTIC ) )
{
theInterface = MapStatistic.class;
}
else
{
try
{
theInterface = TypeCast.asClass( ClassUtil.classForName( typeName ) );
}
catch( Exception e )
{
theInterface = Statistic.class;
}
}
return( create( theInterface, data ) );
|
public static javax.management.j2ee.statistics.Statistic | create(java.lang.Class theInterface, java.util.Map mappings)Create a new Statistic using the specified map. The standard JSR 77
types are handled appropriately. Custom (non-standard) Statistics
may also be used; in this case a proxy is returned which implements
the interface specified by theClass.
Statistic result = null;
// hopefully specific classes are faster than a proxy...
if ( theInterface == CountStatistic.class )
{
result = new CountStatisticImpl( mappings );
}
else if ( theInterface == RangeStatistic.class )
{
result = new RangeStatisticImpl( mappings );
}
else if ( theInterface == BoundaryStatistic.class )
{
result = new BoundaryStatisticImpl( mappings );
}
else if ( theInterface == BoundedRangeStatistic.class )
{
result = new BoundedRangeStatisticImpl( mappings );
}
else if ( theInterface == TimeStatistic.class )
{
result = new TimeStatisticImpl( mappings );
}
else if ( theInterface == StringStatistic.class )
{
result = new StringStatisticImpl( mappings );
}
else if ( theInterface == NumberStatistic.class )
{
result = new NumberStatisticImpl( mappings );
}
else if ( theInterface == MapStatistic.class )
{
result = new MapStatisticImpl( mappings );
}
else
{
throw new IllegalArgumentException(
"Unsupported Statistic interface: " + theInterface.getName() );
}
return( result );
|
public static java.lang.Class | getInterface(javax.management.j2ee.statistics.Statistic s)
final Class<? extends Statistic> implClass = s.getClass();
Class<? extends Statistic> theInterface = MapStatistic.class;
for( int i = 0; i < KNOWN_STATISTICS.length; ++i )
{
final Class<? extends Statistic> candidateInterface = KNOWN_STATISTICS[ i ];
if ( candidateInterface.isAssignableFrom( implClass ) )
{
theInterface = candidateInterface;
break;
}
}
if ( theInterface == MapStatistic.class && ! (s instanceof MapStatisticImpl) )
{
if ( s.getClass().getName().equals( INTERNAL_STRING_STATISTIC_CLASSNAME ) )
{
theInterface = StringStatistic.class;
}
else
{
throw new IllegalArgumentException( "Unknown statistic class: " + s.getClass().getName() );
}
}
return( theInterface );
|