You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by je...@apache.org on 2010/05/21 17:41:07 UTC

svn commit: r947046 [10/12] - in /ode/trunk: ./ axis2/src/main/java/org/apache/ode/axis2/ bpel-dao/ bpel-dao/src/main/java/org/apache/ode/dao/ bpel-dao/src/main/java/org/apache/ode/dao/bpel/ bpel-dao/src/main/java/org/apache/ode/dao/store/ bpel-epr/ bp...

Added: ode/trunk/dao-jpa-hibernate/src/main/files/hibernate.cfg/hsql.properties
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-hibernate/src/main/files/hibernate.cfg/hsql.properties?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-hibernate/src/main/files/hibernate.cfg/hsql.properties (added)
+++ ode/trunk/dao-jpa-hibernate/src/main/files/hibernate.cfg/hsql.properties Fri May 21 15:40:59 2010
@@ -0,0 +1 @@
+dialect=org.hibernate.dialect.HSQLDialect
\ No newline at end of file

Added: ode/trunk/dao-jpa-hibernate/src/main/files/hibernate.cfg/mysql.properties
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-hibernate/src/main/files/hibernate.cfg/mysql.properties?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-hibernate/src/main/files/hibernate.cfg/mysql.properties (added)
+++ ode/trunk/dao-jpa-hibernate/src/main/files/hibernate.cfg/mysql.properties Fri May 21 15:40:59 2010
@@ -0,0 +1 @@
+dialect=org.hibernate.dialect.MySQLInnoDBDialect
\ No newline at end of file

Added: ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/BpelDAOConnectionFactoryImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/BpelDAOConnectionFactoryImpl.java?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/BpelDAOConnectionFactoryImpl.java (added)
+++ ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/BpelDAOConnectionFactoryImpl.java Fri May 21 15:40:59 2010
@@ -0,0 +1,191 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ode.dao.jpa.hibernate;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.BpelDAOConnectionFactory;
+import org.apache.ode.dao.jpa.JpaConnection;
+import org.apache.ode.dao.jpa.JpaOperator;
+import org.apache.ode.dao.jpa.bpel.BpelDAOConnectionImpl;
+import org.apache.ode.il.config.OdeConfigProperties;
+import org.apache.ode.utils.GUID;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.resolver.DialectFactory;
+import org.hibernate.ejb.EntityManagerImpl;
+
+/**
+
+ */
+public class BpelDAOConnectionFactoryImpl implements BpelDAOConnectionFactory {
+
+    static final Log __log = LogFactory.getLog(BpelDAOConnectionFactoryImpl.class);
+    static Map _defaultProperties = new HashMap();
+    static JpaOperator _operator = new JpaOperatorImpl();
+    EntityManagerFactory _emf;
+    TransactionManager _txm;
+    DataSource _ds;
+
+    static {
+        _defaultProperties.put("javax.persistence.provider", "org.hibernate.ejb.HibernatePersistence");
+    }
+
+    public void init(Properties odeConfig, TransactionManager txm, Object env) {
+        this._txm = txm;
+        this._ds = (DataSource) env;
+        Map emfProperties = buildConfig(OdeConfigProperties.PROP_DAOCF + ".", odeConfig, _txm, _ds);
+        _emf = Persistence.createEntityManagerFactory("ode-bpel", emfProperties);
+
+    }
+
+    public BpelDAOConnection getConnection() {
+        final ThreadLocal<BpelDAOConnectionImpl> currentConnection = BpelDAOConnectionImpl.getThreadLocal();
+
+        BpelDAOConnectionImpl conn = (BpelDAOConnectionImpl) currentConnection.get();
+        if (conn != null && isOpen(conn)) {
+            return conn;
+        } else {
+            EntityManager em = _emf.createEntityManager();
+            conn = new BpelDAOConnectionImpl(em, _txm, _operator);
+            currentConnection.set(conn);
+            return conn;
+        }
+    }
+
+    public void shutdown() {
+        _emf.close();
+    }
+
+    static Map buildConfig(String prefix, Properties odeConfig, TransactionManager txm, DataSource ds) {
+        Map props = new HashMap(_defaultProperties);
+
+        String guid = new GUID().toString();
+        if (ds != null) {
+            props.put(Environment.CONNECTION_PROVIDER, DataSourceConnectionProvider.class.getName());
+            HibernateUtil.registerDatasource(guid, ds);
+            props.put(Environment.DIALECT, guessDialect(ds));
+        }
+        if (txm != null) {
+            props.put(Environment.CURRENT_SESSION_CONTEXT_CLASS, "jta");
+            props.put(Environment.TRANSACTION_MANAGER_STRATEGY, HibernateTransactionManagerLookup.class.getName());
+            HibernateUtil.registerTransactionManager(guid, txm);
+            props.put("javax.persistence.transactionType", "JTA");
+        } else {
+            props.put("javax.persistence.transactionType", "RESOURCE_LOCAL");
+        }
+
+
+        if (ds != null || txm != null) {
+            props.put(HibernateUtil.PROP_GUID, guid);
+        }
+
+        if (Boolean.valueOf(odeConfig.getProperty(OdeConfigProperties.PROP_DB_EMBEDDED_CREATE, "true"))) {
+            props.put(Environment.HBM2DDL_AUTO, "create-drop");
+        }
+
+        // Isolation levels override; when you use a ConnectionProvider, this has no effect
+        //String level = System.getProperty("ode.connection.isolation", "2");
+        //props.put(Environment.ISOLATION, level);
+
+        addEntries(prefix, odeConfig, props);
+
+        return props;
+    }
+
+    public static void addEntries(String prefix, Properties odeConfig, Map props) {
+        if (odeConfig != null) {
+            for (Map.Entry me : odeConfig.entrySet()) {
+                String key = (String) me.getKey();
+                if (key.startsWith(prefix)) {
+                    String jpaKey = key.substring(prefix.length() - 1);
+                    String val = (String) me.getValue();
+                    if (val == null || val.trim().length() == 0) {
+                        props.remove(jpaKey);
+                    } else {
+                        props.put(jpaKey, me.getValue());
+                    }
+                }
+            }
+        }
+    }
+
+    /*
+     * For some reason Hibernate does not mark an EntityManager as being closed when
+     * the EntityManagerFactory that created it is closed. This method performs a
+     * deep introspection to determine if the EntityManager is still viable.
+     */
+    public static boolean isOpen(JpaConnection conn) {
+        EntityManager mgr = conn.getEntityManager();
+        if (mgr == null) {
+            return false;
+        } else if (mgr instanceof EntityManagerImpl) {
+            EntityManagerImpl mgrImpl = (EntityManagerImpl) mgr;
+            return !mgrImpl.getSession().getSessionFactory().isClosed();
+        } else {
+            return !conn.isClosed();
+        }
+    }
+    private static final String DEFAULT_HIBERNATE_DIALECT = "org.hibernate.dialect.DerbyDialect";
+    
+    public static String guessDialect(DataSource dataSource) {
+
+        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 = null;
+        try {
+            conn = dataSource.getConnection();
+            Dialect d = DialectFactory.buildDialect(new Properties(), conn);
+            dialect = d.getClass().getName();
+        } catch (SQLException se) {
+            __log.error(se);
+        } finally {
+            try {
+                conn.close();
+            } catch (SQLException ex) {
+                __log.error(ex);
+            }
+        }
+
+        if (dialect == null) {
+            __log.info("Cannot determine hibernate dialect for this database: using the default one.");
+            dialect = DEFAULT_HIBERNATE_DIALECT;
+        }
+
+        return dialect;
+
+    }    
+
+}
+

