in features/src/main/java/org/apache/karaf/cellar/features/management/internal/CellarFeaturesMBeanImpl.java [267:328]
public TabularData getFeatures(String groupName) throws Exception {
Group group = groupManager.findGroupByName(groupName);
if (group == null) {
throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist");
}
CellarSupport support = new CellarSupport();
support.setClusterManager(clusterManager);
support.setGroupManager(groupManager);
support.setConfigurationAdmin(configurationAdmin);
CompositeType featuresType = new CompositeType("Feature", "Karaf Cellar feature",
new String[]{"name", "version", "installed", "located", "blocked"},
new String[]{"Name of the feature", "Version of the feature", "Whether the feature is installed or not",
"Location of the feature (on the cluster or the local node)",
"Feature block policy"},
new OpenType[]{SimpleType.STRING, SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.STRING, SimpleType.STRING});
TabularType tabularType = new TabularType("Features", "Table of all Karaf Cellar features",
featuresType, new String[]{"name", "version"});
TabularData table = new TabularDataSupport(tabularType);
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
try {
Map<String, ExtendedFeatureState> features = gatherFeatures(groupName);
if (features != null && !features.isEmpty()) {
for (ExtendedFeatureState feature : features.values()) {
String located = "";
boolean cluster = feature.isCluster();
boolean local = feature.isLocal();
if (cluster && local)
located = "cluster/local";
if (cluster && !local)
located = "cluster";
if (local && !cluster)
located = "local";
String blocked = "";
boolean inbound = support.isAllowed(group, Constants.CATEGORY, feature.getName(), EventType.INBOUND);
boolean outbound = support.isAllowed(group, Constants.CATEGORY, feature.getName(), EventType.OUTBOUND);
if (!inbound && !outbound)
blocked = "in/out";
if (!inbound && outbound)
blocked = "in";
if (!outbound && inbound)
blocked = "out";
CompositeData data = new CompositeDataSupport(featuresType,
new String[]{"name", "version", "installed", "located", "blocked"},
new Object[]{feature.getName(), feature.getVersion(), feature.getInstalled(), located, blocked});
table.put(data);
}
}
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
return table;
}