You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mr...@apache.org on 2006/11/01 01:05:45 UTC

svn commit: r469714 [3/4] - in /incubator/ode/trunk: ./ axis2/ axis2/src/main/java/org/apache/ode/axis2/ axis2/src/main/java/org/apache/ode/axis2/deploy/ axis2/src/main/java/org/apache/ode/axis2/service/ bpel-api/src/main/java/org/apache/ode/bpel/iapi/...

Added: incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java?view=auto&rev=469714
==============================================================================
--- incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java (added)
+++ incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java Tue Oct 31 16:05:42 2006
@@ -0,0 +1,511 @@
+package org.apache.ode.store;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.dd.*;
+import org.apache.ode.bpel.iapi.*;
+import org.apache.ode.bpel.o.OProcess;
+import org.apache.ode.bpel.o.Serializer;
+import org.apache.ode.store.dao.ConfStoreConnection;
+import org.apache.ode.store.dao.ConfStoreConnectionHib;
+import org.apache.ode.store.dao.ConfStoreConnectionInMem;
+import org.apache.ode.store.dao.ProcessConfDAO;
+import org.apache.ode.store.deploy.DeploymentManager;
+import org.apache.ode.store.deploy.DeploymentManagerImpl;
+import org.apache.ode.store.deploy.DeploymentUnitImpl;
+import org.apache.ode.utils.msg.MessageBundle;
+import org.w3c.dom.Node;
+
+import javax.sql.DataSource;
+import javax.wsdl.Definition;
+import javax.xml.namespace.QName;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.util.*;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/**
+ * @author mriou <mriou at apache dot org>
+ */
+public class ProcessStoreImpl implements ProcessStore {
+
+    private static final Log __log = LogFactory.getLog(ProcessStoreImpl.class);
+    private static final Messages __msgs = MessageBundle.getMessages(Messages.class);
+
+    /**
+     * Management lock for synchronizing management operations and preventing
+     * processing (transactions) from occuring while management operations are
+     * in progress.
+     */
+    private ReadWriteLock _mngmtLock = new ReentrantReadWriteLock();
+
+    private DataSource _ds;
+    private DeploymentManager _deploymentManager;
+    private Map<QName, DeploymentUnitImpl> _deploymentUnits = new HashMap<QName, DeploymentUnitImpl>();
+    private File _appDir;
+    private ConfStoreConnection _conn;
+
+    public ProcessStoreImpl(File appDir, DataSource ds) {
+        this(appDir, ds, new DeploymentManagerImpl(new File(appDir, "processes")));
+    }
+
+    // Both appdir and datasource could be null
+    public ProcessStoreImpl(File appDir, DataSource ds, DeploymentManager deployer) {
+        _deploymentManager = deployer;
+        _appDir = appDir;
+        _ds = ds;
+        // TODO in-memory if no datasource given
+        if (_ds != null) _conn = new ConfStoreConnectionHib(_ds, appDir);
+        else _conn = new ConfStoreConnectionInMem();
+
+        reloadDeploymentUnits();
+    }
+
+    public File getDeploymentDir() {
+        return new File(_appDir, "processes");
+    }
+
+    /**
+     * Deploys a process.
+     */
+    public Collection<QName> deploy(File deploymentUnitDirectory) {
+        __log.info(__msgs.msgDeployStarting(deploymentUnitDirectory));
+
+        _mngmtLock.writeLock().lock();
+        try {
+            DeploymentUnitImpl du = _deploymentManager.createDeploymentUnit(deploymentUnitDirectory);
+
+            // Checking first that the same process isn't deployed elsewhere
+            for (TDeployment.Process processDD : du.getDeploymentDescriptor().getDeploy().getProcessList()) {
+                if (_deploymentUnits.get(processDD.getName()) != null) {
+                    String duName = _deploymentUnits.get(processDD.getName()).getDeployDir().getName();
+                    if (!duName.equals(deploymentUnitDirectory.getName()))
+                        throw new BpelEngineException("Process " + processDD.getName() + " is already deployed in " +
+                                duName + "");
+                }
+            }
+
+            ArrayList<QName> deployed = new ArrayList<QName>();
+            BpelEngineException failed = null;
+            // Going trough each process declared in the dd
+            for (TDeployment.Process processDD : du.getDeploymentDescriptor().getDeploy().getProcessList()) {
+                // If a type is not specified, assume the process id is also the
+                // type.
+                QName type = processDD.getType() != null ? processDD.getType() : processDD.getName();
+                OProcess oprocess = du.getProcesses().get(type);
+                if (oprocess == null)
+                    throw new BpelEngineException("Could not find the compiled process definition for BPEL" + "type "
+                            + type + " when deploying process " + processDD.getName() + " in "
+                            + deploymentUnitDirectory);
+                try {
+                    deploy(processDD.getName(), du, oprocess, processDD);
+                    deployed.add(processDD.getName());
+                } catch (Throwable e) {
+                    String errmsg = __msgs.msgDeployFailed(processDD.getName(), deploymentUnitDirectory);
+                    __log.error(errmsg, e);
+                    failed = new BpelEngineException(errmsg, e);
+                    break;
+                }
+            }
+
+            // Roll back succesfull deployments if we failed.
+            if (failed != null) {
+                if (!deployed.isEmpty()) {
+                    __log.error(__msgs.msgDeployRollback(deploymentUnitDirectory));
+                    for (QName pid : deployed) {
+                        try {
+                            undeploy(pid);
+                        } catch (Throwable t) {
+                            __log.fatal("Unexpect error undeploying process " + pid, t);
+                        }
+                    }
+                }
+
+                throw failed;
+            }
+
+            return new HashSet<QName>(du.getProcesses().keySet());
+        } finally {
+            _mngmtLock.writeLock().unlock();
+        }
+    }
+
+    private void deploy(final QName processId, final DeploymentUnitImpl du,
+                        final OProcess oprocess, TDeployment.Process processDD) {
+
+        _mngmtLock.writeLock().lock();
+        try {
+            // First, make sure we are undeployed.
+            undeploy(processId);
+
+            final ProcessDDInitializer pi = new ProcessDDInitializer(oprocess, processDD);
+            try {
+                _conn.exec(new ConfStoreConnection.Callable<ProcessConfDAO>() {
+                    public ProcessConfDAO run() throws Exception {
+                        // Hack, but at least for now we need to ensure that we
+                        // are
+                        // the only process with this process id.
+                        ProcessConfDAO old = _conn.getProcessConf(processId);
+                        if (old != null) {
+                            String errmsg = __msgs.msgProcessDeployErrAlreadyDeployed(processId);
+                            __log.error(errmsg);
+                            throw new BpelEngineException(errmsg);
+                        }
+
+                        ProcessConfDAO newDao = _conn.createProcess(processId, oprocess.getQName());
+                        pi.init(newDao);
+                        pi.update(newDao);
+                        return newDao;
+                    }
+                });
+                __log.info(__msgs.msgProcessDeployed(processId));
+            } catch (BpelEngineException ex) {
+                throw ex;
+            } catch (Exception dce) {
+                __log.error("", dce);
+                throw new BpelEngineException("", dce);
+            }
+
+            _deploymentUnits.put(processDD.getName(), du);
+        } finally {
+            _mngmtLock.writeLock().unlock();
+        }
+    }
+
+    public Collection<QName> undeploy(File file) {
+        _mngmtLock.writeLock().lock();
+        try {
+            ArrayList<QName> undeployed = new ArrayList<QName>();
+            DeploymentUnitImpl du = null;
+            for (DeploymentUnitImpl deploymentUnit : new HashSet<DeploymentUnitImpl>(_deploymentUnits.values())) {
+                if (deploymentUnit.getDeployDir().getName().equals(file.getName()))
+                    du = deploymentUnit;
+            }
+            if (du == null) return undeployed;
+
+            for (QName pName : du.getProcessNames()) {
+                if (undeploy(pName)) undeployed.add(pName);
+            }
+
+            for (QName pname : du.getProcessNames()) {
+                _deploymentUnits.remove(pname);
+            }
+            _deploymentManager.remove(du);
+
+            return undeployed;
+        } finally {
+            _mngmtLock.writeLock().unlock();
+
+        }
+    }
+
+    public boolean undeploy(final QName process) {
+        _mngmtLock.writeLock().lock();
+        try {
+            if (__log.isDebugEnabled())
+                __log.debug("Unregistering process " + process);
+
+            // Delete it from the database.
+            boolean deleted = _conn.exec(new ConfStoreConnection.Callable<Boolean>() {
+                public Boolean run() throws Exception {
+                    ProcessConfDAO proc = _conn.getProcessConf(process);
+                    if (proc != null) {
+                        proc.delete();
+                        __log.info(__msgs.msgProcessUndeployed(process));
+                        return Boolean.TRUE;
+                    }
+                    return Boolean.FALSE;
+                }
+            });
+            return deleted;
+        } catch (RuntimeException ex) {
+            throw ex;
+        } catch (Exception ex) {
+            __log.error(__msgs.msgProcessUndeployFailed(process), ex);
+            throw new BpelEngineException(ex);
+        } finally {
+            _mngmtLock.writeLock().unlock();
+        }
+    }
+
+    public Map<QName, byte[]> getActiveProcesses() {
+        _mngmtLock.writeLock().lock();
+        try {
+            if (__log.isDebugEnabled())
+                __log.debug("Looking for active processes.");
+
+            // Delete it from the database.
+            return _conn.exec(new ConfStoreConnection.Callable<Map<QName, byte[]>>() {
+                public Map<QName, byte[]> run() throws Exception {
+                    List<ProcessConfDAO> procs = _conn.getActiveProcesses();
+                    HashMap<QName, byte[]> result = new HashMap<QName, byte[]>(procs.size());
+                    for (ProcessConfDAO confDAO : procs) {
+                        QName processId = confDAO.getProcessId();
+                        if (_deploymentUnits.get(processId) == null) {
+                            __log.error("The process " + processId + " appears to exist in the database but no " +
+                                    "deployment exists in the file system. Please undeploy it properly.");
+                            continue;
+                        }
+                        OProcess oprocess = _deploymentUnits.get(processId).getProcesses().get(processId);
+                        result.put(confDAO.getProcessId(), serialize(oprocess));
+                    }
+                    return result;
+                }
+            });
+        } catch (RuntimeException ex) {
+            throw ex;
+        } catch (Exception ex) {
+            __log.error(__msgs.msgDbError(), ex);
+            throw new BpelEngineException(ex);
+        } finally {
+            _mngmtLock.writeLock().unlock();
+        }
+    }
+
+    public Map<String, Endpoint> getInvokeEndpoints(QName processId) {
+        HashMap<String, Endpoint> partnerRoleIntialValues = new HashMap<String, Endpoint>();
+        TDeployment.Process processInfo = getProcessInfo(processId);
+        if (processInfo.getInvokeList() != null) {
+            for (TInvoke invoke : processInfo.getInvokeList()) {
+                String plinkName = invoke.getPartnerLink();
+                TService service = invoke.getService();
+                // NOTE: service can be null for partner links
+                if (service == null) continue;
+                __log.debug("Processing <invoke> element for process " + processId + ": partnerlink " + plinkName + " --> "
+                        + service);
+                partnerRoleIntialValues.put(plinkName, new Endpoint(service.getName(), service.getPort()));
+            }
+        }
+        return partnerRoleIntialValues;
+    }
+
+    public Map<String, Endpoint> getProvideEndpoints(QName processId) {
+        HashMap<String, Endpoint> myRoleEndpoints = new HashMap<String, Endpoint>();
+        TDeployment.Process processInfo = getProcessInfo(processId);
+        if (processInfo.getProvideList() != null) {
+            for (TProvide provide : processInfo.getProvideList()) {
+                String plinkName = provide.getPartnerLink();
+                TService service = provide.getService();
+                if (service == null) {
+                    String errmsg = "Error in <provide> element for process " + processId + "; partnerlink " + plinkName
+                            + "did not identify an endpoint";
+                    __log.error(errmsg);
+                    throw new BpelEngineException(errmsg);
+                }
+                __log.debug("Processing <provide> element for process " + processId + ": partnerlink " + plinkName + " --> "
+                        + service.getName() + " : " + service.getPort());
+                myRoleEndpoints.put(plinkName, new Endpoint(service.getName(), service.getPort()));
+            }
+        }
+        return myRoleEndpoints;
+    }
+
+    public String[] listDeployedPackages() {
+        HashSet<String> deployed = new HashSet<String>();
+        for (DeploymentUnitImpl unit : _deploymentUnits.values()) {
+            deployed.add(unit.getDeployDir().getName());
+        }
+        return deployed.toArray(new String[0]);
+    }
+
+    public QName[] listProcesses(String packageName) {
+        return _deploymentUnits.keySet().toArray(new QName[0]);
+    }
+
+    public void markActive(final QName processId, final boolean status) {
+        _mngmtLock.writeLock().lock();
+        try {
+            if (__log.isDebugEnabled())
+                __log.debug("Setting property on process " + processId);
+
+            // Delete it from the database.
+            _conn.exec(new ConfStoreConnection.Callable<Object>() {
+                public Object run() throws Exception {
+                    ProcessConfDAO dao = _conn.getProcessConf(processId);
+                    if (dao != null)
+                        dao.setActive(status);
+                    return null;
+                }
+            });
+        } catch (RuntimeException ex) {
+            throw ex;
+        } catch (Exception ex) {
+            __log.error(__msgs.msgDbError(), ex);
+            throw new BpelEngineException(ex);
+        } finally {
+            _mngmtLock.writeLock().unlock();
+        }
+    }
+
+    public boolean isActive(final QName processId) {
+        _mngmtLock.writeLock().lock();
+        try {
+            if (__log.isDebugEnabled())
+                __log.debug("Setting property on process " + processId);
+
+            // Delete it from the database.
+            return _conn.exec(new ConfStoreConnection.Callable<Boolean>() {
+                public Boolean run() throws Exception {
+                    return _conn.getProcessConf(processId).isActive();
+                }
+            });
+        } catch (RuntimeException ex) {
+            throw ex;
+        } catch (Exception ex) {
+            __log.error(__msgs.msgDbError(), ex);
+            throw new BpelEngineException(ex);
+        } finally {
+            _mngmtLock.writeLock().unlock();
+        }
+    }
+
+    public ProcessConf getProcessConfiguration(final QName processId) {
+        _mngmtLock.writeLock().lock();
+        try {
+            if (__log.isDebugEnabled())
+                __log.debug("Setting property on process " + processId);
+
+            // Delete it from the database.
+            return _conn.exec(new ConfStoreConnection.Callable<ProcessConf>() {
+                public ProcessConf run() throws Exception {
+                    ProcessConfDAO confDAO = _conn.getProcessConf(processId);
+                    return buildConf(confDAO);
+                }
+            });
+        } catch (RuntimeException ex) {
+            throw ex;
+        } catch (Exception ex) {
+            __log.error(__msgs.msgDbError(), ex);
+            throw new BpelEngineException(ex);
+        } finally {
+            _mngmtLock.writeLock().unlock();
+        }
+    }
+
+    public List<String> getMexInterceptors(QName processId) {
+        ArrayList<String> mexi = new ArrayList<String>();
+        TDeployment.Process processInfo = getProcessInfo(processId);
+        if (processInfo.getMexInterceptors() != null) {
+            for (TMexInterceptor mexInterceptor : processInfo.getMexInterceptors().getMexInterceptorList()) {
+                mexi.add(mexInterceptor.getClassName());
+            }
+        }
+        return mexi;
+    }
+
+    public Definition getDefinitionForService(QName processId, QName serviceName) {
+        DeploymentUnit du = _deploymentUnits.get(processId);
+        return du.getDefinitionForService(serviceName);
+    }
+
+    private TDeployment.Process getProcessInfo(QName pid) {
+        DeployDocument deployDoc = _deploymentUnits.get(pid).getDeploymentDescriptor();
+        for (TDeployment.Process procInfo : deployDoc.getDeploy().getProcessList()) {
+            if (procInfo.getName().equals(pid)) return procInfo;
+        }
+        throw new BpelEngineException("Process not found: " + pid);
+    }
+
+    public void setProperty(final QName processId, final String name, final String namespace, final Node value) {
+        _mngmtLock.writeLock().lock();
+        try {
+            if (__log.isDebugEnabled())
+                __log.debug("Setting property on process " + processId);
+
+            // Delete it from the database.
+            _conn.exec(new ConfStoreConnection.Callable<Object>() {
+                public Object run() throws Exception {
+                    ProcessConfDAO proc = _conn.getProcessConf(processId);
+                    if (proc == null) {
+                        String msg = __msgs.msgProcessNotFound(processId);
+                        __log.info(msg);
+                        throw new BpelEngineException(msg);
+                    }
+                    proc.setProperty(name, namespace, value);
+                    return null;
+                }
+            });
+        } catch (RuntimeException ex) {
+            throw ex;
+        } catch (Exception ex) {
+            __log.error(__msgs.msgDbError(), ex);
+            throw new BpelEngineException(ex);
+        } finally {
+            _mngmtLock.writeLock().unlock();
+        }
+    }
+
+    public void setProperty(final QName processId, final String name, final String namespace, final String value) {
+        _mngmtLock.writeLock().lock();
+        try {
+            if (__log.isDebugEnabled())
+                __log.debug("Setting property on process " + processId);
+
+            // Delete it from the database.
+            _conn.exec(new ConfStoreConnection.Callable<Object>() {
+                public Object run() throws Exception {
+                    ProcessConfDAO proc = _conn.getProcessConf(processId);
+                    if (proc == null) {
+                        String msg = __msgs.msgProcessNotFound(processId);
+                        __log.info(msg);
+                        throw new BpelEngineException(msg);
+                    }
+                    proc.setProperty(name, namespace, value);
+                    return null;
+                }
+            });
+        } catch (RuntimeException ex) {
+            throw ex;
+        } catch (Exception ex) {
+            __log.error(__msgs.msgDbError(), ex);
+            throw new BpelEngineException(ex);
+        } finally {
+            _mngmtLock.writeLock().unlock();
+        }
+    }
+
+    private ProcessConf buildConf(ProcessConfDAO dao) {
+        DeploymentUnit du = _deploymentUnits.get(dao.getProcessId());
+        ProcessConfImpl conf = new ProcessConfImpl();
+        conf.setActive(dao.isActive());
+        conf.setDeployDate(dao.getDeployDate());
+        conf.setDeployer(dao.getDeployer());
+        conf.setFiles(du.allFiles().toArray(new File[0]));
+        conf.setPackageName(du.getDeployDir().getName());
+        conf.setProcessId(dao.getProcessId());
+        conf.setProps(dao.getProperties());
+        return conf;
+    }
+
+    private void reloadDeploymentUnits() {
+        for (DeploymentUnitImpl du : _deploymentManager.getDeploymentUnits())
+            try {
+                for (QName procName : du.getProcessNames()) {
+                    _deploymentUnits.put(procName, du);
+                }
+            } catch (Exception ex) {
+                String errmsg = "Error processing deployment unit " + du.getDeployDir()
+                        + "; some processes may not be loaded.";
+                __log.error(errmsg, ex);
+            }
+    }
+
+    private byte[] serialize(OProcess oprocess) {
+        Serializer serializer = new Serializer(oprocess.compileDate.getTime(), 1);
+        final byte[] bits;
+        try {
+            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            serializer.write(bos);
+            serializer.writeOProcess(oprocess, bos);
+            bos.close();
+            bits = bos.toByteArray();
+            return bits;
+        } catch (Exception ex) {
+            String errmsg = "Error re-serializing CBP";
+            __log.fatal(errmsg, ex);
+            throw new BpelEngineException(errmsg, ex);
+        }
+    }
+
+}

