private void createVariables(RequestContext context) { for (FlowVariable variable : variables.values()) { if (logger.isDebugEnabled()) { logger.debug("Creating " + variable); } variable.create(context); } }
private FlowVariable parseFlowVariable(VarModel var) { Class<?> clazz = toClass(var.getClassName()); VariableValueFactory valueFactory = new BeanFactoryVariableValueFactory(clazz, getFlow() .getApplicationContext().getAutowireCapableBeanFactory()); return new FlowVariable(var.getName(), valueFactory); }
/** * Adds a flow variable. * @param variable the variable */ public void addVariable(FlowVariable variable) { variables.put(variable.getName(), variable); }
public void testRestoreVariable() { FlowVariable var = new FlowVariable("foo", new VariableValueFactory() { public Object createInitialValue(RequestContext context) { return "bar"; } public void restoreReferences(Object value, RequestContext context) { restoreCalled = true; assertEquals("bar", value); } }); MockRequestContext context = new MockRequestContext(); var.create(context); var.restore(context); assertEquals("bar", context.getFlowScope().get("foo")); assertTrue(restoreCalled); }
/** * Create flow variable flow variable. * * @param flow the flow * @param id the id * @param type the type * @return the flow variable */ public FlowVariable createFlowVariable(final Flow flow, final String id, final Class type) { val opt = Arrays.stream(flow.getVariables()).filter(v -> v.getName().equalsIgnoreCase(id)).findFirst(); if (opt.isPresent()) { return opt.get(); } val flowVar = new FlowVariable(id, new BeanFactoryVariableValueFactory(type, applicationContext.getAutowireCapableBeanFactory())); flow.addVariable(flowVar); return flowVar; }
public void testDestroyVariable() { FlowVariable var = new FlowVariable("foo", new VariableValueFactory() { public Object createInitialValue(RequestContext context) { return "bar"; } public void restoreReferences(Object value, RequestContext context) { } }); MockRequestContext context = new MockRequestContext(); var.create(context); assertEquals("bar", context.getFlowScope().get("foo")); var.destroy(context); assertFalse(context.getFlowScope().contains("foo")); }
public void testCreateVariable() { FlowVariable var = new FlowVariable("foo", new VariableValueFactory() { public Object createInitialValue(RequestContext context) { return "bar"; } public void restoreReferences(Object value, RequestContext context) { } }); MockRequestContext context = new MockRequestContext(); var.create(context); assertEquals("bar", context.getFlowScope().get("foo")); }
public void restoreVariables(RequestContext context) { for (FlowVariable variable : variables.values()) { if (logger.isDebugEnabled()) { logger.debug("Restoring " + variable); } variable.restore(context); } }
/** * Creates a new instance of this flow variable in the configured scope. * @param context the flow execution request context */ public final void create(RequestContext context) { scope.getScope(context).put(name, createVariableValue(context)); }
public void restoreVariables(RequestContext context) { for (FlowVariable variable : variables.values()) { if (logger.isDebugEnabled()) { logger.debug("Restoring " + variable); } variable.restore(context); } }
private void createVariables(RequestContext context) { for (FlowVariable variable : variables.values()) { if (logger.isDebugEnabled()) { logger.debug("Creating " + variable); } variable.create(context); } }
private FlowVariable parseFlowVariable(VarModel var) { Class clazz = toClass(var.getClassName()); VariableValueFactory valueFactory = new BeanFactoryVariableValueFactory(clazz, getFlow() .getApplicationContext().getAutowireCapableBeanFactory()); return new FlowVariable(var.getName(), valueFactory); }
/** * Adds a flow variable. * @param variable the variable */ public void addVariable(FlowVariable variable) { variables.put(variable.getName(), variable); }
public void restoreVariables(RequestContext context) { Iterator it = variables.values().iterator(); while (it.hasNext()) { FlowVariable variable = (FlowVariable) it.next(); if (logger.isDebugEnabled()) { logger.debug("Restoring " + variable); } variable.restore(context); } }
private void createVariables(RequestContext context) { Iterator it = variables.values().iterator(); while (it.hasNext()) { FlowVariable variable = (FlowVariable) it.next(); if (logger.isDebugEnabled()) { logger.debug("Creating " + variable); } variable.create(context); } }
private FlowVariable parseFlowVariable(VarModel var) { Class<?> clazz = toClass(var.getClassName()); VariableValueFactory valueFactory = new BeanFactoryVariableValueFactory(clazz, getFlow() .getApplicationContext().getAutowireCapableBeanFactory()); return new FlowVariable(var.getName(), valueFactory); }
/** * Adds a flow variable. * @param variable the variable */ public void addVariable(FlowVariable variable) { variables.put(variable.getName(), variable); }
/** * Create (setup) all known flow variables in flow scope. */ private void createVariables(RequestContext context) { Iterator it = variables.iterator(); while (it.hasNext()) { FlowVariable variable = (FlowVariable) it.next(); if (logger.isDebugEnabled()) { logger.debug("Creating " + variable); } variable.create(context); } }
public void testStartWithVariables() { MockRequestControlContext context = new MockRequestControlContext(flow); flow.addVariable(new FlowVariable("var1", new VariableValueFactory() { public Object createInitialValue(RequestContext context) { return new ArrayList<>(); } public void restoreReferences(Object value, RequestContext context) { } })); flow.start(context, new LocalAttributeMap<>()); context.getFlowScope().getRequired("var1", ArrayList.class); }
public void testFlowVariable() { model.setVars(asList(new VarModel("flow-foo", "org.springframework.webflow.TestBean"))); model.setStates(asList(new EndStateModel("end"))); Flow flow = getFlow(model); assertEquals("flow-foo", flow.getVariable("flow-foo").getName()); }