* How Injecting dependencies when creating "objects" via reflection
and the "object" also has a constructor parameters.
* details:
I have a Hierachy (tree) of classes.
class Base{
Base(String s){...}
}
class Child1{
Child1(String s){super(s)}
}
class Child2{
Child1(String s){super(s)}
}
and so on, not that class Child1 also has its own children.
* Till now I was creating the classes via reflection and invoking the
string parameter constructor.
* now the base class has a dependency that I want guice to inject.
class Base{
Base(String s, Dep d){...}
}
class Child1{
Child1(String s, Dep d){super(s)}
}
class Child2{
Child1(String s, Dep d){super(s)}
}
* I have read up on assisted inject, but am not sure on how to use is
to solve this problem. Since I am using reflection to to create the
objects of this class Hierarchy.
* Note: the reason I am using reflection to create objects is because
the type of the object to be instantiated is not known till runtime. I
receive strings from socket and need to wrap them into objects before
processing them (I have simplified the actual requirement for sake of
brevity).
* so the broader question is how do I create objects of class whose
type is not known till runtime and it has dependinecies and also
constructor parameters.
* and kudos for the 2.0 release :)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---