private void assembleFlow() throws FlowDefinitionConstructionException { try { assembling = true; flowDefinition = assembler.assembleFlow(); } catch (FlowBuilderException e) { throw new FlowDefinitionConstructionException(assembler.getFlowBuilderContext().getFlowId(), e); } finally { assembling = false; } }
private void registerFlowBuilders(DefaultFlowRegistry flowRegistry) { for (FlowBuilderInfo info : this.flowBuilderInfos) { AttributeMap<Object> attributes = info.getAttributes(); updateFlowAttributes(attributes); FlowBuilderContext builderContext = new FlowBuilderContextImpl( info.getId(), attributes, flowRegistry, this.flowBuilderServices); FlowAssembler assembler = new FlowAssembler(info.getBuilder(), builderContext); flowRegistry.registerFlowDefinition(assembler.assembleFlow()); } }
/** * Factory method to assemble a flow definition from a resource. Called by {@link #getFlowDefinition()} to create * the "main" flow to test. May also be called by subclasses to create subflow definitions whose executions should * also be exercised by this test. * @return the built flow definition, ready for execution */ protected final Flow buildFlow() { FlowDefinitionResource resource = getResource(getResourceFactory()); flowBuilderContext = new MockFlowBuilderContext(resource.getId(), resource.getAttributes()); configureFlowBuilderContext(flowBuilderContext); FlowBuilder builder = createFlowBuilder(resource); FlowAssembler assembler = new FlowAssembler(builder, flowBuilderContext); return assembler.assembleFlow(); }
private FlowDefinition buildFlowDefinition(FlowBuilderInfo builderInfo) { try { Class<?> flowBuilderClass = loadClass(builderInfo.getClassName()); FlowBuilder builder = (FlowBuilder) flowBuilderClass.newInstance(); AttributeMap<Object> flowAttributes = getFlowAttributes(builderInfo.getAttributes()); FlowBuilderContext builderContext = new FlowBuilderContextImpl(builderInfo.getId(), flowAttributes, flowRegistry, flowBuilderServices); FlowAssembler assembler = new FlowAssembler(builder, builderContext); return assembler.assembleFlow(); } catch (IllegalArgumentException e) { throw new FlowDefinitionConstructionException(builderInfo.getId(), e); } catch (InstantiationException e) { throw new FlowDefinitionConstructionException(builderInfo.getId(), e); } catch (IllegalAccessException e) { throw new FlowDefinitionConstructionException(builderInfo.getId(), e); } }
/** * Assemble the held flow definition, delegating to the configured FlowAssembler (director). */ protected void assembleFlow() throws FlowBuilderException { if (logger.isDebugEnabled()) { logger.debug("Assembling flow definition with id '" + assembler.getFlowId() + "'"); } try { assembling = true; flowDefinition = assembler.assembleFlow(); } finally { assembling = false; } }
private void assembleFlow() throws FlowDefinitionConstructionException { try { assembling = true; flowDefinition = assembler.assembleFlow(); } catch (FlowBuilderException e) { throw new FlowDefinitionConstructionException(assembler.getFlowBuilderContext().getFlowId(), e); } finally { assembling = false; } }
private void assembleFlow() throws FlowDefinitionConstructionException { try { assembling = true; flowDefinition = assembler.assembleFlow(); } catch (FlowBuilderException e) { throw new FlowDefinitionConstructionException(assembler.getFlowBuilderContext().getFlowId(), e); } finally { assembling = false; } }
/** * Factory method to assemble a flow definition from a resource. Called by {@link #getFlowDefinition()} to create * the "main" flow to test. May also be called by subclasses to create subflow definitions whose executions should * also be exercised by this test. * @param resource the flow definition resource * @return the built flow definition, ready for execution * @see #createFlowBuilder(Resource, FlowServiceLocator) */ protected final Flow createFlow(FlowDefinitionResource resource, FlowServiceLocator serviceLocator) { FlowBuilder builder = createFlowBuilder(resource.getLocation(), serviceLocator); FlowAssembler assembler = new FlowAssembler(resource.getId(), resource.getAttributes(), builder); return assembler.assembleFlow(); }
public void testDisposeCalledOnException() { builder.init(builderContext); EasyMock.expectLastCall().andThrow(new IllegalArgumentException()); builder.dispose(); EasyMock.replay(builder); try { assembler.assembleFlow(); fail("Should have failed"); } catch (IllegalArgumentException e) { EasyMock.verify(builder); } } }
/** * Register the flow built by given flow builder in specified flow definition registry. * <p> * Note that this method will set the {@link #getFlowServiceLocator() flow service locator} of this class on given * flow builder. * @param registry the registry to register the flow in * @param flowId the flow id to assign * @param flowAttributes externally assigned flow attributes that can affect flow construction * @param flowBuilder the builder used to build the flow */ protected void registerFlowDefinition(FlowDefinitionRegistry registry, String flowId, AttributeMap flowAttributes, AbstractFlowBuilder flowBuilder) { flowBuilder.setFlowServiceLocator(getFlowServiceLocator()); Flow flow = new FlowAssembler(flowId, flowAttributes, flowBuilder).assembleFlow(); FlowDefinitionHolder flowHolder = new StaticFlowDefinitionHolder(flow); registry.registerFlowDefinition(flowHolder); } }
private void registerFlowBuilders(DefaultFlowRegistry flowRegistry) { for (FlowBuilderInfo info : this.flowBuilderInfos) { AttributeMap<Object> attributes = info.getAttributes(); updateFlowAttributes(attributes); FlowBuilderContext builderContext = new FlowBuilderContextImpl( info.getId(), attributes, flowRegistry, this.flowBuilderServices); FlowAssembler assembler = new FlowAssembler(info.getBuilder(), builderContext); flowRegistry.registerFlowDefinition(assembler.assembleFlow()); } }
/** * Factory method to assemble a flow definition from a resource. Called by {@link #getFlowDefinition()} to create * the "main" flow to test. May also be called by subclasses to create subflow definitions whose executions should * also be exercised by this test. * @return the built flow definition, ready for execution */ protected final Flow buildFlow() { FlowDefinitionResource resource = getResource(getResourceFactory()); flowBuilderContext = new MockFlowBuilderContext(resource.getId(), resource.getAttributes()); configureFlowBuilderContext(flowBuilderContext); FlowBuilder builder = createFlowBuilder(resource); FlowAssembler assembler = new FlowAssembler(builder, flowBuilderContext); return assembler.assembleFlow(); }
/** * Factory method to assemble a flow definition from a resource. Called by {@link #getFlowDefinition()} to create * the "main" flow to test. May also be called by subclasses to create subflow definitions whose executions should * also be exercised by this test. * @return the built flow definition, ready for execution */ protected final Flow buildFlow() { FlowDefinitionResource resource = getResource(getResourceFactory()); flowBuilderContext = new MockFlowBuilderContext(resource.getId(), resource.getAttributes()); configureFlowBuilderContext(flowBuilderContext); FlowBuilder builder = createFlowBuilder(resource); FlowAssembler assembler = new FlowAssembler(builder, flowBuilderContext); return assembler.assembleFlow(); }
private FlowDefinition buildFlowDefinition(FlowBuilderInfo builderInfo) { try { Class<?> flowBuilderClass = loadClass(builderInfo.getClassName()); FlowBuilder builder = (FlowBuilder) flowBuilderClass.newInstance(); AttributeMap<Object> flowAttributes = getFlowAttributes(builderInfo.getAttributes()); FlowBuilderContext builderContext = new FlowBuilderContextImpl(builderInfo.getId(), flowAttributes, flowRegistry, flowBuilderServices); FlowAssembler assembler = new FlowAssembler(builder, builderContext); return assembler.assembleFlow(); } catch (IllegalArgumentException e) { throw new FlowDefinitionConstructionException(builderInfo.getId(), e); } catch (InstantiationException e) { throw new FlowDefinitionConstructionException(builderInfo.getId(), e); } catch (IllegalAccessException e) { throw new FlowDefinitionConstructionException(builderInfo.getId(), e); } }
private FlowDefinition buildFlowDefinition(FlowBuilderInfo builderInfo) { try { Class flowBuilderClass = loadClass(builderInfo.getClassName()); FlowBuilder builder = (FlowBuilder) flowBuilderClass.newInstance(); AttributeMap flowAttributes = getFlowAttributes(builderInfo.getAttributes()); FlowBuilderContext builderContext = new FlowBuilderContextImpl(builderInfo.getId(), flowAttributes, flowRegistry, flowBuilderServices); FlowAssembler assembler = new FlowAssembler(builder, builderContext); return assembler.assembleFlow(); } catch (IllegalArgumentException e) { throw new FlowDefinitionConstructionException(builderInfo.getId(), e); } catch (InstantiationException e) { throw new FlowDefinitionConstructionException(builderInfo.getId(), e); } catch (IllegalAccessException e) { throw new FlowDefinitionConstructionException(builderInfo.getId(), e); } }
private Flow getFlow(FlowModel model) { FlowModelHolder holder = new StaticFlowModelHolder(model); FlowModelFlowBuilder builder = new FlowModelFlowBuilder(holder); FlowAssembler assembler = new FlowAssembler(builder, new MockFlowBuilderContext("flow")); return assembler.assembleFlow(); }
public void testAssembleFlow() { builder.init(builderContext); builder.dispose(); builder.buildVariables(); builder.buildInputMapper(); builder.buildStartActions(); builder.buildStates(); builder.buildGlobalTransitions(); builder.buildEndActions(); builder.buildOutputMapper(); builder.buildExceptionHandlers(); EasyMock.expect(builder.getFlow()).andReturn(new Flow("search")); EasyMock.replay(builder); Flow flow = assembler.assembleFlow(); assertEquals("search", flow.getId()); EasyMock.verify(builder); }
private Flow getFlow(ClassPathResource resource) { FlowModelHolder holder = new DefaultFlowModelHolder(new XmlFlowModelBuilder(resource, new FlowModelRegistryImpl())); FlowModelFlowBuilder builder = new FlowModelFlowBuilder(holder); FlowAssembler assembler = new FlowAssembler(builder, new MockFlowBuilderContext("flow")); return assembler.assembleFlow(); }
public void testStateExceptionHandlingExceptionInEndState() { FlowBuilder builder = new AbstractFlowBuilder() { public void buildStates() throws FlowBuilderException { State state = new EndState(getFlow(), "end"); state.getEntryActionList().add(new AbstractAction() { protected Event doExecute(RequestContext context) throws Exception { throw new NullPointerException("failing"); } }); new TransitionableState(getFlow(), "showError") { protected void doEnter(RequestControlContext context) throws FlowExecutionException { } }; } public void buildExceptionHandlers() throws FlowBuilderException { getFlow().getExceptionHandlerSet().add( new TransitionExecutingFlowExecutionExceptionHandler().add(Exception.class, "showError")); } public Flow createFlow() throws FlowBuilderException { return Flow.create(getContext().getFlowId(), getContext().getFlowAttributes()); } }; Flow flow = new FlowAssembler(builder, new MockFlowBuilderContext("flow")).assembleFlow(); FlowExecution execution = new FlowExecutionImplFactory().createFlowExecution(flow); execution.start(null, new MockExternalContext()); assertTrue(execution.isActive()); }
public void testExceptionHandlers() { FlowModel model = new FlowModel(); model.setStates(asList(new EndStateModel("state"))); model.setExceptionHandlers(asList(new ExceptionHandlerModel("exceptionHandler"))); FlowExecutionExceptionHandler handler = new FlowExecutionExceptionHandler() { public boolean canHandle(FlowExecutionException exception) { return true; } public void handle(FlowExecutionException exception, RequestControlContext context) { } }; FlowModelFlowBuilder builder = new FlowModelFlowBuilder(new StaticFlowModelHolder(model)); MockFlowBuilderContext context = new MockFlowBuilderContext("foo"); context.registerBean("exceptionHandler", handler); FlowAssembler assembler = new FlowAssembler(builder, context); Flow flow = assembler.assembleFlow(); assertEquals(1, flow.getExceptionHandlerSet().size()); }