You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Sahoo <Sa...@Sun.COM> on 2009/06/07 09:59:20 UTC

How to iterate over all the entries of a bundle? [Ignore the earlier email]

[Please ignore the earlier mail where I had incorrectly set the Reply-To 
header to some other address.]

Hi,

Can anyone tell me how I can iterate over all the entries of a bundle
jar? I don't want any entries from the fragment. So, I thought
Bundle.getEntryPaths() would do the job, but I don't see the desired
behavior. For testing purpose, I am using the following code:

    void printEntryPaths(Bundle b, String s) {
        Enumeration e = b.getEntryPaths(s);
        if (e!=null) {
            while (e.hasMoreElements()) {
                String next = (String)e.nextElement();
                System.out.println(next);
                printEntryPaths(b, next);
            }
        }
    }

    If I call printEntryPaths(someBundle, "/"), it should print all the
entries, right? But, it does not. I test it for a bundle for which "jar"
command prints the following:
jar tf /tmp/someBundle.jar

META-INF/MANIFEST.MF
WEB-INF/web.xml
index.html

For this bundle, the above code only prints:
index.html

I think it is related to the fact that there are no directory entries
for META-INF and WEB-INF in the jar.

Thanks,
Sahoo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: How to iterate over all the entries of a bundle? [Ignore the earlier email]

Posted by Sahoo <Sa...@Sun.COM>.
Stuart McCulloch wrote:
> as I understand it jars without interim directory entries are strictly not
> valid according
> to the official zip spec - however, most jar handling routines are typically
> lenient and
> will fill in missing directories where necessary
>
> in this case Felix could detect that there are entries named
> "WEB-INF/...etc.." and add
> WEB-INF to the entries at the root - I suspect this is what Equinox and
> Knopflerfish do
>
>   
I think this will be a good thing to do in Felix as well. I have filed 
an enhancement type bug:
https://issues.apache.org/jira/browse/FELIX-1210

Thanks,
Sahoo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: How to iterate over all the entries of a bundle? [Ignore the earlier email]

Posted by Stuart McCulloch <mc...@gmail.com>.
2009/6/8 Sahoo <Sa...@sun.com>

> Richard S. Hall wrote:
>
>> First, I am not sure whether that method only returns the bundle content
>> entries...you might need to verify that and create an issue if it is
>> returning fragment entries too.
>>
> I will try that when I have time.
>
>> If I remember correctly, getEntryPaths() works like typing "ls", in that
>> it shows you the contents of the requested directory. Then you need to
>> recurse downward for each subdirectory, which are the names ending with "/".
>>
> That's what the code I sent earlier tries to do.
>
>> If the JAR does not have directory entries, then you will not see them in
>> the output, which will make it difficult to traverse. This is mentioned in
>> the spec.
>>
> This was where I felt the spec was not very clear when I read it. The spec
> does not define what "sub-path" means, does it? In the example jar file,
> there is no directory by name WEB-INF/. Then, how can WEB-INF be the
> sub-path of WEB-INF/web.xml?
>
> Are you saying the jar itself is not a valid? If it is a valid jar, how can
> one iterate over all the entries? An alternative trick is OK with me as
> well.
>

as I understand it jars without interim directory entries are strictly not
valid according
to the official zip spec - however, most jar handling routines are typically
lenient and
will fill in missing directories where necessary

in this case Felix could detect that there are entries named
"WEB-INF/...etc.." and add
WEB-INF to the entries at the root - I suspect this is what Equinox and
Knopflerfish do

Thanks,
> Sahoo
>
> ---------------------------------------------------------------------
>
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 
Cheers, Stuart

Re: How to iterate over all the entries of a bundle? [Ignore the earlier email]

Posted by Sahoo <Sa...@Sun.COM>.

Richard S. Hall wrote:
> First, I am not sure whether that method only returns the bundle 
> content entries...you might need to verify that and create an issue if 
> it is returning fragment entries too.
I will try that when I have time.
>
> If I remember correctly, getEntryPaths() works like typing "ls", in 
> that it shows you the contents of the requested directory. Then you 
> need to recurse downward for each subdirectory, which are the names 
> ending with "/".
That's what the code I sent earlier tries to do.
>
> If the JAR does not have directory entries, then you will not see them 
> in the output, which will make it difficult to traverse. This is 
> mentioned in the spec.
This was where I felt the spec was not very clear when I read it. The 
spec does not define what "sub-path" means, does it? In the example jar 
file, there is no directory by name WEB-INF/. Then, how can WEB-INF be 
the sub-path of WEB-INF/web.xml?


Are you saying the jar itself is not a valid? If it is a valid jar, how 
can one iterate over all the entries? An alternative trick is OK with me 
as well.

Thanks,
Sahoo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: How to iterate over all the entries of a bundle? [Ignore the earlier email]

Posted by "Richard S. Hall" <he...@ungoverned.org>.
First, I am not sure whether that method only returns the bundle content 
entries...you might need to verify that and create an issue if it is 
returning fragment entries too.

If I remember correctly, getEntryPaths() works like typing "ls", in that 
it shows you the contents of the requested directory. Then you need to 
recurse downward for each subdirectory, which are the names ending with "/".

If the JAR does not have directory entries, then you will not see them 
in the output, which will make it difficult to traverse. This is 
mentioned in the spec.

-> richard

On 6/7/09 12:59 AM, Sahoo wrote:
> [Please ignore the earlier mail where I had incorrectly set the 
> Reply-To header to some other address.]
>
> Hi,
>
> Can anyone tell me how I can iterate over all the entries of a bundle
> jar? I don't want any entries from the fragment. So, I thought
> Bundle.getEntryPaths() would do the job, but I don't see the desired
> behavior. For testing purpose, I am using the following code:
>
>    void printEntryPaths(Bundle b, String s) {
>        Enumeration e = b.getEntryPaths(s);
>        if (e!=null) {
>            while (e.hasMoreElements()) {
>                String next = (String)e.nextElement();
>                System.out.println(next);
>                printEntryPaths(b, next);
>            }
>        }
>    }
>
>    If I call printEntryPaths(someBundle, "/"), it should print all the
> entries, right? But, it does not. I test it for a bundle for which "jar"
> command prints the following:
> jar tf /tmp/someBundle.jar
>
> META-INF/MANIFEST.MF
> WEB-INF/web.xml
> index.html
>
> For this bundle, the above code only prints:
> index.html
>
> I think it is related to the fact that there are no directory entries
> for META-INF and WEB-INF in the jar.
>
> Thanks,
> Sahoo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org