I have a page with such definition :

public class CrudPage<T extends Serializable> extends WebPage
{
  public CrudPage(PageParameters pps , AbstractDao<T> dao)
  {...}
}

and here is how I initialize the page :
CrudPage<User> page = new CrudPage<User>(pps , userDao);

the userDao is a Spring injected DAO :
@SpringBean private UserDao userDao;

And in fact , UserDao extends Abstract Dao Pattern :
public interface UserDao extends AbstractDao<User> {...}

Here comes the problem :
I want to know which type is passed to CrudPage , I use the code :

ParameterizedType genericSuperclass = (ParameterizedType)
dao.getClass().getGenericSuperclass();
this.clazz = (Class<T>) genericSuperclass.getActualTypeArguments()[0];

But it throws exception :
java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType

I then print the type :
    System.out.println("dao.getClass() = " + dao.getClass());
    System.out.println("dao.getClass().getGenericSuperclass() = " +
dao.getClass().getGenericSuperclass());

and found the dao is proxied :
dao.getClass() = class org.apache.wicket.proxy.$Proxy101
dao.getClass().getGenericSuperclass() = class java.lang.reflect.Proxy

Maybe that's why I cannot get the type ...

And ... how to solve the problem ?

Thanks a lot !

Reply via email to