Anonymous avatar Anonymous committed 34fce44

Refactored spring factory to the right package

Comments (0)

Files changed (24)

src/java/com/opensymphony/workflow/loader/SpringBeanNameWorkflowFactory.java

-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.workflow.loader;
-
-import com.opensymphony.workflow.FactoryException;
-
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-
-import java.util.Properties;
-
-
-/**
- * Spring-compliant implementation of {@link AbstractWorkflowFactory}. This
- * workflow factory retrieves {@link WorkflowDescriptor}s from the Spring's
- * {@link ApplicationContext}. The name of the WorkflowDescriptors is the name
- * of the bean in the applicationContext. <br />
- * Motivation: reduce number of external configuration files leaving only
- * workflow definitions files. <br />
- * <ul>
- * <li>SpringConfiguration replaces osworkflow.xml</li>
- * <li>WorkflowFactoryImpl replaces workflows.xml</li>
- * </ul>
- * Usage:
- * <pre>
- * &lt;bean id=&quot;myworkflow&quot; class=&quot;com.opensymphony.workflow.loader.WorkflowDescriptorFactoryBean&quot;&gt;
- *     &lt;property name=&quot;descriptorResource&quot;&gt;
- *         &lt;value&gt;classpath:/META-INF/workflow/myworkflow.xml&lt;/value&gt;
- *     &lt;/property&gt;
- * &lt;/bean&gt;
- *
- * &lt;bean id=&quot;workflowFactory&quot; class=&quot;com.opensymphony.workflow.loader.BeanNameWorkflowFactory&quot;/&gt;
- * </pre>
- *
- * @author xd
- */
-public class SpringBeanNameWorkflowFactory implements WorkflowFactory, ApplicationContextAware {
-    //~ Instance fields ////////////////////////////////////////////////////////
-
-    //////////////////////////////////////////////////~ Instance attributes. //
-
-    /** The applicationContext. */
-    private ApplicationContext applicationContext;
-
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    public void setApplicationContext(final ApplicationContext inApplicationContext) {
-        this.applicationContext = inApplicationContext;
-    }
-
-    public void setLayout(String workflowName, Object layout) {
-    }
-
-    public Object getLayout(String workflowName) {
-        return null;
-    }
-
-    public boolean isModifiable(String name) {
-        return false;
-    }
-
-    public String getName() {
-        return null;
-    }
-
-    public Properties getProperties() {
-        return null;
-    }
-
-    //////////////////////////~ AbstractWorkflowFactory implemented methods. //
-    public WorkflowDescriptor getWorkflow(final String inName) {
-        return (WorkflowDescriptor) this.applicationContext.getBean(inName);
-    }
-
-    public WorkflowDescriptor getWorkflow(String name, boolean validate) throws FactoryException {
-        return getWorkflow(name);
-    }
-
-    public String[] getWorkflowNames() {
-        return this.applicationContext.getBeanDefinitionNames(WorkflowDescriptor.class);
-    }
-
-    public void createWorkflow(String name) {
-    }
-
-    public void init(Properties p) {
-    }
-
-    public void initDone() throws FactoryException {
-    }
-
-    public boolean removeWorkflow(final String inName) throws FactoryException {
-        throw new FactoryException("Unsupported operation.");
-    }
-
-    public void renameWorkflow(String oldName, String newName) {
-    }
-
-    public void save() {
-    }
-
-    public boolean saveWorkflow(final String inName, final WorkflowDescriptor inDescriptor, final boolean inReplace) throws FactoryException {
-        throw new FactoryException("Unsupported operation.");
-    }
-}

src/java/com/opensymphony/workflow/loader/SpringHibernateWorkflowFactory.java

-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-/*
- * Created on 30-nov-2005
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package com.opensymphony.workflow.loader;
-
-import com.opensymphony.workflow.FactoryException;
-import com.opensymphony.workflow.InvalidWorkflowDescriptorException;
-
-import net.sf.hibernate.HibernateException;
-import net.sf.hibernate.Session;
-import net.sf.hibernate.SessionFactory;
-
-import org.springframework.dao.DataAccessException;
-
-import org.springframework.orm.hibernate.HibernateCallback;
-import org.springframework.orm.hibernate.HibernateTemplate;
-
-import java.sql.SQLException;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-
-/**
- * DOCUMENT ME!
- *
- * @author $author$
- * @version $Revision$
- */
-public class SpringHibernateWorkflowFactory extends AbstractWorkflowFactory {
-    //~ Static fields/initializers /////////////////////////////////////////////
-
-    private static boolean forceReload;
-
-    //~ Instance fields ////////////////////////////////////////////////////////
-
-    private Map workflows;
-    private SessionFactory sessionFactory;
-    private boolean reload = false;
-    private boolean validate = false;
-
-    //~ Constructors ///////////////////////////////////////////////////////////
-
-    public SpringHibernateWorkflowFactory() {
-        super();
-    }
-
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    public void setLayout(String workflowName, Object layout) {
-    }
-
-    public Object getLayout(String workflowName) {
-        return null;
-    }
-
-    public boolean isModifiable(String name) {
-        return true;
-    }
-
-    public String getName() {
-        return "";
-    }
-
-    public void setReload(boolean reload) {
-        this.reload = reload;
-    }
-
-    public void setSessionFactory(SessionFactory sessionFactory) {
-        this.sessionFactory = sessionFactory;
-    }
-
-    public void setValidate(boolean validate) {
-        this.validate = validate;
-    }
-
-    public WorkflowDescriptor getWorkflow(String name, boolean validate) throws FactoryException {
-        if (!workflows.containsKey(name)) {
-            throw new FactoryException("Unknown workflow name \"" + name + '\"');
-        }
-
-        if (reload || forceReload) {
-            forceReload = false;
-            loadWorkflow(name, validate);
-        }
-
-        return (WorkflowDescriptor) workflows.get(name);
-    }
-
-    public String[] getWorkflowNames() throws FactoryException {
-        int i = 0;
-        String[] res = new String[workflows.keySet().size()];
-        Iterator it = workflows.keySet().iterator();
-
-        while (it.hasNext()) {
-            res[i++] = (String) it.next();
-        }
-
-        return res;
-    }
-
-    public void createWorkflow(String name) {
-    }
-
-    public static void forceReload() {
-        forceReload = true;
-    }
-
-    public void initDone() throws FactoryException {
-        try {
-            workflows = new HashMap();
-
-            List workflowNames = new HibernateTemplate(sessionFactory).find("select wfn.workflowName from WorkflowName wfn");
-
-            for (Iterator iter = workflowNames.iterator(); iter.hasNext();) {
-                String wfn = iter.next().toString();
-                loadWorkflow(wfn, validate);
-            }
-        } catch (Exception e) {
-            throw new FactoryException(e);
-        }
-    }
-
-    public boolean removeWorkflow(String name) throws FactoryException {
-        final HibernateTemplate hibernateTemplate = new HibernateTemplate(sessionFactory);
-        WorkflowName wfn = (WorkflowName) hibernateTemplate.load(WorkflowName.class, name);
-
-        if (wfn != null) {
-            hibernateTemplate.delete(wfn);
-
-            return true;
-        }
-
-        return false;
-    }
-
-    public void renameWorkflow(String oldName, String newName) {
-        final HibernateTemplate hibernateTemplate = new HibernateTemplate(sessionFactory);
-        WorkflowName wfn = (WorkflowName) hibernateTemplate.load(WorkflowName.class, oldName);
-        wfn.setWorkflowName(newName);
-    }
-
-    public void save() {
-    }
-
-    public boolean saveWorkflow(String name, WorkflowDescriptor descriptor, boolean replace) throws FactoryException {
-        WorkflowName wfn = new WorkflowName();
-        wfn.setWorkflowName(name);
-        wfn.setWorkflowDescriptor(descriptor);
-
-        final HibernateTemplate hibernateTemplate = new HibernateTemplate(sessionFactory);
-        hibernateTemplate.saveOrUpdate(wfn);
-
-        initDone();
-
-        return false;
-    }
-
-    private synchronized void loadWorkflow(final String workflowName, final boolean validate) throws FactoryException {
-        try {
-            new HibernateTemplate(sessionFactory).execute(new HibernateCallback() {
-                    public Object doInHibernate(Session session) throws HibernateException, SQLException {
-                        try {
-                            WorkflowName wfn = (WorkflowName) session.load(WorkflowName.class, workflowName);
-
-                            if (validate) {
-                                wfn.getWorkflowDescriptor().validate();
-                            }
-
-                            workflows.put(wfn.getWorkflowName(), wfn.getWorkflowDescriptor());
-
-                            return null;
-                        } catch (InvalidWorkflowDescriptorException e) {
-                            throw new RuntimeException(e);
-                        }
-                    }
-                });
-        } catch (Exception e) {
-            throw new FactoryException(e);
-        }
-    }
-}

