cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From egl...@apache.org
Subject svn commit: r695478 - in /cxf/sandbox/dosgi/dsw/cxf-dsw/src: main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java test/java/org/apache/cxf/dosgi/dsw/OsgiUtilsTest.java
Date Mon, 15 Sep 2008 14:14:45 GMT
Author: eglynn
Date: Mon Sep 15 07:14:44 2008
New Revision: 695478

URL: http://svn.apache.org/viewvc?rev=695478&view=rev
Log:
DOSGi patch from David Bosschaert.

Modified:
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/OsgiUtilsTest.java

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java?rev=695478&r1=695477&r2=695478&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java Mon
Sep 15 07:14:44 2008
@@ -56,7 +56,7 @@
     private static final String REMOTE_SERVICES_NS =
         "http://www.osgi.org/xmlns/rs/v1.0.0";
     
-    private static final String[] INTENT_MAP = {"/META-INF/osgi/intent-map.xml"};
+    static final String[] INTENT_MAP = {"/META-INF/osgi/intent-map.xml"};
     
     private static final String PROPERTY_NAME_ATTRIBUTE = "name";
     private static final String PROVIDE_INTERFACE_ATTRIBUTE = "interface";
@@ -266,6 +266,24 @@
     }
     
     public static IntentMap getIntentMap(BundleContext bundleContext) {
+        IntentMap im = readIntentMap(bundleContext);
+        if (im == null) {
+            // Couldn't read an intent map
+            LOG.log(Level.FINE, "Using default intent map");
+            im = new IntentMap();
+            im.setIntents(new HashMap<String, Object>());
+        }
+        return im;        
+    }
+    
+    static IntentMap readIntentMap(BundleContext bundleContext) {
+        for (String mapFile : INTENT_MAP) {
+            if (bundleContext.getBundle().getResource(mapFile) == null) {
+                LOG.info("Could not find intent map file " + mapFile);
+                return null;
+            }
+        }
+        
         try {
             OsgiBundleXmlApplicationContext ctx = 
                 new OsgiBundleXmlApplicationContext(INTENT_MAP);
@@ -277,10 +295,8 @@
             LOG.fine("retrieved intent map: " + im);
             return im;
         } catch (Throwable t) {
-            LOG.log(Level.WARNING, "intent map load failed: ", t);
-            IntentMap im = new IntentMap();
-            im.setIntents(new HashMap<String, Object>());
-            return im;
+            LOG.log(Level.WARNING, "Intent map load failed: ", t);
+            return null;
         }
     }
     

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/OsgiUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/OsgiUtilsTest.java?rev=695478&r1=695477&r2=695478&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/OsgiUtilsTest.java
(original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/OsgiUtilsTest.java
Mon Sep 15 07:14:44 2008
@@ -8,6 +8,7 @@
 import org.easymock.EasyMock;
 import org.easymock.IAnswer;
 import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.discovery.ServiceDescription;
 
@@ -39,4 +40,15 @@
         
         EasyMock.verify(sr);
     }
+    
+    public void testNoIntentMap() {
+        Bundle b = EasyMock.createNiceMock(Bundle.class);
+        EasyMock.replay(b);
+        BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+        EasyMock.expect(bc.getBundle()).andReturn(b).anyTimes();
+        EasyMock.replay(bc);
+        
+        assertNull(OsgiUtils.readIntentMap(bc));
+        assertNotNull(OsgiUtils.getIntentMap(bc));
+    }    
 }



Mime
View raw message