@Override public boolean destroy(HttpSession session) { if (isAssociated()) { checkContextInitialized(); } return super.destroy(session); }
public void endRequest(ServletRequest servletRequest) { try { /* * Invalidate the request (all bean instances will be scheduled for * destruction) */ requestContext.invalidate(); /* * Deactivate the request, causing all bean instances to be destroyed * (as the context is invalid) */ requestContext.deactivate(); } finally { /* * Ensure that whatever happens we dissociate to prevent any memory * leaks */ requestContext.dissociate(servletRequest); } }
private void activate(HttpConversationContext conversationContext, final HttpServletRequest request) { if (lazy) { conversationContext.activateLazily(lazyInitializationCallback); } else { String cid = determineConversationId(request, conversationContext.getParameterName()); conversationContext.activate(cid); if (cid == null) { // transient conversation conversationInitializedEvent.fire(request); } } }
private void activate(HttpConversationContext conversationContext, final HttpServletRequest request) { if (lazy && conversationContext instanceof LazyHttpConversationContextImpl) { LazyHttpConversationContextImpl lazyConversationContext = (LazyHttpConversationContextImpl) conversationContext; // Activation API should be improved so that it's possible to pass a callback for later execution lazyConversationContext.activate(lazyInitializationCallback); } else { String cid = determineConversationId(request, conversationContext.getParameterName()); conversationContext.activate(cid); if (cid == null) { // transient conversation conversationInitializedEvent.fire(request); } } }
protected void associateConversationContext(HttpServletRequest request) { httpConversationContext().associate(request); }
@Override public void activate() { if (!isAssociated()) { throw ConversationLogger.LOG.mustCallAssociateBeforeActivate(); } if (!isActive()) { super.setActive(true); } else { ConversationLogger.LOG.contextAlreadyActive(getRequest()); } // Reset the initialized flag - a thread which is not cleaned up properly (e.g. async processing on // Tomcat) may break the lazy initialization otherwise this.initialized.set(null); }
@Override public void deactivate() { try { if (isInitialized()) { try { super.deactivate(); } finally { this.initialized.set(null); } } else { // Only deactivate the context, i.e. remove state threadlocal removeState(); } } finally { this.initializationCallback.set(null); } }
private void deactivateSessionDestructionContext(HttpSession session) { HttpSessionDestructionContext context = getSessionDestructionContext(); if (context.isActive()) { context.deactivate(); context.dissociate(session); } }
@Override public boolean associate(HttpSession session) { if (getBeanStore() == null) { // Don't reassociate setBeanStore(new EagerSessionBeanStore(namingScheme, session, getServiceRegistry())); return true; } else { return false; } }
@Override protected BoundBeanStore createSessionBeanStore(NamingScheme namingScheme, HttpSession session) { return new EagerSessionBeanStore(namingScheme, session, getServiceRegistry()); }
@Override protected void initialize(String cid) { this.initialized.set(Boolean.TRUE); super.initialize(cid); }
/** * * @param initializationCallback This callback will be executed during initialization */ public void activate(Consumer<HttpServletRequest> initializationCallback) { activate(); if (initializationCallback != null) { this.initializationCallback.set(initializationCallback); } else { // For the case the deactivation was not performed properly this.initializationCallback.set(null); } }
public HttpServletRequest getHttpServletRequest() { if (getBeanStore() instanceof RequestBeanStore) { return Reflections.<RequestBeanStore>cast(getBeanStore()).getRequest(); } return null; } }
@Override protected void setSessionAttribute(HttpServletRequest request, String name, Object value, boolean create) { if (create || SessionHolder.getSessionIfExists() != null) { getSessionFromRequest(request, true).setAttribute(name, value); } }
private void activate(HttpConversationContext conversationContext, final HttpServletRequest request) { if (lazy) { conversationContext.activateLazily(lazyInitializationCallback); } else { String cid = determineConversationId(request, conversationContext.getParameterName()); conversationContext.activate(cid); if (cid == null) { // transient conversation conversationInitializedEvent.fire(request); } } }
protected void associateConversationContext(HttpServletRequest request) { httpConversationContext().associate(request); }
@Override protected BoundBeanStore createRequestBeanStore(NamingScheme namingScheme, HttpServletRequest request) { return new LazySessionBeanStore(request, namingScheme, false, getServiceRegistry()); }
protected void associateConversationContext(HttpServletRequest request) { httpConversationContext().associate(request); }
protected void associateConversationContext(HttpServletRequest request) { httpConversationContext().associate(request); }