private HttpSession getSession ( InstanceKey instanceKey ) { RequestContext requestContext = appFactory . getInstance ( RequestContext . class ) ; HttpServletRequest httpRequest = requestContext . getRequest ( ) ; if ( httpRequest == null ) { throw new BugError ( "Invalid web context due to null HTTP request. Cannot create managed instance for |%s| with scope SESSION." , instanceKey ) ; } // create HTTP session if missing; accordingly API httpSession is never null if 'create' flag is true return httpRequest . getSession ( true ) ; }
Get HTTP session from current request creating it if necessary . This method should be call inside a request context otherwise bug error is thrown .