Added: ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/ConfStoreDAOConnectionFactoryImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/ConfStoreDAOConnectionFactoryImpl.java?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/ConfStoreDAOConnectionFactoryImpl.java (added)
+++ ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/ConfStoreDAOConnectionFactoryImpl.java Fri May 21 15:40:59 2010
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ode.dao.jpa.hibernate;
+
+import java.util.Map;
+import java.util.Properties;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.dao.jpa.store.ConfStoreDAOConnectionImpl;
+import org.apache.ode.il.config.OdeConfigProperties;
+import org.apache.ode.dao.store.ConfStoreDAOConnection;
+import org.apache.ode.dao.store.ConfStoreDAOConnectionFactory;
+import static org.apache.ode.dao.jpa.hibernate.BpelDAOConnectionFactoryImpl.isOpen;
+import static org.apache.ode.dao.jpa.hibernate.BpelDAOConnectionFactoryImpl._operator;
+import static org.apache.ode.dao.jpa.hibernate.BpelDAOConnectionFactoryImpl.buildConfig;
+/**
+
+ */
+public class ConfStoreDAOConnectionFactoryImpl implements ConfStoreDAOConnectionFactory {
+  
+  static final Log __log = LogFactory.getLog(ConfStoreDAOConnectionFactoryImpl.class);
+  EntityManagerFactory _emf;
+     TransactionManager _txm;
+    DataSource _ds;
+
+
+  public void init(Properties odeConfig,TransactionManager txm, Object env) {
+     this._txm = txm;
+        this._ds = (DataSource) env;
+    Map emfProperties = buildConfig(OdeConfigProperties.PROP_DAOCF + ".", odeConfig, _txm, _ds);
+    _emf = Persistence.createEntityManagerFactory("ode-store", emfProperties);
+
+  }
+
+  public ConfStoreDAOConnection getConnection() {
+    final ThreadLocal<ConfStoreDAOConnectionImpl> currentConnection = ConfStoreDAOConnectionImpl.getThreadLocal();
+
+    ConfStoreDAOConnectionImpl conn = (ConfStoreDAOConnectionImpl)currentConnection.get();
+    if (conn != null && isOpen(conn)) {
+      return conn;
+    } else {
+      EntityManager em = _emf.createEntityManager();
+      conn = new ConfStoreDAOConnectionImpl(em, _txm, _operator);
+      currentConnection.set(conn);
+      return conn;
+    }
+  }
+
+   public void shutdown() {
+    _emf.close();
+  }
+}

Added: ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/DataSourceConnectionProvider.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/DataSourceConnectionProvider.java?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/DataSourceConnectionProvider.java (added)
+++ ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/DataSourceConnectionProvider.java Fri May 21 15:40:59 2010
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.ode.dao.jpa.hibernate;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Properties;
+
+import org.apache.ode.utils.DbIsolation;
+
+import org.hibernate.HibernateException;
+import org.hibernate.connection.ConnectionProvider;
+
+
+public class DataSourceConnectionProvider implements ConnectionProvider {
+
+  private Properties _props;
+  
+  public DataSourceConnectionProvider() {
+  }
+  
+  public void configure(Properties props) throws HibernateException {
+    _props = props;
+  }
+
+  public Connection getConnection() throws SQLException {
+    Connection c = HibernateUtil.getConnection(_props);
+    DbIsolation.setIsolationLevel(c);
+    return c;
+  }
+
+  public void closeConnection(Connection con) throws SQLException {
+    con.close();
+  }
+
+  public void close() throws HibernateException {
+
+  }
+
+  public boolean supportsAggressiveRelease() {
+    return true;
+  }
+
+}

Added: ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/HibernateTransactionManagerLookup.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/HibernateTransactionManagerLookup.java?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/HibernateTransactionManagerLookup.java (added)
+++ ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/HibernateTransactionManagerLookup.java Fri May 21 15:40:59 2010
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ode.dao.jpa.hibernate;
+
+import java.util.Properties;
+
+import javax.transaction.TransactionManager;
+import javax.transaction.Transaction;
+
+import org.hibernate.HibernateException;
+import org.hibernate.transaction.TransactionManagerLookup;
+
+/**
+ * Implementation of the {@link org.hibernate.transaction.TransactionManagerLookup} interface that
+ * uses {@link HibernateUtil} to obtain the JTA {@link TransactionManager} object.
+ */
+public class HibernateTransactionManagerLookup implements TransactionManagerLookup {
+
+	/** Constructor. */
+	public HibernateTransactionManagerLookup() {
+		super();
+	}
+
+	public TransactionManager getTransactionManager(Properties props)
+			throws HibernateException {
+		return HibernateUtil.getTransactionManager(props);
+	}
+
+	public String getUserTransactionName() {
+		return null;
+	}
+
+    public Object getTransactionIdentifier(Transaction transaction) {
+        return transaction;
+    }
+}

Added: ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/HibernateUtil.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/HibernateUtil.java?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/HibernateUtil.java (added)
+++ ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/HibernateUtil.java Fri May 21 15:40:59 2010
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ode.dao.jpa.hibernate;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+
+/**
+ * Manages datasource and transaction, for hibernate usage.
+ * 
+ */
+public class HibernateUtil {
+	
+
+    public static final String PROP_GUID = "ode.hibernate.guid";
+
+    private static final Map<String, TransactionManager> _txManagers =
+            Collections.synchronizedMap(new HashMap<String, TransactionManager>());
+    private static final Map<String, DataSource> _dataSources =
+            Collections.synchronizedMap(new HashMap<String,DataSource>());
+
+    private static final String[] CANNOT_JOIN_FOR_UPDATE_DIALECTS =
+            {"org.hibernate.dialect.IngresDialect"};
+
+    private final TransactionManager _txManager = null;
+
+
+    TransactionManager getTransactionManager() {
+        return _txManager;
+    }
+
+    public static void registerTransactionManager(String uuid, TransactionManager txm) {
+        _txManagers.put(uuid, txm);
+    }
+    
+    public static void registerDatasource(String uuid, DataSource ds){
+    	_dataSources.put(uuid, ds);
+    }
+
+
+    public static TransactionManager getTransactionManager(Properties props) {
+        String guid = props.getProperty(PROP_GUID);
+        return _txManagers.get(guid);
+    }
+
+    public static Connection getConnection(Properties props) throws SQLException {
+        String guid = props.getProperty(PROP_GUID);
+        return _dataSources.get(guid).getConnection();
+    }
+}

Added: ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/JpaOperatorImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/JpaOperatorImpl.java?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/JpaOperatorImpl.java (added)
+++ ode/trunk/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/JpaOperatorImpl.java Fri May 21 15:40:59 2010
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ode.dao.jpa.hibernate;
+
+import java.util.Iterator;
+
+import javax.persistence.Query;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.dao.jpa.JpaOperator;
+
+/**
+ * 
+ * @author Jeff Yu
+ */
+public class JpaOperatorImpl implements JpaOperator {
+
+    private static final Log __log = LogFactory.getLog(JpaOperatorImpl.class);
+
+    public <T> void batchUpdateByIds(Iterator<T> ids, Query query, String parameterName) {
+        while (ids.hasNext()) {
+            query.setParameter(parameterName, ids.next());
+            query.executeUpdate();
+        }
+    }
+
+    public void setBatchSize(Query query, int limit) {
+        //TODO
+    }
+}

