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;
}
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;
}
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;
}
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;
}
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);
}
}
Aggregations