Re: How to I get an un-proxied Spring Bean ?

2010-12-14 Thread Igor Vaynberg
keep calling superclass until its not a proxy

-igor

On Tue, Dec 14, 2010 at 3:28 PM, smallufo  wrote:
> Hi ,
> I tried :
> dao.getClass() = class org.apache.wicket.proxy.$Proxy101
> dao.getClass().getGenericSuperclass() = class java.lang.reflect.Proxy
> dao.getClass().getSuperclass() = class java.lang.reflect.Proxy
>
> But still unable to get the dao class
>
> 2010/12/14 Pedro Santos 
>
>> proxyClass.getSuperclass() gives you the dao type
>>
>>
>

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: How to I get an un-proxied Spring Bean ?

2010-12-14 Thread smallufo
Hi ,
I tried :
dao.getClass() = class org.apache.wicket.proxy.$Proxy101
dao.getClass().getGenericSuperclass() = class java.lang.reflect.Proxy
dao.getClass().getSuperclass() = class java.lang.reflect.Proxy

But still unable to get the dao class

2010/12/14 Pedro Santos 

> proxyClass.getSuperclass() gives you the dao type
>
>


Re: How to I get an un-proxied Spring Bean ?

2010-12-14 Thread James Carman
You could also have AbstractDao have a method like this:

public  Class getEntityType();

I assume you need the type in your DAO when constructing queries, so
you probably already have that set up somewhere.

On Tue, Dec 14, 2010 at 5:45 AM, smallufo  wrote:
> I have a page with such definition :
>
> public class CrudPage extends WebPage
> {
>  public CrudPage(PageParameters pps , AbstractDao dao)
>  {...}
> }
>
> and here is how I initialize the page :
> CrudPage page = new CrudPage(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 {...}
>
> 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) 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 !
>

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: How to I get an un-proxied Spring Bean ?

2010-12-14 Thread Pedro Santos
proxyClass.getSuperclass() gives you the dao type

On Tue, Dec 14, 2010 at 8:45 AM, smallufo  wrote:

> I have a page with such definition :
>
> public class CrudPage extends WebPage
> {
>  public CrudPage(PageParameters pps , AbstractDao dao)
>  {...}
> }
>
> and here is how I initialize the page :
> CrudPage page = new CrudPage(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 {...}
>
> 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) 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 !
>



-- 
Pedro Henrique Oliveira dos Santos


How to I get an un-proxied Spring Bean ?

2010-12-14 Thread smallufo
I have a page with such definition :

public class CrudPage extends WebPage
{
  public CrudPage(PageParameters pps , AbstractDao dao)
  {...}
}

and here is how I initialize the page :
CrudPage page = new CrudPage(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 {...}

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) 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 !