Make code compatible with newer OSGi framework versions

Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/0b48d4a2
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/0b48d4a2
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/0b48d4a2

Branch: refs/heads/master
Commit: 0b48d4a25a7e00d52a72ae1e76db9f301ce98459
Parents: 51a9b4d
Author: Ignasi Barrera <[email protected]>
Authored: Thu Nov 3 09:43:36 2016 +0100
Committer: Ignasi Barrera <[email protected]>
Committed: Thu Nov 3 09:43:36 2016 +0100

----------------------------------------------------------------------
 core/pom.xml                                    |  2 -
 .../test/java/org/jclouds/osgi/BundlesTest.java | 14 ++++---
 .../osgi/MetadataBundleListenerTest.java        | 42 +++++++++++---------
 project/pom.xml                                 | 12 ++++++
 resources/modernizer_exclusions.txt             |  1 +
 scriptbuilder/pom.xml                           |  1 -
 .../osgi/BundleFunctionLoader.java              |  4 +-
 7 files changed, 47 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/0b48d4a2/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index 791a874..67381cb 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -89,13 +89,11 @@
     <dependency>
       <groupId>org.osgi</groupId>
       <artifactId>org.osgi.core</artifactId>
-      <version>4.2.0</version>
       <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.osgi</groupId>
       <artifactId>org.osgi.compendium</artifactId>
-      <version>4.2.0</version>
       <scope>provided</scope>
     </dependency>
     <dependency>

