Refine search
public Conversation initConversation(BeanManager beanManager, String conversationId) { BeanManagerImpl beanManagerImpl = getBeanManagerImpl(beanManager); if (beanManagerImpl == null) return null; ConversationContext conversationContext = beanManagerImpl.instance().select(HttpConversationContext.class).get(); if (!conversationContext.isActive()) conversationContext.activate(conversationId); @SuppressWarnings("unchecked") Bean<Conversation> conversationBean = (Bean<Conversation>)beanManager.getBeans(Conversation.class).iterator().next(); Conversation conversation = (Conversation)beanManager.getReference(conversationBean, Conversation.class, beanManager.createCreationalContext(conversationBean)); return conversation; }
@Override protected Conversation newInstance(InjectionPoint ip, CreationalContext<Conversation> creationalContext) { for (ConversationContext conversationContext : getBeanManager().instance().select(ConversationContext.class)) { if (conversationContext.isActive()) { return conversationContext.getCurrentConversation(); } } /* * Can't get a "real" Conversation, but we need to return something, so * return this dummy Conversation which will simply throw a * ContextNotActiveException for every method call as the spec requires. */ return new ConversationImpl(beanManager); }
public void destroyConversation(BeanManager beanManager) { BeanManagerImpl beanManagerImpl = getBeanManagerImpl(beanManager); if (beanManagerImpl == null) return; ConversationContext conversationContext = beanManagerImpl.instance().select(HttpConversationContext.class).get(); conversationContext.deactivate(); }
@Override public void sendRedirect(String path) throws IOException { FacesContext context = FacesContext.getCurrentInstance(); if (context != null) { // this is a JSF request ConversationContext conversationContext = instance(contextId).select(HttpConversationContext.class).get(); if (conversationContext.isActive()) { Conversation conversation = conversationContext.getCurrentConversation(); if (!conversation.isTransient()) { path = new FacesUrlTransformer(path, context) .toRedirectViewId() .toActionUrl() .appendConversationIdIfNecessary(conversationContext.getParameterName(), conversation.getId()) .encode(); } } } super.sendRedirect(path); } };
protected void deactivateConversationContext(HttpServletRequest request) { try { ConversationContext conversationContext = httpConversationContext(); if (conversationContext.isActive()) { boolean isTransient = conversationContext.getCurrentConversation().isTransient(); if (ConversationLogger.LOG.isTraceEnabled()) { if (isTransient) { ConversationLogger.LOG.cleaningUpTransientConversation(); } else { ConversationLogger.LOG.cleaningUpConversation(conversationContext.getCurrentConversation().getId()); conversationContext.invalidate(); conversationContext.deactivate(); if (isTransient) { conversationDestroyedEvent.fire(request);
/** * Allow the delegate to produce the action URL. If the conversation is * long-running, append the conversation id request parameter to the query * string part of the URL, but only if the request parameter is not already * present. * <p/> * This covers form actions Ajax calls, and redirect URLs (which we want) and * link hrefs (which we don't) * * @see {@link ViewHandler#getActionURL(FacesContext, String)} */ @Override public String getActionURL(FacesContext facesContext, String viewId) { if (contextId == null) { if (facesContext.getAttributes().containsKey(Container.CONTEXT_ID_KEY)) { contextId = (String) facesContext.getAttributes().get(Container.CONTEXT_ID_KEY); } else { contextId = RegistrySingletonProvider.STATIC_INSTANCE; } } String actionUrl = super.getActionURL(facesContext, viewId); final ConversationContext ctx = getConversationContext(contextId); if (ctx!= null && ctx.isActive() && !getSource().equals(Source.BOOKMARKABLE) && !ctx.getCurrentConversation().isTransient()) { return new FacesUrlTransformer(actionUrl, facesContext) .appendConversationIdIfNecessary(getConversationContext(contextId).getParameterName(), ctx.getCurrentConversation().getId()) .getUrl(); } else { return actionUrl; } }
@Override public void begin(String id) { verifyConversationContextActive(); if (!_transient) { throw ConversationLogger.LOG.beginCalledOnLongRunningConversation(); } if (getActiveConversationContext().getConversation(id) != null) { throw ConversationLogger.LOG.conversationIdAlreadyInUse(id); } _transient = false; this.id = id; notifyConversationContext(); ConversationLogger.LOG.promotedTransientConversation(id); }
@Override public void begin() { verifyConversationContextActive(); if (!_transient) { throw ConversationLogger.LOG.beginCalledOnLongRunningConversation(); } _transient = false; if (this.id == null) { // This a conversation that was made transient previously in this request this.id = getActiveConversationContext().generateConversationId(); } notifyConversationContext(); ConversationLogger.LOG.promotedTransientConversation(id); }
/** * Start a request. * @return The request opened. */ public HttpServletRequest openRequest() { HttpServletRequest currentRequest = requests.get(); if (currentRequest != null) { throw new RuntimeException("A request is already open"); } MockHttpServletRequestImpl request = requestProvider.get(); if (currentSession != null) { request.setSession(currentSession); request.getSession(); } currentRequest = new LifecycleAwareRequest(listener, request); requests.set(currentRequest); listener.requestInitialized(new ServletRequestEvent(context, currentRequest)); if (!conversationContext.isActive()) { conversationContext.activate(); } return currentRequest; }
@Inject public ConversationImpl(BeanManagerImpl manager) { this.manager = manager; this._transient = true; this.timeout = isContextActive() ? getActiveConversationContext().getDefaultTimeout() : 0; this.concurrencyLock = new ReentrantLock(); touch(); }
@Override public void sendRedirect(String path) throws IOException { FacesContext context = FacesContext.getCurrentInstance(); if (context != null) { // this is a JSF request ConversationContext conversationContext = instance(contextId).select(HttpConversationContext.class).get(); if (conversationContext.isActive()) { Conversation conversation = conversationContext.getCurrentConversation(); if (!conversation.isTransient()) { path = new FacesUrlTransformer(path, context) .toRedirectViewId() .toActionUrl() .appendConversationIdIfNecessary(conversationContext.getParameterName(), conversation.getId()) .encode(); } } } super.sendRedirect(path); } };
protected void deactivateConversationContext(HttpServletRequest request) { try { ConversationContext conversationContext = httpConversationContext(); if (conversationContext.isActive()) { boolean isTransient = conversationContext.getCurrentConversation().isTransient(); if (ConversationLogger.LOG.isTraceEnabled()) { if (isTransient) { ConversationLogger.LOG.cleaningUpTransientConversation(); } else { ConversationLogger.LOG.cleaningUpConversation(conversationContext.getCurrentConversation().getId()); conversationBeforeDestroyedEvent.fire(request); conversationContext.invalidate(); conversationContext.deactivate(); if (isTransient) { conversationDestroyedEvent.fire(request);
/** * Allow the delegate to produce the action URL. If the conversation is * long-running, append the conversation id request parameter to the query * string part of the URL, but only if the request parameter is not already * present. * <p/> * This covers form actions Ajax calls, and redirect URLs (which we want) and * link hrefs (which we don't) * * @see {@link ViewHandler#getActionURL(FacesContext, String)} */ @Override public String getActionURL(FacesContext facesContext, String viewId) { if (contextId == null) { if (facesContext.getAttributes().containsKey(Container.CONTEXT_ID_KEY)) { contextId = (String) facesContext.getAttributes().get(Container.CONTEXT_ID_KEY); } else { contextId = RegistrySingletonProvider.STATIC_INSTANCE; } } String actionUrl = super.getActionURL(facesContext, viewId); final ConversationContext ctx = getConversationContext(contextId); if (ctx != null && ctx.isActive() && !getSource().equals(Source.BOOKMARKABLE) && !ctx.getCurrentConversation().isTransient()) { return new FacesUrlTransformer(actionUrl, facesContext) .appendConversationIdIfNecessary(getConversationContext(contextId).getParameterName(), ctx.getCurrentConversation().getId()) .getUrl(); } else { return actionUrl; } }
@Override public void begin(String id) { verifyConversationContextActive(); if (!_transient) { throw ConversationLogger.LOG.beginCalledOnLongRunningConversation(); } if (getActiveConversationContext().getConversation(id) != null) { throw ConversationLogger.LOG.conversationIdAlreadyInUse(id); } _transient = false; this.id = id; notifyConversationContext(); ConversationLogger.LOG.promotedTransientConversation(id); }
@Override public void begin() { verifyConversationContextActive(); if (!_transient) { throw ConversationLogger.LOG.beginCalledOnLongRunningConversation(); } _transient = false; if (this.id == null) { // This a conversation that was made transient previously in this request this.id = getActiveConversationContext().generateConversationId(); } notifyConversationContext(); ConversationLogger.LOG.promotedTransientConversation(id); }
/** * Start a request. * @return The request opened. */ public HttpServletRequest openRequest() { HttpServletRequest currentRequest = requests.get(); if (currentRequest != null) { throw new RuntimeException("A request is already open"); } MockHttpServletRequestImpl request = requestProvider.get(); if (currentSession != null) { request.setSession(currentSession); request.getSession(); } currentRequest = new LifecycleAwareRequestEjbCdiUnit(listener, request); requests.set(currentRequest); listener.requestInitialized(new ServletRequestEvent(context, currentRequest)); if (!conversationContext.isActive()) { conversationContext.activate(); } return currentRequest; }
@Inject public ConversationImpl(BeanManagerImpl manager) { this.manager = manager; this._transient = true; this.timeout = isContextActive() ? getActiveConversationContext().getDefaultTimeout() : 0; this.concurrencyLock = new ReentrantLock(); touch(); }
@Override public void sendRedirect(String path) throws IOException { FacesContext context = FacesContext.getCurrentInstance(); if (context != null) { // this is a JSF request ConversationContext conversationContext = instance(contextId).select(HttpConversationContext.class).get(); if (conversationContext.isActive()) { Conversation conversation = conversationContext.getCurrentConversation(); if (!conversation.isTransient()) { path = new FacesUrlTransformer(path, context) .toRedirectViewId() .toActionUrl() .appendConversationIdIfNecessary(conversationContext.getParameterName(), conversation.getId()) .encode(); } } } super.sendRedirect(path); } };
@Override protected Conversation newInstance(InjectionPoint ip, CreationalContext<Conversation> creationalContext) { for (ConversationContext conversationContext : getBeanManager().instance().select(ConversationContext.class)) { if (conversationContext.isActive()) { return conversationContext.getCurrentConversation(); } } /* * Can't get a "real" Conversation, but we need to return something, so * return this dummy Conversation which will simply throw a * ContextNotActiveException for every method call as the spec requires. */ return new ConversationImpl(beanManager); }
protected void deactivateConversationContext(HttpServletRequest request) { try { ConversationContext conversationContext = httpConversationContext(); if (conversationContext.isActive()) { boolean isTransient = conversationContext.getCurrentConversation().isTransient(); if (ConversationLogger.LOG.isTraceEnabled()) { if (isTransient) { ConversationLogger.LOG.cleaningUpTransientConversation(); } else { ConversationLogger.LOG.cleaningUpConversation(conversationContext.getCurrentConversation().getId()); conversationBeforeDestroyedEvent.fire(request); conversationContext.invalidate(); conversationContext.deactivate(); if (isTransient) { conversationDestroyedEvent.fire(request);