karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject [karaf] branch master updated: [KARAF-5805] Add feature required item field to JmxFeature CompositeData
Date Thu, 05 Jul 2018 15:25:06 GMT
This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/master by this push:
     new 67b8cc3  [KARAF-5805] Add feature required item field to JmxFeature CompositeData
     new 20b774e  [KARAF-5805] This closes #540
67b8cc3 is described below

commit 67b8cc319b5e259c2994617fd9da56b3b83b70a7
Author: James Netherton <jamesnetherton@gmail.com>
AuthorDate: Thu Jul 5 10:15:34 2018 +0100

    [KARAF-5805] Add feature required item field to JmxFeature CompositeData
---
 .../internal/management/FeaturesServiceMBeanImpl.java         | 11 ++++-------
 .../karaf/features/management/FeaturesServiceMBean.java       |  5 ++++-
 .../apache/karaf/features/management/codec/JmxFeature.java    |  5 ++++-
 .../karaf/features/management/codec/JmxFeatureTest.java       |  4 +++-
 4 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/management/FeaturesServiceMBeanImpl.java
b/features/core/src/main/java/org/apache/karaf/features/internal/management/FeaturesServiceMBeanImpl.java
index cbc169c..da39bc6 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/management/FeaturesServiceMBeanImpl.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/management/FeaturesServiceMBeanImpl.java
@@ -93,7 +93,7 @@ public class FeaturesServiceMBeanImpl extends StandardEmitterMBean implements
             ArrayList<JmxFeature> features = new ArrayList<>();
             for (Feature feature : allFeatures) {
                 try {
-                    features.add(new JmxFeature(feature, insFeatures.contains(feature)));
+                    features.add(new JmxFeature(feature, insFeatures.contains(feature), featuresService.isRequired(feature)));
                 } catch (Throwable t) {
                     t.printStackTrace();
                 }
@@ -266,12 +266,9 @@ public class FeaturesServiceMBeanImpl extends StandardEmitterMBean implements
     private TabularData infoFeature(Feature[] f) throws Exception {
         ArrayList<JmxFeature> features = new ArrayList<>();
         for (Feature feature:f) {
-            JmxFeature jmxFeature;
-            if (featuresService.isInstalled(feature)) {
-                jmxFeature = new JmxFeature(feature, true);
-            } else {
-                jmxFeature = new JmxFeature(feature, false);
-            }
+            boolean installed = featuresService.isInstalled(feature);
+            boolean required = featuresService.isRequired(feature);
+            JmxFeature jmxFeature = new JmxFeature(feature, installed, required);
             features.add(jmxFeature);
         }
         return JmxFeature.tableFrom(features);
diff --git a/features/core/src/main/java/org/apache/karaf/features/management/FeaturesServiceMBean.java
b/features/core/src/main/java/org/apache/karaf/features/management/FeaturesServiceMBean.java
index c7a0fdd..8d49dc0 100644
--- a/features/core/src/main/java/org/apache/karaf/features/management/FeaturesServiceMBean.java
+++ b/features/core/src/main/java/org/apache/karaf/features/management/FeaturesServiceMBean.java
@@ -36,6 +36,8 @@ public interface FeaturesServiceMBean {
 
     String FEATURE_BLACKLISTED = "Blacklisted";
 
+    String FEATURE_REQUIRED = "Required";
+
     String FEATURE_CONFIG_PID = "Pid";
     String FEATURE_CONFIG_ELEMENTS = "Elements";
     String FEATURE_CONFIG_APPEND = "Append";
@@ -61,7 +63,8 @@ public interface FeaturesServiceMBean {
      * The item names in the CompositeData representing a feature
      */
     String[] FEATURE = {FEATURE_NAME, FEATURE_VERSION, FEATURE_DEPENDENCIES, FEATURE_BUNDLES,
-        FEATURE_CONFIGURATIONS, FEATURE_CONFIGURATIONFILES, FEATURE_INSTALLED, FEATURE_BLACKLISTED};
+        FEATURE_CONFIGURATIONS, FEATURE_CONFIGURATIONFILES, FEATURE_INSTALLED, FEATURE_BLACKLISTED,
+        FEATURE_REQUIRED};
 
     String[] FEATURE_IDENTIFIER = {FEATURE_NAME, FEATURE_VERSION};
 
diff --git a/features/core/src/main/java/org/apache/karaf/features/management/codec/JmxFeature.java
b/features/core/src/main/java/org/apache/karaf/features/management/codec/JmxFeature.java
index c9df7a4..bc50c73 100644
--- a/features/core/src/main/java/org/apache/karaf/features/management/codec/JmxFeature.java
+++ b/features/core/src/main/java/org/apache/karaf/features/management/codec/JmxFeature.java
@@ -72,7 +72,7 @@ public class JmxFeature {
 
     private final CompositeData data;
 
-    public JmxFeature(Feature feature, boolean installed) {
+    public JmxFeature(Feature feature, boolean installed, boolean required) {
         try {
             String[] itemNames = FeaturesServiceMBean.FEATURE;
             Object[] itemValues = new Object[itemNames.length];
@@ -84,6 +84,7 @@ public class JmxFeature {
             itemValues[5] = getConfigFileList(feature.getConfigurationFiles());
             itemValues[6] = installed;
             itemValues[7] = feature.isBlacklisted();
+            itemValues[8] = required;
             data = new CompositeDataSupport(FEATURE, itemNames, itemValues);
         } catch (OpenDataException e) {
             throw new IllegalStateException("Cannot form feature open data", e);
@@ -316,6 +317,7 @@ public class JmxFeature {
             itemTypes[5] = FEATURE_CONFIG_FILES_TABLE;
             itemTypes[6] = SimpleType.BOOLEAN;
             itemTypes[7] = SimpleType.BOOLEAN;
+            itemTypes[8] = SimpleType.BOOLEAN;
 
             itemDescriptions[0] = "The name of the feature";
             itemDescriptions[1] = "The version of the feature";
@@ -325,6 +327,7 @@ public class JmxFeature {
             itemDescriptions[5] = "The feature configuration files";
             itemDescriptions[6] = "Whether the feature is installed";
             itemDescriptions[7] = "Whether the feature is blacklisted";
+            itemDescriptions[8] = "Whether the feature is required";
 
             return new CompositeType("Feature", description, itemNames,
                     itemDescriptions, itemTypes);
diff --git a/features/core/src/test/java/org/apache/karaf/features/management/codec/JmxFeatureTest.java
b/features/core/src/test/java/org/apache/karaf/features/management/codec/JmxFeatureTest.java
index fe6e524..2a92bf5 100644
--- a/features/core/src/test/java/org/apache/karaf/features/management/codec/JmxFeatureTest.java
+++ b/features/core/src/test/java/org/apache/karaf/features/management/codec/JmxFeatureTest.java
@@ -24,6 +24,7 @@ import static org.apache.karaf.features.management.FeaturesServiceMBean.FEATURE_
 import static org.apache.karaf.features.management.FeaturesServiceMBean.FEATURE_DEPENDENCIES;
 import static org.apache.karaf.features.management.FeaturesServiceMBean.FEATURE_INSTALLED;
 import static org.apache.karaf.features.management.FeaturesServiceMBean.FEATURE_NAME;
+import static org.apache.karaf.features.management.FeaturesServiceMBean.FEATURE_REQUIRED;
 import static org.apache.karaf.features.management.FeaturesServiceMBean.FEATURE_VERSION;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -68,13 +69,14 @@ public class JmxFeatureTest {
         configFile.setFinalname("test-configfile.cfg");
         feature.getConfigfile().add(configFile);
 
-        JmxFeature jmxFeature = new JmxFeature(feature, true);
+        JmxFeature jmxFeature = new JmxFeature(feature, true, true);
         CompositeData compositeData = jmxFeature.asCompositeData();
 
         assertEquals("test-feature", compositeData.get(FEATURE_NAME));
         assertEquals("1.0.0", compositeData.get(FEATURE_VERSION));
         assertTrue((Boolean) compositeData.get(FEATURE_INSTALLED));
         assertTrue((Boolean) compositeData.get(FEATURE_BLACKLISTED));
+        assertTrue((Boolean) compositeData.get(FEATURE_REQUIRED));
 
         TabularData featureDependencies = (TabularData) compositeData.get(FEATURE_DEPENDENCIES);
         assertEquals(1, featureDependencies.size());


Mime
View raw message