google-code-export / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
2 stars 1 forks source link

"Who's calling" ability to receive the object that requesting injection. #195

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
So, I have been trying to develop a frame scope. I have
tinkered with ideas to create such a scope, and realized that having a
"Who's calling" object would be best thing.

public class SwingScopes {
    public static final Scope FRAME = new Scope() {
        public <T> Provider<T> scope(final Key<T> key, final
Provider<T> creator, final Object source) {  //Note: Source is the object
that is requesting the injection
             return provider;
       }
        public String toString() {
            return CustomScopes.class.getSimpleName()+".FRAME";
        }
    };

}

Reason for this is under swing development, we can determine the
object requiring it, and make appropriate decision as to what object
the Provider should provide. ;) There can be other reasons to make
this available. Let me know. 

Original issue reported on code.google.com by dh.evolu...@gmail.com on 24 Apr 2008 at 6:23

GoogleCodeExporter commented 9 years ago
Duplicate of issue 27.

Original comment by sven.lin...@gmail.com on 25 Apr 2008 at 6:10

GoogleCodeExporter commented 9 years ago
Dupe of 27.

Original comment by limpbizkit on 14 May 2008 at 3:12