...
- Session 1 is created and closed automatically by the framework
- Plugin 2 creates its own session 2 and closes it afterwards
- Plugin 3 creates its own session 3 and invokes a service from plugin 4
- The service in plugin 4 creates its own session 4 and closes it afterwards
- The session 3 is closed by plugin 3
- The framework automatically closes session 1
...
Retrieving and Creating Sessions
...
Code Block | ||
---|---|---|
| ||
private Session login() { try { String portnr = myConfigService.getParameter("website_settings.frontend_portnr", null, "default"); String hostname = myConfigService.getParameter("website_settings.backend_hostname", null, "default"); String username = myConfigService.getParameter(USERNAMEKEY); String password = myConfigService.getParameter(PASSWORDKEY); String website = myConfigService.getParameter(WEBSITEKEY); // Create mocks for the servlet request and response MockServletContext context = new MockServletContext(); MockHttpServletRequest request = new MockHttpServletRequest(context); request.addParameter("webid", website); request.setServerName(hostname); request.setServerPort(Integer.parseInt(portnr)); MockHttpServletResponse response = new MockHttpServletResponse(); // Create a new session from this mock request Session session = mySessionManager.createSession(request, response); request.setAttribute(Session.XPERIENCENTRAL_SESSION_KEY, session); // Login using the authorization service if (!myAuthorizationService.login(username, password, request)) { LOG.warning("Login failed."); return null; } return session; } catch(ConfigurationManagementException e) { LOG.log(Level.SEVERE, "An exception occurred during login()", e); return null; } } |