Added: incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ConfStoreConnection.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ConfStoreConnection.java?view=auto&rev=469714
==============================================================================
--- incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ConfStoreConnection.java (added)
+++ incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ConfStoreConnection.java Tue Oct 31 16:05:42 2006
@@ -0,0 +1,25 @@
+package org.apache.ode.store.dao;
+
+import javax.xml.namespace.QName;
+import java.util.List;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: dusty
+ * Date: Oct 31, 2006
+ * Time: 11:30:54 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public interface ConfStoreConnection {
+    ProcessConfDAO getProcessConf(QName pid);
+
+    List<ProcessConfDAO> getActiveProcesses();
+
+    ProcessConfDAO createProcess(QName pid, QName type);
+
+    <T> T exec(Callable<T> callable) throws Exception;
+
+    public interface Callable<T> {
+        public T run() throws Exception;
+    }
+}

Added: incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ConfStoreConnectionHib.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ConfStoreConnectionHib.java?view=auto&rev=469714
==============================================================================
--- incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ConfStoreConnectionHib.java (added)
+++ incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ConfStoreConnectionHib.java Tue Oct 31 16:05:42 2006
@@ -0,0 +1,226 @@
+package org.apache.ode.store.dao;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.iapi.BpelEngineException;
+import org.apache.ode.store.Messages;
+import org.apache.ode.store.hobj.HProcessConf;
+import org.apache.ode.store.hobj.HProcessProperty;
+import org.apache.ode.utils.msg.MessageBundle;
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.MappingException;
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.connection.ConnectionProvider;
+import org.hibernate.criterion.Expression;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.DialectFactory;
+
+import javax.sql.DataSource;
+import javax.xml.namespace.QName;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.SQLException;
+import java.util.*;
+
+/**
+ * @author mriou <mriou at apache dot org>
+ */
+public class ConfStoreConnectionHib implements ConfStoreConnection {
+
+    private static final Log __log = LogFactory.getLog(ConfStoreConnectionHib.class);
+    private static final Messages __msgs = MessageBundle.getMessages(Messages.class);
+
+    private static DataSource _ds;
+    private final SessionFactory _sessionFactory;
+
+    public ConfStoreConnectionHib(DataSource _ds, File appRoot) {
+        org.apache.ode.store.dao.ConfStoreConnectionHib._ds = _ds;
+        Properties properties = new Properties();
+        properties.put(Environment.CONNECTION_PROVIDER, DataSourceConnectionProvider.class.getName());
+        properties.put(Environment.CURRENT_SESSION_CONTEXT_CLASS, "thread");
+
+        try {
+            properties.put(Environment.DIALECT, guessDialect(_ds));
+        } catch (Exception ex) {
+            String errmsg = __msgs.msgOdeInitHibernateDialectDetectFailed();
+            __log.error(errmsg,ex);
+            throw new BpelEngineException(errmsg,ex);
+        }
+
+        File hibernatePropFile;
+        String confDir = System.getProperty("org.apache.ode.configDir");
+        if (confDir != null) hibernatePropFile = new File(confDir, "hibernate.properties");
+        else hibernatePropFile = new File(appRoot, "conf" + File.separatorChar + "hibernate.properties");
+
+        if (hibernatePropFile.exists()) {
+            FileInputStream fis;
+            try {
+                fis = new FileInputStream(hibernatePropFile);
+                properties.load(new BufferedInputStream(fis));
+            } catch (IOException e) {
+                String errmsg = __msgs
+                        .msgOdeInitHibernateErrorReadingHibernateProperties(hibernatePropFile);
+                __log.error(errmsg, e);
+                throw new BpelEngineException(errmsg, e);
+            }
+        } else {
+            __log.info(__msgs.msgOdeInitHibernatePropertiesNotFound(hibernatePropFile));
+        }
+
+        _sessionFactory = getDefaultConfiguration().setProperties(properties).buildSessionFactory();
+
+    }
+
+    public ProcessConfDAO getProcessConf(QName pid) {
+        try {
+            Criteria criteria = _sessionFactory.getCurrentSession().createCriteria(HProcessConf.class);
+            criteria.add(Expression.eq("processId", pid.toString()));
+            // For the moment we are expecting only one result.
+            HProcessConf hprocess = (HProcessConf) criteria.uniqueResult();
+            return hprocess == null ? null : new ProcessConfDAOHib(_sessionFactory, hprocess);
+        } catch (HibernateException e) {
+            __log.error("DbError", e);
+            throw e;
+        }
+    }
+
+    public List<ProcessConfDAO> getActiveProcesses() {
+        try {
+            Criteria criteria = _sessionFactory.getCurrentSession().createCriteria(HProcessConf.class);
+            criteria.add(Expression.eq("active", Boolean.TRUE));
+            // For the moment we are expecting only one result.
+            List hprocesses = criteria.list();
+            ArrayList<ProcessConfDAO> result = new ArrayList<ProcessConfDAO>(hprocesses.size());
+            for (Object hprocess : hprocesses) {
+                HProcessConf hpc = (HProcessConf)hprocess;
+                result.add(new ProcessConfDAOHib(_sessionFactory, hpc));
+            }
+            return result;
+        } catch (HibernateException e) {
+            __log.error("DbError", e);
+            throw e;
+        }
+    }
+
+    public ProcessConfDAO createProcess(QName pid, QName type) {
+        HProcessConf process = new HProcessConf();
+        process.setProcessId(pid.toString());
+        process.setTypeName(type.getLocalPart());
+        process.setTypeNamespace(type.getNamespaceURI());
+        process.setDeployDate(new Date());
+        _sessionFactory.getCurrentSession().save(process);
+        return new ProcessConfDAOHib(_sessionFactory, process);
+    }
+
+
+    public static Configuration getDefaultConfiguration() throws MappingException {
+        return new Configuration().addClass(HProcessConf.class).addClass(HProcessProperty.class);
+    }
+
+    private String guessDialect(DataSource dataSource) throws Exception {
+        String dialect = null;
+        // Open a connection and use that connection to figure out database
+        // product name/version number in order to decide which Hibernate
+        // dialect to use.
+        Connection conn = dataSource.getConnection();
+        try {
+            DatabaseMetaData metaData = conn.getMetaData();
+            if (metaData != null) {
+                String dbProductName = metaData.getDatabaseProductName();
+                int dbMajorVer = metaData.getDatabaseMajorVersion();
+                __log.info("Using database " + dbProductName + " major version "
+                        + dbMajorVer);
+                DialectFactory.DatabaseDialectMapper mapper = HIBERNATE_DIALECTS.get(dbProductName);
+                if (mapper != null) {
+                    dialect = mapper.getDialectClass(dbMajorVer);
+                } else {
+                    Dialect hbDialect = DialectFactory.determineDialect(dbProductName, dbMajorVer);
+                    if (hbDialect != null)
+                        dialect = hbDialect.getClass().getName();
+                }
+            }
+        } finally {
+            conn.close();
+        }
+
+        if (dialect == null) {
+            __log
+                    .info("Cannot determine hibernate dialect for this database: using the default one.");
+            dialect = DEFAULT_HIBERNATE_DIALECT;
+        }
+
+        return dialect;
+
+    }
+
+    public static class DataSourceConnectionProvider implements ConnectionProvider {
+        public DataSourceConnectionProvider() {
+        }
+
+        public void configure(Properties props) throws HibernateException {
+        }
+
+        public Connection getConnection() throws SQLException {
+            return _ds.getConnection();
+        }
+
+        public void closeConnection(Connection arg0) throws SQLException {
+            arg0.close();
+        }
+
+        public void close() throws HibernateException {
+        }
+
+        public boolean supportsAggressiveRelease() {
+            return true;
+        }
+    }
+
+    private static final String DEFAULT_HIBERNATE_DIALECT = "org.hibernate.dialect.DerbyDialect";
+    private static final HashMap<String, DialectFactory.VersionInsensitiveMapper> HIBERNATE_DIALECTS = new HashMap<String, DialectFactory.VersionInsensitiveMapper>();
+
+    static {
+        // Hibernate has a nice table that resolves the dialect from the database
+        // product name,
+        // but doesn't include all the drivers. So this is supplementary, and some
+        // day in the
+        // future they'll add more drivers and we can get rid of this.
+        // Drivers already recognized by Hibernate:
+        // HSQL Database Engine
+        // DB2/NT
+        // MySQL
+        // PostgreSQL
+        // Microsoft SQL Server Database, Microsoft SQL Server
+        // Sybase SQL Server
+        // Informix Dynamic Server
+        // Oracle 8 and Oracle >8
+        HIBERNATE_DIALECTS.put("Apache Derby",
+                new DialectFactory.VersionInsensitiveMapper(
+                        "org.hibernate.dialect.DerbyDialect"));
+    }
+
+    /**
+     * Execute a self-contained database transaction.
+     * @param callable database transaction
+     * @return callable result
+     */
+    public <T> T exec(final Callable<T> callable) throws Exception {
+        try {
+            _sessionFactory.getCurrentSession().beginTransaction();
+            T result =  callable.run();
+            _sessionFactory.getCurrentSession().getTransaction().commit();
+            return result;
+        } catch (Exception e) {
+            _sessionFactory.getCurrentSession().getTransaction().rollback();
+            throw e;
+        }
+    }
+
+}