Added: ode/trunk/dao-jpa-hibernate/src/main/scripts/license-header.sql
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-hibernate/src/main/scripts/license-header.sql?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-hibernate/src/main/scripts/license-header.sql (added)
+++ ode/trunk/dao-jpa-hibernate/src/main/scripts/license-header.sql Fri May 21 15:40:59 2010
@@ -0,0 +1,19 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--    http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied.  See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+--
+ 

Added: ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-derby.sql
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-derby.sql?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-derby.sql (added)
+++ ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-derby.sql Fri May 21 15:40:59 2010
@@ -0,0 +1,30 @@
+-- Apache ODE - SimpleScheduler Database Schema
+-- 
+-- Apache Derby scripts by Maciej Szefler.
+-- 
+-- 
+
+CREATE TABLE ode_job (
+  jobid CHAR(64)  NOT NULL DEFAULT '',
+  ts BIGINT  NOT NULL DEFAULT 0,
+  nodeid char(64),
+  scheduled int  NOT NULL DEFAULT 0,
+  transacted int  NOT NULL DEFAULT 0,
+
+  instanceId BIGINT,
+  mexId varchar(255),
+  processId varchar(255),
+  type varchar(255),
+  channel varchar(255),
+  correlatorId varchar(255),
+  correlationKey varchar(255),
+  retryCount int,
+  inMem int,
+  detailsExt blob(4096),
+
+  PRIMARY KEY(jobid));
+
+CREATE INDEX IDX_ODE_JOB_TS ON ode_job(ts);
+CREATE INDEX IDX_ODE_JOB_NODEID ON ode_job(nodeid);
+
+

Added: ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-mysql.sql
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-mysql.sql?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-mysql.sql (added)
+++ ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-mysql.sql Fri May 21 15:40:59 2010
@@ -0,0 +1,33 @@
+-- Apache ODE - SimpleScheduler Database Schema
+-- 
+-- MySQL scripts by Maciej Szefler.
+-- 
+-- 
+DROP TABLE IF EXISTS ODE_JOB;
+
+CREATE TABLE ODE_JOB (
+  jobid CHAR(64)  NOT NULL DEFAULT '',
+  ts BIGINT  NOT NULL DEFAULT 0,
+  nodeid char(64)  NULL,
+  scheduled int  NOT NULL DEFAULT 0,
+  transacted int  NOT NULL DEFAULT 0,
+
+  instanceId BIGINT,
+  mexId varchar(255),
+  processId varchar(255),
+  type varchar(255),
+  channel varchar(255),
+  correlatorId varchar(255),
+  correlationKey varchar(255),
+  retryCount int,
+  inMem int,
+  detailsExt blob(4096),
+
+  PRIMARY KEY(jobid),
+  INDEX IDX_ODE_JOB_TS(ts),
+  INDEX IDX_ODE_JOB_NODEID(nodeid)
+)
+TYPE=InnoDB;
+
+COMMIT;
+

Added: ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-oracle.sql
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-oracle.sql?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-oracle.sql (added)
+++ ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-oracle.sql Fri May 21 15:40:59 2010
@@ -0,0 +1,32 @@
+-- Apache ODE - SimpleScheduler Database Schema
+-- 
+-- Apache Derby scripts by Maciej Szefler.
+-- 
+-- 
+
+DROP TABLE ode_job;
+
+CREATE TABLE ode_job (
+  jobid VARCHAR(64)  NOT NULL,
+  ts number(37)  NOT NULL,
+  nodeid varchar(64),
+  scheduled int  NOT NULL,
+  transacted int  NOT NULL,
+  
+  instanceId number(37),
+  mexId varchar(255),
+  processId varchar(255),
+  type varchar(255),
+  channel varchar(255),
+  correlatorId varchar(255),
+  correlationKey varchar(255),
+  retryCount int,
+  inMem int,
+  detailsExt blob,
+
+  PRIMARY KEY(jobid));
+
+CREATE INDEX IDX_ODE_JOB_TS ON ode_job(ts);
+CREATE INDEX IDX_ODE_JOB_NODEID ON ode_job(nodeid);
+
+

Added: ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-postgres.sql
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-postgres.sql?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-postgres.sql (added)
+++ ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-postgres.sql Fri May 21 15:40:59 2010
@@ -0,0 +1,30 @@
+-- Apache ODE - SimpleScheduler Database Schema
+-- 
+-- Apache Derby scripts by Maciej Szefler.
+-- 
+-- 
+
+CREATE TABLE ode_job (
+  jobid CHAR(64)  NOT NULL DEFAULT '',
+  ts BIGINT  NOT NULL DEFAULT 0,
+  nodeid char(64),
+  scheduled int  NOT NULL DEFAULT 0,
+  transacted int  NOT NULL DEFAULT 0,
+
+  instanceId BIGINT,
+  mexId varchar(255),
+  processId varchar(255),
+  type varchar(255),
+  channel varchar(255),
+  correlatorId varchar(255),
+  correlationKey varchar(255),
+  retryCount int,
+  inMem int,
+  detailsExt bytea,
+
+  PRIMARY KEY(jobid));
+
+CREATE INDEX IDX_ODE_JOB_TS ON ode_job(ts);
+CREATE INDEX IDX_ODE_JOB_NODEID ON ode_job(nodeid);
+
+

Added: ode/trunk/dao-jpa-ojpa/pom.xml
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/pom.xml?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/pom.xml (added)
+++ ode/trunk/dao-jpa-ojpa/pom.xml Fri May 21 15:40:59 2010
@@ -0,0 +1,82 @@
+<?xml version="1.0"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~    http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+-->
+<project xmlns:pom="http://maven.apache.org/POM/4.0.0">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.ode</groupId>
+  <artifactId>ode-dao-jpa-ojpa</artifactId>
+  <name>ODE :: JPA OpenJPA DAO Impl</name>
+
+  <parent>
+    <groupId>org.apache.ode</groupId>
+    <artifactId>ode</artifactId>
+    <version>1.3.5-SNAPSHOT</version>
+  </parent>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.ode</groupId>
+      <artifactId>ode-bpel-schemas</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.ode</groupId>
+      <artifactId>ode-bpel-epr</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.ode</groupId>
+      <artifactId>ode-dao-jpa</artifactId>
+      <classifier>openjpa</classifier>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-jta_1.1_spec</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>javax.persistence</groupId>
+      <artifactId>persistence-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>xerces</groupId>
+      <artifactId>xercesImpl</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>xerces</groupId>
+      <artifactId>xmlParserAPIs</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.openjpa</groupId>
+      <artifactId>openjpa</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>net.sourceforge.serp</groupId>
+      <artifactId>serp</artifactId>
+    </dependency>
+  </dependencies>
+
+</project>
+

