I am using and I went into problem similar to OP.
I need to follow the following to reach the DB service level (for user authentication) and do the following:
@ Override public session new session ( Request request, reply response) {session = new migration (request); MInjector.inject (s); Return s; } Unfortunately this result
java.lang.IllegalStateException: EntityManager is closed (possibly due to fact It is that (A) I am using Open Session and (b) spreads on many requests in the session).
I call it injection to AuthenticatedWebSession.authenticate method. @ Override public boolean authentication (string user name, string pass) {Injector.get () Inject (this); ...} I suspect that this is not the best practice, because now I need access to the service layer in other ways, and this is not a good idea. > Injector.get (). In each such method add injector (this) .
My question:
How can I inject a session object into each request? (Or, if it's all wrong together, then whom do I use the service layer?)
< P> You can apply IRequestCycleListener ( Extend AbstractRequestCycleListener ) and apply: @OverrideBeginRequest on Public Zero (RequestCycle Circle) {if (session .exists ()) {Injector.get () Injection (session .get ()); }} Register getRequestCycleListeners () with the application #init () in your IRequestCycleListener (New YourRequestCycleListener () ) .
No comments:
Post a Comment