You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2018/01/23 17:29:25 UTC

[karaf-decanter] branch master updated: Update to OSGi 6.0.0 and Karaf 4.x

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-decanter.git


The following commit(s) were added to refs/heads/master by this push:
     new fa7e6d2  Update to OSGi 6.0.0 and Karaf 4.x
fa7e6d2 is described below

commit fa7e6d2818db1ff03c86eef5f73c1c5ee963c1ab
Author: Jean-Baptiste Onofré <jb...@apache.org>
AuthorDate: Tue Jan 23 18:29:09 2018 +0100

    Update to OSGi 6.0.0 and Karaf 4.x
---
 .../decanter/appender/camel/CamelAppender.java     |  4 +-
 assembly/src/main/feature/feature.xml              |  2 +-
 .../decanter/collector/jmx/TestMapAttribute.java   | 65 ++++++++++------------
 pom.xml                                            | 13 ++---
 .../karaf/decanter/sla/camel/CamelAlerter.java     |  2 +-
 .../karaf/decanter/sla/email/EmailAlerter.java     |  6 +-
 6 files changed, 43 insertions(+), 49 deletions(-)

diff --git a/appender/camel/src/main/java/org/apache/karaf/decanter/appender/camel/CamelAppender.java b/appender/camel/src/main/java/org/apache/karaf/decanter/appender/camel/CamelAppender.java
index 7ce15f9..7e670b8 100644
--- a/appender/camel/src/main/java/org/apache/karaf/decanter/appender/camel/CamelAppender.java
+++ b/appender/camel/src/main/java/org/apache/karaf/decanter/appender/camel/CamelAppender.java
@@ -51,10 +51,10 @@ public class CamelAppender implements EventHandler {
         open(context.getProperties());
     }
     
