You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Guillaume Sauthier (JIRA)" <ji...@apache.org> on 2008/01/17 17:24:34 UTC

[jira] Created: (FELIX-467) R4SearchPolicyCore.findResources(String) do not aggregate the Enumeration founds

R4SearchPolicyCore.findResources(String) do not aggregate the Enumeration founds
--------------------------------------------------------------------------------

                 Key: FELIX-467
                 URL: https://issues.apache.org/jira/browse/FELIX-467
             Project: Felix
          Issue Type: Bug
          Components: Framework
    Affects Versions: 1.0.0
            Reporter: Guillaume Sauthier


This issue is linked to FELIX-466

The R4SearchPolicyCore.findResources(String) method just exits early on a first hit, and doesn't continue into imported packages.

It should aggregate the different hits and return all matching resources.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FELIX-467) R4SearchPolicyCore.findResources(String) do not aggregate the Enumeration founds

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-467?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Richard S. Hall updated FELIX-467:
----------------------------------

    Attachment: FELIX-467-rick.patch

> R4SearchPolicyCore.findResources(String) do not aggregate the Enumeration founds
> --------------------------------------------------------------------------------
>
>                 Key: FELIX-467
>                 URL: https://issues.apache.org/jira/browse/FELIX-467
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 1.0.0
>            Reporter: Guillaume Sauthier
>         Attachments: FELIX-467-karl.patch, FELIX-467-rick.patch, FELIX-467-tests-bundles.zip, FELIX-467.patch
>
>
> This issue is linked to FELIX-466
> The R4SearchPolicyCore.findResources(String) method just exits early on a first hit, and doesn't continue into imported packages.
> It should aggregate the different hits and return all matching resources.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (FELIX-467) R4SearchPolicyCore.findResources(String) do not aggregate the Enumeration founds

Posted by "Guillaume Sauthier (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-467?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Guillaume Sauthier closed FELIX-467.
------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.0.3

Thanks for the massaging guys :)

> R4SearchPolicyCore.findResources(String) do not aggregate the Enumeration founds
> --------------------------------------------------------------------------------
>
>                 Key: FELIX-467
>                 URL: https://issues.apache.org/jira/browse/FELIX-467
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 1.0.0
>            Reporter: Guillaume Sauthier
>             Fix For: 1.0.3
>
>         Attachments: FELIX-467-karl.patch, FELIX-467-rick.patch, FELIX-467-tests-bundles.zip, FELIX-467.patch
>
>
> This issue is linked to FELIX-466
> The R4SearchPolicyCore.findResources(String) method just exits early on a first hit, and doesn't continue into imported packages.
> It should aggregate the different hits and return all matching resources.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-467) R4SearchPolicyCore.findResources(String) do not aggregate the Enumeration founds

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-467?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12561130#action_12561130 ] 

Richard S. Hall commented on FELIX-467:
---------------------------------------

I have some doubts about the proposed solution the more I think about it. I am not sure what we can do about this issue, but think about the case we are proposing where we aggregate results from the boot class path as well as from imports and local class path.

If we think about it logically, findResources() returns resources that are accessible from the bundle's class path. However, it would never be possible for the bundle to access classes from the boot class path, imports, and local class path at the same time.

Consider a hypothetical case, where we want to query for some component.xml file which gives us information about component classes we can load and instantiate. If we aggregate everything, it is possible that we will return /org/foo/component.xml from the boot class path, imports, and the local class path, where each one defines potentially different classes (e.g., BootClass.class, ImportClass.class, LocalClass.class) to be loaded. If the bundle then tried to load class corresponding to each resource, the class load will only be delegated to the boot class path, it would never search imports or the local class path and thus never be able to load those classes even though it discovered the corresponding resources. Likewise if we were only talking about imports and the local class path.

In short, it almost seems like our result needs to be filtered so that first found package wins and we filter out later discovered resources of the same package, i.e., the same behavior for resources as for classes. Of course, this would be a pain in the butt.

As a side note, I applied these patches locally and we still pass our normal TCK tests, so we could just go with the proposed approach and not be so pedantic.

Or perhaps my reasoning is just all wrong...anyone?

> R4SearchPolicyCore.findResources(String) do not aggregate the Enumeration founds
> --------------------------------------------------------------------------------
>
>                 Key: FELIX-467
>                 URL: https://issues.apache.org/jira/browse/FELIX-467
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 1.0.0
>            Reporter: Guillaume Sauthier
>         Attachments: FELIX-467-tests-bundles.zip, FELIX-467.patch
>
>
> This issue is linked to FELIX-466
> The R4SearchPolicyCore.findResources(String) method just exits early on a first hit, and doesn't continue into imported packages.
> It should aggregate the different hits and return all matching resources.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-467) R4SearchPolicyCore.findResources(String) do not aggregate the Enumeration founds

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-467?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12561433#action_12561433 ] 

