You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org> on 2010/12/01 03:14:16 UTC

[jira] Created: (MYFACES-2986) Provide an interface to override how to find spi interfaces

Provide an interface to override how to find spi interfaces
-----------------------------------------------------------

                 Key: MYFACES-2986
                 URL: https://issues.apache.org/jira/browse/MYFACES-2986
             Project: MyFaces Core
          Issue Type: Improvement
          Components: JSR-314
    Affects Versions: 2.0.2
            Reporter: Leonardo Uribe
            Assignee: Leonardo Uribe


This is the last step to solve MYFACES-2944 and MYFACES-2945 problem related to OSGi and SPI. Now it is possible to call 

ServiceLoaderFinderFactory.setServiceLoaderFinder(ExternalContext ectx, ServiceLoaderFinder slp)

or 

ServiceLoaderFinderFactory.setServiceLoaderFinder(ServletContext ctx, ServiceLoaderFinder slp)

Just before initialization to set a ServiceLoaderFinder that will be used later to locate SPI interfaces. In this way, it is possible to provide a code that looks SPI interfaces using OSGi bundles.


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


[jira] Resolved: (MYFACES-2986) Provide an interface to override how to find spi interfaces

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/MYFACES-2986?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leonardo Uribe resolved MYFACES-2986.
-------------------------------------

    Resolution: Fixed

1) Ok, I committed the necessary changes.

2) Unfortunately in this point we only have an ExternalContext instance, so we can't check for project stage. I added a descriptive warning message indicating what's happening and the action taken. I think is the best we can do. Anyway, I already restored the code to override a Factory (allow AnnotationProviderFactory.setAnnotationProviderFactory ) so in the worst case users could create a custom initializer and call this method if something is not well configured.

> Provide an interface to override how to find spi interfaces
> -----------------------------------------------------------
>
>                 Key: MYFACES-2986
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2986
>             Project: MyFaces Core
>          Issue Type: Improvement
>          Components: JSR-314
>    Affects Versions: 2.0.2
>            Reporter: Leonardo Uribe
>            Assignee: Leonardo Uribe
>             Fix For: 2.0.3-SNAPSHOT
>
>         Attachments: MYFACES-2986-2.patch
>
>
> This is the last step to solve MYFACES-2944 and MYFACES-2945 problem related to OSGi and SPI. Now it is possible to call 
> ServiceLoaderFinderFactory.setServiceLoaderFinder(ExternalContext ectx, ServiceLoaderFinder slp)
> or 
> ServiceLoaderFinderFactory.setServiceLoaderFinder(ServletContext ctx, ServiceLoaderFinder slp)
> Just before initialization to set a ServiceLoaderFinder that will be used later to locate SPI interfaces. In this way, it is possible to provide a code that looks SPI interfaces using OSGi bundles.

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


[jira] Commented: (MYFACES-2986) Provide an interface to override how to find spi interfaces

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2986?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12965544#action_12965544 ] 

Leonardo Uribe commented on MYFACES-2986:
-----------------------------------------

If no objections, I'll commit this code soon. Note the proposed patch removes commons-discovery dependency.

> Provide an interface to override how to find spi interfaces
> -----------------------------------------------------------
>
>                 Key: MYFACES-2986
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2986
>             Project: MyFaces Core
>          Issue Type: Improvement
>          Components: JSR-314
>    Affects Versions: 2.0.2
>            Reporter: Leonardo Uribe
>            Assignee: Leonardo Uribe
>         Attachments: MYFACES-2986-1.patch
>
>
> This is the last step to solve MYFACES-2944 and MYFACES-2945 problem related to OSGi and SPI. Now it is possible to call 
> ServiceLoaderFinderFactory.setServiceLoaderFinder(ExternalContext ectx, ServiceLoaderFinder slp)
> or 
> ServiceLoaderFinderFactory.setServiceLoaderFinder(ServletContext ctx, ServiceLoaderFinder slp)
> Just before initialization to set a ServiceLoaderFinder that will be used later to locate SPI interfaces. In this way, it is possible to provide a code that looks SPI interfaces using OSGi bundles.

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


[jira] Reopened: (MYFACES-2986) Provide an interface to override how to find spi interfaces

Posted by "Jakob Korherr (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/MYFACES-2986?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jakob Korherr reopened MYFACES-2986:
------------------------------------


..some comments to the patch (which was committed a bit too fast)..

> Provide an interface to override how to find spi interfaces
> -----------------------------------------------------------
>
>                 Key: MYFACES-2986
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2986
>             Project: MyFaces Core
>          Issue Type: Improvement
>          Components: JSR-314
>    Affects Versions: 2.0.2
>            Reporter: Leonardo Uribe
>            Assignee: Leonardo Uribe
>             Fix For: 2.0.3-SNAPSHOT
>
>         Attachments: MYFACES-2986-2.patch
>
>
> This is the last step to solve MYFACES-2944 and MYFACES-2945 problem related to OSGi and SPI. Now it is possible to call 
> ServiceLoaderFinderFactory.setServiceLoaderFinder(ExternalContext ectx, ServiceLoaderFinder slp)
> or 
> ServiceLoaderFinderFactory.setServiceLoaderFinder(ServletContext ctx, ServiceLoaderFinder slp)
> Just before initialization to set a ServiceLoaderFinder that will be used later to locate SPI interfaces. In this way, it is possible to provide a code that looks SPI interfaces using OSGi bundles.

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