src/java/com/opensymphony/workflow/loader/SpringWorkflowDescriptorFactory.java

-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.workflow.loader;
-
-import com.opensymphony.workflow.InvalidWorkflowDescriptorException;
-
-import org.springframework.beans.factory.FactoryBean;
-
-import org.springframework.core.io.Resource;
-
-import org.xml.sax.SAXException;
-
-import java.io.IOException;
-
-
-/**
- * DOCUMENT ME!
- *
- * @author $author$
- * @version $Revision: 1.1 $
- */
-public class SpringWorkflowDescriptorFactory implements FactoryBean {
-    //~ Instance fields ////////////////////////////////////////////////////////
-
-    /** The descriptor resource. */
-    private Resource descriptorResource;
-
-    /** Should the descriptor be reloaded on each call. */
-    private boolean reload;
-
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    public final void setDescriptorResource(final Resource inDescriptorResource) {
-        this.descriptorResource = inDescriptorResource;
-    }
-
-    public Object getObject() throws InvalidWorkflowDescriptorException, SAXException, IOException {
-        return WorkflowLoader.load(this.descriptorResource.getInputStream(), false);
-    }
-
-    public Class getObjectType() {
-        return WorkflowDescriptor.class;
-    }
-
-    public final void setReload(final boolean inReload) {
-        this.reload = inReload;
-    }
-
-    public boolean isSingleton() {
-        return !this.reload;
-    }
-}

src/java/com/opensymphony/workflow/loader/SpringWorkflowFactory.java

