Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reflection Guice对象上的类层次结构存在问题_Reflection_Guice_Objectify - Fatal编程技术网

Reflection Guice对象上的类层次结构存在问题

Reflection Guice对象上的类层次结构存在问题,reflection,guice,objectify,Reflection,Guice,Objectify,我正在尝试使用Guice来实例化我的objectifydaos。我的层次结构如下: public class EmpresaDao extends ObjectifyDao<Empresa> { ... } public class ObjectifyDao<T> extends DAOBase { ... } 当我使用“injector.getInstance(EmpresaDao.class)”时,getClass().getGenericSuperclass()

我正在尝试使用Guice来实例化我的objectifydaos。我的层次结构如下:

public class EmpresaDao extends ObjectifyDao<Empresa> { ... }

public class ObjectifyDao<T> extends DAOBase { ... }
当我使用“
injector.getInstance(EmpresaDao.class)
”时,
getClass().getGenericSuperclass()
给出了:

[INFO] superclass -> br.com.xxxxx.server.service.ObjectifyDao<br.com.xxxxx.domain.Empresa>
[INFO] superclass -> class br.com.xxxx.server.service.EmpresaDao
显然,我想让Guice用DI实例化我的对象

有人能解释为什么会这样吗

是否有任何方法(用Guice实例化)可以获得与“new()”相同的超类


谢谢。

这是因为Guice通过动态创建字节码并从EmpresaDao继承来代理EmpresaDao。

感谢Stuart McCulloch,他帮助了我

可以禁用AOP(使用Guice whitout AOP),它提供了我想要的(br.com.xxxxx.server.service.ObjectifyDao)(未测试)

但是我想在我的工具箱上有AOP,所以我通过从Guice生成的代理类中获取TypeArguments来解决这个问题:

        clazz = (Class<T>) ((ParameterizedType) TypeLiteral.get(getClass()).getSupertype(ObjectifyDao.class).getType()).getActualTypeArguments()[0];
clazz=(Class)((ParameterizedType)TypeLiteral.get(getClass()).getSupertype(ObjectifyDao.Class).getType()).getActualTypeArguments()[0];