Richard S. Hall commented on FELIX-467:
---------------------------------------

Even with resources, I would argue that this is still somewhat problematic. For example, perhaps I want to set up the framework so that I am the sole provider of the package org.foo. To achieve this, I put org.foo on the boot delegation property. The end result of the proposed approach is that for classes I am the sole provider, but for resources, it is possible for other people to provide resources too.

I am not arguing that this is a hugely important issue, but it is an issue nonetheless. The real question is whether we want to ignore it (either completely or just for now).

> R4SearchPolicyCore.findResources(String) do not aggregate the Enumeration founds
> --------------------------------------------------------------------------------
>
>                 Key: FELIX-467
>                 URL: https://issues.apache.org/jira/browse/FELIX-467
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 1.0.0
>            Reporter: Guillaume Sauthier
>         Attachments: FELIX-467-tests-bundles.zip, FELIX-467.patch
>
>
> This issue is linked to FELIX-466
> The R4SearchPolicyCore.findResources(String) method just exits early on a first hit, and doesn't continue into imported packages.
> It should aggregate the different hits and return all matching resources.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FELIX-467) R4SearchPolicyCore.findResources(String) do not aggregate the Enumeration founds

Posted by "Guillaume Sauthier (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-467?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Guillaume Sauthier updated FELIX-467:
-------------------------------------

    Attachment: FELIX-467-tests-bundles.zip

Here are a use case / test for this issue.

* 2 bundles :
** Importer, that have a resource locally and that define an import on the package resource
** Exporter, that only export a package that contains a resource file

The importer use its bundle ClassLoader to get access to the resources.

The zip contains 3 eclipse project (1 exporter and 2 importers: the first one that do Import-Package and the second one that do a DynamicImport-Package)

> R4SearchPolicyCore.findResources(String) do not aggregate the Enumeration founds
> --------------------------------------------------------------------------------
>
>                 Key: FELIX-467
>                 URL: https://issues.apache.org/jira/browse/FELIX-467
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 1.0.0
>            Reporter: Guillaume Sauthier
>         Attachments: FELIX-467-tests-bundles.zip, FELIX-467.patch
>
>
> This issue is linked to FELIX-466
> The R4SearchPolicyCore.findResources(String) method just exits early on a first hit, and doesn't continue into imported packages.
> It should aggregate the different hits and return all matching resources.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-467) R4SearchPolicyCore.findResources(String) do not aggregate the Enumeration founds

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-467?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12562555#action_12562555 ] 

Richard S. Hall commented on FELIX-467:
---------------------------------------

I massaged it a little more, mostly just adding support get getResources() for module wires, since it wasn't implemented yet. I think I will go ahead and commit this...we can always continue to make tweaks on it.

Guillaume, if this still resolves your issue, please close. Otherwise, suggest more massaging. :-)

> R4SearchPolicyCore.findResources(String) do not aggregate the Enumeration founds
> --------------------------------------------------------------------------------
>
>                 Key: FELIX-467
>                 URL: https://issues.apache.org/jira/browse/FELIX-467
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 1.0.0
>            Reporter: Guillaume Sauthier
>         Attachments: FELIX-467-karl.patch, FELIX-467-rick.patch, FELIX-467-tests-bundles.zip, FELIX-467.patch
>
>
> This issue is linked to FELIX-466
> The R4SearchPolicyCore.findResources(String) method just exits early on a first hit, and doesn't continue into imported packages.
> It should aggregate the different hits and return all matching resources.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-467) R4SearchPolicyCore.findResources(String) do not aggregate the Enumeration founds

Posted by "Guillaume Sauthier (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-467?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12561400#action_12561400 ] 

Guillaume Sauthier commented on FELIX-467:
------------------------------------------

Thanks for your review Richard

The mean of findResources() in a ClassLoader if to find multiple files at different location, so I cannot see why I should not be able to browse resources from the boot class path and imports and local classpath.

You assume that theses resources are classes centric, and in this case I follow your meaning: If the external resource define a class (that the exporter bundle probably have access to), how can we be sure that the importer bundle will be able to load the defined classes.
OK, this will be the scenario if the importer do not have managed that kind of issue.

And this is an application issue, no ? This is the job of the application to assume that sometimes, ClassNotFoundExceptions are thrown and that it may be good to handle them :)

And if the resources are just images or sounds ? Does this mean anything that the importer bundle will not be able the exporter classes ?

