Search in sources :

Example 1 with ManagedAttribute

use of javax.management.ManagedAttribute in project tomee by apache.

the class SimpleRouter method getActiveRoutes.

@ManagedAttribute
public TabularData getActiveRoutes() {
    if (routes.length == 0) {
        return null;
    }
    final OpenType<?>[] types = new OpenType<?>[routes.length];
    final String[] keys = new String[types.length];
    final String[] values = new String[types.length];
    for (int i = 0; i < types.length; i++) {
        types[i] = SimpleType.STRING;
        keys[i] = routes[i].getOrigin().substring(prefix.length());
        values[i] = routes[i].getRawDestination().substring(prefix.length());
    }
    try {
        final CompositeType ct = new CompositeType("routes", "routes", keys, keys, types);
        final TabularType type = new TabularType("router", "routes", ct, keys);
        final TabularDataSupport data = new TabularDataSupport(type);
        final CompositeData line = new CompositeDataSupport(ct, keys, values);
        data.put(line);
        return data;
    } catch (final OpenDataException e) {
        return null;
    }
}
Also used : OpenType(javax.management.openmbean.OpenType) OpenDataException(javax.management.openmbean.OpenDataException) TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularType(javax.management.openmbean.TabularType) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) CompositeType(javax.management.openmbean.CompositeType) ManagedAttribute(javax.management.ManagedAttribute)

Aggregations

ManagedAttribute (javax.management.ManagedAttribute)1 CompositeData (javax.management.openmbean.CompositeData)1 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)1 CompositeType (javax.management.openmbean.CompositeType)1 OpenDataException (javax.management.openmbean.OpenDataException)1 OpenType (javax.management.openmbean.OpenType)1 TabularDataSupport (javax.management.openmbean.TabularDataSupport)1 TabularType (javax.management.openmbean.TabularType)1