Added: incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ConfStoreConnectionInMem.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ConfStoreConnectionInMem.java?view=auto&rev=469714
==============================================================================
--- incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ConfStoreConnectionInMem.java (added)
+++ incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ConfStoreConnectionInMem.java Tue Oct 31 16:05:42 2006
@@ -0,0 +1,42 @@
+package org.apache.ode.store.dao;
+
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author mriou <mriou at apache dot org>
+ */
+public class ConfStoreConnectionInMem implements ConfStoreConnection {
+
+    private List<ProcessConfDAO> _daos = new ArrayList<ProcessConfDAO>();
+
+    public ProcessConfDAO createProcess(QName pid, QName type) {
+        ProcessConfDAOInMem dao = new ProcessConfDAOInMem();
+        dao.setActive(true);
+        dao.setDeployDate(new Date());
+        dao.setProcessId(pid);
+        dao.setTypeName(type.getLocalPart());
+        dao.setTypeNamespace(type.getNamespaceURI());
+        dao.setVersion(0);
+        _daos.add(dao);
+        return dao;
+    }
+
+    public <T> T exec(Callable<T> callable) throws Exception {
+        return callable.run();
+    }
+
+    public List<ProcessConfDAO> getActiveProcesses() {
+        // In-memory deactivation is highly unlikely to be useful
+        return _daos;
+    }
+
+    public ProcessConfDAO getProcessConf(QName pid) {
+        for (ProcessConfDAO dao : _daos) {
+            if (dao.getProcessId().equals(pid)) return dao;
+        }
+        return null;
+    }
+}

