use of javax.management.openmbean.TabularDataSupport in project jdk8u_jdk by JetBrains.
the class TabularDataOrderTest method makeTable.
private static TabularData makeTable() throws OpenDataException {
TabularData td = new TabularDataSupport(tt);
for (Map.Entry<String, Integer> entry : stringToValue.entrySet()) {
CompositeData cd = new CompositeDataSupport(ct, new String[] { "name", "int" }, new Object[] { entry.getKey(), entry.getValue() });
td.put(cd);
}
return td;
}
use of javax.management.openmbean.TabularDataSupport in project tesb-studio-se by Talend.
the class JMXUtil method installBundle.
/**
* for Job installation
*
* @param bundle
* @return
* @throws ReflectionException
*/
public static long[] installBundle(File bundle) throws Exception {
try {
// MBeanServerConnection mbsc = createJMXconnection();
String KARAF_BUNDLE_MBEAN = "org.apache.karaf:type=bundle,name=trun";
ObjectName objectBundle = new ObjectName(KARAF_BUNDLE_MBEAN);
Set<Object> existsBundles = ((TabularDataSupport) mbsc.getAttribute(objectBundle, "Bundles")).keySet();
Object bundleId = mbsc.invoke(objectBundle, "install", new Object[] { "file:" + bundle.getAbsolutePath() }, new String[] { String.class.getName() });
Set<Object> newBundles = ((TabularDataSupport) mbsc.getAttribute(objectBundle, "Bundles")).keySet();
newBundles.removeAll(existsBundles);
Object[] bundleIds = newBundles.toArray();
long[] newIds = new long[bundleIds.length];
for (int i = 0; i < bundleIds.length; i++) {
String id = bundleIds[i].toString();
newIds[i] = Long.parseLong(id.substring(1, id.length() - 1));
mbsc.invoke(objectBundle, "start", new Object[] { String.valueOf(newIds[i]) }, new String[] { String.class.getName() });
}
// bundleId instanceof Long ? (long) bundleId : 0;
return newIds;
} finally {
// closeJMXConnection();
}
}
use of javax.management.openmbean.TabularDataSupport in project aries by apache.
the class ServiceData method toCompositeData.
public CompositeData toCompositeData(Collection<String> itemNames) {
Map<String, Object> items = new HashMap<String, Object>();
items.put(IDENTIFIER, this.serviceId);
if (itemNames.contains(BUNDLE_IDENTIFIER))
items.put(BUNDLE_IDENTIFIER, this.bundleId);
if (itemNames.contains(OBJECT_CLASS))
items.put(OBJECT_CLASS, this.serviceInterfaces);
TabularData propertiesTable = new TabularDataSupport(JmxConstants.PROPERTIES_TYPE);
for (PropertyData<? extends Object> propertyData : this.properties) {
propertiesTable.put(propertyData.toCompositeData());
}
items.put(PROPERTIES, propertiesTable);
if (itemNames.contains(USING_BUNDLES))
items.put(USING_BUNDLES, toLong(this.usingBundles));
String[] allItemNames = SERVICE_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(SERVICE_TYPE, allItemNames, itemValues);
} catch (OpenDataException e) {
throw new IllegalStateException("Failed to create CompositeData for ServiceReference with " + Constants.SERVICE_ID + " [" + this.serviceId + "]", e);
}
}
use of javax.management.openmbean.TabularDataSupport in project aries by apache.
the class BundleState method listBundles.
private TabularData listBundles(Collection<String> items) throws IOException {
Bundle[] containerBundles = bundleContext.getBundles();
List<BundleData> bundleDatas = new ArrayList<BundleData>();
if (containerBundles != null) {
for (Bundle containerBundle : containerBundles) {
bundleDatas.add(new BundleData(bundleContext, containerBundle, packageAdmin, startLevel));
}
}
TabularData bundleTable = new TabularDataSupport(BUNDLES_TYPE);
for (BundleData bundleData : bundleDatas) {
bundleTable.put(bundleData.toCompositeData(items));
}
return bundleTable;
}
use of javax.management.openmbean.TabularDataSupport in project aries by apache.
the class BundleState method getHeaders.
private TabularData getHeaders(Dictionary<String, String> bundleHeaders) {
List<Header> headers = new ArrayList<Header>();
Enumeration<String> keys = bundleHeaders.keys();
while (keys.hasMoreElements()) {
String key = keys.nextElement();
headers.add(new Header(key, bundleHeaders.get(key)));
}
TabularData headerTable = new TabularDataSupport(HEADERS_TYPE);
for (Header header : headers) {
headerTable.put(header.toCompositeData());
}
return headerTable;
}
Aggregations