http://git-wip-us.apache.org/repos/asf/jclouds/blob/0b48d4a2/core/src/test/java/org/jclouds/osgi/BundlesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/jclouds/osgi/BundlesTest.java 
b/core/src/test/java/org/jclouds/osgi/BundlesTest.java
index 180dd48..b530a2a 100644
--- a/core/src/test/java/org/jclouds/osgi/BundlesTest.java
+++ b/core/src/test/java/org/jclouds/osgi/BundlesTest.java
@@ -34,14 +34,15 @@ import com.google.common.collect.ImmutableSet;
 
 public class BundlesTest {
 
+   @SuppressWarnings("rawtypes")
    @Test
    public void testInstantiateAvailableClassesWhenAllAssignable() throws 
ClassNotFoundException {
       Bundle bundle = createMock(Bundle.class);
-      
expect(bundle.loadClass("org.jclouds.providers.JcloudsTestBlobStoreProviderMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.providers.JcloudsTestBlobStoreProviderMetadata")).andReturn(
             JcloudsTestBlobStoreProviderMetadata.class);
-      
expect(bundle.loadClass("org.jclouds.providers.JcloudsTestComputeProviderMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.providers.JcloudsTestComputeProviderMetadata")).andReturn(
             JcloudsTestComputeProviderMetadata.class);
-      
expect(bundle.loadClass("org.jclouds.providers.JcloudsTestYetAnotherComputeProviderMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.providers.JcloudsTestYetAnotherComputeProviderMetadata")).andReturn(
             JcloudsTestYetAnotherComputeProviderMetadata.class);
       replay(bundle);
 
@@ -55,14 +56,15 @@ public class BundlesTest {
       verify(bundle);
    }
 
+   @SuppressWarnings("rawtypes")
    @Test
    public void testInstantiateAvailableClassesWhenNotAllAssignable() throws 
ClassNotFoundException {
       Bundle bundle = createMock(Bundle.class);
-      
expect(bundle.loadClass("org.jclouds.providers.JcloudsTestBlobStoreProviderMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.providers.JcloudsTestBlobStoreProviderMetadata")).andReturn(
             JcloudsTestBlobStoreProviderMetadata.class);
-      
expect(bundle.loadClass("org.jclouds.apis.JcloudsTestComputeApiMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.apis.JcloudsTestComputeApiMetadata")).andReturn(
             JcloudsTestComputeApiMetadata.class);
-      
expect(bundle.loadClass("org.jclouds.providers.JcloudsTestYetAnotherComputeProviderMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.providers.JcloudsTestYetAnotherComputeProviderMetadata")).andReturn(
             JcloudsTestYetAnotherComputeProviderMetadata.class);
       replay(bundle);
 

http://git-wip-us.apache.org/repos/asf/jclouds/blob/0b48d4a2/core/src/test/java/org/jclouds/osgi/MetadataBundleListenerTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/jclouds/osgi/MetadataBundleListenerTest.java 
b/core/src/test/java/org/jclouds/osgi/MetadataBundleListenerTest.java
index ff976c7..536f6b5 100644
--- a/core/src/test/java/org/jclouds/osgi/MetadataBundleListenerTest.java
+++ b/core/src/test/java/org/jclouds/osgi/MetadataBundleListenerTest.java
@@ -57,17 +57,18 @@ public class MetadataBundleListenerTest {
             
.loadClass("org.jclouds.providers.JcloudsTestComputeProviderMetadata")));
    }
 
+   @SuppressWarnings("rawtypes")
    @Test
    public void testGetProviderMetadata() throws Exception {
       MetadataBundleListener listener = new MetadataBundleListener();
       Bundle bundle = createMock(Bundle.class);
       
expect(bundle.getEntry("/META-INF/services/org.jclouds.providers.ProviderMetadata")).andReturn(
             
getClass().getResource("/META-INF/services/org.jclouds.providers.ProviderMetadata")).anyTimes();
-      
expect(bundle.loadClass("org.jclouds.providers.JcloudsTestBlobStoreProviderMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.providers.JcloudsTestBlobStoreProviderMetadata")).andReturn(
             JcloudsTestBlobStoreProviderMetadata.class).anyTimes();
-      
expect(bundle.loadClass("org.jclouds.providers.JcloudsTestComputeProviderMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.providers.JcloudsTestComputeProviderMetadata")).andReturn(
             JcloudsTestComputeProviderMetadata.class).anyTimes();
-      
expect(bundle.loadClass("org.jclouds.providers.JcloudsTestYetAnotherComputeProviderMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.providers.JcloudsTestYetAnotherComputeProviderMetadata")).andReturn(
             JcloudsTestYetAnotherComputeProviderMetadata.class).anyTimes();
       replay(bundle);
       List<ProviderMetadata> providerMetadataList = 
Lists.newArrayList(listener.listProviderMetadata(bundle));
@@ -79,6 +80,7 @@ public class MetadataBundleListenerTest {
       verify(bundle);
    }
 
+   @SuppressWarnings("rawtypes")
    @Test
    public void testProviderListener() throws Exception {
       MetadataBundleListener listener = new MetadataBundleListener();
@@ -90,11 +92,11 @@ public class MetadataBundleListenerTest {
       
expect(bundle.getEntry("/META-INF/services/org.jclouds.providers.ProviderMetadata")).andReturn(
             
getClass().getResource("/META-INF/services/org.jclouds.providers.ProviderMetadata")).anyTimes();
       
expect(bundle.getEntry("/META-INF/services/org.jclouds.apis.ApiMetadata")).andReturn(null).anyTimes();
-      
expect(bundle.loadClass("org.jclouds.providers.JcloudsTestBlobStoreProviderMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.providers.JcloudsTestBlobStoreProviderMetadata")).andReturn(
             JcloudsTestBlobStoreProviderMetadata.class).anyTimes();
-      
expect(bundle.loadClass("org.jclouds.providers.JcloudsTestComputeProviderMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.providers.JcloudsTestComputeProviderMetadata")).andReturn(
             JcloudsTestComputeProviderMetadata.class).anyTimes();
-      
expect(bundle.loadClass("org.jclouds.providers.JcloudsTestYetAnotherComputeProviderMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.providers.JcloudsTestYetAnotherComputeProviderMetadata")).andReturn(
             JcloudsTestYetAnotherComputeProviderMetadata.class).anyTimes();
 
       
providerListener.added(anyObject(JcloudsTestBlobStoreProviderMetadata.class));
@@ -110,6 +112,7 @@ public class MetadataBundleListenerTest {
       verify(bundle, providerListener);
    }
 
+   @SuppressWarnings("rawtypes")
    @Test
    public void testGetProviderMetadataFromMultipleClassLoaders() throws 
Exception {
       ClassLoader isolatedClassLoader = createIsolatedClassLoader();
@@ -117,11 +120,11 @@ public class MetadataBundleListenerTest {
       Bundle bundle = createMock(Bundle.class);
       
expect(bundle.getEntry("/META-INF/services/org.jclouds.providers.ProviderMetadata")).andReturn(
             
getClass().getResource("/META-INF/services/org.jclouds.providers.ProviderMetadata")).anyTimes();
-      
expect(bundle.loadClass("org.jclouds.providers.JcloudsTestBlobStoreProviderMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.providers.JcloudsTestBlobStoreProviderMetadata")).andReturn(
             
isolatedClassLoader.loadClass(JcloudsTestBlobStoreProviderMetadata.class.getName())).anyTimes();
-      
expect(bundle.loadClass("org.jclouds.providers.JcloudsTestComputeProviderMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.providers.JcloudsTestComputeProviderMetadata")).andReturn(
             JcloudsTestComputeProviderMetadata.class).anyTimes();
-      
expect(bundle.loadClass("org.jclouds.providers.JcloudsTestYetAnotherComputeProviderMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.providers.JcloudsTestYetAnotherComputeProviderMetadata")).andReturn(
             JcloudsTestYetAnotherComputeProviderMetadata.class).anyTimes();
 
       replay(bundle);
@@ -134,17 +137,18 @@ public class MetadataBundleListenerTest {
       verify(bundle);
    }
 
+   @SuppressWarnings("rawtypes")
    @Test
    public void testGetApiMetadata() throws Exception {
       MetadataBundleListener listener = new MetadataBundleListener();
       Bundle bundle = createMock(Bundle.class);
       
expect(bundle.getEntry("/META-INF/services/org.jclouds.apis.ApiMetadata")).andReturn(
             
getClass().getResource("/META-INF/services/org.jclouds.apis.ApiMetadata")).anyTimes();
-      
expect(bundle.loadClass("org.jclouds.apis.JcloudsTestBlobStoreApiMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.apis.JcloudsTestBlobStoreApiMetadata")).andReturn(
             JcloudsTestBlobStoreApiMetadata.class).anyTimes();
-      
expect(bundle.loadClass("org.jclouds.apis.JcloudsTestComputeApiMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.apis.JcloudsTestComputeApiMetadata")).andReturn(
             JcloudsTestComputeApiMetadata.class).anyTimes();
-      
expect(bundle.loadClass("org.jclouds.apis.JcloudsTestYetAnotherComputeApiMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.apis.JcloudsTestYetAnotherComputeApiMetadata")).andReturn(
             JcloudsTestYetAnotherComputeApiMetadata.class).anyTimes();
 
       replay(bundle);
@@ -157,6 +161,7 @@ public class MetadataBundleListenerTest {
       verify(bundle);
    }
 
+   @SuppressWarnings("rawtypes")
    @Test
    public void testApiListener() throws Exception {
       MetadataBundleListener listener = new MetadataBundleListener();
@@ -168,11 +173,11 @@ public class MetadataBundleListenerTest {
       
expect(bundle.getEntry("/META-INF/services/org.jclouds.providers.ProviderMetadata")).andReturn(null).anyTimes();
       
expect(bundle.getEntry("/META-INF/services/org.jclouds.apis.ApiMetadata")).andReturn(
             
getClass().getResource("/META-INF/services/org.jclouds.apis.ApiMetadata")).anyTimes();
-      
expect(bundle.loadClass("org.jclouds.apis.JcloudsTestBlobStoreApiMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.apis.JcloudsTestBlobStoreApiMetadata")).andReturn(
             JcloudsTestBlobStoreApiMetadata.class).anyTimes();
-      
expect(bundle.loadClass("org.jclouds.apis.JcloudsTestComputeApiMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.apis.JcloudsTestComputeApiMetadata")).andReturn(
             JcloudsTestComputeApiMetadata.class).anyTimes();
-      
expect(bundle.loadClass("org.jclouds.apis.JcloudsTestYetAnotherComputeApiMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.apis.JcloudsTestYetAnotherComputeApiMetadata")).andReturn(
             JcloudsTestYetAnotherComputeApiMetadata.class).anyTimes();
 
       apiListener.added(anyObject(JcloudsTestBlobStoreApiMetadata.class));
@@ -188,6 +193,7 @@ public class MetadataBundleListenerTest {
       verify(bundle, apiListener);
    }
 
+   @SuppressWarnings("rawtypes")
    @Test
    public void testGetApiMetadataFromMultipleClassLoaders() throws Exception {
       ClassLoader isolatedClassLoader = createIsolatedClassLoader();
@@ -195,11 +201,11 @@ public class MetadataBundleListenerTest {
       Bundle bundle = createMock(Bundle.class);
       
expect(bundle.getEntry("/META-INF/services/org.jclouds.apis.ApiMetadata")).andReturn(
             
getClass().getResource("/META-INF/services/org.jclouds.apis.ApiMetadata")).anyTimes();
-      
expect(bundle.loadClass("org.jclouds.apis.JcloudsTestBlobStoreApiMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.apis.JcloudsTestBlobStoreApiMetadata")).andReturn(
             
isolatedClassLoader.loadClass(JcloudsTestBlobStoreApiMetadata.class.getName())).anyTimes();
-      
expect(bundle.loadClass("org.jclouds.apis.JcloudsTestComputeApiMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.apis.JcloudsTestComputeApiMetadata")).andReturn(
             JcloudsTestComputeApiMetadata.class).anyTimes();
-      
expect(bundle.loadClass("org.jclouds.apis.JcloudsTestYetAnotherComputeApiMetadata")).andReturn(
+      expect((Class) 
bundle.loadClass("org.jclouds.apis.JcloudsTestYetAnotherComputeApiMetadata")).andReturn(
             JcloudsTestYetAnotherComputeApiMetadata.class).anyTimes();
 
       replay(bundle);

http://git-wip-us.apache.org/repos/asf/jclouds/blob/0b48d4a2/project/pom.xml
----------------------------------------------------------------------
diff --git a/project/pom.xml b/project/pom.xml
index 5378bc9..79c7bbe 100644
--- a/project/pom.xml
+++ b/project/pom.xml
@@ -233,6 +233,8 @@
     <auto-service.version>1.0-rc2</auto-service.version>
     <auto-value.version>1.1</auto-value.version>
     <java-xmlbuilder.version>1.1</java-xmlbuilder.version>
+    <osgi.version>4.2.0</osgi.version>
+    <osgi.compendium.version>${osgi.version}</osgi.compendium.version>
     <http.proxyHost />
     <http.proxyPort />
     
<jclouds.wire.httpstream.url>http://archive.apache.org/dist/commons/logging/binaries/commons-logging-1.1.1-bin.tar.gz</jclouds.wire.httpstream.url>
@@ -362,6 +364,16 @@
         <artifactId>java-xmlbuilder</artifactId>
         <version>${java-xmlbuilder.version}</version>
       </dependency>
+      <dependency>
+        <groupId>org.osgi</groupId>
+        <artifactId>org.osgi.core</artifactId>
+        <version>${osgi.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.osgi</groupId>
+        <artifactId>org.osgi.compendium</artifactId>
+        <version>${osgi.compendium.version}</version>
+      </dependency>
     </dependencies>
   </dependencyManagement>
   <dependencies>

http://git-wip-us.apache.org/repos/asf/jclouds/blob/0b48d4a2/resources/modernizer_exclusions.txt
----------------------------------------------------------------------
diff --git a/resources/modernizer_exclusions.txt 
b/resources/modernizer_exclusions.txt
index 916934b..24b9220 100644
--- a/resources/modernizer_exclusions.txt
+++ b/resources/modernizer_exclusions.txt
@@ -20,3 +20,4 @@ com/google/common/primitives/Longs.compare:(JJ)I
 com/google/inject/Inject
 com/google/inject/Provider
 java/lang/StringBuffer."<init>":()V
+java/util/Hashtable."<init>":(I)V

http://git-wip-us.apache.org/repos/asf/jclouds/blob/0b48d4a2/scriptbuilder/pom.xml
----------------------------------------------------------------------
diff --git a/scriptbuilder/pom.xml b/scriptbuilder/pom.xml
index df80961..79782e3 100644
--- a/scriptbuilder/pom.xml
+++ b/scriptbuilder/pom.xml
@@ -59,7 +59,6 @@
     <dependency>
       <groupId>org.osgi</groupId>
       <artifactId>org.osgi.core</artifactId>
-      <version>4.2.0</version>
       <scope>provided</scope>
     </dependency>
   </dependencies>

http://git-wip-us.apache.org/repos/asf/jclouds/blob/0b48d4a2/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functionloader/osgi/BundleFunctionLoader.java
----------------------------------------------------------------------
diff --git 
a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functionloader/osgi/BundleFunctionLoader.java
 
b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functionloader/osgi/BundleFunctionLoader.java
index 518a92e..de5db8e 100644
--- 
a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functionloader/osgi/BundleFunctionLoader.java
+++ 
b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functionloader/osgi/BundleFunctionLoader.java
@@ -20,7 +20,7 @@ import java.io.IOException;
 import java.net.URL;
 import java.util.Dictionary;
 import java.util.Enumeration;
-import java.util.HashMap;
+import java.util.Hashtable;
 
 import org.jclouds.scriptbuilder.domain.OsFamily;
 import org.jclouds.scriptbuilder.domain.ShellToken;
@@ -100,7 +100,7 @@ public class BundleFunctionLoader implements FunctionLoader 
{
 
    private void registerFunction(String functions) {
       String[] className = { FunctionLoader.class.getName() };
-      Dictionary dictionary = new HashMap<String, Object>();
+      Dictionary<String, Object> dictionary = new Hashtable<String, Object>(1);
       dictionary.put("function", functions);
       registration = bundleContext.registerService(className, this, 
dictionary);
    }

Reply via email to