访问Hibernate而不使用apache Tapestry注入

访问Hibernate而不使用apache Tapestry注入,hibernate,tapestry,Hibernate,Tapestry,我试图从shiro AuthorizationRealm扩展类访问hibernate实体/数据库。由于tapestry IOC不注入外部页面/组件,如何访问Hibernate会话以便访问数据库?如果可以访问tapestry注册表(例如,它存储在Servlet上下文中),然后您可以访问Tapestry内部的必要服务,并最终访问Hibernate会话。Tapestry IOC只能将@注入到它自己创建的服务中。如果您使用new构建了authorizationrealm,则该实例不受IOC控制,不会被注

我试图从shiro AuthorizationRealm扩展类访问hibernate实体/数据库。由于tapestry IOC不注入外部页面/组件,如何访问Hibernate会话以便访问数据库?

如果可以访问tapestry注册表(例如,它存储在Servlet上下文中),然后您可以访问Tapestry内部的必要服务,并最终访问Hibernate会话。

Tapestry IOC只能将
@注入到它自己创建的服务中。如果您使用
new
构建了authorizationrealm,则该实例不受IOC控制,不会被注入


@Autobuild
授权域实例,或将其声明为IOC模块中的服务。

尝试将其添加到AppModule(MongoDB示例):

@Contribute(WebSecurityManager.class)
public static void addRealms(Configuration<Realm> configuration, @Autobuild MongoRealm realm)
{
    configuration.add(realm);
}
public class MongoRealm extends AuthorizingRealm
{
   @Inject
   private SomeDAO someDAO;
   ...
}