I've changed my DefaultFiller to support TypeLiteral
class DefaultFiller<From, To> extends Filler<From, To>{
private final TypeLiteral<Filler<From, To>> literal;
@Inject
public DefaultFiller(TypeLiteral<Filler<From, To>> literal){
this.literal = literal;
}
.....
}
... and now Filler has a default binding from DefaultFiller to
Filler ...
@ImplementedBy(DefaultFiller.class)
public interface Filler<From, To> {
....
}
... and my Filler client class...
public class PersonService{
@Inject
public PersonService(Filler<Person, PersonDto> filler){
...
}
...
}
... with this new configuration, I got an exception...
1) com.google.inject.TypeLiteral<guicedemo.dto.Filler<T, D>> cannot be
used as a key; It is not fully specified.
while locating guicedemo.dto.Filler<guicedemo.Person,
guicedemo.PersonDto>
for parameter 0 at guicedemo.PersonService.<init>
(PersonService.java:27)
while locating guicedemo.PersonService
How I can solve this?
Thanks in advance.
- Andrés
On 6 jul, 12:12, Andrés Testi <[email protected]> wrote:
> It is what I need.
> Thanks a lot, Stuart!
>
> - Andrés
>
> On 6 jul, 11:39, Stuart McCulloch <[email protected]> wrote:
>
> > 2009/7/6 Andrés Testi <[email protected]>
>
> > > I need a thing like a ByKeyProvider:
>
> > > interface ByKeyProvider<T>{
>
> > > T get(Key<T> key);
>
> > > }
>
> > > Of course, I know ByKeyProvider does not exists. Is there a feature
> > > like this?
>
> > basically it's an issue with Java 5 type erasure - while you have certain
> > type
> > information at compile time some of this information is deliberately erased
> > to
> > maintain binary compatibility with pre-generic classes:
>
> > http://java.sun.com/docs/books/tutorial/java/generics/erasure.html
>
> > however Guice provides a technique (type-literals) that lets you retain this
> > information, albeit at the expense of creating a few additional sub-classes:
>
> > http://publicobject.com/2008/11/guice-punches-erasure-in-face.html
>
> > Jesse's example in the above link should be enough to get you started
> > ( if not then post follow up on this thread ;)
>
> > Regards.
>
> > > - Andrés
>
> > --
> > Cheers, Stuart
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---