Reputation: 31
Im trying to access a hibernate entity/database from a shiro AuthorizingRealm extending class. Since the tapestry IOC does not inject outside Pages / Components, how do I access the Hibernate Session so I can access the database?
Upvotes: 0
Views: 108
Reputation:
Try add this to your AppModule (MongoDB example):
@Contribute(WebSecurityManager.class)
public static void addRealms(Configuration<Realm> configuration, @Autobuild MongoRealm realm)
{
configuration.add(realm);
}
and provide also your AuthorizingRealm:
public class MongoRealm extends AuthorizingRealm
{
@Inject
private SomeDAO someDAO;
...
}
Upvotes: 2
Reputation: 28099
Tapestry IOC can only @Inject
into a service that it has created itself. If you have constructed the AuthorizingRealm using new
then the instance is not under IOC control and won't be injected.
Either @Autobuild
the AuthorizingRealm instance or declare it as a service in your IOC module.
Upvotes: 0
Reputation: 549
If you can get access to the Tapestry Registry (it is stored in the Servlet Context, for example), then you can gain access to the necessary services inside Tapestry and ultimately to the Hibernate Session.
Upvotes: 0