Added: ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.derby.xml
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.derby.xml?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.derby.xml (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.derby.xml Fri May 21 15:40:59 2010
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~    http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
+    <persistence-unit name="ode-unit-test-embedded">
+        <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+        <class>org.apache.ode.dao.jpa.ActivityRecoveryDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.CorrelationSetDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.CorrelatorDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.EventDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.FaultDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.MessageDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.MessageExchangeDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.MessageRouteDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.PartnerLinkDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.ProcessDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.ProcessInstanceDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.ResourceRouteDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.ScopeDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.XmlDataDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.ContextValueDAOImpl</class>
+        
+        <class>org.apache.ode.store.jpa.ProcessConfDaoImpl</class>
+        <class>org.apache.ode.store.jpa.ProcessConfPropertyDaoImpl</class>
+        <class>org.apache.ode.store.jpa.DeploymentUnitDaoImpl</class>
+        <class>org.apache.ode.store.jpa.VersionTrackerDAOImpl</class>
+
+        <properties>
+            <!-- Properties for an embedded Derby connection -->
+            <property name="openjpa.ConnectionDriverName" value="org.apache.commons.dbcp.BasicDataSource"/>
+            <property name="openjpa.jdbc.DBDictionary" value="org.apache.openjpa.jdbc.sql.DerbyDictionary"/>
+            <!-- To validate DBSchema and create DDL at runtime - use this property. Currently the DDL is created at build time -->
+            <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+
+            <property name="openjpa.ConnectionProperties"
+                      value="DriverClassName=org.apache.derby.jdbc.EmbeddedDriver,Url=jdbc:derby:target/database/openjpa-test-database;create=true,MaxActive=100,MaxWait=10000,TestOnBorrow=true"/>
+
+        </properties>
+    </persistence-unit>
+</persistence>
+

Added: ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.mysql.xml
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.mysql.xml?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.mysql.xml (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.mysql.xml Fri May 21 15:40:59 2010
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~    http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
+    <persistence-unit name="ode-unit-test-embedded">
+        <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+        <class>org.apache.ode.dao.jpa.ActivityRecoveryDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.CorrelationSetDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.CorrelatorDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.EventDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.FaultDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.MessageDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.MessageExchangeDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.MessageRouteDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.PartnerLinkDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.ProcessDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.ProcessInstanceDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.ResourceRouteDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.ScopeDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.XmlDataDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.ContextValueDAOImpl</class>
+        
+        <class>org.apache.ode.store.jpa.ProcessConfDaoImpl</class>
+        <class>org.apache.ode.store.jpa.ProcessConfPropertyDaoImpl</class>
+        <class>org.apache.ode.store.jpa.DeploymentUnitDaoImpl</class>
+        <class>org.apache.ode.store.jpa.VersionTrackerDAOImpl</class>
+
+        <properties>
+            <!-- Properties for an embedded Derby connection -->
+            <property name="openjpa.ConnectionDriverName" value="org.apache.commons.dbcp.BasicDataSource"/>
+            <property name="openjpa.jdbc.DBDictionary" value="org.apache.openjpa.jdbc.sql.MySQLDictionary"/>
+            <!-- To validate DBSchema and create DDL at runtime - use this property. Currently the DDL is created at build time -->
+            <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+
+            <property name="openjpa.ConnectionProperties"
+                      value="DriverClassName=org.apache.derby.jdbc.EmbeddedDriver,Url=jdbc:derby:target/database/openjpa-test-database;create=true,MaxActive=100,MaxWait=10000,TestOnBorrow=true"/>
+
+        </properties>
+    </persistence-unit>
+</persistence>
+

Added: ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.oracle.xml
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.oracle.xml?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.oracle.xml (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.oracle.xml Fri May 21 15:40:59 2010
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~    http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
+    <persistence-unit name="ode-unit-test-embedded">
+        <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+        <class>org.apache.ode.dao.jpa.ActivityRecoveryDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.CorrelationSetDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.CorrelatorDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.EventDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.FaultDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.MessageDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.MessageExchangeDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.MessageRouteDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.PartnerLinkDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.ProcessDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.ProcessInstanceDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.ResourceRouteDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.ScopeDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.XmlDataDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.ContextValueDAOImpl</class>
+
+        <class>org.apache.ode.store.jpa.ProcessConfDaoImpl</class>
+        <class>org.apache.ode.store.jpa.ProcessConfPropertyDaoImpl</class>
+        <class>org.apache.ode.store.jpa.DeploymentUnitDaoImpl</class>
+        <class>org.apache.ode.store.jpa.VersionTrackerDAOImpl</class>
+
+        <properties>
+            <!-- Properties for an embedded Derby connection -->
+            <property name="openjpa.ConnectionDriverName" value="org.apache.commons.dbcp.BasicDataSource"/>
+            <property name="openjpa.jdbc.DBDictionary" value="org.apache.openjpa.jdbc.sql.OracleDictionary"/>
+            <!-- To validate DBSchema and create DDL at runtime - use this property. Currently the DDL is created at build time -->
+            <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+
+            <property name="openjpa.ConnectionProperties"
+                      value="DriverClassName=org.apache.derby.jdbc.EmbeddedDriver,Url=jdbc:derby:target/database/openjpa-test-database;create=true,MaxActive=100,MaxWait=10000,TestOnBorrow=true"/>
+
+        </properties>
+    </persistence-unit>
+</persistence>
+

Added: ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.postgres.xml
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.postgres.xml?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.postgres.xml (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.postgres.xml Fri May 21 15:40:59 2010
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~    http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
+    <persistence-unit name="ode-unit-test-embedded">
+        <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+        <class>org.apache.ode.dao.jpa.ActivityRecoveryDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.CorrelationSetDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.CorrelatorDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.EventDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.FaultDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.MessageDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.MessageExchangeDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.MessageRouteDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.PartnerLinkDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.ProcessDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.ProcessInstanceDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.ResourceRouteDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.ScopeDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.XmlDataDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.ContextValueDAOImpl</class>
+
+        <class>org.apache.ode.store.jpa.ProcessConfDaoImpl</class>
+        <class>org.apache.ode.store.jpa.ProcessConfPropertyDaoImpl</class>
+        <class>org.apache.ode.store.jpa.DeploymentUnitDaoImpl</class>
+        <class>org.apache.ode.store.jpa.VersionTrackerDAOImpl</class>
+
+        <properties>
+            <!-- Properties for an embedded Derby connection -->
+            <property name="openjpa.ConnectionDriverName" value="org.apache.commons.dbcp.BasicDataSource"/>
+            <property name="openjpa.jdbc.DBDictionary" value="org.apache.openjpa.jdbc.sql.PostgresDictionary"/>
+            <!-- To validate DBSchema and create DDL at runtime - use this property. Currently the DDL is created at build time -->
+            <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+
+            <property name="openjpa.ConnectionProperties"
+                      value="DriverClassName=org.apache.derby.jdbc.EmbeddedDriver,Url=jdbc:derby:target/database/openjpa-test-database;create=true,MaxActive=100,MaxWait=10000,TestOnBorrow=true"/>
+
+        </properties>
+    </persistence-unit>
+</persistence>
+

Added: ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/BpelDAOConnectionFactoryImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/BpelDAOConnectionFactoryImpl.java?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/BpelDAOConnectionFactoryImpl.java (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/BpelDAOConnectionFactoryImpl.java Fri May 21 15:40:59 2010
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ode.dao.jpa.openjpa;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.BpelDAOConnectionFactory;
+import org.apache.ode.dao.jpa.JpaOperator;
+import org.apache.ode.dao.jpa.bpel.BpelDAOConnectionImpl;
+import org.apache.ode.il.config.OdeConfigProperties;
+
+/**
+
+ */
+public class BpelDAOConnectionFactoryImpl implements BpelDAOConnectionFactory {
+
+    static final Log __log = LogFactory.getLog(BpelDAOConnectionFactoryImpl.class);
+    static Map _defaultProperties = new HashMap();
+    static JpaOperator _operator = new JpaOperatorImpl();
+    protected EntityManagerFactory _emf;
+    protected DataSource _ds;
+    protected TransactionManager _txm;
+
+    static {
+        _defaultProperties.put("javax.persistence.provider", "org.apache.openjpa.persistence.PersistenceProviderImpl");
+        _defaultProperties.put("openjpa.Log", "log4j");
+        //This was previously set to fault but caused some issues with in memory CorrelatorDAO rout finds.
+        _defaultProperties.put("openjpa.FlushBeforeQueries", "true");
+        _defaultProperties.put("openjpa.FetchBatchSize", 1000);
+
+        // _defaultProperties.put("openjpa.Log", "DefaultLevel=TRACE");
+    }
+
+    public void init(Properties odeConfig, TransactionManager mgr, Object env) {
+        _txm = mgr;
+        _ds = (DataSource) env;
+        Map emfProperties = buildConfig(OdeConfigProperties.PROP_DAOCF + ".", odeConfig, _txm, _ds);
+        _emf = Persistence.createEntityManagerFactory("ode-bpel", emfProperties);
+    }
+
+    public BpelDAOConnection getConnection() {
+        final ThreadLocal<BpelDAOConnectionImpl> currentConnection = BpelDAOConnectionImpl.getThreadLocal();
+        BpelDAOConnectionImpl conn = (BpelDAOConnectionImpl) currentConnection.get();
+        if (conn != null && !conn.isClosed()) {
+            return conn;
+        } else {
+            EntityManager em = _emf.createEntityManager();
+            conn = createBPELDAOConnection(em, _txm, _operator);
+            currentConnection.set(conn);
+            return conn;
+        }
+    }
+
+    protected BpelDAOConnectionImpl createBPELDAOConnection(EntityManager em, TransactionManager mgr, JpaOperator operator) {
+        return new BpelDAOConnectionImpl(em, mgr, operator);
+    }
+
+    public void shutdown() {
+        _emf.close();
+    }
+
+    static Map buildConfig(String prefix, Properties odeConfig, TransactionManager mgr, DataSource ds) {
+        Map props = new HashMap(_defaultProperties);
+        if (mgr != null) {
+            props.put("openjpa.TransactionMode","managed");
+            /* The following was originally set to managed but rollback tests failed.
+             * There is no code in ODE to automatically enlist  DataSource s in
+             * global transactions
+             */
+            props.put("openjpa.ConnectionFactoryMode", "local");
+            props.put("openjpa.jdbc.TransactionIsolation", "read-committed");
+            props.put("openjpa.ManagedRuntime", new JpaTxMgrProvider(mgr));
+            props.put("javax.persistence.transactionType", "JTA");
+        } else {
+            props.put("javax.persistence.transactionType", "RESOURCE_LOCAL");
+        }
+        if (ds != null) {
+            props.put("openjpa.ConnectionFactory", ds);
+        }
+
+        //props.put("openjpa.jdbc.DBDictionary", dictionary);
+
+        if (Boolean.valueOf(odeConfig.getProperty(OdeConfigProperties.PROP_DB_EMBEDDED_CREATE, "true"))) {
+            props.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(SchemaAction=drop,SchemaAction=add,ForeignKeys=true)");
+        }
+
+        addEntries(prefix, odeConfig, props);
+
+        return props;
+    }
+
+    public static void addEntries(String prefix, Properties odeConfig, Map props) {
+        if (odeConfig != null) {
+            for (Map.Entry me : odeConfig.entrySet()) {
+                String key = (String) me.getKey();
+                if (key.startsWith(prefix)) {
+                    String jpaKey = key.substring(prefix.length() - 1);
+                    String val = (String) me.getValue();
+                    if (val == null || val.trim().length() == 0) {
+                        props.remove(jpaKey);
+                    } else {
+                        props.put(jpaKey, me.getValue());
+                    }
+                }
+            }
+        }
+    }
+}

Added: ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/ConfStoreDAOConnectionFactoryImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/ConfStoreDAOConnectionFactoryImpl.java?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/ConfStoreDAOConnectionFactoryImpl.java (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/ConfStoreDAOConnectionFactoryImpl.java Fri May 21 15:40:59 2010
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ode.dao.jpa.openjpa;
+
+import java.util.Map;
+import java.util.Properties;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+import org.apache.ode.dao.jpa.store.ConfStoreDAOConnectionImpl;
+import org.apache.ode.il.config.OdeConfigProperties;
+import org.apache.ode.dao.store.ConfStoreDAOConnection;
+import org.apache.ode.dao.store.ConfStoreDAOConnectionFactory;
+import static org.apache.ode.dao.jpa.openjpa.BpelDAOConnectionFactoryImpl._operator;
+import static org.apache.ode.dao.jpa.openjpa.BpelDAOConnectionFactoryImpl.buildConfig;
+
+public class ConfStoreDAOConnectionFactoryImpl implements ConfStoreDAOConnectionFactory {
+
+    EntityManagerFactory _emf;
+    TransactionManager _txm;
+    DataSource _ds;
+
+    public void init(Properties odeConfig, TransactionManager txm, Object env) {
+        _txm=txm;
+        _ds = (DataSource) env;
+        Map emfProperties = buildConfig(OdeConfigProperties.PROP_DAOCF_STORE + ".", odeConfig, _txm, _ds);
+        _emf = Persistence.createEntityManagerFactory("ode-store", emfProperties);
+
+    }
+
+    public ConfStoreDAOConnection getConnection() {
+        final ThreadLocal<ConfStoreDAOConnectionImpl> currentConnection = ConfStoreDAOConnectionImpl.getThreadLocal();
+        ConfStoreDAOConnectionImpl conn = (ConfStoreDAOConnectionImpl) currentConnection.get();
+        if (conn != null && !conn.isClosed()) {
+            return conn;
+        } else {
+            EntityManager em = _emf.createEntityManager();
+            conn = new ConfStoreDAOConnectionImpl(em, _txm, _operator);
+            currentConnection.set(conn);
+            return conn;
+        }
+    }
+
+    public void shutdown() {
+        _emf.close();
+    }
+}

Added: ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaOperatorImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaOperatorImpl.java?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaOperatorImpl.java (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaOperatorImpl.java Fri May 21 15:40:59 2010
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ode.dao.jpa.openjpa;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.persistence.Query;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.dao.jpa.JpaOperator;
+import org.apache.openjpa.persistence.OpenJPAPersistence;
+import org.apache.openjpa.persistence.OpenJPAQuery;
+
+/**
+ * 
+ * 
+ * @author Matthieu Riou <mriou at apache dot org>
+ * @author Jeff Yu
+ */
+public class JpaOperatorImpl implements JpaOperator {
+	private static final Log __log = LogFactory.getLog(JpaOperatorImpl.class);
+
+    public <T> void batchUpdateByIds(Iterator<T> ids, Query query, String parameterName) {
+    	if( query instanceof OpenJPAQuery ) {
+    		OpenJPAQuery openJpaQuery = (OpenJPAQuery)query;
+    		int batchSize = openJpaQuery.getFetchPlan().getFetchBatchSize();
+    		if( __log.isTraceEnabled() ) __log.trace("BATCH fetchBatchSize = " + batchSize);
+    		List<T> batch = new ArrayList<T>();
+    		while( ids.hasNext() ) {
+	    		for( int i = 0; i < batchSize && ids.hasNext(); i++ ) {
+	    			batch.add(ids.next());
+	    		}
+	    		if( __log.isTraceEnabled() ) __log.trace("BATCH updating " + batch.size() + " objects.");
+	    		query.setParameter(parameterName, batch);
+	    		query.executeUpdate();
+	    		batch.clear();
+    		}
+    	}
+    }
+
+	public void setBatchSize(Query query, int limit) {
+        OpenJPAQuery kq = OpenJPAPersistence.cast(query);
+        kq.getFetchPlan().setFetchBatchSize(limit);
+	}
+}
\ No newline at end of file

Added: ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaTxMgrProvider.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaTxMgrProvider.java?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaTxMgrProvider.java (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaTxMgrProvider.java Fri May 21 15:40:59 2010
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.ode.dao.jpa.openjpa;
+
+import javax.transaction.NotSupportedException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.apache.openjpa.ee.ManagedRuntime;
+import org.apache.openjpa.util.GeneralException;
+
+public class JpaTxMgrProvider implements ManagedRuntime {
+	private TransactionManager _txMgr;
+	
+    public JpaTxMgrProvider(TransactionManager txMgr) {
+    	_txMgr = txMgr;
+    }
+    
+    public TransactionManager getTransactionManager() throws Exception {
+        return _txMgr;
+    }
+    
+    public void setRollbackOnly(Throwable cause) throws Exception {
+        // there is no generic support for setting the rollback cause
+        getTransactionManager().getTransaction().setRollbackOnly();
+    }
+    
+    public Throwable getRollbackCause() throws Exception {
+        // there is no generic support for setting the rollback cause
+        return null;
+    }
+    
+    public Object getTransactionKey() throws Exception, SystemException {
+        return _txMgr.getTransaction();
+    }
+    
+    public void doNonTransactionalWork(java.lang.Runnable runnable) throws NotSupportedException {
+        TransactionManager tm = null;
+        Transaction transaction = null;
+        
+        try { 
+            tm = getTransactionManager(); 
+            transaction = tm.suspend();
+        } catch (Exception e) {
+            NotSupportedException nse =
+                new NotSupportedException(e.getMessage());
+            nse.initCause(e);
+            throw nse;
+        }
+        
+        runnable.run();
+        
+        try {
+            tm.resume(transaction);
+        } catch (Exception e) {
+            try {
+                transaction.setRollbackOnly();
+            }
+            catch(SystemException se2) {
+                throw new GeneralException(se2);
+            }
+            NotSupportedException nse =
+                new NotSupportedException(e.getMessage());
+            nse.initCause(e);
+            throw nse;
+        } 
+    }
+}
\ No newline at end of file

Added: ode/trunk/dao-jpa-ojpa/src/main/scripts/license-header.sql
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/scripts/license-header.sql?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/scripts/license-header.sql (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/scripts/license-header.sql Fri May 21 15:40:59 2010
@@ -0,0 +1,19 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--    http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied.  See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+--
+ 

Added: ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-derby.sql
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-derby.sql?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-derby.sql (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-derby.sql Fri May 21 15:40:59 2010
@@ -0,0 +1,30 @@
+-- Apache ODE - SimpleScheduler Database Schema
+-- 
+-- Apache Derby scripts by Maciej Szefler.
+-- 
+-- 
+
+CREATE TABLE ode_job (
+  jobid CHAR(64)  NOT NULL DEFAULT '',
+  ts BIGINT  NOT NULL DEFAULT 0,
+  nodeid char(64),
+  scheduled int  NOT NULL DEFAULT 0,
+  transacted int  NOT NULL DEFAULT 0,
+
+  instanceId BIGINT,
+  mexId varchar(255),
+  processId varchar(255),
+  type varchar(255),
+  channel varchar(255),
+  correlatorId varchar(255),
+  correlationKey varchar(255),
+  retryCount int,
+  inMem int,
+  detailsExt blob(4096),
+
+  PRIMARY KEY(jobid));
+
+CREATE INDEX IDX_ODE_JOB_TS ON ode_job(ts);
+CREATE INDEX IDX_ODE_JOB_NODEID ON ode_job(nodeid);
+
+

Added: ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-mysql.sql
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-mysql.sql?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-mysql.sql (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-mysql.sql Fri May 21 15:40:59 2010
@@ -0,0 +1,33 @@
+-- Apache ODE - SimpleScheduler Database Schema
+-- 
+-- MySQL scripts by Maciej Szefler.
+-- 
+-- 
+DROP TABLE IF EXISTS ODE_JOB;
+
+CREATE TABLE ODE_JOB (
+  jobid CHAR(64)  NOT NULL DEFAULT '',
+  ts BIGINT  NOT NULL DEFAULT 0,
+  nodeid char(64)  NULL,
+  scheduled int  NOT NULL DEFAULT 0,
+  transacted int  NOT NULL DEFAULT 0,
+
+  instanceId BIGINT,
+  mexId varchar(255),
+  processId varchar(255),
+  type varchar(255),
+  channel varchar(255),
+  correlatorId varchar(255),
+  correlationKey varchar(255),
+  retryCount int,
+  inMem int,
+  detailsExt blob(4096),
+
+  PRIMARY KEY(jobid),
+  INDEX IDX_ODE_JOB_TS(ts),
+  INDEX IDX_ODE_JOB_NODEID(nodeid)
+)
+TYPE=InnoDB;
+
+COMMIT;
+

Added: ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-oracle.sql
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-oracle.sql?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-oracle.sql (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-oracle.sql Fri May 21 15:40:59 2010
@@ -0,0 +1,32 @@
+-- Apache ODE - SimpleScheduler Database Schema
+-- 
+-- Apache Derby scripts by Maciej Szefler.
+-- 
+-- 
+
+DROP TABLE ode_job;
+
+CREATE TABLE ode_job (
+  jobid VARCHAR(64)  NOT NULL,
+  ts number(37)  NOT NULL,
+  nodeid varchar(64),
+  scheduled int  NOT NULL,
+  transacted int  NOT NULL,
+  
+  instanceId number(37),
+  mexId varchar(255),
+  processId varchar(255),
+  type varchar(255),
+  channel varchar(255),
+  correlatorId varchar(255),
+  correlationKey varchar(255),
+  retryCount int,
+  inMem int,
+  detailsExt blob,
+
+  PRIMARY KEY(jobid));
+
+CREATE INDEX IDX_ODE_JOB_TS ON ode_job(ts);
+CREATE INDEX IDX_ODE_JOB_NODEID ON ode_job(nodeid);
+
+

Added: ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-postgres.sql
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-postgres.sql?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-postgres.sql (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-postgres.sql Fri May 21 15:40:59 2010
@@ -0,0 +1,30 @@
+-- Apache ODE - SimpleScheduler Database Schema
+-- 
+-- Apache Derby scripts by Maciej Szefler.
+-- 
+-- 
+
+CREATE TABLE ode_job (
+  jobid CHAR(64)  NOT NULL DEFAULT '',
+  ts BIGINT  NOT NULL DEFAULT 0,
+  nodeid char(64),
+  scheduled int  NOT NULL DEFAULT 0,
+  transacted int  NOT NULL DEFAULT 0,
+
+  instanceId BIGINT,
+  mexId varchar(255),
+  processId varchar(255),
+  type varchar(255),
+  channel varchar(255),
+  correlatorId varchar(255),
+  correlationKey varchar(255),
+  retryCount int,
+  inMem int,
+  detailsExt bytea,
+
+  PRIMARY KEY(jobid));
+
+CREATE INDEX IDX_ODE_JOB_TS ON ode_job(ts);
+CREATE INDEX IDX_ODE_JOB_NODEID ON ode_job(nodeid);
+
+

Modified: ode/trunk/dao-jpa/pom.xml
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/pom.xml?rev=947046&r1=947045&r2=947046&view=diff
==============================================================================
--- ode/trunk/dao-jpa/pom.xml (original)
+++ ode/trunk/dao-jpa/pom.xml Fri May 21 15:40:59 2010
@@ -21,7 +21,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.ode</groupId>
   <artifactId>ode-dao-jpa</artifactId>
-  <name>ODE :: OpenJPA DAO Impl</name>
+  <name>ODE :: JPA DAO Impl</name>
 
   <parent>
     <groupId>org.apache.ode</groupId>
@@ -37,10 +37,6 @@
     </dependency>
     <dependency>
       <groupId>org.apache.geronimo.specs</groupId>
-      <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.geronimo.specs</groupId>
       <artifactId>geronimo-jta_1.1_spec</artifactId>
     </dependency>
     <dependency>
@@ -52,10 +48,6 @@
       <artifactId>commons-logging</artifactId>
     </dependency>
     <dependency>
-      <groupId>commons-collections</groupId>
-      <artifactId>commons-collections</artifactId>
-    </dependency>
-    <dependency>
       <groupId>org.apache.ode</groupId>
       <artifactId>ode-bpel-api</artifactId>
     </dependency>
@@ -64,24 +56,15 @@
       <artifactId>ode-bpel-dao</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.ode</groupId>
-      <artifactId>ode-utils</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>xerces</groupId>
-      <artifactId>xercesImpl</artifactId>
-    </dependency>
-    <dependency>
-        <groupId>xerces</groupId>
-        <artifactId>xmlParserAPIs</artifactId>
+       <groupId>org.apache.ode</groupId>
+       <artifactId>ode-bpel-epr</artifactId>
     </dependency>
+     <!-- we can't add this as a plugin dependency since OpenJPA needs to be loaded
+    in the same class loader as the persistence.xml. (see ant faq "ignores my classpath" -->
     <dependency>
       <groupId>org.apache.openjpa</groupId>
       <artifactId>openjpa</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>net.sourceforge.serp</groupId>
-      <artifactId>serp</artifactId>
+      <scope>provided</scope>
     </dependency>
   </dependencies>
 
@@ -98,27 +81,46 @@
             </goals>
             <configuration>
               <tasks>
-                <property name="maven.runtime.classpath" refid="maven.compile.classpath"/>
+                <copy todir="${basedir}/target/classes-openjpa">
+                  <fileset dir="${basedir}/target/classes" includes="**/*"/>
+                </copy>
+                <property name="maven.compile.classpath" refid="maven.compile.classpath"/>
                 <path id="classpath">
-		   <pathelement path="${maven.runtime.classpath}"/>
-		</path>
-		<taskdef name="openjpac" classname="org.apache.openjpa.ant.PCEnhancerTask" classpathref="classpath"/>
-                <openjpac>
-		    <fileset dir="${basedir}/src/main">
-		      <include name="**/*.java" />
-		    </fileset>
-		    <classpath>
-		     <pathelement location="${basedir}/target/classes"/>
-		     <pathelement path="${maven.runtime.classpath}"/>
-		    </classpath>
-		 </openjpac>
+                  <pathelement location="${basedir}/target/classes-openjpa"/>
+                  <pathelement path="${maven.compile.classpath}"/>
+                </path>
+                <taskdef name="openjpac" classname="org.apache.openjpa.ant.PCEnhancerTask" classpathref="classpath"/>
+                <openjpac directory="${basedir}/target/classes-openjpa">
+                  <fileset dir="${basedir}/src/main">
+                    <include name="**/*.java" />                    
+                  </fileset>
+                  <classpath refid="classpath"/>
+                </openjpac>
               </tasks>
             </configuration>
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>openjpa-enhancer-package</id>
+            <phase>package</phase>
+            <configuration>
+              <classifier>openjpa</classifier>
+              <classesDirectory>${project.build.directory}/classes-openjpa</classesDirectory>
+            </configuration>
+            <goals>
+              <goal>jar</goal>
+            </goals>
+
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
-   </build>
+  </build>
   
 
 </project>

Added: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaConnection.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaConnection.java?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaConnection.java (added)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaConnection.java Fri May 21 15:40:59 2010
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ode.dao.jpa;
+
+import javax.persistence.EntityManager;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.TransactionManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.dao.DAOConnection;
+
+public class JpaConnection implements DAOConnection {
+
+    private static final Log __log = LogFactory.getLog(JpaConnection.class);
+    final protected EntityManager _em;
+    final protected TransactionManager _mgr;
+    final protected JpaTxContext _txCtx;
+    final protected JpaOperator _operator;
+
+    public JpaConnection(EntityManager em, TransactionManager mgr, JpaOperator operator) {
+        _em = em;
+        _mgr = mgr;
+        if (mgr != null) {
+            _txCtx = new JpaJtaContext();
+        } else {
+            _txCtx = new JpaNonTxContext();
+        }
+        _operator = operator;
+    }
+
+    public EntityManager getEntityManager() {
+        return _em;
+    }
+
+    public JpaOperator getJPADaoOperator() {
+        return _operator;
+    }
+
+    public void close() {
+        /* Connections are stored in thread locals so only destroying the factory
+         * should close the connection
+        _em.close();
+        _em = null;
+        _mgr = null;
+         */
+    }
+
+    public boolean isClosed() {
+        return _em == null ? true : !_em.isOpen();
+    }
+
+    /** Clear out the entity manager after a commit so no stale entites are
+     *  preserved across transactions and all JPA operations pull data directly from
+     *  the DB.
+     *
+     */
+    public void clearOnComplete() {
+        try {
+            _mgr.getTransaction().registerSynchronization(new Synchronization() {
+
+                public void afterCompletion(int i) {
+                    _em.clear();
+                }
+
+                public void beforeCompletion() {
+                }
+            });
+        } catch (Exception e) {
+            __log.error("Error adding commit synchronizer", e);
+        }
+    }
+
+    protected interface JpaTxContext {
+
+        public void begin();
+
+        public void commit();
+
+        public void rollback();
+    }
+
+    class JpaJtaContext implements JpaTxContext {
+
+        /**
+         * Due to the way ODE re-uses connection on ThreadLocals it could be possible
+         * for the JPA EntityManager to not be created on the current JTA transaction
+         * and threfore it must by manually bound to the current transaction.
+         */
+        public void begin() {
+            try {
+                if (_mgr.getStatus() == Status.STATUS_ACTIVE) {
+                    _em.joinTransaction();
+                    clearOnComplete();
+                }
+            } catch (SystemException se) {
+                __log.error(se);
+            }
+        }
+
+        public void commit() {
+        }
+
+        public void rollback() {
+            try {
+                if (_mgr.getStatus() == Status.STATUS_ACTIVE) {
+                    _mgr.setRollbackOnly();
+                }
+            } catch (Exception ex) {
+                __log.error("Unable to set rollbackOnly", ex);
+            }
+        }
+    }
+
+    class JpaNonTxContext implements JpaTxContext {
+
+        public void begin() {
+            _em.getTransaction().begin();
+        }
+
+        public void commit() {
+            _em.getTransaction().commit();
+            _em.clear();
+        }
+
+        public void rollback() {
+            _em.getTransaction().rollback();
+            _em.clear();
+        }
+    }
+}

Added: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaOperator.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaOperator.java?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaOperator.java (added)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaOperator.java Fri May 21 15:40:59 2010
@@ -0,0 +1,20 @@
+package org.apache.ode.dao.jpa;
+
+import java.util.Iterator;
+
+import javax.persistence.Query;
+
+/**
+ * this is interface that will include the methods that will be used in JPA DAO,
+ * But the implementation should be different from various JPA vendor, like OpenJPA, Hibernate etc.
+ * 
+ * @author Jeff Yu
+ *
+ */
+public interface JpaOperator {
+	
+	public <T> void batchUpdateByIds(Iterator<T> ids, Query query, String parameterName);
+	
+	public void setBatchSize(Query query, int limit);
+
+}
\ No newline at end of file

Added: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ActivityRecoveryDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ActivityRecoveryDAOImpl.java?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ActivityRecoveryDAOImpl.java (added)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ActivityRecoveryDAOImpl.java Fri May 21 15:40:59 2010
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.ode.dao.jpa.bpel;
+
+import org.apache.ode.dao.bpel.ActivityRecoveryDAO;
+import org.apache.ode.utils.DOMUtils;
+import org.w3c.dom.Element;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import java.util.Date;
+
+
+@Entity
+@Table(name="ODE_ACTIVITY_RECOVERY")
+@NamedQueries({
+ 	@NamedQuery(name=ActivityRecoveryDAOImpl.DELETE_ACTIVITY_RECOVERIES_BY_IDS, query="delete from ActivityRecoveryDAOImpl as a where a._instanceId in(:ids)"),
+	@NamedQuery(name=ActivityRecoveryDAOImpl.COUNT_ACTIVITY_RECOVERIES_BY_INSTANCES,
+			query="select r._instanceId, count(r._id) from ActivityRecoveryDAOImpl r where r._instance in(:instances) group by r._instanceId")
+})
+public class ActivityRecoveryDAOImpl implements ActivityRecoveryDAO {
+ 	public final static String DELETE_ACTIVITY_RECOVERIES_BY_IDS = "DELETE_ACTIVITY_RECOVERIES_BY_IDS";
+	public final static String COUNT_ACTIVITY_RECOVERIES_BY_INSTANCES = "COUNT_ACTIVITY_RECOVERIES_BY_INSTANCES";
+	
+    @Id @Column(name="ID")
+    @GeneratedValue(strategy= GenerationType.AUTO)
+    @SuppressWarnings("unused")
+    private Long _id;
+
+	@Basic @Column(name="ACTIVITY_ID")
+    private long _activityId;
+	@Basic @Column(name="CHANNEL")
+    private String _channel;
+	@Basic @Column(name="REASON")
+    private String _reason;
+	@Basic @Column(name="DATE_TIME")
+    private Date _dateTime;
+	@Lob @Column(name="DETAILS")
+    private String _details;
+	@Basic @Column(name="ACTIONS")
+    private String _actions;
+	@Basic @Column(name="RETRIES")
+    private int _retries;
+
+ 	@SuppressWarnings("unused")
+ 	@Basic @Column(name="INSTANCE_ID", insertable=false, updatable=false, nullable=true)
+     private Long _instanceId;
+
+	// _instances is unused because this is a one-way relationship at the database level
+    @SuppressWarnings("unused")
+    @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="INSTANCE_ID")
+    private ProcessInstanceDAOImpl _instance;
+
+	
+    public ActivityRecoveryDAOImpl() {}
+	public ActivityRecoveryDAOImpl(String channel, long activityId,
+			String reason, Date dateTime, Element data, String[] actions,
+			int retries) {
+		_channel = channel;
+		_activityId = activityId;
+		_reason = reason;
+		_dateTime = dateTime;
+
+        if (data != null) _details = DOMUtils.domToString(data);
+		
+        String alist = actions[0];
+        for (int i = 1; i < actions.length; ++i)
+            alist += " " + actions[i];
+		_actions = alist;
+		
+		_retries = retries;		
+	}
+	
+	public String getActions() {
+		return _actions;
+	}
+
+	public String[] getActionsList() {
+		return getActions().split(" ");
+	}
+
+	public long getActivityId() {
+		return _activityId;
+	}
+
+	public String getChannel() {
+		return _channel;
+	}
+
+	public Date getDateTime() {
+		return _dateTime;
+	}
+
+	public Element getDetails() {
+		Element ret = null;
+		if ( _details != null ) {
+			try {
+				ret = DOMUtils.stringToDOM(_details);
+			} catch (Exception e) {
+				throw new RuntimeException(e);
+			}
+		}
+		return ret;
+	}
+
+	public String getReason() {
+		return _reason;
+	}
+
+	public int getRetries() {
+		return _retries;
+	}
+
+    public ProcessInstanceDAOImpl getInstance() {
+        return _instance;
+    }
+
+    public void setInstance(ProcessInstanceDAOImpl instance) {
+        _instance = instance;
+    }
+}

Added: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAO.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAO.java?rev=947046&view=auto
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAO.java (added)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAO.java Fri May 21 15:40:59 2010
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ode.dao.jpa.bpel;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+public class BpelDAO {
+	private static final Log __log = LogFactory.getLog(BpelDAO.class);
+
+    protected BpelDAOConnectionImpl getConn() {
+        return BpelDAOConnectionImpl.getThreadLocal().get();
+    }
+
+    protected EntityManager getEM() {
+        return BpelDAOConnectionImpl.getThreadLocal().get().getEntityManager();
+    }
+
+    /**
+     * javax.persistence.Query either let you query for a collection or a single
+     * value throwing an exception if nothing is found. Just a convenient shortcut
+     * for single results allowing null values
+     * @param qry query to execute
+     * @return whatever you assign it to
+     */
+    @SuppressWarnings("unchecked")
+    protected <T> T getSingleResult(Query qry) {
+        List res = qry.getResultList();
+        if (res.size() == 0) return null;
+        return (T) res.get(0);
+    }
+    
+    protected <T> void batchUpdateByIds(Iterator<T> ids, Query query, String parameterName) {
+    	BpelDAOConnectionImpl.getThreadLocal().get().getJPADaoOperator().batchUpdateByIds(ids, query, parameterName);
+    }
+
+
+}
\ No newline at end of file