jpaListener = new JpaFlowExecutionListener(entityManagerFactory, tm);
ClassPathResource res = new ClassPathResource("flow-managed-persistence.xml", getClass());
DefaultFlowModelHolder holder = new DefaultFlowModelHolder(new XmlFlowModelBuilder(res));
FlowModelFlowBuilder builder = new FlowModelFlowBuilder(holder);
MockFlowBuilderContext context = new MockFlowBuilderContext("foo");
FlowAssembler assembler = new FlowAssembler(builder, context);
Flow flow = assembler.assembleFlow();
context.registerSubflow(flow);
Flow notManaged = new Flow("notmanaged");
new EndState(notManaged, "finish");
context.registerSubflow(notManaged);
context.registerBean("loadTestBean", new Action() {
public Event execute(RequestContext context) throws Exception {
assertSessionBound();
EntityManager em = (EntityManager) context.getFlowScope().get("persistenceContext");
TestBean bean = (TestBean) em.getReference(TestBean.class, new Integer(0));
assertNotNull(bean);
context.getFlowScope().put("testBean", bean);
return new Event(this, "success");
}
});
FlowExecutionImplFactory factory = new FlowExecutionImplFactory();
factory.setExecutionListenerLoader(new StaticFlowExecutionListenerLoader(jpaListener));