Added: incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ProcessConfDAO.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ProcessConfDAO.java?view=auto&rev=469714
==============================================================================
--- incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ProcessConfDAO.java (added)
+++ incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ProcessConfDAO.java Tue Oct 31 16:05:42 2006
@@ -0,0 +1,36 @@
+package org.apache.ode.store.dao;
+
+import org.w3c.dom.Node;
+
+import javax.xml.namespace.QName;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * @author mriou <mriou at apache dot org>
+ */
+public interface ProcessConfDAO {
+    Date getDeployDate();
+
+    String getDeployer();
+
+    QName getProcessId();
+
+    String getTypeName();
+
+    String getTypeNamespace();
+
+    int getVersion();
+
+    boolean isActive();
+
+    void setActive(boolean active);
+
+    void setProperty(String name, String ns, Node content);
+
+    void setProperty(String name, String ns, String content);
+
+    Map<QName,Node> getProperties();
+
+    void delete();
+}

Added: incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ProcessConfDAOHib.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ProcessConfDAOHib.java?view=auto&rev=469714
==============================================================================
--- incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ProcessConfDAOHib.java (added)
+++ incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ProcessConfDAOHib.java Tue Oct 31 16:05:42 2006
@@ -0,0 +1,140 @@
+package org.apache.ode.store.dao;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.store.hobj.HProcessConf;
+import org.apache.ode.store.hobj.HProcessProperty;
+import org.apache.ode.utils.DOMUtils;
+import org.hibernate.SessionFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+import javax.xml.namespace.QName;
+import java.io.IOException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author mriou <mriou at apache dot org>
+ */
+public class ProcessConfDAOHib implements ProcessConfDAO {
+
+    private static final Log __log = LogFactory.getLog(ProcessConfDAOHib.class);
+
+    private HProcessConf _process;
+    private SessionFactory _sf;
+
+    public ProcessConfDAOHib(SessionFactory sf, HProcessConf process) {
+        _process = process;
+        _sf = sf;
+    }
+
+    public Date getDeployDate() {
+        return _process.getDeployDate();
+    }
+
+    public String getDeployer() {
+        return _process.getDeployer();
+    }
+
+    public QName getProcessId() {
+        return QName.valueOf(_process.getProcessId());
+    }
+
+    public String getTypeName() {
+        return _process.getTypeName();
+    }
+
+    public String getTypeNamespace() {
+        return _process.getTypeNamespace();
+    }
+
+    public int getVersion() {
+        return _process.getVersion();
+    }
+
+    public boolean isActive() {
+        return _process.isActive();
+    }
+
+    public void setActive(boolean active) {
+        _process.setActive(active);
+    }
+
+    public void setProperty(String name, String ns, Node content) {
+        setProperty(name, ns, DOMUtils.domToStringLevel2(content), false);
+    }
+
+    public void setProperty(String name, String ns, String content) {
+        setProperty(name, ns, content, true);
+    }
+
+    private void setProperty(String name, String ns, String content, boolean simple) {
+        HProcessProperty existingProperty = getProperty(name, ns);
+        if (existingProperty == null) {
+            HProcessProperty property = new HProcessProperty();
+            property.setName(name);
+            property.setNamespace(ns);
+            if (simple) property.setSimpleContent(content);
+            else property.setMixedContent(content);
+            _process.getProperties().add(property);
+            property.setProcess(_process);
+            _sf.getCurrentSession().save(property);
+        } else {
+            if (content == null) {
+                _sf.getCurrentSession().delete(existingProperty);
+                _process.getProperties().remove(existingProperty);
+            } else {
+                if (simple) existingProperty.setSimpleContent(content);
+                else existingProperty.setMixedContent(content);
+                _sf.getCurrentSession().save(existingProperty);
+            }
+        }
+        update();
+    }
+
+    private HProcessProperty getProperty(String name, String ns) {
+        HProcessProperty existingProperty = null;
+        for (HProcessProperty hproperty : _process.getProperties()) {
+            if (hproperty.getName().equals(name) && hproperty.getNamespace().equals(ns))
+                existingProperty = hproperty;
+        }
+        return existingProperty;
+    }
+
+    public Map<QName,Node> getProperties() {
+        HashMap<QName,Node> propsMap = new HashMap<QName, Node>();
+        Document doc = DOMUtils.newDocument();
+        for (HProcessProperty hprop : _process.getProperties()) {
+            QName propName = new QName(hprop.getNamespace(), hprop.getName());
+            Node propNode = null;
+            if (hprop.getSimpleContent() != null) {
+                propNode = doc.createTextNode(hprop.getSimpleContent());
+            } else if (hprop.getMixedContent() != null) {
+                try {
+                    propNode = DOMUtils.stringToDOM(hprop.getMixedContent());
+                } catch (SAXException e) {
+                    __log.error("Mixed content stored in property " + hprop.getName() +
+                            " for process " + getProcessId() + " couldn't be converted to a DOM " +
+                            "document.", e);
+                } catch (IOException e) {
+                    __log.error("Mixed content stored in property " + hprop.getName() +
+                            " for process " + getProcessId() + " couldn't be converted to a DOM " +
+                            "document.", e);
+                }
+            }
+            propsMap.put(propName, propNode);
+        }
+        return propsMap;
+    }
+
+    public void delete() {
+        _sf.getCurrentSession().delete(_process);
+    }
+
+    private void update() {
+      _sf.getCurrentSession().update(_process);
+    }
+}

Added: incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ProcessConfDAOInMem.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ProcessConfDAOInMem.java?view=auto&rev=469714
==============================================================================
--- incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ProcessConfDAOInMem.java (added)
+++ incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/dao/ProcessConfDAOInMem.java Tue Oct 31 16:05:42 2006
@@ -0,0 +1,97 @@
+package org.apache.ode.store.dao;
+
+import org.apache.ode.utils.DOMUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+import javax.xml.namespace.QName;
+import java.util.Date;
+import java.util.HashMap;
+
+/**
+ * @author mriou <mriou at apache dot org>
+ */
+public class ProcessConfDAOInMem implements ProcessConfDAO {
+
+    private QName _processId;
+    private String _deployer;
+    private Date _deployDate;
+    private HashMap<QName, Node> _properties = new HashMap<QName, Node>();
+    private String typeName;
+    private String typeNamespace;
+    private int version;
+    private boolean active;
+
+    public Date getDeployDate() {
+        return _deployDate;
+    }
+
+    public void setDeployDate(Date deployDate) {
+        _deployDate = deployDate;
+    }
+
+    public String getDeployer() {
+        return _deployer;
+    }
+
+    public void setDeployer(String deployer) {
+        _deployer = deployer;
+    }
+
+    public QName getProcessId() {
+        return _processId;
+    }
+
+    public void setProcessId(QName processId) {
+        _processId = processId;
+    }
+
+    public HashMap<QName, Node> getProperties() {
+        return _properties;
+    }
+
+    public boolean isActive() {
+        return active;
+    }
+
+    public void setActive(boolean active) {
+        this.active = active;
+    }
+
+    public String getTypeName() {
+        return typeName;
+    }
+
+    public void setTypeName(String typeName) {
+        this.typeName = typeName;
+    }
+
+    public String getTypeNamespace() {
+        return typeNamespace;
+    }
+
+    public void setTypeNamespace(String typeNamespace) {
+        this.typeNamespace = typeNamespace;
+    }
+
+    public int getVersion() {
+        return version;
+    }
+
+    public void setVersion(int version) {
+        this.version = version;
+    }
+
+    public void setProperty(String name, String ns, Node content) {
+        _properties.put(new QName(ns, name), content);
+    }
+
+    public void setProperty(String name, String ns, String content) {
+        Document doc = DOMUtils.newDocument();        
+        _properties.put(new QName(ns, name), doc.createTextNode(content));
+    }
+
+    public void delete() {
+
+    }
+}

Added: incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/deploy/DeploymentManager.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/deploy/DeploymentManager.java?view=auto&rev=469714
==============================================================================
--- incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/deploy/DeploymentManager.java (added)
+++ incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/deploy/DeploymentManager.java Tue Oct 31 16:05:42 2006
@@ -0,0 +1,44 @@
+package org.apache.ode.store.deploy;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.Set;
+
+/**
+ * Interface to the deployment manager. This is a mechanism for keeping track (persistently) of the deployment
+ * units.
+
+ * @author Maciej Szefler - m s z e f l e r @ g m a i l . c o m
+ *
+ */
+public interface DeploymentManager {
+
+    /**
+     * Create a deployment unit based on a given location (and remember it).
+     * @param location location of the deployment unit
+     * @return instance of the {@link org.apache.ode.bpel.iapi.DeploymentUnit} interface representing the newly created deployment unit
+     */
+    DeploymentUnitImpl createDeploymentUnit(String location);
+
+    DeploymentUnitImpl createDeploymentUnit(File deploymentUnitDirectory);
+
+    /**
+     * Remove a deployment unit previously created using {@link #createDeploymentUnit(String)} method. The removal
+     * is permanent--that is the persistent representation of the deployment unit can be removed.
+     * @param du
+     */
+    void remove(DeploymentUnitImpl du);
+
+    /**
+     * Get the collection of deployment units created with the {@link #createDeploymentUnit(String)} method
+     * that have not been {@link #remove(org.apache.ode.bpel.iapi.DeploymentUnit)}ed.
+     * @return
+     */
+    Collection<DeploymentUnitImpl> getDeploymentUnits();
+
+    /**
+     * @return the list of packages that are declared in the persistent storage.
+     */
+    Set<String> getDeploymentsList();
+
+}