-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.workflow.loader;
-
-import com.opensymphony.workflow.FactoryException;
-
-import java.util.Properties;
-
-
-/**
- * DOCUMENT ME!
- */
-public class SpringWorkflowFactory extends XMLWorkflowFactory {
-    //~ Instance fields ////////////////////////////////////////////////////////
-
-    private String resource;
-
-    //~ Constructors ///////////////////////////////////////////////////////////
-
-    public SpringWorkflowFactory() {
-        super();
-    }
-
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    public void setReload(String reload) {
-        this.reload = Boolean.valueOf(reload).booleanValue();
-    }
-
-    public void setResource(String resource) {
-        this.resource = resource;
-    }
-
-    public void init() {
-        try {
-            Properties props = new Properties();
-            props.setProperty("reload", getReload());
-            props.setProperty("resource", getResource());
-
-            super.init(props);
-            initDone();
-        } catch (FactoryException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    private String getReload() {
-        return String.valueOf(reload);
-    }
-
-    private String getResource() {
-        return resource;
-    }
-}

src/java/com/opensymphony/workflow/loader/WorkflowDescriptor.hbm.xml

-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
-	"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
-	"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
-<!-- com.opensymphony.workflow.loader.ResultDescriptor already added -->
-<hibernate-mapping default-cascade="all">
-	<!-- com.opensymphony.workflow.loader.Workflows -->
-	<class name="com.opensymphony.workflow.loader.WorkflowName" >
-		<id name="workflowName" unsaved-value="any">
-			<generator class="assigned"/>
-		</id>
-		<many-to-one name="workflowDescriptor" cascade="save-update" />
-	</class>
-
-	<!-- com.opensymphony.workflow.loader.AbstractDescriptor root -->
-	<class name="com.opensymphony.workflow.loader.AbstractDescriptor" >
-		<id name="entityId" unsaved-value="0">
-			<generator class="native"/>
-		</id>
-		
-		<!-- discriminator column="class"/-->
-		<property name="id" column="id" />
-		<many-to-one name="parent" class="com.opensymphony.workflow.loader.AbstractDescriptor" cascade="none"/>
-		<!-- com.opensymphony.workflow.loader.ActionDescriptor -->
-		<joined-subclass name="com.opensymphony.workflow.loader.ActionDescriptor">
-			<key column="abstractDescriptorId"/>
-			<property name="view" column="viewProperty" />
-			<property name="name" column="name"/>
-			<property name="finish" column="finish"/>
-			<property name="autoExecute" column="autoExecute" />
-			<property name="common" column="common"/>
-			<many-to-one name="restriction" />
-			<many-to-one name="unconditionalResult"/>
-			<list name="conditionalResults" lazy="false" access="field" cascade="all-delete-orphan">
-				<key column="parentActionDescr"/>
-				<index column="listOrder"/>
-				<one-to-many class="com.opensymphony.workflow.loader.ConditionalResultDescriptor" />					
-			</list>			
-			<list name="validators" lazy="false" access="field" cascade="all-delete-orphan">
-				<key column="parentActionDescr"/>
-				<index column="listOrder"/>
-				<one-to-many class="com.opensymphony.workflow.loader.ValidatorDescriptor" />					
-			</list>			
-			<list name="postFunctions" lazy="false" access="field" cascade="all-delete-orphan">
-				<key column="parentActionDescrPost"/>
-				<index column="listOrder"/>
-				<one-to-many class="com.opensymphony.workflow.loader.FunctionDescriptor" />					
-			</list>			
-			<list name="preFunctions" lazy="false" access="field" cascade="all-delete-orphan">
-				<key column="parentActionDescrPre"/>
-				<index column="listOrder"/>
-				<one-to-many class="com.opensymphony.workflow.loader.FunctionDescriptor" />					
-			</list>						
-			<map name="metaAttributes" table="actionMetaAttributes" lazy="false" >
-				<key column="entityCode"/>
-				<index column="keyName" type ="string"/>
-				<element column="value" type="com.opensymphony.workflow.loader.NotNullStringType" length="4000"/>
-			</map>
-		</joined-subclass>
-		<!-- com.opensymphony.workflow.loader.ResultDescriptor -->
-		<joined-subclass name="com.opensymphony.workflow.loader.ResultDescriptor">
-			<key column="abstractDescriptorId"/>
-			<property name="owner" />
-			<property name="oldStatus" access="field"/>
-			<property name="displayName" access="field"/>
-			<property name="status"/>
-			<property name="split"/>
-			<property name="step" />
-			<property name="join" column="join_id" />
-			<list name="postFunctions" lazy="false" cascade="all-delete-orphan" access="field">
-				<key column="parentResultDescrPost"/>
-				<index column="listOrder"/>
-				<one-to-many class="com.opensymphony.workflow.loader.FunctionDescriptor" />					
-			</list>			
-			<list name="preFunctions" lazy="false" cascade="all-delete-orphan" access="field">
-				<key column="parentResultDescrPre"/>
-				<index column="listOrder"/>
-				<one-to-many class="com.opensymphony.workflow.loader.FunctionDescriptor" />					
-			</list>						
-			<!-- com.opensymphony.workflow.loader.ConditionalResultDescriptor -->
-			<joined-subclass name="com.opensymphony.workflow.loader.ConditionalResultDescriptor">
-				<key column="conditionalResultDescriptorId"/>
-				<list name="conditions" lazy="false" access="field" cascade="all-delete-orphan">
-					<key column="parentConditionalResultDesc"/>
-					<index column="listOrder"/>
-					<one-to-many class="com.opensymphony.workflow.loader.ConditionsDescriptor" />					
-				</list>
-			</joined-subclass>
-		</joined-subclass>
-		<!-- com.opensymphony.workflow.loader.ConditionDescriptor -->
-		<joined-subclass name="com.opensymphony.workflow.loader.ConditionDescriptor">
-			<key column="abstractDescriptorId"/>
-			<property name="name" column="name" />
-			<property name="type" column="type" />
-			<property name="negate" column="negate" />
-			<map name="args" table="conditionsargs" lazy="false" access="field">
-				<key column="entityCode"/>
-				<index column="name" type ="string"/>
-				<element column="value" type="com.opensymphony.workflow.loader.NotNullStringType" length="4000"/>
-			</map>			
-		</joined-subclass>
-		<!-- com.opensymphony.workflow.loader.ConditionsDescriptor -->
-		<joined-subclass name="com.opensymphony.workflow.loader.ConditionsDescriptor">
-			<key column="abstractDescriptorId"/>
-			<property name="type" column="type" />
-			
-			<list name="conditions" lazy="false" cascade="all-delete-orphan">
-				<key column="parentConditionsDescriptor"/>
-				<index column="listOrder"/>
-				<one-to-many class="com.opensymphony.workflow.loader.AbstractDescriptor" />					
-			</list>
-		</joined-subclass>
-		<!-- com.opensymphony.workflow.loader.FunctionDescriptor -->
-		<joined-subclass name="com.opensymphony.workflow.loader.FunctionDescriptor">
-			<key column="abstractDescriptorId"/>
-			<property name="name" column="name" />
-			<property name="type" column="type" />
-			<map name="args" table="functionsargs" lazy="false" access="field">
-				<key column="entityCode"/>
-				<index column="name" type ="string"/>
-				<element column="value" type="com.opensymphony.workflow.loader.NotNullStringType" length="4000"/>
-			</map>			
-		</joined-subclass>
-		<!-- com.opensymphony.workflow.loader.JoinDescriptor -->
-		<joined-subclass name="com.opensymphony.workflow.loader.JoinDescriptor">
-			<key column="abstractDescriptorId"/>
-			<many-to-one name="result" column="result" class="com.opensymphony.workflow.loader.ResultDescriptor"/>
-			<list name="conditions" lazy="false" access="field" cascade="all-delete-orphan">
-				<key column="parentJoinDescriptor"/>
-				<index column="listOrder"/>
-				<one-to-many class="com.opensymphony.workflow.loader.ConditionsDescriptor" />					
-			</list>			
-		</joined-subclass>
-		<!-- com.opensymphony.workflow.loader.PermissionDescriptor -->
-		<joined-subclass name="com.opensymphony.workflow.loader.PermissionDescriptor">
-			<key column="abstractDescriptorId"/>
-			<many-to-one name="restriction" class="com.opensymphony.workflow.loader.RestrictionDescriptor" />
-			<property name="name" column="name" />
-		</joined-subclass>
-		<!-- com.opensymphony.workflow.loader.RegisterDescriptor -->
-		<joined-subclass name="com.opensymphony.workflow.loader.RegisterDescriptor">
-			<key column="abstractDescriptorId"/>
-			<property name="type" column="type" />
-			<property name="variableName" column="variableName" />
-			<map name="args" table="registersargs" lazy="false" access="field">
-				<key column="entityCode"/>
-				<index column="name" type ="string"/>
-				<element column="value" type="com.opensymphony.workflow.loader.NotNullStringType" length="4000"/>
-			</map>			
-		</joined-subclass>
-		<!-- com.opensymphony.workflow.loader.RestrictionDescriptor -->
-		<joined-subclass name="com.opensymphony.workflow.loader.RestrictionDescriptor">
-			<key column="abstractDescriptorId"/>
-			<list name="conditions" lazy="false" access="field" cascade="all-delete-orphan">
-				<key column="parentRestrictionDescriptor"/>
-				<index column="listOrder"/>
-				<one-to-many class="com.opensymphony.workflow.loader.ConditionsDescriptor" />					
-			</list>			
-		</joined-subclass>
-		<!-- com.opensymphony.workflow.loader.SplitDescriptor -->
-		<joined-subclass name="com.opensymphony.workflow.loader.SplitDescriptor">
-			<key column="abstractDescriptorId"/>
-			<list name="results" lazy="false" access="field" cascade="all-delete-orphan">
-				<key column="parentSplitDescriptor"/>
-				<index column="listOrder"/>
-				<one-to-many class="com.opensymphony.workflow.loader.ResultDescriptor" />					
-			</list>			
-		</joined-subclass>
-		<!-- com.opensymphony.workflow.loader.StepDescriptor -->
-		<joined-subclass name="com.opensymphony.workflow.loader.StepDescriptor">
-			<key column="abstractDescriptorId"/>
-			<property name="name" />
-			<property name="hasActions" access="field" />
-			<list name="actions" lazy="false" access="field" cascade="all-delete-orphan">
-				<key column="parentStepDescriptor"/>
-				<index column="listOrder"/>
-				<one-to-many class="com.opensymphony.workflow.loader.ActionDescriptor" />					
-			</list>			
-			<list name="permissions" lazy="false" access="field" cascade="all-delete-orphan">
-				<key column="parentStepDescriptor"/>
-				<index column="listOrder"/>
-				<one-to-many class="com.opensymphony.workflow.loader.PermissionDescriptor" />					
-			</list>			
-			<list name="commonActions" table="commonactions2step" lazy="false" access="field">
-				<key column="parentStepDescriptor"/>
-				<index column="listOrder"/>
-				<element column="value" type="integer"/>
-			</list>			
-			<list name="postFunctions" lazy="false" cascade="all-delete-orphan">
-				<key column="parentStepDescriptorPost"/>
-				<index column="listOrder"/>
-				<one-to-many class="com.opensymphony.workflow.loader.FunctionDescriptor" />					
-			</list>			
-			<list name="preFunctions" lazy="false" cascade="all-delete-orphan">
-				<key column="parentStepDescriptorPre"/>
-				<index column="listOrder"/>
-				<one-to-many class="com.opensymphony.workflow.loader.FunctionDescriptor" />					
-			</list>			
-			<map name="metaAttributes" table="stepMetaAttributes" lazy="false" >
-				<key column="entityCode"/>
-				<index column="keyName" type ="string"/>
-				<element column="value" type="com.opensymphony.workflow.loader.NotNullStringType" length="4000"/>
-			</map>
-		</joined-subclass>
-		<!-- com.opensymphony.workflow.loader.ValidatorDescriptor -->
-		<joined-subclass name="com.opensymphony.workflow.loader.ValidatorDescriptor">
-			<key column="abstractDescriptorId"/>
-			<property name="name" column="name" />
-			<property name="type" column="type" />
-			<map name="args" table="validatorsargs" lazy="false" access="field">
-				<key column="entityCode"/>
-				<index column="name" type ="string"/>
-				<element column="value" type="com.opensymphony.workflow.loader.NotNullStringType" length="4000"/>
-			</map>			
-		</joined-subclass>
-		<!-- com.opensymphony.workflow.loader.WorkflowDescriptor -->
-		<joined-subclass name="com.opensymphony.workflow.loader.WorkflowDescriptor">
-			<key column="abstractDescriptorId"/>
-			<property name="name" />
-			<many-to-one name="globalConditions" class="com.opensymphony.workflow.loader.ConditionsDescriptor" access="field"/>
-			<list name="commonActionsList" lazy="false" access="field" cascade="all-delete-orphan">
-				<key column="parentWorkflowDescrCommonList"/>
-				<index column="listOrder"/>
-				<one-to-many class="com.opensymphony.workflow.loader.ActionDescriptor" />					
-			</list>			
-			<list name="globalActions" lazy="false" access="field" cascade="all-delete-orphan">
-				<key column="parentWorkflowDescGlobal"/>
-				<index column="listOrder"/>
-				<one-to-many class="com.opensymphony.workflow.loader.ActionDescriptor" />					
-			</list>			
-			<list name="initialActions" lazy="false" access="field" cascade="all-delete-orphan">
-				<key column="parentWorkflowDescrInitial"/>
-				<index column="listOrder"/>
-				<one-to-many class="com.opensymphony.workflow.loader.ActionDescriptor" />					
-			</list>			
-			<list name="joins" lazy="false" access="field" cascade="all-delete-orphan">
-				<key column="parentWorkflowDescr"/>
-				<index column="listOrder"/>
-				<one-to-many class="com.opensymphony.workflow.loader.JoinDescriptor" />					
-			</list>			
-			<list name="registers" lazy="false" access="field" cascade="all-delete-orphan">
-				<key column="parentWorkflowDescr"/>
-				<index column="listOrder"/>
-				<one-to-many class="com.opensymphony.workflow.loader.RegisterDescriptor" />
-			</list>			
-			<list name="splits" lazy="false" access="field" cascade="all-delete-orphan">
-				<key column="parentWorkflowDescr"/>
-				<index column="listOrder"/>
-				<one-to-many class="com.opensymphony.workflow.loader.SplitDescriptor" />					
-			</list>			
-			<list name="steps" lazy="false" outer-join="true" batch-size="10" access="field" cascade="all-delete-orphan">
-				<key column="parentWorkflowDescr"/>
-				<index column="listOrder"/>
-				<one-to-many class="com.opensymphony.workflow.loader.StepDescriptor" />					
-			</list>			
-			<map name="commonActions" lazy="false" access="field" cascade="all-delete-orphan">
-				<key column="parentWorkflowDescrCommonMap"/>
-				<index column="id" type="integer"/>
-				<one-to-many class="com.opensymphony.workflow.loader.ActionDescriptor" />					
-			</map>			
-			<map name="metaAttributes" table="workflowMetaAttributes" lazy="false" access="field">
-				<key column="entityCode"/>
-				<index column="keyName" type ="string"/>
-				<element column="value" type="com.opensymphony.workflow.loader.NotNullStringType" length="4000"/>
-			</map>
-			<map name="timerFunctions" lazy="false" access="field" cascade="all-delete-orphan">
-				<key column="parentWorkflowDescr"/>
-				<index column="id" type="integer"/>
-				<one-to-many class="com.opensymphony.workflow.loader.FunctionDescriptor" />					
-			</map>						
-		</joined-subclass>
-	</class>
-</hibernate-mapping>
-

src/java/com/opensymphony/workflow/loader/WorkflowName.java

-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-/*
- * Created on 30-nov-2005
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package com.opensymphony.workflow.loader;
-
-/**
- * DOCUMENT ME!
- *
- * @author $author$
- * @version $Revision$
- */
-public class WorkflowName {
-    //~ Instance fields ////////////////////////////////////////////////////////
-
-    private String workflowName;
-    private WorkflowDescriptor workflowDescriptor;
-
-    //~ Constructors ///////////////////////////////////////////////////////////
-
-    public WorkflowName() {
-        super();
-    }
-
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    public void setWorkflowDescriptor(WorkflowDescriptor workflowDescriptor) {
-        this.workflowDescriptor = workflowDescriptor;
-    }
-
-    public WorkflowDescriptor getWorkflowDescriptor() {
-        return workflowDescriptor;
-    }
-
-    public void setWorkflowName(String workflowName) {
-        this.workflowName = workflowName;
-    }
-
-    public String getWorkflowName() {
-        return workflowName;
-    }
-}

src/java/com/opensymphony/workflow/spi/hibernate/SpringBeanNameWorkflowFactory.java

+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.workflow.spi.hibernate;
+
+import com.opensymphony.workflow.FactoryException;
+import com.opensymphony.workflow.loader.WorkflowDescriptor;
+import com.opensymphony.workflow.loader.WorkflowFactory;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+import java.util.Properties;
+
+
+/**
+ * Spring-compliant implementation of {@link com.opensymphony.workflow.loader.AbstractWorkflowFactory}. This
+ * workflow factory retrieves {@link com.opensymphony.workflow.loader.WorkflowDescriptor}s from the Spring's
+ * {@link ApplicationContext}. The name of the WorkflowDescriptors is the name
+ * of the bean in the applicationContext. <br />
+ * Motivation: reduce number of external configuration files leaving only
+ * workflow definitions files. <br />
+ * <ul>
+ * <li>SpringConfiguration replaces osworkflow.xml</li>
+ * <li>WorkflowFactoryImpl replaces workflows.xml</li>
+ * </ul>
+ * Usage:
+ * <pre>
+ * &lt;bean id=&quot;myworkflow&quot; class=&quot;com.opensymphony.workflow.spi.hibernate.WorkflowDescriptorFactoryBean&quot;&gt;
+ *     &lt;property name=&quot;descriptorResource&quot;&gt;
+ *         &lt;value&gt;classpath:/META-INF/workflow/myworkflow.xml&lt;/value&gt;
+ *     &lt;/property&gt;
+ * &lt;/bean&gt;
+ *
+ * &lt;bean id=&quot;workflowFactory&quot; class=&quot;com.opensymphony.workflow.spi.hibernate.BeanNameWorkflowFactory&quot;/&gt;
+ * </pre>
+ *
+ * @author xd
+ */
+public class SpringBeanNameWorkflowFactory implements WorkflowFactory, ApplicationContextAware {
+    //~ Instance fields ////////////////////////////////////////////////////////
+
+    //////////////////////////////////////////////////~ Instance attributes. //
+
+    /** The applicationContext. */
+    private ApplicationContext applicationContext;
+
+    //~ Methods ////////////////////////////////////////////////////////////////
+
+    public void setApplicationContext(final ApplicationContext inApplicationContext) {
+        this.applicationContext = inApplicationContext;
+    }
+
+    public void setLayout(String workflowName, Object layout) {
+    }
+
+    public Object getLayout(String workflowName) {
+        return null;
+    }
+
+    public boolean isModifiable(String name) {
+        return false;
+    }
+
+    public String getName() {
+        return null;
+    }
+
+    public Properties getProperties() {
+        return null;
+    }
+
+    //////////////////////////~ AbstractWorkflowFactory implemented methods. //
+    public WorkflowDescriptor getWorkflow(final String inName) {
+        return (WorkflowDescriptor) this.applicationContext.getBean(inName);
+    }
+
+    public WorkflowDescriptor getWorkflow(String name, boolean validate) throws FactoryException {
+        return getWorkflow(name);
+    }
+
+    public String[] getWorkflowNames() {
+        return this.applicationContext.getBeanDefinitionNames(WorkflowDescriptor.class);
+    }
+
+    public void createWorkflow(String name) {
+    }
+
+    public void init(Properties p) {
+    }
+
+    public void initDone() throws FactoryException {
+    }
+
+    public boolean removeWorkflow(final String inName) throws FactoryException {
+        throw new FactoryException("Unsupported operation.");
+    }
+
+    public void renameWorkflow(String oldName, String newName) {
+    }
+
+    public void save() {
+    }
+
+    public boolean saveWorkflow(final String inName, final WorkflowDescriptor inDescriptor, final boolean inReplace) throws FactoryException {
+        throw new FactoryException("Unsupported operation.");
+    }
+}

src/java/com/opensymphony/workflow/spi/hibernate/SpringHibernateWorkflowFactory.java

+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+/*
+ * Created on 30-nov-2005
+ *
+ * To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package com.opensymphony.workflow.spi.hibernate;
+
+import com.opensymphony.workflow.FactoryException;
+import com.opensymphony.workflow.InvalidWorkflowDescriptorException;
+import com.opensymphony.workflow.loader.AbstractWorkflowFactory;
+import com.opensymphony.workflow.loader.WorkflowDescriptor;
+
+import net.sf.hibernate.HibernateException;
+import net.sf.hibernate.Session;
+import net.sf.hibernate.SessionFactory;
+
+import org.springframework.orm.hibernate.HibernateCallback;
+import org.springframework.orm.hibernate.HibernateTemplate;
+
+import java.sql.SQLException;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * DOCUMENT ME!
+ *
+ * @author $author$
+ * @version $Revision: 1.1 $
+ */
+public class SpringHibernateWorkflowFactory extends AbstractWorkflowFactory {
+    //~ Static fields/initializers /////////////////////////////////////////////
+
+    private static boolean forceReload;
+
+    //~ Instance fields ////////////////////////////////////////////////////////
+
+    private Map workflows;
+    private SessionFactory sessionFactory;
+    private boolean reload = false;
+    private boolean validate = false;
+
+    //~ Constructors ///////////////////////////////////////////////////////////
+
+    public SpringHibernateWorkflowFactory() {
+        super();
+    }
+
+    //~ Methods ////////////////////////////////////////////////////////////////
+
+    public void setLayout(String workflowName, Object layout) {
+    }
+
+    public Object getLayout(String workflowName) {
+        return null;
+    }
+
+    public boolean isModifiable(String name) {
+        return true;
+    }
+
+    public String getName() {
+        return "";
+    }
+
+    public void setReload(boolean reload) {
+        this.reload = reload;
+    }
+
+    public void setSessionFactory(SessionFactory sessionFactory) {
+        this.sessionFactory = sessionFactory;
+    }
+
+    public void setValidate(boolean validate) {
+        this.validate = validate;
+    }
+
+    public WorkflowDescriptor getWorkflow(String name, boolean validate) throws FactoryException {
+        if (!workflows.containsKey(name)) {
+            throw new FactoryException("Unknown workflow name \"" + name + '\"');
+        }
+
+        if (reload || forceReload) {
+            forceReload = false;
+            loadWorkflow(name, validate);
+        }
+
+        return (WorkflowDescriptor) workflows.get(name);
+    }
+
+    public String[] getWorkflowNames() throws FactoryException {
+        int i = 0;
+        String[] res = new String[workflows.keySet().size()];
+        Iterator it = workflows.keySet().iterator();
+
+        while (it.hasNext()) {
+            res[i++] = (String) it.next();
+        }
+
+        return res;
+    }
+
+    public void createWorkflow(String name) {
+    }
+
+    public static void forceReload() {
+        forceReload = true;
+    }
+
+    public void initDone() throws FactoryException {
+        try {
+            workflows = new HashMap();
+
+            List workflowNames = new HibernateTemplate(sessionFactory).find("select wfn.workflowName from WorkflowName wfn");
+
+            for (Iterator iter = workflowNames.iterator(); iter.hasNext();) {
+                String wfn = iter.next().toString();
+                loadWorkflow(wfn, validate);
+            }
+        } catch (Exception e) {
+            throw new FactoryException(e);
+        }
+    }
+
+    public boolean removeWorkflow(String name) throws FactoryException {
+        final HibernateTemplate hibernateTemplate = new HibernateTemplate(sessionFactory);
+        WorkflowName wfn = (WorkflowName) hibernateTemplate.load(WorkflowName.class, name);
+
+        if (wfn != null) {
+            hibernateTemplate.delete(wfn);
+
+            return true;
+        }
+
+        return false;
+    }
+
+    public void renameWorkflow(String oldName, String newName) {
+        final HibernateTemplate hibernateTemplate = new HibernateTemplate(sessionFactory);
+        WorkflowName wfn = (WorkflowName) hibernateTemplate.load(WorkflowName.class, oldName);
+        wfn.setWorkflowName(newName);
+    }
+
+    public void save() {
+    }
+
+    public boolean saveWorkflow(String name, WorkflowDescriptor descriptor, boolean replace) throws FactoryException {
+        WorkflowName wfn = new WorkflowName();
+        wfn.setWorkflowName(name);
+        wfn.setWorkflowDescriptor(descriptor);
+
+        final HibernateTemplate hibernateTemplate = new HibernateTemplate(sessionFactory);
+        hibernateTemplate.saveOrUpdate(wfn);
+
+        initDone();
+
+        return false;
+    }
+
+    private synchronized void loadWorkflow(final String workflowName, final boolean validate) throws FactoryException {
+        try {
+            new HibernateTemplate(sessionFactory).execute(new HibernateCallback() {
+                    public Object doInHibernate(Session session) throws HibernateException, SQLException {
+                        try {
+                            WorkflowName wfn = (WorkflowName) session.load(WorkflowName.class, workflowName);
+
+                            if (validate) {
+                                wfn.getWorkflowDescriptor().validate();
+                            }
+
+                            workflows.put(wfn.getWorkflowName(), wfn.getWorkflowDescriptor());
+
+                            return null;
+                        } catch (InvalidWorkflowDescriptorException e) {
+                            throw new RuntimeException(e);
+                        }
+                    }
+                });
+        } catch (Exception e) {
+            throw new FactoryException(e);
+        }
+    }
+}

src/java/com/opensymphony/workflow/spi/hibernate/SpringWorkflowDescriptorFactory.java

+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.workflow.spi.hibernate;
+
+import com.opensymphony.workflow.InvalidWorkflowDescriptorException;
+import com.opensymphony.workflow.loader.WorkflowDescriptor;
+import com.opensymphony.workflow.loader.WorkflowLoader;
+
+import org.springframework.beans.factory.FactoryBean;
+
+import org.springframework.core.io.Resource;
+
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+
+
+/**
+ * DOCUMENT ME!
+ *
+ * @author $author$
+ * @version $Revision: 1.1 $
+ */
+public class SpringWorkflowDescriptorFactory implements FactoryBean {
+    //~ Instance fields ////////////////////////////////////////////////////////
+
+    /** The descriptor resource. */
+    private Resource descriptorResource;
+
+    /** Should the descriptor be reloaded on each call. */
+    private boolean reload;
+
+    //~ Methods ////////////////////////////////////////////////////////////////
+
+    public final void setDescriptorResource(final Resource inDescriptorResource) {
+        this.descriptorResource = inDescriptorResource;
+    }
+
+    public Object getObject() throws InvalidWorkflowDescriptorException, SAXException, IOException {
+        return WorkflowLoader.load(this.descriptorResource.getInputStream(), false);
+    }
+
+    public Class getObjectType() {
+        return WorkflowDescriptor.class;
+    }
+
+    public final void setReload(final boolean inReload) {
+        this.reload = inReload;
+    }
+
+    public boolean isSingleton() {
+        return !this.reload;
+    }
+}

src/java/com/opensymphony/workflow/spi/hibernate/SpringWorkflowFactory.java

+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.workflow.spi.hibernate;
+
+import com.opensymphony.workflow.FactoryException;
+import com.opensymphony.workflow.loader.XMLWorkflowFactory;
+
+import java.util.Properties;
+
+
+/**
+ * DOCUMENT ME!
+ */
+public class SpringWorkflowFactory extends XMLWorkflowFactory {
+    //~ Instance fields ////////////////////////////////////////////////////////
+
+    private String resource;
+
+    //~ Constructors ///////////////////////////////////////////////////////////
+
+    public SpringWorkflowFactory() {
+        super();
+    }
+
+    //~ Methods ////////////////////////////////////////////////////////////////
+
+    public void setReload(String reload) {
+        this.reload = Boolean.valueOf(reload).booleanValue();
+    }
+
+    public void setResource(String resource) {
+        this.resource = resource;
+    }
+
+    public void init() {
+        try {
+            Properties props = new Properties();
+            props.setProperty("reload", getReload());
+            props.setProperty("resource", getResource());
+
+            super.init(props);
+            initDone();
+        } catch (FactoryException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private String getReload() {
+        return String.valueOf(reload);
+    }
+
+    private String getResource() {
+        return resource;
+    }
+}

src/java/com/opensymphony/workflow/spi/hibernate/WorkflowDescriptor.hbm.xml

+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+	"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
+	"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
+<!-- com.opensymphony.workflow.loader.ResultDescriptor already added -->
+<hibernate-mapping default-cascade="all">
+	<!-- com.opensymphony.workflow.loader.Workflows -->
+	<class name="com.opensymphony.workflow.spi.hibernate.WorkflowName" >
+		<id name="workflowName" unsaved-value="any">
+			<generator class="assigned"/>
+		</id>
+		<many-to-one name="workflowDescriptor" cascade="save-update" />
+	</class>
+
+	<!-- com.opensymphony.workflow.loader.AbstractDescriptor root -->
+	<class name="com.opensymphony.workflow.loader.AbstractDescriptor" >
+		<id name="entityId" unsaved-value="0">
+			<generator class="native"/>
+		</id>
+		
+		<!-- discriminator column="class"/-->
+		<property name="id" column="id" />
+		<many-to-one name="parent" class="com.opensymphony.workflow.loader.AbstractDescriptor" cascade="none"/>
+		<!-- com.opensymphony.workflow.loader.ActionDescriptor -->
+		<joined-subclass name="com.opensymphony.workflow.loader.ActionDescriptor">
+			<key column="abstractDescriptorId"/>
+			<property name="view" column="viewProperty" />
+			<property name="name" column="name"/>
+			<property name="finish" column="finish"/>
+			<property name="autoExecute" column="autoExecute" />
+			<property name="common" column="common"/>
+			<many-to-one name="restriction" />
+			<many-to-one name="unconditionalResult"/>
+			<list name="conditionalResults" lazy="false" access="field" cascade="all-delete-orphan">
+				<key column="parentActionDescr"/>
+				<index column="listOrder"/>
+				<one-to-many class="com.opensymphony.workflow.loader.ConditionalResultDescriptor" />					
+			</list>			
+			<list name="validators" lazy="false" access="field" cascade="all-delete-orphan">
+				<key column="parentActionDescr"/>
+				<index column="listOrder"/>
+				<one-to-many class="com.opensymphony.workflow.loader.ValidatorDescriptor" />					
+			</list>			
+			<list name="postFunctions" lazy="false" access="field" cascade="all-delete-orphan">
+				<key column="parentActionDescrPost"/>
+				<index column="listOrder"/>
+				<one-to-many class="com.opensymphony.workflow.loader.FunctionDescriptor" />					
+			</list>			
+			<list name="preFunctions" lazy="false" access="field" cascade="all-delete-orphan">
+				<key column="parentActionDescrPre"/>
+				<index column="listOrder"/>
+				<one-to-many class="com.opensymphony.workflow.loader.FunctionDescriptor" />					
+			</list>						
+			<map name="metaAttributes" table="actionMetaAttributes" lazy="false" >
+				<key column="entityCode"/>
+				<index column="keyName" type ="string"/>
+				<element column="value" type="com.opensymphony.workflow.loader.NotNullStringType" length="4000"/>
+			</map>
+		</joined-subclass>
+		<!-- com.opensymphony.workflow.loader.ResultDescriptor -->
+		<joined-subclass name="com.opensymphony.workflow.loader.ResultDescriptor">
+			<key column="abstractDescriptorId"/>
+			<property name="owner" />
+			<property name="oldStatus" access="field"/>
+			<property name="displayName" access="field"/>
+			<property name="status"/>
+			<property name="split"/>
+			<property name="step" />
+			<property name="join" column="join_id" />
+			<list name="postFunctions" lazy="false" cascade="all-delete-orphan" access="field">
+				<key column="parentResultDescrPost"/>
+				<index column="listOrder"/>
+				<one-to-many class="com.opensymphony.workflow.loader.FunctionDescriptor" />					
+			</list>			
+			<list name="preFunctions" lazy="false" cascade="all-delete-orphan" access="field">
+				<key column="parentResultDescrPre"/>
+				<index column="listOrder"/>
+				<one-to-many class="com.opensymphony.workflow.loader.FunctionDescriptor" />					
+			</list>						
+			<!-- com.opensymphony.workflow.loader.ConditionalResultDescriptor -->
+			<joined-subclass name="com.opensymphony.workflow.loader.ConditionalResultDescriptor">
+				<key column="conditionalResultDescriptorId"/>
+				<list name="conditions" lazy="false" access="field" cascade="all-delete-orphan">
+					<key column="parentConditionalResultDesc"/>
+					<index column="listOrder"/>
+					<one-to-many class="com.opensymphony.workflow.loader.ConditionsDescriptor" />					
+				</list>
+			</joined-subclass>
+		</joined-subclass>
+		<!-- com.opensymphony.workflow.loader.ConditionDescriptor -->
+		<joined-subclass name="com.opensymphony.workflow.loader.ConditionDescriptor">
+			<key column="abstractDescriptorId"/>
+			<property name="name" column="name" />
+			<property name="type" column="type" />
+			<property name="negate" column="negate" />
+			<map name="args" table="conditionsargs" lazy="false" access="field">
+				<key column="entityCode"/>
+				<index column="name" type ="string"/>
+				<element column="value" type="com.opensymphony.workflow.loader.NotNullStringType" length="4000"/>
+			</map>			
+		</joined-subclass>
+		<!-- com.opensymphony.workflow.loader.ConditionsDescriptor -->
+		<joined-subclass name="com.opensymphony.workflow.loader.ConditionsDescriptor">
+			<key column="abstractDescriptorId"/>
+			<property name="type" column="type" />
+			
+			<list name="conditions" lazy="false" cascade="all-delete-orphan">
+				<key column="parentConditionsDescriptor"/>
+				<index column="listOrder"/>
+				<one-to-many class="com.opensymphony.workflow.loader.AbstractDescriptor" />					
+			</list>
+		</joined-subclass>
+		<!-- com.opensymphony.workflow.loader.FunctionDescriptor -->
+		<joined-subclass name="com.opensymphony.workflow.loader.FunctionDescriptor">
+			<key column="abstractDescriptorId"/>
+			<property name="name" column="name" />
+			<property name="type" column="type" />
+			<map name="args" table="functionsargs" lazy="false" access="field">
+				<key column="entityCode"/>
+				<index column="name" type ="string"/>
+				<element column="value" type="com.opensymphony.workflow.loader.NotNullStringType" length="4000"/>
+			</map>			
+		</joined-subclass>
+		<!-- com.opensymphony.workflow.loader.JoinDescriptor -->
+		<joined-subclass name="com.opensymphony.workflow.loader.JoinDescriptor">
+			<key column="abstractDescriptorId"/>
+			<many-to-one name="result" column="result" class="com.opensymphony.workflow.loader.ResultDescriptor"/>
+			<list name="conditions" lazy="false" access="field" cascade="all-delete-orphan">
+				<key column="parentJoinDescriptor"/>
+				<index column="listOrder"/>
+				<one-to-many class="com.opensymphony.workflow.loader.ConditionsDescriptor" />					
+			</list>			
+		</joined-subclass>
+		<!-- com.opensymphony.workflow.loader.PermissionDescriptor -->
+		<joined-subclass name="com.opensymphony.workflow.loader.PermissionDescriptor">
+			<key column="abstractDescriptorId"/>
+			<many-to-one name="restriction" class="com.opensymphony.workflow.loader.RestrictionDescriptor" />
+			<property name="name" column="name" />
+		</joined-subclass>
+		<!-- com.opensymphony.workflow.loader.RegisterDescriptor -->
+		<joined-subclass name="com.opensymphony.workflow.loader.RegisterDescriptor">
+			<key column="abstractDescriptorId"/>
+			<property name="type" column="type" />
+			<property name="variableName" column="variableName" />
+			<map name="args" table="registersargs" lazy="false" access="field">
+				<key column="entityCode"/>
+				<index column="name" type ="string"/>
+				<element column="value" type="com.opensymphony.workflow.loader.NotNullStringType" length="4000"/>
+			</map>			
+		</joined-subclass>
+		<!-- com.opensymphony.workflow.loader.RestrictionDescriptor -->
+		<joined-subclass name="com.opensymphony.workflow.loader.RestrictionDescriptor">
+			<key column="abstractDescriptorId"/>
+			<list name="conditions" lazy="false" access="field" cascade="all-delete-orphan">
+				<key column="parentRestrictionDescriptor"/>
+				<index column="listOrder"/>
+				<one-to-many class="com.opensymphony.workflow.loader.ConditionsDescriptor" />					
+			</list>			
+		</joined-subclass>
+		<!-- com.opensymphony.workflow.loader.SplitDescriptor -->
+		<joined-subclass name="com.opensymphony.workflow.loader.SplitDescriptor">
+			<key column="abstractDescriptorId"/>
+			<list name="results" lazy="false" access="field" cascade="all-delete-orphan">
+				<key column="parentSplitDescriptor"/>
+				<index column="listOrder"/>
+				<one-to-many class="com.opensymphony.workflow.loader.ResultDescriptor" />					
+			</list>			
+		</joined-subclass>
+		<!-- com.opensymphony.workflow.loader.StepDescriptor -->
+		<joined-subclass name="com.opensymphony.workflow.loader.StepDescriptor">
+			<key column="abstractDescriptorId"/>
+			<property name="name" />
+			<property name="hasActions" access="field" />
+			<list name="actions" lazy="false" access="field" cascade="all-delete-orphan">
+				<key column="parentStepDescriptor"/>
+				<index column="listOrder"/>
+				<one-to-many class="com.opensymphony.workflow.loader.ActionDescriptor" />					
+			</list>			
+			<list name="permissions" lazy="false" access="field" cascade="all-delete-orphan">
+				<key column="parentStepDescriptor"/>
+				<index column="listOrder"/>
+				<one-to-many class="com.opensymphony.workflow.loader.PermissionDescriptor" />					
+			</list>			
+			<list name="commonActions" table="commonactions2step" lazy="false" access="field">
+				<key column="parentStepDescriptor"/>
+				<index column="listOrder"/>
+				<element column="value" type="integer"/>
+			</list>			
+			<list name="postFunctions" lazy="false" cascade="all-delete-orphan">
+				<key column="parentStepDescriptorPost"/>
+				<index column="listOrder"/>
+				<one-to-many class="com.opensymphony.workflow.loader.FunctionDescriptor" />					
+			</list>			
+			<list name="preFunctions" lazy="false" cascade="all-delete-orphan">
+				<key column="parentStepDescriptorPre"/>
+				<index column="listOrder"/>
+				<one-to-many class="com.opensymphony.workflow.loader.FunctionDescriptor" />					
+			</list>			
+			<map name="metaAttributes" table="stepMetaAttributes" lazy="false" >
+				<key column="entityCode"/>
+				<index column="keyName" type ="string"/>
+				<element column="value" type="com.opensymphony.workflow.loader.NotNullStringType" length="4000"/>
+			</map>
+		</joined-subclass>
+		<!-- com.opensymphony.workflow.loader.ValidatorDescriptor -->
+		<joined-subclass name="com.opensymphony.workflow.loader.ValidatorDescriptor">
+			<key column="abstractDescriptorId"/>
+			<property name="name" column="name" />
+			<property name="type" column="type" />
+			<map name="args" table="validatorsargs" lazy="false" access="field">
+				<key column="entityCode"/>
+				<index column="name" type ="string"/>
+				<element column="value" type="com.opensymphony.workflow.loader.NotNullStringType" length="4000"/>
+			</map>			
+		</joined-subclass>
+		<!-- com.opensymphony.workflow.loader.WorkflowDescriptor -->
+		<joined-subclass name="com.opensymphony.workflow.loader.WorkflowDescriptor">
+			<key column="abstractDescriptorId"/>
+			<property name="name" />
+			<many-to-one name="globalConditions" class="com.opensymphony.workflow.loader.ConditionsDescriptor" access="field"/>
+			<list name="commonActionsList" lazy="false" access="field" cascade="all-delete-orphan">
+				<key column="parentWorkflowDescrCommonList"/>
+				<index column="listOrder"/>
+				<one-to-many class="com.opensymphony.workflow.loader.ActionDescriptor" />					
+			</list>			
+			<list name="globalActions" lazy="false" access="field" cascade="all-delete-orphan">
+				<key column="parentWorkflowDescGlobal"/>
+				<index column="listOrder"/>
+				<one-to-many class="com.opensymphony.workflow.loader.ActionDescriptor" />					
+			</list>			
+			<list name="initialActions" lazy="false" access="field" cascade="all-delete-orphan">
+				<key column="parentWorkflowDescrInitial"/>
+				<index column="listOrder"/>
+				<one-to-many class="com.opensymphony.workflow.loader.ActionDescriptor" />					
+			</list>			
+			<list name="joins" lazy="false" access="field" cascade="all-delete-orphan">
+				<key column="parentWorkflowDescr"/>
+				<index column="listOrder"/>
+				<one-to-many class="com.opensymphony.workflow.loader.JoinDescriptor" />					
+			</list>			
+			<list name="registers" lazy="false" access="field" cascade="all-delete-orphan">
+				<key column="parentWorkflowDescr"/>
+				<index column="listOrder"/>
+				<one-to-many class="com.opensymphony.workflow.loader.RegisterDescriptor" />
+			</list>			
+			<list name="splits" lazy="false" access="field" cascade="all-delete-orphan">
+				<key column="parentWorkflowDescr"/>
+				<index column="listOrder"/>
+				<one-to-many class="com.opensymphony.workflow.loader.SplitDescriptor" />					
+			</list>			
+			<list name="steps" lazy="false" outer-join="true" batch-size="10" access="field" cascade="all-delete-orphan">
+				<key column="parentWorkflowDescr"/>
+				<index column="listOrder"/>
+				<one-to-many class="com.opensymphony.workflow.loader.StepDescriptor" />					
+			</list>			
+			<map name="commonActions" lazy="false" access="field" cascade="all-delete-orphan">
+				<key column="parentWorkflowDescrCommonMap"/>
+				<index column="id" type="integer"/>
+				<one-to-many class="com.opensymphony.workflow.loader.ActionDescriptor" />					
+			</map>			
+			<map name="metaAttributes" table="workflowMetaAttributes" lazy="false" access="field">
+				<key column="entityCode"/>
+				<index column="keyName" type ="string"/>
+				<element column="value" type="com.opensymphony.workflow.loader.NotNullStringType" length="4000"/>
+			</map>
+			<map name="timerFunctions" lazy="false" access="field" cascade="all-delete-orphan">
+				<key column="parentWorkflowDescr"/>
+				<index column="id" type="integer"/>
+				<one-to-many class="com.opensymphony.workflow.loader.FunctionDescriptor" />					
+			</map>						
+		</joined-subclass>
+	</class>
+</hibernate-mapping>
+

src/java/com/opensymphony/workflow/spi/hibernate/WorkflowName.java

+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.workflow.spi.hibernate;
+
+import com.opensymphony.workflow.loader.WorkflowDescriptor;
+
+
+/**
+ * DOCUMENT ME!
+ *
+ * @author $author$
+ * @version $Revision: 1.1 $
+ */
+public class WorkflowName {
+    //~ Instance fields ////////////////////////////////////////////////////////
+
+    private String workflowName;
+    private WorkflowDescriptor workflowDescriptor;
+
+    //~ Methods ////////////////////////////////////////////////////////////////
+
+    public void setWorkflowDescriptor(WorkflowDescriptor workflowDescriptor) {
+        this.workflowDescriptor = workflowDescriptor;
+    }
+
+    public WorkflowDescriptor getWorkflowDescriptor() {
+        return workflowDescriptor;
+    }
+
+    public void setWorkflowName(String workflowName) {
+        this.workflowName = workflowName;
+    }
+
+    public String getWorkflowName() {
+        return workflowName;
+    }
+}

src/test/com/opensymphony/workflow/spi/hibernate/NewSpringHibernateLoaderFunctionalWorkflowTestCase.java

-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.workflow.spi.hibernate;
-
-import com.opensymphony.workflow.Workflow;
-import com.opensymphony.workflow.config.Configuration;
-import com.opensymphony.workflow.loader.WorkflowDescriptor;
-import com.opensymphony.workflow.loader.WorkflowFactory;
-import com.opensymphony.workflow.spi.AbstractFunctionalWorkflowTest;
-import com.opensymphony.workflow.util.DatabaseHelper;
-
-import org.springframework.beans.factory.xml.XmlBeanFactory;
-
-import org.springframework.core.io.ClassPathResource;
-
-
-/**
- * White Box semi-functional test case that uses Spring's managed Hibernate as Store
- *
- * @author Luca Masini (l.masini@infogroup.it)
- */
-public class NewSpringHibernateLoaderFunctionalWorkflowTestCase extends AbstractFunctionalWorkflowTest {
-    //~ Constructors ///////////////////////////////////////////////////////////
-
-    public NewSpringHibernateLoaderFunctionalWorkflowTestCase(String s) {
-        super(s);
-    }
-
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    protected void setUp() throws Exception {
-        super.setUp();
-        DatabaseHelper.runScript("", "jdbc/CreateDS");
-
-        XmlBeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("new-osworkflow-spring-hibernate-loader.xml"));
-        WorkflowFactory oldFactory = (WorkflowFactory) beanFactory.getBean("xmlWorkflowFactory");
-        WorkflowDescriptor wfd = oldFactory.getWorkflow(getWorkflowName());
-
-        WorkflowFactory newFactory = (WorkflowFactory) beanFactory.getBean("workflowFactory");
-        newFactory.saveWorkflow(getWorkflowName(), wfd, true);
-
-        workflow = (Workflow) beanFactory.getBean("workflow");
-        workflow.setConfiguration((Configuration) beanFactory.getBean("osworkflowConfiguration"));
-    }
-
-    protected String getWorkflowName() {
-        return "example";
-    }
-
-    protected void tearDown() throws Exception {
-        DatabaseHelper.runScript(getClass().getResource("/scripts/jdbc/dropschema.sql"), "jdbc/DefaultDS");
-    }
-}

src/test/com/opensymphony/workflow/spi/hibernate/SpringHibernateLoaderFunctionalWorkflowTestCase.java

+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.workflow.spi.hibernate;
+
+import com.opensymphony.workflow.Workflow;
+import com.opensymphony.workflow.config.Configuration;
+import com.opensymphony.workflow.loader.WorkflowDescriptor;
+import com.opensymphony.workflow.loader.WorkflowFactory;
+import com.opensymphony.workflow.spi.AbstractFunctionalWorkflowTest;
+import com.opensymphony.workflow.util.DatabaseHelper;
+
+import org.springframework.beans.factory.xml.XmlBeanFactory;
+
+import org.springframework.core.io.ClassPathResource;
+
+
+/**
+ * White Box semi-functional test case that uses Spring's managed Hibernate as Store
+ *
+ * @author Luca Masini (l.masini@infogroup.it)
+ */
+public class SpringHibernateLoaderFunctionalWorkflowTestCase extends AbstractFunctionalWorkflowTest {
+    //~ Constructors ///////////////////////////////////////////////////////////
+
+    public SpringHibernateLoaderFunctionalWorkflowTestCase(String s) {
+        super(s);
+    }
+
+    //~ Methods ////////////////////////////////////////////////////////////////
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        DatabaseHelper.runScript("", "jdbc/CreateDS");
+
+        XmlBeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("osworkflow-spring-hibernate-loader.xml"));
+        WorkflowFactory oldFactory = (WorkflowFactory) beanFactory.getBean("xmlWorkflowFactory");
+        WorkflowDescriptor wfd = oldFactory.getWorkflow(getWorkflowName());
+
+        WorkflowFactory newFactory = (WorkflowFactory) beanFactory.getBean("workflowFactory");
+        newFactory.saveWorkflow(getWorkflowName(), wfd, true);
+
+        workflow = (Workflow) beanFactory.getBean("workflow");
+        workflow.setConfiguration((Configuration) beanFactory.getBean("osworkflowConfiguration"));
+    }
+
+    protected String getWorkflowName() {
+        return "example";
+    }
+
+    protected void tearDown() throws Exception {
+        DatabaseHelper.runScript(getClass().getResource("/scripts/jdbc/dropschema.sql"), "jdbc/DefaultDS");
+    }
+}

src/test/com/opensymphony/workflow/spi/hibernate3/HibernateFunctionalWorkflowTestCase.java

         session = factory3.openSession();
 
         Configuration config = new DefaultConfiguration();
-        config.load(getClass().getResource("/new-osworkflow-hibernate3.xml"));
+        config.load(getClass().getResource("/osworkflow-hibernate3.xml"));
         config.getPersistenceArgs().put("session", session);
         config.getPersistenceArgs().put("propertySetDelegate", new PropertySetDelegateImpl());
 

src/test/com/opensymphony/workflow/spi/hibernate3/SpringHibernateFunctionalWorkflowTestCase.java

         super.setUp();
         DatabaseHelper.runScript("", "jdbc/CreateDS");
 
-        XmlBeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("new-osworkflow-spring-hibernate3.xml"));
+        XmlBeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("osworkflow-spring-hibernate3.xml"));
 
         workflow = (Workflow) beanFactory.getBean("workflow");
         workflow.setConfiguration((Configuration) beanFactory.getBean("osworkflowConfiguration"));

