Search in sources :

Example 66 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project aries by apache.

the class BundleWiringData method getCapReqCompositeData.

private static CompositeData getCapReqCompositeData(CompositeType type, String namespace, Set<Map.Entry<String, Object>> attributeSet, Set<Map.Entry<String, String>> directiveSet) throws OpenDataException {
    Map<String, Object> reqItems = new HashMap<String, Object>();
    TabularData attributes = new TabularDataSupport(BundleWiringStateMBean.ATTRIBUTES_TYPE);
    for (Map.Entry<String, Object> entry : attributeSet) {
        PropertyData<?> pd = PropertyData.newInstance(entry.getKey(), entry.getValue());
        attributes.put(pd.toCompositeData());
    }
    reqItems.put(BundleWiringStateMBean.ATTRIBUTES, attributes);
    TabularData directives = new TabularDataSupport(BundleWiringStateMBean.DIRECTIVES_TYPE);
    for (Map.Entry<String, String> entry : directiveSet) {
        CompositeData directive = new CompositeDataSupport(BundleWiringStateMBean.DIRECTIVE_TYPE, new String[] { BundleWiringStateMBean.KEY, BundleWiringStateMBean.VALUE }, new Object[] { entry.getKey(), entry.getValue() });
        directives.put(directive);
    }
    reqItems.put(BundleWiringStateMBean.DIRECTIVES, directives);
    reqItems.put(BundleWiringStateMBean.NAMESPACE, namespace);
    CompositeData req = new CompositeDataSupport(type, reqItems);
    return req;
}
Also used : HashMap(java.util.HashMap) TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) HashMap(java.util.HashMap) Map(java.util.Map) TabularData(javax.management.openmbean.TabularData)

Example 67 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project aries by apache.

the class ServiceState method getProperties.

/**
     * @see org.osgi.jmx.framework.ServiceStateMBean#getProperties(long)
     */
public TabularData getProperties(long serviceId) throws IOException {
    ServiceReference reference = resolveService(bundleContext, serviceId);
    TabularData propertiesTable = new TabularDataSupport(PROPERTIES_TYPE);
    for (String propertyKey : reference.getPropertyKeys()) {
        propertiesTable.put(PropertyData.newInstance(propertyKey, reference.getProperty(propertyKey)).toCompositeData());
    }
    return propertiesTable;
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) ServiceReference(org.osgi.framework.ServiceReference) TabularData(javax.management.openmbean.TabularData)

Example 68 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project aries by apache.

the class ServiceState method listServices.

private TabularData listServices(String clazz, String filter, Collection<String> serviceTypeItems) throws IOException {
    TabularData servicesTable = new TabularDataSupport(SERVICES_TYPE);
    ServiceReference[] allServiceReferences = null;
    try {
        allServiceReferences = bundleContext.getAllServiceReferences(clazz, filter);
    } catch (InvalidSyntaxException e) {
        throw new IllegalStateException("Failed to retrieve all service references", e);
    }
    if (allServiceReferences != null) {
        for (ServiceReference reference : allServiceReferences) {
            servicesTable.put(new ServiceData(reference).toCompositeData(serviceTypeItems));
        }
    }
    return servicesTable;
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) ServiceData(org.apache.aries.jmx.codec.ServiceData) TabularData(javax.management.openmbean.TabularData) ServiceReference(org.osgi.framework.ServiceReference)

Example 69 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project aries by apache.

the class UserAdmin method getProperties.

/**
     * @see org.osgi.jmx.service.useradmin.UserAdminMBean#getProperties(java.lang.String)
     */
public TabularData getProperties(String rolename) throws IOException {
    if (rolename == null) {
        throw new IOException("Role name cannot be null");
    }
    Role role = userAdmin.getRole(rolename);
    if (role == null) {
        return null;
    }
    Dictionary<String, Object> properties = role.getProperties();
    if (properties == null) {
        return null;
    }
    TabularData data = new TabularDataSupport(JmxConstants.PROPERTIES_TYPE);
    for (Enumeration<String> keys = properties.keys(); keys.hasMoreElements(); ) {
        String key = keys.nextElement();
        data.put(PropertyData.newInstance(key, properties.get(key)).toCompositeData());
    }
    return data;
}
Also used : Role(org.osgi.service.useradmin.Role) TabularDataSupport(javax.management.openmbean.TabularDataSupport) IOException(java.io.IOException) TabularData(javax.management.openmbean.TabularData)

Example 70 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project aries by apache.

the class BundleWiringState method getRevisionsWiring.

/* (non-Javadoc)
     * @see org.osgi.jmx.framework.BundleRevisionsStateMBean#getRevisionsWiring(long, java.lang.String)
     */
public TabularData getRevisionsWiring(long bundleId, String namespace) throws IOException {
    Bundle bundle = FrameworkUtils.resolveBundle(bundleContext, bundleId);
    BundleRevisions revisions = bundle.adapt(BundleRevisions.class);
    TabularData td = new TabularDataSupport(BundleWiringStateMBean.BUNDLES_WIRING_TYPE);
    for (BundleRevision revision : revisions.getRevisions()) {
        Map<BundleRevision, Integer> revisionIDMap = getRevisionTransitiveClosure(revision, namespace);
        td.put(getRevisionWiring(revision, System.identityHashCode(revision), namespace, revisionIDMap));
    }
    return td;
}
Also used : Bundle(org.osgi.framework.Bundle) TabularDataSupport(javax.management.openmbean.TabularDataSupport) BundleRevision(org.osgi.framework.wiring.BundleRevision) BundleRevisions(org.osgi.framework.wiring.BundleRevisions) TabularData(javax.management.openmbean.TabularData)

Aggregations

TabularDataSupport (javax.management.openmbean.TabularDataSupport)103 TabularData (javax.management.openmbean.TabularData)67 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)60 CompositeData (javax.management.openmbean.CompositeData)51 CompositeType (javax.management.openmbean.CompositeType)50 TabularType (javax.management.openmbean.TabularType)36 Map (java.util.Map)27 OpenDataException (javax.management.openmbean.OpenDataException)24 HashMap (java.util.HashMap)11 Bundle (org.osgi.framework.Bundle)10 IOException (java.io.IOException)7 ObjectName (javax.management.ObjectName)7 OpenType (javax.management.openmbean.OpenType)7 EndpointUtilizationStatistics (org.apache.camel.spi.EndpointUtilizationStatistics)7 Test (org.junit.Test)6 ConcurrentMap (java.util.concurrent.ConcurrentMap)5 MBeanException (javax.management.MBeanException)5 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)5 ArrayList (java.util.ArrayList)4 Dictionary (java.util.Dictionary)4