Added: incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/deploy/DeploymentManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/deploy/DeploymentManagerImpl.java?view=auto&rev=469714
==============================================================================
--- incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/deploy/DeploymentManagerImpl.java (added)
+++ incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/deploy/DeploymentManagerImpl.java Tue Oct 31 16:05:42 2006
@@ -0,0 +1,146 @@
+package org.apache.ode.store.deploy;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.utils.fs.FileUtils;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/**
+ * A simple implementation of the
+ * {@link org.apache.ode.store.deploy.DeploymentManager} interface.
+ *
+ * @author Maciej Szefler - m s z e f l e r @ g m a i l . c o m
+ *
+ */
+public class DeploymentManagerImpl implements DeploymentManager {
+
+    private static final Log __log = LogFactory.getLog(DeploymentManagerImpl.class);
+    private File _deployDir;
+    private File _deployStateFile;
+
+    private HashSet<DeploymentUnitImpl> _knownDeployments = new HashSet<DeploymentUnitImpl>();
+    private HashSet<String> _deploymentsList = new HashSet<String>();
+
+    /** Lock to prevent clobbering of the file. */
+    private ReentrantReadWriteLock _rwLock = new ReentrantReadWriteLock();
+
+    private long _lastRead = 0;
+
+    public DeploymentManagerImpl(File deployDir) {
+        _deployDir = deployDir;
+        _deployStateFile = new File(deployDir.getParentFile(), "ode-deployed.dat");
+    }
+
+    public DeploymentUnitImpl createDeploymentUnit(String location) {
+        return createDeploymentUnit(new File(location));
+    }
+
+    public DeploymentUnitImpl createDeploymentUnit(File deploymentUnitDirectory) {
+        read();
+        _rwLock.writeLock().lock();
+        try {
+            _deploymentsList.add(deploymentUnitDirectory.getName());
+            DeploymentUnitImpl du = new DeploymentUnitImpl(deploymentUnitDirectory);
+            _knownDeployments.add(du);
+            write();
+            return du;
+        } finally {
+            _rwLock.writeLock().unlock();
+        }
+    }
+
+    public void remove(DeploymentUnitImpl du) {
+//        read();
+        _rwLock.writeLock().lock();
+        try {
+            if (!_knownDeployments.remove(du))
+                return;
+            _deploymentsList.remove(du.getDeployDir().getName());
+            write();
+            FileUtils.deepDelete(du.getDeployDir());
+        } finally {
+            _rwLock.writeLock().unlock();
+        }
+    }
+
+    public Collection<DeploymentUnitImpl> getDeploymentUnits() {
+        read();
+        _rwLock.writeLock().lock();
+        try {
+            return new ArrayList<DeploymentUnitImpl>(_knownDeployments);
+        } finally {
+            _rwLock.writeLock().unlock();
+        }
+    }
+
+    /**
+     * Read the file containing list of deployment units from disk.
+     *
+     */
+    private void read() {
+        _rwLock.writeLock().lock();
+        try {
+            if (!_deployStateFile.exists()) {
+                _knownDeployments.clear();
+                return;
+            }
+
+            if (_deployStateFile.lastModified() > _lastRead) {
+                LineNumberReader reader = new LineNumberReader(new FileReader(_deployStateFile));
+                _knownDeployments.clear();
+                try {
+                    String lin;
+                    while ((lin = reader.readLine()) != null) {
+                        _deploymentsList.add(lin);
+                        try {
+                            _knownDeployments.add(new DeploymentUnitImpl(new File(_deployDir, lin)));
+                        } catch (Exception ex) {
+                            DeploymentManagerImpl.__log.debug("Failed to load DU (skipping): " + lin,ex);
+                        }
+                    }
+
+                    _lastRead = _deployStateFile.lastModified();
+                } finally {
+                    reader.close();
+                }
+            }
+        } catch (IOException ioex) {
+            throw new RuntimeException(ioex);
+        } finally {
+            _rwLock.writeLock().unlock();
+        }
+    }
+
+    /**
+     * Write the file containing the list of deployment units to disk.
+     *
+     */
+    private void write() {
+        _rwLock.writeLock().lock();
+        try {
+            PrintWriter writer = new PrintWriter(_deployStateFile);
+            try {
+                for (DeploymentUnitImpl du : _knownDeployments) {
+                    writer.println(du.getDeployDir().getName());
+                }
+            } finally {
+                writer.close();
+            }
+
+        } catch (IOException ioex) {
+            throw new RuntimeException(ioex);
+        } finally {
+            _rwLock.writeLock().unlock();
+        }
+    }
+
+    public Set<String> getDeploymentsList() {
+        return _deploymentsList;
+    }
+}

