use of javax.management.openmbean.OpenDataException in project aries by apache.
the class BundleWiringData method getCapabilitiesCompositeData.
public static CompositeData[] getCapabilitiesCompositeData(List<BundleCapability> bundleCapabilities) {
try {
CompositeData[] data = new CompositeData[bundleCapabilities.size()];
for (int i = 0; i < bundleCapabilities.size(); i++) {
BundleCapability requirement = bundleCapabilities.get(i);
CompositeData cd = BundleWiringData.getCapReqCompositeData(BundleWiringStateMBean.BUNDLE_CAPABILITY_TYPE, requirement.getNamespace(), requirement.getAttributes().entrySet(), requirement.getDirectives().entrySet());
data[i] = cd;
}
return data;
} catch (OpenDataException e) {
throw new IllegalStateException("Can't create CompositeData", e);
}
}
use of javax.management.openmbean.OpenDataException in project aries by apache.
the class PropertyData method toCompositeData.
/**
* Returns CompositeData representing a Property typed by {@link JmxConstants#PROPERTY_TYPE}.
* @return
*/
public CompositeData toCompositeData() {
CompositeData result = null;
Map<String, Object> items = new HashMap<String, Object>();
items.put(KEY, this.key);
items.put(VALUE, this.encodedValue);
items.put(TYPE, this.encodedType);
try {
result = new CompositeDataSupport(PROPERTY_TYPE, items);
} catch (OpenDataException e) {
throw new IllegalStateException("Failed to create CompositeData for Property [" + this.key + ":" + this.value + "]", e);
}
return result;
}
use of javax.management.openmbean.OpenDataException in project aries by apache.
the class ServiceEventData method toCompositeData.
/**
* Returns CompositeData representing a ServiceEvent typed by {@link ServiceStateMBean#SERVICE_EVENT_TYPE}.
* @return
*/
public CompositeData toCompositeData() {
CompositeData result = null;
Map<String, Object> items = new HashMap<String, Object>();
items.put(IDENTIFIER, this.serviceId);
items.put(OBJECT_CLASS, this.serviceInterfaces);
items.put(BUNDLE_IDENTIFIER, this.bundleId);
items.put(BUNDLE_LOCATION, this.bundleLocation);
items.put(BUNDLE_SYMBOLIC_NAME, this.bundleSymbolicName);
items.put(EVENT, this.eventType);
try {
result = new CompositeDataSupport(SERVICE_EVENT_TYPE, items);
} catch (OpenDataException e) {
throw new IllegalStateException("Failed to create CompositeData for ServiceEvent for Service [" + this.serviceId + "]", e);
}
return result;
}
use of javax.management.openmbean.OpenDataException 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);
}
}
use of javax.management.openmbean.OpenDataException in project deltaspike by apache.
the class DynamicMBeanWrapper method toTabularData.
private TabularData toTabularData(final String typeName, final String description, final Table table) {
final OpenType<?>[] types = new OpenType<?>[table.getColumnNames().size()];
for (int i = 0; i < types.length; i++) {
types[i] = SimpleType.STRING;
}
try {
final String[] keys = table.getColumnNames().toArray(new String[table.getColumnNames().size()]);
final CompositeType ct = new CompositeType(typeName, description, keys, keys, types);
final TabularType type = new TabularType(typeName, description, ct, keys);
final TabularDataSupport data = new TabularDataSupport(type);
for (final Collection<String> line : table.getLines()) {
data.put(new CompositeDataSupport(ct, keys, line.toArray(new Object[line.size()])));
}
return data;
} catch (final OpenDataException e) {
throw new IllegalArgumentException(e);
}
}
Aggregations