public Object getValue(Object context) throws EvaluationException { String subflowId = (String) this.subflowId.getValue(context); return flowDefinitionLocator.getFlowDefinition(subflowId); }
public FlowExecution restoreExecution(FlowExecutionSnapshot snapshot, String flowId, FlowExecutionKey key, MutableAttributeMap<Object> conversationScope, FlowExecutionKeyFactory keyFactory) throws FlowExecutionRestorationFailureException { SimpleFlowExecutionSnapshot snapshotImpl = (SimpleFlowExecutionSnapshot) snapshot; FlowDefinition def = flowDefinitionLocator.getFlowDefinition(flowId); FlowExecution execution = snapshotImpl.getFlowExecution(); flowExecutionFactory.restoreFlowExecution(execution, def, key, conversationScope, flowDefinitionLocator); return execution; }
public FlowExecution restoreExecution(FlowExecutionSnapshot snapshot, String flowId, FlowExecutionKey key, MutableAttributeMap<Object> conversationScope, FlowExecutionKeyFactory keyFactory) throws FlowExecutionRestorationFailureException { SerializedFlowExecutionSnapshot snapshotImpl = (SerializedFlowExecutionSnapshot) snapshot; FlowDefinition def = flowDefinitionLocator.getFlowDefinition(flowId); FlowExecution execution; try { execution = snapshotImpl.unmarshal(def.getClassLoader()); } catch (SnapshotUnmarshalException e) { throw new FlowExecutionRestorationFailureException(key, e); } flowExecutionFactory.restoreFlowExecution(execution, def, key, conversationScope, flowDefinitionLocator); return execution; }
public FlowExecutionResult launchExecution(String flowId, MutableAttributeMap<?> input, ExternalContext context) throws FlowException { try { if (logger.isDebugEnabled()) { logger.debug("Launching new execution of flow '" + flowId + "' with input " + input); } ExternalContextHolder.setExternalContext(context); FlowDefinition flowDefinition = definitionLocator.getFlowDefinition(flowId); FlowExecution flowExecution = executionFactory.createFlowExecution(flowDefinition); flowExecution.start(input, context); if (!flowExecution.hasEnded()) { FlowExecutionLock lock = executionRepository.getLock(flowExecution.getKey()); lock.lock(); try { executionRepository.putFlowExecution(flowExecution); } finally { lock.unlock(); } return createPausedResult(flowExecution); } else { return createEndResult(flowExecution); } } finally { ExternalContextHolder.setExternalContext(null); } }
for (Iterator<FlowSessionImpl> it = execution.getSubflowSessionIterator(); it.hasNext();) { FlowSessionImpl subflowSession = it.next(); Flow subflowDef = (Flow) subflowDefinitionLocator.getFlowDefinition(subflowSession.getFlowId()); subflowSession.setFlow(subflowDef); subflowSession.setState(subflowDef.getStateInstance(subflowSession.getStateId()));
public Object getValue(Object context) throws EvaluationException { String subflowId = (String) this.subflowId.getValue(context); return flowDefinitionLocator.getFlowDefinition(subflowId); }
public Object getValue(Object context) throws EvaluationException { String subflowId = (String) this.subflowId.getValue(context); return flowDefinitionLocator.getFlowDefinition(subflowId); }
public FlowExecution restoreExecution(FlowExecutionSnapshot snapshot, String flowId, FlowExecutionKey key, MutableAttributeMap conversationScope, FlowExecutionKeyFactory keyFactory) throws FlowExecutionRestorationFailureException { SimpleFlowExecutionSnapshot snapshotImpl = (SimpleFlowExecutionSnapshot) snapshot; FlowDefinition def = flowDefinitionLocator.getFlowDefinition(flowId); FlowExecution execution = snapshotImpl.getFlowExecution(); flowExecutionFactory.restoreFlowExecution(execution, def, key, conversationScope, flowDefinitionLocator); return execution; }
public FlowExecution restoreExecution(FlowExecutionSnapshot snapshot, String flowId, FlowExecutionKey key, MutableAttributeMap<Object> conversationScope, FlowExecutionKeyFactory keyFactory) throws FlowExecutionRestorationFailureException { SimpleFlowExecutionSnapshot snapshotImpl = (SimpleFlowExecutionSnapshot) snapshot; FlowDefinition def = flowDefinitionLocator.getFlowDefinition(flowId); FlowExecution execution = snapshotImpl.getFlowExecution(); flowExecutionFactory.restoreFlowExecution(execution, def, key, conversationScope, flowDefinitionLocator); return execution; }
private boolean isNotValidFlowDefinitionId(@SuppressWarnings("unused") FlowExecution flowExecution, GrailsWebRequest webRequest) { final FlowDefinitionLocator locator = getDefinitionLocator(); final String requestPath = webRequest.getControllerName() + "/" + webRequest.getActionName(); try { locator.getFlowDefinition(requestPath); return false; } catch (NoSuchFlowDefinitionException e) { return true; } } }
@Override public FlowExecution getFlowExecution(final FlowExecutionKey key) throws FlowExecutionRepositoryException { Assert.notNull(flowExecutionFactory, "FlowExecutionFactory cannot be null"); Assert.notNull(flowDefinitionLocator, "FlowDefinitionLocator cannot be null"); Assert.notNull(transcoder, "Transcoder cannot be null"); if (!(key instanceof ClientFlowExecutionKey)) { throw new IllegalArgumentException( "Expected instance of ClientFlowExecutionKey but got " + key.getClass().getName()); } final byte[] encoded = ((ClientFlowExecutionKey) key).getData(); try { final SerializedFlowExecutionState state = (SerializedFlowExecutionState) this.transcoder.decode(encoded); final FlowDefinition flow = this.flowDefinitionLocator.getFlowDefinition(state.getFlowId()); return this.flowExecutionFactory.restoreFlowExecution( state.getExecution(), flow, key, state.getConversationScope(), this.flowDefinitionLocator); } catch (final IOException e) { throw new ClientFlowExecutionRepositoryException("Error decoding flow execution", e); } }
public FlowExecution restoreExecution(FlowExecutionSnapshot snapshot, String flowId, FlowExecutionKey key, MutableAttributeMap<Object> conversationScope, FlowExecutionKeyFactory keyFactory) throws FlowExecutionRestorationFailureException { SerializedFlowExecutionSnapshot snapshotImpl = (SerializedFlowExecutionSnapshot) snapshot; FlowDefinition def = flowDefinitionLocator.getFlowDefinition(flowId); FlowExecution execution; try { execution = snapshotImpl.unmarshal(def.getClassLoader()); } catch (SnapshotUnmarshalException e) { throw new FlowExecutionRestorationFailureException(key, e); } flowExecutionFactory.restoreFlowExecution(execution, def, key, conversationScope, flowDefinitionLocator); return execution; }
public FlowExecution restoreExecution(FlowExecutionSnapshot snapshot, String flowId, FlowExecutionKey key, MutableAttributeMap conversationScope, FlowExecutionKeyFactory keyFactory) throws FlowExecutionRestorationFailureException { SerializedFlowExecutionSnapshot snapshotImpl = (SerializedFlowExecutionSnapshot) snapshot; FlowDefinition def = flowDefinitionLocator.getFlowDefinition(flowId); FlowExecution execution; try { execution = snapshotImpl.unmarshal(def.getClassLoader()); } catch (SnapshotUnmarshalException e) { throw new FlowExecutionRestorationFailureException(key, e); } flowExecutionFactory.restoreFlowExecution(execution, def, key, conversationScope, flowDefinitionLocator); return execution; }
public FlowExecutionResult launchExecution(String flowId, MutableAttributeMap input, ExternalContext context) throws FlowException { try { if (logger.isDebugEnabled()) { logger.debug("Launching new execution of flow '" + flowId + "' with input " + input); } ExternalContextHolder.setExternalContext(context); FlowDefinition flowDefinition = definitionLocator.getFlowDefinition(flowId); FlowExecution flowExecution = executionFactory.createFlowExecution(flowDefinition); flowExecution.start(input, context); if (!flowExecution.hasEnded()) { executionRepository.putFlowExecution(flowExecution); return createPausedResult(flowExecution); } else { return createEndResult(flowExecution); } } finally { ExternalContextHolder.setExternalContext(null); } }
public FlowExecutionResult launchExecution(String flowId, MutableAttributeMap<?> input, ExternalContext context) throws FlowException { try { if (logger.isDebugEnabled()) { logger.debug("Launching new execution of flow '" + flowId + "' with input " + input); } ExternalContextHolder.setExternalContext(context); FlowDefinition flowDefinition = definitionLocator.getFlowDefinition(flowId); FlowExecution flowExecution = executionFactory.createFlowExecution(flowDefinition); flowExecution.start(input, context); if (!flowExecution.hasEnded()) { FlowExecutionLock lock = executionRepository.getLock(flowExecution.getKey()); lock.lock(); try { executionRepository.putFlowExecution(flowExecution); } finally { lock.unlock(); } return createPausedResult(flowExecution); } else { return createEndResult(flowExecution); } } finally { ExternalContextHolder.setExternalContext(null); } }
public ResponseInstruction launch(String flowDefinitionId, ExternalContext context) throws FlowException { if (logger.isDebugEnabled()) { logger.debug("Launching flow execution for flow definition '" + flowDefinitionId + "'"); } // expose external context as a thread-bound service ExternalContextHolder.setExternalContext(context); try { FlowDefinition flowDefinition = definitionLocator.getFlowDefinition(flowDefinitionId); FlowExecution flowExecution = executionFactory.createFlowExecution(flowDefinition); ViewSelection selectedView = flowExecution.start(createInput(context), context); if (flowExecution.isActive()) { // execution still active => store it in the repository FlowExecutionKey key = executionRepository.generateKey(flowExecution); FlowExecutionLock lock = executionRepository.getLock(key); lock.lock(); try { executionRepository.putFlowExecution(key, flowExecution); } finally { lock.unlock(); } return new ResponseInstruction(key.toString(), flowExecution, selectedView); } else { // execution already ended => just render the selected view return new ResponseInstruction(flowExecution, selectedView); } } finally { ExternalContextHolder.setExternalContext(null); } }
for (Iterator<FlowSessionImpl> it = execution.getSubflowSessionIterator(); it.hasNext();) { FlowSessionImpl subflowSession = it.next(); Flow subflowDef = (Flow) subflowDefinitionLocator.getFlowDefinition(subflowSession.getFlowId()); subflowSession.setFlow(subflowDef); subflowSession.setState(subflowDef.getStateInstance(subflowSession.getStateId()));
for (Iterator it = execution.getSubflowSessionIterator(); it.hasNext();) { FlowSessionImpl subflowSession = (FlowSessionImpl) it.next(); Flow subflowDef = (Flow) subflowDefinitionLocator.getFlowDefinition(subflowSession.getFlowId()); subflowSession.setFlow(subflowDef); subflowSession.setState(subflowDef.getStateInstance(subflowSession.getStateId()));
public void testLaunchFlowExecution() { String flowId = "foo"; MutableAttributeMap<Object> input = null; MockExternalContext context = new MockExternalContext(); EasyMock.expect(locator.getFlowDefinition(flowId)).andReturn(definition); EasyMock.expect(factory.createFlowExecution(definition)).andReturn(execution); execution.start(input, context); execution.hasEnded(); EasyMock.expectLastCall().andReturn(false); MockFlowExecutionKey flowExecutionKey = new MockFlowExecutionKey("12345"); EasyMock.expect(execution.getKey()).andReturn(flowExecutionKey); EasyMock.expect(repository.getLock(flowExecutionKey)).andReturn(lock); lock.lock(); repository.putFlowExecution(execution); lock.unlock(); EasyMock.expect(execution.getDefinition()).andReturn(definition); EasyMock.expect(definition.getId()).andReturn("foo"); EasyMock.expect(execution.getKey()).andReturn(flowExecutionKey); replayMocks(); FlowExecutionResult result = flowExecutor.launchExecution("foo", null, context); assertTrue(result.isPaused()); assertEquals("12345", result.getPausedKey()); assertFalse(result.isEnded()); assertNull(result.getOutcome()); assertNull(ExternalContextHolder.getExternalContext()); verifyMocks(); }
public FlowExecution restoreState(FlowExecution flowExecution, MutableAttributeMap conversationScope) { FlowExecutionImpl impl = (FlowExecutionImpl) flowExecution; Flow flow = (Flow) definitionLocator.getFlowDefinition(impl.getFlowId()); impl.setFlow(flow); if (impl.hasSessions()) { } else { definition = (Flow) definitionLocator.getFlowDefinition(subflow.getFlowId());