src/test/new-osworkflow-hibernate3.xml

-<osworkflow>
-  <!-- The hibernate store requires that you specify the session factory in ConfigLoader.persistenceArgs
-       See javadocs for the store -->
-  <persistence class="com.opensymphony.workflow.spi.hibernate3.HibernateWorkflowStore" />
-  <factory class="com.opensymphony.workflow.loader.URLWorkflowFactory">
-    <property key="cache" value="true" />
-  </factory>
-</osworkflow>

src/test/new-osworkflow-spring-hibernate-loader.xml

-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
-
-<beans>
-
-	<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
-        <property name="jndiName"><value>jdbc/DefaultDS</value></property>
-    </bean>
-    
-	<!--bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
-		<property name="driverClassName"><value>org.hsqldb.jdbcDriver</value></property>
-		<property name="url"><value>jdbc:hsqldb:data/osworkflow</value></property>
-		<property name="username"><value>sa</value></property>
-		<property name="password"><value></value></property>
-	</bean-->
-
-	<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
-		<property name="dataSource"><ref local="dataSource"/></property>
-		<property name="mappingResources">
-			<list>
-				<value>com/opensymphony/workflow/loader/WorkflowDescriptor.hbm.xml</value>
-				<value>com/opensymphony/workflow/spi/hibernate/HibernateCurrentStep.hbm.xml</value>
-				<value>com/opensymphony/workflow/spi/hibernate/HibernateHistoryStep.hbm.xml</value>
-				<value>com/opensymphony/workflow/spi/hibernate/HibernateWorkflowEntry.hbm.xml</value>				
-				<value>com/opensymphony/module/propertyset/hibernate/PropertySetItemImpl.hbm.xml</value>
-			</list>
-		</property>
-		<property name="hibernateProperties">
-			<props>
-				<prop key="hibernate.dialect">net.sf.hibernate.dialect.MckoiDialect</prop>
-				<!--prop key="hibernate.dialect">net.sf.hibernate.dialect.HSQLDialect</prop-->		
-				<prop key="hibernate.show_sql">false</prop>
-				<prop key="hibernate.hbm2ddl.auto">create-drop</prop>
-			</props>
-		</property>
-	</bean>
-	
-    <bean id="transactionManager" 
-        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
-        <property name="dataSource"><ref local="dataSource"/></property>
-    </bean>	
-    
-	<!--bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
-		<property name="sessionFactory"><ref local="sessionFactory"/></property>
-	</bean-->
-
-	<bean id="xmlWorkflowFactory" class="com.opensymphony.workflow.loader.SpringWorkflowFactory" init-method="init">
-        <property name="resource"><value>spring-workflows.xml</value></property>
-        <property name="reload"><value>false</value></property>
-	</bean>
-		
-	<bean id="workflowStore" class="com.opensymphony.workflow.spi.hibernate.NewSpringHibernateWorkflowStore">
-		<property name="sessionFactory"><ref local="sessionFactory"/></property>
-		<property name="propertySetDelegate">
-			<bean id="propertySetDelegate" class="com.opensymphony.workflow.spi.hibernate.DefaultHibernatePropertySetDelegate">
-				<property name="sessionFactory"><ref local="sessionFactory"/></property>
-			</bean>
-		</property>
-	</bean>
-		
-	<bean id="workflowTypeResolver" class="com.opensymphony.workflow.util.SpringTypeResolver"/>
-	
-	<bean id="workflowFactory" class="com.opensymphony.workflow.loader.SpringHibernateWorkflowFactory" init-method="initDone">
-		<property name="sessionFactory"><ref bean="sessionFactory"/></property>
-        <property name="reload"><value>true</value></property>
-        <property name="validate"><value>false</value></property>
-	</bean>
-	
-	<bean id="osworkflowConfiguration" class="com.opensymphony.workflow.config.SpringConfiguration">
-		<property name="store"><ref local="workflowStore"/></property>
-		<property name="factory"><ref local="workflowFactory"/></property>		
-	</bean>
-	
-	<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
-		<property name="transactionManager"><ref local="transactionManager"/></property>
-		<property name="transactionAttributes">
-			<props>
-				<prop key="*">PROPAGATION_REQUIRED</prop>
-			</props>
-		</property>
-	</bean>
-
-	<bean id="workflow" class="org.springframework.aop.framework.ProxyFactoryBean">
-		<property name="singleton">
-			<value>false</value>
-		</property>
-		<property name="proxyInterfaces">
-			<value>com.opensymphony.workflow.Workflow</value>
-		</property>
-		<property name="interceptorNames">
-			<list>
-				<value>transactionInterceptor</value>
-				<value>workflowTarget</value>
-			</list>
-		</property>
-	</bean>
-
-	<bean id="workflowTarget" class="com.opensymphony.workflow.basic.BasicWorkflow" singleton="false">
-		<constructor-arg><value>test</value></constructor-arg>
-		<property name="configuration"><ref local="osworkflowConfiguration"/></property>	
-	</bean>
-
-	<!--bean id="testSpringFunction" class="function.to.test.with.spring" singleton="false" /-->
-
-	
-</beans>

src/test/new-osworkflow-spring-hibernate3.xml

-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
-
-<beans>
-
-	<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
-        <property name="jndiName"><value>jdbc/DefaultDS</value></property>
-    </bean>
-    
-	<!--bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
-		<property name="driverClassName"><value>org.hsqldb.jdbcDriver</value></property>
-		<property name="url"><value>jdbc:hsqldb:data/osworkflow</value></property>
-		<property name="username"><value>sa</value></property>
-		<property name="password"><value></value></property>
-	</bean-->
-
-	<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
-		<property name="dataSource"><ref local="dataSource"/></property>
-		<property name="mappingResources">
-			<list>
-				<value>com/opensymphony/workflow/spi/hibernate/HibernateCurrentStep.hbm.xml</value>
-				<value>com/opensymphony/workflow/spi/hibernate/HibernateHistoryStep.hbm.xml</value>
-				<value>com/opensymphony/workflow/spi/hibernate/HibernateWorkflowEntry.hbm.xml</value>