Search in sources :

Example 71 with TabularDataSupport

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

the class BundleWiringState method getRevisionsWiringClosure.

/* (non-Javadoc)
     * @see org.osgi.jmx.framework.BundleRevisionsStateMBean#getWiringClosure(long, java.lang.String)
     */
public TabularData getRevisionsWiringClosure(long rootBundleId, String namespace) throws IOException {
    Bundle bundle = FrameworkUtils.resolveBundle(bundleContext, rootBundleId);
    BundleRevisions revisions = bundle.adapt(BundleRevisions.class);
    Map<BundleRevision, Integer> revisionIDMap = new HashMap<BundleRevision, Integer>();
    for (BundleRevision revision : revisions.getRevisions()) {
        populateTransitiveRevisions(namespace, revision, revisionIDMap);
    }
    // Set the root current revision ID to 0,
    // TODO check if there is already a revision with ID 0 and if so swap them. Quite a small chance that this will be needed
    BundleRevision revision = bundle.adapt(BundleRevision.class);
    revisionIDMap.put(revision, 0);
    TabularData td = new TabularDataSupport(BundleWiringStateMBean.BUNDLES_WIRING_TYPE);
    for (Map.Entry<BundleRevision, Integer> entry : revisionIDMap.entrySet()) {
        td.put(getRevisionWiring(entry.getKey(), entry.getValue(), namespace, revisionIDMap));
    }
    return td;
}
Also used : HashMap(java.util.HashMap) Bundle(org.osgi.framework.Bundle) TabularDataSupport(javax.management.openmbean.TabularDataSupport) BundleRevision(org.osgi.framework.wiring.BundleRevision) HashMap(java.util.HashMap) Map(java.util.Map) BundleRevisions(org.osgi.framework.wiring.BundleRevisions) TabularData(javax.management.openmbean.TabularData)

Example 72 with TabularDataSupport

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

the class BundleWiringState method getRevisionsDeclaredRequirements.

/* (non-Javadoc)
     * @see org.osgi.jmx.framework.BundleRevisionsStateMBean#getRevisionsDeclaredRequirements(long, java.lang.String, boolean)
     */
public TabularData getRevisionsDeclaredRequirements(long bundleId, String namespace) throws IOException {
    Bundle bundle = FrameworkUtils.resolveBundle(bundleContext, bundleId);
    BundleRevisions revisions = bundle.adapt(BundleRevisions.class);
    TabularData td = new TabularDataSupport(BundleWiringStateMBean.REVISIONS_REQUIREMENTS_TYPE);
    for (BundleRevision revision : revisions.getRevisions()) {
        td.put(BundleWiringData.getRevisionRequirements(System.identityHashCode(revision), revision.getDeclaredRequirements(namespace)));
    }
    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)

Example 73 with TabularDataSupport

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

the class BundleWiringState method getCurrentWiringClosure.

/* (non-Javadoc)
     * @see org.osgi.jmx.framework.BundleRevisionsStateMBean#getCurrentWiringClosure(long)
     */
public TabularData getCurrentWiringClosure(long rootBundleId, String namespace) throws IOException {
    Map<BundleRevision, Integer> revisionIDMap = getCurrentRevisionTransitiveRevisionsClosure(rootBundleId, namespace);
    TabularData td = new TabularDataSupport(BundleWiringStateMBean.BUNDLES_WIRING_TYPE);
    for (Map.Entry<BundleRevision, Integer> entry : revisionIDMap.entrySet()) {
        td.put(getRevisionWiring(entry.getKey(), entry.getValue(), namespace, revisionIDMap));
    }
    return td;
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) BundleRevision(org.osgi.framework.wiring.BundleRevision) HashMap(java.util.HashMap) Map(java.util.Map) TabularData(javax.management.openmbean.TabularData)

Example 74 with TabularDataSupport

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

the class ConfigurationAdmin method getPropertiesForLocation.

/**
     * @see org.osgi.jmx.service.cm.ConfigurationAdminMBean#getPropertiesForLocation(java.lang.String, java.lang.String)
     */
