@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { // just touch the conversation. contextsService.getCurrentContext(ConversationScoped.class, true); // otherwise business as usual... chain.doFilter(request, response); }
public static void ensureRequestScope(final ContextsService cs, final ServletRequestListener listener) { final Context reqCtx = cs.getCurrentContext(RequestScoped.class); if (reqCtx == null || !cs.getCurrentContext(RequestScoped.class).isActive()) { listener.requestInitialized(null); FAKE_REQUEST.set(true); } }
/** * Remove the given ConversationContext from the SessionContext storage. * This method usually will get called at {@link Conversation#end()} or during cleanup. * Not that this does <b>not</b> destroy the ConversationContext! * @return {@code true} if the conversationContext got removed */ public boolean removeConversationFromStorage(ConversationContext conversationContext) { Context sessionContext = webBeansContext.getContextsService().getCurrentContext(SessionScoped.class); Set<ConversationContext> sessionConversations = getSessionConversations(sessionContext, true); return sessionConversations.remove(conversationContext); }
private void ensureRequestScope() { final Context reqCtx = webBeansContext.getContextsService().getCurrentContext(RequestScoped.class); if (reqCtx == null || !webBeansContext.getContextsService().getCurrentContext(RequestScoped.class).isActive()) { requestInitialized(null); EndWebBeansListener.FAKE_REQUEST.set(true); } }
@Override public AbstractContext getRequestContext() { WebBeansContext webBeansContext = WebBeansContext.getInstance(); RequestContext currentContext = (RequestContext) webBeansContext.getContextsService().getCurrentContext(RequestScoped.class); return currentContext; }
/** * {@inheritDoc} */ @Override protected ConversationImpl newInstance(CreationalContextImpl<ConversationImpl> creationalContext) { Context currentContext = contextsService.getCurrentContext(ConversationScoped.class); if (currentContext != null && currentContext instanceof ConversationContext) { return ((ConversationContext) currentContext).getConversation(); } else { throw new ContextNotActiveException("WebBeans context with scope type annotation @ConversationScoped" + " does not exist within current thread"); } } }
@Override public boolean activate() { if (startParam != null) { return false; } Context ctx = context.getContextsService().getCurrentContext(RequestScoped.class); if (ctx == null) { startParam = new Object(); context.getContextsService().startContext(RequestScoped.class, startParam); return true; } return false; }
private boolean ensureRequestScope() { Context context = this.lifeCycle.getContextService().getCurrentContext(RequestScoped.class); if (context == null || !context.isActive()) { requestInitialized(null); return true; } return false; }
/** * Add the given ConversationContext to the SessionContext. * This method usually will get called at {@link Conversation#begin()}. */ public void addToConversationStorage(ConversationContext conversationContext, String conversationId) { Asserts.assertNotNull(conversationId, "conversationId"); Context sessionContext = webBeansContext.getContextsService().getCurrentContext(SessionScoped.class); Set<ConversationContext> sessionConversations = getSessionConversations(sessionContext, true); // check whether this conversation already exists for (ConversationContext sessionConversation : sessionConversations) { if (conversationId.equals(sessionConversation.getConversation().getId())) { throw new IllegalArgumentException("Conversation with id=" + conversationId + " already exists!"); } } // if not, then simply add this conversation sessionConversations.add(conversationContext); }
Context standardContext = webBeansContext.getContextsService().getCurrentContext(scopeType);
/** * {@inheritDoc} * * This will also remove the current ConversationContext from the SessionContext */ @Override public void end() { checkThreadUsage(); if (!isTransient) { iDontUseItAnymore(); id = null; isTransient = true; } else { logger.log(Level.WARNING, OWBLogConst.WARN_0004, id); throw new IllegalStateException(toString() + " has already ended"); } // now store this conversation in the SessionContext ConversationManager conversationManager = webBeansContext.getConversationManager(); ConversationContext conversationContext = (ConversationContext) webBeansContext.getContextsService().getCurrentContext(ConversationScoped.class); conversationManager.removeConversationFromStorage(conversationContext); }
public Object getLifecycleEventPayload(ConversationContext ctx) { Object payLoad = null; if (ctx.getConversation().getId() != null) { payLoad = ctx.getConversation().getId(); } if (payLoad == null) { RequestContext requestContext = (RequestContext) webBeansContext.getContextsService().getCurrentContext(RequestScoped.class); if (requestContext != null) { payLoad = requestContext.getRequestObject(); } } if (payLoad == null) { payLoad = new Object(); } return payLoad; }
Context ctx = service.getCurrentContext(scopeType); ctx = service.getCurrentContext(scopeType); if(ctx != null && !ctx.isActive())
ConversationContext conversationContext = (ConversationContext) webBeansContext.getContextsService().getCurrentContext(ConversationScoped.class); conversationManager.addToConversationStorage(conversationContext, id);
@Override public void contextEntered(final ThreadContext oldContext, final ThreadContext newContext) { final BeanContext beanContext = newContext.getBeanContext(); final WebBeansContext webBeansContext = beanContext.getModuleContext().getAppContext().getWebBeansContext(); if (webBeansContext == null) { return; } final ContextsService contextsService = webBeansContext.getContextsService(); final Context requestContext = contextsService.getCurrentContext(RequestScoped.class); if (requestContext == null) { contextsService.startContext(RequestScoped.class, null); newContext.set(DestroyContext.class, new DestroyContext(contextsService, newContext)); } }