/** * Called just prior to dispatching a message, fault or exception. The * Seam request lifecycle is ended here */ public void close(MessageContext messageContext) { Lifecycle.endRequest(); }
/** * Get the Seam component, even if no application context * is associated with the current thread. */ public static Component componentForName(String name) { if ( Contexts.isApplicationContextActive() ) { return Component.forName(name); } else { Lifecycle.setupApplication(); try { return Component.forName(name); } finally { Lifecycle.cleanupApplication(); } } }
private void cleanup() { Contexts.getEventContext().remove(AbstractDispatcher.EXECUTING_ASYNCHRONOUS_CALL); if (createContexts) Lifecycle.endCall(); } }
protected Object invoke(InvocationContext invocation, EventType invocationType) throws Exception { if ( !isSeamComponent || !Lifecycle.isApplicationInitialized()) { //not a Seam component return invocation.proceed(); } else if ( Contexts.isEventContextActive() || Contexts.isApplicationContextActive() ) //not sure about the second bit (only needed at init time!) { // a Seam component, and Seam contexts exist return createInvocationContext(invocation, invocationType).proceed(); } else { //if invoked outside of a set of Seam contexts, //set up temporary Seam EVENT and APPLICATION //contexts just for this call Lifecycle.beginCall(); try { return createInvocationContext(invocation, invocationType).proceed(); } finally { Lifecycle.endCall(); } } }
public CoreSession getDocumentManager(RepositoryLocation serverLocation) { if (serverLocation == null) { /* * currentServerLocation (factory in ServerContextBean) is set through navigationContext, which itself * injects documentManager, so it will be null the first time. */ return null; } CloseableCoreSession session = sessions.get(serverLocation); if (session == null) { if (Lifecycle.isDestroying()) { /* * During Seam component destroy phases, we don't want to recreate a core session just for injection. * This happens during logout when the session context is destroyed; we don't want to cause EJB calls in * this case as the authentication wouldn't work. */ return null; } String serverName = serverLocation.getName(); session = CoreInstance.openCoreSession(serverName); log.debug("Opened session for repository " + serverName); sessions.put(serverLocation, session); } return session; }
/** * Starts a Seam Call if one is not available and if executing within a Spring * Transaction. */ public static void beginTransactionalSeamCall() { if (ScopeType.APPLICATION.isContextActive()) { log.debug("Application available. Won't start a new call"); return; } if (TransactionSynchronizationManager.isSynchronizationActive()) { TransactionSynchronizationManager .registerSynchronization(new SeamLifecycleSynchronization()); log.debug("Beginning Transactional Seam Call"); Lifecycle.beginCall(); return; } throw new IllegalStateException( "Seam application context not available and cannot be started. " + "Seam Managed Persistence Context not available. " + "Try placing the spring bean call inside of a spring transaction or try making the spring bean " + "a Seam Component using <seam:component/>."); }
/** * @deprecated Use {@link Lifecycle#setupApplication()} */ @Deprecated public static void mockApplication() { setupApplication(null); }
/** * @deprecated Use {@link Lifecycle#cleanupApplication()} */ @Deprecated public static void unmockApplication() { cleanupApplication(); }
@AroundInvoke public Object aroundInvoke(InvocationContext ctx) throws Exception { Component comp = getComponent(); String name = comp.getName(); Object target = ctx.getTarget(); Method method = ctx.getMethod(); Object[] parameters = ctx.getParameters(); Context outerMethodContext = Lifecycle.beginMethod(); try { Contexts.getMethodContext().set(name, target); Contexts.getMethodContext().set("org.jboss.seam.this", target); Contexts.getMethodContext().set("org.jboss.seam.method", method); Contexts.getMethodContext().set("org.jboss.seam.parameters", parameters); Contexts.getMethodContext().set("org.jboss.seam.component", comp); return ctx.proceed(); } finally { Lifecycle.endMethod(outerMethodContext); } }
@Deprecated public static void beginSession(Map<String, Object> session) { beginSession(session,null); }
public static void beginApplication(ServletContext context) { // caching the classloader to servletContext WeakReference<ClassLoader> ref = new WeakReference<ClassLoader>(Thread.currentThread().getContextClassLoader()); context.setAttribute("seam.context.classLoader",ref); log.debug("Cached the context classloader in servletContext as 'seam.context.classLoader'"); context.setAttribute(SERVLET_CONTEXT_KEY, context); servletContext = context; Lifecycle.beginApplication( new ServletApplicationMap(context) ); }
@Unwrap public EntityManager getEntityManager() throws NamingException, SystemException { if (entityManager==null) initEntityManager(); if ( !synchronizationRegistered && !Lifecycle.isDestroying() ) { joinTransaction(); } return entityManager; }
private void setup() { if (createContexts) Lifecycle.beginCall(); Contexts.getEventContext().set(AbstractDispatcher.EXECUTING_ASYNCHRONOUS_CALL, true); if (taskId!=null) { BusinessProcess.instance().resumeTask(taskId); } else if (processId!=null) { BusinessProcess.instance().resumeProcess(processId); } if (timer!=null) { Contexts.getEventContext().set("timer", timer); } log.debug("executing: " + this); }
public static void beginSession(HttpSession session) { Lifecycle.beginSession( new ServletSessionMap(session), new ServletApplicationMap(session.getServletContext()) ); }
if (!Contexts.isApplicationContextActive()) Lifecycle.setupApplication(); unmockApplication = true; Lifecycle.cleanupApplication();
Lifecycle.endRequest();
@Unwrap public Session getSession() throws Exception { if (session==null) initSession(); if ( !synchronizationRegistered && !Lifecycle.isDestroying() ) { joinTransaction(); } return session; }
@Override public void afterCompletion(int status) { //Close the seam call we started if it is still active. if(ScopeType.APPLICATION.isContextActive()) { log.debug("Ending Transactional Seam Call"); Lifecycle.endCall(); } else { log.warn("Spring started a transactional Seam call but somebody else closed before it before the transaction committed."); } } }
public void init(FilterConfig filterConfig) throws ServletException { Lifecycle.setupApplication(new ServletApplicationMap(filterConfig.getServletContext())); try { filters = getSortedFilters(); for ( Filter filter : filters ) { log.info( "Initializing filter: " + Component.getComponentName(filter.getClass())); filter.init(filterConfig); } } finally { Lifecycle.cleanupApplication(); } }