Are you expecting the resource OSGI-INF/text.txt to exist in nested jars
contain on the Bundle-ClassPath?  If not then you should simply use
Bundle.getEntry("OSGI-INF/text.txt") instead so you only search the raw
content of the bundle.  This also avoids having to create a class loader
for all bundles you are searching since Bundle.getResource requires a class
loader to be created if the bundle is resolved.

I agree with BJ a URL should be returned if the resource actually exists in
the bundle.

Tom




|------------>
| From:      |
|------------>
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
  |BJ Hargrave/Austin/i...@ibmus                                                
                                                                      |
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| To:        |
|------------>
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
  |OSGi Developer Mail List <[email protected]>                            
                                                                     |
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Date:      |
|------------>
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
  |03/16/2010 07:48 AM                                                          
                                                                     |
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Subject:   |
|------------>
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Re: [osgi-dev] Q on Bundle#getResource()                                     
                                                                     |
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|





I assume it will return the URL in both cases.
--



 BJ Hargrave
 Senior Technical Staff      office: +1 386 848
 Member, IBM                               1781
 OSGi Fellow and CTO of the  mobile: +1 386 848
 OSGi Alliance                             3788
 [email protected]







                                                                       
 From:        Ikuo Yamasaki <[email protected]>              
                                                                       
 To:          [email protected]                                
                                                                       
 Date:        2010/03/16 03:52                                         
                                                                       
 Subject:     [osgi-dev] Q on Bundle#getResource()                     
                                                                       
 Sent by:     [email protected]                           
                                                                       






Hi OSGi Exports,

I have questions on Bundle#getResource(String name).

Let me assume that bundle1 would like to get resource of
"OSGI-INF/text.txt" in the bundle JAR file.

Q1. Which should Bundle#getResource("OSGI-INF/test.txt") return,
                the URL of the resource or null ?

I expect the URL.

Q2. Which should Bundle#getResource("/OSGI-INF/test.txt") return,
                the URL of the resource or null ?

I expect the URL as well, but not sure.

The spec says "The name of the resource. See
java.lang.ClassLoader.getResource for a description
of the format of a resource name." I cannot find the any format of a
resource name in
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ClassLoader.html#getResource
(java.lang.String)


Best regards,

---------------------
NTT Cyber Solutions Laboratories

    Ikuo YAMASAKI
       E-mail: [email protected]
TEL +81-46-859-8537  FAX +81-46-855-1282


_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

<<inline: graycol.gif>>

<<inline: ecblank.gif>>

_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to