karaf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (KARAF-5786) Add blacklisted item field to JmxFeature & JmxRepository CompositeData
Date Thu, 14 Jun 2018 07:18:00 GMT

    [ https://issues.apache.org/jira/browse/KARAF-5786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16512061#comment-16512061
] 

ASF GitHub Bot commented on KARAF-5786:
---------------------------------------

grgrzybek closed pull request #526: [KARAF-5786] Add blacklisted key to JmxFeature & JmxRepository
CompositeData
URL: https://github.com/apache/karaf/pull/526
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 ca33599b55..c7a0fddfbd 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
@@ -34,6 +34,8 @@
 
     String FEATURE_INSTALLED = "Installed";
 
+    String FEATURE_BLACKLISTED = "Blacklisted";
+
     String FEATURE_CONFIG_PID = "Pid";
     String FEATURE_CONFIG_ELEMENTS = "Elements";
     String FEATURE_CONFIG_APPEND = "Append";
@@ -59,7 +61,7 @@
      * 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_CONFIGURATIONS, FEATURE_CONFIGURATIONFILES, FEATURE_INSTALLED, FEATURE_BLACKLISTED};
 
     String[] FEATURE_IDENTIFIER = {FEATURE_NAME, FEATURE_VERSION};
 
@@ -84,6 +86,8 @@
 
     String REPOSITORY_FEATURES = "Features";
 
+    String REPOSITORY_BLACKLISTED = "Blacklisted";
+
     /**
      * The type of the event which is emitted for repositories events
      */
@@ -98,7 +102,7 @@
     /**
      * The item names in the CompositeData representing a feature
      */