Added: incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/deploy/DeploymentUnitImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/deploy/DeploymentUnitImpl.java?view=auto&rev=469714
==============================================================================
--- incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/deploy/DeploymentUnitImpl.java (added)
+++ incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/deploy/DeploymentUnitImpl.java Tue Oct 31 16:05:42 2006
@@ -0,0 +1,276 @@
+package org.apache.ode.store.deploy;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.compiler.BpelC;
+import org.apache.ode.bpel.compiler.DefaultWsdlFinder;
+import org.apache.ode.bpel.compiler.DefaultXsltFinder;
+import org.apache.ode.bpel.compiler.api.CompilationException;
+import org.apache.ode.bpel.compiler.wsdl.Definition4BPEL;
+import org.apache.ode.bpel.compiler.wsdl.WSDLFactory4BPEL;
+import org.apache.ode.bpel.compiler.wsdl.WSDLFactoryBPEL20;
+import org.apache.ode.bpel.dd.DeployDocument;
+import org.apache.ode.bpel.dd.TDeployment;
+import org.apache.ode.bpel.iapi.BpelEngineException;
+import org.apache.ode.bpel.iapi.DeploymentUnit;
+import org.apache.ode.bpel.o.OProcess;
+import org.apache.ode.bpel.o.Serializer;
+
+import javax.wsdl.Definition;
+import javax.wsdl.WSDLException;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+import java.io.*;
+import java.util.*;
+
+/**
+ * Container providing various functions on the deployment directory.
+ *
+ * @author mriou
+ *
+ * TODO Add a way to cause lazy methods to re-process stuff on disk.
+ */
+public class DeploymentUnitImpl implements DeploymentUnit {
+
+    private static Log __log = LogFactory.getLog(DeploymentUnitImpl.class);
+
+    private String _name;
+    private File _duDirectory;
+    private DocumentRegistry _docRegistry;
+    private HashMap<QName, OProcess> _processes;
+    private DeployDocument _dd;
+    private File _descriptorFile;
+    private HashMap<QName, TDeployment.Process> _processInfo;
+    private boolean _refreshed;
+
+    private static final FileFilter _wsdlFilter = new FileFilter() {
+        public boolean accept(File path) {
+            return path.getName().endsWith(".wsdl");
+        }
+    };
+
+    private static final FileFilter _cbpFilter = new FileFilter() {
+        public boolean accept(File path) {
+            return path.getName().endsWith(".cbp");
+        }
+    };
+
+    private static final FileFilter _bpelFilter = new FileFilter() {
+        public boolean accept(File path) {
+            return path.getName().endsWith(".bpel");
+        }
+    };
+
+    public DeploymentUnitImpl(File dir) {
+        if (!dir.exists())
+            throw new IllegalArgumentException("Directory " + dir + " does not exist!");
+
+        _duDirectory = dir;
+        _name = dir.getName();
+        _descriptorFile = new File(_duDirectory, "deploy.xml");
+
+        if (!_descriptorFile.exists())
+            throw new IllegalArgumentException("Directory " + dir + " does not contain a deploy.xml file!");
+
+        refresh();
+    }
+
+
+    /**
+     * Checking for each BPEL file if we have a corresponding compiled process.
+     * If we don't, starts compilation. The force parameter just forces
+     * compilation, whether a cbp file exists or not.
+     */
+    private void compileProcesses(boolean force) {
+        ArrayList<File> bpels = listFilesRecursively(_duDirectory, DeploymentUnitImpl._bpelFilter);
+        for (File bpel : bpels) {
+            File compiled = new File(bpel.getParentFile(), bpel.getName().substring(0,bpel.getName().length()-".bpel".length()) + ".cbp");
+            if (compiled.exists() && !force) {
+                continue;
+            }
+            compile(bpel);
+        }
+    }
+
+    private void compile(File bpelFile) {
+        BpelC bpelc = BpelC.newBpelCompiler();
+        bpelc.setOutputDirectory(_duDirectory);
+        bpelc.setWsdlFinder(new DefaultWsdlFinder(_duDirectory));
+        bpelc.setXsltFinder(new DefaultXsltFinder(_duDirectory));
+        try {
+            bpelc.compile(bpelFile);
+        } catch (IOException e) {
+            DeploymentUnitImpl.__log.error("Couldn't compile process file!", e);
+        }
+    }
+
+    private void loadProcessDefinitions(boolean force) {
+        try {
+            compileProcesses(force);
+        } catch (CompilationException e) {
+            // No retry on compilation error, we just forget about it
+            throw new BpelEngineException("Compilation failure!");
+        }
+        if (_processes == null || force) {
+            _processes = new HashMap<QName, OProcess>();
+            ArrayList<File> cbps = listFilesRecursively(_duDirectory, DeploymentUnitImpl._cbpFilter);
+            for (File file : cbps) {
+                OProcess oprocess = loadProcess(file);
+                _processes.put(new QName(oprocess.targetNamespace, oprocess.getName()), oprocess);
+            }
+        }
+    }
+
+    /**
+     * Load the parsed and compiled BPEL process definition.
+     */
+    private OProcess loadProcess(File f) {
+        InputStream is = null;
+        try {
+            is = new FileInputStream(f);
+            Serializer ofh = new Serializer(is);
+            return ofh.readOProcess();
+        } catch (Exception e) {
+            throw new BpelEngineException("Couldn't read compiled BPEL process " + f.getAbsolutePath(), e);
+        } finally {
+            try {
+                if (is != null)
+                    is.close();
+            } catch (Exception e) {
+            }
+        }
+    }
+
+    public boolean removed() {
+        return !_duDirectory.exists();
+    }
+
+    public boolean matches(File f) {
+        return f.getAbsolutePath().equals(new File(_duDirectory, "deploy.xml").getAbsolutePath());
+    }
+
+    public int hashCode() {
+        return _name.hashCode();
+    }
+
+    public boolean equals(Object obj) {
+        if (!(obj instanceof DeploymentUnitImpl)) return false;
+        return ((DeploymentUnitImpl)obj).getDeployDir().getAbsolutePath().equals(getDeployDir().getAbsolutePath());
+    }
+
+    public File getDeployDir() {
+        return _duDirectory;
+    }
+
+    public DeployDocument getDeploymentDescriptor() {
+        if (_dd == null) {
+            File ddLocation = new File(_duDirectory, "deploy.xml");
+            try {
+                _dd = DeployDocument.Factory.parse(ddLocation);
+            } catch (Exception e) {
+                throw new BpelEngineException("Couldnt read deployment descriptor at location "
+                        + ddLocation.getAbsolutePath(), e);
+            }
+
+        }
+        return _dd;
+    }
+
+    public HashMap<QName, OProcess> getProcesses() {
+        loadProcessDefinitions(false);
+        return _processes;
+    }
+
+    public DocumentRegistry getDocRegistry() {
+        if (_docRegistry == null) {
+            _docRegistry = new DocumentRegistry(new DocumentEntityResolver(_duDirectory));
+
+            WSDLFactory4BPEL wsdlFactory = (WSDLFactory4BPEL) WSDLFactoryBPEL20.newInstance();
+            WSDLReader r = wsdlFactory.newWSDLReader();
+
+            ArrayList<File> wsdls = listFilesRecursively(_duDirectory, DeploymentUnitImpl._wsdlFilter);
+            for (File file : wsdls) {
+                try {
+                    _docRegistry.addDefinition((Definition4BPEL) r.readWSDL(file.toURI().toString()));
+                } catch (WSDLException e) {
+                    throw new BpelEngineException("Couldn't read WSDL document " + file.getAbsolutePath(), e);
+                }
+            }
+        }
+        return _docRegistry;
+    }
+
+    public Definition getDefinitionForService(QName name) {
+        return getDocRegistry().getDefinition(name);
+    }
+
+    public Collection<Definition> getDefinitions() {
+        Definition4BPEL defs[] = getDocRegistry().getDefinitions();
+        ArrayList<Definition> ret = new ArrayList<Definition>(defs.length);
+        for (Definition4BPEL def : defs)
+            ret.add(def);
+        return ret;
+    }
+
+    public Set<QName> getProcessNames() {
+        if (_processes == null) loadProcessDefinitions(false);
+        return _processes.keySet();
+    }
+
+    public String toString() {
+        return "{DeploymentUnit " + _name + "}";
+    }
+
+    public TDeployment.Process getProcessDeployInfo(QName pid) {
+        if (_processInfo == null) {
+            _processInfo = new HashMap<QName, TDeployment.Process>();
+
+            for (TDeployment.Process p : getDeploymentDescriptor().getDeploy().getProcessList()) {
+                _processInfo.put(p.getName(), p);
+            }
+        }
+
+        return _processInfo.get(pid);
+    }
+
+    public void refresh() {
+        if (!_refreshed) {
+            loadProcessDefinitions(true);
+            _refreshed = true;
+        }
+    }
+
+    public List<File> allFiles() {
+        return allFiles(_duDirectory);
+    }
+
+    private List<File> allFiles(File dir) {
+        ArrayList<File> result = new ArrayList<File>();
+        for (File file : dir.listFiles()) {
+            if (file.isDirectory()) {
+                result.addAll(allFiles(file));
+            }
+            if (file.isHidden()) continue;
+            if (file.isFile()) {
+                result.add(file);
+            }
+        }
+        return result;
+    }
+
+    private ArrayList<File> listFilesRecursively(File root, FileFilter filter) {
+        ArrayList<File> result = new ArrayList<File>();
+        // Filtering the files we're interested in in the current directory
+        File[] select = root.listFiles(filter);
+        for (File file : select) {
+            result.add(file);
+        }
+        // Then we can check the directories
+        File[] all = root.listFiles();
+        for (File file : all) {
+            if (file.isDirectory())
+                result.addAll(listFilesRecursively(file, filter));
+        }
+        return result;
+    }
+}

Added: incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/deploy/DocumentEntityResolver.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/deploy/DocumentEntityResolver.java?view=auto&rev=469714
==============================================================================
--- incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/deploy/DocumentEntityResolver.java (added)
+++ incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/deploy/DocumentEntityResolver.java Tue Oct 31 16:05:42 2006
@@ -0,0 +1,41 @@
+package org.apache.ode.store.deploy;
+
+import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
+import com.sun.org.apache.xerces.internal.xni.XNIException;
+import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver;
+import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
+import org.apache.ode.utils.fs.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * Resolves references inide the deployment unit.
+ */
+public class DocumentEntityResolver implements XMLEntityResolver {
+
+    private File _docRoot;
+
+    public DocumentEntityResolver(File docRoot) {
+        _docRoot = docRoot;
+    }
+
+    public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException {
+        XMLInputSource src = new XMLInputSource(resourceIdentifier);
+        String resourceName = resourceIdentifier.getLiteralSystemId();
+        String base;
+        try {
+            base = new URI(FileUtils.encodePath(resourceIdentifier.getBaseSystemId())).toURL().getFile();
+        } catch (URISyntaxException e) {
+            throw new RuntimeException("Base system id incorrect, parser error", e);
+        }
+
+        if (new File(new File(base).getParent(), resourceName).exists())
+            src.setByteStream(new File(new File(base).getParent(), resourceName).toURL().openStream());
+        else src.setByteStream(new File(_docRoot, resourceName).toURL().openStream());
+
+        return src;
+    }
+}

Added: incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/deploy/DocumentRegistry.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/deploy/DocumentRegistry.java?view=auto&rev=469714
==============================================================================
--- incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/deploy/DocumentRegistry.java (added)
+++ incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/deploy/DocumentRegistry.java Tue Oct 31 16:05:42 2006
@@ -0,0 +1,84 @@
+package org.apache.ode.store.deploy;
+
+import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.compiler.api.CompilationException;
+import org.apache.ode.bpel.compiler.wsdl.Definition4BPEL;
+import org.apache.ode.store.Messages;
+import org.apache.ode.utils.xsd.SchemaModel;
+
+import javax.xml.namespace.QName;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A parsed collection of WSDL definitions, including BPEL-specific extensions.
+ */
+public class DocumentRegistry {
+    private static final Log __log = LogFactory.getLog(DocumentRegistry.class);
+    private static final Messages __msgs = Messages.getMessages(Messages.class);
+
+    private final ArrayList<Definition4BPEL> _definitions = new ArrayList<Definition4BPEL>();
+    private final Map<URI, byte[]> _schemas = new HashMap<URI,byte[]>();
+
+    private SchemaModel _model;
+    private XMLEntityResolver _resolver;
+
+    public DocumentRegistry(XMLEntityResolver resolver) {
+        // bogus schema to force schema creation
+        _schemas.put(URI.create("http://www.apache.org/ode/bogus/namespace"),
+                ("<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\""
+                        + " targetNamespace=\"http://www.apache.org/ode/bogus/namespace\">"
+                        + "<xsd:simpleType name=\"__bogusType__\">"
+                        + "<xsd:restriction base=\"xsd:normalizedString\"/>"
+                        + "</xsd:simpleType>" + "</xsd:schema>").getBytes());
+        _resolver = resolver;
+    }
+
+
+    /**
+     * Obtains an WSDL definition based on its target namespace.
+     *
+     * @param serviceName
+     *
+     * @return WSDL definition or <code>null</code> if unavailable.
+     */
+    public Definition4BPEL getDefinition(QName serviceName) {
+        for (Definition4BPEL definition4BPEL : _definitions) {
+            if (definition4BPEL.getTargetNamespace().equals(serviceName.getNamespaceURI())) {
+                if (definition4BPEL.getService(serviceName) != null)
+                    return definition4BPEL;
+            }
+        }
+        return null;
+    }
+
+    public Definition4BPEL[] getDefinitions(){
+        return _definitions.toArray(new Definition4BPEL[_definitions.size()]);
+    }
+
+    /**
+     * Adds a WSDL definition for use in resolving MessageType, PortType,
+     * Operation and BPEL properties and property aliases
+     * @param def WSDL definition
+     */
+    @SuppressWarnings("unchecked")
+    public void addDefinition(Definition4BPEL def) throws CompilationException {
+        if (def == null)
+            throw new NullPointerException("def=null");
+
+        if (DocumentRegistry.__log.isDebugEnabled()) {
+            DocumentRegistry.__log.debug("addDefinition(" + def.getTargetNamespace() + " from " + def.getDocumentBaseURI() + ")");
+        }
+
+        _definitions.add(def);
+
+        // For now the schemas are never used at runtime. Check the compiler if this needs to be
+        // put back in.
+//        captureSchemas(def);
+    }
+
+}

