void run() throws Exception { if ( Contexts.isEventContextActive() || Contexts.isApplicationContextActive() ) //not sure about the second bit (only needed at init time!) { process(); } else { Lifecycle.beginCall(); try { process(); } finally { Lifecycle.endCall(); } } }
/** * 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/>."); }
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); }
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(); } } }