java - How to get a dagger instance from a type only known at runtime -
I am processing an annotation which has a type parameter to use this type of parameter to instantiate a new object is done.
With Google Guice, I will inject the 'injector' myself and use it to find the right examples. Although I'm a bit new to the dagger and I do not see any solutions described on the net. I know that the object graph can give me an example, can I allow myself to inject the object graph? How do i do this
I managed to do it this way. Not sure if this is good ...
Bar:
public class bar {private commodity object; @ Inject bar (object graph object) {this.objectGraph = objectGraph; } Public ObjectGraph getObjectGraph () {Object object; }}> bar module:
@module (injects = bar.class, full = false) public class BarModule {} FooModule: Module (= BarModule.class is included, injects = ObjectGraph.class, absolute = true, library = true) Public class FooModule {Private ObjectGraph objectGraph; Public Zero Set Object Graph (Object Graph Graphics) {this.objectGraph = objectGraph; } @ Sigletton object graph provides object graph () {return tap; }}
EntryPoint:
public class EntryPoint {public static zero main (string [] args) {FooModule fooModule = New FooModule (); Object Graph objectGraph = ObjectGraph.Credit (new bar module (FU module)); FooModule.setObjectGraph (objectGraph); Println (objectGraph); Repeatedly = objectGraph.get (bar.); ObjectGraph objectGraph1 = bar.getObjectGraph (); Println (objectGraph); }}
Comments
Post a Comment