Added: incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/hobj/HProcessConf.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/hobj/HProcessConf.java?view=auto&rev=469714
==============================================================================
--- incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/hobj/HProcessConf.java (added)
+++ incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/hobj/HProcessConf.java Tue Oct 31 16:05:42 2006
@@ -0,0 +1,164 @@
+package org.apache.ode.store.hobj;
+
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author mriou <mriou at apache dot org>
+ * @hibernate.class table="BPEL_PROCESS_CONF"
+ */
+public class HProcessConf {
+
+    private Long _id;
+
+    /** {@link HProcessProperty}s for this process. */
+    private Set<HProcessProperty> _properties = new HashSet<HProcessProperty>();
+
+    /** Simple name of the process. */
+    private String _processId;
+
+    /** User that deployed the process. */
+    private String _deployer;
+
+    /** Date of last deployment. */
+    private Date _deployDate;
+
+    /** Process name. */
+    private String _typeName;
+
+    /** Process namespace. */
+    private String _typeNamespace;
+
+    /** Process version. */
+    private int _version;
+
+    /** Whether process is retired */
+    private boolean _active;
+
+    /**
+     * @hibernate.id generator-class="native" column="ID"
+     */
+    public Long getId() {
+        return _id;
+    }
+
+    public void setId(Long id) {
+        _id = id;
+    }
+
+    /**
+     * @hibernate.set
+     *  lazy="true"
+     *  inverse="true"
+     *  cascade="delete"
+     * @hibernate.collection-key
+     *  column="PROCESS_ID"
+     * @hibernate.collection-one-to-many
+     *   class="org.apache.ode.store.hobj.HProcessProperty"
+     */
+    public Set<HProcessProperty> getProperties() {
+        return _properties;
+    }
+
+    public void setProperties(Set<HProcessProperty> properties) {
+        _properties = properties;
+    }
+
+    /**
+     *
+     * @hibernate.property
+     * @hibernate.column
+     *  name="PROCID"
+     *  not-null="true"
+     *  unique="true"
+     */
+    public String getProcessId() {
+        return _processId;
+    }
+
+    public void setProcessId(String processId) {
+        _processId = processId;
+    }
+
+    /**
+     * The user that deployed the process.
+     * @hibernate.property
+     *    column="deployer"
+     */
+    public String getDeployer() {
+        return _deployer;
+    }
+
+    public void setDeployer(String deployer) {
+        _deployer = deployer;
+    }
+
+
+
+    /**
+     * The date the process was deployed.
+     * @hibernate.property
+     *    column="deploydate"
+     */
+    public Date getDeployDate() {
+        return _deployDate;
+    }
+
+    public void setDeployDate(Date deployDate) {
+        _deployDate = deployDate;
+    }
+
+    /**
+     * The type of the process (BPEL process definition name).
+     * @hibernate.property
+     *     column="type_name"
+     */
+    public String getTypeName() {
+        return _typeName;
+    }
+
+    public void setTypeName(String processName) {
+        _typeName = processName;
+    }
+
+    /**
+     * The type of the process (BPEL process definition name).
+     * @hibernate.property
+     *     column="type_ns"
+     */
+    public String getTypeNamespace() {
+        return _typeNamespace;
+    }
+
+    public void setTypeNamespace(String processName) {
+        _typeNamespace = processName;
+    }
+
+    /**
+     * The process version.
+     * @hibernate.property
+     *    column="version"
+     */
+    public int getVersion() {
+        return _version;
+    }
+
+    public void setVersion(int version) {
+        _version = version;
+    }
+
+    /**
+     * The process status.
+     * @hibernate.property
+     *    column="ACTIVE"
+     */
+    public boolean isActive() {
+        return _active;
+    }
+
+    public void setActive(boolean active) {
+        _active = active;
+    }
+
+}

Added: incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/hobj/HProcessProperty.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/hobj/HProcessProperty.java?view=auto&rev=469714
==============================================================================
--- incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/hobj/HProcessProperty.java (added)
+++ incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/hobj/HProcessProperty.java Tue Oct 31 16:05:42 2006
@@ -0,0 +1,90 @@
+package org.apache.ode.store.hobj;
+
+/**
+ * The property content is stored into a classic varchar if it's a simple type
+ * and into a CLOB if it's mixed (so one of the two will always be null).
+ * @hibernate.class table="BPEL_PROCESS_PROPERTY"
+ */
+public class HProcessProperty {
+
+    private Long _id;
+    private String _name;
+    private String _namespace;
+    private String _simpleContent;
+    private String _mixedContent;
+    private HProcessConf _process;
+
+    public HProcessProperty() {
+        super();
+    }
+
+    /**
+     * @hibernate.id generator-class="native" column="ID"
+     */
+    public Long getId() {
+        return _id;
+    }
+
+    public void setId(Long id) {
+        _id = id;
+    }
+
+    /**
+     * @hibernate.property column="PROPNAME"
+     */
+    public String getName() {
+        return _name;
+    }
+
+    public void setName(String name) {
+        _name = name;
+    }
+
+    /**
+     * @hibernate.property column="PROPNS"
+     */
+    public String getNamespace() {
+        return _namespace;
+    }
+
+    public void setNamespace(String namespace) {
+        _namespace = namespace;
+    }
+
+    /**
+     * @hibernate.property column="SIMPLE_CNT"
+     */
+    public String getSimpleContent() {
+        return _simpleContent;
+    }
+
+    public void setSimpleContent(String simpleContent) {
+        _simpleContent = simpleContent;
+    }
+
+    /**
+     * @hibernate.property
+     *  column="MIXED_CNT"
+     *  type="text"
+     *  length="1000000000"
+     */
+    public String getMixedContent() {
+        return _mixedContent;
+    }
+
+    public void setMixedContent(String mixedContent) {
+        _mixedContent = mixedContent;
+    }
+
+    /**
+     * @hibernate.many-to-one column="PROCESS_ID"
+     */
+    public HProcessConf getProcess() {
+        return _process;
+    }
+
+    public void setProcess(HProcessConf process) {
+        _process = process;
+    }
+
+}

Modified: incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/SessionManager.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/SessionManager.java?view=diff&rev=469714&r1=469713&r2=469714
==============================================================================
--- incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/SessionManager.java (original)
+++ incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/SessionManager.java Tue Oct 31 16:05:42 2006
@@ -21,7 +21,14 @@
 import org.apache.ode.daohib.bpel.hobj.*;
 import org.apache.ode.daohib.hobj.HLargeData;
 import org.apache.ode.utils.uuid.UUID;
+import org.hibernate.HibernateException;
+import org.hibernate.MappingException;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.Configuration;
 
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.Collections;
@@ -29,15 +36,6 @@
 import java.util.Map;
 import java.util.Properties;
 
-import javax.sql.DataSource;
-import javax.transaction.TransactionManager;
-
-import org.hibernate.HibernateException;
-import org.hibernate.MappingException;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.cfg.Configuration;
-
 /**
  * Manages hibernate sessions, and their association with 
  * a transaction thread.  Uses a ThreadLocal strategy for 
@@ -89,7 +87,6 @@
   public static final Configuration getDefaultConfiguration() throws MappingException {
     return new Configuration()
             .addClass(HProcess.class)
-            .addClass(HProcessProperty.class)
             .addClass(HProcessInstance.class)
             .addClass(HCorrelator.class)
             .addClass(HCorrelatorMessage.class)

Modified: incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/HibernateDao.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/HibernateDao.java?view=diff&rev=469714&r1=469713&r2=469714
==============================================================================
--- incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/HibernateDao.java (original)
+++ incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/HibernateDao.java Tue Oct 31 16:05:42 2006
@@ -18,17 +18,16 @@
  */
 package org.apache.ode.daohib.bpel;
 
-import java.io.Serializable;
-
-import org.hibernate.Session;
-
 import org.apache.ode.daohib.SessionManager;
 import org.apache.ode.daohib.hobj.HObject;
+import org.hibernate.Session;
+
+import java.io.Serializable;
 
 /**
  * Base class for our DAO objects.
  */
