Thank you, Bob!
Solved \o/
For anyone facing a similar problem, here is the re-aligned
implementation of the getStoreInstance(...) method:
private <T extends CommonUpdatableEntity> Store<T, Query<T>>
getStoreInstance(final Class<T> entity) {
final ParameterizedType parameterizedQueryType = new
ParameterizedType() {
public Type[] getActualTypeArguments() {
return new Type[] { entity };
}
public Type getOwnerType() {
return null;
}
public Type getRawType() {
return Query.class;
}
};
ParameterizedType parameterizedStoreType = new ParameterizedType()
{
public Type[] getActualTypeArguments() {
// Here we tell the runtime that one of these Type arguments
is
// another ParameterizedType. Example: Store<Project,
Query<Project>>
return new Type[] { entity, parameterizedQueryType };
}
public Type getOwnerType() {
return null;
}
public Type getRawType() {
return Store.class;
}
};
TypeLiteral<?> type = TypeLiteral.get(parameterizedStoreType);
if (injector.findBindingsByType(type).size() > 0) {
return (Store<T, Query<T>>)
injector.findBindingsByType(type).get(0).getProvider().get();
}
return null;
}
On Oct 4, 4:04 pm, "Bob Lee" <[EMAIL PROTECTED]> wrote:
> On Fri, Oct 3, 2008 at 4:49 PM, Rahul <[EMAIL PROTECTED]> wrote:
> > My next question is : How do I create a TypeLiteral from those 2
> > instances now? Or, did you mean them to be used in some other
> > fashion?
>
> Use TypeLiteral.get(Type).
>
> Bob
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---