[jira] Commented: (MYFACES-2986) Provide an interface to override how to find spi interfaces

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2986?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12965745#action_12965745 ] 

Leonardo Uribe commented on MYFACES-2986:
-----------------------------------------

1) Ok, use ServiceProviderFinder sounds better, so I commited the necessary changes.

2) Well, in theory in the classpath there will not be multiple SPI implementations, because the idea is each server container provide its own implementations (note LifecycleProvider is an exception to this rule). Pick the first one is the same as commons-discovery does. About the ordering problem, we can't do too much, because it is a problem related to SPI itself. But anyway, we always provide two ways to override a SPI provider. For example, if someone wants to override AnnotationProvider it can create a custom one under this key:

META-INF/services/org.apache.myfaces.spi.AnnotationProvider

or he/she can override the factory to define a custom ordering or something else:

META-INF/services/org.apache.myfaces.spi.AnnotationProviderFactory

But maybe we should log an informative message indicating there are two possible SPI providers, instead prevent initialize myfaces.

> Provide an interface to override how to find spi interfaces
> -----------------------------------------------------------
>
>                 Key: MYFACES-2986
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2986
>             Project: MyFaces Core
>          Issue Type: Improvement
>          Components: JSR-314
>    Affects Versions: 2.0.2
>            Reporter: Leonardo Uribe
>            Assignee: Leonardo Uribe
>             Fix For: 2.0.3-SNAPSHOT
>
>         Attachments: MYFACES-2986-2.patch
>
>
> This is the last step to solve MYFACES-2944 and MYFACES-2945 problem related to OSGi and SPI. Now it is possible to call 
> ServiceLoaderFinderFactory.setServiceLoaderFinder(ExternalContext ectx, ServiceLoaderFinder slp)
> or 
> ServiceLoaderFinderFactory.setServiceLoaderFinder(ServletContext ctx, ServiceLoaderFinder slp)
> Just before initialization to set a ServiceLoaderFinder that will be used later to locate SPI interfaces. In this way, it is possible to provide a code that looks SPI interfaces using OSGi bundles.

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


[jira] Commented: (MYFACES-2986) Provide an interface to override how to find spi interfaces

Posted by "Jakob Korherr (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2986?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12965738#action_12965738 ] 

Jakob Korherr commented on MYFACES-2986:
----------------------------------------

The patch looks good! It is very great that we can finally get rid of commons-discovery!

Two comments:

1) I don't really like the name "ServiceLoaderFinder". This would suggest a class which finds "ServiceLoaders", but it actually finds ServiceProviders. Thus I'd like to propose to change the name to "ServiceProviderFinder".

2) the patch always uses the first SPI class from the List:

if (classList != null && !classList.isEmpty())
{
    return ClassUtils.newInstance(classList.get(0));
}

I think it would be better here to throw an Exception if there is more than one fitting SPI implementation, because right now it is not really clear which one will be used in this case ( --> does the default ServiceLoaderFinder always return the service classes in the same order?).

WDYT?

> Provide an interface to override how to find spi interfaces
> -----------------------------------------------------------
>
>                 Key: MYFACES-2986
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2986
>             Project: MyFaces Core
>          Issue Type: Improvement
>          Components: JSR-314
>    Affects Versions: 2.0.2
>            Reporter: Leonardo Uribe
>            Assignee: Leonardo Uribe
>             Fix For: 2.0.3-SNAPSHOT
>
>         Attachments: MYFACES-2986-2.patch
>
>
> This is the last step to solve MYFACES-2944 and MYFACES-2945 problem related to OSGi and SPI. Now it is possible to call 
> ServiceLoaderFinderFactory.setServiceLoaderFinder(ExternalContext ectx, ServiceLoaderFinder slp)
> or 
> ServiceLoaderFinderFactory.setServiceLoaderFinder(ServletContext ctx, ServiceLoaderFinder slp)
> Just before initialization to set a ServiceLoaderFinder that will be used later to locate SPI interfaces. In this way, it is possible to provide a code that looks SPI interfaces using OSGi bundles.

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


[jira] Updated: (MYFACES-2986) Provide an interface to override how to find spi interfaces

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/MYFACES-2986?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leonardo Uribe updated MYFACES-2986:
------------------------------------

    Status: Patch Available  (was: Open)

