Yes, this is a missing feature in Guice --- to customize JIT binding.

I think the closest approximation that works is to inspect Binder and list up all injection points of ExtensionList<T> and add explicit bindings.

This should work until someone tries this with injectMembers()


On 10/06/2014 11:06 AM, nicolas de loof wrote:
afaik Guice don't allow us to do something like this :

@Inject Collection<BuildWrapperDescriptor> descriptors

would be really nice so we don't need
Jenkins.getInstance.getExtensionList(..)

2014-10-06 19:59 GMT+02:00 Kohsuke Kawaguchi <[email protected]
<mailto:[email protected]>>:


    Sorry, I missed this, my apologies. JavaOne week got in my way.

    Guice is firmly integrated into the core now, as you saw. All the
    extension impls (stuff marked with @Extension) are Guice singleton
    components, including "Jenkins", and you'll see @Inject in newer
    code. You can also add your own module, too.

    OTOH, DI is really only used for objects in the singleton scope, and
    no attempts have been made to create other potentially interesting
    scopes, such as the "build" scope. This would be probably something
    useful that I'd love to see someone run with.

    And even if we do all that, I still don't think you can get rid of
    Jenkins.getInstance() completely, as there'll be always some objects
    that get created outside Guice. I personally think it's a perfectly
    normal thing to do, so I don't see the need to prohibit that.


    I briefly looked at your code but didn't spot anything that uses
    injection. Maybe you've reverted it back. If you have specific
    questions I'd be happy to answer.




    On 10/06/2014 01:37 AM, Marc Carter wrote:

        Not a word from anyone :) ? I'll assume that is "No and so far
        over the
        horizon that you should delete your experimental branch"

        Perhaps after three years, the codebase has moved on and it is
        reasonable to resurrect the old code branch(es) and implement this
        feature? What were the final limiting factors that stopped it going
        mainstream at the time?

        Marc

        On Sunday, 21 September 2014 14:52:43 UTC+1, Marc Carter wrote:

             Hi all,

             There were plenty of conversations dating from 2011 on this
        topic
             but everything has since gone quiet. I see Guice is
        included as a
             direct dependency of jenkins-core but is hardly mentioned
        in the
             code and JSR-330 annotations don't seem to "just work" in
        plugin
             extensions, descriptors etc. Presumably it is not there for the
             benefit of general plugins or I'm just not doing it right

        
(https://github.com/JoelJ/ez-__templates/commit/__830001ee4593fa1f395a7c3bb4981e__119ac85e13
        
<https://github.com/JoelJ/ez-templates/commit/830001ee4593fa1f395a7c3bb4981e119ac85e13>).

             Can someone advise please?

             Marc

        --
        You received this message because you are subscribed to the Google
        Groups "Jenkins Developers" group.
        To unsubscribe from this group and stop receiving emails from
        it, send
        an email to jenkinsci-dev+unsubscribe@__googlegroups.com
        <mailto:jenkinsci-dev%[email protected]>
        <mailto:[email protected]
        <mailto:jenkinsci-dev%[email protected]>>.
        For more options, visit https://groups.google.com/d/__optout
        <https://groups.google.com/d/optout>.



    --
    Kohsuke Kawaguchi | CloudBees, Inc. | http://cloudbees.com/
    Try Jenkins Enterprise, our professional version of Jenkins


    --
    You received this message because you are subscribed to the Google
    Groups "Jenkins Developers" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to jenkinsci-dev+unsubscribe@__googlegroups.com
    <mailto:jenkinsci-dev%[email protected]>.
    For more options, visit https://groups.google.com/d/__optout
    <https://groups.google.com/d/optout>.


--
You received this message because you are subscribed to the Google
Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.


--
Kohsuke Kawaguchi | CloudBees, Inc. | http://cloudbees.com/
Try Jenkins Enterprise, our professional version of Jenkins

--
You received this message because you are subscribed to the Google Groups "Jenkins 
Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to