ClusterNodeInfoTabular.java
1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.granite.jmx.annotation.OpenTypeUtils
* com.adobe.granite.jmx.annotation.TabularTypeInfo
*/
package com.day.crx.sling.server.jmx;
import com.adobe.granite.jmx.annotation.OpenTypeUtils;
import com.adobe.granite.jmx.annotation.TabularTypeInfo;
import com.day.crx.core.cluster.ClusterNodeInfo;
import java.util.ArrayList;
import java.util.List;
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.CompositeDataSupport;
import javax.management.openmbean.CompositeType;
import javax.management.openmbean.OpenDataException;
import javax.management.openmbean.TabularData;
import javax.management.openmbean.TabularDataSupport;
import javax.management.openmbean.TabularType;
@TabularTypeInfo(rowType=ClusterNodeInfo.class, indexNames={"id"})
public class ClusterNodeInfoTabular {
private List<ClusterNodeInfo> nodes = new ArrayList<ClusterNodeInfo>();
public void add(ClusterNodeInfo node) {
this.nodes.add(node);
}
public TabularData toTabularData() {
try {
TabularType type = OpenTypeUtils.createTabularType(this.getClass());
TabularDataSupport tabular = new TabularDataSupport(type);
CompositeType itemType = OpenTypeUtils.createCompositeType(ClusterNodeInfo.class);
String[] itemNames = new String[]{"id", "OS", "hostname", "repositoryHome"};
for (ClusterNodeInfo node : this.nodes) {
Object[] itemValues = new Object[]{node.getId(), node.getOS(), node.getHostname(), node.getRepositoryHome()};
tabular.put(new CompositeDataSupport(itemType, itemNames, itemValues));
}
return tabular;
}
catch (OpenDataException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
}