> Provide an interface to override how to find spi interfaces
> -----------------------------------------------------------
>
>                 Key: MYFACES-2986
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2986
>             Project: MyFaces Core
>          Issue Type: Improvement
>          Components: JSR-314
>    Affects Versions: 2.0.2
>            Reporter: Leonardo Uribe
>            Assignee: Leonardo Uribe
>         Attachments: MYFACES-2986-1.patch
>
>
> This is the last step to solve MYFACES-2944 and MYFACES-2945 problem related to OSGi and SPI. Now it is possible to call 
> ServiceLoaderFinderFactory.setServiceLoaderFinder(ExternalContext ectx, ServiceLoaderFinder slp)
> or 
> ServiceLoaderFinderFactory.setServiceLoaderFinder(ServletContext ctx, ServiceLoaderFinder slp)
> Just before initialization to set a ServiceLoaderFinder that will be used later to locate SPI interfaces. In this way, it is possible to provide a code that looks SPI interfaces using OSGi bundles.

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


[jira] Commented: (MYFACES-2986) Provide an interface to override how to find spi interfaces

Posted by "Jakob Korherr (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2986?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12965786#action_12965786 ] 

Jakob Korherr commented on MYFACES-2986:
----------------------------------------

Ok, good solution :)

> Provide an interface to override how to find spi interfaces
> -----------------------------------------------------------
>
>                 Key: MYFACES-2986
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2986
>             Project: MyFaces Core
>          Issue Type: Improvement
>          Components: JSR-314
>    Affects Versions: 2.0.2
>            Reporter: Leonardo Uribe
>            Assignee: Leonardo Uribe
>             Fix For: 2.0.3-SNAPSHOT
>
>         Attachments: MYFACES-2986-2.patch
>
>
> This is the last step to solve MYFACES-2944 and MYFACES-2945 problem related to OSGi and SPI. Now it is possible to call 
> ServiceLoaderFinderFactory.setServiceLoaderFinder(ExternalContext ectx, ServiceLoaderFinder slp)
> or 
> ServiceLoaderFinderFactory.setServiceLoaderFinder(ServletContext ctx, ServiceLoaderFinder slp)
> Just before initialization to set a ServiceLoaderFinder that will be used later to locate SPI interfaces. In this way, it is possible to provide a code that looks SPI interfaces using OSGi bundles.

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


[jira] Commented: (MYFACES-2986) Provide an interface to override how to find spi interfaces

Posted by "Jakob Korherr (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2986?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12965748#action_12965748 ] 

Jakob Korherr commented on MYFACES-2986:
----------------------------------------

1) OK, great! But please also change DefaultServiceLoaderFinder to DefaultServiceProviderFinder (I think you forgot this one in your last commit)

2) Yes, in theory there should only be (maximum) one SPI impl per SPI, however a user may misconfigure his classpath or copy/paste the wrong code and thus get two SPI impls for one SPI. In this case it is not clear what happens, so we should really throw an exception (at least when running in development mode).

> Provide an interface to override how to find spi interfaces
> -----------------------------------------------------------
>
>                 Key: MYFACES-2986
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2986
>             Project: MyFaces Core
>          Issue Type: Improvement
>          Components: JSR-314
>    Affects Versions: 2.0.2
>            Reporter: Leonardo Uribe
>            Assignee: Leonardo Uribe
>             Fix For: 2.0.3-SNAPSHOT
>
>         Attachments: MYFACES-2986-2.patch
>
>
> This is the last step to solve MYFACES-2944 and MYFACES-2945 problem related to OSGi and SPI. Now it is possible to call 
> ServiceLoaderFinderFactory.setServiceLoaderFinder(ExternalContext ectx, ServiceLoaderFinder slp)
> or 
> ServiceLoaderFinderFactory.setServiceLoaderFinder(ServletContext ctx, ServiceLoaderFinder slp)
> Just before initialization to set a ServiceLoaderFinder that will be used later to locate SPI interfaces. In this way, it is possible to provide a code that looks SPI interfaces using OSGi bundles.

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


[jira] Updated: (MYFACES-2986) Provide an interface to override how to find spi interfaces

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/MYFACES-2986?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leonardo Uribe updated MYFACES-2986:
------------------------------------

       Resolution: Fixed
    Fix Version/s: 2.0.3-SNAPSHOT
           Status: Resolved  (was: Patch Available)

> Provide an interface to override how to find spi interfaces
> -----------------------------------------------------------
>
>                 Key: MYFACES-2986
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2986
>             Project: MyFaces Core
>          Issue Type: Improvement
>          Components: JSR-314
>    Affects Versions: 2.0.2
>            Reporter: Leonardo Uribe
>            Assignee: Leonardo Uribe
>             Fix For: 2.0.3-SNAPSHOT
>
>         Attachments: MYFACES-2986-2.patch
>
>
> This is the last step to solve MYFACES-2944 and MYFACES-2945 problem related to OSGi and SPI. Now it is possible to call 
> ServiceLoaderFinderFactory.setServiceLoaderFinder(ExternalContext ectx, ServiceLoaderFinder slp)
> or 
> ServiceLoaderFinderFactory.setServiceLoaderFinder(ServletContext ctx, ServiceLoaderFinder slp)
> Just before initialization to set a ServiceLoaderFinder that will be used later to locate SPI interfaces. In this way, it is possible to provide a code that looks SPI interfaces using OSGi bundles.

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