private void setEntityManager(FlowSession session, EntityManager em) { session.getScope().put(PERSISTENCE_CONTEXT_ATTRIBUTE, em); }
public StateDefinition getCurrentState() { return flowExecution.getActiveSession().getState(); }
private boolean isParentPersistenceContext(FlowSession flowSession) { return ((!flowSession.isRoot()) && isPersistenceContext(flowSession.getParent().getDefinition())); }
public void sessionEnded(RequestContext context, FlowSession session, String outcome, AttributeMap<?> output) { if (isParentPersistenceContext(session)) { if (!isPersistenceContext(session.getDefinition())) { bind(getHibernateSession(session.getParent())); } } }
public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap<?> input) { boolean reusePersistenceContext = false; if (isParentPersistenceContext(session)) { if (isPersistenceContext(session.getDefinition())) { setEntityManager(session, getEntityManager(session.getParent())); reusePersistenceContext = true; } else { unbind(getEntityManager(session.getParent())); } } if (isPersistenceContext(session.getDefinition()) && (!reusePersistenceContext)) { EntityManager em = entityManagerFactory.createEntityManager(); session.getScope().put(PERSISTENCE_CONTEXT_ATTRIBUTE, em); bind(em); } }
public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap input) { if (!session.isRoot()) { FlowSession parent = session.getParent(); if (isPersistenceContext(parent.getDefinition())) { unbind(getEntityManager(parent)); } } if (isPersistenceContext(session.getDefinition())) { EntityManager em = entityManagerFactory.createEntityManager(); session.getScope().put(PERSISTENCE_CONTEXT_ATTRIBUTE, em); bind(em); } }
private FlowExecutionException wrap(Exception e) { if (isActive()) { FlowSession session = getActiveSession(); String flowId = session.getDefinition().getId(); String stateId = session.getState() != null ? session.getState().getId() : null; return new FlowExecutionException(flowId, stateId, "Exception thrown in state '" + stateId + "' of flow '" + flowId + "'", e); } else { return new FlowExecutionException(flow.getId(), null, "Exception thrown within inactive flow '" + flow.getId() + "'", e); } }
/** * Autowire all objects in flash, flow and conversation scope for given flow execution. Autowiring will only happen * if the provided flow execution is still active. * @see #autowire(ScopeType, MutableAttributeMap) */ public void autowire(FlowExecutionContext flowExecutionContext) { if (flowExecutionContext.isActive()) { // no need to autowire request scope since that will be setup from scratch in this request // autowire flash and flow scope for all flow sessions in the flow execution FlowSession flowSession = flowExecutionContext.getActiveSession(); while (flowSession != null) { autowire(ScopeType.FLASH, flowSession.getFlashMap()); autowire(ScopeType.FLOW, flowSession.getScope()); flowSession = flowSession.getParent(); } // autowire conversation scope, which is not tied to the flow session autowire(ScopeType.CONVERSATION, flowExecutionContext.getConversationScope()); } }
/** * Put ticket granting ticket in request and flow scopes. * * @param context the context * @param ticketValue the ticket value */ public static void putTicketGrantingTicketInScopes(final RequestContext context, final String ticketValue) { putTicketGrantingTicketIntoMap(context.getRequestScope(), ticketValue); putTicketGrantingTicketIntoMap(context.getFlowScope(), ticketValue); var session = context.getFlowExecutionContext().getActiveSession().getParent(); while (session != null) { putTicketGrantingTicketIntoMap(session.getScope(), ticketValue); session = session.getParent(); } }
/** * Creates a new mock flow execution context for the specified active flow session. */ public MockFlowExecutionContext(FlowSession flowSession) { setActiveSession(flowSession); this.flow = flowSession.getDefinition(); }
/** * Specialization of State's <code>doEnter</code> template method that executes behavior specific to this state type * in polymorphic fashion. * <p> * This implementation pops the top (active) flow session off the execution stack, ending it, and resumes control in * the parent flow (if necessary). If the ended session is the root flow, a final response is rendered. * @param context the control context for the currently executing flow, used by this state to manipulate the flow * execution * @throws FlowExecutionException if an exception occurs in this state */ protected void doEnter(final RequestControlContext context) throws FlowExecutionException { FlowSession activeSession = context.getFlowExecutionContext().getActiveSession(); if (activeSession.isRoot()) { // entire flow execution is ending; issue the final response if (finalResponseAction != null && !context.getExternalContext().isResponseComplete()) { ActionExecutor.execute(finalResponseAction, context); context.getExternalContext().recordResponseComplete(); } context.endActiveFlowSession(getId(), createSessionOutput(context)); } else { // there is a parent flow that will resume (this flow is a subflow) LocalAttributeMap<Object> sessionOutput = createSessionOutput(context); context.endActiveFlowSession(getId(), sessionOutput); } }
public MutableAttributeMap<Object> getViewScope() throws IllegalStateException { return flowExecution.getActiveSession().getViewScope(); }
public boolean getEmbeddedMode() { return flowExecution.getActiveSession().isEmbeddedMode(); }
public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap input) { if (!session.isRoot()) { FlowSession parent = session.getParent(); if (isPersistenceContext(parent.getDefinition())) { unbind(getHibernateSession(parent)); } } if (isPersistenceContext(session.getDefinition())) { Session hibernateSession = createSession(context); session.getScope().put(PERSISTENCE_CONTEXT_ATTRIBUTE, hibernateSession); bind(hibernateSession); } }
public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap<?> input) { boolean reusePersistenceContext = false; if (isParentPersistenceContext(session)) { if (isPersistenceContext(session.getDefinition())) { setEntityManager(session, getEntityManager(session.getParent())); reusePersistenceContext = true; } else { unbind(getEntityManager(session.getParent())); } } if (isPersistenceContext(session.getDefinition()) && (!reusePersistenceContext)) { EntityManager em = entityManagerFactory.createEntityManager(); session.getScope().put(PERSISTENCE_CONTEXT_ATTRIBUTE, em); bind(em); } }
public void sessionEnded(RequestContext context, FlowSession session, String outcome, AttributeMap<?> output) { if (isParentPersistenceContext(session)) { if (!isPersistenceContext(session.getDefinition())) { bind(getEntityManager(session.getParent())); } } }
public void sessionEnding(RequestContext context, FlowSession session, String outcome, MutableAttributeMap<?> output) { if (isParentPersistenceContext(session)) { return; } if (isPersistenceContext(session.getDefinition())) { final EntityManager em = getEntityManager(session); Boolean commitStatus = session.getState().getAttributes().getBoolean("commit"); if (Boolean.TRUE.equals(commitStatus)) { transactionTemplate.execute(new TransactionCallbackWithoutResult() { protected void doInTransactionWithoutResult(TransactionStatus status) { em.joinTransaction(); } }); } unbind(em); em.close(); } }
public FlowDefinition getActiveFlow() { return flowExecution.getActiveSession().getDefinition(); }
@Override public void sessionEnding(RequestContext context, FlowSession session, String outcome, MutableAttributeMap output) { final Session hibernateSession = getBoundHibernateSession(session); if (hibernateSession!= null && session.isRoot()) { LOG.debug("sessionEnding: Commit transaction and unbinding Hibernate session"); super.sessionEnding(context, session, outcome, output); } }
/** * Returns view scope. * @return view scope */ protected MutableAttributeMap<Object> getViewScope() throws IllegalStateException { return getFlowExecution().getActiveSession().getViewScope(); }