How can I instantiate a bean with generic type using spring config
public class GenericService<T>
{
...
}
Note that T is not the concrete type of a bean property. It is really just the type for one of the methods of the service.
In other words.. Can I instantiate new GenericService of type String() or new GenericService of type Long() using spring context.
My generic class contains
public List performTheService(String word, Class clazz) { return clazz.newInstance().getAllWords(); ... }
The return type of the generic method depends on the concrete parameter type of the class instantiated. Is this possible or a wrong usage of DI + generics? TIA