-abstract class HibernateDao {
+public abstract class HibernateDao {
   protected final SessionManager _sm;
   protected final HObject _hobj;
 

Modified: incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessDaoImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessDaoImpl.java?view=diff&rev=469714&r1=469713&r2=469714
==============================================================================
--- incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessDaoImpl.java (original)
+++ incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessDaoImpl.java Tue Oct 31 16:05:42 2006
@@ -20,28 +20,20 @@
 
 import org.apache.ode.bpel.common.CorrelationKey;
 import org.apache.ode.bpel.dao.CorrelatorDAO;
-import org.apache.ode.bpel.dao.PartnerLinkDAO;
 import org.apache.ode.bpel.dao.ProcessDAO;
 import org.apache.ode.bpel.dao.ProcessInstanceDAO;
-import org.apache.ode.bpel.dao.ProcessPropertyDAO;
 import org.apache.ode.daohib.SessionManager;
 import org.apache.ode.daohib.bpel.hobj.HCorrelationSet;
 import org.apache.ode.daohib.bpel.hobj.HCorrelator;
-import org.apache.ode.daohib.bpel.hobj.HPartnerLink;
 import org.apache.ode.daohib.bpel.hobj.HProcess;
 import org.apache.ode.daohib.bpel.hobj.HProcessInstance;
-import org.apache.ode.daohib.bpel.hobj.HProcessProperty;
-import org.apache.ode.daohib.hobj.HLargeData;
-import org.apache.ode.utils.DOMUtils;
 import org.hibernate.Criteria;
 import org.hibernate.Hibernate;
 import org.hibernate.Query;
 import org.hibernate.criterion.Expression;
 import org.hibernate.criterion.Order;
-import org.w3c.dom.Node;
 
 import javax.xml.namespace.QName;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
 import java.util.Iterator;
@@ -127,83 +119,10 @@
         // nothing to do here (yet?)
     }
 
-    /**
-     * @see org.apache.ode.bpel.dao.ProcessDAO#instanceCompleted(ProcessInstanceDAO)
-     */
-    public void setProperty(String name, String ns, Node content) {
-        setProperty(name, ns, DOMUtils.domToStringLevel2(content), false);
-    }
-    /**
-     * @see org.apache.ode.bpel.dao.ProcessDAO#instanceCompleted(ProcessInstanceDAO)
-     */
-    public void setProperty(String name, String ns, String content) {
-        setProperty(name, ns, content, true);
-    }
-
-    private void setProperty(String name, String ns, String content, boolean simple) {
-        HProcessProperty existingProperty = getProperty(name, ns);
-        if (existingProperty == null) {
-            HProcessProperty property = new HProcessProperty();
-            property.setName(name);
-            property.setNamespace(ns);
-            if (simple) property.setSimpleContent(content);
-            else property.setMixedContent(content);
-            _process.getProperties().add(property);
-            property.setProcess(_process);
-            getSession().save(property);
-        } else {
-            if (content == null) {
-                getSession().delete(existingProperty);
-                _process.getProperties().remove(existingProperty);
-            } else {
-                if (simple) existingProperty.setSimpleContent(content);
-                else existingProperty.setMixedContent(content);
-                getSession().save(existingProperty);
-            }
-        }
-    }
-
-    private HProcessProperty getProperty(String name, String ns) {
-        HProcessProperty existingProperty = null;
-        for (HProcessProperty hproperty : _process.getProperties()) {
-            if (hproperty.getName().equals(name) && hproperty.getNamespace().equals(ns))
-                existingProperty = hproperty;
-        }
-        return existingProperty;
-    }
-
-    /**
-     * @see org.apache.ode.bpel.dao.ProcessDAO#instanceCompleted(ProcessInstanceDAO)
-     */
-    public Collection<ProcessPropertyDAO> getProperties() {
-        ArrayList<ProcessPropertyDAO> propDAOs =
-                new ArrayList<ProcessPropertyDAO>(_process.getProperties().size());
-        for (HProcessProperty hproperty : _process.getProperties()) {
-            propDAOs.add(new ProcessPropertyDAOImpl(_sm, hproperty));
-        }
-        return propDAOs;
-    }
-
-    public Collection<PartnerLinkDAO> getDeployedEndpointReferences() {
-        ArrayList<PartnerLinkDAO> eprDAOs = new ArrayList<PartnerLinkDAO>(_process.getDeploymentPartnerLinks().size());
-        for (HPartnerLink hepr : _process.getDeploymentPartnerLinks()) {
-            eprDAOs.add(new PartnerLinkDAOImpl(_sm, hepr));
-        }
-        return eprDAOs;
-    }
-
     public void delete() {
         getSession().delete(_process);
     }
 
-    public String getDeployer() {
-        return _process.getDeployer();
-    }
-
-    public Date getDeployDate() {
-        return _process.getDeployDate();
-    }
-
     public QName getType() {
         return new QName(_process.getTypeNamespace(), _process.getTypeName());
     }
@@ -212,33 +131,6 @@
         return _process.getVersion();
     }
 
-    /**
-     * @see org.apache.ode.daohib.bpel.hobj.HProcess#isRetired()
-     */
-    public boolean isRetired() {
-        return _process.isRetired();
-    }
-
-    /**
-     * @see org.apache.ode.daohib.bpel.hobj.HProcess#setRetired(boolean)
-     */
-    public void setRetired(boolean retired) {
-        _process.setRetired(retired);
-        update();
-    }
-
-
-    public void setActive(boolean active) {
-        _process.setActive(active);
-        update();
-
-
-    }
-
-    public boolean isActive() {
-        return _process.isActive();
-    }
-
     public void addCorrelator(String corrid) {
         HCorrelator correlator = new HCorrelator();
         correlator.setCorrelatorId(corrid);
@@ -247,43 +139,6 @@
         _process.getCorrelators().add(correlator);
         getSession().save(correlator);
         getSession().saveOrUpdate(_process);
-    }
-
-    public void setCompiledProcess(byte[] cbp) {
-        if (_process.getCompiledProcess() != null)
-            getSession().delete(_process.getCompiledProcess());
-        HLargeData x = new HLargeData(cbp);
-        getSession().save(x);
-        _process.setCompiledProcess(x);
-    }
-
-    public byte[] getCompiledProcess() {
-        HLargeData x = _process.getCompiledProcess();
-        return x == null ? null : x.getBinary();
-    }
-
-    public PartnerLinkDAO getDeployedEndpointReference(int plinkModelId) {
-        Query q  = getSession().createFilter(_process.getDeploymentPartnerLinks(), QRY_EPR);
-        q.setInteger(0,plinkModelId);
-        HPartnerLink hepr = (HPartnerLink) q.uniqueResult();
-        if (hepr == null)
-            return null;
-        return new PartnerLinkDAOImpl(_sm,hepr);
-    }
-
-    public PartnerLinkDAO addDeployedPartnerLink(int plinkModelId, String plinkName,
-                                                 String myRoleName,
-                                                 String partnerRoleName) {
-        HPartnerLink hepr = new HPartnerLink();
-        hepr.setModelId(plinkModelId);
-        hepr.setLinkName(plinkName);
-        hepr.setMyRole(myRoleName);
-        hepr.setPartnerRole(partnerRoleName);
-        hepr.setProcess(_process);
-        _process.getDeploymentPartnerLinks().add(hepr);
-        getSession().save(hepr);
-        update();
-        return new PartnerLinkDAOImpl(_sm,hepr);
     }
 
 	public int getNumInstances() {

Modified: incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HProcess.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HProcess.java?view=diff&rev=469714&r1=469713&r2=469714
==============================================================================
--- incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HProcess.java (original)
+++ incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HProcess.java Tue Oct 31 16:05:42 2006
@@ -39,9 +39,6 @@
     /** Instances of this BPEL process. */
     private Collection<HProcessInstance> _instances = new HashSet<HProcessInstance>();
 
-    /** {@link HProcessProperty}s for this process. */
-    private Set<HProcessProperty> _properties = new HashSet<HProcessProperty>();
-
     /** Events belonging to this BPEL process. */
     private Collection<HBpelEvent> _events = new HashSet<HBpelEvent>();
 
@@ -131,24 +128,6 @@
     }
 
     /**
-     * @hibernate.set
-     *  lazy="true"
-     *  inverse="true"
-     *  cascade="delete"
-     * @hibernate.collection-key
-     *  column="PROCESS_ID"
-     * @hibernate.collection-one-to-many
-     *   class="org.apache.ode.daohib.bpel.hobj.HProcessProperty"
-     */
-    public Set<HProcessProperty> getProperties() {
-        return _properties;
-    }
-
-    public void setProperties(Set<HProcessProperty> properties) {
-        _properties = properties;
-    }
-
-    /**
      * @hibernate.bag
      *  lazy="true"
      *  inverse="true"
@@ -294,15 +273,6 @@
 
     public void setActive(boolean active) {
         _active = active;
-    }
-
-    /** @hibernate.many-to-one column="CBP" */
-    public HLargeData getCompiledProcess() {
-        return _compiledProcess;
-    }
-
-    public void setCompiledProcess(HLargeData compiledProcess) {
-        _compiledProcess = compiledProcess;
     }
 
 }

Modified: incubator/ode/trunk/jbi/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/jbi/pom.xml?view=diff&rev=469714&r1=469713&r2=469714
==============================================================================
--- incubator/ode/trunk/jbi/pom.xml (original)
+++ incubator/ode/trunk/jbi/pom.xml Tue Oct 31 16:05:42 2006
@@ -60,6 +60,10 @@
 			<groupId>org.apache.derby</groupId>
 			<artifactId>derby</artifactId>
 		</dependency>
+        <dependency>
+            <groupId>org.apache.ode</groupId>
+            <artifactId>ode-bpel-store</artifactId>
+        </dependency>
 
         <!-- The following dependencies are "provided" to avoid classloading issues in ServiceMix -->
 		<dependency>

Modified: incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/BindingContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/BindingContextImpl.java?view=diff&rev=469714&r1=469713&r2=469714
==============================================================================
--- incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/BindingContextImpl.java (original)
+++ incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/BindingContextImpl.java Tue Oct 31 16:05:42 2006
@@ -18,19 +18,14 @@
  */
 package org.apache.ode.jbi;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.iapi.*;
+
 import javax.jbi.servicedesc.ServiceEndpoint;
 import javax.wsdl.PortType;
 import javax.xml.namespace.QName;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.iapi.BindingContext;
-import org.apache.ode.bpel.iapi.ContextException;
-import org.apache.ode.bpel.iapi.DeploymentUnit;
-import org.apache.ode.bpel.iapi.Endpoint;
-import org.apache.ode.bpel.iapi.EndpointReference;
-import org.apache.ode.bpel.iapi.PartnerRoleChannel;
-
 /**
  * JBI Implementation of ODE's {@link org.apache.ode.bpel.iapi.BindingContext}
  * interface.
@@ -47,7 +42,7 @@
         _ode = ode;
     }
 
-    public EndpointReference activateMyRoleEndpoint(QName processId, DeploymentUnit deploymentUnit, Endpoint myRoleEndpoint,
+    public EndpointReference activateMyRoleEndpoint(QName processId, Endpoint myRoleEndpoint,
             PortType portType) {
         try {
             return _ode.activateEndpoint(processId, myRoleEndpoint);
@@ -67,8 +62,8 @@
         }
     }
 
-    public PartnerRoleChannel createPartnerRoleChannel(QName processId, DeploymentUnit deploymentUnit,
-            PortType portType, Endpoint initialPartnerEndpoint) {
+    public PartnerRoleChannel createPartnerRoleChannel(QName processId, PortType portType,
+            Endpoint initialPartnerEndpoint) {
         
         if (initialPartnerEndpoint != null) {
             ServiceEndpoint se = _ode.getContext().getEndpoint(initialPartnerEndpoint.serviceName,initialPartnerEndpoint.portName);