> R4SearchPolicyCore.findResources(String) do not aggregate the Enumeration founds
> --------------------------------------------------------------------------------
>
>                 Key: FELIX-467
>                 URL: https://issues.apache.org/jira/browse/FELIX-467
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 1.0.0
>            Reporter: Guillaume Sauthier
>         Attachments: FELIX-467-tests-bundles.zip, FELIX-467.patch
>
>
> This issue is linked to FELIX-466
> The R4SearchPolicyCore.findResources(String) method just exits early on a first hit, and doesn't continue into imported packages.
> It should aggregate the different hits and return all matching resources.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-467) R4SearchPolicyCore.findResources(String) do not aggregate the Enumeration founds

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-467?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12561436#action_12561436 ] 

Richard S. Hall commented on FELIX-467:
---------------------------------------

For what its worth, Tom Watson says Equinox works like this:

-----

Here is what we do in Equinox.

1) First of all, we do not do anything tricky for 1.4 vs 1.5. We assume ClassLoader.getResources is final and always delegates to the boot class loader for every package.
2) For Bundle.getResources() we do not actually ask the ClassLoader.getResources. Instead we wire directly into the proper OSGi delegation model. This unfortunately means Bundle.getResources() and ClassLoader.getResources could potentially return different results depending on what was available from the boot class loader.

Lets ignore that little issue and assume we can override ClassLoader.getResources and do proper OSGi delegation. The process should look something like this:

1) Check to see if the resource is in the java/* namespace. If so *only* delegate to boot and return the Enumeration returned from boot.
2) Check to see if the resource is on the o.o.f.bootdelegation list. If so get the Enumeration from boot and pass the result to the next step.
3) Check to see if the resource is imported (using Import-Package). If so delegate to the exporter's local (and fragments) classpath and return the results in a compound Enumeration which includes the results from the previous step. If not imported then pass the incoming Enumeration to the next step.
4) Check to see if the resource is accessed from a required bundle (using Require-Bundle). If so delegate to each required bundle's local (and fragments) classpath which exports the requested resource package and compound the results with the incoming Enumeration. Pass the results to the next step.
5) Delegate to the local bundle's (and fragments) classpath. Compound the results with the incoming Enumeration and return the results.

----

This approach is slightly different than ours, but still can lead to a situation where packages that are boot delegated AND imported can be combined for resources. It is different than our proposal because it explicitly stops if the package is imported.

> R4SearchPolicyCore.findResources(String) do not aggregate the Enumeration founds
> --------------------------------------------------------------------------------
>
>                 Key: FELIX-467
>                 URL: https://issues.apache.org/jira/browse/FELIX-467
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 1.0.0
>            Reporter: Guillaume Sauthier
>         Attachments: FELIX-467-tests-bundles.zip, FELIX-467.patch
>
>
> This issue is linked to FELIX-466
> The R4SearchPolicyCore.findResources(String) method just exits early on a first hit, and doesn't continue into imported packages.
> It should aggregate the different hits and return all matching resources.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FELIX-467) R4SearchPolicyCore.findResources(String) do not aggregate the Enumeration founds

Posted by "Guillaume Sauthier (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-467?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Guillaume Sauthier updated FELIX-467:
-------------------------------------

    Attachment: FELIX-467.patch

This patch mainly change the R4SearchPolicyCore.findResources() method to create a combined enumeration of available resources.

I've added a CompoundEnumeration class that combine multiple Enumeration in a single one.
There are tests for this new Enumeration that are automatically launched by maven.

> R4SearchPolicyCore.findResources(String) do not aggregate the Enumeration founds
> --------------------------------------------------------------------------------
>
>                 Key: FELIX-467
>                 URL: https://issues.apache.org/jira/browse/FELIX-467
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 1.0.0
>            Reporter: Guillaume Sauthier
>         Attachments: FELIX-467.patch
>
>
> This issue is linked to FELIX-466
> The R4SearchPolicyCore.findResources(String) method just exits early on a first hit, and doesn't continue into imported packages.
> It should aggregate the different hits and return all matching resources.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FELIX-467) R4SearchPolicyCore.findResources(String) do not aggregate the Enumeration founds

Posted by "Karl Pauls (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-467?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Karl Pauls updated FELIX-467:
-----------------------------

    Attachment: FELIX-467-karl.patch

I massaged the proposed patch a bit and made it behave according to what equinox does. It seems to work for me - what do others think? In case we can agree on this patch I could still make it part of Felix 1.0.2...

> R4SearchPolicyCore.findResources(String) do not aggregate the Enumeration founds
> --------------------------------------------------------------------------------
>
>                 Key: FELIX-467
>                 URL: https://issues.apache.org/jira/browse/FELIX-467
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 1.0.0
>            Reporter: Guillaume Sauthier
>         Attachments: FELIX-467-karl.patch, FELIX-467-tests-bundles.zip, FELIX-467.patch
>
>
> This issue is linked to FELIX-466
> The R4SearchPolicyCore.findResources(String) method just exits early on a first hit, and doesn't continue into imported packages.
> It should aggregate the different hits and return all matching resources.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.