public TabularData getPropertiesForLocation(String pid, String location) throws IOException {
    if (pid == null || pid.length() < 1) {
        throw new IOException("Argument pid cannot be null or empty");
    }
    TabularData propertiesTable = null;
    Configuration config = configurationAdmin.getConfiguration(pid, location);
    Dictionary<String, Object> properties = config.getProperties();
    if (properties != null) {
        propertiesTable = new TabularDataSupport(PROPERTIES_TYPE);
        Enumeration<String> keys = properties.keys();
        while (keys.hasMoreElements()) {
            String key = keys.nextElement();
            propertiesTable.put(PropertyData.newInstance(key, properties.get(key)).toCompositeData());
        }
    }
    return propertiesTable;
}
Also used : Configuration(org.osgi.service.cm.Configuration) TabularDataSupport(javax.management.openmbean.TabularDataSupport) IOException(java.io.IOException) TabularData(javax.management.openmbean.TabularData)

Example 75 with TabularDataSupport

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

the class BundleData method toCompositeData.

public CompositeData toCompositeData(Collection<String> itemNames) {
    Map<String, Object> items = new HashMap<String, Object>();
    items.put(IDENTIFIER, this.identifier);
    if (itemNames.contains(EXPORTED_PACKAGES))
        items.put(EXPORTED_PACKAGES, this.exportedPackages);
    if (itemNames.contains(FRAGMENT))
        items.put(FRAGMENT, this.fragment);
    if (itemNames.contains(FRAGMENTS))
        items.put(FRAGMENTS, toLong(this.fragments));
    if (itemNames.contains(HOSTS))
        items.put(HOSTS, toLong(this.hosts));
    if (itemNames.contains(IMPORTED_PACKAGES))
        items.put(IMPORTED_PACKAGES, this.importedPackages);
    if (itemNames.contains(LAST_MODIFIED))
        items.put(LAST_MODIFIED, this.lastModified);
    if (itemNames.contains(LOCATION))
        items.put(LOCATION, this.location);
    if (itemNames.contains(PERSISTENTLY_STARTED))
        items.put(PERSISTENTLY_STARTED, this.persistentlyStarted);
    if (itemNames.contains(REGISTERED_SERVICES))
        items.put(REGISTERED_SERVICES, toLong(this.registeredServices));
    if (itemNames.contains(REMOVAL_PENDING))
        items.put(REMOVAL_PENDING, this.removalPending);
    if (itemNames.contains(REQUIRED))
        items.put(REQUIRED, this.required);
    if (itemNames.contains(REQUIRED_BUNDLES))
        items.put(REQUIRED_BUNDLES, toLong(this.requiredBundles));
    if (itemNames.contains(REQUIRING_BUNDLES))
        items.put(REQUIRING_BUNDLES, toLong(this.requiringBundles));
    if (itemNames.contains(SERVICES_IN_USE))
        items.put(SERVICES_IN_USE, toLong(this.servicesInUse));
    if (itemNames.contains(START_LEVEL))
        items.put(START_LEVEL, this.bundleStartLevel);
    if (itemNames.contains(STATE))
        items.put(STATE, this.state);
    if (itemNames.contains(SYMBOLIC_NAME))
        items.put(SYMBOLIC_NAME, this.symbolicName);
    if (itemNames.contains(VERSION))
        items.put(VERSION, this.version);
    if (itemNames.contains(HEADERS)) {
        TabularData headerTable = new TabularDataSupport(HEADERS_TYPE);
        for (Header header : this.headers) {
            headerTable.put(header.toCompositeData());
        }
        items.put(HEADERS, headerTable);
    }
    String[] allItemNames = BUNDLE_TYPE.keySet().toArray(new String[] {});
    Object[] itemValues = new Object[allItemNames.length];
    for (int i = 0; i < allItemNames.length; i++) {
        itemValues[i] = items.get(allItemNames[i]);
    }
    try {
        return new CompositeDataSupport(BUNDLE_TYPE, allItemNames, itemValues);
    } catch (OpenDataException e) {
        throw new IllegalStateException("Failed to create CompositeData for BundleData [" + this.identifier + "]", e);
    }
}
Also used : HashMap(java.util.HashMap) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) TabularData(javax.management.openmbean.TabularData) OpenDataException(javax.management.openmbean.OpenDataException) TabularDataSupport(javax.management.openmbean.TabularDataSupport)

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