-    public void open(Dictionary<String, String> config) throws ConfigurationException {
+    public void open(Dictionary<String, Object> config) throws ConfigurationException {
         LOGGER.debug("Creating CamelContext, and use the {} URI", destinationUri);
         this.camelContext = new DefaultCamelContext();
-        this.destinationUri = config.get("destination.uri");
+        this.destinationUri = (String) config.get("destination.uri");
         if (this.destinationUri == null) {
             throw new ConfigurationException("destination.uri", "destination.uri is not defined");
         }
diff --git a/assembly/src/main/feature/feature.xml b/assembly/src/main/feature/feature.xml
index f776054..bc9312e 100644
--- a/assembly/src/main/feature/feature.xml
+++ b/assembly/src/main/feature/feature.xml
@@ -16,7 +16,7 @@
     See the License for the specific language governing permissions and
     limitations under the License.
 -->
-<features name="karaf-decanter-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.0.0 http://karaf.apache.org/xmlns/features/v1.0.0">
+<features name="karaf-decanter-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.0.0 http://karaf.apache.org/xmlns/features/v1.0.0">
 
     <feature name="decanter" version="${project.version}" description="Meta feature installing elasticsearch, kibana, jmx collector, log collector Decanter features">
         <feature version="${elasticsearch22.version}">elasticsearch</feature>
diff --git a/collector/jmx/src/test/java/org/apache/karaf/decanter/collector/jmx/TestMapAttribute.java b/collector/jmx/src/test/java/org/apache/karaf/decanter/collector/jmx/TestMapAttribute.java
index ccb6fe7..3bde32c 100644
--- a/collector/jmx/src/test/java/org/apache/karaf/decanter/collector/jmx/TestMapAttribute.java
+++ b/collector/jmx/src/test/java/org/apache/karaf/decanter/collector/jmx/TestMapAttribute.java
@@ -1,12 +1,7 @@
 package org.apache.karaf.decanter.collector.jmx;
 
 import java.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
+import java.util.*;
 
 import javax.management.MBeanServerConnection;
 import javax.management.MalformedObjectNameException;
@@ -28,48 +23,48 @@ public class TestMapAttribute {
         Object freeMem = data.get("FreePhysicalMemorySize");
         Assert.assertTrue(freeMem != null);
         Assert.assertTrue(freeMem instanceof Long);
-        Assert.assertTrue((Long)freeMem > 10000);
+        Assert.assertTrue((Long) freeMem > 10000);
         System.out.println(data);
     }
 
     @Test
     public void testSingleObjectName() throws Exception {
-    	ComponentContext ctx = Mockito.mock( ComponentContext.class );
-    	Properties props = new Properties();
-    	Mockito.when( ctx.getProperties()).thenReturn( props );
+        ComponentContext ctx = Mockito.mock(ComponentContext.class);
+        Dictionary props = new Hashtable<>();
+        Mockito.when(ctx.getProperties()).thenReturn(props);
 
-    	props.put( "object.name", "java.lang:*" );
-    	JmxCollector collector = new JmxCollector();
-    	Assert.assertNull( collector.getObjectNames());
-    	collector.activate( ctx );
+        props.put("object.name", "java.lang:*");
+        JmxCollector collector = new JmxCollector();
+        Assert.assertNull(collector.getObjectNames());
+        collector.activate(ctx);
 
-    	Set<String> objectNames = collector.getObjectNames();
-    	Assert.assertEquals( 1, objectNames.size());
-    	Assert.assertEquals( "java.lang:*", objectNames.iterator().next());
+        Set<String> objectNames = collector.getObjectNames();
+        Assert.assertEquals(1, objectNames.size());
+        Assert.assertEquals("java.lang:*", objectNames.iterator().next());
     }
 
     @Test
     public void testSeveralObjectNames() throws Exception {
-    	ComponentContext ctx = Mockito.mock( ComponentContext.class );
-    	Properties props = new Properties();
-    	Mockito.when( ctx.getProperties()).thenReturn( props );
+        ComponentContext ctx = Mockito.mock(ComponentContext.class);
+        Dictionary props = new Hashtable();
+        Mockito.when(ctx.getProperties()).thenReturn(props);
 
-    	props.put( "object.name.system", "java.lang:*" );
-    	props.put( "object.name", "org.something.else:*" );
-    	props.put( "object.name.karaf", "org.apache.karaf:type=http" );
-    	props.put( "object.name.2", "whatever" );
-    	props.put( "object.name-invalid", "not expected" );
+        props.put("object.name.system", "java.lang:*");
+        props.put("object.name", "org.something.else:*");
+        props.put("object.name.karaf", "org.apache.karaf:type=http");
+        props.put("object.name.2", "whatever");
+        props.put("object.name-invalid", "not expected");
 
-    	JmxCollector collector = new JmxCollector();
-    	Assert.assertNull( collector.getObjectNames());
-    	collector.activate( ctx );
+        JmxCollector collector = new JmxCollector();
+        Assert.assertNull(collector.getObjectNames());
+        collector.activate(ctx);
 
-    	List<String> objectNames = new ArrayList<>( collector.getObjectNames());
-    	Collections.sort( objectNames );
-    	Assert.assertEquals( 4, objectNames.size());
-    	Assert.assertEquals( "java.lang:*", objectNames.get( 0 ));
-    	Assert.assertEquals( "org.apache.karaf:type=http", objectNames.get( 1 ));
-    	Assert.assertEquals( "org.something.else:*", objectNames.get( 2 ));
-    	Assert.assertEquals( "whatever", objectNames.get( 3 ));
+        List<String> objectNames = new ArrayList<>(collector.getObjectNames());
+        Collections.sort(objectNames);
+        Assert.assertEquals(4, objectNames.size());
+        Assert.assertEquals("java.lang:*", objectNames.get(0));
+        Assert.assertEquals("org.apache.karaf:type=http", objectNames.get(1));
+        Assert.assertEquals("org.something.else:*", objectNames.get(2));
+        Assert.assertEquals("whatever", objectNames.get(3));
     }
 }
diff --git a/pom.xml b/pom.xml
index b6e7bdb..26fc0ee 100644
--- a/pom.xml
+++ b/pom.xml
@@ -287,14 +287,13 @@
             <!-- OSGi -->
             <dependency>
                 <groupId>org.osgi</groupId>
-                <artifactId>org.osgi.core</artifactId>
-                <version>4.3.1</version>
+                <artifactId>osgi.core</artifactId>
+                <version>6.0.0</version>
             </dependency>
             <dependency>
                 <groupId>org.osgi</groupId>
-                <artifactId>org.osgi.compendium</artifactId>
-                <version>4.3.1</version>
-                <scope>provided</scope>
+                <artifactId>osgi.cmpn</artifactId>
+                <version>6.0.0</version>
             </dependency>
 
             <!-- ActiveMQ -->
@@ -359,12 +358,12 @@
     <dependencies>
         <dependency>
             <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.core</artifactId>
+            <artifactId>osgi.core</artifactId>
             <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.compendium</artifactId>
+            <artifactId>osgi.cmpn</artifactId>
             <scope>provided</scope>
         </dependency>
         <dependency>
diff --git a/sla/camel/src/main/java/org/apache/karaf/decanter/sla/camel/CamelAlerter.java b/sla/camel/src/main/java/org/apache/karaf/decanter/sla/camel/CamelAlerter.java
index 1e60759..83cc27a 100644
--- a/sla/camel/src/main/java/org/apache/karaf/decanter/sla/camel/CamelAlerter.java
+++ b/sla/camel/src/main/java/org/apache/karaf/decanter/sla/camel/CamelAlerter.java
@@ -44,7 +44,7 @@ public class CamelAlerter implements EventHandler {
     @SuppressWarnings("unchecked")
     @Activate
     public void activate(ComponentContext context) throws ConfigurationException {
-        Dictionary<String, String> config = context.getProperties();
+        Dictionary<String, Object> config = context.getProperties();
         this.alertDestinationUri = (String) config.get("alert.destination.uri");
         if (alertDestinationUri == null) {
             throw new ConfigurationException("alert.destination.uri", "alert.destination.uri property is not defined");
diff --git a/sla/email/src/main/java/org/apache/karaf/decanter/sla/email/EmailAlerter.java b/sla/email/src/main/java/org/apache/karaf/decanter/sla/email/EmailAlerter.java
index 265190e..b56ba9a 100644
--- a/sla/email/src/main/java/org/apache/karaf/decanter/sla/email/EmailAlerter.java
+++ b/sla/email/src/main/java/org/apache/karaf/decanter/sla/email/EmailAlerter.java
@@ -49,13 +49,13 @@ public class EmailAlerter implements EventHandler {
 
     @SuppressWarnings("unchecked")
     public void activate(ComponentContext context) throws ConfigurationException {
-        Dictionary<String, String> config = context.getProperties();
+        Dictionary<String, Object> config = context.getProperties();
         requireProperty(config, "from");
         requireProperty(config, "to");
         requireProperty(config, "host");
 
-        this.from = config.get("from");
-        this.to = config.get("to");
+        this.from = (String) config.get("from");
+        this.to = (String) config.get("to");
 
         properties = new Properties();
         properties.put("mail.smtp.host", config.get("host"));

-- 
To stop receiving notification emails like this one, please contact
jbonofre@apache.org.