-    String[] REPOSITORY = {REPOSITORY_NAME, REPOSITORY_URI, REPOSITORY_REPOSITORIES, REPOSITORY_FEATURES};
+    String[] REPOSITORY = {REPOSITORY_NAME, REPOSITORY_URI, REPOSITORY_REPOSITORIES, REPOSITORY_FEATURES,
REPOSITORY_BLACKLISTED};
 
     /**
      * The item names in the CompositeData representing the event raised for
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 ae5469ec1b..c9df7a4b4b 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
@@ -83,6 +83,7 @@ public JmxFeature(Feature feature, boolean installed) {
             itemValues[4] = getConfigList(feature.getConfigurations());
             itemValues[5] = getConfigFileList(feature.getConfigurationFiles());
             itemValues[6] = installed;
+            itemValues[7] = feature.isBlacklisted();
             data = new CompositeDataSupport(FEATURE, itemNames, itemValues);
         } catch (OpenDataException e) {
             throw new IllegalStateException("Cannot form feature open data", e);
@@ -314,6 +315,7 @@ private static CompositeType createFeatureType() {
             itemTypes[4] = FEATURE_CONFIG_TABLE;
             itemTypes[5] = FEATURE_CONFIG_FILES_TABLE;
             itemTypes[6] = SimpleType.BOOLEAN;
+            itemTypes[7] = SimpleType.BOOLEAN;
 
             itemDescriptions[0] = "The name of the feature";
             itemDescriptions[1] = "The version of the feature";
@@ -322,6 +324,7 @@ private static CompositeType createFeatureType() {
             itemDescriptions[4] = "The feature configurations";
             itemDescriptions[5] = "The feature configuration files";
             itemDescriptions[6] = "Whether the feature is installed";
+            itemDescriptions[7] = "Whether the feature is blacklisted";
 
             return new CompositeType("Feature", description, itemNames,
                     itemDescriptions, itemTypes);
diff --git a/features/core/src/main/java/org/apache/karaf/features/management/codec/JmxRepository.java
b/features/core/src/main/java/org/apache/karaf/features/management/codec/JmxRepository.java
index 47e9f1c661..c3ee385dd2 100644
--- a/features/core/src/main/java/org/apache/karaf/features/management/codec/JmxRepository.java
+++ b/features/core/src/main/java/org/apache/karaf/features/management/codec/JmxRepository.java
@@ -52,6 +52,7 @@ public JmxRepository(Repository repository) {
             itemValues[1] = repository.getURI().toString();
             itemValues[2] = toStringArray(repository.getRepositories());
             itemValues[3] = getFeatureIdentifierTable(Arrays.asList(repository.getFeatures()));
+            itemValues[4] = repository.isBlacklisted();
             data = new CompositeDataSupport(REPOSITORY, itemNames, itemValues);
         } catch (Exception e) {
             throw new IllegalStateException("Cannot form repository open data", e);
@@ -107,11 +108,13 @@ private static CompositeType createRepositoryType() {
             itemTypes[1] = SimpleType.STRING;
             itemTypes[2] = new ArrayType<String>(1, SimpleType.STRING);
             itemTypes[3] = JmxFeature.FEATURE_IDENTIFIER_TABLE;
+            itemTypes[4] = SimpleType.BOOLEAN;
 
             itemDescriptions[0] = "The name of the repository";
             itemDescriptions[1] = "The uri of the repository";
             itemDescriptions[2] = "The dependent repositories";
             itemDescriptions[3] = "The list of included features";
+            itemDescriptions[4] = "Whether the repository is blacklisted";
 
             return new CompositeType("Repository", 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
new file mode 100644
index 0000000000..fe6e524948
--- /dev/null
+++ b/features/core/src/test/java/org/apache/karaf/features/management/codec/JmxFeatureTest.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.features.management.codec;
+
+import static org.apache.karaf.features.management.FeaturesServiceMBean.FEATURE_BLACKLISTED;
+import static org.apache.karaf.features.management.FeaturesServiceMBean.FEATURE_BUNDLES;
+import static org.apache.karaf.features.management.FeaturesServiceMBean.FEATURE_CONFIGURATIONFILES;
+import static org.apache.karaf.features.management.FeaturesServiceMBean.FEATURE_CONFIGURATIONS;
+import static org.apache.karaf.features.management.FeaturesServiceMBean.FEATURE_CONFIG_PID;
+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_VERSION;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+
+import org.apache.karaf.features.internal.model.Bundle;
+import org.apache.karaf.features.internal.model.Config;
+import org.apache.karaf.features.internal.model.ConfigFile;
+import org.apache.karaf.features.internal.model.Dependency;
+import org.apache.karaf.features.internal.model.Feature;
+import org.junit.Test;
+
+public class JmxFeatureTest {
+
+    @Test
+    public void testJmxFeatureCompositeData() throws Exception {
+        Feature feature = new Feature();
+        feature.setName("test-feature");
+        feature.setVersion("1.0.0");
+        feature.setBlacklisted(true);
+
+        Dependency dependency = new Dependency();
+        dependency.setName("test-dependent-feature");
+        dependency.setVersion("1.0.0");
+        feature.getFeature().add(dependency);
+
+        Bundle bundle = new Bundle();
+        bundle.setLocation("mvn:org.test/test/1.0.0");
+        feature.getBundle().add(bundle);
+
+        Config config = new Config();
+        config.setName(FEATURE_CONFIG_PID);
+        config.setValue("org.test.pid");
+        config.setAppend(false);
+        config.getProperties().put("test-key", "test-value");
+        feature.getConfig().add(config);
+
+        ConfigFile configFile = new ConfigFile();
+        configFile.setFinalname("test-configfile.cfg");
+        feature.getConfigfile().add(configFile);
+
+        JmxFeature jmxFeature = new JmxFeature(feature, 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));
+
+        TabularData featureDependencies = (TabularData) compositeData.get(FEATURE_DEPENDENCIES);
+        assertEquals(1, featureDependencies.size());
+        assertNotNull(featureDependencies.get(new Object[] {"test-dependent-feature", "1.0.0"}));
+
+        String[] bundleUrls = (String[]) compositeData.get(FEATURE_BUNDLES);
+        assertEquals(new String[] {"mvn:org.test/test/1.0.0"}, bundleUrls);
+
+        TabularData featureConfigs = (TabularData) compositeData.get(FEATURE_CONFIGURATIONS);
+        assertEquals(1, featureConfigs.size());
+        assertNotNull(featureConfigs.get(new Object[] {FEATURE_CONFIG_PID}));
+
+        TabularData featureConfigFiles = (TabularData) compositeData.get(FEATURE_CONFIGURATIONFILES);
+        assertEquals(1, featureConfigFiles.size());
+        assertNotNull(featureConfigFiles.get(new Object[] {"test-configfile.cfg"}));
+    }
+}
diff --git a/features/core/src/test/java/org/apache/karaf/features/management/codec/JmxRepositoryTest.java
b/features/core/src/test/java/org/apache/karaf/features/management/codec/JmxRepositoryTest.java
new file mode 100644
index 0000000000..e61123fc80
--- /dev/null
+++ b/features/core/src/test/java/org/apache/karaf/features/management/codec/JmxRepositoryTest.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.features.management.codec;
+
+import static org.apache.karaf.features.management.FeaturesServiceMBean.REPOSITORY_BLACKLISTED;
+import static org.apache.karaf.features.management.FeaturesServiceMBean.REPOSITORY_FEATURES;
+import static org.apache.karaf.features.management.FeaturesServiceMBean.REPOSITORY_NAME;
+import static org.apache.karaf.features.management.FeaturesServiceMBean.REPOSITORY_REPOSITORIES;
+import static org.apache.karaf.features.management.FeaturesServiceMBean.REPOSITORY_URI;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.net.URI;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+
+import org.apache.karaf.features.Repository;
+import org.apache.karaf.features.internal.model.Feature;
+import org.apache.karaf.features.internal.model.Features;
+import org.apache.karaf.features.internal.service.RepositoryImpl;
+import org.junit.Test;
+
+public class JmxRepositoryTest {
+
+    @Test
+    public void testJmxRepositoryCompositeData() throws Exception {
+        Features features = new Features();
+        features.setName("test-1.0.0");
+        features.getRepository().add("mvn:org.test/test-dependency/1.0.0/xml/features");
+        features.getFeature().add(new Feature("test-feature", "1.0.0"));
+
+        URI uri = new URI("mvn:org.test/test/1.0.0/xml/features");
+        Repository repository = new RepositoryImpl(uri, features, true);
+
+        JmxRepository jmxRepository = new JmxRepository(repository);
+        CompositeData compositeData = jmxRepository.asCompositeData();
+
+        assertEquals("test-1.0.0", compositeData.get(REPOSITORY_NAME));
+        assertEquals(uri.toString(), compositeData.get(REPOSITORY_URI));
+        assertTrue((Boolean) compositeData.get(REPOSITORY_BLACKLISTED));
+
+        String[] repositoryUris = (String[]) compositeData.get(REPOSITORY_REPOSITORIES);
+        assertEquals(1, repositoryUris.length);
+        assertEquals("mvn:org.test/test-dependency/1.0.0/xml/features", repositoryUris[0]);
+
+        TabularData repositoryFeatures = (TabularData) compositeData.get(REPOSITORY_FEATURES);
+        assertEquals(1, repositoryFeatures.size());
+        assertNotNull(repositoryFeatures.get(new Object[] {"test-feature", "1.0.0"}));
+    }
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Add blacklisted item field to JmxFeature & JmxRepository CompositeData
> ----------------------------------------------------------------------
>
>                 Key: KARAF-5786
>                 URL: https://issues.apache.org/jira/browse/KARAF-5786
>             Project: Karaf
>          Issue Type: Improvement
>          Components: karaf-management
>    Affects Versions: 4.2.0
>            Reporter: James Netherton
>            Priority: Major
>
> Neither JmxFeature or JmxRepository exposes information to determine whether they are
blacklisted. It'd be useful to add a 'blacklisted' key to CompositeData so that clients can access this
data.  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message