You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by fm...@apache.org on 2011/10/09 20:09:13 UTC

svn commit: r1180676 - in /felix/trunk/scr/src: main/java/org/apache/felix/scr/impl/BundleComponentActivator.java test/java/org/apache/felix/scr/impl/BundleComponentActivatorTest.java

Author: fmeschbe
Date: Sun Oct  9 18:09:12 2011
New Revision: 1180676

URL: http://svn.apache.org/viewvc?rev=1180676&view=rev
Log:
FELIX-2895 Don't use getResource any longer to find descriptors. The findEntry/findEntries methods are provided explicitly to access such configuration information. Also we do not want to use the class loaders to find the resource since these might also span imported packages - or worse - required bundles.

Modified:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/BundleComponentActivatorTest.java

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java?rev=1180676&r1=1180675&r2=1180676&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java Sun Oct  9 18:09:12 2011
@@ -164,18 +164,6 @@ public class BundleComponentActivator im
             return new URL[0];
         }
 
-        // for compatibility with previoues versions (<= 1.0.8) use getResource() for non wildcarded entries
-        if ( descriptorLocation.indexOf( "*" ) == -1 )
-        {
-            final URL descriptor = bundle.getResource( descriptorLocation );
-            if ( descriptor == null )
-            {
-                return new URL[0];
-            }
-            return new URL[]
-                { descriptor };
-        }
-
         // split pattern and path
         final int lios = descriptorLocation.lastIndexOf( "/" );
         final String path;

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/BundleComponentActivatorTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/BundleComponentActivatorTest.java?rev=1180676&r1=1180675&r2=1180676&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/BundleComponentActivatorTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/BundleComponentActivatorTest.java Sun Oct  9 18:09:12 2011
@@ -78,22 +78,26 @@ public class BundleComponentActivatorTes
      *
      * @throws MalformedURLException unexpected
      */
-    public void test_findDescriptors_withNonWildcardLocation()
-        throws MalformedURLException
+    public void test_findDescriptors_withNonWildcardLocation() throws MalformedURLException
     {
-        URL descriptor = new URL( "file:foo.xml" );
-        final Bundle bundle = (Bundle) EasyMock.createNiceMock( Bundle.class );
-        EasyMock.expect( bundle.getResource( "/some/location/foo.xml" ) ).andReturn( descriptor );
+        final URL[] descriptors = new URL[]
+            { new URL( "file:foo.xml" ) };
+        final Enumeration de = new Vector( Arrays.asList( descriptors ) ).elements();
+        final Bundle bundle = ( Bundle ) EasyMock.createNiceMock( Bundle.class );
+        EasyMock.expect( bundle.findEntries( "/some/location", "foo.xml", false ) ).andReturn( de );
 
-        EasyMock.replay( new Object[]{ bundle } );
+        EasyMock.replay( new Object[]
+            { bundle } );
         final URL[] urls = BundleComponentActivator.findDescriptors( bundle, "/some/location/foo.xml" );
-        EasyMock.verify( new Object[]{ bundle } );
+        EasyMock.verify( new Object[]
+            { bundle } );
 
         assertNotNull( "Descriptor array is not null", urls );
         assertEquals( "Descriptor length", 1, urls.length );
-        assertEquals( "Descriptor", descriptor, urls[ 0 ] );
+        assertEquals( "Descriptor", descriptors[0], urls[0] );
     }
 
+
     public void findDescriptors_withWildcardLocation( final String location,
                                                       final String path,
                                                       final String filePattern )