riftsaw SVN: r663 - in branches/ODE/ODE-1.x-jpa: axis2/src/main/java/org/apache/ode/axis2 and 89 other directories.
by riftsaw-commits@lists.jboss.org
Author: jeff.yuchang
Date: 2010-05-25 12:20:16 -0400 (Tue, 25 May 2010)
New Revision: 663
Added:
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/DAOConnection.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/DAOConnectionFactory.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ActivityRecoveryDAO.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/BpelDAOConnection.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/BpelDAOConnectionFactory.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/BpelDAOConnectionFactoryJDBC.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/CorrelationSetDAO.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/CorrelatorDAO.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/CorrelatorMessageDAO.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/DeferredProcessInstanceCleanable.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/FaultDAO.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/FilteredInstanceDeletable.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/MessageDAO.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/MessageExchangeDAO.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/MessageRouteDAO.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/NoRootContextException.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/PartnerLinkDAO.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ProcessDAO.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ProcessInstanceDAO.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ProcessManagementDAO.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/QueryReturnedEmptyResultException.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/QueryReturnedMultipleResultsException.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/RoleEnum.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ScopeDAO.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ScopeStateEnum.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/XmlDataDAO.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/package.html
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/store/
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/store/ConfStoreDAOConnection.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/store/ConfStoreDAOConnectionFactory.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/store/DeploymentUnitDAO.java
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/store/ProcessConfDAO.java
branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/dbutil/DatabaseConnectionManager.java
branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/dbutil/DerbyDatabase.java
branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/dbutil/EmbeddedDatabase.java
branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/dbutil/H2Database.java
branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/txutil/
branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/txutil/TransactionConfigException.java
branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/txutil/TxManager.java
branches/ODE/ODE-1.x-jpa/bpel-store/src/test/java/org/apache/ode/store/DaoTest.java
branches/ODE/ODE-1.x-jpa/bpel-test/src/main/java/org/apache/ode/test/MockTransactionManager.java
branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/dao/
branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/dao/bpel/
branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/dao/bpel/BaseTestDAO.java
branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/dao/bpel/InsertObjectTest.java
branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/dao/bpel/ListInstanceTest.java
branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/dao/bpel/ProcessManagementDaoTest.java
branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/dao/bpel/SelectObjectTest.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/DataSourceConnectionProvider.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/HibernateTransactionManagerLookup.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/JotmTransaction.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/JotmTransactionFactory.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/NativeHiLoGenerator.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/SessionManager.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ActivityRecoveryDaoImpl.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/BpelDAOConnectionFactoryImpl.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/BpelDAOConnectionImpl.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/CorrelationSetDaoImpl.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/CorrelatorDaoImpl.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/CorrelatorMessageDaoImpl.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/CriteriaBuilder.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/FaultDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/HibernateDao.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/HibernateHandle.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/MessageDaoImpl.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/MessageExchangeDaoImpl.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/MessageRouteDaoImpl.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/PartnerLinkDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessDaoImpl.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessInstanceDaoImpl.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessManagementDaoImpl.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ScopeDaoImpl.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/XmlDataDaoImpl.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/GZipDataType.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HActivityRecovery.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HBpelEvent.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelationProperty.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelationSet.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelator.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelatorMessage.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelatorMessageKey.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelatorSelector.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HFaultData.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HLargeData.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HMessage.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HMessageExchange.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HMessageExchangeProperty.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HObject.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HPartnerLink.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HProcess.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HProcessInstance.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HScope.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HVariableProperty.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HXmlData.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/package.html
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/package.html
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ql/
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ql/HibernateInstancesQueryCompiler.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ql/StateComparator.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/package.html
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/ConfStoreDAOConnectionFactoryImpl.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/ConfStoreDAOConnectionImpl.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/HibernateDao.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/hobj/
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/hobj/DeploymentUnitDaoImpl.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/hobj/ProcessConfDaoImpl.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/hobj/VersionTrackerDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa-db/
branches/ODE/ODE-1.x-jpa/dao-jpa-db/build.xml
branches/ODE/ODE-1.x-jpa/dao-jpa-db/pom.xml
branches/ODE/ODE-1.x-jpa/dao-jpa-db/shutdown.sql
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/assembly/
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/assembly/bin.xml
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.derby.xml
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.hsql.xml
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.mysql.xml
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.oracle.xml
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.postgres.xml
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/common.sql
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/license-header.sql
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/simplesched-derby.sql
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/simplesched-hsql.sql
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/simplesched-mysql.sql
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/simplesched-oracle.sql
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/simplesched-postgres.sql
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/test/
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/test/java/
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/test/java/org/
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/test/java/org/apache/
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/test/java/org/apache/ode/
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/test/java/org/apache/ode/dao/
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/test/java/org/apache/ode/dao/jpa/
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/test/java/org/apache/ode/dao/jpa/test/
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/test/resources/
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/test/resources/META-INF/
branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/test/resources/META-INF/persistence.xml
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/pom.xml
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/descriptors/
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/descriptors/persistence.derby.xml
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/descriptors/persistence.mysql.xml
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/descriptors/persistence.oracle.xml
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/descriptors/persistence.postgres.xml
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/files/
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/files/hibernate.cfg/
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/files/hibernate.cfg/hsql.properties
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/files/hibernate.cfg/mysql.properties
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/BpelDAOConnectionFactoryImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/ConfStoreDAOConnectionFactoryImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/DataSourceConnectionProvider.java
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/HibernateTransactionManagerLookup.java
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/HibernateUtil.java
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/JpaOperatorImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/scripts/
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/scripts/license-header.sql
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/scripts/simplesched-derby.sql
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/scripts/simplesched-mysql.sql
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/scripts/simplesched-oracle.sql
branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/scripts/simplesched-postgres.sql
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/pom.xml
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/descriptors/
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/descriptors/persistence.derby.xml
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/descriptors/persistence.mysql.xml
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/descriptors/persistence.oracle.xml
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/descriptors/persistence.postgres.xml
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/java/
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/java/org/
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/java/org/apache/
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/java/org/apache/ode/
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/BpelDAOConnectionFactoryImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/ConfStoreDAOConnectionFactoryImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaOperatorImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaTxMgrProvider.java
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/scripts/
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/scripts/license-header.sql
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/scripts/simplesched-derby.sql
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/scripts/simplesched-mysql.sql
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/scripts/simplesched-oracle.sql
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/scripts/simplesched-postgres.sql
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaConnection.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaOperator.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ActivityRecoveryDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAO.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAOConnectionImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/CorrSetProperty.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/CorrelationSetDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/CorrelatorDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/EventDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/FaultDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/JpaTxMgrProvider.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MessageDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MessageExchangeDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MessageRouteDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MexProperty.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/PartnerLinkDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessInstanceDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessManagementDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ScopeDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/XmlDataDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/XmlDataProperty.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ConfStoreDAO.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ConfStoreDAOConnectionImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/DeploymentUnitDaoImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ProcessConfDaoImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ProcessConfPropertyDaoImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/VersionTrackerDAOImpl.java
Removed:
branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/bpel/
branches/ODE/ODE-1.x-jpa/bpel-store/src/main/java/org/apache/ode/store/ConfStoreConnection.java
branches/ODE/ODE-1.x-jpa/bpel-store/src/main/java/org/apache/ode/store/ConfStoreConnectionFactory.java
branches/ODE/ODE-1.x-jpa/bpel-store/src/main/java/org/apache/ode/store/DeploymentUnitDAO.java
branches/ODE/ODE-1.x-jpa/bpel-store/src/main/java/org/apache/ode/store/ProcessConfDAO.java
branches/ODE/ODE-1.x-jpa/bpel-store/src/main/java/org/apache/ode/store/hib/
branches/ODE/ODE-1.x-jpa/bpel-store/src/main/java/org/apache/ode/store/jpa/
branches/ODE/ODE-1.x-jpa/bpel-store/src/main/resources/META-INF/persistence.xml
branches/ODE/ODE-1.x-jpa/bpel-store/src/test/java/org/apache/ode/store/hib/DaoTest.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/daohib/
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/BaseTestDAO.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/ListInstanceTest.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/ProcessManagementDaoTest.java
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa-derby/src/test/java/org/apache/ode/dao/jpa/test/InsertObjectTest.java
branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa-derby/src/test/java/org/apache/ode/dao/jpa/test/SelectObjectTest.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ActivityRecoveryDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionFactoryImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrSetProperty.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelationSetDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelatorDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/EventDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/FaultDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaTxMgrProvider.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageExchangeDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageRouteDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MexProperty.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/OpenJPADAO.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/PartnerLinkDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessInstanceDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessManagementDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ScopeDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/XmlDataDAOImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/XmlDataProperty.java
Modified:
branches/ODE/ODE-1.x-jpa/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java
branches/ODE/ODE-1.x-jpa/bpel-dao/pom.xml
branches/ODE/ODE-1.x-jpa/bpel-epr/pom.xml
branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/config/OdeConfigProperties.java
branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/dbutil/Database.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/pom.xml
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelDatabase.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelManagementFacadeImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcessDatabase.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BrokeredMyRoleMessageExchangeImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/DebuggerSupport.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/InterceptorContextImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MessageExchangeImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MessageImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MexDaoUtil.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/PartnerLinkMyRoleImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/PartnerRoleMessageExchangeImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessCleanUpRunnable.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessStatusConverter.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/cron/RuntimeDataCleanupRunnable.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/CorrelationKeyMigration.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/CorrelationKeySetDataMigration.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/CorrelationKeySetMigration.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/CorrelatorsMigration.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/Migration.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/MigrationHandler.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/OutstandingRequestsMigration.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/replayer/Replayer.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/replayer/ReplayerBpelRuntimeContextImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/replayer/ReplayerContext.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/replayer/ReplayerScheduler.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/MessageExchangeInterceptor.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionFactoryImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelationSetDaoImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelatorDaoImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/FaultDaoImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageDAOImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageExchangeDAOImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageRouteDaoImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/PartnerLinkDAOImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessInstanceDaoImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessManagementDaoImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ScopeDaoImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/XmlDataDaoImpl.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/test/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImplTest.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/test/java/org/apache/ode/bpel/engine/cron/CronSchedulerTest.java
branches/ODE/ODE-1.x-jpa/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java
branches/ODE/ODE-1.x-jpa/bpel-store/pom.xml
branches/ODE/ODE-1.x-jpa/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java
branches/ODE/ODE-1.x-jpa/bpel-store/src/test/java/org/apache/ode/store/ProcessStoreTest.java
branches/ODE/ODE-1.x-jpa/bpel-test/pom.xml
branches/ODE/ODE-1.x-jpa/bpel-test/src/main/java/org/apache/ode/test/BPELTestAbstract.java
branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/VersionedRedeployTest.java
branches/ODE/ODE-1.x-jpa/dao-hibernate/pom.xml
branches/ODE/ODE-1.x-jpa/dao-jpa/pom.xml
branches/ODE/ODE-1.x-jpa/jbi/pom.xml
branches/ODE/ODE-1.x-jpa/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java
branches/ODE/ODE-1.x-jpa/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java
branches/ODE/ODE-1.x-jpa/pom.xml
branches/ODE/ODE-1.x-jpa/scheduler-simple/pom.xml
Log:
* commit the store and bpel module jpa refactoring.
* update the jbi/pom.xml, to fix the mvn eclipse:eclipse
(will commit the axis2-war compliation fix shortly)
Modified: branches/ODE/ODE-1.x-jpa/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -58,7 +58,6 @@
import org.apache.ode.axis2.service.ManagementService;
import org.apache.ode.axis2.util.ClusterUrlTransformer;
import org.apache.ode.bpel.connector.BpelServerConnector;
-import org.apache.ode.bpel.dao.BpelDAOConnectionFactory;
import org.apache.ode.bpel.engine.BpelServerImpl;
import org.apache.ode.bpel.engine.CountLRUDehydrationPolicy;
import org.apache.ode.bpel.engine.cron.CronScheduler;
@@ -73,6 +72,8 @@
import org.apache.ode.bpel.memdao.BpelDAOConnectionFactoryImpl;
import org.apache.ode.bpel.pmapi.InstanceManagement;
import org.apache.ode.bpel.pmapi.ProcessManagement;
+import org.apache.ode.dao.bpel.BpelDAOConnectionFactory;
+import org.apache.ode.dao.store.ConfStoreDAOConnectionFactory;
import org.apache.ode.il.dbutil.Database;
import org.apache.ode.scheduler.simple.JdbcDelegate;
import org.apache.ode.scheduler.simple.SimpleScheduler;
@@ -109,6 +110,8 @@
protected TransactionManager _txMgr;
protected BpelDAOConnectionFactory _daoCF;
+
+ protected ConfStoreDAOConnectionFactory _storeDaoCF;
protected ExecutorService _executorService;
@@ -424,7 +427,7 @@
}
}
}
-
+
/**
* Initialize the DAO.
*
@@ -432,8 +435,10 @@
*/
protected void initDAO() throws ServletException {
__log.info(__msgs.msgOdeUsingDAOImpl(_odeConfig.getDAOConnectionFactory()));
+ __log.info(__msgs.msgOdeUsingDAOImpl(_odeConfig.getDAOConfStoreConnectionFactory()));
try {
_daoCF = _db.createDaoCF();
+ _storeDaoCF = _db.createDaoStoreCF();
} catch (Exception ex) {
String errmsg = __msgs.msgDAOInstantiationFailed(_odeConfig.getDAOConnectionFactory());
__log.error(errmsg, ex);
@@ -453,7 +458,7 @@
}
protected ProcessStoreImpl createProcessStore(EndpointReferenceContext eprContext, DataSource ds) {
- return new ProcessStoreImpl(eprContext, ds, _odeConfig.getDAOConnectionFactory(), _odeConfig, false);
+ return new ProcessStoreImpl(eprContext,_txMgr,_storeDaoCF);
}
protected Scheduler createScheduler() {
Modified: branches/ODE/ODE-1.x-jpa/bpel-dao/pom.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/pom.xml 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/pom.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -36,5 +36,9 @@
<groupId>org.jboss.soa.bpel</groupId>
<artifactId>riftsaw-bpel-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jta_1.1_spec</artifactId>
+ </dependency>
</dependencies>
</project>
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/DAOConnection.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/DAOConnection.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/DAOConnection.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+public interface DAOConnection {
+
+ void close();
+
+ boolean isClosed();
+
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/DAOConnectionFactory.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/DAOConnectionFactory.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/DAOConnectionFactory.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,43 @@
+/*
+ * 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;
+
+import java.util.Properties;
+import javax.transaction.TransactionManager;
+
+public interface DAOConnectionFactory<C extends DAOConnection> {
+
+ /**
+ *
+ * @return a connection object to a store.
+ */
+ public C getConnection();
+
+ /**
+ * Initializes the connection factory with properties required to establish a
+ * connection.
+ *
+ * @param properties
+ */
+
+ <E> void init(Properties p, TransactionManager txm, E envCtx);
+
+ void shutdown();
+
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ActivityRecoveryDAO.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ActivityRecoveryDAO.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ActivityRecoveryDAO.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,46 @@
+/*
+ * 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.bpel;
+
+import java.util.Date;
+import org.w3c.dom.Element;
+
+/**
+ * Activity recovery object. Registered when activity enters recovery state.
+ */
+public interface ActivityRecoveryDAO {
+
+ long getActivityId();
+
+ String getChannel();
+
+ String getReason();
+
+ Element getDetails();
+
+ Date getDateTime();
+
+ String getActions();
+
+ String[] getActionsList();
+
+ int getRetries();
+
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/BpelDAOConnection.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/BpelDAOConnection.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/BpelDAOConnection.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,124 @@
+/*
+ * 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.bpel;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.ode.bpel.common.BpelEventFilter;
+import org.apache.ode.bpel.common.InstanceFilter;
+import org.apache.ode.bpel.evt.BpelEvent;
+import org.apache.ode.dao.DAOConnection;
+
+
+/**
+ * Represents the physical resource for connecting to the bpel state store.
+ */
+public interface BpelDAOConnection extends DAOConnection{
+ /**
+ * Return the DAO for a bpel process.
+ *
+ * @param processId name (identifier) of the process
+ *
+ * @return DAO
+ */
+ ProcessDAO getProcess(QName processId);
+
+
+ /**
+ * Retrieve a process instance from the database.
+ * @param iid instance identifier
+ * @return process instance
+ */
+ ProcessInstanceDAO getInstance(Long iid);
+
+ /**
+ * Retrieve a scope instance from the database.
+ * @param siidl scope instance identifier
+ * @return scope instance
+ */
+ ScopeDAO getScope(Long siidl);
+
+ /**
+ * Query instances in the database meeting the requested
+ * criteria.
+ * @param criteria
+ * @return Collection<ProcessInstanceDAO>
+ */
+ Collection<ProcessInstanceDAO> instanceQuery(InstanceFilter criteria);
+
+ Collection<ProcessInstanceDAO> instanceQuery(String expression);
+
+ int getNumInstances(QName processId);
+
+ /**
+ * Insert a BPEL event into the database.
+ * @param event a BPEL event
+ * @param process associated process (optional)
+ * @param instance associated instance (optional)
+ */
+ void insertBpelEvent(BpelEvent event, ProcessDAO process,
+ ProcessInstanceDAO instance);
+
+ /**
+ * Execute a query for the timeline for BPEL events matching the criteria.
+ * @param ifilter instance filter (optional)
+ * @param efilter event filter (optional)
+ * @return List of event timestamps of events matching the criteria
+ */
+ List<Date> bpelEventTimelineQuery(InstanceFilter ifilter, BpelEventFilter efilter);
+
+ /**
+ * Execute a query to retrieve the BPEL events matching the criteria.
+ * @param ifilter instance filter
+ * @param efilter event filter
+ * @return
+ */
+ List<BpelEvent> bpelEventQuery(InstanceFilter ifilter, BpelEventFilter efilter);
+
+
+ Map<Long, Collection<CorrelationSetDAO>> getCorrelationSets(Collection<ProcessInstanceDAO> instances);
+
+ Collection<CorrelationSetDAO> getActiveCorrelationSets();
+
+ ProcessDAO createTransientProcess(Serializable id);
+
+ ProcessDAO createProcess(QName pid, QName type, String guid, long version);
+
+ /**
+ * Create a message exchange.
+ * @param dir type of message exchange
+ * @return
+ */
+ MessageExchangeDAO createMessageExchange(char dir);
+
+ MessageExchangeDAO getMessageExchange(String mexid);
+
+ /**
+ * Returns an interface for process and instance management.
+ *
+ * @return a ProcessManagement DAO
+ */
+ ProcessManagementDAO getProcessManagement();
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/BpelDAOConnectionFactory.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/BpelDAOConnectionFactory.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/BpelDAOConnectionFactory.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,36 @@
+/*
+ * 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.bpel;
+
+
+import org.apache.ode.dao.DAOConnectionFactory;
+
+public interface BpelDAOConnectionFactory extends DAOConnectionFactory<BpelDAOConnection>{
+
+ /**
+ * Create a JTA transaction-aware state store connection to an the state store.
+ * The state store must have previously been created in order for this method to
+ * be succesful.
+ *
+ * @return a {@link BpelDAOConnection} connection object to the state
+ * store.
+ */
+ public BpelDAOConnection getConnection();
+
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/BpelDAOConnectionFactoryJDBC.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/BpelDAOConnectionFactoryJDBC.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/BpelDAOConnectionFactoryJDBC.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,48 @@
+/*
+ * 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.bpel;
+
+import javax.sql.DataSource;
+
+/**
+ * Extension of the {@link BpelDAOConnectionFactory} interface for DAOs that
+ * are based on J2EE/JDBC data sources.
+ *
+ * @author Maciej Szefler - m s z e f l e r @ g m a i l . c o m
+ */
+public interface BpelDAOConnectionFactoryJDBC extends BpelDAOConnectionFactory {
+
+ /**
+ * Set the managed data source (transactions tied to transaction manager).
+ * @param ds
+ */
+ public void setDataSource(DataSource ds);
+
+ /**
+ * Set the unmanaged data source.
+ * @param ds
+ */
+ public void setUnmanagedDataSource(DataSource ds);
+
+ /**
+ * Set the transaction manager.
+ * @param tm
+ */
+ public void setTransactionManager(Object tm);
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/CorrelationSetDAO.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/CorrelationSetDAO.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/CorrelationSetDAO.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,79 @@
+/*
+ * 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.bpel;
+
+import org.apache.ode.bpel.common.CorrelationKey;
+
+import javax.xml.namespace.QName;
+import java.util.Map;
+
+/**
+ * <p>
+ * Data access object representing a BPEL correlation set.
+ * Correlation sets are late-bound constants that "belong"
+ * either to the process or to a scope.
+ * </p>
+ */
+public interface CorrelationSetDAO {
+
+ public Long getCorrelationSetId();
+
+ /**
+ * Get the name of the correlation set.
+ * @return name of the correlation set
+ */
+ public String getName();
+
+ /**
+ * Get the scope instance to which this correlation set belongs.
+ *
+ * @see {@link ScopeDAO}
+ * @return owning scope instance
+ */
+ public ScopeDAO getScope();
+
+ /**
+ * Sets the value of the correlation set.
+ * @param names qualified names of the correlation set properties
+ * @param values
+ */
+ public void setValue(QName[] names, CorrelationKey values);
+
+ /**
+ * Get the value of the correlation set.
+ *
+ * @return valu of correlation set
+ */
+ public CorrelationKey getValue();
+
+ /**
+ * Get correlation set properties with their values as a Map.
+ * @return Map with the property qualified name as key and value as Map value.
+ */
+ public Map<QName, String> getProperties();
+
+ /**
+ * @return the process this correlation is related to, gives a chance of optimization to the underlying impl
+ */
+ ProcessDAO getProcess();
+ /**
+ * @return the instance this correlation is related to, gives a chance of optimization to the underlying impl
+ */
+ ProcessInstanceDAO getInstance();
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/CorrelatorDAO.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/CorrelatorDAO.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/CorrelatorDAO.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,118 @@
+/*
+ * 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.bpel;
+
+import java.util.List;
+
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.bpel.common.CorrelationKeySet;
+
+import java.util.Collection;
+
+/**
+ * <p>
+ * Data access object representing a <em>correlator</em>. A correlator
+ * does not have a simple explanation: it acts as match-maker connecting
+ * messages with <em>message consumers</em> (i.e. BPEL pick and receive
+ * operations) across time. For each partnerLink "myRole" and operation
+ * there is one correlator.
+ * </p>
+ * <p>
+ * The correlator functions as a two-sided queue: when a message is
+ * received the correlator is used to dequeue a consumer based on the
+ * keys from the message. If no consumer matches the keys in the message,
+ * the message itself is enqueued along with its keys. Conversely, when
+ * a BPEL pick/receive operation is performed, the correlator is used
+ * to dequeue a message matching a given correlation key. If no message is
+ * found, the consumer (i.e. the pick/receive operation) is enqueued
+ * along with the target key.
+ * </p>
+ * <p>
+ * The end result is matching of messages to pick/receive operations,
+ * irrespective of whether the operation or the message arrives first.
+ * Make sense?
+ * </p>
+ */
+public interface CorrelatorDAO {
+
+ /**
+ * Get the correlator identifier.
+ * @return correlator identifier
+ */
+ String getCorrelatorId();
+
+ void setCorrelatorId(String newId);
+
+ /**
+ * Enqueue a message exchange to the queue with a set of correlation keys.
+ *
+ * @param mex message exchange
+ * @param correlationKeys pre-computed set of correlation keys for this message
+ */
+ void enqueueMessage(MessageExchangeDAO mex, CorrelationKeySet correlationKeySet);
+
+
+ /**
+ * Dequeue a message exchange matching a correlationKey constraint.
+ *
+ * @param correlationKey correlation correlationKey constraint
+ * @return opaque message-related data previously enqueued with the
+ * given correlation correlationKey
+ */
+ MessageExchangeDAO dequeueMessage(CorrelationKeySet correlationKeySet);
+
+ /**
+ * @return all messages waiting on this correlator, use with care as it can potentially return a lot of values
+ */
+ Collection<CorrelatorMessageDAO> getAllMessages();
+
+ /**
+ * Find a route matching the given correlation key.
+ * @param correlationKey correlation key
+ * @return route matching the given correlation key
+ */
+ List<MessageRouteDAO> findRoute(CorrelationKeySet correlationKeySet);
+
+ /**
+ * Check if corresponding key set is free to register (see ODE-804)
+ * @param correlationKeySet
+ * @return true - available, false - not available
+ */
+ boolean checkRoute(CorrelationKeySet correlationKeySet);
+
+ /**
+ * Add a route from the given correlation key to the given process instance.
+ * @param routeGroupId identifier of the group of routes to which this route belongs
+ * @param target target process instance
+ * @param index relative order in which the route should be considered
+ * @param correlationKey correlation key to match
+ */
+ void addRoute(String routeGroupId, ProcessInstanceDAO target, int index, CorrelationKeySet correlationKeySet, String routePolicy);
+
+ /**
+ * Remove all routes with the given route-group identifier.
+ * @param routeGroupId
+ */
+ void removeRoutes(String routeGroupId, ProcessInstanceDAO target);
+
+ /**
+ * @return all routes registered on this correlator, use with care as it can potentially return a lot of values
+ */
+ Collection<MessageRouteDAO> getAllRoutes();
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/CorrelatorMessageDAO.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/CorrelatorMessageDAO.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/CorrelatorMessageDAO.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,29 @@
+/*
+ * 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.bpel;
+
+import org.apache.ode.bpel.common.CorrelationKey;
+
+public interface CorrelatorMessageDAO {
+
+ CorrelationKey getCorrelationKey();
+
+ void setCorrelationKey(CorrelationKey ckey);
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/DeferredProcessInstanceCleanable.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/DeferredProcessInstanceCleanable.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/DeferredProcessInstanceCleanable.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,28 @@
+package org.apache.ode.dao.bpel;
+
+import java.io.Serializable;
+
+/**
+ * Instances and associated data for a ProcessDAO implementation that implements this
+ * interface can be deleted in a deferred fashion.
+ *
+ * @author sean
+ *
+ */
+public interface DeferredProcessInstanceCleanable {
+ /**
+ * Returns the database id.
+ *
+ * @return database id
+ */
+ Serializable getId();
+
+ /**
+ * Deletes instances and data for this process, the number of rows gets deletes is limited
+ * by the transaction size.
+ *
+ * @param transactionSize the number of rows to delete
+ * @return the number of rows actually deleted
+ */
+ int deleteInstances(int transactionSize);
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/FaultDAO.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/FaultDAO.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/FaultDAO.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,42 @@
+/*
+ * 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.bpel;
+
+import org.w3c.dom.Element;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Fault data access object. Used to access information about a
+ * fault that affected a process execution (causing the failure of
+ * an instance for example).
+ */
+public interface FaultDAO {
+
+ QName getName();
+
+ Element getData();
+
+ String getExplanation();
+
+ int getLineNo();
+
+ int getActivityId();
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/FilteredInstanceDeletable.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/FilteredInstanceDeletable.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/FilteredInstanceDeletable.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,24 @@
+package org.apache.ode.dao.bpel;
+
+import java.util.Set;
+
+import org.apache.ode.bpel.common.InstanceFilter;
+import org.apache.ode.bpel.iapi.ProcessConf.CLEANUP_CATEGORY;
+
+/**
+ * An implementation of this interface provides a way to delete runtime process instances
+ * through the InstanceFilter.
+ *
+ * @author sean
+ *
+ */
+public interface FilteredInstanceDeletable {
+ /**
+ * Deletes instance filter by the given instance filter and clean up categories.
+ *
+ * @param filter instance filter
+ * @param categories clean up categories
+ * @return returns the number of instances that are deleted
+ */
+ int deleteInstances(InstanceFilter filter, Set<CLEANUP_CATEGORY> categories);
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/MessageDAO.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/MessageDAO.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/MessageDAO.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,39 @@
+/*
+ * 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.bpel;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+
+// TODO: Abstract out the data representation.
+public interface MessageDAO {
+
+ void setType(QName type);
+ QName getType();
+
+ void setData(Element value);
+ Element getData();
+
+ void setHeader(Element value);
+ Element getHeader();
+
+ MessageExchangeDAO getMessageExchange();
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/MessageExchangeDAO.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/MessageExchangeDAO.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/MessageExchangeDAO.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,255 @@
+/*
+ * 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.bpel;
+
+import org.w3c.dom.Element;
+
+import javax.xml.namespace.QName;
+import java.util.Date;
+import java.util.Set;
+
+/**
+ * Data access object for a message exchange.
+ */
+public interface MessageExchangeDAO {
+
+ public static final char DIR_BPEL_INVOKES_PARTNERROLE = 'P';
+
+ public static final char DIR_PARTNER_INVOKES_MYROLE = 'M';
+
+ /**
+ * Instance id of the message exchange.
+ *
+ * @return message exchange id.
+ */
+ String getMessageExchangeId();
+
+ /**
+ * Get output message (could be fault message)
+ *
+ * @return output message DAO
+ */
+ MessageDAO getResponse();
+
+ /**
+ * Creation time of the message exchange
+ *
+ * @return create time
+ */
+ Date getCreateTime();
+
+ void setCreateTime(Date createTime);
+
+ /**
+ * Get the input message.
+ *
+ * @return input message DAO
+ */
+ MessageDAO getRequest();
+
+ /**
+ * Get the operation name of this message exchange.
+ *
+ * @return operation name.
+ */
+ String getOperation();
+
+ /**
+ * The qualified name of the WSDL port type.
+ *
+ * @return port type name
+ */
+ QName getPortType();
+
+ /**
+ * Set the port type.
+ *
+ * @param porttype
+ * port type
+ */
+ void setPortType(QName porttype);
+
+ /**
+ * Set state of last message sent/received.
+ *
+ * @param status state to be set
+ */
+ void setStatus(String status);
+
+ /**
+ * Get state of last message sent/received.
+ *
+ * @return the state
+ */
+ String getStatus();
+
+ /**
+ * Create a new message associated with this message-exchange
+ *
+ * @param type
+ * message type
+ * @return new {@link MessageDAO}
+ */
+ MessageDAO createMessage(QName type);
+
+ /**
+ * Creates an input message DAO.
+ */
+ void setRequest(MessageDAO msg);
+
+ /**
+ * Creates an output message DAO.
+ */
+ void setResponse(MessageDAO msg);
+
+ /**
+ * Get the model id for the partner link to which this message exchange
+ * relates.
+ *
+ * @return
+ */
+ int getPartnerLinkModelId();
+
+ /**
+ * Set the model id for the partner link to which this message exchange
+ * relates
+ *
+ * @param modelId
+ */
+ void setPartnerLinkModelId(int modelId);
+
+ /**
+ * Get the correlation identifier/client id
+ *
+ * @return correlation identifier
+ */
+ String getCorrelationId();
+
+ /**
+ * Set the correlation identifier/client id
+ *
+ * @param correlationId
+ * identifier
+ */
+ void setCorrelationId(String correlationId);
+
+ void setPattern(String string);
+
+ void setOperation(String opname);
+
+ void setEPR(Element epr);
+
+ Element getEPR();
+
+ String getPattern();
+
+ /**
+ * Get the response channel.
+ *
+ * @return response channel.
+ */
+ String getChannel();
+
+ /**
+ * Set the response channel.
+ *
+ * @param string
+ * response channel
+ */
+ void setChannel(String string);
+
+ boolean getPropagateTransactionFlag();
+
+ QName getFault();
+
+ void setFault(QName faultType);
+
+ public String getFaultExplanation();
+
+ public void setFaultExplanation(String explanation);
+
+ void setCorrelationStatus(String cstatus);
+
+ String getCorrelationStatus();
+
+ /**
+ * Get the process associate with this message exchange. The process should
+ * always be available for partnerRole message exchanges. However, for myRole
+ * message exchanges, it is possible that no process is associated with the
+ * message exchange (i.e. if the EPR routing fails).
+ *
+ * @return process associated with the message exchange
+ */
+ ProcessDAO getProcess();
+
+ void setProcess(ProcessDAO process);
+
+ void setInstance(ProcessInstanceDAO dao);
+
+ ProcessInstanceDAO getInstance();
+
+ /**
+ * Get the direction of the message exchange.
+ *
+ * @return
+ */
+ char getDirection();
+
+ /**
+ * Get the "callee"--the id of the process being invoked in a myRole
+ * exchange.
+ * @return
+ */
+ QName getCallee();
+
+ /**
+ * Set the "callee"--the id of the process being invoked in a myRole
+ * exchange.
+ * @param callee
+ */
+ void setCallee(QName callee);
+
+ String getProperty(String key);
+
+ void setProperty(String key, String value);
+
+ Set<String> getPropertyNames();
+
+ void setPartnerLink(PartnerLinkDAO plinkDAO);
+
+ PartnerLinkDAO getPartnerLink();
+
+ /**
+ * Gets the mex id for the message exchange that has been piped with
+ * this one in a process to process interaction.
+ * @return
+ */
+ String getPipedMessageExchangeId();
+ void setPipedMessageExchangeId(String mexId);
+
+ int getSubscriberCount();
+ void setSubscriberCount(int subscriberCount);
+
+ void release(boolean doClean);
+
+ /**
+ * Deletes messages that arrived before the route is setup
+ */
+ void releasePremieMessages();
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/MessageRouteDAO.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/MessageRouteDAO.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/MessageRouteDAO.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,57 @@
+/*
+ * 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.bpel;
+
+import org.apache.ode.bpel.common.CorrelationKeySet;
+
+import org.apache.ode.bpel.common.CorrelationKey;
+
+/**
+ * Data access object representing a message consumer. A message consumer
+ * represents an unsatisfied BPEL <code>pick</code> or <code>receive</code>
+ * activity.
+ */
+public interface MessageRouteDAO {
+
+ /**
+ * Get the BPEL process instance to which this consumer belongs.
+ *
+ * @return the process instance to which this consumer belongs
+ */
+ ProcessInstanceDAO getTargetInstance();
+
+ String getGroupId();
+
+ int getIndex();
+
+ String getRoute();
+
+ /**
+ * Returns a correlation key set for the message route
+ * @return
+ */
+ public CorrelationKeySet getCorrelationKeySet();
+
+ void setCorrelationKeySet(CorrelationKeySet keySet);
+
+ void setCorrelationKey(CorrelationKey key);
+
+ CorrelationKey getCorrelationKey();
+
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/NoRootContextException.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/NoRootContextException.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/NoRootContextException.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,27 @@
+/*
+ * 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.bpel;
+
+/**
+ * Exception thrown when no root context.
+ */
+public class NoRootContextException extends Exception {
+ private static final long serialVersionUID = -5160169433065685209L;
+}
+
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/PartnerLinkDAO.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/PartnerLinkDAO.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/PartnerLinkDAO.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,72 @@
+/*
+ * 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.bpel;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+
+/**
+ * Data access object representing the endpoint reference of a specific
+ * partner link role (typically the partnerRole). An EPR has an implicit
+ * value attributed by the engine (usually by using the WSDL service
+ * definition but anyway that's the communication layer business). An
+ * EndpointReferenceDAO only has its own value if the default has been
+ * overriden (by assignment).
+ */
+public interface PartnerLinkDAO {
+
+ /**
+ * Get the model id of the partner link.
+ * @return
+ */
+ public int getPartnerLinkModelId();
+
+ public String getMyRoleName();
+
+ public String getPartnerRoleName();
+
+ public String getPartnerLinkName();
+
+ /**
+ * Get the service name associated with this partner link.
+ * @return
+ */
+ public QName getMyRoleServiceName();
+
+ public void setMyRoleServiceName(QName svcName);
+
+ public Element getMyEPR();
+
+ public void setMyEPR(Element val);
+
+ public Element getPartnerEPR();
+
+ public void setPartnerEPR(Element val);
+
+public String getMySessionId();
+
+public String getPartnerSessionId();
+
+public void setPartnerSessionId(String session);
+
+public void setMySessionId(String sessionId);
+
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ProcessDAO.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ProcessDAO.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ProcessDAO.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,121 @@
+/*
+ * 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.bpel;
+
+import org.apache.ode.bpel.common.CorrelationKey;
+
+import javax.xml.namespace.QName;
+
+import java.util.Collection;
+
+/**
+ * BPEL process data access objects. Contains references to active process instances ({@link ProcessInstanceDAO} and messages bound
+ * for instances yet to be created or not yet correlated..
+ */
+public interface ProcessDAO {
+ /**
+ * Get the unique process identifier.
+ *
+ * @return process identifier
+ */
+ QName getProcessId();
+
+ /**
+ * Get the BPEL process name.
+ *
+ * @return qualified BPEL process name.
+ */
+ QName getType();
+
+ /**
+ * Get the process version
+ *
+ * @return version
+ */
+ long getVersion();
+
+ /**
+ * Get a message correlator instance.
+ *
+ * @param correlatorId
+ * correlator identifier
+ * @return correlator corresponding to the given identifier
+ */
+ CorrelatorDAO getCorrelator(String correlatorId);
+
+ /**
+ * Create a new process instance object.
+ *
+ * @param instantiatingCorrelator
+ * instantiating {@link CorrelatorDAO}
+ * @return newly generated instance DAO
+ */
+ ProcessInstanceDAO createInstance(CorrelatorDAO instantiatingCorrelator);
+
+ /**
+ * Get a process instance (by identifier).
+ *
+ * @param iid
+ * unique instance identifier.
+ * @return DAO corresponding to the process instance
+ */
+ ProcessInstanceDAO getInstance(Long iid);
+
+ /**
+ * Locates a process instance based on a correlation key.
+ *
+ * @param cckey
+ * correlation key
+ * @return collection of {@link ProcessInstanceDAO} that match correlation key, ordered by date
+ */
+ Collection<ProcessInstanceDAO> findInstance(CorrelationKey cckey);
+
+ /**
+ * Remove the routes with the given Id for all the correlators in the process.
+ *
+ * @todo remove this method.
+ * @param routeId
+ */
+ void removeRoutes(String routeId, ProcessInstanceDAO target);
+
+ /**
+ * Callback indicating that a process instance has completed its duties.
+ *
+ * @param instance
+ * the completed {@link ProcessInstanceDAO}
+ */
+ void instanceCompleted(ProcessInstanceDAO instance);
+
+ /**
+ * Deletes only the process and routes without instances. This also deletes any static data to
+ * the process: correlators.
+ */
+ void deleteProcessAndRoutes();
+
+ CorrelatorDAO addCorrelator(String correlator);
+
+ String getGuid();
+
+ int getNumInstances();
+
+ /**
+ * @return all instances that haven't completed, use with care as there could be a lot of them
+ */
+ Collection<ProcessInstanceDAO> getActiveInstances();
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ProcessInstanceDAO.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ProcessInstanceDAO.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ProcessInstanceDAO.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,266 @@
+/*
+ * 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.bpel;
+
+import org.apache.ode.bpel.evt.ProcessInstanceEvent;
+import org.apache.ode.bpel.iapi.ProcessConf.CLEANUP_CATEGORY;
+import org.w3c.dom.Element;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+
+/**
+ * BPEL process instance data access object. This object serves as the root
+ * object for data related to a particular process instance; this state
+ * includes auditing events, scopes, pick/received waiters, and the
+ * serialized process instance image.
+ */
+public interface ProcessInstanceDAO {
+
+ /**
+ * Get the time when the process instance was created.
+ * @return time of instance creation
+ */
+ public Date getCreateTime();
+
+ /**
+ * Get the time when the process instance was last active (re-hydrated).
+ * @return time of activity
+ */
+ public Date getLastActiveTime();
+
+ /**
+ * Set last activity time for the process instance
+ * @param dt tiem of activity
+ */
+ void setLastActiveTime(Date dt);
+
+ /**
+ * The un-caught fault associated with the process. This will be
+ * <code>null</code> if no fault occurred or if all faults are caught and
+ * processed.
+ * @param fault the fault
+ */
+ void setFault(FaultDAO fault);
+
+ void setFault(QName faultName, String explanation, int faultLineNo, int activityId, Element faultMessage);
+
+ /**
+ * The un-caught fault associated with the process. This will be
+ * <code>null</code> if no fault occurred or if all faults are caught and
+ * processed.
+ *
+ * @return the fault
+ */
+ FaultDAO getFault();
+
+ /**
+ * Get the (opaque) instance execution state.
+ * @return opaque execution state
+ */
+ byte[] getExecutionState();
+
+ /**
+ * Set the (opaque) instance execution state.
+ * @param execState execuction state
+ */
+ void setExecutionState(byte[] execState);
+
+ /**
+ * Get the process.
+ *
+ * @return process reference.
+ */
+ ProcessDAO getProcess();
+
+ /**
+ * Get the root (global) scope for the process.
+ *
+ * @return the root scope
+ */
+ ScopeDAO getRootScope();
+
+ /**
+ * Set the state of the process instance; one of the <code>STATE_XXX</code>
+ * constants defined in ProcessState.
+ *
+ * This should automatically populate the previous state.
+ *
+ * @param state new state of the process instance
+ */
+ void setState(short state);
+
+ /**
+ * Get the state of the process instance; one of the <code>STATE_XXX</code>
+ * constants defined in ProcessState.
+ *
+ * @return state of process instance
+ */
+ short getState();
+
+ /**
+ * Returns the next to last state.
+ * @return
+ */
+ short getPreviousState();
+
+ /**
+ * Creates a new scope.
+ *
+ * @param parentScope parent scope of the new scope, or null if this is the
+ * root scope.
+ * @param name scope name
+ *
+ * @return the newly created scope
+ */
+ ScopeDAO createScope(ScopeDAO parentScope, String name, int scopeModelId);
+
+ /**
+ * Get the instance identifier.
+ * @return the instance identifier
+ */
+ Long getInstanceId();
+
+ /**
+ * Returns a scope using its instance id.
+ * @param scopeInstanceId
+ * @return
+ */
+ ScopeDAO getScope(Long scopeInstanceId);
+
+ /**
+ * Returns all the scopes with the associated name.
+ * @param scopeName
+ * @return
+ */
+ Collection<ScopeDAO> getScopes(String scopeName);
+
+ /**
+ * Returns all the scopes belonging to this isntance.
+ * @param scopeName
+ * @return
+ */
+ Collection<ScopeDAO> getScopes();
+
+ /**
+ * Return the correlator which results in the instantiation of the process instance.
+ * @return
+ */
+ CorrelatorDAO getInstantiatingCorrelator();
+
+ /**
+ * Returns all variable instances matching the variable name for a specified scope.
+ */
+ XmlDataDAO[] getVariables(String variableName, int scopeModelId);
+
+ /**
+ * Get all the correlation sets for this process.
+ * @return {@link Set} of {@link CorrelationSetDAO} objects
+ */
+ Set<CorrelationSetDAO> getCorrelationSets();
+
+ /**
+ * Get a correlation set by its name from this process
+ * @param name
+ * @return a {@link CorrelationSetDAO} object
+ */
+ CorrelationSetDAO getCorrelationSet(String name);
+
+ /**
+ * A simple callback to allow the ProcessInstance to perform post-completion duties.
+ * The DAO's state indicates whether any fault has occured.
+ */
+ void finishCompletion();
+
+ /**
+ * Delete the process instance object from the database.
+ */
+ void delete(Set<CLEANUP_CATEGORY> cleanupCategories);
+
+ /**
+ * Delete the process instance object from the database.
+ * @param cleanupCategories the categories of entities to delete
+ * @param deleteMyRoleMex will clean up the my role mex if set to true
+ */
+ void delete(Set<CLEANUP_CATEGORY> cleanupCategories, boolean deleteMyRoleMex);
+
+ /**
+ * Insert a BPEL event to the database (associating with this process).
+ * @param event BPEL event
+ */
+ void insertBpelEvent(ProcessInstanceEvent event);
+
+ /**
+ * Get a triple containing the first
+ * @return
+ */
+ EventsFirstLastCountTuple getEventsFirstLastCount();
+
+ /**
+ * Get the next number from a monotonically increasing sequence.
+ * @return next number in seqeunce
+ */
+ public long genMonotonic();
+
+ public BpelDAOConnection getConnection();
+
+ /**
+ * Get number of activities in the failure state.
+ */
+ int getActivityFailureCount();
+
+ /**
+ * Get date/time of last activity failure.
+ */
+ Date getActivityFailureDateTime();
+
+ /**
+ * Returns all activity recovery objects for this process instance.
+ */
+ Collection<ActivityRecoveryDAO> getActivityRecoveries();
+
+ /**
+ * Create an activity recovery object for a given activity instance.
+ * Specify the reason and optional data associated with the failure.
+ * Date/time failure occurred, and the recovery channel and available
+ * recovery actions.
+ */
+ void createActivityRecovery(String channel, long activityId, String reason, Date dateTime, Element data, String[] actions, int retries);
+
+ /**
+ * Delete previously registered activity recovery.
+ */
+ void deleteActivityRecovery(String channel);
+
+ /**
+ * Transport object holding the date of the first and last instance event
+ * along with the number events.
+ */
+ public class EventsFirstLastCountTuple {
+ public Date first;
+ public Date last;
+ public int count;
+ }
+
+ Collection<String> getMessageExchangeIds();
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ProcessManagementDAO.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ProcessManagementDAO.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ProcessManagementDAO.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,102 @@
+/*
+ * 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.bpel;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+/**
+ * This DAO handles any process and instance management related database
+ * operations. The idea is to separate out the operational side of database
+ * tasks from core engine.
+ *
+ * @author sean
+ *
+ */
+public interface ProcessManagementDAO {
+ public static class InstanceSummaryKey {
+ public final String pid;
+ public final String instanceStatus;
+
+ public InstanceSummaryKey(String pid, String instanceStatus) {
+ super();
+ this.pid = pid;
+ this.instanceStatus = instanceStatus;
+ }
+
+ @Override
+ public String toString() {
+ return "InstanceSummaryKey [instanceStatus=" + instanceStatus
+ + ", pid=" + pid + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime
+ * result
+ + ((instanceStatus == null) ? 0 : instanceStatus.hashCode());
+ result = prime * result + ((pid == null) ? 0 : pid.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ InstanceSummaryKey other = (InstanceSummaryKey) obj;
+ if (instanceStatus == null) {
+ if (other.instanceStatus != null)
+ return false;
+ } else if (!instanceStatus.equals(other.instanceStatus))
+ return false;
+ if (pid == null) {
+ if (other.pid != null)
+ return false;
+ } else if (!pid.equals(other.pid))
+ return false;
+ return true;
+ }
+
+ }
+
+ public static class FailedSummaryValue {
+ public final Long count;
+ public final Date lastFailed;
+ public FailedSummaryValue(Long count, Date lastFailed) {
+ super();
+ this.count = count;
+ this.lastFailed = lastFailed;
+ }
+ }
+
+ public Map<InstanceSummaryKey, Long> countInstancesSummary(Set<String> pids);
+
+ public Map<String, FailedSummaryValue> findFailedCountAndLastFailedDateForProcessIds(Set<String> pids);
+}
\ No newline at end of file
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/QueryReturnedEmptyResultException.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/QueryReturnedEmptyResultException.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/QueryReturnedEmptyResultException.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,27 @@
+/*
+ * 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.bpel;
+
+/**
+ * Thrown when a query returns empty results.
+ */
+public class QueryReturnedEmptyResultException extends Exception {
+ private static final long serialVersionUID = -6775955398350301761L;
+}
+
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/QueryReturnedMultipleResultsException.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/QueryReturnedMultipleResultsException.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/QueryReturnedMultipleResultsException.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,33 @@
+/*
+ * 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.bpel;
+
+/**
+ * Thrown when a query returns multiple results.
+ *
+ * <p>
+ * Created on Mar 9, 2004 at 1:51:09 PM.
+ * </p>
+ *
+ * @author Maciej Szefler <a href="mailto:mbs@fivesight.com">mbs</a>
+ */
+public class QueryReturnedMultipleResultsException extends Exception {
+ private static final long serialVersionUID = 3652252549449534331L;
+}
+
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/RoleEnum.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/RoleEnum.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/RoleEnum.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,88 @@
+/*
+ * 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.bpel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Partner-link role enumeration; one of {@link #MY_ROLE} or {@link
+ * #PARTNER_ROLE}.
+ */
+public class RoleEnum {
+
+ /** My Role */
+ public static final RoleEnum MY_ROLE = new RoleEnum("MY_ROLE");
+
+ /** Partner Role */
+ public static final RoleEnum PARTNER_ROLE = new RoleEnum("PARTNER_ROLE");
+
+ private static final List<RoleEnum> ENUMS = new ArrayList<RoleEnum>();
+ private short _id;
+ private transient String _name;
+
+ private RoleEnum(String name) {
+ _id = (short)ENUMS.size();
+ _name = name;
+ ENUMS.add(this);
+ }
+
+ /**
+ * @see Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object o) {
+ return ((RoleEnum)o)._id == _id;
+ }
+
+ /**
+ * DOCUMENTME
+ *
+ * @param code
+ * DOCUMENTME
+ *
+ * @return DOCUMENTME
+ */
+ public static RoleEnum fromCode(short code) {
+ return ENUMS.get(code);
+ }
+
+ /**
+ * @see Object#hashCode()
+ */
+ public int hashCode() {
+ return _id;
+ }
+
+ /**
+ * DOCUMENTME
+ *
+ * @return DOCUMENTME
+ */
+ public short toCode() {
+ return _id;
+ }
+
+ /**
+ * @see Object#toString()
+ */
+ public String toString() {
+ return "RoleEnum." + _name;
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ScopeDAO.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ScopeDAO.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ScopeDAO.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -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.bpel;
+
+import org.apache.ode.bpel.evt.BpelEvent;
+
+import java.util.Collection;
+import java.util.List;
+
+
+/**
+ * Data access objec representing a BPEL scope instance.
+ * Objects of this class manage a collection of correlation
+ * sets and XML data variables.
+ */
+public interface ScopeDAO {
+
+ /**
+ * Get the unique identifier for this scope instance.
+ * @return scope instance id
+ */
+ Long getScopeInstanceId();
+
+ /**
+ * Get the scope model id from the object
+ * @return scope model id
+ */
+ int getModelId();
+
+
+ /**
+ * Get scope name (from the definition / or auto-generated).
+ * NOTE: the scope names are not necessarily unique.
+ * @return scope name
+ */
+ String getName();
+
+ /**
+ * Get a correlation set by name.
+ * @param corrSetName correlation set name
+ * @return correlation set instance
+ */
+ CorrelationSetDAO getCorrelationSet(String corrSetName);
+
+ /**
+ * Gets all correlation sets for this scope
+ * @return correlation set instances
+ */
+ Collection<CorrelationSetDAO> getCorrelationSets();
+
+ /**
+ * Get the parent scope.
+ * @return parent scope
+ */
+ ScopeDAO getParentScope();
+
+ Collection<ScopeDAO> getChildScopes();
+
+ /**
+ * Get the process instance to which this scope belongs.
+ * @return owner {@link ProcessInstanceDAO}
+ */
+ ProcessInstanceDAO getProcessInstance();
+
+ /**
+ * Set current state of the scope.
+ * @param state new scope state
+ */
+ void setState(ScopeStateEnum state);
+
+ /**
+ * Get current state of the scope.
+ * @return current scope state
+ */
+ ScopeStateEnum getState();
+
+ /**
+ * Get a variable by name.
+ * @param varName variable name
+ * @return {@link XmlDataDAO} object representing the requested variable
+ */
+ XmlDataDAO getVariable(String varName);
+
+ /**
+ * Get a colleciton of all the variables belonging to this scope.
+ * @return collection of variables
+ */
+ Collection<XmlDataDAO> getVariables();
+
+ /**
+ * Get an ordered list of events associated with this scope.
+ * @return collection of bpel events.
+ */
+ List<BpelEvent> listEvents();
+
+ /**
+ * Create a storage space for partner link values for the scope.
+ * @param plinkModelId partner link model id
+ * @param pLinkName partner link name
+ * @return {@link PartnerLinkDAO} object representing the created endpoint reference
+ */
+ PartnerLinkDAO createPartnerLink(int plinkModelId, String pLinkName, String myRole, String partnerRole);
+
+ /**
+ * Get the parnter link storage object associated with this scope instance
+ * and the provided partner link model id.
+ * @param plinkModelId partner link model id
+ * @return {@link PartnerLinkDAO} object representing the requested endpoint reference
+ */
+ PartnerLinkDAO getPartnerLink(int plinkModelId);
+
+ /**
+ * Get all partner link storage object associated with this scope instance.
+ * @return List of {@link PartnerLinkDAO} objects
+ */
+ Collection<PartnerLinkDAO> getPartnerLinks();
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ScopeStateEnum.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ScopeStateEnum.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/ScopeStateEnum.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,56 @@
+/*
+ * 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.bpel;
+
+public class ScopeStateEnum {
+ /** DOCUMENTME */
+ public static final ScopeStateEnum ACTIVE = new ScopeStateEnum("ACTIVE");
+
+ /** DOCUMENTME */
+ public static final ScopeStateEnum FAULTED = new ScopeStateEnum("FAULTED");
+
+ /** DOCUMENTME */
+ public static final ScopeStateEnum FAULTHANDLER = new ScopeStateEnum("FAULTHANDLER");
+
+ /** DOCUMENTME */
+ public static final ScopeStateEnum COMPLETED = new ScopeStateEnum("COMPLETED");
+
+ /** DOCUMENTME */
+ public static final ScopeStateEnum COMPENSATING = new ScopeStateEnum("COMPENSATING");
+
+ /** DOCUMENTME */
+ public static final ScopeStateEnum COMPENSATED = new ScopeStateEnum("COMPENSATED");
+ private final String myName; // for debug only
+
+ public ScopeStateEnum(String name) {
+ myName = name;
+ }
+
+ public boolean equals(Object o) {
+ return ((ScopeStateEnum)o).myName.equals(myName);
+ }
+
+ public int hashCode() {
+ return myName.hashCode();
+ }
+
+ public String toString() {
+ return myName;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/XmlDataDAO.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/XmlDataDAO.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/XmlDataDAO.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -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.bpel;
+
+import org.w3c.dom.Node;
+
+
+/**
+ * Data access object representing a piece of XML data. This is object is used
+ * to model BPEL variables.
+ */
+public interface XmlDataDAO {
+
+ /**
+ * Get the name of the variable.
+ * @return variable name
+ */
+ public String getName();
+
+
+ /**
+ * Checks if the dao has been assigned any data.
+ *
+ * @return <code>true</code> is assignment has NOT occured.
+ */
+ public boolean isNull();
+
+
+ /**
+ * Retreive the variable data.
+ *
+ * @return the variable data
+ */
+ public Node get();
+
+ /**
+ * Remove the object from the data store.
+ */
+ public void remove();
+
+ /**
+ * Set the data value of a variable.
+ *
+ * @param val value
+ */
+ public void set(Node val);
+
+ /**
+ * Return the value of a property. Properties are useful
+ * for extracting simple type data which can be used for querying
+ * and identifying process instances.
+ * @param propertyName
+ * @return value of property or <b>null</b> if not set.
+ */
+ public String getProperty(String propertyName);
+
+ /**
+ * Sets the value of a property
+ * @param pname
+ * @param pvalue
+ */
+ public void setProperty(String pname, String pvalue);
+
+ /**
+ * Gets the scope associated with this xml data.
+ * @return scope
+ */
+ public ScopeDAO getScopeDAO();
+
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/package.html
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/package.html (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/bpel/package.html 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,35 @@
+<!--
+ ~ 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.
+ -->
+
+<html>
+ <head><title>DAO Package</title></head>
+ <body>
+ <p>Data-Access Object (DAO) interfaces used by the BPEL Service Provider
+ to communicate with the data store; can be used to customize the
+ BPEL persistence layer.
+ The BPEL DAO layer is used to maintain persistent state of each
+ active BPEL process instance. This includes the values of scope
+ variables, as well as instance "state snapshots" that
+ may need to be persisted due to the activation of receive, pick,
+ or invoke activity that cannot be immediately satisfied. Like
+ the DAO of the framework (see {@link com.fs.jlo.sfwk.bapi.dao}), the
+ BPEL DAO is a "dumb" object-relational model supporting
+ transactional access.</p>
+ </body>
+</html>
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/store/ConfStoreDAOConnection.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/store/ConfStoreDAOConnection.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/store/ConfStoreDAOConnection.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,38 @@
+/*
+ * 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.store;
+
+
+import java.util.Collection;
+
+import org.apache.ode.dao.DAOConnection;
+
+/**
+ */
+public interface ConfStoreDAOConnection extends DAOConnection{
+ DeploymentUnitDAO createDeploymentUnit(String name);
+
+ DeploymentUnitDAO getDeploymentUnit(String name);
+
+ Collection<DeploymentUnitDAO> getDeploymentUnits();
+
+ long getNextVersion();
+
+ void setVersion(long version);
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/store/ConfStoreDAOConnectionFactory.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/store/ConfStoreDAOConnectionFactory.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/store/ConfStoreDAOConnectionFactory.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,29 @@
+/*
+ * 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.store;
+
+import org.apache.ode.dao.DAOConnectionFactory;
+
+/**
+ * Connection factory for DB store.
+ * @author mszefler
+ */
+public interface ConfStoreDAOConnectionFactory extends DAOConnectionFactory<ConfStoreDAOConnection> {
+ ConfStoreDAOConnection getConnection();
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/store/DeploymentUnitDAO.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/store/DeploymentUnitDAO.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/store/DeploymentUnitDAO.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,77 @@
+/*
+ * 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.store;
+
+import javax.xml.namespace.QName;
+import java.util.Collection;
+import java.util.Date;
+
+/**
+ * DAO interface for a "deployment unit", a collection of processes deployed as a single
+ * unit.
+ *
+ * @author mszefler
+ *
+ */
+public interface DeploymentUnitDAO {
+
+ /**
+ * Get the name of the deployment unit.
+ * @return du name
+ */
+ String getName();
+
+ /**
+ * Get the deployment unit directory path.
+ * @return deployment unit directory path
+ */
+ String getDeploymentUnitDir();
+
+
+ void setDeploymentUnitDir(String dir);
+
+ /**
+ * Get the collection of processes that are deployed as part of this deployment unit.
+ * @return
+ */
+ Collection<? extends ProcessConfDAO> getProcesses();
+
+ /**
+ * Get the date/time the DU was deployed.
+ * @return
+ */
+ Date getDeployDate();
+
+ /**
+ * Get the userid of the user doing the deploying.
+ * @return
+ */
+ String getDeployer();
+
+
+ /**
+ * Delete this deployment unit (deletes all the children).
+ */
+ void delete();
+
+ ProcessConfDAO createProcess(QName pid, QName type, long version);
+
+ ProcessConfDAO getProcess(QName pid);
+
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/store/ProcessConfDAO.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/store/ProcessConfDAO.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-dao/src/main/java/org/apache/ode/dao/store/ProcessConfDAO.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,51 @@
+/*
+ * 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.store;
+
+import org.apache.ode.bpel.iapi.ProcessState;
+
+import javax.xml.namespace.QName;
+import java.util.Collection;
+
+/**
+ * DAO interface for a process configuration.
+ * @author mriou <mriou at apache dot org>
+ */
+public interface ProcessConfDAO {
+
+ QName getPID();
+
+ QName getType();
+
+ long getVersion();
+
+ DeploymentUnitDAO getDeploymentUnit();
+
+ ProcessState getState();
+
+ void setState(ProcessState state);
+
+ void setProperty(QName name, String content);
+
+ String getProperty(QName name);
+
+ Collection<QName> getPropertyNames();
+
+ void delete();
+}
Modified: branches/ODE/ODE-1.x-jpa/bpel-epr/pom.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-epr/pom.xml 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-epr/pom.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -48,8 +48,14 @@
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.1_spec</artifactId>
</dependency>
Modified: branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/config/OdeConfigProperties.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/config/OdeConfigProperties.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/config/OdeConfigProperties.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -45,7 +45,11 @@
public static final String PROP_DB_EXTERNAL_DS = "db.ext.dataSource";
public static final String PROP_DB_EMBEDDED_NAME = "db.emb.name";
+
+ public static final String PROP_DB_EMBEDDED_TYPE = "db.emb.type";
+ public static final String PROP_DB_EMBEDDED_CREATE = "db.emb.create";
+
public static final String PROP_DB_INTERNAL_URL = "db.int.jdbcurl";
public static final String PROP_DB_INTERNAL_DRIVER = "db.int.driver";
@@ -97,6 +101,10 @@
public static final String PROP_PROCESS_INSTANCE_THROTTLED_MAXIMUM_COUNT = "process.instance.throttled.maximum.count";
public static final String PROP_DAOCF = "dao.factory";
+
+ public static final String PROP_DAOCF_STORE = "dao.factory.store";
+
+ public static final String PROP_DAOCF_SCHEDULER = "dao.factory.scheduler";
public static final String PROP_MIGRATION_TRANSACTION_TIMEOUT = "migration.transaction.timeout";
@@ -111,6 +119,12 @@
/** Default defaults for the database embedded name and dao connection factory class. */
private static String __dbEmbName = "jpadb";
private static String __daoCfClass = "org.apache.ode.dao.jpa.BPELDAOConnectionFactoryImpl";
+
+ /** Default defaults for the database embedded name and dao connection factory class. */
+ public static String DEFAULT_DB_EMB_NAME = "ode-db";
+ public static String DEFAULT_DB_EMB_TYPE = "h2";
+ public static String DEFAULT_DAOCF_CLASS = "org.apache.ode.dao.jpa.openjpa.BpelDAOConnectionFactoryImpl";
+ public static String DEFAULT_DAOCF_STORE_CLASS = "org.apache.ode.dao.jpa.openjpa.ConfStoreDAOConnectionFactoryImpl";
static {
String odep = System.getProperty("ode.persistence");
@@ -135,7 +149,19 @@
/** Embedded database (Ode provides default embedded database with connection pool) */
EMBEDDED
}
+
+ /**
+ * Possible database implementation.
+ */
+ public enum EmbeddedDbType {
+
+ DERBY,
+
+ H2,
+ HSQL
+ }
+
public OdeConfigProperties(File cfgFile, String prefix) {
_cfgFile = cfgFile;
_prefix = prefix;
@@ -188,15 +214,28 @@
}
+ public EmbeddedDbType getDbEmbeddedType() {
+ return EmbeddedDbType.valueOf(getProperty(OdeConfigProperties.PROP_DB_EMBEDDED_TYPE, DEFAULT_DB_EMB_TYPE).trim().toUpperCase());
+ }
+
+ public boolean isDbEmbeddedCreate() {
+ return Boolean.valueOf(getProperty(OdeConfigProperties.PROP_DB_EMBEDDED_CREATE, "true"));
+ }
+
public DatabaseMode getDbMode() {
return DatabaseMode.valueOf(getProperty(OdeConfigProperties.PROP_DB_MODE, DatabaseMode.EMBEDDED.toString()).trim()
.toUpperCase());
}
public String getDAOConnectionFactory() {
- return getProperty(PROP_DAOCF, __daoCfClass);
+ return getProperty(PROP_DAOCF, DEFAULT_DAOCF_CLASS);
}
+ public String getDAOConfStoreConnectionFactory() {
+ return getProperty(PROP_DAOCF_STORE, DEFAULT_DAOCF_STORE_CLASS);
+ }
+
+
public String getDbDataSource() {
return getProperty(OdeConfigProperties.PROP_DB_EXTERNAL_DS, "java:comp/env/jdbc/ode-ds");
}
Modified: branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/dbutil/Database.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/dbutil/Database.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/dbutil/Database.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -19,30 +19,19 @@
package org.apache.ode.il.dbutil;
import java.io.File;
-import java.sql.SQLException;
-import java.util.Properties;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import javax.transaction.TransactionManager;
-import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.derby.jdbc.EmbeddedDriver;
-import org.apache.geronimo.connector.outbound.GenericConnectionManager;
-import org.apache.geronimo.connector.outbound.connectionmanagerconfig.LocalTransactions;
-import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport;
-import org.apache.geronimo.connector.outbound.connectionmanagerconfig.SinglePool;
-import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport;
-import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
-import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator;
-import org.apache.geronimo.transaction.manager.RecoverableTransactionManager;
-import org.apache.ode.bpel.dao.BpelDAOConnectionFactoryJDBC;
+import org.apache.ode.dao.bpel.BpelDAOConnectionFactory;
+import org.apache.ode.dao.store.ConfStoreDAOConnectionFactory;
import org.apache.ode.il.config.OdeConfigProperties;
import org.apache.ode.utils.LoggingInterceptor;
-import org.tranql.connector.jdbc.JDBCDriverMCF;
+
/**
* Does the dirty work of setting up / obtaining a DataSource based on the configuration in the {@link OdeConfigProperties} object.
*
@@ -54,15 +43,11 @@
private static final Messages __msgs = Messages.getMessages(Messages.class);
- private static final int CONNECTION_MAX_WAIT_MILLIS = 30000;
-
- private static final int CONNECTION_MAX_IDLE_MINUTES = 5;
-
private OdeConfigProperties _odeConfig;
private boolean _started;
- private GenericConnectionManager _connectionManager;
+ private DatabaseConnectionManager _connectionManager;
private TransactionManager _txm;
@@ -70,9 +55,9 @@
private File _workRoot;
- private boolean _needDerbyShutdown;
+ private boolean _needShutdown;
- private String _derbyUrl;
+ private EmbeddedDatabase _embeddedDB;
public Database(OdeConfigProperties props) {
if (props == null)
@@ -93,7 +78,7 @@
if (_started)
return;
- _needDerbyShutdown = false;
+ _needShutdown = false;
_datasource = null;
_connectionManager = null;
@@ -102,42 +87,35 @@
}
public synchronized void shutdown() {
- if (!_started)
- return;
+ if (!_started) {
+ return;
+ }
- if (_connectionManager != null)
- try {
- __log.debug("Stopping connection manager");
- _connectionManager.doStop();
- } catch (Throwable t) {
- __log.warn("Exception while stopping connection manager: " + t.getMessage());
- } finally {
- _connectionManager = null;
- }
+ if (_connectionManager != null) {
+ try {
+ __log.debug("Stopping connection manager");
+ _connectionManager.shutdown();
+ } catch (Throwable t) {
+ __log.warn("Exception while stopping connection manager: " + t.getMessage());
+ } finally {
+ _connectionManager = null;
+ }
+ }
- if (_needDerbyShutdown) {
- __log.debug("shutting down derby.");
- EmbeddedDriver driver = new EmbeddedDriver();
- try {
- driver.connect(_derbyUrl + ";shutdown=true", new Properties());
- } catch (SQLException ex) {
- // Shutdown will always return an exeption!
- if (ex.getErrorCode() != 45000)
- __log.error("Error shutting down Derby: " + ex.getErrorCode(), ex);
+ if (_needShutdown) {
+ __log.debug("shutting down database.");
+ _embeddedDB.shutdown();
- } catch (Throwable ex) {
- __log.debug("Error shutting down Derby.", ex);
- }
- }
+ }
- _needDerbyShutdown = false;
+ _needShutdown = false;
_datasource = null;
_started = false;
}
public DataSource getDataSource() {
- //return __logSql.isDebugEnabled() ? new LoggingDataSourceWrapper(_datasource, __logSql) : _datasource;
- return __logSql.isDebugEnabled() ? LoggingInterceptor.createLoggingDS(_datasource, __logSql) : _datasource;
+ DataSource ds = __logSql.isDebugEnabled() ? LoggingInterceptor.createLoggingDS(_datasource, __logSql) : _datasource;
+ return ds;
}
private void initDataSource() throws DatabaseConfigException {
@@ -159,7 +137,7 @@
private void initExternalDb() throws DatabaseConfigException {
try {
_datasource = (DataSource) lookupInJndi(_odeConfig.getDbDataSource());
- __log.info(__msgs.msgOdeUsingExternalDb(_odeConfig.getDbDataSource()));
+ __log.debug(__msgs.msgOdeUsingExternalDb(_odeConfig.getDbDataSource()));
} catch (Exception ex) {
String msg = __msgs.msgOdeInitExternalDbFailed(_odeConfig.getDbDataSource());
__log.error(msg, ex);
@@ -168,87 +146,34 @@
}
private void initInternalDb() throws DatabaseConfigException {
- __log.info(__msgs.msgOdeUsingInternalDb(_odeConfig.getDbIntenralJdbcUrl(), _odeConfig.getDbInternalJdbcDriverClass()));
+ __log.debug(__msgs.msgOdeUsingInternalDb(_odeConfig.getDbIntenralJdbcUrl(), _odeConfig.getDbInternalJdbcDriverClass()));
initInternalDb(_odeConfig.getDbIntenralJdbcUrl(), _odeConfig.getDbInternalJdbcDriverClass(),
_odeConfig.getDbInternalUserName(), _odeConfig.getDbInternalPassword());
+
}
private void initInternalDb(String url, String driverClass, String username,String password) throws DatabaseConfigException {
-
- __log.debug("Creating connection pool for " + url + " with driver " + driverClass);
- if (!(_txm instanceof RecoverableTransactionManager)) {
- throw new RuntimeException("TransactionManager is not recoverable.");
- }
-
- TransactionSupport transactionSupport = LocalTransactions.INSTANCE;
- ConnectionTracker connectionTracker = new ConnectionTrackingCoordinator();
-
- PoolingSupport poolingSupport = new SinglePool(
- _odeConfig.getPoolMaxSize(),
- _odeConfig.getPoolMinSize(),
- CONNECTION_MAX_WAIT_MILLIS,
- CONNECTION_MAX_IDLE_MINUTES,
- true, // match one
- false, // match all
- false); // select one assume match
-
- _connectionManager = new GenericConnectionManager(
- transactionSupport,
- poolingSupport,
- null,
- connectionTracker,
- (RecoverableTransactionManager) _txm,
- getClass().getName(),
- getClass().getClassLoader());
-
-
- try {
- javax.resource.spi.ManagedConnectionFactory mcf = null;
- String mcfClass = _odeConfig.getDbInternalMCFClass();
- if (mcfClass != null) {
- Properties dbInternalMCFProps = _odeConfig.getDbInternalMCFProperties();
- if (__log.isDebugEnabled()) {
- __log.debug("Using internal DB MCF " + mcfClass + " " + dbInternalMCFProps);
- }
- mcf = (javax.resource.spi.ManagedConnectionFactory) Class.forName(mcfClass).newInstance();
- BeanUtils.copyProperties(mcf, dbInternalMCFProps);
- } else {
- if (__log.isDebugEnabled()) {
- __log.debug("Using internal DB JDBCDriverMCF");
- }
- JDBCDriverMCF mcf2 = new JDBCDriverMCF();
- mcf = mcf2;
- mcf2.setDriver(driverClass);
- mcf2.setConnectionURL(url);
- if (username != null) {
- mcf2.setUserName(username);
- }
- if (password != null) {
- mcf2.setPassword(password);
- }
- }
- _connectionManager.doStart();
- _datasource = (DataSource) mcf.createConnectionFactory(_connectionManager);
- } catch (Exception ex) {
- String errmsg = __msgs.msgOdeDbPoolStartupFailed(url);
- __log.error(errmsg, ex);
- throw new DatabaseConfigException(errmsg, ex);
- }
+ _connectionManager = new DatabaseConnectionManager(_txm,_odeConfig);
+ _connectionManager.init(url, driverClass, username, password);
+ _datasource = _connectionManager.getDataSource();
}
/**
* Initialize embedded (DERBY) database.
*/
- private void initEmbeddedDb() throws DatabaseConfigException {
+ private void initEmbeddedDb() throws DatabaseConfigException {
- String db = _odeConfig.getDbEmbeddedName();
-
- String url = "jdbc:derby:" + _workRoot + "/" + db ;
- __log.info("Using Embedded Derby: " + url);
- _derbyUrl = url;
- initInternalDb(url, org.apache.derby.jdbc.EmbeddedDriver.class.getName(),"sa",null);
- _needDerbyShutdown = true;
+ switch (_odeConfig.getDbEmbeddedType()) {
+ case DERBY:
+ _embeddedDB = new DerbyDatabase();
+ break;
+ default:
+ _embeddedDB = new H2Database();
}
+ _embeddedDB.init(_workRoot,_odeConfig,_txm);
+ _datasource = _embeddedDB.getDataSource();
+ _needShutdown = true;
+ }
@SuppressWarnings("unchecked")
private <T> T lookupInJndi(String objName) throws Exception {
@@ -272,24 +197,41 @@
}
}
- public BpelDAOConnectionFactoryJDBC createDaoCF() throws DatabaseConfigException {
+ public BpelDAOConnectionFactory createDaoCF() throws DatabaseConfigException {
String pClassName = _odeConfig.getDAOConnectionFactory();
- __log.info(__msgs.msgOdeUsingDAOImpl(pClassName));
+ __log.debug(__msgs.msgOdeUsingDAOImpl(pClassName));
- BpelDAOConnectionFactoryJDBC cf;
+ BpelDAOConnectionFactory cf;
try {
- cf = (BpelDAOConnectionFactoryJDBC) Class.forName(pClassName).newInstance();
+ cf = (BpelDAOConnectionFactory) Class.forName(pClassName).newInstance();
} catch (Exception ex) {
String errmsg = __msgs.msgDAOInstantiationFailed(pClassName);
__log.error(errmsg, ex);
throw new DatabaseConfigException(errmsg, ex);
}
- cf.setDataSource(getDataSource());
- cf.setTransactionManager(_txm);
- cf.init(_odeConfig.getProperties());
+ cf.init(_odeConfig.getProperties(),_txm,getDataSource());
return cf;
}
+
+ public ConfStoreDAOConnectionFactory createDaoStoreCF() throws DatabaseConfigException {
+ String pClassName = _odeConfig.getDAOConfStoreConnectionFactory();
+
+ __log.debug(__msgs.msgOdeUsingDAOImpl(pClassName));
+
+ ConfStoreDAOConnectionFactory cf;
+ try {
+ cf = (ConfStoreDAOConnectionFactory) Class.forName(pClassName).newInstance();
+ } catch (Exception ex) {
+ String errmsg = __msgs.msgDAOInstantiationFailed(pClassName);
+ __log.error(errmsg, ex);
+ throw new DatabaseConfigException(errmsg, ex);
+ }
+
+ cf.init(_odeConfig.getProperties(),_txm,getDataSource());
+ return cf;
+ }
+
}
Added: branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/dbutil/DatabaseConnectionManager.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/dbutil/DatabaseConnectionManager.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/dbutil/DatabaseConnectionManager.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,117 @@
+/*
+ * 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.il.dbutil;
+
+
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.connector.outbound.GenericConnectionManager;
+import org.apache.geronimo.connector.outbound.connectionmanagerconfig.LocalTransactions;
+import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport;
+import org.apache.geronimo.connector.outbound.connectionmanagerconfig.SinglePool;
+import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport;
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator;
+import org.apache.geronimo.transaction.manager.RecoverableTransactionManager;
+import org.apache.ode.il.config.OdeConfigProperties;
+import org.apache.ode.il.txutil.TxManager;
+import org.tranql.connector.jdbc.JDBCDriverMCF;
+
+public class DatabaseConnectionManager {
+
+ private static final long serialVersionUID = 1L;
+ private static final Log __log = LogFactory.getLog(DatabaseConnectionManager.class);
+ private static final Messages __msgs = Messages.getMessages(Messages.class);
+ private static final int CONNECTION_MAX_WAIT_MILLIS = 30000;
+ private static final int CONNECTION_MAX_IDLE_MINUTES = 5;
+ private GenericConnectionManager _connectionManager;
+ private TransactionManager _txm = null;
+ private String _url = null;
+ private OdeConfigProperties _odeConfig = null;
+ private DataSource _dataSource = null;
+
+ public DatabaseConnectionManager(TransactionManager txm, OdeConfigProperties odeConfig) {
+ _txm = txm;
+ _odeConfig = odeConfig;
+ }
+
+ public void init(String url, String driverClass, String username, String password) throws DatabaseConfigException {
+ __log.debug("Creating connection pool for " + url + " with driver " + driverClass);
+
+ if (!(_txm instanceof RecoverableTransactionManager)) {
+ throw new RuntimeException("TransactionManager is not recoverable.");
+ }
+
+ _url = url;
+ TransactionSupport transactionSupport = LocalTransactions.INSTANCE;
+ ConnectionTracker connectionTracker = new ConnectionTrackingCoordinator();
+
+ PoolingSupport poolingSupport = new SinglePool(
+ _odeConfig.getPoolMaxSize(),
+ _odeConfig.getPoolMinSize(),
+ CONNECTION_MAX_WAIT_MILLIS,
+ CONNECTION_MAX_IDLE_MINUTES,
+ true, // match one
+ false, // match all
+ false); // select one assume match
+
+ _connectionManager = new GenericConnectionManager(
+ transactionSupport,
+ poolingSupport,
+ null,
+ connectionTracker,
+ (RecoverableTransactionManager) _txm,
+ getClass().getName(),
+ getClass().getClassLoader());
+
+ JDBCDriverMCF mcf = new JDBCDriverMCF();
+ try {
+ mcf.setDriver(driverClass);
+ mcf.setConnectionURL(url);
+ if (username != null) {
+ mcf.setUserName(username);
+ }
+ if (password != null) {
+ mcf.setPassword(password);
+ }
+ _connectionManager.doStart();
+ _dataSource = (DataSource) mcf.createConnectionFactory(_connectionManager);
+ } catch (Exception ex) {
+ String errmsg = __msgs.msgOdeDbPoolStartupFailed(url);
+ __log.error(errmsg, ex);
+ throw new DatabaseConfigException(errmsg, ex);
+ }
+ }
+
+ public void shutdown() throws DatabaseConfigException {
+ try {
+ _connectionManager.doStop();
+ } catch (Exception ex) {
+ String errmsg = __msgs.msgOdeDbPoolStartupFailed(_url);
+ __log.error(errmsg, ex);
+ throw new DatabaseConfigException(errmsg, ex);
+ }
+ }
+
+ public DataSource getDataSource() {
+ return _dataSource;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/dbutil/DerbyDatabase.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/dbutil/DerbyDatabase.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/dbutil/DerbyDatabase.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,104 @@
+/*
+ * 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.il.dbutil;
+
+import java.io.File;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.derby.impl.io.VFMemoryStorageFactory;
+import org.apache.derby.jdbc.EmbeddedDataSource;
+import org.apache.ode.il.config.OdeConfigProperties;
+
+public class DerbyDatabase implements EmbeddedDatabase {
+
+ private static final Log __log = LogFactory.getLog(DerbyDatabase.class);
+ private DatabaseConnectionManager _connectionManager;
+ private String _dbUrl = null;
+ private DataSource _dataSource = null;
+ private File _workRoot = null;
+ private String _dbName = null;
+
+ public void init(File workRoot, OdeConfigProperties props, TransactionManager txm) {
+ _workRoot = workRoot;
+ _dbName = props.getDbEmbeddedName();
+ if (_workRoot == null) {
+ _dbUrl = "jdbc:derby:memory:" + _dbName + ";create=true";
+ try {
+ DriverManager.getConnection(_dbUrl).close();
+ } catch (SQLException se) {
+ __log.error(se);
+ }
+ EmbeddedDataSource dds = new EmbeddedDataSource();
+ dds.setDatabaseName("memory:" + _dbName);
+ dds.setUser("sa");
+ dds.setCreateDatabase("true");
+ _dataSource = dds;
+ } else {
+ _dbUrl = "jdbc:derby:" + _workRoot + File.separator + _dbName;
+ if (props.isDbEmbeddedCreate()) {
+ _dbUrl += ";create=true";
+ }
+ String clazz = org.apache.derby.jdbc.EmbeddedDriver.class.getName();
+ _connectionManager = new DatabaseConnectionManager(txm, props);
+ try {
+ _connectionManager.init(_dbUrl, clazz, "sa", null);
+ } catch (DatabaseConfigException ex) {
+ __log.error("Unable to initialize connection pool", ex);
+ }
+ _dataSource = _connectionManager.getDataSource();
+ __log.debug("Using Embedded Database: " + _dbUrl);
+ }
+ }
+
+ public void shutdown() {
+ if (_connectionManager != null) {
+ try {
+ _connectionManager.shutdown();
+ } catch (DatabaseConfigException ex) {
+ __log.error("unable to shutdown connection pool", ex);
+ }
+ }
+ try {
+ DriverManager.getConnection(_dbUrl + ";shutdown=true").close();
+ } catch (SQLException ex) {
+ // Shutdown will always return an exeption!
+ if (ex.getErrorCode() != 45000) {
+ __log.error("Error shutting down Derby: " + ex.getErrorCode(), ex);
+ }
+ } catch (Throwable ex) {
+ __log.debug("Error shutting down Derby.", ex);
+ }
+ if (_workRoot == null) {
+ try {
+ //Don't worry about File IO, this is only virtual
+ VFMemoryStorageFactory.purgeDatabase(new File(_dbName).getCanonicalPath());
+ } catch (Exception e) {
+ __log.debug("Error shutting down Derby.", e);
+ }
+ }
+ }
+
+ public DataSource getDataSource() {
+ return _dataSource;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/dbutil/EmbeddedDatabase.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/dbutil/EmbeddedDatabase.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/dbutil/EmbeddedDatabase.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,33 @@
+/*
+ * 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.il.dbutil;
+
+import java.io.File;
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+import org.apache.ode.il.config.OdeConfigProperties;
+
+public interface EmbeddedDatabase {
+
+ void init(File workRoot, OdeConfigProperties props, TransactionManager txm);
+
+ void shutdown();
+
+ DataSource getDataSource();
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/dbutil/H2Database.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/dbutil/H2Database.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/dbutil/H2Database.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,81 @@
+/*
+ * 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.il.dbutil;
+
+import java.io.File;
+import java.sql.Connection;
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.il.config.OdeConfigProperties;
+import org.h2.jdbcx.JdbcDataSource;
+
+public class H2Database implements EmbeddedDatabase {
+
+ private static final Log __log = LogFactory.getLog(H2Database.class);
+ private DatabaseConnectionManager _connectionManager;
+ private String _dbUrl = null;
+ private DataSource _dataSource = null;
+
+ public void init(File workRoot, OdeConfigProperties props, TransactionManager txm) {
+ String db = props.getDbEmbeddedName();
+ if (workRoot == null) {
+ _dbUrl = "jdbc:h2:mem:" + db + ";DB_CLOSE_DELAY=-1";
+ JdbcDataSource hds = new JdbcDataSource();
+ hds.setURL(_dbUrl);
+ hds.setUser("sa");
+ _dataSource = hds;
+ } else {
+ _dbUrl = "jdbc:h2:" + workRoot + File.separator + db;
+ if (!props.isDbEmbeddedCreate()) {
+ _dbUrl += ";IFEXISTS=TRUE";
+ }
+ String clazz = org.h2.Driver.class.getName();
+ _connectionManager = new DatabaseConnectionManager(txm, props);
+ try {
+ _connectionManager.init(_dbUrl, clazz, "sa", null);
+ } catch (DatabaseConfigException ex) {
+ __log.error("Unable to initialize connection pool", ex);
+ }
+ _dataSource = _connectionManager.getDataSource();
+ }
+ __log.debug("Using Embedded Database: " + _dbUrl);
+ }
+
+ public void shutdown() {
+ if (_connectionManager != null) {
+ try {
+ _connectionManager.shutdown();
+ } catch (DatabaseConfigException ex) {
+ __log.error("unable to shutdown connection pool", ex);
+ }
+ }
+ try {
+ Connection conn = getDataSource().getConnection();
+ conn.createStatement().execute("SHUTDOWN");
+ } catch (Throwable ex) {
+ __log.debug("Error shutting down H2.", ex);
+ }
+ }
+
+ public DataSource getDataSource() {
+ return _dataSource;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/txutil/TransactionConfigException.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/txutil/TransactionConfigException.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/txutil/TransactionConfigException.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,29 @@
+/*
+ * 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.il.txutil;
+
+public class TransactionConfigException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ public TransactionConfigException(String msg, Exception ex) {
+ super(msg,ex);
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/txutil/TxManager.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/txutil/TxManager.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-epr/src/main/java/org/apache/ode/il/txutil/TxManager.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,173 @@
+/*
+ * 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.il.txutil;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.xa.XAResource;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.il.config.OdeConfigProperties;
+
+
+/**
+ * Does the dirty work of setting up / obtaining a TransactionManager based on the configuration in the {@link OdeConfigProperties} object.
+ *
+ */
+public class TxManager {
+ private static final Log __log = LogFactory.getLog(TxManager.class);
+
+ private OdeConfigProperties _odeConfig;
+ private boolean _debugTxn = false;
+
+
+ public TxManager(OdeConfigProperties props) {
+ if (props == null)
+ throw new NullPointerException("Must provide a configuration.");
+
+ _odeConfig = props;
+ _debugTxn=Boolean.valueOf(_odeConfig.getProperty("tx.debug","false"));
+ }
+
+
+ public TransactionManager createTransactionManager() throws TransactionConfigException {
+ String txFactoryName = _odeConfig.getTxFactoryClass();
+ __log.debug("Initializing transaction manager using " + txFactoryName);
+ try {
+ Class txFactClass = Class.forName(txFactoryName);
+ Object txFact = txFactClass.newInstance();
+ TransactionManager txMgr = (TransactionManager) txFactClass.getMethod("getTransactionManager", (Class[]) null).invoke(txFact);
+ if (__log.isDebugEnabled() && _debugTxn)
+ txMgr = new DebugTxMgr(txMgr);
+ return txMgr;
+ } catch (Exception e) {
+ __log.fatal("Couldn't initialize a transaction manager with factory: " + txFactoryName, e);
+ throw new TransactionConfigException("Couldn't initialize a transaction manager with factory: " + txFactoryName, e);
+ }
+ }
+
+
+ // Transactional debugging stuff, to track down all these little annoying bugs.
+ public static class DebugTxMgr implements TransactionManager {
+ protected TransactionManager _tm;
+
+ public DebugTxMgr(TransactionManager tm) {
+ _tm = tm;
+ }
+
+ public void begin() throws NotSupportedException, SystemException {
+ __log.debug("Txm begin");
+ _tm.begin();
+ }
+
+ public void commit() throws HeuristicMixedException, HeuristicRollbackException, IllegalStateException, RollbackException, SecurityException, SystemException {
+ __log.debug("Txm commit");
+ for (StackTraceElement traceElement : Thread.currentThread().getStackTrace()) {
+ __log.debug(traceElement.toString());
+ }
+ _tm.commit();
+ }
+
+ public int getStatus() throws SystemException {
+ __log.debug("Txm status");
+ return _tm.getStatus();
+ }
+
+ public Transaction getTransaction() throws SystemException {
+ Transaction tx = _tm.getTransaction();
+ __log.debug("Txm get tx " + tx);
+ return tx == null ? null : new DebugTx(tx);
+ }
+
+ public void resume(Transaction transaction) throws IllegalStateException, InvalidTransactionException, SystemException {
+ __log.debug("Txm resume");
+ _tm.resume(transaction);
+ }
+
+ public void rollback() throws IllegalStateException, SecurityException, SystemException {
+ __log.debug("Txm rollback");
+ _tm.rollback();
+ }
+
+ public void setRollbackOnly() throws IllegalStateException, SystemException {
+ __log.debug("Txm set rollback");
+ _tm.setRollbackOnly();
+ }
+
+ public void setTransactionTimeout(int i) throws SystemException {
+ __log.debug("Txm set tiemout " + i);
+ _tm.setTransactionTimeout(i);
+ }
+
+ public Transaction suspend() throws SystemException {
+ __log.debug("Txm suspend");
+ return _tm.suspend();
+ }
+ }
+
+ public static class DebugTx implements Transaction {
+ private Transaction _tx;
+
+ public DebugTx(Transaction tx) {
+ _tx = tx;
+ }
+
+ public void commit() throws HeuristicMixedException, HeuristicRollbackException, RollbackException, SecurityException, SystemException {
+ __log.debug("Tx commit");
+ _tx.commit();
+ }
+
+ public boolean delistResource(XAResource xaResource, int i) throws IllegalStateException, SystemException {
+ return _tx.delistResource(xaResource, i);
+ }
+
+ public boolean enlistResource(XAResource xaResource) throws IllegalStateException, RollbackException, SystemException {
+ return _tx.enlistResource(xaResource);
+ }
+
+ public int getStatus() throws SystemException {
+ return _tx.getStatus();
+ }
+
+ public void registerSynchronization(Synchronization synchronization) throws IllegalStateException, RollbackException, SystemException {
+ __log.debug("Synchronization registration on " + synchronization.getClass().getName());
+ _tx.registerSynchronization(synchronization);
+ }
+
+ public void rollback() throws IllegalStateException, SystemException {
+ __log.debug("Tx rollback");
+ _tx.rollback();
+ }
+
+ public void setRollbackOnly() throws IllegalStateException, SystemException {
+ __log.debug("Tx set rollback");
+ _tx.setRollbackOnly();
+ }
+ }
+
+}
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/pom.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/pom.xml 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/pom.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -95,8 +95,8 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -202,13 +202,26 @@
<artifactId>tranql-connector-derby-common</artifactId>
<version>1.1</version>
<scope>test</scope>
- </dependency>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.components</groupId>
+ <artifactId>geronimo-transaction</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
-
- <build>
- <plugins>
-
- </plugins>
- </build>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>**/ActivityRecoveryTest.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelDatabase.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelDatabase.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelDatabase.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -22,9 +22,9 @@
import javax.xml.namespace.QName;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.BpelDAOConnectionFactory;
import org.apache.ode.bpel.iapi.Scheduler;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.BpelDAOConnectionFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -34,9 +34,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
import org.apache.ode.bpel.evt.BpelEvent;
import org.apache.ode.bpel.iapi.BpelEngine;
import org.apache.ode.bpel.iapi.BpelEngineException;
@@ -61,6 +58,9 @@
import org.apache.ode.bpel.o.OPartnerLink;
import org.apache.ode.bpel.o.OProcess;
import org.apache.ode.bpel.runtime.InvalidProcessException;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
import org.apache.ode.utils.DOMUtils;
import org.apache.ode.utils.Namespaces;
import org.apache.ode.utils.msg.MessageBundle;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelManagementFacadeImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelManagementFacadeImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelManagementFacadeImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -22,13 +22,13 @@
import org.apache.ode.bpel.bdi.breaks.Breakpoint;
import org.apache.ode.bpel.bdi.breaks.VariableModificationBreakpoint;
import org.apache.ode.bpel.common.CorrelationKey;
-import org.apache.ode.bpel.dao.*;
import org.apache.ode.bpel.iapi.BpelServer;
import org.apache.ode.bpel.iapi.ProcessStore;
import org.apache.ode.bpel.o.OProcess;
import org.apache.ode.bpel.pmapi.*;
import org.apache.ode.bpel.pmapi.TInstanceInfo.EventInfo;
import org.apache.ode.bpel.runtime.breaks.ActivityBreakpointImpl;
+import org.apache.ode.dao.bpel.*;
import org.apache.ode.utils.DOMUtils;
import org.apache.ode.utils.uuid.UUIDGen;
import org.w3c.dom.Node;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -38,10 +38,6 @@
import org.apache.ode.agents.memory.SizingAgent;
import org.apache.ode.bpel.common.FaultException;
import org.apache.ode.bpel.common.ProcessState;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.DeferredProcessInstanceCleanable;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
import org.apache.ode.bpel.engine.extvar.ExternalVariableConf;
import org.apache.ode.bpel.engine.extvar.ExternalVariableManager;
import org.apache.ode.bpel.evt.ProcessInstanceEvent;
@@ -69,6 +65,10 @@
import org.apache.ode.bpel.runtime.PROCESS;
import org.apache.ode.bpel.runtime.PropertyAliasEvaluationContext;
import org.apache.ode.bpel.runtime.channels.FaultData;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.DeferredProcessInstanceCleanable;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
import org.apache.ode.jacob.soup.ReplacementMap;
import org.apache.ode.utils.ObjectPrinter;
import org.apache.ode.utils.Properties;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcessDatabase.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcessDatabase.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcessDatabase.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -18,9 +18,9 @@
*/
package org.apache.ode.bpel.engine;
-import org.apache.ode.bpel.dao.BpelDAOConnectionFactory;
-import org.apache.ode.bpel.dao.ProcessDAO;
import org.apache.ode.bpel.iapi.Scheduler;
+import org.apache.ode.dao.bpel.BpelDAOConnectionFactory;
+import org.apache.ode.dao.bpel.ProcessDAO;
import javax.xml.namespace.QName;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -39,16 +39,6 @@
import org.apache.ode.bpel.common.CorrelationKeySet;
import org.apache.ode.bpel.common.FaultException;
import org.apache.ode.bpel.common.ProcessState;
-import org.apache.ode.bpel.dao.CorrelationSetDAO;
-import org.apache.ode.bpel.dao.CorrelatorDAO;
-import org.apache.ode.bpel.dao.MessageDAO;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
-import org.apache.ode.bpel.dao.MessageRouteDAO;
-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.ScopeDAO;
-import org.apache.ode.bpel.dao.XmlDataDAO;
import org.apache.ode.bpel.evar.ExternalVariableModuleException;
import org.apache.ode.bpel.evar.ExternalVariableModule.Value;
import org.apache.ode.bpel.evt.CorrelationSetWriteEvent;
@@ -102,6 +92,16 @@
import org.apache.ode.utils.ObjectPrinter;
import org.apache.ode.bpel.evar.ExternalVariableModuleException;
import org.apache.ode.bpel.evar.ExternalVariableModule.Value;
+import org.apache.ode.dao.bpel.CorrelationSetDAO;
+import org.apache.ode.dao.bpel.CorrelatorDAO;
+import org.apache.ode.dao.bpel.MessageDAO;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
+import org.apache.ode.dao.bpel.MessageRouteDAO;
+import org.apache.ode.dao.bpel.PartnerLinkDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.ScopeDAO;
+import org.apache.ode.dao.bpel.XmlDataDAO;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -35,10 +35,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.BpelDAOConnectionFactory;
-import org.apache.ode.bpel.dao.DeferredProcessInstanceCleanable;
-import org.apache.ode.bpel.dao.ProcessDAO;
import org.apache.ode.bpel.engine.cron.CronScheduler;
import org.apache.ode.bpel.engine.migration.MigrationHandler;
import org.apache.ode.bpel.evar.ExternalVariableModule;
@@ -59,6 +55,10 @@
import org.apache.ode.bpel.iapi.Scheduler.Synchronizer;
import org.apache.ode.bpel.intercept.MessageExchangeInterceptor;
import org.apache.ode.bpel.o.OProcess;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.BpelDAOConnectionFactory;
+import org.apache.ode.dao.bpel.DeferredProcessInstanceCleanable;
+import org.apache.ode.dao.bpel.ProcessDAO;
import org.apache.ode.utils.msg.MessageBundle;
import org.apache.ode.utils.stl.CollectionsX;
import org.apache.ode.utils.stl.MemberOfFunction;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BrokeredMyRoleMessageExchangeImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BrokeredMyRoleMessageExchangeImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BrokeredMyRoleMessageExchangeImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -28,12 +28,12 @@
import javax.wsdl.Operation;
import javax.wsdl.PortType;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
import org.apache.ode.bpel.iapi.BpelEngineException;
import org.apache.ode.bpel.iapi.EndpointReference;
import org.apache.ode.bpel.iapi.Message;
import org.apache.ode.bpel.iapi.MyRoleMessageExchange;
import org.apache.ode.bpel.iapi.ProcessState;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
/**
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -19,7 +19,6 @@
package org.apache.ode.bpel.engine;
-import org.apache.ode.bpel.dao.BpelDAOConnectionFactory;
import org.apache.ode.bpel.iapi.BindingContext;
import org.apache.ode.bpel.iapi.BpelEventListener;
import org.apache.ode.bpel.iapi.EndpointReferenceContext;
@@ -28,6 +27,7 @@
import org.apache.ode.bpel.intercept.MessageExchangeInterceptor;
import org.apache.ode.bpel.engine.cron.CronScheduler;
import org.apache.ode.bpel.evar.ExternalVariableModule;
+import org.apache.ode.dao.bpel.BpelDAOConnectionFactory;
import java.util.HashMap;
import java.util.List;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/DebuggerSupport.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/DebuggerSupport.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/DebuggerSupport.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -23,9 +23,6 @@
import org.apache.ode.bpel.iapi.DebuggerContext;
import org.apache.ode.bpel.bdi.breaks.Breakpoint;
import org.apache.ode.bpel.common.ProcessState;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
import org.apache.ode.bpel.evt.ActivityExecStartEvent;
import org.apache.ode.bpel.evt.BpelEvent;
import org.apache.ode.bpel.evt.ProcessCompletionEvent;
@@ -39,6 +36,9 @@
import org.apache.ode.bpel.pmapi.ManagementException;
import org.apache.ode.bpel.pmapi.ProcessingException;
import org.apache.ode.bpel.runtime.breaks.BreakpointImpl;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
import org.apache.ode.utils.CollectionUtils;
import org.apache.ode.utils.msg.MessageBundle;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/InterceptorContextImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/InterceptorContextImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/InterceptorContextImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -18,11 +18,11 @@
*/
package org.apache.ode.bpel.engine;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.ProcessDAO;
import org.apache.ode.bpel.iapi.BpelEngine;
import org.apache.ode.bpel.iapi.ProcessConf;
import org.apache.ode.bpel.intercept.MessageExchangeInterceptor.InterceptorContext;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.ProcessDAO;
/**
* Implementation of the {@link org.apache.ode.bpel.intercept.MessageExchangeInterceptor.InterceptorContext}
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MessageExchangeImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MessageExchangeImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MessageExchangeImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -21,12 +21,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.dao.MessageDAO;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
import org.apache.ode.bpel.iapi.BpelEngineException;
import org.apache.ode.bpel.iapi.EndpointReference;
import org.apache.ode.bpel.iapi.Message;
import org.apache.ode.bpel.iapi.MessageExchange;
+import org.apache.ode.dao.bpel.MessageDAO;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
import org.apache.ode.utils.msg.MessageBundle;
import org.w3c.dom.Element;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MessageImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MessageImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MessageImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -31,8 +31,8 @@
import org.w3c.dom.Node;
import org.w3c.dom.Document;
-import org.apache.ode.bpel.dao.MessageDAO;
import org.apache.ode.bpel.iapi.Message;
+import org.apache.ode.dao.bpel.MessageDAO;
import org.apache.ode.utils.DOMUtils;
public class MessageImpl implements Message {
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MexDaoUtil.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MexDaoUtil.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MexDaoUtil.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -21,12 +21,12 @@
import javax.xml.namespace.QName;
-import org.apache.ode.bpel.dao.MessageDAO;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
import org.apache.ode.bpel.iapi.Message;
import org.apache.ode.bpel.iapi.MessageExchange;
import org.apache.ode.bpel.iapi.MessageExchange.FailureType;
import org.apache.ode.bpel.iapi.MessageExchange.Status;
+import org.apache.ode.dao.bpel.MessageDAO;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
import org.w3c.dom.Element;
/**
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -33,7 +33,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
import org.apache.ode.bpel.engine.replayer.Replayer;
import org.apache.ode.bpel.iapi.Message;
import org.apache.ode.bpel.iapi.MessageExchange;
@@ -46,6 +45,7 @@
import org.apache.ode.bpel.intercept.InterceptorInvoker;
import org.apache.ode.bpel.intercept.MessageExchangeInterceptor;
import org.apache.ode.bpel.intercept.MessageExchangeInterceptor.InterceptorContext;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/PartnerLinkMyRoleImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/PartnerLinkMyRoleImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/PartnerLinkMyRoleImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -34,10 +34,6 @@
import org.apache.ode.bpel.common.FaultException;
import org.apache.ode.bpel.common.InvalidMessageException;
import org.apache.ode.bpel.common.OptionalCorrelationKey;
-import org.apache.ode.bpel.dao.CorrelatorDAO;
-import org.apache.ode.bpel.dao.MessageRouteDAO;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
import org.apache.ode.bpel.evt.CorrelationMatchEvent;
import org.apache.ode.bpel.evt.CorrelationNoMatchEvent;
import org.apache.ode.bpel.evt.NewProcessInstanceEvent;
@@ -52,6 +48,10 @@
import org.apache.ode.bpel.o.OScope;
import org.apache.ode.bpel.runtime.InvalidProcessException;
import org.apache.ode.bpel.runtime.PROCESS;
+import org.apache.ode.dao.bpel.CorrelatorDAO;
+import org.apache.ode.dao.bpel.MessageRouteDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
import org.apache.ode.utils.ObjectPrinter;
import org.apache.ode.utils.msg.MessageBundle;
import org.w3c.dom.Element;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/PartnerRoleMessageExchangeImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/PartnerRoleMessageExchangeImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/PartnerRoleMessageExchangeImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -21,7 +21,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
import org.apache.ode.bpel.engine.WorkEvent.Type;
import org.apache.ode.bpel.engine.replayer.Replayer;
import org.apache.ode.bpel.iapi.BpelEngineException;
@@ -29,6 +28,7 @@
import org.apache.ode.bpel.iapi.Message;
import org.apache.ode.bpel.iapi.PartnerRoleChannel;
import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
import org.apache.ode.utils.DOMUtils;
import org.w3c.dom.Element;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -44,16 +44,6 @@
import org.apache.ode.bpel.common.Filter;
import org.apache.ode.bpel.common.InstanceFilter;
import org.apache.ode.bpel.common.ProcessFilter;
-import org.apache.ode.bpel.dao.ActivityRecoveryDAO;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.CorrelationSetDAO;
-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.ScopeDAO;
-import org.apache.ode.bpel.dao.XmlDataDAO;
-import org.apache.ode.bpel.dao.ProcessManagementDAO.FailedSummaryValue;
-import org.apache.ode.bpel.dao.ProcessManagementDAO.InstanceSummaryKey;
import org.apache.ode.bpel.engine.replayer.Replayer;
import org.apache.ode.bpel.evt.ActivityEvent;
import org.apache.ode.bpel.evt.BpelEvent;
@@ -133,6 +123,16 @@
import org.apache.ode.bpel.pmapi.TVariableInfo;
import org.apache.ode.bpel.pmapi.TVariableRef;
import org.apache.ode.bpel.pmapi.VariableInfoDocument;
+import org.apache.ode.dao.bpel.ActivityRecoveryDAO;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.CorrelationSetDAO;
+import org.apache.ode.dao.bpel.PartnerLinkDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.ScopeDAO;
+import org.apache.ode.dao.bpel.XmlDataDAO;
+import org.apache.ode.dao.bpel.ProcessManagementDAO.FailedSummaryValue;
+import org.apache.ode.dao.bpel.ProcessManagementDAO.InstanceSummaryKey;
import org.apache.ode.utils.ISO8601DateParser;
import org.apache.ode.utils.msg.MessageBundle;
import org.apache.ode.utils.stl.CollectionsX;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessCleanUpRunnable.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessCleanUpRunnable.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessCleanUpRunnable.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -6,10 +6,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.dao.DeferredProcessInstanceCleanable;
-import org.apache.ode.bpel.dao.ProcessDAO;
import org.apache.ode.bpel.engine.BpelServerImpl.ContextsAware;
import org.apache.ode.bpel.iapi.Scheduler.MapSerializableRunnable;
+import org.apache.ode.dao.bpel.DeferredProcessInstanceCleanable;
+import org.apache.ode.dao.bpel.ProcessDAO;
public class ProcessCleanUpRunnable implements MapSerializableRunnable, ContextsAware {
private static final long serialVersionUID = 1L;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessStatusConverter.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessStatusConverter.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessStatusConverter.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -24,10 +24,10 @@
import java.util.Map;
import org.apache.ode.bpel.common.ProcessState;
-import org.apache.ode.bpel.dao.ScopeStateEnum;
import org.apache.ode.bpel.pmapi.ProcessingException;
import org.apache.ode.bpel.pmapi.TInstanceStatus;
import org.apache.ode.bpel.pmapi.TScopeStatus;
+import org.apache.ode.dao.bpel.ScopeStateEnum;
/**
* Class for converting status codes from external (PMAPI) to internal (DAO) representation.
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/cron/RuntimeDataCleanupRunnable.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/cron/RuntimeDataCleanupRunnable.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/cron/RuntimeDataCleanupRunnable.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -9,13 +9,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ode.bpel.common.InstanceFilter;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.FilteredInstanceDeletable;
import org.apache.ode.bpel.engine.Contexts;
import org.apache.ode.bpel.engine.BpelServerImpl.ContextsAware;
import org.apache.ode.bpel.iapi.ProcessConf.CLEANUP_CATEGORY;
import org.apache.ode.bpel.iapi.ProcessConf.CleanupInfo;
import org.apache.ode.bpel.iapi.Scheduler.MapSerializableRunnable;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.FilteredInstanceDeletable;
public class RuntimeDataCleanupRunnable implements MapSerializableRunnable, ContextsAware {
private final Log _log = LogFactory.getLog(RuntimeDataCleanupRunnable.class);
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/CorrelationKeyMigration.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/CorrelationKeyMigration.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/CorrelationKeyMigration.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -22,10 +22,10 @@
import org.apache.ode.bpel.engine.BpelProcess;
import org.apache.ode.bpel.engine.ReplacementMapImpl;
import org.apache.ode.bpel.engine.OutstandingRequestManager;
-import org.apache.ode.bpel.dao.*;
import org.apache.ode.bpel.common.CorrelationKey;
import org.apache.ode.bpel.o.*;
import org.apache.ode.bpel.runtime.Selector;
+import org.apache.ode.dao.bpel.*;
import org.apache.ode.jacob.vpu.ExecutionQueueImpl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/CorrelationKeySetDataMigration.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/CorrelationKeySetDataMigration.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/CorrelationKeySetDataMigration.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -20,13 +20,13 @@
package org.apache.ode.bpel.engine.migration;
import org.apache.ode.bpel.engine.BpelProcess;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.dao.CorrelatorDAO;
-import org.apache.ode.bpel.dao.MessageRouteDAO;
import org.apache.ode.bpel.o.OPartnerLink;
import org.apache.ode.bpel.common.CorrelationKey;
import org.apache.ode.bpel.common.CorrelationKeySet;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.CorrelatorDAO;
+import org.apache.ode.dao.bpel.MessageRouteDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/CorrelationKeySetMigration.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/CorrelationKeySetMigration.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/CorrelationKeySetMigration.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -22,13 +22,13 @@
import org.apache.ode.bpel.engine.BpelProcess;
import org.apache.ode.bpel.engine.OutstandingRequestManager;
import org.apache.ode.bpel.engine.ReplacementMapImpl;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
-import org.apache.ode.bpel.dao.ProcessDAO;
import org.apache.ode.bpel.runtime.Selector;
import org.apache.ode.bpel.common.CorrelationKey;
import org.apache.ode.bpel.common.CorrelationKeySet;
import org.apache.ode.bpel.o.OProcess;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
import org.apache.ode.jacob.vpu.ExecutionQueueImpl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/CorrelatorsMigration.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/CorrelatorsMigration.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/CorrelatorsMigration.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -20,10 +20,10 @@
package org.apache.ode.bpel.engine.migration;
import org.apache.ode.bpel.engine.BpelProcess;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.dao.CorrelatorDAO;
import org.apache.ode.bpel.o.OPartnerLink;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.CorrelatorDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/Migration.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/Migration.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/Migration.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -20,7 +20,7 @@
package org.apache.ode.bpel.engine.migration;
import org.apache.ode.bpel.engine.BpelProcess;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
import java.util.Set;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/MigrationHandler.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/MigrationHandler.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/MigrationHandler.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -61,7 +61,7 @@
}
public boolean migrate(final Set<BpelProcess> registeredProcesses, int migrationTransactionTimeout) {
- if (_contexts.dao.getDataSource() == null) {
+ if (_contexts.dao.getConnection() == null) {
__log.debug("No datasource available, stopping migration. Probably running fully in-memory.");
return true;
}
@@ -153,7 +153,7 @@
PreparedStatement stmt = null;
ResultSet rs = null;
try {
- conn = _contexts.dao.getDataSource().getConnection();
+ conn = null; //FIXME jpa refactoring work leftover
stmt = conn.prepareStatement("SELECT VERSION FROM ODE_SCHEMA_VERSION");
rs = stmt.executeQuery();
if (rs.next()) version = rs.getInt("VERSION");
@@ -175,7 +175,7 @@
Connection conn = null;
Statement stmt = null;
try {
- conn = _contexts.dao.getDataSource().getConnection();
+ conn = null;//FIXME jpa refactoring work leftover
stmt = conn.createStatement();
int res = stmt.executeUpdate("UPDATE ODE_SCHEMA_VERSION SET VERSION = " + version);
// This should never happen but who knows?
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/OutstandingRequestsMigration.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/OutstandingRequestsMigration.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/migration/OutstandingRequestsMigration.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -27,12 +27,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
import org.apache.ode.bpel.engine.BpelProcess;
import org.apache.ode.bpel.engine.IMAManager;
import org.apache.ode.bpel.engine.OutstandingRequestManager;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
import org.apache.ode.jacob.vpu.ExecutionQueueImpl;
/**
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/replayer/Replayer.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/replayer/Replayer.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/replayer/Replayer.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -32,10 +32,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
import org.apache.ode.bpel.engine.BpelEngineImpl;
import org.apache.ode.bpel.engine.BpelProcess;
import org.apache.ode.bpel.engine.MyRoleMessageExchangeImpl;
@@ -55,6 +51,10 @@
import org.apache.ode.bpel.pmapi.Replay;
import org.apache.ode.bpel.pmapi.CommunicationType.Exchange;
import org.apache.ode.bpel.runtime.PROCESS;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
import org.apache.xmlbeans.XmlCalendar;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/replayer/ReplayerBpelRuntimeContextImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/replayer/ReplayerBpelRuntimeContextImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/replayer/ReplayerBpelRuntimeContextImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -27,10 +27,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ode.bpel.common.FaultException;
-import org.apache.ode.bpel.dao.MessageDAO;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
-import org.apache.ode.bpel.dao.PartnerLinkDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
import org.apache.ode.bpel.engine.BpelEngineImpl;
import org.apache.ode.bpel.engine.BpelProcess;
import org.apache.ode.bpel.engine.BpelRuntimeContextImpl;
@@ -50,6 +46,10 @@
import org.apache.ode.bpel.runtime.channels.InvokeResponseChannel;
import org.apache.ode.bpel.runtime.channels.PickResponseChannel;
import org.apache.ode.bpel.runtime.channels.TimerResponseChannel;
+import org.apache.ode.dao.bpel.MessageDAO;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
+import org.apache.ode.dao.bpel.PartnerLinkDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
import org.apache.ode.jacob.JacobRunnable;
import org.apache.ode.utils.DOMUtils;
import org.apache.ode.utils.GUID;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/replayer/ReplayerContext.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/replayer/ReplayerContext.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/replayer/ReplayerContext.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -37,8 +37,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
import org.apache.ode.bpel.engine.BpelEngineImpl;
import org.apache.ode.bpel.engine.BpelProcess;
import org.apache.ode.bpel.engine.MyRoleMessageExchangeImpl;
@@ -53,6 +51,8 @@
import org.apache.ode.bpel.pmapi.CommunicationType.Exchange;
import org.apache.ode.bpel.pmapi.CommunicationType.ServiceConfig;
import org.apache.ode.bpel.runtime.PROCESS;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
import org.apache.ode.utils.DOMUtils;
import org.apache.xmlbeans.XmlAnySimpleType;
import org.apache.xmlbeans.XmlObject;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/replayer/ReplayerScheduler.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/replayer/ReplayerScheduler.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/replayer/ReplayerScheduler.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -26,9 +26,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
import org.apache.ode.bpel.iapi.ContextException;
import org.apache.ode.bpel.iapi.Scheduler;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
/**
* Manages events invocation in sorted order during replaying.
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/MessageExchangeInterceptor.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/MessageExchangeInterceptor.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/MessageExchangeInterceptor.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -18,13 +18,13 @@
*/
package org.apache.ode.bpel.intercept;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.ProcessDAO;
import org.apache.ode.bpel.engine.BpelProcess;
import org.apache.ode.bpel.iapi.BpelEngine;
import org.apache.ode.bpel.iapi.MyRoleMessageExchange;
import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange;
import org.apache.ode.bpel.iapi.ProcessConf;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.ProcessDAO;
/**
* Hook into the BPEL server that enables intercepting of message exchange
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionFactoryImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionFactoryImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionFactoryImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -18,12 +18,14 @@
*/
package org.apache.ode.bpel.memdao;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.BpelDAOConnectionFactory;
import org.apache.ode.bpel.iapi.Scheduler;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.BpelDAOConnectionFactory;
import javax.xml.namespace.QName;
import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
@@ -50,7 +52,7 @@
}
/**
- * @see org.apache.ode.bpel.dao.BpelDAOConnectionFactory#init(java.util.Properties)
+ * @see org.apache.ode.dao.bpel.BpelDAOConnectionFactory#init(java.util.Properties)
*/
public void init(Properties properties) {
}
@@ -61,4 +63,8 @@
public DataSource getDataSource() {
return null;
}
+
+ public void init(Properties p, TransactionManager txm, Object envCtx) {
+
+ }
}
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -24,14 +24,14 @@
import org.apache.ode.bpel.common.Filter;
import org.apache.ode.bpel.common.InstanceFilter;
import org.apache.ode.bpel.common.ProcessFilter;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.CorrelationSetDAO;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
-import org.apache.ode.bpel.dao.ScopeDAO;
import org.apache.ode.bpel.evt.BpelEvent;
import org.apache.ode.bpel.iapi.Scheduler;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.CorrelationSetDAO;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.ScopeDAO;
import org.apache.ode.utils.ISO8601DateParser;
import org.apache.ode.utils.stl.CollectionsX;
import org.apache.ode.utils.stl.UnaryFunction;
@@ -332,7 +332,7 @@
}
/**
- * @see org.apache.ode.bpel.dao.BpelDAOConnection#instanceQuery(String)
+ * @see org.apache.ode.dao.bpel.BpelDAOConnection#instanceQuery(String)
*/
public Collection<ProcessInstanceDAO> instanceQuery(String expression) {
//TODO
@@ -388,4 +388,8 @@
public ProcessManagementDaoImpl getProcessManagement() {
return new ProcessManagementDaoImpl();
}
+
+ public boolean isClosed() {
+ return false;
+ }
}
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelationSetDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelationSetDaoImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelationSetDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -19,10 +19,10 @@
package org.apache.ode.bpel.memdao;
import org.apache.ode.bpel.common.CorrelationKey;
-import org.apache.ode.bpel.dao.CorrelationSetDAO;
-import org.apache.ode.bpel.dao.ScopeDAO;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.CorrelationSetDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.ScopeDAO;
import javax.xml.namespace.QName;
import java.util.HashMap;
@@ -44,7 +44,7 @@
* @param name correlation set name
* @param scope the scope for which the correlation set is relevant
*/
- public CorrelationSetDaoImpl(String name, org.apache.ode.bpel.dao.ScopeDAO scope) {
+ public CorrelationSetDaoImpl(String name, org.apache.ode.dao.bpel.ScopeDAO scope) {
_name = name;
_scope = scope;
_csetId = IdGen.newCorrelationSetId();
@@ -55,14 +55,14 @@
}
/**
- * @see org.apache.ode.bpel.dao.CorrelationSetDAO#getName()
+ * @see org.apache.ode.dao.bpel.CorrelationSetDAO#getName()
*/
public String getName() {
return _name;
}
/**
- * @see org.apache.ode.bpel.dao.CorrelationSetDAO#getScope()
+ * @see org.apache.ode.dao.bpel.CorrelationSetDAO#getScope()
*/
public ScopeDAO getScope() {
return _scope;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelatorDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelatorDaoImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelatorDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -22,7 +22,7 @@
import org.apache.commons.logging.LogFactory;
import org.apache.ode.bpel.common.CorrelationKey;
import org.apache.ode.bpel.common.CorrelationKeySet;
-import org.apache.ode.bpel.dao.*;
+import org.apache.ode.dao.bpel.*;
import java.util.ArrayList;
import java.util.Iterator;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/FaultDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/FaultDaoImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/FaultDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -19,7 +19,7 @@
package org.apache.ode.bpel.memdao;
-import org.apache.ode.bpel.dao.FaultDAO;
+import org.apache.ode.dao.bpel.FaultDAO;
import org.apache.ode.utils.QNameUtils;
import org.w3c.dom.Element;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageDAOImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -19,8 +19,8 @@
package org.apache.ode.bpel.memdao;
-import org.apache.ode.bpel.dao.MessageDAO;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
+import org.apache.ode.dao.bpel.MessageDAO;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
import org.apache.ode.utils.DOMUtils;
import org.w3c.dom.Element;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageExchangeDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageExchangeDAOImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageExchangeDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -19,11 +19,11 @@
package org.apache.ode.bpel.memdao;
-import org.apache.ode.bpel.dao.MessageDAO;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
-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.dao.bpel.MessageDAO;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
+import org.apache.ode.dao.bpel.PartnerLinkDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
import org.w3c.dom.Element;
import javax.xml.namespace.QName;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageRouteDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageRouteDaoImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageRouteDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -20,8 +20,8 @@
import org.apache.ode.bpel.common.CorrelationKeySet;
import org.apache.ode.bpel.common.CorrelationKey;
-import org.apache.ode.bpel.dao.MessageRouteDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.MessageRouteDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
/**
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/PartnerLinkDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/PartnerLinkDAOImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/PartnerLinkDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -19,14 +19,14 @@
package org.apache.ode.bpel.memdao;
-import org.apache.ode.bpel.dao.PartnerLinkDAO;
+import org.apache.ode.dao.bpel.PartnerLinkDAO;
import org.w3c.dom.Element;
import javax.xml.namespace.QName;
/**
* A very simple, in-memory implementation of the
- * {@link org.apache.ode.bpel.dao.PartnerLinkDAO} interface.
+ * {@link org.apache.ode.dao.bpel.PartnerLinkDAO} interface.
*/
public class PartnerLinkDAOImpl extends DaoBaseImpl implements PartnerLinkDAO {
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -33,11 +33,11 @@
import org.apache.commons.logging.LogFactory;
import org.apache.ode.bpel.common.CorrelationKey;
import org.apache.ode.bpel.common.ProcessState;
-import org.apache.ode.bpel.dao.CorrelationSetDAO;
-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.dao.bpel.CorrelationSetDAO;
+import org.apache.ode.dao.bpel.CorrelatorDAO;
+import org.apache.ode.dao.bpel.PartnerLinkDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
/**
* A very simple, in-memory implementation of the {@link ProcessDAO} interface.
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessInstanceDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessInstanceDaoImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessInstanceDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -19,18 +19,18 @@
package org.apache.ode.bpel.memdao;
import org.apache.ode.bpel.common.ProcessState;
-import org.apache.ode.bpel.dao.ActivityRecoveryDAO;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.CorrelationSetDAO;
-import org.apache.ode.bpel.dao.CorrelatorDAO;
-import org.apache.ode.bpel.dao.FaultDAO;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
-import org.apache.ode.bpel.dao.ScopeDAO;
-import org.apache.ode.bpel.dao.XmlDataDAO;
import org.apache.ode.bpel.evt.ProcessInstanceEvent;
import org.apache.ode.bpel.iapi.ProcessConf.CLEANUP_CATEGORY;
+import org.apache.ode.dao.bpel.ActivityRecoveryDAO;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.CorrelationSetDAO;
+import org.apache.ode.dao.bpel.CorrelatorDAO;
+import org.apache.ode.dao.bpel.FaultDAO;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.ScopeDAO;
+import org.apache.ode.dao.bpel.XmlDataDAO;
import org.apache.ode.utils.QNameUtils;
import org.w3c.dom.Element;
@@ -209,7 +209,7 @@
}
/**
- * @see org.apache.ode.bpel.dao.ProcessInstanceDAO#getScope(java.lang.Long)
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getScope(java.lang.Long)
*/
public ScopeDAO getScope(Long scopeInstanceId) {
return _scopes.get(scopeInstanceId);
@@ -223,7 +223,7 @@
}
/**
- * @see org.apache.ode.bpel.dao.ProcessInstanceDAO#insertBpelEvent(org.apache.ode.bpel.evt.ProcessInstanceEvent)
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#insertBpelEvent(org.apache.ode.bpel.evt.ProcessInstanceEvent)
*/
public void insertBpelEvent(ProcessInstanceEvent event) {
_events.add(event);
@@ -234,14 +234,14 @@
}
/**
- * @see org.apache.ode.bpel.dao.ProcessInstanceDAO#getInstantiatingCorrelator()
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getInstantiatingCorrelator()
*/
public CorrelatorDAO getInstantiatingCorrelator() {
return _instantiatingCorrelator;
}
/**
- * @see org.apache.ode.bpel.dao.ProcessInstanceDAO#getScopes(java.lang.String)
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getScopes(java.lang.String)
*/
public Collection<ScopeDAO> getScopes(String scopeName) {
List<ScopeDAO> scopes = _scopesByName.get(scopeName);
@@ -249,28 +249,28 @@
}
/**
- * @see org.apache.ode.bpel.dao.ProcessInstanceDAO#getPreviousState()
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getPreviousState()
*/
public short getPreviousState() {
return _previousState;
}
/**
- * @see org.apache.ode.bpel.dao.ProcessInstanceDAO#getLastActiveTime()
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getLastActiveTime()
*/
public Date getLastActiveTime() {
return _lastActive;
}
/**
- * @see org.apache.ode.bpel.dao.ProcessInstanceDAO#setLastActiveTime(java.util.Date)
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#setLastActiveTime(java.util.Date)
*/
public void setLastActiveTime(Date dt) {
_lastActive = dt;
}
/**
- * @see org.apache.ode.bpel.dao.ProcessInstanceDAO#finishCompletion()
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#finishCompletion()
*/
public void finishCompletion() {
// make sure we have completed.
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessManagementDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessManagementDaoImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessManagementDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -27,10 +27,10 @@
import javax.xml.namespace.QName;
import org.apache.ode.bpel.common.InstanceFilter;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
-import org.apache.ode.bpel.dao.ProcessManagementDAO;
-import org.apache.ode.bpel.dao.ProcessManagementDAO.InstanceSummaryKey;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.ProcessManagementDAO;
+import org.apache.ode.dao.bpel.ProcessManagementDAO.InstanceSummaryKey;
public class ProcessManagementDaoImpl extends DaoBaseImpl implements ProcessManagementDAO {
public Object[] findFailedCountAndLastFailedDateForProcessId(BpelDAOConnection conn, String status, String processId) {
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ScopeDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ScopeDaoImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ScopeDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -18,12 +18,12 @@
*/
package org.apache.ode.bpel.memdao;
-import org.apache.ode.bpel.dao.CorrelationSetDAO;
-import org.apache.ode.bpel.dao.PartnerLinkDAO;
-import org.apache.ode.bpel.dao.ScopeDAO;
-import org.apache.ode.bpel.dao.ScopeStateEnum;
-import org.apache.ode.bpel.dao.XmlDataDAO;
import org.apache.ode.bpel.evt.BpelEvent;
+import org.apache.ode.dao.bpel.CorrelationSetDAO;
+import org.apache.ode.dao.bpel.PartnerLinkDAO;
+import org.apache.ode.dao.bpel.ScopeDAO;
+import org.apache.ode.dao.bpel.ScopeStateEnum;
+import org.apache.ode.dao.bpel.XmlDataDAO;
import java.util.ArrayList;
import java.util.Collection;
@@ -41,7 +41,7 @@
private Map<String, CorrelationSetDAO> _correlations = new HashMap<String, CorrelationSetDAO>();
private Map<Integer, PartnerLinkDAO> _eprs = new HashMap<Integer, PartnerLinkDAO>();
private ProcessInstanceDaoImpl _processInstance;
- private org.apache.ode.bpel.dao.ScopeDAO _parent;
+ private org.apache.ode.dao.bpel.ScopeDAO _parent;
private Long _instanceId;
private int _scopeModelId;
@@ -62,7 +62,7 @@
/**
- * @see org.apache.ode.bpel.dao.ScopeDAO#getCorrelationSet(java.lang.String)
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getCorrelationSet(java.lang.String)
*/
public CorrelationSetDAO getCorrelationSet(String corrSetName) {
CorrelationSetDAO corr = _correlations.get(corrSetName);
@@ -76,42 +76,42 @@
}
/**
- * @see org.apache.ode.bpel.dao.ScopeDAO#getParentScope()
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getParentScope()
*/
- public org.apache.ode.bpel.dao.ScopeDAO getParentScope() {
+ public org.apache.ode.dao.bpel.ScopeDAO getParentScope() {
return _parent;
}
/**
- * @see org.apache.ode.bpel.dao.ScopeDAO#getProcessInstance()
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getProcessInstance()
*/
- public org.apache.ode.bpel.dao.ProcessInstanceDAO getProcessInstance() {
+ public org.apache.ode.dao.bpel.ProcessInstanceDAO getProcessInstance() {
return _processInstance;
}
/**
- * @see org.apache.ode.bpel.dao.ScopeDAO#setState(org.apache.ode.bpel.dao.ScopeStateEnum)
+ * @see org.apache.ode.dao.bpel.ScopeDAO#setState(org.apache.ode.dao.bpel.ScopeStateEnum)
*/
- public void setState(org.apache.ode.bpel.dao.ScopeStateEnum state) {
+ public void setState(org.apache.ode.dao.bpel.ScopeStateEnum state) {
_state = state;
}
/**
- * @see org.apache.ode.bpel.dao.ScopeDAO#getState()
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getState()
*/
- public org.apache.ode.bpel.dao.ScopeStateEnum getState() {
+ public org.apache.ode.dao.bpel.ScopeStateEnum getState() {
return _state;
}
/**
- * @see org.apache.ode.bpel.dao.ScopeDAO#getName()
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getName()
*/
public String getName() {
return _type;
}
/**
- * @see org.apache.ode.bpel.dao.ScopeDAO#getVariable(java.lang.String)
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getVariable(java.lang.String)
*/
public XmlDataDAO getVariable(String varName) {
XmlDataDAO v = _variables.get(varName);
@@ -129,14 +129,14 @@
}
/**
- * @see org.apache.ode.bpel.dao.ScopeDAO#getScopeInstanceId()
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getScopeInstanceId()
*/
public Long getScopeInstanceId() {
return _instanceId;
}
/**
- * @see org.apache.ode.bpel.dao.ScopeDAO#getModelId()
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getModelId()
*/
public int getModelId() {
return _scopeModelId;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/XmlDataDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/XmlDataDaoImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/XmlDataDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -18,8 +18,8 @@
*/
package org.apache.ode.bpel.memdao;
-import org.apache.ode.bpel.dao.ScopeDAO;
-import org.apache.ode.bpel.dao.XmlDataDAO;
+import org.apache.ode.dao.bpel.ScopeDAO;
+import org.apache.ode.dao.bpel.XmlDataDAO;
import org.apache.ode.utils.DOMUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -91,14 +91,14 @@
}
/**
- * @see org.apache.ode.bpel.dao.XmlDataDAO#getProperty(java.lang.String)
+ * @see org.apache.ode.dao.bpel.XmlDataDAO#getProperty(java.lang.String)
*/
public String getProperty(String propertyName) {
return _properties.getProperty(propertyName);
}
/**
- * @see org.apache.ode.bpel.dao.XmlDataDAO#setProperty(java.lang.String, java.lang.String)
+ * @see org.apache.ode.dao.bpel.XmlDataDAO#setProperty(java.lang.String, java.lang.String)
*/
public void setProperty(String pname, String pvalue) {
_properties.setProperty(pname, pvalue);
@@ -109,7 +109,7 @@
}
/**
- * @see org.apache.ode.bpel.dao.XmlDataDAO#getScopeDAO()
+ * @see org.apache.ode.dao.bpel.XmlDataDAO#getScopeDAO()
*/
public ScopeDAO getScopeDAO() {
return _scope;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/test/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImplTest.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/test/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImplTest.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/test/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImplTest.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -8,8 +8,8 @@
import javax.transaction.TransactionManager;
import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
import org.apache.ode.bpel.engine.MyRoleMessageExchangeImpl.ResponseCallback;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
import org.apache.ode.scheduler.simple.SimpleScheduler;
import org.jmock.Mock;
import org.jmock.MockObjectTestCase;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/test/java/org/apache/ode/bpel/engine/cron/CronSchedulerTest.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/test/java/org/apache/ode/bpel/engine/cron/CronSchedulerTest.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/test/java/org/apache/ode/bpel/engine/cron/CronSchedulerTest.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -17,7 +17,7 @@
import org.apache.ode.bpel.iapi.Scheduler;
import org.apache.ode.bpel.iapi.ProcessConf.CLEANUP_CATEGORY;
import org.apache.ode.bpel.iapi.ProcessConf.CleanupInfo;
-import org.apache.ode.daohib.bpel.BpelDAOConnectionImpl;
+import org.apache.ode.dao.hib.bpel.BpelDAOConnectionImpl;
import org.apache.ode.utils.CronExpression;
import org.jmock.Mock;
import org.jmock.MockObjectTestCase;
Modified: branches/ODE/ODE-1.x-jpa/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -18,17 +18,23 @@
*/
package org.apache.ode.bpel.runtime;
-import org.apache.derby.jdbc.EmbeddedXADataSource;
-import org.apache.geronimo.connector.outbound.GenericConnectionManager;
-import org.apache.geronimo.connector.outbound.connectionmanagerconfig.LocalTransactions;
-import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport;
-import org.apache.geronimo.connector.outbound.connectionmanagerconfig.SinglePool;
-import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport;
-import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
-import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator;
-import org.apache.geronimo.transaction.manager.RecoverableTransactionManager;
-import org.apache.ode.bpel.dao.BpelDAOConnectionFactory;
-import org.apache.ode.bpel.dao.BpelDAOConnectionFactoryJDBC;
+import java.io.File;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
import org.apache.ode.bpel.engine.BpelServerImpl;
import org.apache.ode.bpel.iapi.BindingContext;
import org.apache.ode.bpel.iapi.ContextException;
@@ -41,9 +47,9 @@
import org.apache.ode.bpel.iapi.PartnerRoleChannel;
import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange;
import org.apache.ode.bpel.iapi.Scheduler;
-import org.apache.ode.bpel.iapi.Scheduler.MapSerializableRunnable;
import org.apache.ode.bpel.memdao.BpelDAOConnectionFactoryImpl;
-import org.apache.ode.dao.jpa.BPELDAOConnectionFactoryImpl;
+import org.apache.ode.dao.bpel.BpelDAOConnectionFactory;
+import org.apache.ode.dao.store.ConfStoreDAOConnectionFactory;
import org.apache.ode.il.EmbeddedGeronimoFactory;
import org.apache.ode.il.MockScheduler;
import org.apache.ode.il.config.OdeConfigProperties;
@@ -51,29 +57,10 @@
import org.apache.ode.store.ProcessStoreImpl;
import org.apache.ode.utils.DOMUtils;
import org.apache.ode.utils.GUID;
-import org.hsqldb.jdbc.jdbcDataSource;
-import org.tranql.connector.derby.EmbeddedLocalMCF;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import javax.resource.spi.ConnectionManager;
-import javax.sql.DataSource;
-import javax.transaction.TransactionManager;
-import javax.wsdl.PortType;
-import javax.xml.namespace.QName;
-import java.io.File;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Collections;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-
class MockBpelServer {
BpelServerImpl _server;
@@ -82,7 +69,8 @@
Database _database;
DataSource _dataSource;
SchedulerWrapper _scheduler;
- BpelDAOConnectionFactory _daoCF;
+ BpelDAOConnectionFactory _bpelDaoCF;
+ ConfStoreDAOConnectionFactory _confDaoCF;
EndpointReferenceContext _eprContext;
MessageExchangeContext _mexContext;
BindingContext _bindContext;
@@ -97,16 +85,16 @@
createDataSource();
createScheduler();
createDAOConnection();
- if (_daoCF == null)
+ if (_bpelDaoCF == null)
throw new RuntimeException("No DAO");
- _server.setDaoConnectionFactory(_daoCF);
+ _server.setDaoConnectionFactory(_bpelDaoCF);
_server.setInMemDaoConnectionFactory(new BpelDAOConnectionFactoryImpl(_scheduler));
if (_scheduler == null)
throw new RuntimeException("No scheduler");
createEndpointReferenceContext();
Properties storeProps = new Properties();
storeProps.setProperty("hibernate.hbm2ddl.auto", "update");
- _store = new ProcessStoreImpl(_eprContext, _dataSource,"hib", new OdeConfigProperties(storeProps, ""), true);
+ _store = new ProcessStoreImpl(_eprContext,_txManager,_confDaoCF);
_server.setScheduler(_scheduler);
_server.setEndpointReferenceContext(_eprContext);
_server.setMessageExchangeContext(createMessageExchangeContext());
@@ -182,45 +170,14 @@
}
protected DataSource createDataSource() throws Exception {
- TransactionSupport transactionSupport = LocalTransactions.INSTANCE;
- ConnectionTracker connectionTracker = new ConnectionTrackingCoordinator();
-
- PoolingSupport poolingSupport = new SinglePool(
- 10,
- 0,
- 1000,
- 1,
- true,
- false,
- false);
-
- ConnectionManager connectionManager = new GenericConnectionManager(
- transactionSupport,
- poolingSupport,
- null,
- connectionTracker,
- (RecoverableTransactionManager) _txManager,
- getClass().getName(),
- getClass().getClassLoader());
-
-
- EmbeddedLocalMCF mcf = new org.tranql.connector.derby.EmbeddedLocalMCF();
- mcf.setCreateDatabase(true);
- mcf.setDatabaseName("target/testdb");
- mcf.setUserName("sa");
- mcf.setPassword("");
- _dataSource = (DataSource) mcf.createConnectionFactory(connectionManager);
- return _dataSource;
-
-
-// d = org.tranql.connector.jdbc.JDBCDriverMCF();
-// EmbeddedXADataSource ds = new EmbeddedXADataSource();
-// ds.setCreateDatabase("create");
-// ds.setDatabaseName("target/testdb");
-// ds.setUser("sa");
-// ds.setPassword("");
-// _dataSource = ds;
-// return _dataSource;
+ Properties props = new Properties();
+ props.setProperty(OdeConfigProperties.PROP_DAOCF, System.getProperty(OdeConfigProperties.PROP_DAOCF,OdeConfigProperties.DEFAULT_DAOCF_CLASS));
+ OdeConfigProperties odeProps = new OdeConfigProperties(props,"");
+ _database = new Database(odeProps);
+ _database.setTransactionManager(_txManager);
+ _database.start();
+ _dataSource=_database.getDataSource();
+ return _dataSource;
}
protected Scheduler createScheduler() throws Exception {
@@ -234,30 +191,15 @@
return _scheduler;
}
- protected BpelDAOConnectionFactory createDAOConnection() throws Exception {
+ protected void createDAOConnection() throws Exception {
if (_txManager == null)
throw new RuntimeException("No transaction manager");
if (_dataSource == null)
throw new RuntimeException("No data source");
+
+ _bpelDaoCF = _database.createDaoCF();
+ _confDaoCF = _database.createDaoStoreCF();
-//
-// BpelDAOConnectionFactoryJDBC daoCF = new BPELDAOConnectionFactoryImpl();
-// daoCF.setDataSource(_dataSource);
-// daoCF.setTransactionManager(_txManager);
-// Properties props = new Properties();
-// props.put("openjpa.Log", "log4j");
-// props.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=false)");
-// daoCF.init(props);
-// _daoCF = daoCF;
- org.apache.ode.daohib.bpel.BpelDAOConnectionFactoryImpl daoCF = new org.apache.ode.daohib.bpel.BpelDAOConnectionFactoryImpl();
- daoCF.setDataSource(_dataSource);
- daoCF.setTransactionManager(_txManager);
- Properties props = new Properties();
- props.setProperty("hibernate.hbm2ddl.auto", "update");
- daoCF.init(props);
-
- _daoCF = daoCF;
- return _daoCF;
}
protected EndpointReferenceContext createEndpointReferenceContext() {
Modified: branches/ODE/ODE-1.x-jpa/bpel-store/pom.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-store/pom.xml 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-store/pom.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -54,14 +54,6 @@
</dependency>
<dependency>
<groupId>org.jboss.soa.bpel</groupId>
- <artifactId>riftsaw-dao-hibernate</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.soa.bpel</groupId>
- <artifactId>riftsaw-dao-jpa</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.soa.bpel</groupId>
<artifactId>riftsaw-utils</artifactId>
</dependency>
<dependency>
@@ -69,154 +61,90 @@
<artifactId>commons-logging</artifactId>
</dependency>
<dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-core</artifactId>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring</artifactId>
+ <version>${spring.version}</version>
</dependency>
<dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-stax-api_1.0_spec</artifactId>
- </dependency>
- <dependency>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.xmlbeans</groupId>
- <artifactId>xmlbeans</artifactId>
- </dependency>
- <dependency>
- <groupId>xerces</groupId>
- <artifactId>xercesImpl</artifactId>
- </dependency>
- <dependency>
- <groupId>wsdl4j</groupId>
- <artifactId>wsdl4j</artifactId>
- </dependency>
-
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jta_1.1_spec</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
+ <groupId>org.apache.geronimo.components</groupId>
+ <artifactId>geronimo-transaction</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>jaxen</groupId>
- <artifactId>jaxen</artifactId>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-dao-jpa-ojpa</artifactId>
<scope>test</scope>
</dependency>
+ <!-- for the integration tests - seems to work with the openjpa enhanced enities -->
<dependency>
- <groupId>dom4j</groupId>
- <artifactId>dom4j</artifactId>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-dao-jpa-hibernate</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>xalan</groupId>
- <artifactId>xalan</artifactId>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-dao-hibernate</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.openjpa</groupId>
- <artifactId>openjpa</artifactId>
- </dependency>
- <dependency>
- <groupId>net.sourceforge.serp</groupId>
- <artifactId>serp</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
- <build>
- <plugins>
+ <build>
+ <plugins>
<plugin>
- <artifactId>maven-antrun-plugin</artifactId>
+ <artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
- <id>openjpa-enhancer</id>
- <phase>process-classes</phase>
+ <id>hibernate-jpa</id>
+ <phase>integration-test</phase>
<goals>
- <goal>run</goal>
+ <goal>test</goal>
</goals>
<configuration>
- <tasks>
- <property name="maven.runtime.classpath" refid="maven.test.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>
- </tasks>
+ <reportsDirectory>${project.build.directory}/surefire-reports/hibernate-jpa</reportsDirectory>
+ <systemProperties>
+ <property>
+ <name>dao.factory.store</name>
+ <value>org.apache.ode.dao.jpa.hibernate.ConfStoreDAOConnectionFactoryImpl</value>
+ </property>
+ </systemProperties>
+ <includes>
+ <include>**/DaoTest.java</include>
+ <include>**/ProcessStoreTest.java</include>
+ </includes>
</configuration>
</execution>
+ <execution>
+ <id>hibernate</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <reportsDirectory>${project.build.directory}/surefire-reports/hibernate</reportsDirectory>
+ <systemProperties>
+ <property>
+ <name>dao.factory.store</name>
+ <value>org.apache.ode.dao.hib.store.ConfStoreDAOConnectionFactoryImpl</value>
+ </property>
+ </systemProperties>
+ <includes>
+ <include>**/DaoTest.java</include>
+ <include>**/ProcessStoreTest.java</include>
+ </includes>
+ </configuration>
+ </execution>
</executions>
</plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>xdoclet-maven-plugin</artifactId>
- <executions>
- <execution>
- <phase>generate-sources</phase>
- <goals>
- <goal>xdoclet</goal>
- </goals>
-
- <configuration>
- <tasks>
- <hibernatedoclet excludedTags="@version,@author,@todo" verbose="true"
- destdir="${project.build.outputDirectory}" force="true">
- <hibernate version="3.0"/>
- <fileset dir="${project.build.sourceDirectory}" includes="org/apache/ode/store/hib/*.java"/>
- </hibernatedoclet>
- </tasks>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
+ </plugins>
+ </build>
</project>
Deleted: branches/ODE/ODE-1.x-jpa/bpel-store/src/main/java/org/apache/ode/store/ConfStoreConnection.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-store/src/main/java/org/apache/ode/store/ConfStoreConnection.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-store/src/main/java/org/apache/ode/store/ConfStoreConnection.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,38 +0,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.
- */
-package org.apache.ode.store;
-
-
-import java.util.Collection;
-
-/**
- */
-public interface ConfStoreConnection {
- DeploymentUnitDAO createDeploymentUnit(String name);
-
- DeploymentUnitDAO getDeploymentUnit(String name);
-
- Collection<DeploymentUnitDAO> getDeploymentUnits();
-
- void close();
-
- long getNextVersion();
-
- void setVersion(long version);
-}
Deleted: branches/ODE/ODE-1.x-jpa/bpel-store/src/main/java/org/apache/ode/store/ConfStoreConnectionFactory.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-store/src/main/java/org/apache/ode/store/ConfStoreConnectionFactory.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-store/src/main/java/org/apache/ode/store/ConfStoreConnectionFactory.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,27 +0,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.
- */
-package org.apache.ode.store;
-
-/**
- * Connection factory for DB store.
- * @author mszefler
- */
-public interface ConfStoreConnectionFactory extends ProcessStoreTransactionProvider {
- ConfStoreConnection getConnection();
-}
Deleted: branches/ODE/ODE-1.x-jpa/bpel-store/src/main/java/org/apache/ode/store/DeploymentUnitDAO.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-store/src/main/java/org/apache/ode/store/DeploymentUnitDAO.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-store/src/main/java/org/apache/ode/store/DeploymentUnitDAO.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,77 +0,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.
- */
-package org.apache.ode.store;
-
-import javax.xml.namespace.QName;
-import java.util.Collection;
-import java.util.Date;
-
-/**
- * DAO interface for a "deployment unit", a collection of processes deployed as a single
- * unit.
- *
- * @author mszefler
- *
- */
-public interface DeploymentUnitDAO {
-
- /**
- * Get the name of the deployment unit.
- * @return du name
- */
- String getName();
-
- /**
- * Get the deployment unit directory path.
- * @return deployment unit directory path
- */
- String getDeploymentUnitDir();
-
-
- void setDeploymentUnitDir(String dir);
-
- /**
- * Get the collection of processes that are deployed as part of this deployment unit.
- * @return
- */
- Collection<? extends ProcessConfDAO> getProcesses();
-
- /**
- * Get the date/time the DU was deployed.
- * @return
- */
- Date getDeployDate();
-
- /**
- * Get the userid of the user doing the deploying.
- * @return
- */
- String getDeployer();
-
-
- /**
- * Delete this deployment unit (deletes all the children).
- */
- void delete();
-
- ProcessConfDAO createProcess(QName pid, QName type, long version);
-
- ProcessConfDAO getProcess(QName pid);
-
-}
Deleted: branches/ODE/ODE-1.x-jpa/bpel-store/src/main/java/org/apache/ode/store/ProcessConfDAO.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-store/src/main/java/org/apache/ode/store/ProcessConfDAO.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-store/src/main/java/org/apache/ode/store/ProcessConfDAO.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,51 +0,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.
- */
-package org.apache.ode.store;
-
-import org.apache.ode.bpel.iapi.ProcessState;
-
-import javax.xml.namespace.QName;
-import java.util.Collection;
-
-/**
- * DAO interface for a process configuration.
- * @author mriou <mriou at apache dot org>
- */
-public interface ProcessConfDAO {
-
- QName getPID();
-
- QName getType();
-
- long getVersion();
-
- DeploymentUnitDAO getDeploymentUnit();
-
- ProcessState getState();
-
- void setState(ProcessState state);
-
- void setProperty(QName name, String content);
-
- String getProperty(QName name);
-
- Collection<QName> getPropertyNames();
-
- void delete();
-}
Modified: branches/ODE/ODE-1.x-jpa/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -18,34 +18,55 @@
*/
package org.apache.ode.store;
+import java.io.File;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+import javax.xml.namespace.QName;
+
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.dd.DeployDocument;
import org.apache.ode.bpel.dd.TDeployment;
-import org.apache.ode.bpel.iapi.*;
-import org.apache.ode.il.config.OdeConfigProperties;
+import org.apache.ode.bpel.iapi.ContextException;
+import org.apache.ode.bpel.iapi.EndpointReferenceContext;
+import org.apache.ode.bpel.iapi.ProcessConf;
+import org.apache.ode.bpel.iapi.ProcessState;
+import org.apache.ode.bpel.iapi.ProcessStore;
+import org.apache.ode.bpel.iapi.ProcessStoreEvent;
+import org.apache.ode.bpel.iapi.ProcessStoreListener;
+import org.apache.ode.dao.store.ConfStoreDAOConnection;
+import org.apache.ode.dao.store.ConfStoreDAOConnectionFactory;
+import org.apache.ode.dao.store.DeploymentUnitDAO;
+import org.apache.ode.dao.store.ProcessConfDAO;
import org.apache.ode.store.DeploymentUnitDir.CBPInfo;
import org.apache.ode.utils.DOMUtils;
-import org.apache.ode.utils.GUID;
import org.apache.ode.utils.msg.MessageBundle;
-import org.hsqldb.jdbc.jdbcDataSource;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import javax.sql.DataSource;
-import javax.xml.namespace.QName;
-import java.io.File;
-import java.io.IOException;
-import java.sql.SQLException;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
/**
* <p>
* JDBC-based implementation of a process store. Also provides an "in-memory" store by way of HSQL database.
@@ -78,10 +99,12 @@
/** Guards access to the _processes and _deploymentUnits */
private final ReadWriteLock _rw = new ReentrantReadWriteLock();
- private ConfStoreConnectionFactory _cf;
+ private ConfStoreDAOConnectionFactory _cf;
- private EndpointReferenceContext eprContext;
+ private EndpointReferenceContext _eprContext;
+ private TransactionManager _txm;
+
private boolean generateProcessEventsAll;
protected File _deployDir;
@@ -101,42 +124,13 @@
*/
private DataSource _inMemDs;
- public ProcessStoreImpl() {
- this(null, null, "", new OdeConfigProperties(new Properties(), ""), true);
- }
-
- public ProcessStoreImpl(EndpointReferenceContext eprContext, DataSource ds, String persistenceType, OdeConfigProperties props, boolean createDatamodel) {
- this.eprContext = eprContext;
- this.generateProcessEventsAll = props.getProperty("generateProcessEvents", "all").equals("all");
- if (ds != null) {
- // ugly hack
- if (persistenceType.toLowerCase().indexOf("hib") != -1) {
- _cf = new org.apache.ode.store.hib.DbConfStoreConnectionFactory(ds, props.getProperties(), createDatamodel, props.getTxFactoryClass());
- } else {
- _cf = new org.apache.ode.store.jpa.DbConfStoreConnectionFactory(ds, createDatamodel, props.getTxFactoryClass());
- }
- } else {
- // If the datasource is not provided, then we create a HSQL-based
- // in-memory database. Makes testing a bit simpler.
- DataSource hsqlds = createInternalDS(new GUID().toString());
- if ("hibernate".equalsIgnoreCase(persistenceType)) {
- _cf = new org.apache.ode.store.hib.DbConfStoreConnectionFactory(hsqlds, props.getProperties(), createDatamodel, props.getTxFactoryClass());
- } else {
- _cf = new org.apache.ode.store.jpa.DbConfStoreConnectionFactory(hsqlds, createDatamodel, props.getTxFactoryClass());
- }
- _inMemDs = hsqlds;
- }
- }
-
/**
* Constructor that hardwires OpenJPA on a new in-memory database. Suitable for tests.
*/
- public ProcessStoreImpl(EndpointReferenceContext eprContext, DataSource inMemDs) {
- this.eprContext = eprContext;
- DataSource hsqlds = createInternalDS(new GUID().toString());
- //when in memory we always create the model as we are starting from scratch
- _cf = new org.apache.ode.store.jpa.DbConfStoreConnectionFactory(hsqlds, true, OdeConfigProperties.DEFAULT_TX_FACTORY_CLASS_NAME);
- _inMemDs = hsqlds;
+ public <E> ProcessStoreImpl(EndpointReferenceContext eprContext, TransactionManager mgr, ConfStoreDAOConnectionFactory cf) {
+ _eprContext = eprContext;
+ _txm = mgr;
+ _cf=cf;
}
public void shutdown() {
@@ -187,7 +181,7 @@
if (autoincrementVersion || du.getStaticVersion() == -1) {
// Process and DU use a monotonically increased single version number by default.
version = exec(new Callable<Long>() {
- public Long call(ConfStoreConnection conn) {
+ public Long call(ConfStoreDAOConnection conn) {
return conn.getNextVersion();
}
});
@@ -239,7 +233,7 @@
}
ProcessConfImpl pconf = new ProcessConfImpl(pid, processDD.getName(), version, du, processDD, deployDate,
- calcInitialProperties(processDD), calcInitialState(processDD), eprContext, _configDir, generateProcessEventsAll);
+ calcInitialProperties(processDD), calcInitialState(processDD), _eprContext, _configDir, generateProcessEventsAll);
processes.add(pconf);
}
@@ -258,7 +252,7 @@
// Do the deployment in the DB. We need this so that we remember deployments across system shutdowns.
// We don't fail if there is a DB error, simply print some errors.
deployed = exec(new Callable<Collection<QName>>() {
- public Collection<QName> call(ConfStoreConnection conn) {
+ public Collection<QName> call(ConfStoreDAOConnection conn) {
// Check that this deployment unit is not deployed.
DeploymentUnitDAO dudao = conn.getDeploymentUnit(du.getName());
if (dudao != null) {
@@ -357,7 +351,7 @@
public Collection<QName> undeploy(final String duName) {
try {
exec(new Callable<Collection<QName>>() {
- public Collection<QName> call(ConfStoreConnection conn) {
+ public Collection<QName> call(ConfStoreDAOConnection conn) {
DeploymentUnitDAO dudao = conn.getDeploymentUnit(duName);
if (dudao != null)
dudao.delete();
@@ -450,7 +444,7 @@
// Update in the database.
ProcessState old = exec(new Callable<ProcessState>() {
- public ProcessState call(ConfStoreConnection conn) {
+ public ProcessState call(ConfStoreDAOConnection conn) {
DeploymentUnitDAO dudao = conn.getDeploymentUnit(dudir.getName());
if (dudao == null) {
String errmsg = __msgs.msgProcessNotFound(pid);
@@ -511,7 +505,7 @@
final DeploymentUnitDir dudir = pconf.getDeploymentUnit();
exec(new ProcessStoreImpl.Callable<Object>() {
- public Object call(ConfStoreConnection conn) {
+ public Object call(ConfStoreDAOConnection conn) {
DeploymentUnitDAO dudao = conn.getDeploymentUnit(dudir.getName());
if (dudao == null)
return null;
@@ -533,7 +527,7 @@
public void loadAll() {
final ArrayList<ProcessConfImpl> loaded = new ArrayList<ProcessConfImpl>();
exec(new Callable<Object>() {
- public Object call(ConfStoreConnection conn) {
+ public Object call(ConfStoreDAOConnection conn) {
Collection<DeploymentUnitDAO> dus = conn.getDeploymentUnits();
for (DeploymentUnitDAO du : dus)
try {
@@ -578,7 +572,7 @@
public long getCurrentVersion() {
long version = exec(new Callable<Long>() {
- public Long call(ConfStoreConnection conn) {
+ public Long call(ConfStoreDAOConnection conn) {
return conn.getNextVersion();
}
});
@@ -608,7 +602,7 @@
if (version == 0) {
// Process and DU use a monotonically increased single version number.
version = exec(new Callable<Long>() {
- public Long call(ConfStoreConnection conn) {
+ public Long call(ConfStoreDAOConnection conn) {
return conn.getNextVersion();
}
});
@@ -668,7 +662,7 @@
}
}
- private ConfStoreConnection getConnection() {
+ private ConfStoreDAOConnection getConnection() {
return _cf.getConnection();
}
@@ -749,7 +743,7 @@
// TODO: update the props based on the values in the DB.
ProcessConfImpl pconf = new ProcessConfImpl(p.getPID(), p.getType(), p.getVersion(), dud, pinfo, dudao
- .getDeployDate(), props, p.getState(), eprContext, _configDir, generateProcessEventsAll);
+ .getDeployDate(), props, p.getState(), _eprContext, _configDir, generateProcessEventsAll);
version = p.getVersion();
_processes.put(pconf.getProcessId(), pconf);
@@ -799,7 +793,7 @@
try {
return exec(new Callable<Boolean>() {
- public Boolean call(ConfStoreConnection conn) {
+ public Boolean call(ConfStoreDAOConnection conn) {
DeploymentUnitDAO dudao = conn.getDeploymentUnit(duName);
if (dudao == null)
return false;
@@ -824,27 +818,32 @@
*/
abstract class Callable<V> implements java.util.concurrent.Callable<V> {
public V call() {
- boolean success = false;
- // in JTA, transaction is bigger than the session
- _cf.beginTransaction();
- ConfStoreConnection conn = getConnection();
+ boolean success = false;
+ ConfStoreDAOConnection conn = getConnection();
try {
+ if (_txm!=null)
+ _txm.begin();
V r = call(conn);
- _cf.commitTransaction();
+ if (_txm!=null)
+ _txm.commit();
success = true;
return r;
+ } catch (Exception e){
+ e.printStackTrace();
+ __log.error("TxError",e);
+ return null;
} finally {
- if (!success)
+ if (!success && _txm != null)
try {
- _cf.rollbackTransaction();
+ _txm.rollback();
} catch (Exception ex) {
__log.error("DbError", ex);
}
+ conn.close();
}
- // session is closed automatically when committed or rolled back under JTA
}
- abstract V call(ConfStoreConnection conn);
+ abstract V call(ConfStoreDAOConnection conn);
}
public void setDeployDir(File depDir) {
@@ -874,14 +873,6 @@
this._configDir = configDir;
}
- public static DataSource createInternalDS(String guid) {
- jdbcDataSource hsqlds = new jdbcDataSource();
- hsqlds.setDatabase("jdbc:hsqldb:mem:" + guid);
- hsqlds.setUser("sa");
- hsqlds.setPassword("");
- return hsqlds;
- }
-
public static void shutdownInternalDB(DataSource ds) {
try {
ds.getConnection().createStatement().execute("SHUTDOWN;");
Deleted: branches/ODE/ODE-1.x-jpa/bpel-store/src/main/resources/META-INF/persistence.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-store/src/main/resources/META-INF/persistence.xml 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-store/src/main/resources/META-INF/persistence.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,35 +0,0 @@
-<?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-store">
- <!--
- This properties file is used specifically by the
- OpenJPA Enhancer.
- -->
- <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
- <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>
- </persistence-unit>
-</persistence>
Added: branches/ODE/ODE-1.x-jpa/bpel-store/src/test/java/org/apache/ode/store/DaoTest.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-store/src/test/java/org/apache/ode/store/DaoTest.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-store/src/test/java/org/apache/ode/store/DaoTest.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,202 @@
+/*
+ * 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.store;
+
+import junit.framework.TestCase;
+
+import org.apache.ode.dao.store.ConfStoreDAOConnection;
+import org.apache.ode.dao.store.ConfStoreDAOConnectionFactory;
+import org.apache.ode.dao.store.DeploymentUnitDAO;
+import org.apache.ode.dao.store.ProcessConfDAO;
+import org.apache.ode.il.config.OdeConfigProperties;
+import org.apache.ode.il.dbutil.Database;
+import org.apache.ode.il.txutil.TxManager;
+import java.util.Properties;
+
+import javax.transaction.TransactionManager;
+import javax.xml.namespace.QName;
+
+public class DaoTest extends TestCase {
+
+ ConfStoreDAOConnectionFactory _cf;
+
+ Database _db;
+
+ TransactionManager _txm;
+
+ public void setUp() throws Exception {
+ Properties props = new Properties();
+ props.setProperty(OdeConfigProperties.PROP_DAOCF_STORE,System.getProperty(OdeConfigProperties.PROP_DAOCF_STORE,OdeConfigProperties.DEFAULT_DAOCF_STORE_CLASS));
+ OdeConfigProperties odeProps = new OdeConfigProperties(props, "");
+ TxManager tx = new TxManager(odeProps);
+ _txm = tx.createTransactionManager();
+ _db = new Database(odeProps);
+ _db.setTransactionManager(_txm);
+ _db.start();
+ _cf = _db.createDaoStoreCF();
+ }
+
+ public void tearDown() throws Exception {
+ _cf.shutdown();
+ _db.shutdown();
+ }
+
+ public void testEmpty() throws Exception {
+ ConfStoreDAOConnection conn = _cf.getConnection();
+ _txm.begin();
+ assertEquals(0, conn.getDeploymentUnits().size());
+ assertNull(conn.getDeploymentUnit("foobar"));
+ _txm.commit();
+ conn.close();
+ }
+
+ public void testCreateDU() throws Exception{
+ ConfStoreDAOConnection conn = _cf.getConnection();
+ _txm.begin();
+ try {
+ DeploymentUnitDAO du = conn.createDeploymentUnit("foo");
+ assertNotNull(du);
+ assertEquals("foo", du.getName());
+ assertNotNull(du.getDeployDate());
+ } finally {
+ _txm.commit();
+ conn.close();
+ }
+
+ conn = _cf.getConnection();
+ _txm.begin();
+ try {
+ DeploymentUnitDAO du = conn.getDeploymentUnit("foo");
+ assertNotNull(du);
+ assertEquals("foo", du.getName());
+ } finally {
+ _txm.commit();
+ }
+
+ }
+
+ public void testRollback() throws Exception {
+ ConfStoreDAOConnection conn = _cf.getConnection();
+ _txm.begin();
+ try {
+ DeploymentUnitDAO du = conn.createDeploymentUnit("foo");
+ assertNotNull(du);
+ assertEquals("foo", du.getName());
+ assertNotNull(du.getDeployDate());
+ } finally {
+ _txm.rollback();
+ conn.close();
+ }
+
+ conn = _cf.getConnection();
+ _txm.begin();
+ try {
+ DeploymentUnitDAO du = conn.getDeploymentUnit("foo");
+ assertNull(du);
+ } finally {
+ _txm.commit();
+ }
+ }
+
+ public void testGetDeploymentUnits() throws Exception {
+ ConfStoreDAOConnection conn = _cf.getConnection();
+ _txm.begin();
+ try {
+ conn.createDeploymentUnit("foo1");
+ conn.createDeploymentUnit("foo2");
+ conn.createDeploymentUnit("foo3");
+ conn.createDeploymentUnit("foo4");
+ } finally {
+ _txm.commit();
+ conn.close();
+ }
+
+ conn = _cf.getConnection();
+ _txm.begin();
+ try {
+ assertNotNull(conn.getDeploymentUnit("foo1"));
+ assertNotNull(conn.getDeploymentUnit("foo2"));
+ assertNotNull(conn.getDeploymentUnit("foo3"));
+ assertNotNull(conn.getDeploymentUnit("foo4"));
+ assertNull(conn.getDeploymentUnit("foo5"));
+ } finally {
+ _txm.commit();
+ }
+ }
+
+ public void testCreateProcess() throws Exception {
+ QName foobar = new QName("foo","bar");
+ ConfStoreDAOConnection conn = _cf.getConnection();
+ _txm.begin();
+ try {
+ DeploymentUnitDAO du = conn.createDeploymentUnit("foo1");
+ ProcessConfDAO p = du.createProcess(foobar,foobar,1);
+ assertEquals(foobar,p.getPID());
+ assertEquals(foobar,p.getType());
+ assertNotNull(p.getDeploymentUnit());
+ assertEquals("foo1", p.getDeploymentUnit().getName());
+ } finally {
+ _txm.commit();
+ conn.close();
+ }
+
+ conn = _cf.getConnection();
+ _txm.begin();
+ try {
+ DeploymentUnitDAO du = conn.getDeploymentUnit("foo1");
+ ProcessConfDAO p = du.getProcess(foobar);
+ assertNotNull(p);
+ assertNotNull(du.getProcesses());
+
+ assertEquals(foobar,p.getPID());
+ assertEquals(foobar,p.getType());
+ } finally {
+ _txm.commit();
+ conn.close();
+ }
+ }
+
+ public void testProcessProperties() throws Exception {
+ QName foobar = new QName("foo","bar");
+ ConfStoreDAOConnection conn = _cf.getConnection();
+ _txm.begin();
+ try {
+ DeploymentUnitDAO du = conn.createDeploymentUnit("foo1");
+ ProcessConfDAO p = du.createProcess(foobar,foobar,1);
+ p.setProperty(foobar,"baz");
+ } finally {
+ _txm.commit();
+ conn.close();
+ }
+
+ conn = _cf.getConnection();
+ _txm.begin();
+ try {
+ DeploymentUnitDAO du = conn.getDeploymentUnit("foo1");
+ ProcessConfDAO p = du.getProcess(foobar);
+ assertNotNull(p.getProperty(foobar));
+ assertEquals("baz", p.getProperty(foobar));
+ assertNotNull(p.getPropertyNames());
+ assertTrue(p.getPropertyNames().contains(foobar));
+ } finally {
+ _txm.commit();
+ conn.close();
+ }
+ }
+}
\ No newline at end of file
Modified: branches/ODE/ODE-1.x-jpa/bpel-store/src/test/java/org/apache/ode/store/ProcessStoreTest.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-store/src/test/java/org/apache/ode/store/ProcessStoreTest.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-store/src/test/java/org/apache/ode/store/ProcessStoreTest.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -23,29 +23,48 @@
import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
+import java.util.Properties;
+import javax.transaction.TransactionManager;
import javax.xml.namespace.QName;
import junit.framework.TestCase;
import org.apache.ode.bpel.iapi.ProcessConf;
import org.apache.ode.bpel.iapi.ProcessConf.CLEANUP_CATEGORY;
+import org.apache.ode.dao.store.ConfStoreDAOConnectionFactory;
+import org.apache.ode.il.config.OdeConfigProperties;
+import org.apache.ode.il.dbutil.Database;
+import org.apache.ode.il.txutil.TxManager;
public class ProcessStoreTest extends TestCase {
ProcessStoreImpl _ps;
+ Database _db;
+ ConfStoreDAOConnectionFactory _cf;
private File _testdd;
public void setUp() throws Exception {
- System.setProperty("openjpa.properties", "/openjpa.xml");
- _ps = new ProcessStoreImpl();
+ Properties props = new Properties();
+ props.setProperty(OdeConfigProperties.PROP_DAOCF_STORE,System.getProperty(OdeConfigProperties.PROP_DAOCF_STORE,OdeConfigProperties.DEFAULT_DAOCF_STORE_CLASS));
+ OdeConfigProperties odeProps = new OdeConfigProperties(props, "");
+ _db = new Database(odeProps);
+ TxManager tx = new TxManager(odeProps);
+ TransactionManager txm = tx.createTransactionManager();
+ _db.setTransactionManager(txm);
+ _db.start();
+ _cf = _db.createDaoStoreCF();
+ _ps = new ProcessStoreImpl(null,txm, _cf);
_ps.loadAll();
- URI tdd= getClass().getResource("/testdd/deploy.xml").toURI();
+ URI tdd = getClass().getResource("/testdd/deploy.xml").toURI();
_testdd = new File(tdd.getPath()).getParentFile();
+
}
public void tearDown() throws Exception {
_ps.shutdown();
+ _cf.shutdown();
+ _db.shutdown();
}
public void testSanity() {
Deleted: branches/ODE/ODE-1.x-jpa/bpel-store/src/test/java/org/apache/ode/store/hib/DaoTest.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-store/src/test/java/org/apache/ode/store/hib/DaoTest.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-store/src/test/java/org/apache/ode/store/hib/DaoTest.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,184 +0,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.
- */
-package org.apache.ode.store.hib;
-
-import junit.framework.TestCase;
-
-import org.apache.ode.il.config.OdeConfigProperties;
-import org.apache.ode.store.ConfStoreConnection;
-import org.apache.ode.store.ConfStoreConnectionFactory;
-import org.apache.ode.store.DeploymentUnitDAO;
-import org.apache.ode.store.ProcessConfDAO;
-import org.hsqldb.jdbc.jdbcDataSource;
-import java.util.Properties;
-import javax.xml.namespace.QName;
-
-public class DaoTest extends TestCase {
- jdbcDataSource hsqlds;
-
- ConfStoreConnectionFactory cf;
-
- public void setUp() throws Exception {
- hsqlds = new jdbcDataSource();
- hsqlds.setDatabase("jdbc:hsqldb:mem:test");
- hsqlds.setUser("sa");
- hsqlds.setPassword("");
-
- cf = new DbConfStoreConnectionFactory(hsqlds, new Properties(), true, OdeConfigProperties.DEFAULT_TX_FACTORY_CLASS_NAME);
- }
-
- public void tearDown() throws Exception {
- hsqlds.getConnection().createStatement().execute("SHUTDOWN");
- }
-
- public void testEmpty() {
- cf.beginTransaction();
- ConfStoreConnection conn = cf.getConnection();
- assertEquals(0, conn.getDeploymentUnits().size());
- assertNull(conn.getDeploymentUnit("foobar"));
- cf.commitTransaction();
- }
-
- public void testCreateDU() {
- cf.beginTransaction();
- ConfStoreConnection conn = cf.getConnection();
- try {
- DeploymentUnitDAO du = conn.createDeploymentUnit("foo");
- assertNotNull(du);
- assertEquals("foo", du.getName());
- assertNotNull(du.getDeployDate());
- } finally {
- cf.commitTransaction();
- }
-
- cf.beginTransaction();
- conn = cf.getConnection();
- try {
- DeploymentUnitDAO du = conn.getDeploymentUnit("foo");
- assertNotNull(du);
- assertEquals("foo", du.getName());
- } finally {
- cf.commitTransaction();
- }
-
- }
-
- public void testRollback() {
- cf.beginTransaction();
- ConfStoreConnection conn = cf.getConnection();
- try {
- DeploymentUnitDAO du = conn.createDeploymentUnit("foo");
- assertNotNull(du);
- assertEquals("foo", du.getName());
- assertNotNull(du.getDeployDate());
- } finally {
- cf.rollbackTransaction();
- }
-
- cf.beginTransaction();
- conn = cf.getConnection();
- try {
- DeploymentUnitDAO du = conn.getDeploymentUnit("foo");
- assertNull(du);
- } finally {
- cf.commitTransaction();
- }
- }
-
- public void testGetDeploymentUnits() {
- cf.beginTransaction();
- ConfStoreConnection conn = cf.getConnection();
- try {
- conn.createDeploymentUnit("foo1");
- conn.createDeploymentUnit("foo2");
- conn.createDeploymentUnit("foo3");
- conn.createDeploymentUnit("foo4");
- } finally {
- cf.commitTransaction();
- }
-
- cf.beginTransaction();
- conn = cf.getConnection();
- try {
- assertNotNull(conn.getDeploymentUnit("foo1"));
- assertNotNull(conn.getDeploymentUnit("foo2"));
- assertNotNull(conn.getDeploymentUnit("foo3"));
- assertNotNull(conn.getDeploymentUnit("foo4"));
- assertNull(conn.getDeploymentUnit("foo5"));
- } finally {
- cf.commitTransaction();
- }
- }
-
- public void testCreateProcess() {
- QName foobar = new QName("foo","bar");
- cf.beginTransaction();
- ConfStoreConnection conn = cf.getConnection();
- try {
- DeploymentUnitDAO du = conn.createDeploymentUnit("foo1");
- ProcessConfDAO p = du.createProcess(foobar,foobar,1);
- assertEquals(foobar,p.getPID());
- assertEquals(foobar,p.getType());
- assertNotNull(p.getDeploymentUnit());
- assertEquals("foo1", p.getDeploymentUnit().getName());
- } finally {
- cf.commitTransaction();
- }
-
- cf.beginTransaction();
- conn = cf.getConnection();
- try {
- DeploymentUnitDAO du = conn.getDeploymentUnit("foo1");
- ProcessConfDAO p = du.getProcess(foobar);
- assertNotNull(p);
- assertNotNull(du.getProcesses());
-
- assertEquals(foobar,p.getPID());
- assertEquals(foobar,p.getType());
- } finally {
- cf.commitTransaction();
- }
- }
-
- public void testProcessProperties() {
- QName foobar = new QName("foo","bar");
- cf.beginTransaction();
- ConfStoreConnection conn = cf.getConnection();
- try {
- DeploymentUnitDAO du = conn.createDeploymentUnit("foo1");
- ProcessConfDAO p = du.createProcess(foobar,foobar,1);
- p.setProperty(foobar,"baz");
- } finally {
- cf.commitTransaction();
- }
-
- cf.beginTransaction();
- conn = cf.getConnection();
- try {
- DeploymentUnitDAO du = conn.getDeploymentUnit("foo1");
- ProcessConfDAO p = du.getProcess(foobar);
- assertNotNull(p.getProperty(foobar));
- assertEquals("baz", p.getProperty(foobar));
- assertNotNull(p.getPropertyNames());
- assertTrue(p.getPropertyNames().contains(foobar));
- } finally {
- cf.commitTransaction();
- }
- }
-}
\ No newline at end of file
Modified: branches/ODE/ODE-1.x-jpa/bpel-test/pom.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-test/pom.xml 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-test/pom.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -146,26 +146,110 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
- <dependency>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
- </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!-- for the integration tests - seems to work with the openjpa enhanced enities -->
+ <dependency>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-dao-jpa-hibernate</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-dao-jpa-ojpa</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-dao-hibernate</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <!-- FIXME: temporary skip it, 3 failed test cases (2 in JDK6, 3 in JDK5): testIMA, testRetireOld, testIsolated**-->
- <excludes>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- FIXME: temporary skip it, 3 failed test cases (2 in JDK6, 3 in JDK5): testIMA, testRetireOld, testIsolated**-->
+ <excludes>
<exclude>**/MessageRouting20Test.java</exclude>
- <exclude>**/VersionedRedeployTest.java</exclude>
- <!--exclude>**/StructuredActivities20Test.java</exclude-->
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ <exclude>**/VersionedRedeployTest.java</exclude>
+ <exclude>**/StructuredActivities20Test.java</exclude>
+ <exclude>**/ProcessManagementDaoTest.java</exclude>
+ <exclude>**/SelectObjectTest.java</exclude>
+ </excludes>
+ </configuration>
+ <executions>
+ <execution>
+ <id>hibernate-jpa</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <reportsDirectory>${project.build.directory}/surefire-reports/hibernate-jpa</reportsDirectory>
+ <systemProperties>
+ <property>
+ <name>dao.factory</name>
+ <value>org.apache.ode.dao.jpa.hibernate.BpelDAOConnectionFactoryImpl</value>
+ </property>
+ <property>
+ <name>dao.factory.store</name>
+ <value>org.apache.ode.dao.jpa.hibernate.ConfStoreDAOConnectionFactoryImpl</value>
+ </property>
+ </systemProperties>
+ <includes>
+ <include>**/dao/bpel/*Test.java</include>
+ <include>**/dao/bpel/*Test.java</include>
+ </includes>
+ </configuration>
+ </execution>
+ <execution>
+ <id>hibernate</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <reportsDirectory>${project.build.directory}/surefire-reports/hibernate</reportsDirectory>
+ <systemProperties>
+ <property>
+ <name>dao.factory</name>
+ <value>org.apache.ode.dao.hib.bpel.BpelDAOConnectionFactoryImpl</value>
+ </property>
+ <property>
+ <name>dao.factory.store</name>
+ <value>org.apache.ode.dao.hib.store.ConfStoreDAOConnectionFactoryImpl</value>
+ </property>
+ </systemProperties>
+ <includes>
+ <include>**/dao/bpel/*Test.java</include>
+ <include>**/dao/bpel/*Test.java</include>
+ </includes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ <configuration>
+ <testClassesDirectory>src/test/resources/bpel/2.0</testClassesDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
Modified: branches/ODE/ODE-1.x-jpa/bpel-test/src/main/java/org/apache/ode/test/BPELTestAbstract.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-test/src/main/java/org/apache/ode/test/BPELTestAbstract.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-test/src/main/java/org/apache/ode/test/BPELTestAbstract.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -25,7 +25,9 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future;
@@ -35,12 +37,12 @@
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
import javax.xml.namespace.QName;
import org.apache.ode.bpel.common.evt.DebugBpelEventListener;
-import org.apache.ode.bpel.dao.BpelDAOConnectionFactory;
import org.apache.ode.bpel.engine.BpelServerImpl;
+import org.apache.ode.bpel.iapi.EndpointReference;
+import org.apache.ode.bpel.iapi.EndpointReferenceContext;
import org.apache.ode.bpel.iapi.Message;
import org.apache.ode.bpel.iapi.MessageExchange;
import org.apache.ode.bpel.iapi.MyRoleMessageExchange;
@@ -50,9 +52,11 @@
import org.apache.ode.bpel.iapi.MessageExchange.Status;
import org.apache.ode.bpel.iapi.MyRoleMessageExchange.CorrelationStatus;
import org.apache.ode.bpel.memdao.BpelDAOConnectionFactoryImpl;
-import org.apache.ode.dao.jpa.BPELDAOConnectionFactoryImpl;
+import org.apache.ode.dao.bpel.BpelDAOConnectionFactory;
+import org.apache.ode.dao.store.ConfStoreDAOConnectionFactory;
import org.apache.ode.il.MockScheduler;
import org.apache.ode.il.config.OdeConfigProperties;
+import org.apache.ode.il.dbutil.Database;
import org.apache.ode.store.ProcessConfImpl;
import org.apache.ode.store.ProcessStoreImpl;
import org.apache.ode.utils.DOMUtils;
@@ -79,7 +83,9 @@
protected MockScheduler scheduler;
- protected BpelDAOConnectionFactory _cf;
+ protected BpelDAOConnectionFactory _bcf;
+
+ protected ConfStoreDAOConnectionFactory _scf;
/** Failures that have been detected. */
protected List<Failure> _failures;
@@ -92,6 +98,10 @@
/** What's actually been deployed. */
private List<Deployment> _deployed;
+
+ private MockTransactionManager _txm;
+
+ private Database _db;
@Before
public void setUp() throws Exception {
@@ -101,12 +111,17 @@
_deployments = new ArrayList<Deployment>();
_invocations = new ArrayList<Invocation>();
_deployed = new ArrayList<Deployment>();
+
+ _txm = new MockTransactionManager();
+ Properties props = new Properties();
+ props.setProperty(OdeConfigProperties.PROP_DAOCF_STORE, System.getProperty(OdeConfigProperties.PROP_DAOCF_STORE,OdeConfigProperties.DEFAULT_DAOCF_STORE_CLASS));
+ OdeConfigProperties odeProps = new OdeConfigProperties(props,"");
+ _db = new Database(odeProps);
+ _db.setTransactionManager(_txm);
+ _db.start();
if (Boolean.getBoolean("org.apache.ode.test.persistent")) {
- emf = Persistence.createEntityManagerFactory("ode-unit-test-embedded");
- em = emf.createEntityManager();
- _cf = new BPELDAOConnectionFactoryImpl();
- _server.setDaoConnectionFactory(_cf);
+ _server.setDaoConnectionFactory(_bcf);
scheduler = new MockScheduler() {
@Override
public void beginTransaction() {
@@ -128,16 +143,32 @@
};
} else {
- scheduler = new MockScheduler();
- _cf = new BpelDAOConnectionFactoryImpl(scheduler);
- _server.setDaoConnectionFactory(_cf);
+ scheduler = new MockScheduler(_txm);
+ _bcf = new BpelDAOConnectionFactoryImpl(scheduler);
+ _bcf.init(null, _txm, _txm);
+ _server.setDaoConnectionFactory(_bcf);
}
_server.setInMemDaoConnectionFactory(new BpelDAOConnectionFactoryImpl(scheduler));
_server.setScheduler(scheduler);
_server.setBindingContext(new BindingContextImpl());
_server.setMessageExchangeContext(mexContext);
scheduler.setJobProcessor(_server);
- store = new ProcessStoreImpl(null, null, "jpa", new OdeConfigProperties(new Properties(), ""), true);
+ final EndpointReferenceContext eprContext = new EndpointReferenceContext() {
+ public EndpointReference resolveEndpointReference(Element epr) {
+ return null;
+ }
+
+ public EndpointReference convertEndpoint(QName targetType, Element sourceEndpoint) {
+ return null;
+ }
+
+ public Map getConfigLookup(EndpointReference epr) {
+ return Collections.EMPTY_MAP;
+ }
+ };
+
+ _scf = _db.createDaoStoreCF();
+ store = new ProcessStoreImpl(eprContext, _txm, _scf);
store.registerListener(new ProcessStoreListener() {
public void onProcessStoreEvent(ProcessStoreEvent event) {
// bounce the process
Added: branches/ODE/ODE-1.x-jpa/bpel-test/src/main/java/org/apache/ode/test/MockTransactionManager.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-test/src/main/java/org/apache/ode/test/MockTransactionManager.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-test/src/main/java/org/apache/ode/test/MockTransactionManager.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,237 @@
+/*
+ * 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.test;
+
+import java.util.ArrayList;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.xa.XAResource;
+
+/**
+ * A minimal transaction manager that can be used for testing.
+ *
+ * @author Maciej Szefler <mszefler at gmail dot com>
+ *
+ */
+public class MockTransactionManager implements TransactionManager {
+ ThreadLocal<TX> _transaction = new ThreadLocal<TX>();
+
+ public void begin() throws NotSupportedException, SystemException {
+ if (_transaction.get() != null)
+ throw new NotSupportedException("Transaction active (nested tx not supported): " + _transaction.get());
+
+ _transaction.set(new TX());
+ }
+
+ public void commit() throws HeuristicMixedException, HeuristicRollbackException, IllegalStateException, RollbackException,
+ SecurityException, SystemException {
+ if (_transaction.get() == null)
+ throw new IllegalStateException("Transaction not active. ");
+
+ try {
+ _transaction.get().commit();
+ } finally {
+ _transaction.set(null);
+ }
+ }
+
+ public int getStatus() throws SystemException {
+ if (_transaction.get() == null)
+ return Status.STATUS_NO_TRANSACTION;
+
+ return _transaction.get().getStatus();
+
+ }
+
+ public Transaction getTransaction() throws SystemException {
+ return _transaction.get();
+ }
+
+ public void resume(Transaction tx) throws IllegalStateException, InvalidTransactionException, SystemException {
+ if (_transaction.get() != null)
+ throw new IllegalStateException("Transaction is active in current thread: " + _transaction.get());
+ try {
+ _transaction.set((TX) tx);
+ } catch (ClassCastException cce) {
+ throw new InvalidTransactionException();
+ }
+
+ }
+
+ public void rollback() throws IllegalStateException, SecurityException, SystemException {
+ if (_transaction.get() == null)
+ throw new IllegalStateException("Transaction not active. ");
+
+ try {
+ _transaction.get().rollback();
+ } finally {
+ _transaction.set(null);
+ }
+ }
+
+ public void setRollbackOnly() throws IllegalStateException, SystemException {
+ if (_transaction.get() == null)
+ throw new IllegalStateException("Transaction not active. ");
+
+ _transaction.get().setRollbackOnly();
+
+ }
+
+ public void setTransactionTimeout(int arg0) throws SystemException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Transaction suspend() throws SystemException {
+ try {
+ return _transaction.get();
+ } finally {
+ _transaction.set(null);
+ }
+ }
+
+
+ protected void doBegin(TX tx) {}
+ protected void doCommit(TX tx) {}
+ protected void doRollback(TX tx){}
+
+ public class TX implements Transaction {
+
+ final ArrayList<XAResource> _resources = new ArrayList<XAResource>();
+
+ final ArrayList<Synchronization> _synchros = new ArrayList<Synchronization> ();
+
+ private int _status;
+
+ public void commit() throws HeuristicMixedException, HeuristicRollbackException, RollbackException, SecurityException,
+ SystemException {
+ switch (_status) {
+ case Status.STATUS_COMMITTED:
+ return;
+ case Status.STATUS_MARKED_ROLLBACK:
+ rollback();
+ throw new RollbackException("Transaction was marked for rollback!");
+ case Status.STATUS_ACTIVE:
+ fireBefore();
+ if (_status == Status.STATUS_MARKED_ROLLBACK) {
+ rollback();
+ throw new RollbackException("Transaction was marked for rollback in beforeCompletion handler.");
+ }
+ _status = Status.STATUS_COMMITTING;
+ try {
+ doCommit(this);
+ _status = Status.STATUS_COMMITTED;
+ } catch (Exception ex) {
+ _status = Status.STATUS_ROLLEDBACK;
+ throw new RollbackException("Transaction was rolled back due to commit failure." );
+ } finally {
+ fireAfter();
+ }
+ break;
+ default:
+ throw new IllegalStateException("Unexpected transaction state.");
+ }
+ }
+
+ public boolean delistResource(XAResource arg0, int arg1) throws IllegalStateException, SystemException {
+ // TODO: perhaps we should do something with the resources?
+ _resources.remove(arg0);
+ return true;
+ }
+
+ public boolean enlistResource(XAResource r) throws IllegalStateException, RollbackException, SystemException {
+ return _resources.add(r);
+ }
+
+ public int getStatus() throws SystemException {
+ return _status;
+ }
+
+ public void registerSynchronization(Synchronization synch) throws IllegalStateException, RollbackException, SystemException {
+ _synchros.add(synch);
+ }
+
+ public void rollback() throws IllegalStateException, SystemException {
+ // TODO Auto-generated method stub
+ switch (_status) {
+ case Status.STATUS_ROLLEDBACK:
+ return;
+ case Status.STATUS_MARKED_ROLLBACK:
+ case Status.STATUS_ACTIVE:
+ _status = Status.STATUS_ROLLING_BACK;
+ try {
+ doRollback(this);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ } finally {
+ _status = Status.STATUS_ROLLEDBACK;
+ fireAfter();
+ }
+ break;
+ default:
+ throw new IllegalStateException("Unexpected transaction state.");
+ }
+ }
+
+ public void setRollbackOnly() throws IllegalStateException, SystemException {
+ switch (_status) {
+ case Status.STATUS_ACTIVE:
+ case Status.STATUS_MARKED_ROLLBACK:
+ _status = Status.STATUS_MARKED_ROLLBACK;
+ break;
+ case Status.STATUS_ROLLEDBACK:
+ case Status.STATUS_ROLLING_BACK:
+ break;
+ default:
+ throw new IllegalStateException();
+ }
+ }
+
+ private void fireBefore() {
+ for (Synchronization s : _synchros)
+ try {
+ s.beforeCompletion();
+ } catch (Throwable t) {
+ ; // ignore errors.
+ }
+
+ }
+
+ private void fireAfter() {
+ for (Synchronization s : _synchros)
+ try {
+ s.afterCompletion(_status);
+ } catch (Throwable t) {
+ ; // ignore errors.
+ }
+
+ }
+
+ }
+
+}
Modified: branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/VersionedRedeployTest.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/VersionedRedeployTest.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/VersionedRedeployTest.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -64,24 +64,24 @@
// Checking for each step that all instances still exist and that each process got one execution
// so no instance has been created after a process has been retired.
go("/bpel/2.0/TestVersionedRedeploy/HelloWorld-1");
- Assert.assertEquals(1, _cf.getConnection().getProcess(qName1).getNumInstances());
+ Assert.assertEquals(1, _bcf.getConnection().getProcess(qName1).getNumInstances());
// clean up deployment and invocations
_deployments.clear();
_invocations.clear();
go("/bpel/2.0/TestVersionedRedeploy/HelloWorld-2");
- Assert.assertEquals(1, _cf.getConnection().getProcess(qName1).getNumInstances());
- Assert.assertEquals(1, _cf.getConnection().getProcess(qName2).getNumInstances());
+ Assert.assertEquals(1, _bcf.getConnection().getProcess(qName1).getNumInstances());
+ Assert.assertEquals(1, _bcf.getConnection().getProcess(qName2).getNumInstances());
// clean up deployment and invocations
_deployments.clear();
_invocations.clear();
go("/bpel/2.0/TestVersionedRedeploy/HelloWorld-3");
- Assert.assertEquals(1, _cf.getConnection().getProcess(qName1).getNumInstances());
- Assert.assertEquals(1, _cf.getConnection().getProcess(qName2).getNumInstances());
- Assert.assertEquals(1, _cf.getConnection().getProcess(qName3).getNumInstances());
+ Assert.assertEquals(1, _bcf.getConnection().getProcess(qName1).getNumInstances());
+ Assert.assertEquals(1, _bcf.getConnection().getProcess(qName2).getNumInstances());
+ Assert.assertEquals(1, _bcf.getConnection().getProcess(qName3).getNumInstances());
}
@Test public void testVersionedUndeployDeploy() throws Throwable {
@@ -96,7 +96,7 @@
Assert.assertNull(store.getProcessConfiguration(qName1));
Assert.assertNull(store.getProcessConfiguration(qName3));
- Assert.assertEquals(1, _cf.getConnection().getProcess(qName2).getNumInstances());
+ Assert.assertEquals(1, _bcf.getConnection().getProcess(qName2).getNumInstances());
}
}
Added: branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/dao/bpel/BaseTestDAO.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/dao/bpel/BaseTestDAO.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/dao/bpel/BaseTestDAO.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,78 @@
+/*
+ * 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.test.dao.bpel;
+
+import java.util.Properties;
+
+import javax.transaction.TransactionManager;
+
+import junit.framework.TestCase;
+
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.BpelDAOConnectionFactory;
+import org.apache.ode.il.EmbeddedGeronimoFactory;
+import org.apache.ode.il.config.OdeConfigProperties;
+import org.apache.ode.il.dbutil.Database;
+
+/**
+ * Testing BpelDAOConnectionImpl.listInstance. We're just producing a lot
+ * of different filter combinations and test if they execute ok. To really
+ * test that the result is the one expected would take a huge test database
+ * (with at least a process and an instance for every possible combination).
+ */
+public abstract class BaseTestDAO extends TestCase {
+
+ protected BpelDAOConnection daoConn;
+ protected TransactionManager _txm;
+ private Database _db;
+ protected BpelDAOConnectionFactory _factoryImpl;
+
+ protected void initTM() throws Exception {
+ _txm = new EmbeddedGeronimoFactory().getTransactionManager();
+ Properties props = new Properties();
+ props.setProperty(OdeConfigProperties.PROP_DAOCF, System.getProperty(OdeConfigProperties.PROP_DAOCF,OdeConfigProperties.DEFAULT_DAOCF_CLASS));
+ OdeConfigProperties odeProps = new OdeConfigProperties(props,"");
+ _db = new Database(odeProps);
+ _db.setTransactionManager(_txm);
+ _db.start();
+ //txm.begin();
+
+ _factoryImpl = _db.createDaoCF();
+
+ _txm.begin();
+ daoConn = _factoryImpl.getConnection();
+
+ }
+
+ protected void stopTM() throws Exception {
+ _txm.commit();
+ daoConn.close();
+
+ _factoryImpl.shutdown();
+ _db.shutdown();
+
+
+ }
+
+ protected TransactionManager getTransactionManager() {
+ return _txm;
+ }
+
+}
\ No newline at end of file
Added: branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/dao/bpel/InsertObjectTest.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/dao/bpel/InsertObjectTest.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/dao/bpel/InsertObjectTest.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,165 @@
+/*
+ * 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.test.dao.bpel;
+
+import java.io.IOException;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+import javax.xml.namespace.QName;
+
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.bpel.common.CorrelationKeySet;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.CorrelationSetDAO;
+import org.apache.ode.dao.bpel.CorrelatorDAO;
+import org.apache.ode.dao.bpel.MessageDAO;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
+import org.apache.ode.dao.bpel.PartnerLinkDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.ScopeDAO;
+import org.apache.ode.dao.bpel.ScopeStateEnum;
+import org.apache.ode.dao.bpel.XmlDataDAO;
+import org.apache.ode.utils.DOMUtils;
+import org.xml.sax.SAXException;
+
+public class InsertObjectTest extends BaseTestDAO {
+
+ private static final String TEST_NS = "http://org.apache.ode.jpa.test";
+ private static final String CORRELATOR_ID1 = "testCorrelator1";
+ private static final String CORRELATOR_ID2 = "testCorrelator2";
+ private static final Calendar cal = new GregorianCalendar();
+
+ ProcessDAO _process;
+
+ @Override
+ protected void setUp() throws Exception {
+ initTM();
+ }
+
+ public void testStart() throws Exception {
+ createStuff(daoConn);
+ }
+
+ void createStuff(BpelDAOConnection conn) throws Exception {
+
+ CorrelatorDAO corr = createProcess(conn,"testPID1","testType");
+ ProcessInstanceDAO pi1 = createProcessInstance(_process, corr);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ stopTM();
+ }
+
+ private MessageExchangeDAO createMessageExchange(ProcessDAO p, ProcessInstanceDAO pi, PartnerLinkDAO pl ) throws SAXException, IOException {
+ MessageExchangeDAO me = pi.getConnection().createMessageExchange('0');
+
+ me.setCallee(new QName(TEST_NS,"testCallee"));
+ me.setChannel("testChannel");
+ me.setCorrelationId("testCorrelationId");
+ me.setCorrelationStatus("testCorrelationStatus");
+ me.setEPR(DOMUtils.stringToDOM("<testEPR>EPR</testEPR>"));
+ me.setFault(new QName("testFault"));
+ me.setFaultExplanation("testFaultExplanation");
+ me.setInstance(pi);
+ me.setOperation("testOperation");
+ me.setPartnerLink(pl);
+ me.setPartnerLinkModelId(1);
+ me.setPattern("testPattern");
+ me.setPortType(new QName(TEST_NS,"testPortType"));
+ me.setProcess(p);
+ me.setProperty("testProp1Key", "testProp1");
+ me.setProperty("testProp2Key", "testProp2");
+ me.setRequest(createMessage(me,"testRequest"));
+ me.setResponse(createMessage(me,"testResponse"));
+ me.setStatus("testStatus");
+
+ return me;
+ }
+
+ private MessageDAO createMessage(MessageExchangeDAO me, String name) throws SAXException, IOException {
+ MessageDAO m = me.createMessage(new QName(TEST_NS,name));
+
+ m.setType(new QName(TEST_NS,name));
+ m.setData(DOMUtils.stringToDOM("<testData>some test data</testData>"));
+
+ return m;
+ }
+
+ private CorrelatorDAO createProcess(BpelDAOConnection conn, String pid, String type) {
+ _process = conn.createProcess(new QName(TEST_NS,pid), new QName(TEST_NS,type),"GUID1",1);
+ CorrelatorDAO corr = _process.addCorrelator(CORRELATOR_ID1);
+ _process.addCorrelator(CORRELATOR_ID2);
+ return corr;
+ }
+
+ private ProcessInstanceDAO createProcessInstance(ProcessDAO process, CorrelatorDAO corr) throws SAXException, IOException {
+ ProcessInstanceDAO pi = null;
+ String[] actions = { "action1","action2" };
+ String[] correlationKeys = { "key1", "key2" };
+ CorrelationKey key1 = new CorrelationKey("key1",correlationKeys);
+ CorrelationKey key2 = new CorrelationKey("key2",correlationKeys);
+ CorrelationKey[] corrkeys = {key1,key2};
+ QName[] names = { new QName(TEST_NS,"name1"), new QName(TEST_NS,"name2") };
+
+ pi = process.createInstance(corr);
+
+ pi.setExecutionState(new String("test execution state").getBytes());
+ pi.setFault(new QName(TEST_NS,"testFault"), "testExplanation", 1, 1, DOMUtils.stringToDOM("<testFaultMessage>testMessage</testFaultMessage>"));
+ pi.setLastActiveTime(cal.getTime());
+ pi.setState((short) 1);
+
+ pi.createActivityRecovery("testChannel1", 3, "testReason1", cal.getTime(), DOMUtils.stringToDOM("<testData>testData1</testData>"), actions, 2);
+ pi.createActivityRecovery("testChannel2", 4, "testReason2", cal.getTime(), DOMUtils.stringToDOM("<testData>testData2</testData>"), actions, 2);
+
+ ScopeDAO root = pi.createScope(null, "Root", 1);
+ root.setState(ScopeStateEnum.ACTIVE);
+ ScopeDAO child1 = pi.createScope(root, "Child1", 2);
+ child1.setState(ScopeStateEnum.ACTIVE);
+ XmlDataDAO var1 = child1.getVariable("var1");
+ var1.set(DOMUtils.stringToDOM("<testData>testData</testData>"));
+ var1.setProperty("key1", "prop1");
+ var1.setProperty("key2", "prop2");
+ XmlDataDAO var2 = child1.getVariable("var2");
+ var2.set(DOMUtils.stringToDOM("<testData>testData</testData>"));
+ var2.setProperty("key1", "prop1");
+ var2.setProperty("key2", "prop2");
+
+ CorrelationSetDAO cs1 = child1.getCorrelationSet("TestCorrelationSet1");
+ cs1.setValue(names,key1);
+
+ PartnerLinkDAO pl1 = child1.createPartnerLink(1, "Test PartnerLink1", "MyRole1", "PartnerRole1");
+ pl1.setMyEPR(DOMUtils.stringToDOM("<testEPR>testMyEPR</testEPR>"));
+ pl1.setMyRoleServiceName(new QName(TEST_NS,"testRoleService"));
+ pl1.setMySessionId("TestMySessionID");
+ pl1.setPartnerEPR(DOMUtils.stringToDOM("<testEPR>testPartnerEPR</testEPR>"));
+ pl1.setPartnerSessionId("TestPartnerSessionID");
+
+ MessageExchangeDAO mex = createMessageExchange(process,pi,pl1);
+
+ corr.addRoute("testRoute", pi, 1, new CorrelationKeySet().add(key1), "one");
+ corr.enqueueMessage(mex, new CorrelationKeySet().add(corrkeys[0]).add(corrkeys[1]));
+
+ return pi;
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/dao/bpel/ListInstanceTest.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/dao/bpel/ListInstanceTest.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/dao/bpel/ListInstanceTest.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,109 @@
+/*
+ * 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.test.dao.bpel;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.ode.bpel.common.InstanceFilter;
+
+/**
+ * Testing BpelDAOConnectionImpl.listInstance. We're just producing a lot
+ * of different filter combinations and test if they execute ok. To really
+ * test that the result is the one expected would take a huge test database
+ * (with at least a process and an instance for every possible combination).
+ */
+public class ListInstanceTest extends BaseTestDAO {
+
+ private Map<String, List> filterElmts;
+ private ArrayList<String> order;
+
+ protected void setUp() throws Exception {
+ initTM();
+ buildFilterElements();
+ }
+
+ protected void tearDown() throws Exception {
+ stopTM();
+ }
+
+ public void testListInstance() throws Exception {
+ for (int index = 0; index < 7; index++) {
+ StringBuffer filter = new StringBuffer();
+ for (Map.Entry<String, List> entry : filterElmts.entrySet()) {
+ filter.append(entry.getKey());
+ filter.append(entry.getValue().get((index < entry.getValue().size()) ? index : index % entry.getValue().size()));
+ InstanceFilter ifilter = new InstanceFilter(filter.toString(),
+ order.get((index < order.size()) ? index : index % order.size()), 0);
+ daoConn.instanceQuery(ifilter);
+ }
+ }
+ }
+
+ private void buildFilterElements() {
+ filterElmts = new HashMap<String, List>();
+ ArrayList<String> nameList = new ArrayList<String>();
+ nameList.add("=Hello* ");
+ nameList.add("=HelloWorld ");
+ filterElmts.put("name", nameList);
+
+ ArrayList<String> namespaceList = new ArrayList<String>();
+ namespaceList.add("=http://ode* ");
+ namespaceList.add("=http://ode ");
+ filterElmts.put("namespace", namespaceList);
+
+ ArrayList<String> statusList = new ArrayList<String>();
+ statusList.add("=active ");
+ statusList.add("=suspended ");
+ statusList.add("=error ");
+ statusList.add("=completed|terminated ");
+ statusList.add("=faulted|terminated ");
+ statusList.add("=error|active ");
+ filterElmts.put("status", statusList);
+
+ ArrayList<String> startedList = new ArrayList<String>();
+ startedList.add(">=2005-11-29T15:11 ");
+ startedList.add("<=2005-11-29T15:11 ");
+ startedList.add("<2005-11-29T15:11 started>=2005-11-29T15:11 ");
+ startedList.add(">2005-11-29T15:11 started<=2005-11-29T15:11 ");
+ startedList.add("=2005-11-29T15:11 ");
+ filterElmts.put("started", startedList);
+
+ ArrayList<String> lastActiveList = new ArrayList<String>();
+ lastActiveList.add(">=2005-11-29T15:11 ");
+ lastActiveList.add("<=2005-11-29T15:11 ");
+ lastActiveList.add("<2005-11-29T15:11 last-active>=2005-11-29T15:11 ");
+ lastActiveList.add(">2005-11-29T15:11 last-active<=2005-11-29T15:11 ");
+ lastActiveList.add("=2005-11-29T15:11 ");
+ filterElmts.put("last-active", lastActiveList);
+
+ order = new ArrayList<String>();
+ order.add("pid");
+ order.add("name pid");
+ order.add("namespace -name");
+ order.add("version -pid +name");
+ order.add("status namespace");
+ order.add("-started -version status");
+ order.add("+last-active name -pid +version -status namespace");
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/dao/bpel/ProcessManagementDaoTest.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/dao/bpel/ProcessManagementDaoTest.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/dao/bpel/ProcessManagementDaoTest.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,78 @@
+/*
+ * 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.test.dao.bpel;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+import org.apache.ode.bpel.common.InstanceFilter;
+import org.apache.ode.bpel.common.ProcessState;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.ProcessManagementDAO.FailedSummaryValue;
+import org.apache.ode.dao.bpel.ProcessManagementDAO.InstanceSummaryKey;
+
+/**
+ * Testing BpelDAOConnectionImpl.listInstance. We're just producing a lot of
+ * different filter combinations and test if they execute ok. To really test
+ * that the result is the one expected would take a huge test database (with at
+ * least a process and an instance for every possible combination).
+ */
+public class ProcessManagementDaoTest extends BaseTestDAO {
+
+ protected void setUp() throws Exception {
+ initTM();
+ }
+
+ protected void tearDown() throws Exception {
+ stopTM();
+ }
+
+
+ public void testInstanceSummary() throws Exception {
+ Set<String> pids = new HashSet<String>();
+ QName pid = QName.valueOf("{ns}pid");
+ pids.add(pid.toString());
+ ProcessDAO p = daoConn.createProcess(pid, QName.valueOf("{ns}type"), "abc", 1);
+ ProcessInstanceDAO i = p.createInstance(p.addCorrelator("cor"));
+ i.setState(ProcessState.STATE_COMPLETED_OK);
+ Map<InstanceSummaryKey, Long> r = daoConn.getProcessManagement().countInstancesSummary(pids);
+ System.out.println("resultSummary:" + r);
+ assertEquals(1, r.size());
+ }
+
+ public void testInstanceSummaryFailures() throws Exception {
+ Set<String> pids = new HashSet<String>();
+ QName pid = QName.valueOf("{ns}pid");
+ pids.add(pid.toString());
+ ProcessDAO p = daoConn.createProcess(pid, QName.valueOf("{ns}type"), "abc", 1);
+ ProcessInstanceDAO i = p.createInstance(p.addCorrelator("cor"));
+ Map<String, FailedSummaryValue> r = daoConn.getProcessManagement().findFailedCountAndLastFailedDateForProcessIds(pids);
+ System.out.println("resultSummary:" + r);
+ assertEquals(0, r.size());
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/dao/bpel/SelectObjectTest.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/dao/bpel/SelectObjectTest.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/bpel-test/src/test/java/org/apache/ode/test/dao/bpel/SelectObjectTest.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,275 @@
+/*
+ * 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.test.dao.bpel;
+
+import java.util.Collection;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.xml.namespace.QName;
+
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.bpel.common.CorrelationKeySet;
+import org.apache.ode.dao.bpel.ActivityRecoveryDAO;
+import org.apache.ode.dao.bpel.CorrelationSetDAO;
+import org.apache.ode.dao.bpel.CorrelatorDAO;
+import org.apache.ode.dao.bpel.FaultDAO;
+import org.apache.ode.dao.bpel.MessageDAO;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
+import org.apache.ode.dao.bpel.MessageRouteDAO;
+import org.apache.ode.dao.bpel.PartnerLinkDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.ScopeDAO;
+import org.apache.ode.dao.bpel.ScopeStateEnum;
+import org.apache.ode.dao.bpel.XmlDataDAO;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class SelectObjectTest extends BaseTestDAO {
+
+ private EntityManager em;
+ private static final String TEST_NS = "http://org.apache.ode.jpa.test";
+ private String[] correlationKeys = { "key1", "key2" };
+ private String[] actions = { "action1","action2" };
+ private CorrelationKey key1 = new CorrelationKey("key1",correlationKeys);
+ private static final String CORRELATOR_ID1 = "testCorrelator1";
+ private static final String CORRELATOR_ID2 = "testCorrelator2";
+
+ @Override
+ protected void setUp() throws Exception {
+ initTM();
+ }
+
+ @Ignore
+ @Test
+ public void testGetObject() throws Exception {
+ new InsertObjectTest().createStuff(daoConn);
+
+ _txm.commit();
+ _txm.begin();
+
+ daoConn = _factoryImpl.getConnection();
+
+ // Assert the ProcessDAO
+ ProcessDAO p = daoConn.getProcess(new QName(TEST_NS,"testPID1"));
+ assertNotNull( p );
+ Collection<ProcessInstanceDAO> insts = p.findInstance(key1);
+ assertNotNull( insts );
+ assertTrue( insts.size() > 0 );
+ assertNotNull(p.getType());
+ assertNotNull(p.getProcessId());
+ assertEquals( p.getVersion() , 1 );
+
+ // Assert the CorrelatorDAO
+ CorrelatorDAO corr = p.getCorrelator(CORRELATOR_ID1);
+ assertNotNull( corr );
+ assertEquals(corr.getCorrelatorId(),CORRELATOR_ID1);
+
+ // Assert the MessageRouteDAO
+ List<MessageRouteDAO> routes = corr.findRoute(new CorrelationKeySet().add(key1));
+ MessageRouteDAO route = null;
+ if (routes != null && routes.size() > 0) {
+ route = routes.get(0);
+ }
+ assertNotNull( route );
+ assertEquals(route.getGroupId(),"testRoute" );
+ assertEquals(route.getIndex() , 1 );
+ assertNotNull(route.getTargetInstance() );
+
+ // Assert the ProcessInstanceDAO
+ for ( ProcessInstanceDAO inst : insts ) {
+ Long id = inst.getInstanceId();
+ assertNotNull( id );
+
+ ProcessInstanceDAO inst2 = daoConn.getInstance(id);
+ assertSame(inst2,inst);
+
+ ProcessInstanceDAO inst3 = p.getInstance(id);
+ assertSame( inst3 , inst );
+
+ Long mon = inst.genMonotonic();
+ assertEquals(inst.getActivityFailureCount() , 2);
+ assertNotNull(inst.getActivityFailureDateTime() );
+ assertNotNull(inst.getCreateTime() );
+ assertTrue(inst.getExecutionState().length > 0 );
+ assertNotNull(inst.getLastActiveTime() );
+ assertSame(inst.getProcess() , p );
+ assertEquals(inst.getPreviousState() , 0);
+ assertEquals(inst.getState() , 1);
+
+ // Assert the Root ScopeDAO
+ ScopeDAO rs = inst.getRootScope();
+ assertNotNull( rs );
+ assertNotNull(rs.getChildScopes());
+ ScopeDAO child1 = null;
+ for ( ScopeDAO childItr : rs.getChildScopes()){
+ child1 = childItr;
+ break;
+ }
+ assertNotNull(child1);
+ assertNotNull(rs.getCorrelationSets());
+ assertEquals(rs.getCorrelationSets().size() , 0 );
+ assertEquals(rs.getModelId(),1);
+ assertEquals(rs.getName(),"Root");
+ assertTrue(rs.getParentScope() == null);
+ assertNotNull(rs.getPartnerLinks());
+ assertEquals(rs.getPartnerLinks().size() ,0);
+ assertSame(rs.getProcessInstance(),inst);
+ assertNotNull(rs.getScopeInstanceId());
+ assertEquals(rs.getState(),ScopeStateEnum.ACTIVE);
+ assertNotNull(rs.getVariables());
+ assertEquals(rs.getVariables().size(),0);
+
+
+ // Assert the ActivityRecoveryDAO
+ assertNotNull(inst.getActivityRecoveries());
+ ActivityRecoveryDAO rec1 = null;
+ for (ActivityRecoveryDAO recItr : inst.getActivityRecoveries()) {
+ if (recItr.getActivityId() == 3) {
+ rec1 = recItr;break;
+ }
+ }
+ assertNotNull(rec1);
+ String tmpAct = rec1.getActions();
+// assertEquals(rec1.getActionsList(),actions);
+ assertEquals(rec1.getActivityId(),3);
+ assertEquals(rec1.getChannel(),"testChannel1");
+ assertNotNull(rec1.getDateTime());
+// assertNotNull(rec1.getDetails());
+ assertEquals(rec1.getReason(),"testReason1");
+ assertEquals(rec1.getRetries(),2);
+
+ // Assert the CorrelationSetDAO
+ //assertNotNull(inst.getCorrelationSets());
+ //CorrelationSetDAO cs1 = null;
+ //for ( CorrelationSetDAO csItr : inst.getCorrelationSets() ) {
+ // cs1 = csItr;
+ // break;
+ //}
+ //assertNotNull(cs1);
+
+ // Assert the FaultDAO
+ FaultDAO fault = inst.getFault();
+ assertNotNull(fault);
+ assertEquals(fault.getActivityId(),1);
+ assertNotNull(fault.getData());
+ assertEquals(fault.getExplanation(),"testExplanation");
+ assertEquals(fault.getLineNo(),1);
+ assertEquals(fault.getName(),new QName(TEST_NS,"testFault"));
+
+ // Assert MessageExchangeDAO
+ CorrelatorDAO ic = inst.getInstantiatingCorrelator();
+ assertNotNull(ic);
+ assertEquals(ic.getCorrelatorId(),CORRELATOR_ID1);
+ // The message is dequeued but not persisted
+ MessageExchangeDAO me = ic.dequeueMessage(new CorrelationKeySet().add(key1));
+ assertNotNull(me);
+ assertEquals(me.getCallee(),new QName(TEST_NS,"testCallee"));
+ assertEquals(me.getPropagateTransactionFlag(),false);
+ assertEquals(me.getChannel(),"testChannel");
+ assertEquals(me.getCorrelationId(),"testCorrelationId");
+ //assertNotNull(me.getCreateTime());
+ assertEquals(me.getDirection(),'0');
+ assertNotNull(me.getEPR());
+ assertEquals(me.getFault().toString(),"testFault");
+ assertEquals(me.getFaultExplanation(),"testFaultExplanation");
+ assertSame(me.getInstance(),inst);
+ assertEquals(me.getOperation(),"testOperation");
+ assertNotNull(me.getPartnerLink());
+ assertEquals(me.getPartnerLinkModelId(),1);
+ assertEquals(me.getPattern(),"testPattern");
+ assertEquals(me.getPortType(),new QName(TEST_NS,"testPortType"));
+ assertSame(me.getProcess(),p);
+ assertEquals(me.getProperty("testProp1Key"),"testProp1");
+ assertNotNull(me.getRequest());
+ assertNotNull(me.getResponse());
+ assertEquals(me.getStatus(),"testStatus");
+
+ // Assert MessageDAO
+ MessageDAO m = me.getRequest();
+ assertNotNull(m.getData());
+ assertSame(m.getMessageExchange(),me);
+ assertEquals(m.getType(),new QName(TEST_NS,"testRequest"));
+
+
+ //Assert Child ScopeDAO
+ assertNotNull(inst.getScopes());
+ assertTrue(inst.getScopes().size() > 0);
+ assertNotNull(inst.getScopes("Child1"));
+ assertTrue(inst.getScopes("Child1").size() == 1);
+ ScopeDAO childS = inst.getScopes("Child1").iterator().next();
+ assertSame(childS,child1);
+ assertSame(childS.getParentScope(),rs);
+ assertNotNull(childS.getChildScopes());
+ assertEquals(childS.getChildScopes().size(), 0);
+ assertNotNull(childS.getVariables());
+ assertTrue(childS.getVariables().size() > 0);
+ assertNotNull(childS.getVariable("var1"));
+ XmlDataDAO chsVar = childS.getVariable("var1");
+ assertNotNull(childS.getPartnerLinks());
+ assertTrue(childS.getPartnerLinks().size() > 0);
+ PartnerLinkDAO spl = childS.getPartnerLinks().iterator().next();
+ assertSame(spl,me.getPartnerLink());
+ assertSame(spl,childS.getPartnerLink(spl.getPartnerLinkModelId()));
+ assertNotNull(childS.getCorrelationSets());
+ assertTrue(childS.getCorrelationSets().size() > 0);
+ assertNotNull(childS.getCorrelationSet("TestCorrelationSet1"));
+
+ // Assert CorrelationSetDAO
+ CorrelationSetDAO cs = childS.getCorrelationSet("TestCorrelationSet1");
+ assertEquals(cs.getName(),"TestCorrelationSet1");
+ assertNotNull(cs.getProperties());
+ assertTrue(cs.getProperties().size() > 0);
+ assertSame(cs.getScope(),childS);
+ assertNotNull(cs.getValue());
+ assertEquals(cs.getProperties().get(new QName(TEST_NS,"name1")),"key1");
+
+
+ // Assert PartnerLinkDAO
+ assertNotNull(spl.getMyEPR());
+ assertEquals(spl.getMyRoleName(),"MyRole1");
+ assertEquals(spl.getMyRoleServiceName(),new QName(TEST_NS,"testRoleService"));
+ assertEquals(spl.getMySessionId(),"TestMySessionID");
+ assertNotNull(spl.getPartnerEPR());
+ assertEquals(spl.getPartnerLinkModelId(),1);
+ assertEquals(spl.getPartnerLinkName(),"Test PartnerLink1");
+ assertEquals(spl.getPartnerRoleName(),"PartnerRole1");
+ assertEquals(spl.getPartnerSessionId(),"TestPartnerSessionID");
+
+ // Assert Variables
+ assertNotNull(inst.getVariables("var1", 2));
+ assertEquals(inst.getVariables("var1", 2).length,1);
+ XmlDataDAO[] vars = inst.getVariables("var1", 2);
+ assertSame(chsVar,vars[0]);
+ assertNotNull(vars[0].get());
+ assertEquals(vars[0].getName(),"var1");
+ // assertEquals(vars[0].getProperty("key1"),"prop1");
+ assertSame(vars[0].getScopeDAO(),childS);
+
+ }
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ stopTM();
+ }
+
+}
Modified: branches/ODE/ODE-1.x-jpa/dao-hibernate/pom.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/pom.xml 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/pom.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -43,12 +43,10 @@
<dependency>
<groupId>org.jboss.soa.bpel</groupId>
<artifactId>riftsaw-bpel-epr</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
</dependency>
<dependency>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
@@ -88,7 +86,7 @@
<hibernatedoclet excludedTags="@version,@author,@todo" verbose="true"
destdir="${project.build.outputDirectory}" force="true">
<hibernate version="3.0"/>
- <fileset dir="${project.build.sourceDirectory}" includes="org/apache/ode/daohib/bpel/hobj/*.java"/>
+ <fileset dir="${project.build.sourceDirectory}" includes="org/apache/ode/dao/hib/bpel/hobj/*.java,org/apache/ode/dao/hib/store/hobj/*.java"/>
</hibernatedoclet>
</tasks>
</configuration>
@@ -108,7 +106,7 @@
<configuration>
<source>
import java.io.File
- def process_instance_hbm_file = new File('${project.build.outputDirectory}', 'org/apache/ode/daohib/bpel/hobj/HProcessInstance.hbm.xml')
+ def process_instance_hbm_file = new File('${project.build.outputDirectory}', 'org/apache/ode/dao/hib/bpel/hobj/HProcessInstance.hbm.xml')
def contents = process_instance_hbm_file.text
if (!contents.contains('not-found="ignore"')) {
process_instance_hbm_file.text = contents.replace('class="org.apache.ode.daohib.bpel.hobj.HProcess"',
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/DataSourceConnectionProvider.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/DataSourceConnectionProvider.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/DataSourceConnectionProvider.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -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.hib;
+
+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 = SessionManager.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: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/HibernateTransactionManagerLookup.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/HibernateTransactionManagerLookup.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/HibernateTransactionManagerLookup.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -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.hib;
+
+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 SessionManager} to obtain the JTA {@link TransactionManager} object.
+ */
+public class HibernateTransactionManagerLookup implements TransactionManagerLookup {
+
+ /** Constructor. */
+ public HibernateTransactionManagerLookup() {
+ super();
+ }
+
+ public TransactionManager getTransactionManager(Properties props)
+ throws HibernateException {
+ return SessionManager.getTransactionManager(props);
+ }
+
+ public String getUserTransactionName() {
+ return null;
+ }
+
+ public Object getTransactionIdentifier(Transaction transaction) {
+ return transaction;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/JotmTransaction.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/JotmTransaction.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/JotmTransaction.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,360 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.apache.ode.dao.hib;
+
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.HibernateException;
+import org.hibernate.Transaction;
+import org.hibernate.TransactionException;
+import org.hibernate.jdbc.JDBCContext;
+import org.hibernate.transaction.TransactionFactory;
+import org.hibernate.util.JTAHelper;
+
+/**
+ * {@link Transaction} implementation based on transaction management through
+ * a JTA {@link UserTransaction}. Similar to {@link CMTTransaction}, except
+ * here we are actually managing the transactions through the Hibernate
+ * transaction mechanism.
+ *
+ * @author Gavin King
+ * @author Steve Ebersole
+ * @author Les Hazlewood
+ *
+ * Scraped from org.hibernate
+ */
+public class JotmTransaction implements Transaction {
+ private static final Log log = LogFactory.getLog( JotmTransaction.class );
+
+ private final JDBCContext jdbcContext;
+ private final TransactionFactory.Context transactionContext;
+
+ private UserTransaction userTransaction;
+ private boolean newTransaction;
+ private boolean begun;
+ private boolean commitFailed;
+ private boolean commitSucceeded;
+ private boolean callback;
+
+ public JotmTransaction(
+ UserTransaction userTransaction,
+ JDBCContext jdbcContext,
+ TransactionFactory.Context transactionContext) {
+ this.jdbcContext = jdbcContext;
+ this.transactionContext = transactionContext;
+ this.userTransaction = userTransaction;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void begin() throws HibernateException {
+ if ( begun ) {
+ return;
+ }
+ if ( commitFailed ) {
+ throw new TransactionException( "cannot re-start transaction after failed commit" );
+ }
+
+ log.debug( "begin" );
+
+ try {
+ newTransaction = userTransaction.getStatus() == Status.STATUS_NO_TRANSACTION;
+ if ( newTransaction ) {
+ userTransaction.begin();
+ log.debug( "Began a new JTA transaction" );
+ }
+ }
+ catch ( Exception e ) {
+ log.error( "JTA transaction begin failed", e );
+ throw new TransactionException( "JTA transaction begin failed", e );
+ }
+
+ /*if (newTransaction) {
+ // don't need a synchronization since we are committing
+ // or rolling back the transaction ourselves - assuming
+ // that we do no work in beforeTransactionCompletion()
+ synchronization = false;
+ }*/
+
+ boolean synchronization = jdbcContext.registerSynchronizationIfPossible();
+
+ if ( !newTransaction && !synchronization ) {
+ log.warn( "You should set hibernate.transaction.manager_lookup_class if cache is enabled" );
+ }
+
+ if ( !synchronization ) {
+ //if we could not register a synchronization,
+ //do the before/after completion callbacks
+ //ourself (but we need to let jdbcContext
+ //know that this is what we are going to
+ //do, so it doesn't keep trying to register
+ //synchronizations)
+ callback = jdbcContext.registerCallbackIfNecessary();
+ }
+
+ begun = true;
+ commitSucceeded = false;
+
+ jdbcContext.afterTransactionBegin( this );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void commit() throws HibernateException {
+ if ( !begun ) {
+ throw new TransactionException( "Transaction not successfully started" );
+ }
+
+ log.debug( "commit" );
+
+ boolean flush = !transactionContext.isFlushModeNever()
+ && ( callback || !transactionContext.isFlushBeforeCompletionEnabled() );
+
+ if ( flush ) {
+ transactionContext.managedFlush(); //if an exception occurs during flush, user must call rollback()
+ }
+
+ if ( callback && newTransaction ) {
+ jdbcContext.beforeTransactionCompletion( this );
+ }
+
+ closeIfRequired();
+
+ if ( newTransaction ) {
+ try {
+ userTransaction.commit();
+ commitSucceeded = true;
+ log.debug( "Committed JTA UserTransaction" );
+ }
+ catch ( Exception e ) {
+ commitFailed = true; // so the transaction is already rolled back, by JTA spec
+ log.error( "JTA commit failed", e );
+ throw new TransactionException( "JTA commit failed: ", e );
+ }
+ finally {
+ afterCommitRollback();
+ }
+ }
+ else {
+ // this one only really needed for badly-behaved applications!
+ // (if the TransactionManager has a Sychronization registered,
+ // its a noop)
+ // (actually we do need it for downgrading locks)
+ afterCommitRollback();
+ }
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void rollback() throws HibernateException {
+ if ( !begun && !commitFailed ) {
+ throw new TransactionException( "Transaction not successfully started" );
+ }
+
+ log.debug( "rollback" );
+
+ try {
+ closeIfRequired();
+ }
+ catch ( Exception e ) {
+ // swallow it, and continue to roll back JTA transaction
+ log.error( "could not close session during rollback", e );
+ }
+
+ try {
+ if ( newTransaction ) {
+ if ( !commitFailed ) {
+ userTransaction.rollback();
+ log.debug( "Rolled back JTA UserTransaction" );
+ }
+ }
+ else {
+ userTransaction.setRollbackOnly();
+ log.debug( "set JTA UserTransaction to rollback only" );
+ }
+ }
+ catch ( Exception e ) {
+ log.error( "JTA rollback failed", e );
+ throw new TransactionException( "JTA rollback failed", e );
+ }
+ finally {
+ afterCommitRollback();
+ }
+ }
+
+ private static final int NULL = Integer.MIN_VALUE;
+
+ private void afterCommitRollback() throws TransactionException {
+
+ begun = false;
+ // this method is a noop if there is a Synchronization!
+ if ( callback ) {
+ if ( !newTransaction ) {
+ log.warn( "You should set hibernate.transaction.manager_lookup_class if cache is enabled" );
+ }
+ int status = NULL;
+ try {
+ status = userTransaction.getStatus();
+ }
+ catch ( Exception e ) {
+ log.error( "Could not determine transaction status after commit", e );
+ throw new TransactionException( "Could not determine transaction status after commit", e );
+ }
+ finally {
+ jdbcContext.afterTransactionCompletion( status == Status.STATUS_COMMITTED, this );
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean wasRolledBack() throws TransactionException {
+ final int status;
+ try {
+ status = userTransaction.getStatus();
+ }
+ catch ( SystemException se ) {
+ log.error( "Could not determine transaction status", se );
+ throw new TransactionException( "Could not determine transaction status", se );
+ }
+ if ( status == Status.STATUS_UNKNOWN ) {
+ throw new TransactionException( "Could not determine transaction status" );
+ }
+ else {
+ return JTAHelper.isRollback( status );
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean wasCommitted() throws TransactionException {
+ final int status;
+ try {
+ status = userTransaction.getStatus();
+ }
+ catch ( SystemException se ) {
+ log.error( "Could not determine transaction status", se );
+ throw new TransactionException( "Could not determine transaction status: ", se );
+ }
+ if ( status == Status.STATUS_UNKNOWN ) {
+ throw new TransactionException( "Could not determine transaction status" );
+ }
+ else {
+ return status == Status.STATUS_COMMITTED;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isActive() throws TransactionException {
+ if ( !begun || commitFailed || commitSucceeded ) {
+ return false;
+ }
+
+ final int status;
+ try {
+ status = userTransaction.getStatus();
+ }
+ catch ( SystemException se ) {
+ log.error( "Could not determine transaction status", se );
+ throw new TransactionException( "Could not determine transaction status: ", se );
+ }
+ if ( status == Status.STATUS_UNKNOWN ) {
+ throw new TransactionException( "Could not determine transaction status" );
+ }
+ else {
+ return status == Status.STATUS_ACTIVE;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void registerSynchronization(Synchronization sync) throws HibernateException {
+ if ( getTransactionManager() == null ) {
+ throw new IllegalStateException( "JTA TransactionManager not available" );
+ }
+ else {
+ try {
+ getTransactionManager().getTransaction().registerSynchronization( sync );
+ }
+ catch ( Exception e ) {
+ throw new TransactionException( "could not register synchronization", e );
+ }
+ }
+ }
+
+ /**
+ * Getter for property 'transactionManager'.
+ *
+ * @return Value for property 'transactionManager'.
+ */
+ private TransactionManager getTransactionManager() {
+ return transactionContext.getFactory().getTransactionManager();
+ }
+
+ private void closeIfRequired() throws HibernateException {
+ boolean close = callback &&
+ transactionContext.shouldAutoClose() &&
+ !transactionContext.isClosed();
+ if ( close ) {
+ transactionContext.managedClose();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setTimeout(int seconds) {
+ try {
+ userTransaction.setTransactionTimeout( seconds );
+ }
+ catch ( SystemException se ) {
+ throw new TransactionException( "could not set transaction timeout", se );
+ }
+ }
+
+ /**
+ * Getter for property 'userTransaction'.
+ *
+ * @return Value for property 'userTransaction'.
+ */
+ protected UserTransaction getUserTransaction() {
+ return userTransaction;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/JotmTransactionFactory.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/JotmTransactionFactory.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/JotmTransactionFactory.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,309 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.apache.ode.dao.hib;
+
+import java.util.Properties;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.ConnectionReleaseMode;
+import org.hibernate.HibernateException;
+import org.hibernate.Transaction;
+import org.hibernate.TransactionException;
+import org.hibernate.jdbc.JDBCContext;
+import org.hibernate.cfg.Environment;
+import org.hibernate.transaction.TransactionFactory;
+import org.hibernate.transaction.TransactionManagerLookup;
+import org.hibernate.transaction.TransactionManagerLookupFactory;
+import org.hibernate.util.NamingHelper;
+import org.hibernate.util.JTAHelper;
+
+/**
+ * Factory for {@link JotmTransaction} instances.
+ * <p/>
+ * To be completely accurate to the JTA spec, JTA implementations should
+ * publish their contextual {@link UserTransaction} reference into JNDI.
+ * However, in practice there are quite a few <tt>stand-alone</tt>
+ * implementations intended for use outside of J2EE/JEE containers and
+ * which therefore do not publish their {@link UserTransaction} references
+ * into JNDI but which otherwise follow the aspects of the JTA specification.
+ * This {@link TransactionFactory} implementation can support both models.
+ * <p/>
+ * For complete JTA implementations (including dependence on JNDI), the
+ * {@link UserTransaction} reference is obtained by a call to
+ * {@link #resolveInitialContext}. Hibernate will then attempt to locate the
+ * {@link UserTransaction} within this resolved
+ * {@link InitialContext} based on the namespace returned by
+ * {@link #resolveUserTransactionName}.
+ * <p/>
+ * For the so-called <tt>stand-alone</tt> implementations, we do not care at
+ * all about the JNDI aspects just described. Here, the implementation would
+ * have a specific manner to obtain a reference to its contextual
+ * {@link UserTransaction}; usually this would be a static code reference, but
+ * again it varies. Anyway, for each implementation the integration would need
+ * to override the {@link #getUserTransaction} method and return the appropriate
+ * thing.
+ *
+ * @author Gavin King
+ * @author Steve Ebersole
+ * @author Les Hazlewood
+ *
+ * Scraped from org.hibernate
+ */
+public class JotmTransactionFactory implements TransactionFactory {
+ public static final String DEFAULT_USER_TRANSACTION_NAME = "java:comp/UserTransaction";
+ private static final Log log = LogFactory.getLog( JotmTransactionFactory.class );
+
+ protected InitialContext initialContext;
+ protected String userTransactionName;
+
+ private TransactionManager txManager;
+
+ /**
+ * Configure this transaction factory. Specifically here we are attempting to
+ * resolve both an {@link #getInitialContext InitialContext} as well as the
+ * {@link #getUserTransactionName() JNDI namespace} for the {@link UserTransaction}.
+ *
+ * @param props The configuration properties
+ *
+ * @exception HibernateException
+ */
+ public void configure(Properties props) throws HibernateException {
+ this.initialContext = resolveInitialContext( props );
+ this.userTransactionName = resolveUserTransactionName( props );
+ log.debug( "Configured JTATransactionFactory to use [" + userTransactionName + "] for UserTransaction JDNI namespace" );
+ txManager = new HibernateTransactionManagerLookup().getTransactionManager(props);
+ }
+
+ /**
+ * Given the lot of Hibernate configuration properties, resolve appropriate
+ * reference to JNDI {@link InitialContext}.
+ * <p/>
+ * In general, the properties in which we are interested here all begin with
+ * <tt>hibernate.jndi</tt>. Especially important depending on your
+ * environment are {@link Environment#JNDI_URL hibernate.jndi.url} and
+ * {@link Environment#JNDI_CLASS hibernate.jndi.class}
+ *
+ * @param properties The Hibernate config properties.
+ * @return The resolved InitialContext.
+ */
+ protected final InitialContext resolveInitialContext(Properties properties) {
+ try {
+ return NamingHelper.getInitialContext( properties );
+ }
+ catch ( NamingException ne ) {
+ throw new HibernateException( "Could not obtain initial context", ne );
+ }
+ }
+
+ /**
+ * Given the lot of Hibernate configuration properties, resolve appropriate
+ * JNDI namespace to use for {@link UserTransaction} resolution.
+ * <p/>
+ * We determine the namespace to use by<ol>
+ * <li>Any specified {@link Environment#USER_TRANSACTION jta.UserTransaction} config property</li>
+ * <li>If a {@link TransactionManagerLookup} was indicated, use its
+ * {@link TransactionManagerLookup#getUserTransactionName}</li>
+ * <li>finally, as a last resort, we use {@link #DEFAULT_USER_TRANSACTION_NAME}</li>
+ * </ol>
+ *
+ * @param properties The Hibernate config properties.
+ * @return The resolved {@link UserTransaction} namespace
+ */
+ protected final String resolveUserTransactionName(Properties properties) {
+ String utName = properties.getProperty( Environment.USER_TRANSACTION );
+ if ( utName == null ) {
+ TransactionManagerLookup lookup = TransactionManagerLookupFactory.getTransactionManagerLookup( properties );
+ if ( lookup != null ) {
+ utName = lookup.getUserTransactionName();
+ }
+ }
+ return utName == null ? DEFAULT_USER_TRANSACTION_NAME : utName;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Transaction createTransaction(JDBCContext jdbcContext, Context transactionContext)
+ throws HibernateException {
+ /*
+ * JTA TransactionManager returns a JTA transaction. We need a user transaction to use
+ * hibernate's JTATransactionFactory.
+ */
+ // UserTransaction ut = getUserTransaction();
+ UserTransaction ut;
+ try {
+ ut = new UserTransaction() {
+ javax.transaction.Transaction transaction = txManager.getTransaction();
+ public void begin() throws NotSupportedException, SystemException {
+ // TODO Auto-generated method stub
+ }
+
+ public void commit() throws HeuristicMixedException,
+ HeuristicRollbackException, IllegalStateException,
+ RollbackException, SecurityException, SystemException {
+ transaction.commit();
+ }
+
+ public int getStatus() throws SystemException {
+ // TODO Auto-generated method stub
+ return transaction.getStatus();
+ }
+
+ public void rollback() throws IllegalStateException,
+ SecurityException, SystemException {
+ // TODO Auto-generated method stub
+ transaction.rollback();
+ }
+
+ public void setRollbackOnly() throws IllegalStateException,
+ SystemException {
+ // TODO Auto-generated method stub
+ transaction.setRollbackOnly();
+ }
+
+ public void setTransactionTimeout(int i) throws SystemException {
+ // TODO Auto-generated method stub
+ }
+ };
+ } catch (SystemException e) {
+ throw new HibernateException(e);
+ }
+
+ return new JotmTransaction( ut, jdbcContext, transactionContext );
+ }
+
+ /**
+ * Get the {@link UserTransaction} reference.
+ *
+ * @return The appropriate {@link UserTransaction} reference.
+ */
+ protected UserTransaction getUserTransaction() {
+ final String utName = getUserTransactionName();
+ log.debug( "Attempting to locate UserTransaction via JNDI [" + utName + "]");
+
+ try {
+ UserTransaction ut = ( UserTransaction ) getInitialContext().lookup( utName );
+ if ( ut == null ) {
+ throw new TransactionException( "Naming service lookup for UserTransaction returned null [" + utName +"]" );
+ }
+
+ log.trace( "Obtained UserTransaction" );
+
+ return ut;
+ }
+ catch ( NamingException ne ) {
+ throw new TransactionException( "Could not find UserTransaction in JNDI [" + utName + "]", ne );
+ }
+ }
+
+ /**
+ * Getter for property 'initialContext'.
+ *
+ * @return Value for property 'initialContext'.
+ */
+ protected InitialContext getInitialContext() {
+ return initialContext;
+ }
+
+ /**
+ * Getter for property 'userTransactionName'.
+ * The algorithm here is
+ *
+ * @return Value for property 'userTransactionName'.
+ */
+ protected String getUserTransactionName() {
+ return userTransactionName;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ConnectionReleaseMode getDefaultReleaseMode() {
+ return ConnectionReleaseMode.AFTER_STATEMENT;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isTransactionManagerRequired() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean areCallbacksLocalToHibernateTransactions() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isTransactionInProgress(
+ JDBCContext jdbcContext,
+ Context transactionContext,
+ Transaction transaction) {
+ try {
+ // Essentially:
+ // 1) If we have a local (Hibernate) transaction in progress
+ // and it already has the UserTransaction cached, use that
+ // UserTransaction to determine the status.
+ // 2) If a transaction manager has been located, use
+ // that transaction manager to determine the status.
+ // 3) Finally, as the last resort, try to lookup the
+ // UserTransaction via JNDI and use that to determine the
+ // status.
+ if ( transaction != null ) {
+ UserTransaction ut = ( ( JotmTransaction ) transaction ).getUserTransaction();
+ if ( ut != null ) {
+ return JTAHelper.isInProgress( ut.getStatus() );
+ }
+ }
+
+ if ( jdbcContext.getFactory().getTransactionManager() != null ) {
+ return JTAHelper.isInProgress( jdbcContext.getFactory().getTransactionManager().getStatus() );
+ }
+ else {
+ UserTransaction ut = getUserTransaction();
+ return ut != null && JTAHelper.isInProgress( ut.getStatus() );
+ }
+ }
+ catch ( SystemException se ) {
+ throw new TransactionException( "Unable to check transaction status", se );
+ }
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/NativeHiLoGenerator.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/NativeHiLoGenerator.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/NativeHiLoGenerator.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,94 @@
+/*
+ * 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.hib;
+
+import java.io.Serializable;
+import java.util.Properties;
+
+import org.hibernate.HibernateException;
+import org.hibernate.MappingException;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.id.Configurable;
+import org.hibernate.id.IdentifierGenerator;
+import org.hibernate.id.PersistentIdentifierGenerator;
+import org.hibernate.id.SequenceHiLoGenerator;
+import org.hibernate.id.TableHiLoGenerator;
+import org.hibernate.type.Type;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class NativeHiLoGenerator implements IdentifierGenerator, PersistentIdentifierGenerator, Configurable {
+ private static final Log __log = LogFactory.getLog(NativeHiLoGenerator.class);
+ private IdentifierGenerator _proxy;
+
+ public NativeHiLoGenerator() {
+ super();
+ }
+
+ public Serializable generate(SessionImplementor session, Object object) throws HibernateException {
+ return _proxy.generate(session, object);
+ }
+
+ public Object generatorKey() {
+ if (_proxy instanceof PersistentIdentifierGenerator)
+ return ((PersistentIdentifierGenerator) _proxy).generatorKey();
+ else
+ return this;
+ }
+
+ public String[] sqlCreateStrings(Dialect dialect) throws HibernateException {
+ if (_proxy instanceof PersistentIdentifierGenerator)
+ return ((PersistentIdentifierGenerator) _proxy).sqlCreateStrings(dialect);
+ else
+ return new String[] {};
+ }
+
+ public String[] sqlDropStrings(Dialect dialect) throws HibernateException {
+ if (_proxy instanceof PersistentIdentifierGenerator)
+ return ((PersistentIdentifierGenerator) _proxy).sqlDropStrings(dialect);
+ else
+ return null;
+ }
+
+ public void configure(Type type, Properties params, Dialect dialect) throws MappingException {
+ Class generatorClass = null;
+ if (dialect.supportsSequences()) {
+ __log.debug("Using SequenceHiLoGenerator");
+ generatorClass = SequenceHiLoGenerator.class;
+ } else {
+ generatorClass = TableHiLoGenerator.class;
+ __log.debug("Using native dialect generator " + generatorClass);
+ }
+
+ IdentifierGenerator g = null;
+ try {
+ g = (IdentifierGenerator) generatorClass.newInstance();
+ } catch (Exception e) {
+ throw new MappingException("", e);
+ }
+
+ if (g instanceof Configurable)
+ ((Configurable) g).configure(type, params, dialect);
+
+ this._proxy = g;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/SessionManager.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/SessionManager.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/SessionManager.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,224 @@
+/*
+ * 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.hib;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.dao.hib.bpel.hobj.*;
+import org.apache.ode.dao.hib.store.hobj.DeploymentUnitDaoImpl;
+import org.apache.ode.dao.hib.store.hobj.ProcessConfDaoImpl;
+import org.apache.ode.dao.hib.store.hobj.VersionTrackerDAOImpl;
+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 org.hibernate.cfg.Environment;
+
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Manages hibernate sessions, and their association with
+ * a transaction thread. Uses a ThreadLocal strategy for
+ * managing sessions.
+ */
+public class SessionManager {
+ private static final Log __log = LogFactory.getLog(SessionManager.class);
+
+ 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 String _uuid = new UUID().toString();
+ private final TransactionManager _txManager;
+ private final SessionFactory _sessionFactory;
+ private boolean _canJoinForUpdate = true;
+
+ private final TxContext _ctx;
+
+ public SessionManager(Properties env, DataSource ds, TransactionManager tx) throws HibernateException {
+ this(getDefaultConfiguration(), env, ds, tx);
+ }
+
+ /** Inaccessible constructor. */
+ public SessionManager(Configuration conf, Properties env, DataSource ds, TransactionManager tx) throws HibernateException {
+
+ if (tx!=null){
+ _ctx = new HibernateJtaTxContext();
+ }else{
+ _ctx = new HibernateNonTxContext();
+ }
+
+ _txManager = tx;
+ _txManagers.put(_uuid,tx);
+ _dataSources.put(_uuid,ds);
+
+ _sessionFactory = conf.setProperties(env).setProperty(PROP_GUID, _uuid).buildSessionFactory();
+
+ /*
+ Some Hibernate dialects (like IngresDialect) do not support update for join.
+ We need to distinguish them and explicitly define subqueries, otherwise Hibernate
+ implicitly generates joins which causes problems during update for such DBMS.
+ See org.apache.ode.daohib.bpel.CorrelatorDaoImpl for instance.
+ */
+ String currentHibDialect = env.getProperty(Environment.DIALECT);
+ for (String dialect : CANNOT_JOIN_FOR_UPDATE_DIALECTS) {
+ if (dialect.equals(currentHibDialect)) {
+ _canJoinForUpdate = false;
+ }
+ }
+ }
+
+ TransactionManager getTransactionManager() {
+ return _txManager;
+ }
+
+ public static void registerTransactionManager(String uuid, TransactionManager txm) {
+ _txManagers.put(uuid, txm);
+ }
+
+ /**
+ * Get the current Hibernate Session.
+ */
+ public Session getSession() {
+ return _sessionFactory.getCurrentSession();
+ }
+
+ /**
+ * Returns flag which shows whether " where .. join ... for update" kind of queries can be used (supported
+ * by currently effective {@link org.hibernate.dialect.Dialect}. If it's {@code false} than sub-query fallback
+ * should be invoked instead.
+ *
+ * @return currently returns false only for {@link org.hibernate.dialect.IngresDialect}
+ */
+ public boolean canJoinForUpdate() {
+ return _canJoinForUpdate;
+ }
+
+
+ /**
+ * Returns a hibernate configuration with hibernate DAO objects added as resources.
+ * @return
+ * @throws MappingException
+ */
+ public static Configuration getDefaultConfiguration() throws MappingException {
+ return new Configuration()
+ .addClass(HProcess.class)
+ .addClass(HProcessInstance.class)
+ .addClass(HCorrelator.class)
+ .addClass(HCorrelatorMessage.class)
+ .addClass(HCorrelationProperty.class)
+ .addClass(HCorrelatorSelector.class)
+ .addClass(HMessageExchange.class)
+ .addClass(HMessage.class)
+ .addClass(HPartnerLink.class)
+ .addClass(HScope.class)
+ .addClass(HCorrelationSet.class)
+ .addClass(HXmlData.class)
+ .addClass(HVariableProperty.class)
+ .addClass(HBpelEvent.class)
+ .addClass(HFaultData.class)
+ .addClass(HActivityRecovery.class)
+ .addClass(HMessageExchangeProperty.class)//store classes
+ .addClass(ProcessConfDaoImpl.class)
+ .addClass(DeploymentUnitDaoImpl.class)
+ .addClass(VersionTrackerDAOImpl.class);
+ }
+
+ 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();
+ }
+
+ public boolean isClosed() {
+ return _sessionFactory.isClosed();
+ }
+
+ public void shutdown() {
+ _sessionFactory.close();
+ }
+
+
+ public void begin(){
+ _ctx.begin();
+ }
+
+ public void commit(){
+ _ctx.commit();
+ }
+
+ public void rollback(){
+ _ctx.rollback();
+ }
+
+ public interface TxContext {
+
+ public void begin();
+
+ public void commit();
+
+ public void rollback();
+ }
+
+ public class HibernateNonTxContext implements TxContext {
+
+ public void begin() {
+ getSession().beginTransaction();
+ }
+
+ public void commit() {
+ getSession().getTransaction().commit();
+ }
+
+ public void rollback() {
+ getSession().getTransaction().rollback();
+ }
+ }
+
+ public class HibernateJtaTxContext implements TxContext {
+
+ public void begin() {
+ }
+
+ public void commit() {
+ }
+
+ public void rollback() {
+ }
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ActivityRecoveryDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ActivityRecoveryDaoImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ActivityRecoveryDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,85 @@
+/*
+ * 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.hib.bpel;
+
+import java.io.IOException;
+import java.util.Date;
+
+import org.apache.ode.dao.bpel.ActivityRecoveryDAO;
+import org.apache.ode.dao.hib.SessionManager;
+import org.apache.ode.dao.hib.bpel.hobj.HActivityRecovery;
+import org.apache.ode.utils.DOMUtils;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+/**
+ * Hibernate based {@link ActivityRecoveryDao} implementation
+ */
+public class ActivityRecoveryDaoImpl extends HibernateDao implements ActivityRecoveryDAO {
+ HActivityRecovery _self;
+
+ public ActivityRecoveryDaoImpl(SessionManager sm, HActivityRecovery recovery) {
+ super(sm, recovery);
+ entering("ActivityRecoveryDaoImpl.ActivityRecoveryDaoImpl");
+ _self = recovery;
+ }
+
+ public long getActivityId() {
+ return _self.getActivityId();
+ }
+
+ public String getChannel() {
+ return _self.getChannel();
+ }
+
+ public String getReason() {
+ return _self.getReason();
+ }
+
+ public Date getDateTime() {
+ return _self.getDateTime();
+ }
+
+ public Element getDetails() {
+ entering("ActivityRecoveryDaoImpl.getDetails");
+ if (_self.getDetails() == null) {
+ return null;
+ }
+ try {
+ return DOMUtils.stringToDOM(_self.getDetails());
+ } catch (SAXException e) {
+ throw new RuntimeException(e);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public String getActions() {
+ return _self.getActions();
+ }
+
+ public String[] getActionsList() {
+ return _self.getActions().split(" ");
+ }
+
+ public int getRetries() {
+ return _self.getRetries();
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/BpelDAOConnectionFactoryImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/BpelDAOConnectionFactoryImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/BpelDAOConnectionFactoryImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,208 @@
+/*
+ * 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.hib.bpel;
+
+import java.sql.Connection;
+import java.util.Enumeration;
+import java.util.Properties;
+
+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.hib.DataSourceConnectionProvider;
+import org.apache.ode.dao.hib.HibernateTransactionManagerLookup;
+import org.apache.ode.dao.hib.SessionManager;
+import org.apache.ode.il.config.OdeConfigProperties;
+import org.hibernate.HibernateException;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.resolver.DialectFactory;
+
+/**
+ * Hibernate-based {@link org.apache.ode.dao.bpel.BpelDAOConnectionFactory}
+ * implementation.
+ */
+public class BpelDAOConnectionFactoryImpl implements BpelDAOConnectionFactory {
+ private static final Log __log = LogFactory.getLog(BpelDAOConnectionFactoryImpl.class);
+
+ protected SessionManager _sessionManager;
+
+ private DataSource _ds;
+
+ private TransactionManager _tm;
+
+ /**
+ * Constructor.
+ */
+ public BpelDAOConnectionFactoryImpl() {
+ }
+
+ public BpelDAOConnection getConnection() {
+ try {
+ return new BpelDAOConnectionImpl(_sessionManager);
+ } catch (HibernateException e) {
+ __log.error("DbError", e);
+ throw e;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void init(Properties initialProps, TransactionManager mgr, Object env) {
+ _tm=mgr;
+ _ds=(DataSource)env;
+ if (_tm == null){
+ __log.error("Hibernate BpelDAOConnectionFactoryImpl requires a JTA Transaction Manager to be set.");
+ }
+ _sessionManager = setupSessionManager(initialProps, _tm, _ds);
+
+
+ }
+
+ public static SessionManager setupSessionManager(Properties initialProps, TransactionManager mgr, DataSource ds){
+ return setupSessionManager(SessionManager.getDefaultConfiguration(), initialProps, mgr, ds);
+ }
+
+ public static SessionManager setupSessionManager(Configuration conf, Properties initialConfig, TransactionManager mgr, DataSource ds){
+ // Don't want to pollute original properties
+ Properties properties = new Properties();
+ if (initialConfig != null) {
+ for (Object prop : initialConfig.keySet()) {
+ properties.put(prop, initialConfig.get(prop));
+ }
+ }
+
+ // Note that we don't allow the following properties to be overriden by
+ // the client.
+ /*
+ if (properties.containsKey(Environment.CONNECTION_PROVIDER))
+ __log.warn("Ignoring user-specified Hibernate property: " + Environment.CONNECTION_PROVIDER);
+ if (properties.containsKey(Environment.TRANSACTION_MANAGER_STRATEGY))
+ __log.warn("Ignoring user-specified Hibernate property: " + Environment.TRANSACTION_MANAGER_STRATEGY);
+ if (properties.containsKey(Environment.SESSION_FACTORY_NAME))
+ __log.warn("Ignoring user-specified Hibernate property: " + Environment.SESSION_FACTORY_NAME);
+ */
+ if (ds!=null){
+ properties.put(Environment.CONNECTION_PROVIDER, DataSourceConnectionProvider.class.getName());
+ // Guess Hibernate dialect if not specified in hibernate.properties
+ if (properties.get(Environment.DIALECT) == null) {
+ try {
+ properties.put(Environment.DIALECT, guessDialect(ds));
+ } catch (Exception ex) {
+ String errmsg = "Unable to detect Hibernate dialect!";
+
+ if (__log.isDebugEnabled())
+ __log.debug(errmsg, ex);
+
+ __log.error(errmsg);
+ }
+ }
+ }
+
+ if (mgr!=null){
+ properties.put(Environment.TRANSACTION_MANAGER_STRATEGY, HibernateTransactionManagerLookup.class.getName());
+ /*
+ * Since Hibernate 3.2.6, Hibernate JTATransaction requires User Transaction bound on JNDI. Let's work around
+ * by implementing Hibernate JTATransactionFactory that hooks up to the JTATransactionManager(ODE uses geronimo
+ * by default).
+ */
+ //properties.put(Environment.TRANSACTION_STRATEGY, "org.hibernate.transaction.JTATransactionFactory");
+ properties.put(Environment.TRANSACTION_STRATEGY, "org.apache.ode.dao.hib.JotmTransactionFactory");
+ properties.put(Environment.CURRENT_SESSION_CONTEXT_CLASS, "jta");
+ }else{
+ properties.put(Environment.TRANSACTION_STRATEGY,"org.hibernate.transaction.JDBCTransactionFactory");
+ properties.put(Environment.CURRENT_SESSION_CONTEXT_CLASS,"thread");
+ }
+
+ // Isolation levels override
+ if (System.getProperty("ode.connection.isolation") != null) {
+ String level = System.getProperty("ode.connection.isolation", "2");
+ properties.put(Environment.ISOLATION, level);
+ }
+
+ if (Boolean.valueOf(initialConfig.getProperty(OdeConfigProperties.PROP_DB_EMBEDDED_CREATE, "true"))) {
+ properties.put(Environment.HBM2DDL_AUTO, "create-drop");
+ }
+
+ if (__log.isDebugEnabled()) {
+ Enumeration names = properties.propertyNames();
+ __log.debug("Properties passed to Hibernate:");
+ while (names.hasMoreElements()) {
+ String name = (String) names.nextElement();
+ __log.debug(name + "=" + properties.getProperty(name));
+ }
+ }
+
+ return new SessionManager(conf, properties, ds,mgr);
+
+ }
+
+ protected SessionManager createSessionManager(Properties properties, DataSource ds, TransactionManager tm) {
+ return new SessionManager(properties, ds, tm);
+ }
+
+ private static final String DEFAULT_HIBERNATE_DIALECT = "org.hibernate.dialect.DerbyDialect";
+
+ public void shutdown() {
+ // Not too much to do for hibernate.
+ }
+
+ public static 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 {
+ Dialect d = DialectFactory.buildDialect(new Properties(), conn);
+ dialect=d.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 void setDataSource(DataSource ds) {
+ _ds = ds;
+ }
+
+ public DataSource getDataSource() {
+ return _ds;
+ }
+
+ public void setTransactionManager(Object tm) {
+ _tm = (TransactionManager) tm;
+ }
+
+ public void setUnmanagedDataSource(DataSource ds) {
+ // Hibernate doesn't use this.
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/BpelDAOConnectionImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/BpelDAOConnectionImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/BpelDAOConnectionImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,357 @@
+/*
+ * 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.hib.bpel;
+
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.common.BpelEventFilter;
+import org.apache.ode.bpel.common.InstanceFilter;
+import org.apache.ode.bpel.common.ProcessState;
+import org.apache.ode.bpel.evt.BpelEvent;
+import org.apache.ode.bpel.evt.ScopeEvent;
+import org.apache.ode.bpel.iapi.ProcessConf.CLEANUP_CATEGORY;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.CorrelationSetDAO;
+import org.apache.ode.dao.bpel.FilteredInstanceDeletable;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.ProcessManagementDAO;
+import org.apache.ode.dao.bpel.ScopeDAO;
+import org.apache.ode.dao.hib.SessionManager;
+import org.apache.ode.dao.hib.bpel.hobj.HBpelEvent;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelationSet;
+import org.apache.ode.dao.hib.bpel.hobj.HMessageExchange;
+import org.apache.ode.dao.hib.bpel.hobj.HProcess;
+import org.apache.ode.dao.hib.bpel.hobj.HProcessInstance;
+import org.apache.ode.dao.hib.bpel.hobj.HScope;
+import org.apache.ode.dao.hib.bpel.ql.HibernateInstancesQueryCompiler;
+import org.apache.ode.ql.eval.skel.CommandEvaluator;
+import org.apache.ode.ql.tree.Builder;
+import org.apache.ode.ql.tree.BuilderFactory;
+import org.apache.ode.ql.tree.nodes.Query;
+import org.apache.ode.utils.SerializableUtils;
+import org.apache.ode.utils.stl.CollectionsX;
+import org.apache.ode.utils.stl.UnaryFunctionEx;
+import org.hibernate.Criteria;
+import org.hibernate.FetchMode;
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.criterion.DetachedCriteria;
+import org.hibernate.criterion.Expression;
+import org.hibernate.criterion.Projections;
+
+/**
+ * Hibernate-based {@link BpelDAOConnection} implementation.
+ */
+public class BpelDAOConnectionImpl implements BpelDAOConnection, FilteredInstanceDeletable {
+
+ private static final Log __log = LogFactory.getLog(BpelDAOConnectionImpl.class);
+
+ protected SessionManager _sm;
+
+ public BpelDAOConnectionImpl(SessionManager sm) {
+ _sm = sm;
+ }
+
+ protected Session getSession(){
+ return _sm.getSession();
+ }
+
+ public MessageExchangeDAO createMessageExchange(char dir) {
+ HMessageExchange mex = new HMessageExchange();
+ mex.setDirection(dir);
+ mex.setInsertTime(new Date(System.currentTimeMillis()));
+ getSession().save(mex);
+ return new MessageExchangeDaoImpl(_sm, mex);
+ }
+
+ public MessageExchangeDAO getMessageExchange(String mexid) {
+ HMessageExchange mex = (HMessageExchange) getSession().get(HMessageExchange.class, new Long(mexid));
+ return mex == null ? null : new MessageExchangeDaoImpl(_sm, mex);
+ }
+
+ public ProcessDAO createProcess(QName pid, QName type, String guid, long version) {
+ HProcess process = new HProcess();
+ process.setProcessId(pid.toString());
+ process.setTypeName(type.getLocalPart());
+ process.setTypeNamespace(type.getNamespaceURI());
+ process.setDeployDate(new Date());
+ process.setGuid(guid);
+ process.setVersion(version);
+ getSession().save(process);
+ return new ProcessDaoImpl(_sm, process);
+ }
+
+ public ProcessDAO createTransientProcess(Serializable id) {
+ HProcess process = new HProcess();
+ process.setId((Long)id);
+
+ return new ProcessDaoImpl(_sm, process);
+ }
+
+ public ProcessDAO getProcess(QName processId) {
+ try {
+ Criteria criteria = getSession().createCriteria(HProcess.class);
+ criteria.add(Expression.eq("processId", processId.toString()));
+ // For the moment we are expecting only one result.
+ HProcess hprocess = (HProcess) criteria.uniqueResult();
+ return hprocess == null ? null : new ProcessDaoImpl(_sm, hprocess);
+ } catch (HibernateException e) {
+ __log.error("DbError", e);
+ throw e;
+ }
+
+ }
+
+ public void close() {
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessDAO#getInstance(java.lang.Long)
+ */
+ public ProcessInstanceDAO getInstance(Long instanceId) {
+ return _getInstance(_sm, getSession(), instanceId);
+ }
+
+ public int getNumInstances(QName processId) {
+ ProcessDAO process = getProcess(processId);
+ if (process != null)
+ return process.getNumInstances();
+ else return -1;
+ }
+
+ public ScopeDAO getScope(Long siidl) {
+ return _getScope(_sm, getSession(), siidl);
+ }
+
+ public Collection<ProcessInstanceDAO> instanceQuery(InstanceFilter criteria) {
+ if (criteria.getLimit() == 0) {
+ return Collections.emptyList();
+ }
+ List<ProcessInstanceDAO> daos = new ArrayList<ProcessInstanceDAO>();
+
+ Iterator<HProcessInstance> iter = _instanceQuery(getSession(), false, criteria);
+ while (iter.hasNext()) {
+ daos.add(new ProcessInstanceDaoImpl(_sm, iter.next()));
+ }
+
+ return daos;
+ }
+
+ public int deleteInstances(InstanceFilter criteria, Set<CLEANUP_CATEGORY> categories) {
+ if (criteria.getLimit() == 0) {
+ return 0;
+ }
+
+ List<HProcessInstance> instances = _instanceQueryForList(getSession(), false, criteria);
+ if( __log.isDebugEnabled() ) __log.debug("Collected " + instances.size() + " instances to delete.");
+
+ if( !instances.isEmpty() ) {
+ ProcessDaoImpl process = (ProcessDaoImpl)createTransientProcess(instances.get(0).getProcessId());
+ return process.deleteInstances(instances, categories);
+ }
+
+ return 0;
+ }
+
+ static Iterator<HProcessInstance> _instanceQuery(Session session, boolean countOnly, InstanceFilter filter) {
+ return _instanceQueryForList(session, countOnly, filter).iterator();
+ }
+
+ @SuppressWarnings("unchecked")
+ private static List<HProcessInstance> _instanceQueryForList(Session session, boolean countOnly, InstanceFilter filter) {
+ CriteriaBuilder cb = new CriteriaBuilder();
+
+ return cb.buildHQLQuery(session, filter).list();
+ }
+
+ static ProcessInstanceDAO _getInstance(SessionManager sm, Session session, Long iid) {
+ HProcessInstance instance = (HProcessInstance) session.get(HProcessInstance.class, iid);
+ return instance != null ? new ProcessInstanceDaoImpl(sm, instance) : null;
+ }
+
+ static ScopeDAO _getScope(SessionManager sm, Session session, Long siid) {
+ HScope scope = (HScope) session.get(HScope.class, siid);
+ return scope != null ? new ScopeDaoImpl(sm, scope) : null;
+ }
+
+ public void insertBpelEvent(BpelEvent event, ProcessDAO process, ProcessInstanceDAO instance) {
+ _insertBpelEvent(_sm.getSession(), event, process, instance);
+ }
+
+ /**
+ * Helper method for inserting bpel events into the database.
+ *
+ * @param sess
+ * @param event
+ * @param process
+ * @param instance
+ */
+ static void _insertBpelEvent(Session sess, BpelEvent event, ProcessDAO process, ProcessInstanceDAO instance) {
+ HBpelEvent hevent = new HBpelEvent();
+ hevent.setTstamp(new Timestamp(System.currentTimeMillis()));
+ hevent.setType(BpelEvent.eventName(event));
+ hevent.setDetail(event.toString());
+ if (process != null)
+ hevent.setProcess((HProcess) ((ProcessDaoImpl) process).getHibernateObj());
+ if (instance != null)
+ hevent.setInstance((HProcessInstance) ((ProcessInstanceDaoImpl) instance).getHibernateObj());
+ if (event instanceof ScopeEvent)
+ hevent.setScopeId(((ScopeEvent) event).getScopeId());
+ try {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(bos);
+ oos.writeObject(event);
+ oos.flush();
+ hevent.setData(bos.toByteArray());
+ } catch (Throwable ex) {
+ // this is really unexpected.
+ __log.fatal("InternalError: BpelEvent serialization failed.", ex);
+ }
+ sess.save(hevent);
+ }
+
+ @SuppressWarnings( { "unchecked", "deprecation" })
+ public List<Date> bpelEventTimelineQuery(InstanceFilter ifilter, BpelEventFilter efilter) {
+ CriteriaBuilder cb = new CriteriaBuilder();
+ Criteria crit = getSession().createCriteria(HBpelEvent.class);
+ if (ifilter != null)
+ cb.buildCriteria(crit, efilter);
+ if (ifilter != null)
+ cb.buildCriteria(crit.createCriteria("instance"), ifilter);
+ crit.setFetchMode("tstamp", FetchMode.EAGER);
+ crit.setProjection(Projections.property("tstamp"));
+ return crit.list();
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<BpelEvent> bpelEventQuery(InstanceFilter ifilter, BpelEventFilter efilter) {
+ CriteriaBuilder cb = new CriteriaBuilder();
+ Criteria crit = getSession().createCriteria(HBpelEvent.class);
+ if (efilter != null)
+ cb.buildCriteria(crit, efilter);
+ if (ifilter != null)
+ cb.buildCriteria(crit.createCriteria("instance"), ifilter);
+ List<HBpelEvent> hevents = crit.list();
+ List<BpelEvent> ret = new ArrayList<BpelEvent>(hevents.size());
+ try {
+ CollectionsX.transformEx(ret, hevents, new UnaryFunctionEx<HBpelEvent, BpelEvent>() {
+ public BpelEvent apply(HBpelEvent x) throws Exception {
+ return (BpelEvent) SerializableUtils.toObject(x.getData(), BpelEvent.class
+ .getClassLoader());
+ }
+
+ });
+ } catch (Exception ex) {
+ __log.fatal("Internal error: unable to transform HBpelEvent", ex);
+ throw new RuntimeException(ex);
+ }
+ return ret;
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.BpelDAOConnection#instanceQuery(String)
+ */
+ @SuppressWarnings("unchecked")
+ public Collection<ProcessInstanceDAO> instanceQuery(String expression) {
+ Builder<String> builder = BuilderFactory.getInstance().createBuilder();
+ final org.apache.ode.ql.tree.nodes.Node rootNode = builder.build(expression);
+
+ HibernateInstancesQueryCompiler compiler = new HibernateInstancesQueryCompiler();
+
+ CommandEvaluator<List, Session> eval = compiler.compile((Query) rootNode);
+ List<HProcessInstance> instancesList = (List<HProcessInstance>) eval.evaluate(getSession());
+
+ Collection<ProcessInstanceDAO> result = new ArrayList<ProcessInstanceDAO>(instancesList.size());
+ for (HProcessInstance instance : instancesList) {
+ result.add(getInstance(instance.getId()));
+ }
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Map<Long, Collection<CorrelationSetDAO>> getCorrelationSets(Collection<ProcessInstanceDAO> instances) {
+ if (instances.size() == 0) {
+ return new HashMap<Long, Collection<CorrelationSetDAO>>();
+ }
+ ArrayList<Long> iids = new ArrayList<Long>(instances.size());
+ int i=0;
+ for (ProcessInstanceDAO dao: instances) {
+ iids.add(dao.getInstanceId());
+ i++;
+ }
+ Collection<HCorrelationSet> csets = new ArrayList<HCorrelationSet>();
+ // some databases don't like long lists of values with IN operator
+ // so we select in batches. Oracle 9i, for instance, doesn't support
+ // more than 1000 -- we opt to be conservative.
+ final int batchSize = 100;
+ int index = 0;
+ while (index < iids.size()) {
+ List<Long> subList = iids.subList(index, Math.min(index+batchSize, iids.size()));
+ csets.addAll(getSession().getNamedQuery(HCorrelationSet.SELECT_CORSETS_BY_INSTANCES).setParameterList("instances", subList).list());
+ index += batchSize;
+ }
+ Map<Long, Collection<CorrelationSetDAO>> map = new HashMap<Long, Collection<CorrelationSetDAO>>();
+ for (HCorrelationSet cset: csets) {
+ Long id = cset.getInstance().getId();
+ Collection<CorrelationSetDAO> existing = map.get(id);
+ if (existing == null) {
+ existing = new ArrayList<CorrelationSetDAO>();
+ map.put(id, existing);
+ }
+ existing.add(new CorrelationSetDaoImpl(_sm, cset));
+ }
+ return map;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Collection<CorrelationSetDAO> getActiveCorrelationSets() {
+ ArrayList<CorrelationSetDAO> csetDaos = new ArrayList<CorrelationSetDAO>();
+ Collection<HCorrelationSet> csets = getSession().getNamedQuery(HCorrelationSet.SELECT_CORSETS_BY_PROCESS_STATES).setParameter("states", ProcessState.STATE_ACTIVE).list();
+ for (HCorrelationSet cset : csets)
+ csetDaos.add(new CorrelationSetDaoImpl(_sm, cset));
+ return csetDaos;
+ }
+
+
+ public ProcessManagementDAO getProcessManagement() {
+ return new ProcessManagementDaoImpl(_sm);
+ }
+
+ public boolean isClosed() {
+ return _sm.isClosed();
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/CorrelationSetDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/CorrelationSetDaoImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/CorrelationSetDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,116 @@
+/*
+ * 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.hib.bpel;
+
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.dao.bpel.CorrelationSetDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.ScopeDAO;
+import org.apache.ode.dao.hib.SessionManager;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelationProperty;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelationSet;
+
+import javax.xml.namespace.QName;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * Hibernate-based {@link CorrelationSetDAO} implementation.
+ */
+class CorrelationSetDaoImpl extends HibernateDao
+ implements CorrelationSetDAO {
+
+ private HCorrelationSet _correlationSet;
+
+ public CorrelationSetDaoImpl(SessionManager sessionManager, HCorrelationSet correlationSet) {
+ super(sessionManager, correlationSet);
+ entering("CorrelationSetDaoImpl.CorrelationSetDaoImpl");
+ _correlationSet = correlationSet;
+ }
+
+ public Long getCorrelationSetId() {
+ return _correlationSet.getId();
+ }
+
+ public String getName() {
+ return _correlationSet.getName();
+ }
+
+ public ScopeDAO getScope() {
+ entering("CorrelationSetDaoImpl.getScope");
+ return new ScopeDaoImpl(_sm, _correlationSet.getScope());
+ }
+
+ public void setValue(QName[] names, CorrelationKey values) {
+ entering("CorrelationSetDaoImpl.setValue");
+ _correlationSet.setValue(values.toCanonicalString());
+ if (names != null) {
+ if (_correlationSet.getProperties() == null || _correlationSet.getProperties().size() == 0) {
+ for (int m = 0; m < names.length; m++) {
+ HCorrelationProperty prop =
+ new HCorrelationProperty(names[m], values.getValues()[m], _correlationSet);
+ getSession().save(prop);
+ }
+ } else {
+ for (int m = 0; m < names.length; m++) {
+ HCorrelationProperty prop = getProperty(names[m]);
+ if (prop == null) prop = new HCorrelationProperty(names[m], values.getValues()[m], _correlationSet);
+ else prop.setValue(values.getValues()[m]);
+ getSession().save(prop);
+ }
+ }
+ }
+ getSession().update(_correlationSet);
+ }
+
+ public CorrelationKey getValue() {
+ entering("CorrelationSetDaoImpl.getValue");
+ if (_correlationSet.getValue() != null) return new CorrelationKey(_correlationSet.getValue());
+ else return null;
+ }
+
+ public Map<QName, String> getProperties() {
+ entering("CorrelationSetDaoImpl.getProperties");
+ HashMap<QName, String> result = new HashMap<QName, String>();
+ for (HCorrelationProperty property : _correlationSet.getProperties()) {
+ result.put(property.getQName(), property.getValue());
+ }
+ return result;
+ }
+
+ public ProcessDAO getProcess() {
+ return new ProcessDaoImpl(_sm, _correlationSet.getProcess());
+ }
+
+ public ProcessInstanceDAO getInstance() {
+ return new ProcessInstanceDaoImpl(_sm, _correlationSet.getInstance());
+ }
+
+ private HCorrelationProperty getProperty(QName qName) {
+ entering("CorrelationSetDaoImpl.getProperty");
+ for (HCorrelationProperty property : _correlationSet.getProperties()) {
+ if (qName.getLocalPart().equals(property.getName())
+ && qName.getNamespaceURI().equals(property.getNamespace()))
+ return property;
+ }
+ return null;
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/CorrelatorDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/CorrelatorDaoImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/CorrelatorDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,275 @@
+/*
+ * 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.hib.bpel;
+
+import java.util.*;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.bpel.common.CorrelationKeySet;
+import org.apache.ode.dao.bpel.*;
+import org.apache.ode.dao.hib.SessionManager;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelator;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelatorMessage;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelatorSelector;
+import org.apache.ode.dao.hib.bpel.hobj.HMessageExchange;
+import org.apache.ode.dao.hib.bpel.hobj.HProcess;
+import org.apache.ode.dao.hib.bpel.hobj.HProcessInstance;
+import org.hibernate.Hibernate;
+import org.hibernate.LockMode;
+import org.hibernate.Query;
+import org.hibernate.Session;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Hibernate-based {@link CorrelatorDAO} implementation.
+ */
+class CorrelatorDaoImpl extends HibernateDao implements CorrelatorDAO {
+ static Log __log = LogFactory.getLog(CorrelatorDaoImpl.class);
+
+ /** filter for finding a matching selector. */
+ private static final String LOCK_SELECTORS = "update from HCorrelatorSelector as hs set hs.lock = hs.lock+1 where hs.processType = :processType";
+ private static final String CHECK_SELECTORS = "from HCorrelatorSelector as hs where hs.processType = :processType and hs.correlator.correlatorId = :correlatorId";
+ private static final String FLTR_SELECTORS = "from HCorrelatorSelector as hs where hs.processType = :processType and hs.correlator.correlatorId = :correlatorId";
+ private static final String FLTR_SELECTORS_SUBQUERY = ("from HCorrelatorSelector as hs where hs.processType = :processType and hs.correlatorId = " +
+ "(select hc.id from HCorrelator as hc where hc.correlatorId = :correlatorId )").intern();
+
+ /** Query for removing routes. */
+ private static final String QRY_DELSELECTORS = "delete from HCorrelatorSelector where groupId = ? and instance = ?";
+
+ private HCorrelator _hobj;
+
+ public CorrelatorDaoImpl(SessionManager sm, HCorrelator hobj) {
+ super(sm, hobj);
+ entering("CorrelatorDaoImpl.CorrelatorDaoImpl");
+ _hobj = hobj;
+ }
+
+ @SuppressWarnings("unchecked")
+ public MessageExchangeDAO dequeueMessage(CorrelationKeySet keySet) {
+ entering("CorrelatorDaoImpl.dequeueMessage");
+
+ MessageExchangeDAO mex = null;
+
+ String hdr = "dequeueMessage(" + keySet + "): ";
+ __log.debug(hdr);
+
+ List<CorrelationKeySet> subSets = keySet.findSubSets();
+ Query qry = getSession().createFilter(_hobj.getMessageCorrelations(),
+ generateUnmatchedQuery(subSets));
+ for( int i = 0; i < subSets.size(); i++ ) {
+ qry.setString("s" + i, subSets.get(i).toCanonicalString());
+ }
+
+ // We really should consider the possibility of multiple messages matching a criteria.
+ // When the message is handled, its not too convenient to attempt to determine if the
+ // received message conflicts with one already received.
+ Iterator mcors = qry.iterate();
+ try {
+ if (!mcors.hasNext()) {
+ if (__log.isDebugEnabled())
+ __log.debug(hdr + "did not find a MESSAGE entry.");
+ } else {
+ HCorrelatorMessage mcor = (HCorrelatorMessage) mcors.next();
+ if (__log.isDebugEnabled())
+ __log.debug(hdr + "found MESSAGE entry " + mcor.getMessageExchange());
+ mex = new MessageExchangeDaoImpl(_sm, mcor.getMessageExchange());
+ }
+ } finally {
+ Hibernate.close(mcors);
+ }
+
+ return mex;
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<MessageRouteDAO> findRoute(CorrelationKeySet keySet) {
+ List<MessageRouteDAO> routes = new ArrayList<MessageRouteDAO>();
+
+ entering("CorrelatorDaoImpl.findRoute");
+ String hdr = "findRoute(keySet=" + keySet + "): ";
+ if (__log.isDebugEnabled()) __log.debug(hdr);
+
+ String processType = new QName(_hobj.getProcess().getTypeNamespace(), _hobj.getProcess().getTypeName()).toString();
+ List<CorrelationKeySet> subSets = keySet.findSubSets();
+
+ Query q = getSession().createQuery(generateSelectorQuery(_sm.canJoinForUpdate() ? FLTR_SELECTORS : FLTR_SELECTORS_SUBQUERY, subSets));
+ q.setString("processType", processType);
+ q.setString("correlatorId", _hobj.getCorrelatorId());
+
+ for( int i = 0; i < subSets.size(); i++ ) {
+ q.setString("s" + i, subSets.get(i).toCanonicalString());
+ }
+ // Make sure we obtain a lock for the selector we want to find.
+ q.setLockMode("hs", LockMode.UPGRADE);
+
+ List<HProcessInstance> targets = new ArrayList<HProcessInstance>();
+ for (HCorrelatorSelector selector : (List<HCorrelatorSelector>)q.list()) {
+ if (selector != null) {
+ boolean isRoutePolicyOne = selector.getRoute() == null || "one".equals(selector.getRoute());
+ if ("all".equals(selector.getRoute()) ||
+ (isRoutePolicyOne && !targets.contains(selector.getInstance()))) {
+ routes.add(new MessageRouteDaoImpl(_sm, selector));
+ targets.add(selector.getInstance());
+ }
+ }
+ }
+
+ if(__log.isDebugEnabled()) __log.debug(hdr + "found " + routes);
+
+ // obtain a lock on the correlator to eliminate potential race condition.
+ if(__log.isDebugEnabled()) __log.debug("Obtain record lock on " + _hobj);
+ Query correlatorLockQuery = getSession().createQuery("from HCorrelator as hc where id = :id");
+ correlatorLockQuery.setLong("id", _hobj.getId());
+ correlatorLockQuery.setLockMode("hc", LockMode.UPGRADE);
+ correlatorLockQuery.list();
+
+ return routes;
+ }
+
+ private String generateUnmatchedQuery(List<CorrelationKeySet> subSets) {
+ StringBuffer filterQuery = new StringBuffer();
+
+ if( subSets.size() == 1 ) {
+ filterQuery.append(" where this.correlationKey = :s0");
+ } else if( subSets.size() > 1 ) {
+ filterQuery.append(" where this.correlationKey in(");
+ for( int i = 0; i < subSets.size(); i++ ) {
+ if( i > 0 ) {
+ filterQuery.append(", ");
+ }
+ filterQuery.append(":s").append(i);
+ }
+ filterQuery.append(")");
+ }
+
+ return filterQuery.toString();
+ }
+
+ private String generateSelectorQuery(String header, List<CorrelationKeySet> subSets) {
+ StringBuffer filterQuery = new StringBuffer(header);
+
+ if( subSets.size() == 1 ) {
+ filterQuery.append(" and hs.correlationKey = :s0");
+ } else if( subSets.size() > 1 ) {
+ filterQuery.append(" and hs.correlationKey in(");
+ for( int i = 0; i < subSets.size(); i++ ) {
+ if( i > 0 ) {
+ filterQuery.append(", ");
+ }
+ filterQuery.append(":s").append(i);
+ }
+ filterQuery.append(")");
+ }
+
+ return filterQuery.toString();
+ }
+
+ public void enqueueMessage(MessageExchangeDAO mex, CorrelationKeySet correlationKeySet) {
+ entering("CorrelatorDaoImpl.enqueueMessage");
+ String hdr = "enqueueMessage(mex=" + ((MessageExchangeDaoImpl) mex)._hobj.getId() + " keySet="
+ + correlationKeySet.toCanonicalString() + "): ";
+
+ if (__log.isDebugEnabled())
+ __log.debug(hdr);
+
+ for( CorrelationKeySet aSubSet : correlationKeySet.findSubSets() ) {
+ HCorrelatorMessage mcor = new HCorrelatorMessage();
+ mcor.setCorrelator(_hobj);
+ mcor.setCreated(new Date());
+ mcor.setMessageExchange((HMessageExchange) ((MessageExchangeDaoImpl) mex)._hobj);
+ mcor.setCorrelationKey(aSubSet.toCanonicalString());
+ getSession().save(mcor);
+
+ if (__log.isDebugEnabled())
+ __log.debug(hdr + "saved " + mcor);
+ }
+ }
+
+ public void addRoute(String routeGroupId, ProcessInstanceDAO target, int idx, CorrelationKeySet correlationKeySet, String routePolicy) {
+ entering("CorrelatorDaoImpl.addRoute");
+ String hdr = "addRoute(" + routeGroupId + ", iid=" + target.getInstanceId() + ", idx=" + idx + ", ckeySet="
+ + correlationKeySet + "): ";
+
+ if (__log.isDebugEnabled())
+ __log.debug(hdr);
+ HCorrelatorSelector hsel = new HCorrelatorSelector();
+ hsel.setGroupId(routeGroupId);
+ hsel.setIndex(idx);
+ hsel.setLock(0);
+ hsel.setCorrelationKey(correlationKeySet.toCanonicalString());
+ hsel.setInstance((HProcessInstance) ((ProcessInstanceDaoImpl) target).getHibernateObj());
+ hsel.setProcessType(target.getProcess().getType().toString());
+ hsel.setCorrelator(_hobj);
+ hsel.setCreated(new Date());
+ hsel.setRoute(routePolicy);
+ getSession().save(hsel);
+
+ if (__log.isDebugEnabled())
+ __log.debug(hdr + "saved " + hsel);
+ }
+
+ public boolean checkRoute(CorrelationKeySet correlationKeySet) {
+ entering("CorrelatorDaoImpl.checkRoute");
+ Query q = getSession().getNamedQuery(HCorrelatorSelector.SELECT_MESSAGE_ROUTE);
+ q.setEntity("corr",_hobj);
+ q.setString("ckey", correlationKeySet.toCanonicalString());
+ q.setReadOnly(true);
+ return q.list().isEmpty();
+ }
+
+ public String getCorrelatorId() {
+ return _hobj.getCorrelatorId();
+ }
+
+ public void setCorrelatorId(String newId) {
+ _hobj.setCorrelatorId(newId);
+ }
+
+ public void removeRoutes(String routeGroupId, ProcessInstanceDAO target) {
+ entering("CorrelatorDaoImpl.removeRoutes");
+ String hdr = "removeRoutes(" + routeGroupId + ", iid=" + target.getInstanceId() + "): ";
+ __log.debug(hdr);
+ Session session = getSession();
+ Query q = session.createQuery(QRY_DELSELECTORS);
+ q.setString(0, routeGroupId); // groupId
+ q.setEntity(1, ((ProcessInstanceDaoImpl) target).getHibernateObj()); // instance
+ int updates = q.executeUpdate();
+ session.flush(); // explicit flush to ensure route removed
+ if (__log.isDebugEnabled())
+ __log.debug(hdr + "deleted " + updates + " rows");
+ }
+
+ public Collection<CorrelatorMessageDAO> getAllMessages() {
+ Collection<CorrelatorMessageDAO> msgs = new ArrayList<CorrelatorMessageDAO>();
+ for (HCorrelatorMessage correlatorMessage : _hobj.getMessageCorrelations())
+ msgs.add(new CorrelatorMessageDaoImpl(_sm, correlatorMessage));
+ return msgs;
+ }
+
+ public Collection<MessageRouteDAO> getAllRoutes() {
+ Collection<MessageRouteDAO> routes = new ArrayList<MessageRouteDAO>();
+ for (HCorrelatorSelector selector : _hobj.getSelectors())
+ routes.add(new MessageRouteDaoImpl(_sm, selector));
+ return routes;
+ }
+
+}
\ No newline at end of file
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/CorrelatorMessageDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/CorrelatorMessageDaoImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/CorrelatorMessageDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,44 @@
+/*
+ * 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.hib.bpel;
+
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.dao.bpel.CorrelatorMessageDAO;
+import org.apache.ode.dao.hib.SessionManager;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelatorMessage;
+
+public class CorrelatorMessageDaoImpl extends HibernateDao implements CorrelatorMessageDAO {
+
+ private HCorrelatorMessage _hobj;
+
+ public CorrelatorMessageDaoImpl(SessionManager sm, HCorrelatorMessage hobj) {
+ super(sm, hobj);
+ entering("CorrelatorDaoImpl.CorrelatorDaoImpl");
+ _hobj = hobj;
+ }
+
+ public CorrelationKey getCorrelationKey() {
+ return new CorrelationKey(_hobj.getCorrelationKey());
+ }
+
+ public void setCorrelationKey(CorrelationKey ckey) {
+ _hobj.setCorrelationKey(ckey.toCanonicalString());
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/CriteriaBuilder.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/CriteriaBuilder.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/CriteriaBuilder.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,428 @@
+/*
+ * 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.hib.bpel;
+
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.common.BpelEventFilter;
+import org.apache.ode.bpel.common.Filter;
+import org.apache.ode.bpel.common.InstanceFilter;
+import org.apache.ode.utils.ISO8601DateParser;
+import org.apache.ode.utils.RelativeDateParser;
+import org.hibernate.Criteria;
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.criterion.Disjunction;
+import org.hibernate.criterion.Property;
+import org.hibernate.criterion.Restrictions;
+
+/**
+ * Class used for converting "filter" objects into Hibernate
+ * {@link org.hibernate.Criteria} objects.
+ */
+class CriteriaBuilder {
+ static final Log __log = LogFactory.getLog(CriteriaBuilder.class);
+
+ /**
+ * Build a HQL query from an instance filter.
+ * @param filter filter
+ */
+ Query buildHQLQuery(Session session, InstanceFilter filter) {
+ Map<String, Object> parameters = new HashMap<String, Object>();
+
+ StringBuffer query = new StringBuffer();
+
+ query.append("select pi from HProcessInstance as pi left join fetch pi.fault ");
+
+ if (filter != null) {
+ // Building each clause
+ ArrayList<String> clauses = new ArrayList<String>();
+
+ // iid filter
+ if ( filter.getIidFilter() != null ) {
+ StringBuffer filters = new StringBuffer();
+ List<String> iids = filter.getIidFilter();
+ for (int m = 0; m < iids.size(); m++) {
+ filters.append(" pi.id = :iid").append(m);
+ parameters.put("iid" + m, iids.get(m));
+ if (m < iids.size() - 1) filters.append(" or");
+ }
+ clauses.add(" (" + filters + ")");
+ }
+
+ // pid filter
+ if (filter.getPidFilter() != null) {
+ StringBuffer filters = new StringBuffer();
+ List<String> pids = filter.getPidFilter();
+ String cmp;
+ if (filter.arePidsNegative()) {
+ cmp = " != ";
+ } else {
+ cmp = " = ";
+ }
+ for (int m = 0; m < pids.size(); m++) {
+ filters.append(" pi.process.id ").append(cmp).append(" :pid").append(m);
+ parameters.put("pid" + m, pids.get(m));
+ if (m < pids.size() - 1) filters.append(" or");
+ }
+ clauses.add(" (" + filters + ")");
+ }
+
+ // name filter
+ if (filter.getNameFilter() != null) {
+ clauses.add(" pi.process.typeName like :pname");
+ parameters.put("pname", filter.getNameFilter().replaceAll("\\*", "%"));
+ }
+
+ // name space filter
+ if (filter.getNamespaceFilter() != null) {
+ clauses.add(" pi.process.typeNamespace like :pnamespace");
+ parameters.put("pnamespace", filter.getNamespaceFilter().replaceAll("\\*", "%"));
+ }
+
+ // started filter
+ if (filter.getStartedDateFilter() != null) {
+ for ( String ds : filter.getStartedDateFilter() ) {
+ // named parameters not needed as date is parsed and is hence not
+ // prone to HQL injections
+ clauses.add(" pi.created " + dateFilter(ds));
+ }
+ }
+
+ // last-active filter
+ if (filter.getLastActiveDateFilter() != null) {
+ for ( String ds : filter.getLastActiveDateFilter() ) {
+ // named parameters not needed as date is parsed and is hence not
+ // prone to HQL injections
+ clauses.add(" pi.lastActiveTime " + dateFilter(ds));
+ }
+ }
+
+ // status filter
+ if (filter.getStatusFilter() != null) {
+ StringBuffer filters = new StringBuffer();
+ List<Short> states = filter.convertFilterState();
+ for (int m = 0; m < states.size(); m++) {
+ filters.append(" pi.state = :pstate").append(m);
+ parameters.put("pstate" + m, states.get(m));
+ if (m < states.size() - 1) filters.append(" or");
+ }
+ clauses.add(" (" + filters.toString() + ")");
+ }
+
+ // $property filter
+ if (filter.getPropertyValuesFilter() != null) {
+ Map<String,String> props = filter.getPropertyValuesFilter();
+ // join to correlation sets
+ query.append(" inner join pi.correlationSets as cs");
+ int i = 0;
+ for (String propKey : props.keySet()) {
+ i++;
+ // join to props for each prop
+ query.append(" inner join cs.properties as csp"+i);
+ // add clause for prop key and value
+
+ // spaces have to be escaped, might be better handled in InstanceFilter
+ String value = props.get(propKey).replaceAll(" ", " ");
+ if (propKey.startsWith("{")) {
+ String namespace = propKey.substring(1, propKey.lastIndexOf("}"));
+ clauses.add(" csp" + i + ".name = :cspname" + i +
+ " and csp" + i + ".namespace = :cspnamespace" + i +
+ " and csp" + i + ".value = :cspvalue" + i);
+
+ parameters.put("cspname" + i, propKey.substring(propKey.lastIndexOf("}") + 1, propKey.length()));
+ parameters.put("cspnamespace" + i, namespace);
+ parameters.put("cspvalue" + i, value);
+ } else {
+ clauses.add(" csp" + i + ".name = :cspname" + i +
+ " and csp" + i + ".value = :cspvalue" + i);
+
+ parameters.put("cspname" + i, propKey);
+ parameters.put("cspvalue" + i, value);
+ }
+ }
+ }
+
+ // order by
+ StringBuffer orderby = new StringBuffer("");
+ if (filter.getOrders() != null) {
+ orderby.append(" order by");
+ List<String> orders = filter.getOrders();
+ for (int m = 0; m < orders.size(); m++) {
+ String field = orders.get(m);
+ String ord = " asc";
+ if (field.startsWith("-")) {
+ ord = " desc";
+ }
+ String fieldName = " pi.id";
+ if (field.endsWith("name")) {
+ fieldName = " pi.process.typeName";
+ }
+ if (field.endsWith("namespace")) {
+ fieldName = " pi.process.typeNamespace";
+ }
+ if ( field.endsWith("version")) {
+ fieldName = " pi.process.version";
+ }
+ if ( field.endsWith("status")) {
+ fieldName = " pi.state";
+ }
+ if ( field.endsWith("started")) {
+ fieldName = " pi.created";
+ }
+ if ( field.endsWith("last-active")) {
+ fieldName = " pi.lastActiveTime";
+ }
+ orderby.append(fieldName + ord);
+ if (m < orders.size() - 1) orderby.append(", ");
+ }
+
+ }
+
+ // Preparing the statement
+ if (clauses.size() > 0) {
+ query.append(" where");
+ for (int m = 0; m < clauses.size(); m++) {
+ query.append(clauses.get(m));
+ if (m < clauses.size() - 1) query.append(" and");
+ }
+ }
+
+ query.append(orderby);
+ }
+
+ if (__log.isDebugEnabled()) {
+ __log.debug(query.toString());
+ }
+
+ Query q = session.createQuery(query.toString());
+
+ for (String p : parameters.keySet()) {
+ q.setParameter(p, parameters.get(p));
+ }
+
+ if (filter.getLimit() != 0) {
+ q.setMaxResults(filter.getLimit());
+ }
+
+ return q;
+ }
+
+ private static String dateFilter(String filter) {
+ String date = Filter.getDateWithoutOp(filter);
+ String op = filter.substring(0,filter.indexOf(date));
+ Date dt = null;
+ try {
+ dt = ISO8601DateParser.parse(date);
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ Timestamp ts = new Timestamp(dt.getTime());
+ return op + " '" + ts.toString() + "'";
+ }
+
+
+
+ /**
+ * Build a Hibernate {@link Criteria} from an instance filter.
+ * @param crit target (destination) criteria
+ * @param filter filter
+ */
+ void buildCriteria(Criteria crit, InstanceFilter filter) {
+ Criteria processCrit = crit.createCriteria("process");
+
+ // Filtering on PID
+ List<String> pids = filter.getPidFilter();
+ if (pids != null && pids.size() > 0) {
+ Disjunction disj = Restrictions.disjunction();
+ for (String pid: pids) {
+ if( !filter.arePidsNegative() ) {
+ disj.add(Restrictions.eq("processId", pid));
+ } else {
+ disj.add(Restrictions.ne("processId", pid));
+ }
+ }
+ processCrit.add(disj);
+ }
+
+ List<String> iids = filter.getIidFilter();
+ if (iids != null && iids.size() > 0) {
+ Disjunction disj = Restrictions.disjunction();
+ for (String iid: iids) {
+ disj.add(Restrictions.eq("id", new Long(iid)));
+ }
+ crit.add(disj);
+ }
+
+ // Filtering on name and namespace
+ if (filter.getNameFilter() != null) {
+ processCrit.add(Restrictions.like("typeName", filter.getNameFilter().replaceAll("\\*", "%")));
+ }
+ if (filter.getNamespaceFilter() != null) {
+ processCrit.add(Restrictions.like("typeNamespace", filter.getNamespaceFilter().replaceAll("\\*", "%")));
+ }
+
+ // Specific filter for status (using a disjunction between possible statuses)
+ if (filter.getStatusFilter() != null) {
+ List<Short> statuses = filter.convertFilterState();
+ Disjunction disj = Restrictions.disjunction();
+ for (short status : statuses) {
+ disj.add(Restrictions.eq("state", status));
+ }
+ crit.add(disj);
+ }
+
+ // Specific filter for started and last active dates.
+ if (filter.getStartedDateFilter() != null) {
+ for (String sdf : filter.getStartedDateFilter()) {
+ addFilterOnPrefixedDate(crit, sdf, "created");
+ }
+ }
+ if (filter.getLastActiveDateFilter() != null) {
+ for (String ladf : filter.getLastActiveDateFilter()) {
+ addFilterOnPrefixedDate(crit, ladf, "lastActiveTime");
+ }
+ }
+
+ // Specific filter for correlation properties
+ if (filter.getPropertyValuesFilter() != null) {
+ Criteria propCrit = crit.createCriteria("correlationSets").createCriteria("properties");
+ for (Map.Entry<String, String> corValue : filter.getPropertyValuesFilter().entrySet()) {
+ String propName = (String)corValue.getKey();
+ if (propName.startsWith("{")) {
+ String namespace = propName.substring(1, propName.lastIndexOf("}"));
+ propName = propName.substring(propName.lastIndexOf("}") + 1, propName.length());
+ propCrit.add(Restrictions.eq("name", propName))
+ .add(Restrictions.eq("namespace", namespace))
+ .add(Restrictions.eq("value", corValue.getValue()));
+ } else {
+ propCrit.add(Restrictions.eq("name", corValue.getKey()))
+ .add(Restrictions.eq("value", corValue.getValue()));
+ }
+ }
+ }
+
+ // Ordering
+ if (filter.orders != null) {
+ for (String key : filter.orders) {
+ boolean ascending = true;
+ String orderKey = key;
+ if (key.startsWith("+") || key.startsWith("-")) {
+ orderKey = key.substring(1, key.length());
+ if (key.startsWith("-")) ascending = false;
+ }
+
+ if ("name".equals(orderKey)) {
+ if (ascending) processCrit.addOrder(Property.forName("typeName").asc());
+ else processCrit.addOrder(Property.forName("typeName").desc());
+ } else if ("namespace".equals(orderKey)) {
+ if (ascending) processCrit.addOrder(Property.forName("typeNamespace").asc());
+ else processCrit.addOrder(Property.forName("typeNamespace").desc());
+ } else if ("pid".equals(orderKey)) {
+ if (ascending) processCrit.addOrder(Property.forName("processId").asc());
+ else processCrit.addOrder(Property.forName("processId").desc());
+ } else if ("version".equals(orderKey)) {
+ if (ascending) processCrit.addOrder(Property.forName("version").asc());
+ else processCrit.addOrder(Property.forName("version").desc());
+ } else if ("status".equals(orderKey)) {
+ if (ascending) crit.addOrder(Property.forName("state").asc());
+ else crit.addOrder(Property.forName("state").desc());
+ } else if ("started".equals(orderKey)) {
+ if (ascending) crit.addOrder(Property.forName("created").asc());
+ else crit.addOrder(Property.forName("created").desc());
+ } else if ("last-active".equals(orderKey)) {
+ if (ascending) crit.addOrder(Property.forName("lastActiveTime").asc());
+ else crit.addOrder(Property.forName("lastActiveTime").desc());
+ }
+ }
+ }
+
+ if (filter.getLimit() > 0) crit.setMaxResults(filter.getLimit());
+ }
+
+ /**
+ * Build criteria for an event filter.
+ * @param crit target criteria
+ * @param efilter event filter
+ */
+ void buildCriteria(Criteria crit, BpelEventFilter efilter) {
+ if (efilter.getTypeFilter() != null)
+ crit.add(Restrictions.like("type", efilter.getTypeFilter().replace('*','%')));
+
+ // Specific filter for started and last active dates.
+ if (efilter.getTimestampFilter() != null) {
+ for (Filter.Restriction<Date> sdf : efilter.getTimestampFilter()) {
+ addFilterOnPrefixedDate(crit, sdf.op, sdf.value, "tstamp");
+ }
+ }
+
+ if (efilter.limit > 0) crit.setMaxResults(efilter.limit);
+ }
+
+ void addScopeFilter(Criteria crit, String scopeId) {
+ crit.add(Restrictions.eq("",scopeId));
+ }
+
+ static void addFilterOnPrefixedDate(Criteria crit, String prefixedDate, String dateAttribute) {
+ Date realDate = null;
+ try {
+ realDate = parseDateExpression(getDateWithoutOp(prefixedDate));
+ } catch (ParseException e) {
+ // Never occurs, the deploy date format is pre-validated by the filter
+ }
+ addFilterOnPrefixedDate(crit,prefixedDate,realDate,dateAttribute);
+ }
+
+ private static Date parseDateExpression(String date) throws ParseException {
+ if( date.toLowerCase().startsWith("-") && date.length() > 1 ) {
+ return RelativeDateParser.parseRelativeDate(date.substring(1));
+ } else {
+ return ISO8601DateParser.parse(date);
+ }
+ }
+
+ static void addFilterOnPrefixedDate(Criteria crit, String op, Date date, String dateAttribute) {
+ if (op.startsWith("=")) {
+ crit.add(Restrictions.eq(dateAttribute, date));
+ } else if (op.startsWith("<=")) {
+ crit.add(Restrictions.le(dateAttribute, date));
+ } else if (op.startsWith(">=")) {
+ crit.add(Restrictions.ge(dateAttribute, date));
+ } else if (op.startsWith("<")) {
+ crit.add(Restrictions.lt(dateAttribute, date));
+ } else if (op.startsWith(">")) {
+ crit.add(Restrictions.gt(dateAttribute, date));
+ }
+ }
+
+ private static String getDateWithoutOp(String ddf) {
+ return Filter.getDateWithoutOp(ddf);
+ }
+
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/FaultDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/FaultDAOImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/FaultDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,75 @@
+/*
+ * 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.hib.bpel;
+
+import java.io.IOException;
+
+import javax.xml.namespace.QName;
+
+import org.apache.ode.dao.bpel.FaultDAO;
+import org.apache.ode.dao.hib.SessionManager;
+import org.apache.ode.dao.hib.bpel.hobj.HFaultData;
+import org.apache.ode.utils.DOMUtils;
+import org.apache.ode.utils.QNameUtils;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+/**
+ * Hibernate based {@link FaultDAO} implementation
+ */
+public class FaultDAOImpl extends HibernateDao implements FaultDAO {
+
+
+ HFaultData _self;
+
+ public FaultDAOImpl(SessionManager sm, HFaultData fault) {
+ super(sm, fault);
+ entering("FaultDAOImpl.FaultDAOImpl");
+ _self = fault;
+ }
+
+ public QName getName() {
+ return QNameUtils.toQName(_self.getName());
+ }
+
+ public Element getData() {
+ entering("FaultDAOImpl.getData");
+ if (_self.getData() == null) return null;
+ try {
+ return DOMUtils.stringToDOM(_self.getData());
+ } catch (SAXException e) {
+ throw new RuntimeException(e);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public String getExplanation() {
+ return _self.getExplanation();
+ }
+
+ public int getLineNo() {
+ return _self.getLineNo();
+ }
+
+ public int getActivityId() {
+ return _self.getActivityId();
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/HibernateDao.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/HibernateDao.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/HibernateDao.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,121 @@
+/*
+ * 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.hib.bpel;
+
+import org.apache.ode.dao.hib.SessionManager;
+import org.apache.ode.dao.hib.bpel.hobj.HObject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.Query;
+import org.hibernate.Session;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * Base class for our DAO objects.
+ * <p>
+ * All subclass methods that might trigger SQL queries should log a message in the log category 'org.apache.ode.bpel.DAO' when entered.
+ * A typical message could be "className.methodName". <br/>
+ * Typical candidates are setters, finders and getters of entities. Getters of simple properties won't provide relevant information.
+ */
+public abstract class HibernateDao {
+
+ // logger used by subclasses to track entered methods that may trigger sql query
+ // we don't use the package name to avoid interferences with other logging info.
+ static final Log logDao = LogFactory.getLog("org.apache.ode.bpel.DAO");
+
+ protected final SessionManager _sm;
+ protected final HObject _hobj;
+
+ protected HibernateDao(SessionManager sessionManager, HObject hobj) {
+ _sm = sessionManager;
+ _hobj = hobj;
+ }
+
+ void entering(String msg){
+ // add a prefix to be parser friendly
+ if(logDao.isDebugEnabled()) logDao.debug("entering "+msg);
+ }
+
+ void leaving(String msg){
+ if(logDao.isDebugEnabled()) logDao.debug("leaving "+msg);
+ }
+
+ /**
+ * @see org.apache.ode.utils.dao.DAO#getDHandle()
+ */
+ public Serializable getDHandle() {
+ return new HibernateHandle(getClass(), _hobj.getClass(), getSession().getIdentifier(_hobj));
+ }
+
+ protected Session getSession() {
+ return _sm.getSession();
+ }
+
+ public HObject getHibernateObj() {
+ return _hobj;
+ }
+
+ public Serializable getId() {
+ if( _hobj != null ) {
+ return _hobj.getId();
+ }
+ return null;
+ }
+
+ public boolean equals(Object obj) {
+ assert obj instanceof HibernateDao;
+ return _hobj.getId().equals(((HibernateDao) obj)._hobj.getId());
+ }
+
+ public int hashCode() {
+ return _hobj.getId().hashCode();
+ }
+
+ protected void update() {
+ _sm.getSession().update(_hobj);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void deleteByIds(Class entity, List<Long> ids) {
+ deleteByColumn(entity, "id", ids);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void deleteByColumn(Class entity, String column, List<Long> values) {
+ if( values != null && values.size() > 0 ) {
+ final String delete = "delete from "+entity.getName()+" as e where e."+column+" in (:values)";
+
+ // some databases don't like long lists of values with IN operator
+ // so we delete in batches. Oracle 9i, for instance, doesn't support
+ // more than 1000 -- we opt to be conservative.
+ final int batchSize = 100;
+
+ int index = 0;
+ while (index < values.size()) {
+ List<Long> subList = values.subList(index, Math.min(index+batchSize, values.size()));
+ Query query = getSession().createQuery(delete);
+ query.setParameterList("values", subList);
+ query.executeUpdate();
+ index += batchSize;
+ }
+ }
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/HibernateHandle.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/HibernateHandle.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/HibernateHandle.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -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.hib.bpel;
+
+import java.io.Serializable;
+
+/**
+ * Serializable class for obtain a reference to a hibernate POJO
+ */
+class HibernateHandle implements Serializable{
+
+ private static final long serialVersionUID = 1L;
+ private Class _daoCls;
+ private Class _hibCls;
+ private Serializable _id;
+ /**
+ *
+ */
+ public HibernateHandle(Class daoCls, Class hibCls, Serializable id) {
+ _daoCls = daoCls;
+ _hibCls = hibCls;
+ _id = id;
+ }
+
+ public Class getHibernateClass(){
+ return _hibCls;
+ }
+
+ public Class getDAOClass(){
+ return _daoCls;
+ }
+
+ public Serializable getId(){
+ return _id;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/MessageDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/MessageDaoImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/MessageDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,98 @@
+/*
+ * 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.hib.bpel;
+
+
+import javax.xml.namespace.QName;
+
+import org.apache.ode.dao.bpel.MessageDAO;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
+import org.apache.ode.dao.hib.SessionManager;
+import org.apache.ode.dao.hib.bpel.hobj.HMessage;
+import org.apache.ode.utils.DOMUtils;
+import org.hibernate.Session;
+import org.w3c.dom.Element;
+
+
+public class MessageDaoImpl extends HibernateDao implements MessageDAO {
+
+ private HMessage _hself;
+ private Session _session;
+
+ public MessageDaoImpl(SessionManager sessionManager, HMessage hobj) {
+ super(sessionManager, hobj);
+ entering("MessageDaoImpl.MessageDaoImpl");
+ _hself = hobj;
+ _session = sessionManager.getSession();
+ }
+
+ public void setType(QName type) {
+ entering("MessageDaoImpl.setType");
+ _hself.setType(type == null ? null : type.toString());
+ }
+
+ public QName getType() {
+ return _hself.getType() == null ? null : QName.valueOf(_hself.getType());
+ }
+
+ public void setData(Element value) {
+ entering("MessageDaoImpl.setData");
+ if (value == null) return;
+ _hself.setMessageData(DOMUtils.domToBytes(value));
+ update();
+ leaving("MessageDaoImpl.setData");
+ }
+
+ public Element getData() {
+ entering("MessageDaoImpl.getData");
+ if (_hself.getMessageData() == null)
+ return null;
+ try {
+ return DOMUtils.stringToDOM(_hself.getMessageData());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void setHeader(Element value) {
+ entering("MessageDaoImpl.setHeader");
+ if (value == null) return;
+ _hself.setHeader(DOMUtils.domToBytes(value));
+ update();
+ leaving("MessageDaoImpl.setHeader");
+ }
+
+ public Element getHeader() {
+ entering("MessageDaoImpl.getHeader");
+ if (_hself.getHeader() == null) return null;
+ try {
+ return DOMUtils.stringToDOM(_hself.getHeader());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public MessageExchangeDAO getMessageExchange() {
+ entering("MessageDaoImpl.getMessageExchange");
+ return new MessageExchangeDaoImpl(_sm,_hself.getMessageExchange());
+ }
+
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/MessageExchangeDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/MessageExchangeDaoImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/MessageExchangeDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,381 @@
+/*
+ * 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.hib.bpel;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.dao.bpel.MessageDAO;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
+import org.apache.ode.dao.bpel.PartnerLinkDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.hib.SessionManager;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelatorMessage;
+import org.apache.ode.dao.hib.bpel.hobj.HMessage;
+import org.apache.ode.dao.hib.bpel.hobj.HMessageExchange;
+import org.apache.ode.dao.hib.bpel.hobj.HProcess;
+import org.apache.ode.dao.hib.bpel.hobj.HProcessInstance;
+import org.apache.ode.utils.DOMUtils;
+import org.apache.ode.utils.stl.CollectionsX;
+import org.apache.ode.utils.stl.UnaryFunctionEx;
+import org.w3c.dom.Element;
+
+public class MessageExchangeDaoImpl extends HibernateDao implements
+ MessageExchangeDAO {
+ @SuppressWarnings("unused")
+ private static final Log __log = LogFactory.getLog(MessageExchangeDaoImpl.class);
+
+ private HMessageExchange _hself;
+
+ // Used when provided process and instance aren't hibernate implementations. The relation
+ // therefore can't be persisted. Used for in-mem DAOs so that doesn't matter much.
+ private ProcessDAO _externalProcess;
+ private ProcessInstanceDAO _externalInstance;
+
+ public MessageExchangeDaoImpl(SessionManager sm, HMessageExchange mex) {
+ super(sm, mex);
+ entering("MessageExchangeDaoImpl.MessageExchangeDaoImpl");
+ _hself = mex;
+ }
+
+ public String getMessageExchangeId() {
+ return _hself.getId().toString();
+ }
+
+ public MessageDAO getResponse() {
+ entering("MessageExchangeDaoImpl.getResponse");
+ return _hself.getResponse() == null ? null : new MessageDaoImpl(_sm, _hself.getResponse());
+ }
+
+ public Date getCreateTime() {
+ return _hself.getInsertTime();
+ }
+
+ public void setCreateTime(Date createTime) {
+ _hself.setInsertTime(createTime);
+ }
+
+ public MessageDAO getRequest() {
+ entering("MessageExchangeDaoImpl.getRequest");
+ return _hself.getRequest() == null ? null : new MessageDaoImpl(_sm, _hself.getRequest());
+ }
+
+ public String getOperation() {
+ return _hself.getOperationName();
+ }
+
+ public QName getPortType() {
+ return _hself.getPortType() == null ? null : QName.valueOf(_hself.getPortType());
+ }
+
+ public void setPortType(QName porttype) {
+ entering("MessageExchangeDaoImpl.setPortType");
+ _hself.setPortType(porttype == null ? null : porttype.toString());
+ update();
+ }
+
+ public void setStatus(String status) {
+ entering("MessageExchangeDaoImpl.setStatus");
+ _hself.setState(status);
+ update();
+ }
+
+ public String getStatus() {
+ return _hself.getState();
+ }
+
+ public MessageDAO createMessage(QName type) {
+ entering("MessageExchangeDaoImpl.createMessage");
+ HMessage message = new HMessage();
+ message.setType(type == null ? null : type.toString());
+ message.setCreated(new Date());
+ message.setMessageExchange(_hself);
+ getSession().save(message);
+ return new MessageDaoImpl(_sm, message);
+
+ }
+
+ public void setRequest(MessageDAO msg) {
+ entering("MessageExchangeDaoImpl.setRequest");
+ _hself.setRequest(msg == null ? null : (HMessage) ((MessageDaoImpl) msg).getHibernateObj());
+ update();
+ }
+
+ public void setResponse(MessageDAO msg) {
+ entering("MessageExchangeDaoImpl.setResponse");
+ _hself.setResponse(msg == null ? null : (HMessage) ((MessageDaoImpl) msg).getHibernateObj());
+ update();
+ }
+
+ public int getPartnerLinkModelId() {
+ return _hself.getPartnerLinkModelId();
+ }
+
+ public void setPartnerLinkModelId(int modelId) {
+ entering("MessageExchangeDaoImpl.setPartnerLinkModelId");
+ _hself.setPartnerLinkModelId(modelId);
+ update();
+ }
+
+ public String getCorrelationId() {
+ return _hself.getClientKey();
+ }
+
+ public void setCorrelationId(String clientKey) {
+ entering("MessageExchangeDaoImpl.setCorrelationId");
+ _hself.setClientKey(clientKey);
+ update();
+ }
+
+ public void setPattern(String pattern) {
+ entering("MessageExchangeDaoImpl.setPattern");
+ _hself.setPattern(pattern);
+ update();
+
+ }
+
+ public void setOperation(String opname) {
+ entering("MessageExchangeDaoImpl.setOperation");
+ _hself.setOperationName(opname);
+ update();
+ }
+
+ public void setEPR(Element source) {
+ entering("MessageExchangeDaoImpl.setEPR");
+ if (source == null)
+ _hself.setEndpoint(null);
+ else {
+ _hself.setEndpoint(DOMUtils.domToBytes(source));
+ }
+
+ getSession().saveOrUpdate(_hself);
+
+ }
+
+ public Element getEPR() {
+ entering("MessageExchangeDaoImpl.getEPR");
+ byte[] endpoint = _hself.getEndpoint();
+ if (endpoint == null)
+ return null;
+ try {
+ return DOMUtils.stringToDOM(endpoint);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void setCallbackEPR(Element source) {
+ entering("MessageExchangeDaoImpl.setCallbackEPR");
+ if (source == null)
+ _hself.setCallbackEndpoint(null);
+ else {
+ _hself.setCallbackEndpoint(DOMUtils.domToBytes(source));
+ }
+
+ getSession().saveOrUpdate(_hself);
+
+ }
+
+ public Element getCallbackEPR() {
+ entering("MessageExchangeDaoImpl.getCallbackEPR");
+ byte[] endpoint = _hself.getCallbackEndpoint();
+ if (endpoint == null)
+ return null;
+ try {
+ return DOMUtils.stringToDOM(endpoint);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public String getPattern() {
+ return _hself.getPattern();
+ }
+
+ public String getChannel() {
+ return _hself.getChannelName();
+ }
+
+ public void setChannel(String channel) {
+ entering("MessageExchangeDaoImpl.setChannel");
+ _hself.setChannelName(channel);
+ update();
+ }
+
+ public boolean getPropagateTransactionFlag() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public QName getFault() {
+ return _hself.getFault() == null ? null : QName.valueOf(_hself.getFault());
+ }
+
+ public void setFault(QName faultType) {
+ entering("MessageExchangeDaoImpl.setFault");
+ _hself.setFault(faultType == null ? null : faultType.toString());
+ update();
+ }
+
+ public String getFaultExplanation() {
+ return _hself.getFaultExplanation();
+ }
+
+ public void setFaultExplanation(String explanation) {
+ entering("MessageExchangeDaoImpl.setFaultExplanation");
+ _hself.setFaultExplanation(explanation);
+ update();
+ }
+
+ public void setCorrelationStatus(String cstatus) {
+ entering("MessageExchangeDaoImpl.setCorrelationStatus");
+ _hself.setCorrelationStatus(cstatus);
+ update();
+ }
+
+ public String getCorrelationStatus() {
+ return _hself.getCorrelationStatus();
+ }
+
+ public ProcessDAO getProcess() {
+ entering("MessageExchangeDaoImpl.getProcess");
+ if (_externalProcess != null) return _externalProcess;
+ else return _hself.getProcess() == null ? null : new ProcessDaoImpl(_sm, _hself.getProcess());
+ }
+
+ public void setProcess(ProcessDAO process) {
+ entering("MessageExchangeDaoImpl.setProcess");
+ if (process == null || process instanceof ProcessDaoImpl) {
+ _hself.setProcess(process == null ? null : (HProcess) ((ProcessDaoImpl) process).getHibernateObj());
+ update();
+ } else {
+ _externalProcess = process;
+ }
+ }
+
+ public void setInstance(ProcessInstanceDAO instance) {
+ entering("MessageExchangeDaoImpl.setInstance");
+ if (instance == null || instance instanceof ProcessInstanceDaoImpl) {
+ _hself.setInstance(instance == null ? null : (HProcessInstance) ((ProcessInstanceDaoImpl) instance)
+ .getHibernateObj());
+ update();
+ } else {
+ _externalInstance = instance;
+ }
+
+ }
+
+ public ProcessInstanceDAO getInstance() {
+ entering("MessageExchangeDaoImpl.getInstance");
+ if (_externalInstance != null) return _externalInstance;
+ else return _hself.getInstance() == null ? null : new ProcessInstanceDaoImpl(_sm, _hself.getInstance());
+ }
+
+ public char getDirection() {
+ return _hself.getDirection();
+ }
+
+ public QName getCallee() {
+ String callee = _hself.getCallee();
+ return callee == null ? null : QName.valueOf(callee);
+ }
+
+ public void setCallee(QName callee) {
+ entering("MessageExchangeDaoImpl.setCallee");
+ _hself.setCallee(callee == null ? null : callee.toString());
+ update();
+ }
+
+ public String getProperty(String key) {
+ entering("MessageExchangeDaoImpl.getProperty");
+ return _hself.getProperties().get(key);
+ }
+
+ public void setProperty(String key, String value) {
+ entering("MessageExchangeDaoImpl.setProperty");
+ _hself.getProperties().put(key, value);
+ update();
+ }
+
+ public void setPartnerLink(PartnerLinkDAO plinkDAO) {
+ entering("MessageExchangeDaoImpl.setPartnerLink");
+ _hself.setPartnerLink(((PartnerLinkDAOImpl) plinkDAO)._self);
+ update();
+ }
+
+ public PartnerLinkDAO getPartnerLink() {
+ entering("MessageExchangeDaoImpl.getPartnerLink");
+ return new PartnerLinkDAOImpl(_sm, _hself.getPartnerLink());
+ }
+
+ public Set<String> getPropertyNames() {
+ entering("MessageExchangeDaoImpl.getPropertyNames");
+ return Collections.unmodifiableSet(_hself.getProperties().keySet());
+ }
+
+ public String getPipedMessageExchangeId() {
+ return _hself.getPipedMessageExchangeId();
+ }
+
+ public void setPipedMessageExchangeId(String mexId) {
+ entering("MessageExchangeDaoImpl.setPipedMessageExchangeId");
+ _hself.setPipedMessageExchangeId(mexId);
+ }
+
+ public int getSubscriberCount() {
+ return _hself.getSubscriberCount();
+ }
+
+ public void setSubscriberCount(int subscriberCount) {
+ _hself.setSubscriberCount(subscriberCount);
+ }
+
+ public void release(boolean doClean) {
+ if( doClean ) {
+ deleteMessages();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void releasePremieMessages() {
+ deleteByIds(HCorrelatorMessage.class, getSession().getNamedQuery(HCorrelatorMessage.SELECT_CORMESSAGE_IDS_BY_MEX).setParameter("mex", _hself).list());
+ }
+
+ public void incrementSubscriberCount() {
+ _hself.incrementSubscriberCount();
+ }
+
+ @SuppressWarnings("unchecked")
+ public void deleteMessages() {
+ deleteByIds(HCorrelatorMessage.class, getSession().getNamedQuery(HCorrelatorMessage.SELECT_CORMESSAGE_IDS_BY_MEX).setParameter("mex", _hself).list());
+
+ getSession().delete(_hself);
+ // This deletes endpoint LData, callbackEndpoint LData, request HMessage, response HMessage, HMessageExchangeProperty
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/MessageRouteDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/MessageRouteDaoImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/MessageRouteDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,95 @@
+/*
+ * 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.hib.bpel;
+
+import org.apache.ode.bpel.common.CorrelationKeySet;
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.dao.bpel.MessageRouteDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.hib.SessionManager;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelatorSelector;
+import org.apache.ode.dao.hib.bpel.hobj.HProcessInstance;
+import org.hibernate.Query;
+
+/**
+ * Hibernate-based {@link MessageRouteDAO} implementation.
+ */
+class MessageRouteDaoImpl extends HibernateDao implements MessageRouteDAO {
+
+ private static final String LOCK_INSTANCE = "update " + HProcessInstance.class.getName()
+ + " set lock=lock+1 where id=?";
+
+ private HCorrelatorSelector _selector;
+
+ private boolean _locked = false;
+
+ public MessageRouteDaoImpl(SessionManager sm, HCorrelatorSelector hobj) {
+ super(sm, hobj);
+ entering("MessageRouteDaoImpl.MessageRouteDaoImpl");
+ _selector = hobj;
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.MessageRouteDAO#getTargetInstance()
+ */
+ public ProcessInstanceDAO getTargetInstance() {
+ entering("MessageRouteDaoImpl.getTargetInstance");
+ // First we need to reliably lock the instance:
+ if (!_locked) {
+ Query q = getSession().createQuery(LOCK_INSTANCE);
+ q.setLong(0, _selector.getInstance().getId());
+ q.executeUpdate();
+ _locked = true;
+ }
+
+ // now it is safe to return
+ return new ProcessInstanceDaoImpl(_sm, _selector.getInstance());
+ }
+
+ public String getGroupId() {
+ entering("MessageRouteDaoImpl.getGroupId");
+ return _selector.getGroupId();
+ }
+
+ public int getIndex() {
+ entering("MessageRouteDaoImpl.getIndex");
+ return _selector.getIndex();
+ }
+
+ public String getRoute() {
+ return _selector.getRoute();
+ }
+
+ public CorrelationKeySet getCorrelationKeySet() {
+ return new CorrelationKeySet(_selector.getCorrelationKey());
+ }
+
+ public void setCorrelationKeySet(CorrelationKeySet keySet) {
+ _selector.setCorrelationKey(keySet.toCanonicalString());
+ }
+
+ public void setCorrelationKey(CorrelationKey key) {
+ _selector.setCorrelationKey(key.toCanonicalString());
+ }
+
+ public CorrelationKey getCorrelationKey() {
+ return new CorrelationKey(_selector.getCorrelationKey());
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/PartnerLinkDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/PartnerLinkDAOImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/PartnerLinkDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,146 @@
+/*
+ * 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.hib.bpel;
+
+import javax.xml.namespace.QName;
+
+import org.apache.ode.dao.bpel.PartnerLinkDAO;
+import org.apache.ode.dao.hib.SessionManager;
+import org.apache.ode.dao.hib.bpel.hobj.HPartnerLink;
+import org.apache.ode.utils.DOMUtils;
+import org.w3c.dom.Element;
+
+/**
+ * Hibernate based {EndpointReferenceDAO} implementation. can either be related
+ * to a scope (when it's specific to a scope instance, for example because it
+ * has been assigned during the instance execution) or to a process definition
+ * (general endpoint configuration).
+ */
+public class PartnerLinkDAOImpl extends HibernateDao implements PartnerLinkDAO {
+
+
+ /** Cached copy of my epr */
+ private Element _myEPR;
+
+ /** Cached copy of partner epr. */
+ private Element _partnerEPR;
+
+ HPartnerLink _self;
+
+ public PartnerLinkDAOImpl(SessionManager sessionManager, HPartnerLink hobj) {
+ super(sessionManager, hobj);
+ entering("PartnerLinkDAOImpl.PartnerLinkDAOImpl");
+ _self = hobj;
+ }
+
+ public String getPartnerLinkName() {
+ return _self.getLinkName();
+ }
+
+ public String getPartnerRoleName() {
+ return _self.getPartnerRole();
+ }
+
+ public String getMyRoleName() {
+ return _self.getMyRole();
+ }
+
+ public int getPartnerLinkModelId() {
+ return _self.getModelId();
+ }
+
+ public QName getMyRoleServiceName() {
+ return _self.getServiceName() == null ? null : QName.valueOf(_self.getServiceName());
+ }
+
+ public void setMyRoleServiceName(QName svcName) {
+ entering("PartnerLinkDAOImpl.setMyRoleServiceName");
+ _self.setServiceName(svcName == null ? null : svcName.toString());
+ update();
+ }
+
+ public Element getMyEPR() {
+ entering("PartnerLinkDAOImpl.getMyEPR");
+ if (_myEPR != null)
+ return _myEPR;
+ if (_self.getMyEPR() == null)
+ return null;
+ try {
+ return DOMUtils.stringToDOM(_self.getMyEPR());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void setMyEPR(Element val) {
+ entering("PartnerLinkDAOImpl.setMyEPR");
+ _myEPR = val;
+ if (val == null) {
+ _self.setMyEPR(null);
+ } else {
+ _self.setMyEPR(DOMUtils.domToBytes(val));
+ }
+ getSession().update(_self);
+ }
+
+ public Element getPartnerEPR() {
+ entering("PartnerLinkDAOImpl.getPartnerEPR");
+ if (_partnerEPR != null)
+ return _partnerEPR;
+ if (_self.getPartnerEPR() == null)
+ return null;
+ try {
+ return _partnerEPR = DOMUtils.stringToDOM(_self.getPartnerEPR());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void setPartnerEPR(Element val) {
+ entering("PartnerLinkDAOImpl.setPartnerEPR");
+ _partnerEPR = val;
+ if (val == null) {
+ _self.setPartnerEPR(null);
+ } else {
+ _self.setPartnerEPR(DOMUtils.domToBytes(val));
+ }
+ getSession().update(_self);
+ }
+
+ public String getMySessionId() {
+ return _self.getMySessionId();
+ }
+
+ public String getPartnerSessionId() {
+ return _self.getPartnerSessionId();
+ }
+
+ public void setPartnerSessionId(String session) {
+ entering("PartnerLinkDAOImpl.setPartnerSessionId");
+ _self.setPartnerSessionId(session);
+ }
+
+ public void setMySessionId(String sessionId) {
+ entering("PartnerLinkDAOImpl.setMySessionId");
+ _self.setMySessionId(sessionId);
+
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessDaoImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,299 @@
+/*
+ * 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.hib.bpel;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.bpel.common.ProcessState;
+import org.apache.ode.bpel.iapi.ProcessConf.CLEANUP_CATEGORY;
+import org.apache.ode.dao.bpel.CorrelatorDAO;
+import org.apache.ode.dao.bpel.DeferredProcessInstanceCleanable;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.hib.SessionManager;
+import org.apache.ode.dao.hib.bpel.hobj.HActivityRecovery;
+import org.apache.ode.dao.hib.bpel.hobj.HBpelEvent;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelationProperty;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelationSet;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelator;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelatorMessage;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelatorSelector;
+import org.apache.ode.dao.hib.bpel.hobj.HFaultData;
+import org.apache.ode.dao.hib.bpel.hobj.HMessage;
+import org.apache.ode.dao.hib.bpel.hobj.HMessageExchange;
+import org.apache.ode.dao.hib.bpel.hobj.HMessageExchangeProperty;
+import org.apache.ode.dao.hib.bpel.hobj.HPartnerLink;
+import org.apache.ode.dao.hib.bpel.hobj.HProcess;
+import org.apache.ode.dao.hib.bpel.hobj.HProcessInstance;
+import org.apache.ode.dao.hib.bpel.hobj.HScope;
+import org.apache.ode.dao.hib.bpel.hobj.HVariableProperty;
+import org.apache.ode.dao.hib.bpel.hobj.HXmlData;
+import org.hibernate.Criteria;
+import org.hibernate.Hibernate;
+import org.hibernate.Query;
+import org.hibernate.StaleStateException;
+import org.hibernate.UnresolvableObjectException;
+import org.hibernate.criterion.Expression;
+import org.hibernate.criterion.Order;
+
+/**
+ * Hibernate-based {@link ProcessDAO} implementation.
+ */
+public class ProcessDaoImpl extends HibernateDao implements ProcessDAO, DeferredProcessInstanceCleanable {
+ private static final Log __log = LogFactory.getLog(ProcessDaoImpl.class);
+
+ private static final String QRY_CORRELATOR = "where this.correlatorId = ?";
+
+ private HProcess _process;
+
+ public ProcessDaoImpl(SessionManager sm, HProcess process) {
+ super(sm,process);
+ entering("ProcessDaoImpl.ProcessDaoImpl");
+ _process = process;
+ }
+
+ public QName getProcessId() {
+ return _process == null ? null : QName.valueOf(_process.getProcessId());
+ }
+
+ public ProcessInstanceDAO getInstance(Long iid) {
+ entering("ProcessDaoImpl.getInstance");
+ ProcessInstanceDAO instance = BpelDAOConnectionImpl._getInstance(_sm, getSession(), iid);
+ if (instance == null || !instance.getProcess().getProcessId().equals(getProcessId()))
+ return null;
+ return instance;
+ }
+
+ @SuppressWarnings("unchecked")
+ public CorrelatorDAO getCorrelator(String corrId) {
+ entering("ProcessDaoImpl.getCorrelator");
+ Iterator results;
+ Query q = getSession().createFilter(_process.getCorrelators(),
+ QRY_CORRELATOR);
+ results = q.setString(0, corrId).iterate();
+
+ if(!results.hasNext()){
+ String msg = "no such correlator: corrId = " + corrId;
+ throw new IllegalArgumentException(msg);
+ }
+ try {
+ return new CorrelatorDaoImpl(_sm, (HCorrelator)results.next());
+ } finally {
+ Hibernate.close(results);
+ }
+ }
+
+ public void removeRoutes(String routeId, ProcessInstanceDAO target) {
+ entering("ProcessDaoImpl.removeRoutes");
+ for (HCorrelator hCorrelator : _process.getCorrelators()) {
+ new CorrelatorDaoImpl(_sm, hCorrelator).removeRoutes(routeId, target);
+ }
+ }
+
+ public ProcessInstanceDAO createInstance(CorrelatorDAO correlator) {
+ entering("ProcessDaoImpl.createInstance");
+ HProcessInstance instance = new HProcessInstance();
+ instance.setInstantiatingCorrelator((HCorrelator)((CorrelatorDaoImpl)correlator).getHibernateObj());
+ instance.setProcess(_process);
+ instance.setCreated(new Date());
+ getSession().save(instance);
+// _process.addInstance(instance);
+
+ return new ProcessInstanceDaoImpl(_sm,instance);
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessDAO#findInstance(CorrelationKey)
+ */
+ @SuppressWarnings("unchecked")
+ public Collection<ProcessInstanceDAO> findInstance(CorrelationKey ckeyValue) {
+ entering("ProcessDaoImpl.findInstance");
+ Criteria criteria = getSession().createCriteria(HCorrelationSet.class);
+ criteria.add(Expression.eq("scope.instance.process.id",_process.getId()));
+ criteria.add(Expression.eq("value", ckeyValue.toCanonicalString()));
+ criteria.addOrder(Order.desc("scope.instance.created"));
+ return criteria.list();
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessDAO#instanceCompleted(ProcessInstanceDAO)
+ */
+ public void instanceCompleted(ProcessInstanceDAO instance) {
+ // nothing to do here (yet?)
+ }
+
+ @SuppressWarnings("unchecked")
+ public void deleteProcessAndRoutes() {
+ // delete routes
+ deleteByIds(HCorrelatorSelector.class, getSession().getNamedQuery(HCorrelatorSelector.SELECT_MESSAGE_ROUTE_IDS_BY_PROCESS).setParameter("process", _process).list());
+
+ // delete process dao
+ deleteByIds(HCorrelator.class, getSession().getNamedQuery(HCorrelator.SELECT_CORRELATOR_IDS_BY_PROCESS).setParameter("process", _process).list());
+ try {
+ getSession().refresh(_process);
+ getSession().delete(_process); // this deletes HCorrelator -> HCorrelatorSelector
+
+ // after this delete, we have a use case that creates the process with the same procid.
+ // for hibernate to work without the database deferred constraint check, let's just flush the session.
+ getSession().flush();
+ } catch( UnresolvableObjectException sse ) {
+ __log.debug("Process: " + getProcessId() + " has been already deleted.");
+ // don't sweat, they already deleted by another thread or process
+ } catch( StaleStateException sse ) {
+ __log.debug("Process: " + getProcessId() + " has been already deleted.");
+ // don't sweat, they already deleted by another thread or process
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public int deleteInstances(int transactionSize) {
+ entering("ProcessDaoImpl.delete");
+
+ if( transactionSize < 1 ) {
+ if(__log.isWarnEnabled()) __log.warn("A zero or negative value was given for the transaction size of process dao deletion; overriding to '1'. Not using bulk deletion of rows may result in performance degradation.");
+ transactionSize = 1;
+ }
+
+ Collection<HProcessInstance> instances = getSession().getNamedQuery(HProcessInstance.SELECT_INSTANCES_BY_PROCESS).setParameter("process", _process).setMaxResults(transactionSize).list();
+ if( !instances.isEmpty() ) {
+ deleteEvents(instances);
+ deleteCorrelations(instances);
+ deleteMessages(instances);
+ deleteVariables(instances);
+ deleteProcessInstances(instances);
+ }
+
+ return instances.size();
+ }
+
+ public int deleteInstances(Collection<HProcessInstance> instances, Set<CLEANUP_CATEGORY> categories) {
+ entering("ProcessDaoImpl.deleteInstances");
+
+ if( !instances.isEmpty() ) {
+ if( categories.contains(CLEANUP_CATEGORY.EVENTS)) {
+ deleteEvents(instances);
+ }
+ if( categories.contains(CLEANUP_CATEGORY.CORRELATIONS)) {
+ deleteCorrelations(instances);
+ }
+ if( categories.contains(CLEANUP_CATEGORY.MESSAGES)) {
+ deleteMessages(instances);
+ }
+ if( categories.contains(CLEANUP_CATEGORY.VARIABLES)) {
+ deleteVariables(instances);
+ }
+ if( categories.contains(CLEANUP_CATEGORY.INSTANCE)) {
+ deleteProcessInstances(instances);
+ }
+ }
+
+ return instances.size();
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteProcessInstances(Collection<HProcessInstance> instances) {
+ deleteByIds(HActivityRecovery.class, getSession().getNamedQuery(HActivityRecovery.SELECT_ACTIVITY_RECOVERY_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HFaultData.class, getSession().getNamedQuery(HFaultData.SELECT_FAULT_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+
+ List<Long> instanceIds = new ArrayList<Long>();
+ for( HProcessInstance instance : instances ) {
+ instanceIds.add(instance.getId());
+ }
+ deleteByIds(HProcessInstance.class, instanceIds);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteVariables(Collection<HProcessInstance> instances) {
+ deleteByIds(HVariableProperty.class, getSession().getNamedQuery(HVariableProperty.SELECT_VARIABLE_PROPERTY_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HXmlData.class, getSession().getNamedQuery(HXmlData.SELECT_XMLDATA_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HPartnerLink.class, getSession().getNamedQuery(HPartnerLink.SELECT_PARTNER_LINK_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HScope.class, getSession().getNamedQuery(HScope.SELECT_SCOPE_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteMessages(Collection<HProcessInstance> instances) {
+ deleteByIds(HActivityRecovery.class, getSession().getNamedQuery(HCorrelatorMessage.SELECT_CORMESSAGE_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HMessage.class, getSession().getNamedQuery(HMessage.SELECT_MESSAGE_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ List<Long> mex = getSession().getNamedQuery(HMessageExchange.SELECT_MEX_IDS_BY_INSTANCES).setParameterList("instances", instances).list();
+ deleteByColumn(HMessageExchangeProperty.class, "mex.id", mex);
+ deleteByIds(HMessageExchange.class, mex);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteCorrelations(Collection<HProcessInstance> instances) {
+ deleteByIds(HCorrelationProperty.class, getSession().getNamedQuery(HCorrelationProperty.SELECT_CORPROP_IDS_BY_INSTANCES).setParameterList ("instances", instances).list());
+ deleteByIds(HCorrelationSet.class, getSession().getNamedQuery(HCorrelationSet.SELECT_CORSET_IDS_BY_INSTANCES).setParameterList ("instances", instances).list());
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteEvents(Collection<HProcessInstance> instances) {
+ deleteByIds(HBpelEvent.class, getSession().getNamedQuery(HBpelEvent.SELECT_EVENT_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ }
+
+ public QName getType() {
+ return new QName(_process.getTypeNamespace(), _process.getTypeName());
+ }
+
+ public long getVersion() {
+ return _process.getVersion();
+ }
+
+ public CorrelatorDAO addCorrelator(String corrid) {
+ entering("ProcessDaoImpl.addCorrelator");
+ HCorrelator correlator = new HCorrelator();
+ correlator.setCorrelatorId(corrid);
+ correlator.setProcess(_process);
+ correlator.setCreated(new Date());
+// _process.addCorrelator(correlator);
+ getSession().save(correlator);
+ getSession().saveOrUpdate(_process);
+ return new CorrelatorDaoImpl(_sm, correlator);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Collection<ProcessInstanceDAO> getActiveInstances() {
+ ArrayList<ProcessInstanceDAO> instDaos = new ArrayList<ProcessInstanceDAO>();
+ Collection<HProcessInstance> insts = getSession().getNamedQuery(HProcessInstance.SELECT_INSTANCES_BY_PROCESS_AND_STATES)
+ .setParameter("process", _process).setParameterList("states", new Object[] {ProcessState.STATE_ACTIVE}).list();
+ for (HProcessInstance inst : insts)
+ instDaos.add(new ProcessInstanceDaoImpl(_sm, inst));
+ return instDaos;
+ }
+
+ public int getNumInstances() {
+ entering("ProcessDaoImpl.getNumInstances");
+ // this should be efficient if the relation is tagged as extra-lazy.
+ // If the collection is not initialized yet, Hibernate will do a count(*) and the whole collection will not be fetched.
+ return _process.getInstances().size();
+ }
+
+ public String getGuid() {
+ return _process.getGuid();
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessInstanceDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessInstanceDaoImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessInstanceDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,573 @@
+/*
+ * 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.hib.bpel;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.common.ProcessState;
+import org.apache.ode.bpel.evt.ProcessInstanceEvent;
+import org.apache.ode.bpel.iapi.ProcessConf.CLEANUP_CATEGORY;
+import org.apache.ode.dao.bpel.ActivityRecoveryDAO;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.CorrelationSetDAO;
+import org.apache.ode.dao.bpel.CorrelatorDAO;
+import org.apache.ode.dao.bpel.FaultDAO;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.ScopeDAO;
+import org.apache.ode.dao.bpel.ScopeStateEnum;
+import org.apache.ode.dao.bpel.XmlDataDAO;
+import org.apache.ode.dao.hib.SessionManager;
+import org.apache.ode.dao.hib.bpel.hobj.HActivityRecovery;
+import org.apache.ode.dao.hib.bpel.hobj.HBpelEvent;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelationProperty;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelationSet;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelatorMessage;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelatorSelector;
+import org.apache.ode.dao.hib.bpel.hobj.HFaultData;
+import org.apache.ode.dao.hib.bpel.hobj.HMessage;
+import org.apache.ode.dao.hib.bpel.hobj.HMessageExchange;
+import org.apache.ode.dao.hib.bpel.hobj.HMessageExchangeProperty;
+import org.apache.ode.dao.hib.bpel.hobj.HPartnerLink;
+import org.apache.ode.dao.hib.bpel.hobj.HProcessInstance;
+import org.apache.ode.dao.hib.bpel.hobj.HScope;
+import org.apache.ode.dao.hib.bpel.hobj.HVariableProperty;
+import org.apache.ode.dao.hib.bpel.hobj.HXmlData;
+import org.apache.ode.utils.DOMUtils;
+import org.apache.ode.utils.QNameUtils;
+import org.apache.ode.utils.stl.CollectionsX;
+import org.apache.ode.utils.stl.UnaryFunction;
+import org.hibernate.Criteria;
+import org.hibernate.Hibernate;
+import org.hibernate.Query;
+import org.hibernate.criterion.Projections;
+import org.hibernate.criterion.Restrictions;
+import org.w3c.dom.Element;
+
+/**
+ * Hibernate-based {@link ProcessInstanceDAO} implementation.
+ */
+public class ProcessInstanceDaoImpl extends HibernateDao implements ProcessInstanceDAO {
+ private static final Log __log = LogFactory.getLog(ProcessInstanceDaoImpl.class);
+
+ /** Query for removing selectors. */
+ private static final String QRY_DELSELECTORS = "delete from " +
+ HCorrelatorSelector.class.getName() + " where instance = ?";
+
+ private static final String QRY_VARIABLES = "from " + HXmlData.class.getName()
+ + " as x where x.name = ? and x.scope.scopeModelId = ? and x.scope.instance.id = ?";
+
+ private static final String QRY_RECOVERIES = "from " + HActivityRecovery.class.getName() +
+ " AS x WHERE x.instance.id = ?";
+
+ private HProcessInstance _instance;
+
+ private ScopeDAO _root;
+
+ public ProcessInstanceDaoImpl(SessionManager sm, HProcessInstance instance) {
+ super(sm, instance);
+ entering("ProcessInstanceDaoImpl.ProcessInstanceDaoImpl");
+ _instance = instance;
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getCreateTime()
+ */
+ public Date getCreateTime() {
+ return _instance.getCreated();
+ }
+
+ public void setFault(FaultDAO fault) {
+ entering("ProcessInstanceDaoImpl.setFault");
+ _instance.setFault(((FaultDAOImpl)fault)._self);
+ getSession().update(_instance);
+
+ }
+
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#setFault(javax.xml.namespace.QName, String, int, int, org.w3c.dom.Element)
+ */
+ public void setFault(QName name, String explanation, int lineNo, int activityId, Element faultData) {
+ entering("ProcessInstanceDaoImpl.setFault");
+ if (_instance.getFault() != null)
+ getSession().delete(_instance.getFault());
+
+ HFaultData fault = new HFaultData();
+ fault.setName(QNameUtils.fromQName(name));
+ fault.setExplanation(explanation);
+ fault.setLineNo(lineNo);
+ fault.setActivityId(activityId);
+ if (faultData != null) {
+ fault.setData(DOMUtils.domToBytes(faultData));
+ }
+
+ _instance.setFault(fault);
+ getSession().save(fault);
+ getSession().update(_instance);
+ }
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getFault()
+ */
+ public FaultDAO getFault() {
+ entering("ProcessInstanceDaoImpl.getFault");
+ if (_instance.getFault() == null) return null;
+ else return new FaultDAOImpl(_sm, _instance.getFault());
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getExecutionState()
+ */
+ public byte[] getExecutionState() {
+ entering("ProcessInstanceDaoImpl.getExecutionState");
+ if (_instance.getJacobState() == null) return null;
+ return _instance.getJacobState();
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#setExecutionState(byte[])
+ */
+ public void setExecutionState(byte[] bytes) {
+ entering("ProcessInstanceDaoImpl.setExecutionState");
+ if (bytes.length > 0) {
+ _instance.setJacobState(bytes);
+ }
+ getSession().update(_instance);
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getProcess()
+ */
+ public ProcessDAO getProcess() {
+ entering("ProcessInstanceDaoImpl.getProcess");
+ return new ProcessDaoImpl(_sm, _instance.getProcess());
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getRootScope()
+ */
+ public ScopeDAO getRootScope() {
+ entering("ProcessInstanceDaoImpl.getRootScope");
+ if (_root != null)
+ return _root;
+ Query rootQry = getSession().createFilter(_instance.getScopes(),
+ "where this.parentScope is null");
+ HScope hroot = (HScope)rootQry.uniqueResult();
+ if (hroot == null)
+ return null;
+ return _root = new ScopeDaoImpl(_sm, hroot);
+ }
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#setState(short)
+ */
+ public void setState(short state) {
+ entering("ProcessInstanceDaoImpl.setState");
+ _instance.setPreviousState(_instance.getState());
+ _instance.setState(state);
+ if(state==ProcessState.STATE_TERMINATED) {
+ clearSelectors();
+ }
+ getSession().update(_instance);
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getState()
+ */
+ public short getState() {
+ return _instance.getState();
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getPreviousState()
+ */
+ public short getPreviousState() {
+ return _instance.getPreviousState();
+ }
+
+
+ public ScopeDAO createScope(ScopeDAO parentScope, String name, int scopeModelId) {
+ entering("ProcessInstanceDaoImpl.createScope");
+ HScope scope = new HScope();
+ scope.setParentScope(parentScope != null
+ ? (HScope)((ScopeDaoImpl)parentScope).getHibernateObj()
+ : null);
+ scope.setName(name);
+ scope.setScopeModelId(scopeModelId);
+ scope.setState(ScopeStateEnum.ACTIVE.toString());
+ scope.setInstance(_instance);
+ scope.setCreated(new Date());
+// _instance.addScope(scope);
+ getSession().save(scope);
+
+ return new ScopeDaoImpl(_sm, scope);
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getInstanceId()
+ */
+ public Long getInstanceId() {
+ return _instance.getId();
+ }
+
+ public ScopeDAO getScope(Long scopeInstanceId) {
+ entering("ProcessInstanceDaoImpl.getScope");
+ Long id = Long.valueOf(scopeInstanceId);
+ HScope scope = (HScope)getSession().get(HScope.class, id);
+ return scope != null
+ ? new ScopeDaoImpl(_sm, scope)
+ : null;
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getScopes(java.lang.String)
+ */
+ @SuppressWarnings("unchecked")
+ public Collection<ScopeDAO> getScopes(String scopeName) {
+ entering("ProcessInstanceDaoImpl.getScopes");
+ Collection<HScope> hscopes;
+ if (scopeName != null) {
+ Query filter = _sm.getSession().createFilter(_instance.getScopes(),
+ "where this.name=?");
+ filter.setString(0,scopeName);
+ hscopes = filter.list();
+ } else
+ hscopes = _instance.getScopes();
+ ArrayList<ScopeDAO> ret = new ArrayList<ScopeDAO>();
+ CollectionsX.transform(ret, hscopes, new UnaryFunction<HScope,ScopeDAO> () {
+ public ScopeDAO apply(HScope x) {
+ return new ScopeDaoImpl(_sm, x);
+ }
+ });
+ return ret;
+ }
+
+ public Collection<ScopeDAO> getScopes() {
+ return getScopes(null);
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getInstantiatingCorrelator()
+ */
+ public CorrelatorDAO getInstantiatingCorrelator() {
+ entering("ProcessInstanceDaoImpl.getInstantiatingCorrelator");
+ return new CorrelatorDaoImpl(_sm, _instance.getInstantiatingCorrelator());
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getLastActiveTime()
+ */
+ public Date getLastActiveTime() {
+ return _instance.getLastActiveTime();
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#setLastActiveTime(java.util.Date)
+ */
+ public void setLastActiveTime(Date dt) {
+ entering("ProcessInstanceDaoImpl.setLastActiveTime");
+ _instance.setLastActiveTime(dt);
+ }
+
+ public Set<CorrelationSetDAO> getCorrelationSets() {
+ entering("ProcessInstanceDaoImpl.getCorrelationSets");
+ Set<CorrelationSetDAO> results = new HashSet<CorrelationSetDAO>();
+
+ for (HCorrelationSet hCorrelationSet : _instance.getCorrelationSets()) {
+ results.add(new CorrelationSetDaoImpl(_sm, hCorrelationSet));
+ }
+
+ return results;
+ }
+
+ public CorrelationSetDAO getCorrelationSet(String name) {
+ entering("ProcessInstanceDaoImpl.getCorrelationSet");
+ for (HCorrelationSet hCorrelationSet : _instance.getCorrelationSets()) {
+ if (hCorrelationSet.getName().equals(name))
+ return new CorrelationSetDaoImpl(_sm, hCorrelationSet);
+ }
+ return null;
+ }
+
+ /**
+ * TODO this is never used, except by test cases - should be removed
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getVariables(java.lang.String, int)
+ */
+ @SuppressWarnings("unchecked")
+ public XmlDataDAO[] getVariables(String variableName, int scopeModelId) {
+ entering("ProcessInstanceDaoImpl.getVariables");
+ List<XmlDataDAO> results = new ArrayList<XmlDataDAO>();
+
+ Iterator iter;
+ Query qry = getSession().createQuery(QRY_VARIABLES);
+ qry.setString(0, variableName);
+ qry.setInteger(1, scopeModelId);
+ qry.setLong(2, _instance.getId());
+ iter = qry.iterate();
+
+ while(iter.hasNext()) {
+ results.add(new XmlDataDaoImpl(_sm, (HXmlData)iter.next()));
+ }
+ Hibernate.close(iter);
+
+ return results.toArray(new XmlDataDAO[results.size()]);
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#finishCompletion()
+ */
+ public void finishCompletion() {
+ entering("ProcessInstanceDaoImpl.finishCompletion");
+ // make sure we have completed.
+ assert (ProcessState.isFinished(this.getState()));
+ // let our process know that we've done our work.
+ this.getProcess().instanceCompleted(this);
+ }
+
+ public void delete(Set<CLEANUP_CATEGORY> cleanupCategories) {
+ delete(cleanupCategories, true);
+ }
+
+ public void delete(Set<CLEANUP_CATEGORY> cleanupCategories, boolean deleteMyRoleMex) {
+ entering("ProcessInstanceDaoImpl.delete");
+ if(__log.isDebugEnabled()) __log.debug("Cleaning up instance data with categories = " + cleanupCategories);
+
+ if( _instance.getJacobState() != null ) {
+ _instance.setJacobState(null);
+ }
+
+ HProcessInstance[] instances = new HProcessInstance[] {_instance};
+
+ if( cleanupCategories.contains(CLEANUP_CATEGORY.EVENTS) ) {
+ deleteEvents(instances);
+ }
+
+ if( cleanupCategories.contains(CLEANUP_CATEGORY.CORRELATIONS) ) {
+ deleteCorrelations(instances);
+ }
+
+ if( cleanupCategories.contains(CLEANUP_CATEGORY.MESSAGES) ) {
+ deleteMessages(instances, deleteMyRoleMex);
+ }
+
+ if( cleanupCategories.contains(CLEANUP_CATEGORY.VARIABLES) ) {
+ deleteVariables(instances);
+ }
+
+ if( cleanupCategories.contains(CLEANUP_CATEGORY.INSTANCE) ) {
+ deleteInstances(instances);
+ }
+
+ getSession().flush();
+
+ if(__log.isDebugEnabled()) __log.debug("Instance data cleaned up and flushed.");
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteInstances(HProcessInstance[] instances) {
+ deleteByIds(HFaultData.class, getSession().getNamedQuery(HFaultData.SELECT_FAULT_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+
+ getSession().delete(_instance); // this deletes JcobState, HActivityRecovery -> ActivityRecovery-LData
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteVariables(HProcessInstance[] instances) {
+ deleteByIds(HCorrelationProperty.class, getSession().getNamedQuery(HCorrelationProperty.SELECT_CORPROP_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HCorrelationSet.class, getSession().getNamedQuery(HCorrelationSet.SELECT_CORSET_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+
+ deleteByIds(HVariableProperty.class, getSession().getNamedQuery(HVariableProperty.SELECT_VARIABLE_PROPERTY_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HXmlData.class, getSession().getNamedQuery(HXmlData.SELECT_XMLDATA_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+
+ deleteByIds(HPartnerLink.class, getSession().getNamedQuery(HPartnerLink.SELECT_PARTNER_LINK_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+
+ deleteByIds(HScope.class, getSession().getNamedQuery(HScope.SELECT_SCOPE_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteMessages(HProcessInstance[] instances, boolean deleteMyRoleMex) {
+ // Let's delete ALL mex properties here
+ List<Long> allMexes = getSession().getNamedQuery(HMessageExchange.SELECT_MEX_IDS_BY_INSTANCES).setParameterList("instances", instances).list();
+ deleteByColumn(HMessageExchangeProperty.class, "mex.id", allMexes);
+
+ if( deleteMyRoleMex ) { // Delete my role mex and partner role mexes
+ // delete messages
+ deleteByIds(HMessage.class, getSession().getNamedQuery(HMessage.SELECT_MESSAGE_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+
+ // delete all mexes
+ deleteByIds(HMessageExchange.class, allMexes);
+ } else { // Delete only the unmatched mexes, there are chances that some unmatched messages are still there
+ Collection<HMessageExchange> unmatchedMex = getSession().getNamedQuery(HMessageExchange.SELECT_UNMATCHED_MEX_BY_INSTANCES).setParameterList("instances", instances).list();
+ if( !unmatchedMex.isEmpty() ) {
+ List<Long> mexIdList = new ArrayList<Long>();
+ for( HMessageExchange mex : unmatchedMex ) {
+ mexIdList.add(mex.getId());
+ }
+
+ // delete unmatched mexes
+ getSession().delete(unmatchedMex);
+ }
+ }
+
+ // Delete routes and unmatched messages
+ deleteByIds(HCorrelatorMessage.class, getSession().getNamedQuery(HCorrelatorMessage.SELECT_CORMESSAGE_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HCorrelatorSelector.class, getSession().getNamedQuery(HCorrelatorSelector.SELECT_MESSAGE_ROUTE_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteCorrelations(HProcessInstance[] instances) {
+ deleteByIds(HCorrelationProperty.class, getSession().getNamedQuery(HCorrelationProperty.SELECT_CORPROP_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HCorrelationSet.class, getSession().getNamedQuery(HCorrelationSet.SELECT_CORSET_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteEvents(HProcessInstance[] instances) {
+ deleteByIds(HBpelEvent.class, getSession().getNamedQuery(HBpelEvent.SELECT_EVENT_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ }
+
+ public void insertBpelEvent(ProcessInstanceEvent event) {
+ entering("ProcessInstanceDaoImpl.insertBpelEvent");
+ // Defer to the BpelDAOConnectionImpl
+ BpelDAOConnectionImpl._insertBpelEvent(getSession(), event, this.getProcess(), this);
+ }
+
+ public EventsFirstLastCountTuple getEventsFirstLastCount() {
+ entering("ProcessInstanceDaoImpl.getEventsFirstLastCount");
+ // Using a criteria, find the min,max, and count of event tstamps.
+ Criteria c = getSession().createCriteria(HBpelEvent.class);
+ c.add(Restrictions.eq("instance",_instance));
+ c.setProjection(Projections.projectionList().add(Projections.min("tstamp"))
+ .add(Projections.max("tstamp"))
+ .add(Projections.count("tstamp")));
+
+ Object[] ret = (Object[]) c.uniqueResult();
+ EventsFirstLastCountTuple flc = new EventsFirstLastCountTuple();
+ flc.first = (Date) ret[0];
+ flc.last = (Date) ret[1];
+ flc.count = (Integer)ret[2];
+ return flc;
+ }
+
+ public Collection<MessageExchangeDAO> getMessageExchanges() {
+ Collection<MessageExchangeDAO> exchanges = new ArrayList<MessageExchangeDAO>();
+
+ for( HMessageExchange exchange : _instance.getMessageExchanges() ) {
+ exchanges.add(new MessageExchangeDaoImpl(_sm, exchange));
+ }
+
+ return exchanges;
+ }
+
+ public long genMonotonic() {
+ entering("ProcessInstanceDaoImpl.genMonotonic");
+ long seq = _instance.getSequence()+1;
+ _instance.setSequence(seq);
+ return seq;
+ }
+
+ protected void clearSelectors() {
+ entering("ProcessInstanceDaoImpl.clearSelectors");
+ Query q = getSession().createQuery(QRY_DELSELECTORS);
+ q.setEntity(0, _instance);
+ q.executeUpdate();
+ }
+
+ public int getActivityFailureCount() {
+ return _instance.getActivityFailureCount();
+ }
+
+ public Date getActivityFailureDateTime() {
+ return _instance.getActivityFailureDateTime();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Collection<ActivityRecoveryDAO> getActivityRecoveries() {
+ entering("ProcessInstanceDaoImpl.getActivityRecoveries");
+ List<ActivityRecoveryDAO> results = new ArrayList<ActivityRecoveryDAO>();
+ Query qry = getSession().createQuery(QRY_RECOVERIES);
+ qry.setLong(0, _instance.getId());
+ Iterator iter = qry.iterate();
+ while (iter.hasNext())
+ results.add(new ActivityRecoveryDaoImpl(_sm, (HActivityRecovery) iter.next()));
+ Hibernate.close(iter);
+ return results;
+ }
+
+ public void createActivityRecovery(String channel, long activityId, String reason,
+ Date dateTime, Element data, String[] actions, int retries) {
+ entering("ProcessInstanceDaoImpl.createActivityRecovery");
+ HActivityRecovery recovery = new HActivityRecovery();
+ recovery.setInstance(_instance);
+ recovery.setChannel(channel);
+ recovery.setActivityId(activityId);
+ recovery.setReason(reason);
+ recovery.setDateTime(dateTime);
+ recovery.setRetries(retries);
+ if (data != null) {
+ recovery.setDetails(DOMUtils.domToBytes(data));
+ }
+ String list = actions[0];
+ for (int i = 1; i < actions.length; ++i)
+ list += " " + actions[i];
+ recovery.setActions(list);
+// _instance.addRecovery(recovery);
+ getSession().save(recovery);
+ _instance.setActivityFailureDateTime(dateTime);
+ _instance.setActivityFailureCount(_instance.getActivityFailureCount() + 1);
+ getSession().update(_instance);
+ }
+
+ /**
+ * Delete previously registered activity recovery.
+ */
+ public void deleteActivityRecovery(String channel) {
+ entering("ProcessInstanceDaoImpl.deleteActivityRecovery");
+ for (HActivityRecovery recovery : _instance.getActivityRecoveries()) {
+ if (recovery.getChannel().equals(channel)) {
+ getSession().delete(recovery);
+ _instance.setActivityFailureCount(_instance.getActivityFailureCount() - 1);
+ getSession().update(_instance);
+ return;
+ }
+ }
+ }
+
+ public BpelDAOConnection getConnection() {
+ entering("ProcessInstanceDaoImpl.getConnection");
+ return new BpelDAOConnectionImpl(_sm);
+ }
+
+ public Collection<String> getMessageExchangeIds() {
+ Collection<String> c = new HashSet<String>();
+ for (HMessageExchange m : _instance.getMessageExchanges()) {
+ c.add(m.getId().toString());
+ }
+ return c;
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessManagementDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessManagementDaoImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessManagementDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,68 @@
+/*
+ * 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.hib.bpel;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ode.bpel.common.InstanceFilter;
+import org.apache.ode.bpel.common.InstanceFilter.StatusKeys;
+import org.apache.ode.dao.bpel.ProcessManagementDAO;
+import org.apache.ode.dao.hib.SessionManager;
+import org.apache.ode.dao.hib.bpel.hobj.HProcessInstance;
+import org.hibernate.Query;
+
+public class ProcessManagementDaoImpl extends HibernateDao implements ProcessManagementDAO {
+ protected ProcessManagementDaoImpl(SessionManager sessionManager) {
+ super(sessionManager, null);
+ }
+
+ public Map<InstanceSummaryKey, Long> countInstancesSummary(Set<String> pids) {
+ Map<InstanceSummaryKey, Long> result = new HashMap<InstanceSummaryKey, Long>();
+ if (!pids.isEmpty()) {
+ for (StatusKeys status : InstanceFilter.StatusKeys.values()) {
+ Query query = getSession().getNamedQuery(HProcessInstance.COUNT_INSTANCES_BY_PROCESSES_IDS_AND_STATES);
+ query.setParameterList("states", new InstanceFilter("status=" + status.toString()).convertFilterState());
+ query.setParameterList("processIds", pids);
+ for (Object o : query.list()) {
+ Object[] row = (Object[]) o;
+ InstanceSummaryKey key = new InstanceSummaryKey(row[0].toString(), status.toString());
+ result.put(key, (Long) row[1]);
+ }
+ }
+ }
+ return result;
+ }
+
+ public Map<String, FailedSummaryValue> findFailedCountAndLastFailedDateForProcessIds(Set<String> pids) {
+ Map<String, FailedSummaryValue> result = new HashMap<String, FailedSummaryValue>();
+ if (!pids.isEmpty()) {
+ Query query = getSession().getNamedQuery(HProcessInstance.COUNT_FAILED_INSTANCES_BY_PROCESSES_IDS_AND_STATES);
+ query.setParameterList("processIds", pids);
+ for (Object o : query.list()) {
+ Object[] row = (Object[]) o;
+ result.put(row[0].toString(), new FailedSummaryValue((Long) row[1], (Date) row[2]));
+ }
+ }
+ return result;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ScopeDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ScopeDaoImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ScopeDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,266 @@
+/*
+ * 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.hib.bpel;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.ode.bpel.evt.BpelEvent;
+import org.apache.ode.dao.bpel.CorrelationSetDAO;
+import org.apache.ode.dao.bpel.PartnerLinkDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.ScopeDAO;
+import org.apache.ode.dao.bpel.ScopeStateEnum;
+import org.apache.ode.dao.bpel.XmlDataDAO;
+import org.apache.ode.dao.hib.SessionManager;
+import org.apache.ode.dao.hib.bpel.hobj.HBpelEvent;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelationSet;
+import org.apache.ode.dao.hib.bpel.hobj.HPartnerLink;
+import org.apache.ode.dao.hib.bpel.hobj.HScope;
+import org.apache.ode.dao.hib.bpel.hobj.HXmlData;
+import org.apache.ode.utils.SerializableUtils;
+import org.apache.ode.utils.stl.CollectionsX;
+import org.apache.ode.utils.stl.UnaryFunction;
+import org.apache.ode.utils.stl.UnaryFunctionEx;
+import org.hibernate.Criteria;
+import org.hibernate.Query;
+import org.hibernate.criterion.Restrictions;
+
+/**
+ * Hibernate-based {@link ScopeDAO} implementation.
+ */
+public class ScopeDaoImpl extends HibernateDao implements ScopeDAO {
+
+
+ private static final String QRY_VARIABLE = "from " + HXmlData.class.getName() +
+ " as x where x.name = ? and x.scope.id = ?";
+
+ private static final String QRY_CSET = "from " + HCorrelationSet.class.getName() +
+ " as c where c.name = ? and c.scope.id = ?";
+
+ private static final String QRY_SCOPE_EPR = "from " + HPartnerLink.class.getName() +
+ " as e where e.modelId = ? and e.scope = ?";
+
+ private HScope _scope;
+
+ private HashMap<String,XmlDataDAO> _variables = new HashMap<String,XmlDataDAO>();
+
+ public ScopeDaoImpl(SessionManager sm, HScope scope) {
+ super(sm, scope);
+ entering("ScopeDaoImpl.ScopeDaoImpl");
+ _scope = scope;
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getCorrelationSet(java.lang.String)
+ */
+ public CorrelationSetDAO getCorrelationSet(String corrSetName) {
+ entering("ScopeDaoImpl.getCorrelationSet");
+ Query qry = getSession().createQuery(QRY_CSET);
+ qry.setString(0,corrSetName);
+ qry.setLong(1,_scope.getId());
+ HCorrelationSet cs;
+ List res = qry.list();
+
+ if(res.size() == 0){
+ // if it doesn't exist, we make it
+ cs = new HCorrelationSet(_scope, corrSetName);
+// _scope.addCorrelationSet(cs);
+ getSession().save(cs);
+ } else {
+ cs = (HCorrelationSet)res.get(0);
+ }
+ return new CorrelationSetDaoImpl(_sm, cs);
+ }
+ /**
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getParentScope()
+ */
+ public ScopeDAO getParentScope() {
+ entering("ScopeDaoImpl.getParentScope");
+ return _scope.getParentScope() != null
+ ? new ScopeDaoImpl(_sm, _scope.getParentScope())
+ : null;
+ }
+ /**
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getProcessInstance()
+ */
+ public ProcessInstanceDAO getProcessInstance() {
+ entering("ScopeDaoImpl.getProcessInstance");
+ return new ProcessInstanceDaoImpl(_sm, _scope.getInstance());
+ }
+ /**
+ * @see org.apache.ode.dao.bpel.ScopeDAO#setState(org.apache.ode.dao.bpel.ScopeStateEnum)
+ */
+ public void setState(ScopeStateEnum state) {
+ entering("ScopeDaoImpl.setState");
+ _scope.setState(state.toString());
+ getSession().update(_scope);
+ }
+ /**
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getState()
+ */
+ public ScopeStateEnum getState() {
+ return new ScopeStateEnum(_scope.getState());
+ }
+ /**
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getName()
+ */
+ public String getName() {
+ return _scope.getName();
+ }
+ /**
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getVariable(java.lang.String)
+ */
+ public XmlDataDAO getVariable(String varName) {
+ entering("ScopeDaoImpl.getVariable");
+ XmlDataDAO cached = _variables.get(varName);
+ if (cached != null) return _variables.get(varName);
+
+ HXmlData data = null;
+ for (HXmlData e : _scope.getVariables()) {
+ if (e.getName().equals(varName) && e.getScope().getId().equals(_scope.getId())) {
+ data = e;
+ }
+ }
+ if (data == null) {
+ data = new HXmlData();
+ data.setName(varName);
+ data.setScope(_scope);
+ _scope.getVariables().add(data);
+ }
+
+ XmlDataDaoImpl varDao = new XmlDataDaoImpl(_sm, data);
+ _variables.put(varName, varDao);
+ return varDao;
+ }
+
+ public PartnerLinkDAO createPartnerLink(int modelId, String pLinkName, String myRole, String partnerRole) {
+ entering("ScopeDaoImpl.createPartnerLink");
+ HPartnerLink epr = new HPartnerLink();
+ epr.setModelId(modelId);
+ epr.setLinkName(pLinkName);
+ epr.setMyRole(myRole);
+ epr.setPartnerRole(partnerRole);
+ epr.setScope(_scope);
+// _scope.addPartnerLink(epr);
+ getSession().save(epr);
+ PartnerLinkDAOImpl eprDao = new PartnerLinkDAOImpl(_sm, epr);
+ return eprDao;
+ }
+
+ public PartnerLinkDAO getPartnerLink(int plinkId) {
+ entering("ScopeDaoImpl.getPartnerLink");
+ Query qry = getSession().createQuery(QRY_SCOPE_EPR);
+ qry.setInteger(0,plinkId);
+ qry.setEntity(1,_scope);
+ HPartnerLink hpl = (HPartnerLink) qry.uniqueResult();
+ if (hpl == null)
+ return null;
+ return new PartnerLinkDAOImpl(_sm, hpl);
+ }
+
+ public Collection<PartnerLinkDAO> getPartnerLinks() {
+ entering("ScopeDaoImpl.getPartnerLinks");
+ ArrayList<PartnerLinkDAO> plinks = new ArrayList<PartnerLinkDAO>();
+ for (HPartnerLink hPartnerLink : _scope.getPartnerLinks()) {
+ plinks.add(new PartnerLinkDAOImpl(_sm, hPartnerLink));
+ }
+ return plinks;
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getScopeInstanceId()
+ */
+ public Long getScopeInstanceId() {
+ return _scope.getId();
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getModelId()
+ */
+ public int getModelId() {
+ return _scope.getScopeModelId();
+ }
+
+ public Set<CorrelationSetDAO> getCorrelationSets() {
+ entering("ScopeDaoImpl.getCorrelationSets");
+ Set<CorrelationSetDAO> results = new HashSet<CorrelationSetDAO>();
+ for (HCorrelationSet hCorrelationSet : _scope.getCorrelationSets()) {
+ results.add(new CorrelationSetDaoImpl(_sm, hCorrelationSet));
+ }
+ return results;
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public Collection<ScopeDAO> getChildScopes() {
+ entering("ScopeDaoImpl.getChildScopes");
+ Query q = getSession().createQuery("from " + HScope.class.getName() + " as x where x.parentScope=?");
+ q.setEntity(0, _scope);
+ Collection<HScope> hscopes = q.list();
+ return CollectionsX.transform(new LinkedList<ScopeDAO>(), hscopes, new UnaryFunction<HScope,ScopeDAO>() {
+ public ScopeDAO apply(HScope x) {
+ return new ScopeDaoImpl(_sm,x);
+ }
+
+ });
+ }
+
+ @SuppressWarnings("unchecked")
+ public Collection<XmlDataDAO> getVariables() {
+ entering("ScopeDaoImpl.getVariables");
+ Query q = getSession().createFilter(_scope.getVariables(), "where this.scope=?");
+ q.setEntity(0, _scope);
+ return CollectionsX.transform(new LinkedList<XmlDataDAO>(), (Collection<HXmlData>)q.list(), new UnaryFunction<HXmlData,XmlDataDAO>() {
+ public XmlDataDAO apply(HXmlData x) {
+ return new XmlDataDaoImpl(_sm,x);
+ }
+
+ });
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<BpelEvent> listEvents() {
+ entering("ScopeDaoImpl.listEvents");
+// CriteriaBuilder cb = new CriteriaBuilder();
+ Criteria crit = _sm.getSession().createCriteria(HBpelEvent.class);
+// if (efilter != null)
+// cb.buildCriteria(crit, efilter);
+ crit.add(Restrictions.eq("scopeId",_scope.getId()));
+
+ List<HBpelEvent> hevents = crit.list();
+ List<BpelEvent> ret = new ArrayList<BpelEvent>(hevents.size());
+ try {
+ CollectionsX.transformEx(ret,hevents,new UnaryFunctionEx<HBpelEvent,BpelEvent>() {
+ public BpelEvent apply(HBpelEvent x) throws Exception{
+ return (BpelEvent) SerializableUtils.toObject(x.getData(),BpelEvent.class.getClassLoader());
+ }
+
+ });
+ }catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ return ret;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/XmlDataDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/XmlDataDaoImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/XmlDataDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,172 @@
+/*
+ * 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.hib.bpel;
+
+import java.util.Iterator;
+
+import org.apache.ode.dao.bpel.ScopeDAO;
+import org.apache.ode.dao.bpel.XmlDataDAO;
+import org.apache.ode.dao.hib.SessionManager;
+import org.apache.ode.dao.hib.bpel.hobj.HVariableProperty;
+import org.apache.ode.dao.hib.bpel.hobj.HXmlData;
+import org.apache.ode.utils.DOMUtils;
+import org.hibernate.Query;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
+
+/**
+ * Hibernate-based {@link XmlDataDAO} implementation.
+ */
+public class XmlDataDaoImpl extends HibernateDao implements XmlDataDAO {
+
+
+ private static final String QUERY_PROPERTY =
+ "from " + HVariableProperty.class.getName() +
+ " as p where p.xmlData.id = ? and p.name = ?";
+
+ private HXmlData _data;
+ private Node _node;
+
+ /**
+ * @param hobj
+ */
+ public XmlDataDaoImpl(SessionManager sm, HXmlData hobj) {
+ super(sm, hobj);
+ entering("XmlDataDaoImpl.XmlDataDaoImpl");
+ _data = hobj;
+ }
+ /**
+ * @see org.apache.ode.dao.bpel.XmlDataDAO#isNull()
+ */
+ public boolean isNull() {
+ entering("XmlDataDaoImpl.isNull");
+ return (_data.getData() == null || _data.getData().length == 0);
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.XmlDataDAO#get()
+ */
+ public Node get() {
+ entering("XmlDataDaoImpl.get");
+ if(_node == null){
+ _node = prepare();
+ }
+ return _node;
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.XmlDataDAO#remove()
+ */
+ public void remove() {
+
+ }
+ /**
+ * @see org.apache.ode.dao.bpel.XmlDataDAO#set(org.w3c.dom.Node)
+ */
+ public void set(Node val) {
+ entering("XmlDataDaoImpl.set");
+ _node = val;
+ _data.setSimpleType(!(val instanceof Element));
+
+ if(_data.isSimpleType()) {
+ _data.setData(_node.getNodeValue().getBytes());
+ } else {
+ _data.setData(DOMUtils.domToString(_node).getBytes());
+ }
+
+ getSession().saveOrUpdate(_data);
+ leaving("XmlDataDaoImpl.set");
+ }
+ /**
+ * @see org.apache.ode.dao.bpel.XmlDataDAO#getProperty(java.lang.String)
+ */
+ public String getProperty(String propertyName) {
+ entering("XmlDataDaoImpl.getProperty");
+ HVariableProperty p = _getProperty(propertyName);
+ return p == null
+ ? null
+ : p.getValue();
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.XmlDataDAO#setProperty(java.lang.String, java.lang.String)
+ */
+ public void setProperty(String pname, String pvalue) {
+ entering("XmlDataDaoImpl.setProperty");
+ HVariableProperty p = _getProperty(pname);
+ if(p == null){
+ p = new HVariableProperty(_data, pname, pvalue);
+ getSession().save(p);
+// _data.addProperty(p);
+ }else{
+ p.setValue(pvalue);
+ getSession().update(p);
+ }
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.XmlDataDAO#getScopeDAO()
+ */
+ public ScopeDAO getScopeDAO() {
+ entering("XmlDataDaoImpl.getScopeDAO");
+ return new ScopeDaoImpl(_sm,_data.getScope());
+ }
+
+ private HVariableProperty _getProperty(String propertyName){
+ entering("XmlDataDaoImpl._getProperty");
+ Iterator iter;
+ Query qry = getSession().createQuery(QUERY_PROPERTY);
+ qry.setLong(0, _data.getId());
+ qry.setString(1, propertyName);
+ iter = qry.iterate();
+ return iter.hasNext()
+ ? (HVariableProperty)iter.next()
+ : null;
+ }
+
+ private Node prepare(){
+ if(_data.getData() == null || _data.getData().length == 0)
+ return null;
+ String data = new String(_data.getData());
+ if(_data.isSimpleType()){
+ Document d = DOMUtils.newDocument();
+ // we create a dummy wrapper element
+ // prevents some apps from complaining
+ // when text node is not actual child of document
+ Element e = d.createElement("text-node-wrapper");
+ Text tnode = d.createTextNode(data);
+ d.appendChild(e);
+ e.appendChild(tnode);
+ return tnode;
+ }else{
+ try{
+ return DOMUtils.stringToDOM(data);
+ }catch(Exception e){
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ public String getName() {
+ return _data.getName();
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/GZipDataType.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/GZipDataType.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/GZipDataType.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,221 @@
+/*
+ * 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.hib.bpel.hobj;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.sql.SQLException;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.Types;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.hibernate.usertype.UserType;
+
+/**
+ * Custom Hibernate datatype that compresses (GZip) byte arrays
+ * to increase performance and save disk space.
+ */
+public class GZipDataType implements UserType {
+ private static final Log log = LogFactory.getLog(GZipDataType.class);
+
+ public static final int[] SQL_TYPES = new int[] { Types.BLOB };
+
+ public static final Class RETURNED_CLASS = new byte[0].getClass();
+
+ /** For backward compatibility with non-zipped data, prefix the gzip stream with a magic sequence */
+ public static final byte[] GZIP_PREFIX = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x03, 0x02, 0x01, 0x00 };
+
+ // Compression statistics
+ private static long _totalBytesBefore = 0;
+ private static long _totalBytesAfter = 0;
+ private static volatile long _lastLogTime = 0;
+ private static final Object STATS_LOCK = new Object();
+
+ private static volatile boolean _compressionEnabled = System.getProperty("org.apache.ode.dao.hib.bpel.hobj.GZipDataType.enabled", "true").equalsIgnoreCase("true");
+
+ /** Reconstruct an object from the cacheable representation */
+ public Object assemble(Serializable cached, Object owner) {
+ // serializable representation is same
+ return cached;
+ }
+
+ /** Transform the object into its cacheable representation */
+ public Serializable disassemble(Object value) {
+ // as-is
+ return (Serializable) value;
+ }
+
+ /** Return a deep copy of the persistent state */
+ public Object deepCopy(Object value) {
+ if (value == null) return null;
+ return ((byte[]) value).clone();
+ }
+
+ /** Compare two instances of the class mapped by this type for persistence "equality". */
+ public boolean equals(Object x, Object y) {
+ byte[] buf1 = (byte[]) x;
+ byte[] buf2 = (byte[]) y;
+ if (buf1 == buf2) return true;
+ if (buf1 == null && buf2 != null) return false;
+ if (buf1 != null && buf2 == null) return false;
+ if (buf1.length != buf2.length) return false;
+ for (int i=0; i<buf1.length; i++) {
+ if (buf1[i] != buf2[i]) return false;
+ }
+ return true;
+ }
+
+ /** Get a hashcode for the instance, consistent with persistence "equality" */
+ public int hashCode(Object x) {
+ if (x == null) return 0;
+ byte[] buf = (byte[]) x;
+ int hash = 0;
+ for (int i=0; i<buf.length; i++) {
+ hash += buf[i];
+ }
+ return hash;
+ }
+
+ /** Are objects of this type mutable? */
+ public boolean isMutable() {
+ return false;
+ }
+
+ /** Retrieve an instance of the mapped class from a JDBC resultset. */
+ public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws SQLException {
+ if (names.length != 1) throw new IllegalStateException("Expected a single column name instead of "+names.length);
+ byte[] buf = rs.getBytes(names[0]);
+ if (buf == null) {
+ return null;
+ }
+ if (buf.length >= GZIP_PREFIX.length) {
+ boolean gzip = true;
+ for (int i=0; i<GZIP_PREFIX.length; i++) {
+ if (buf[i] != GZIP_PREFIX[i]) {
+ gzip = false;
+ break;
+ }
+ }
+ if (gzip) {
+ buf = gunzip(new ByteArrayInputStream(buf, GZIP_PREFIX.length, buf.length-GZIP_PREFIX.length));
+ }
+ }
+ return buf;
+ }
+
+ /** Write an instance of the mapped class to a prepared statement. */
+ public void nullSafeSet(PreparedStatement st, Object value, int index) throws SQLException {
+ byte[] buf = (byte[]) value;
+ if (buf != null) {
+ synchronized (STATS_LOCK) {
+ if (_totalBytesBefore > Integer.MAX_VALUE) {
+ // prevent overflow - renormalize to percent value
+ _totalBytesAfter = _totalBytesAfter*100/_totalBytesBefore;
+ _totalBytesBefore = 100;
+ }
+ _totalBytesBefore += buf.length;
+ }
+ // only try to zip if we have more than 100 bytes
+ if (buf != null && buf.length > 100 && _compressionEnabled) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(buf.length);
+ for (int i=0; i<GZIP_PREFIX.length; i++) {
+ baos.write(GZIP_PREFIX[i]);
+ }
+ gzip((byte[]) value, baos);
+ byte[] zipped = baos.toByteArray();
+ // only use zipped representation if we gain 2% or more
+ if (zipped.length*100/buf.length < 99) {
+ buf = zipped;
+ }
+ }
+ synchronized (STATS_LOCK) {
+ _totalBytesAfter += buf.length;
+ }
+ if (log.isDebugEnabled()) {
+ long now = System.currentTimeMillis();
+ if (_lastLogTime+5000 < now) {
+ log.debug("Average compression ratio: "+ (_totalBytesAfter*100/_totalBytesBefore)+"%");
+ _lastLogTime = now;
+ }
+ }
+ }
+ st.setBytes(index, buf);
+ }
+
+ /** During merge, replace the existing (target) value in the entity we are
+ * merging to with a new (original) value from the detached entity we are merging.
+ */
+ public Object replace(Object original, Object target, Object owner) {
+ return original;
+ }
+
+ /** The class returned by nullSafeGet(). */
+ public Class returnedClass() {
+ return RETURNED_CLASS;
+ }
+
+ /** Return the SQL type codes for the columns mapped by this type. */
+ public int[] sqlTypes() {
+ return SQL_TYPES;
+ }
+
+ /**
+ * Compress (using gzip algorithm) a byte array into an output stream.
+ */
+ public static void gzip(byte[] content, OutputStream out) {
+ try {
+ GZIPOutputStream zip = new GZIPOutputStream(out);
+ zip.write(content, 0, content.length);
+ zip.finish();
+ zip.close();
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ /**
+ * Decompress (using gzip algorithm) a byte array.
+ */
+ public static byte[] gunzip(InputStream input) {
+ try {
+ GZIPInputStream unzip = new GZIPInputStream(input);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(32*1024);
+ byte[] buf = new byte[4096];
+ int len;
+ while ((len = unzip.read(buf)) > 0) {
+ baos.write(buf, 0, len);
+ }
+ unzip.close();
+ return baos.toByteArray();
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HActivityRecovery.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HActivityRecovery.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HActivityRecovery.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,134 @@
+/*
+ * 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.hib.bpel.hobj;
+
+import java.util.Date;
+
+/**
+ * Persistent representation of activity recovery information.
+ * @hibernate.class table="BPEL_ACTIVITY_RECOVERY"
+ * @hibernate.query name="SELECT_ACTIVITY_RECOVERY_IDS_BY_INSTANCES" query="select id from HActivityRecovery as a where a.instance in (:instances)"
+ */
+public class HActivityRecovery extends HObject {
+ public final static String SELECT_ACTIVITY_RECOVERY_IDS_BY_INSTANCES = "SELECT_ACTIVITY_RECOVERY_IDS_BY_INSTANCES";
+
+ /** Process instance to which this scope belongs. */
+ private HProcessInstance _instance;
+ private long _activityId;
+ private String _channel;
+ private String _reason;
+ private Date _dateTime;
+ private byte[] _details;
+ private String _actions;
+ private int _retries;
+
+ /**
+ * Get the {@link HProcessInstance} to which this scope object belongs.
+ * @hibernate.many-to-one
+ * column="PIID" foreign-key="none"
+ */
+ public HProcessInstance getInstance() {
+ return _instance;
+ }
+
+ /** @see #getInstance() */
+ public void setInstance(HProcessInstance instance) {
+ _instance = instance;
+ }
+
+ /**
+ * @hibernate.property column="AID"
+ */
+ public long getActivityId() {
+ return _activityId;
+ }
+
+ public void setActivityId(long activityId) {
+ _activityId = activityId;
+ }
+
+ /**
+ * @hibernate.property column="CHANNEL"
+ */
+ public String getChannel() {
+ return _channel;
+ }
+
+ public void setChannel(String channel) {
+ _channel = channel;
+ }
+
+ /**
+ * @hibernate.property column="REASON"
+ */
+ public String getReason() {
+ return _reason;
+ }
+
+ public void setReason(String reason) {
+ _reason = reason;
+ }
+
+ /**
+ * @hibernate.property column="DATE_TIME"
+ */
+ public Date getDateTime() {
+ return _dateTime;
+ }
+
+ public void setDateTime(Date dateTime) {
+ _dateTime = dateTime;
+ }
+
+ /**
+ * @hibernate.property type="org.apache.ode.dao.hib.bpel.hobj.GZipDataType"
+ *
+ * @hibernate.column name="DETAILS" sql-type="blob(2G)"
+ */
+ public byte[] getDetails() {
+ return _details;
+ }
+
+ public void setDetails(byte[] details) {
+ _details = details;
+ }
+
+ /**
+ * @hibernate.property column="ACTIONS"
+ */
+ public String getActions() {
+ return _actions;
+ }
+
+ public void setActions(String actions) {
+ _actions = actions;
+ }
+
+ /**
+ * @hibernate.property column="RETRIES"
+ */
+ public int getRetries() {
+ return _retries;
+ }
+
+ public void setRetries(int retries) {
+ _retries = retries;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HBpelEvent.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HBpelEvent.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HBpelEvent.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,138 @@
+
+/*
+ * 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.hib.bpel.hobj;
+
+import java.sql.Timestamp;
+
+
+/**
+ * Row representation of a BPEL event.
+ *
+ * @hibernate.class table="BPEL_EVENT"
+ * @hibernate.query name="SELECT_EVENT_IDS_BY_INSTANCES" query="select id from HBpelEvent as e where e.instance in (:instances)"
+ */
+public class HBpelEvent extends HObject {
+ public static final String SELECT_EVENT_IDS_BY_INSTANCES = "SELECT_EVENT_IDS_BY_INSTANCES";
+
+ private Timestamp _tstamp;
+ private String _type;
+ private String _detail;
+
+ private HProcess _process;
+ private HProcessInstance _instance;
+ private byte[] _data;
+
+ /** Scope identifier, possibly null. */
+ private Long _scopeId;
+
+ /**
+ * @hibernate.many-to-one column="IID" foreign-key="none"
+ */
+ public HProcessInstance getInstance() {
+ return _instance;
+ }
+
+ public void setInstance(HProcessInstance instance) {
+ _instance = instance;
+ }
+
+ /**
+ * @hibernate.many-to-one column="PID" foreign-key="none"
+ */
+ public HProcess getProcess() {
+ return _process;
+ }
+
+ public void setProcess(HProcess process) {
+ _process = process;
+ }
+
+ /**
+ * @hibernate.property
+ * column="TSTAMP"
+ */
+ public Timestamp getTstamp() {
+ return _tstamp;
+ }
+
+ public void setTstamp(Timestamp tstamp) {
+ _tstamp = tstamp;
+ }
+
+ /**
+ * @hibernate.property
+ * column="TYPE"
+ */
+ public String getType() {
+ return _type;
+ }
+
+ public void setType(String type) {
+ _type = type;
+ }
+
+ /**
+ * TODO Check 32000 is enough for details
+ */
+ /**
+ * @hibernate.property
+ * column="DETAIL"
+ * type="text"
+ * length="32000"
+ */
+ public String getDetail() {
+ return _detail;
+ }
+
+ public void setDetail(String detail) {
+ _detail = detail;
+ }
+
+
+ /**
+ * @hibernate.property type="org.apache.ode.dao.hib.bpel.hobj.GZipDataType"
+ *
+ * @hibernate.column name="DATA" sql-type="blob(2G)"
+ */
+ public byte[] getData() {
+ return _data;
+ }
+
+ public void setData(byte[] data) {
+ _data = data;
+ }
+
+ /**
+ * Get the scope identifier of the scope associated with this event.
+ * Note, that this is not implemented as a many-to-one relationship
+ * because when scopes are deleted from the database we do not want
+ * their events to suffer the same fate.
+ * @hibernate.property
+ * column="SID"
+ */
+ public Long getScopeId() {
+ return _scopeId;
+ }
+
+ public void setScopeId(Long scopeId) {
+ _scopeId = scopeId;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelationProperty.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelationProperty.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelationProperty.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,108 @@
+/*
+ * 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.hib.bpel.hobj;
+
+
+import javax.xml.namespace.QName;
+
+/**
+ * Hibernate table-mapped class representing one valued property in
+ * a correlation set.
+ * @hibernate.class table="BPEL_CORRELATION_PROP"
+ * @hibernate.query name="SELECT_CORPROP_IDS_BY_INSTANCES" query="select id from HCorrelationProperty as p where p.correlationSet in(select s from HCorrelationSet as s where s.instance in (:instances))"
+ */
+public class HCorrelationProperty extends HObject {
+ public final static String SELECT_CORPROP_IDS_BY_INSTANCES = "SELECT_CORPROP_IDS_BY_INSTANCES";
+
+ private String _name;
+ private String _namespace;
+ private String _value;
+ private HCorrelationSet _correlationSet;
+
+ public HCorrelationProperty() {
+ super();
+ }
+
+ public HCorrelationProperty(String name, String namespace, String value, HCorrelationSet correlationSet) {
+ super();
+ _name = name;
+ _namespace = namespace;
+ _value = value;
+ _correlationSet = correlationSet;
+ _correlationSet.getProperties().add(this);
+ }
+
+ public HCorrelationProperty(QName qname, String value, HCorrelationSet correlationSet) {
+ super();
+ _name = qname.getLocalPart();
+ _namespace = qname.getNamespaceURI();
+ _value = value;
+ _correlationSet = correlationSet;
+ _correlationSet.getProperties().add(this);
+ }
+
+ /**
+ * @hibernate.property column="NAME"
+ */
+ public String getName() {
+ return _name;
+ }
+
+ public void setName(String name) {
+ _name = name;
+ }
+
+ /**
+ * @hibernate.property column="NAMESPACE"
+ */
+ public String getNamespace() {
+ return _namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ _namespace = namespace;
+ }
+
+ /**
+ * @hibernate.property column="VALUE"
+ */
+ public String getValue() {
+ return _value;
+ }
+
+ public void setValue(String value) {
+ _value = value;
+ }
+
+ /**
+ * @hibernate.many-to-one column="CORR_SET_ID" foreign-key="none"
+ */
+ public HCorrelationSet getCorrelationSet() {
+ return _correlationSet;
+ }
+
+ public void setCorrelationSet(HCorrelationSet correlationSet) {
+ _correlationSet = correlationSet;
+ }
+
+ public QName getQName() {
+ return new QName(getNamespace(), getName());
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelationSet.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelationSet.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelationSet.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,134 @@
+/*
+ * 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.hib.bpel.hobj;
+
+
+import java.util.HashSet;
+import java.util.Collection;
+
+/**
+ * Hibernate table representing correlation set values.
+ * @hibernate.class table="BPEL_CORRELATION_SET"
+ * @hibernate.query name="SELECT_CORSET_IDS_BY_INSTANCES" query="select id from HCorrelationSet as c where c.instance in (:instances)"
+ * @hibernate.query name="SELECT_CORSETS_BY_INSTANCES" query="from HCorrelationSet as c left join fetch c.properties where c.instance.id in (:instances)"
+ * @hibernate.query name="SELECT_CORSETS_BY_PROCESS_STATES" query="from HCorrelationSet as c left join fetch c.process left join fetch c.instance where c.instance.state in (:states)"
+ */
+public class HCorrelationSet extends HObject{
+ public static final String SELECT_CORSET_IDS_BY_INSTANCES = "SELECT_CORSET_IDS_BY_INSTANCES";
+ public static final String SELECT_CORSETS_BY_INSTANCES = "SELECT_CORSETS_BY_INSTANCES";
+ public static final String SELECT_CORSETS_BY_PROCESS_STATES = "SELECT_CORSETS_BY_PROCESS_STATES";
+
+ private HProcess _process;
+ private HProcessInstance _instance;
+ private Collection<HCorrelationProperty> _properties = new HashSet<HCorrelationProperty>();
+ private HScope _scope;
+ private String _name;
+ private String _value;
+
+ public HCorrelationSet() {
+ super();
+ }
+
+ public HCorrelationSet(HScope scope, String name) {
+ super();
+ _scope = scope;
+ _instance = scope.getInstance();
+ _process = _instance.getProcess();
+ _name = name;
+ }
+
+ /**
+ * @hibernate.property
+ * column="VALUE"
+ */
+ public String getValue() {
+ return _value;
+ }
+
+ public void setName(String name) {
+ _name = name;
+ }
+
+ public void setScope(HScope scope) {
+ _scope = scope;
+ }
+
+ public void setValue(String value) {
+ _value = value;
+ }
+
+ /**
+ * @hibernate.property
+ * column="CORR_SET_NAME"
+ * length="255"
+ */
+ public String getName() {
+ return _name;
+ }
+
+ /**
+ * @hibernate.many-to-one
+ * column="SCOPE_ID" foreign-key="none"
+ */
+ public HScope getScope() {
+ return _scope;
+ }
+
+ /**
+ * @hibernate.many-to-one
+ * column="PIID" foreign-key="none"
+ */
+ public HProcessInstance getInstance() {
+ return _instance;
+ }
+
+ public void setInstance(HProcessInstance instance) {
+ _instance = instance;
+ }
+
+ /**
+ * @hibernate.many-to-one
+ * column="PROCESS_ID" foreign-key="none"
+ */
+ public HProcess getProcess() {
+ return _process;
+ }
+
+ public void setProcess(HProcess process) {
+ _process = process;
+ }
+
+ /**
+ * @hibernate.set
+ * lazy="true"
+ * inverse="true"
+ * cascade="delete"
+ * @hibernate.collection-key
+ * column="CORR_SET_ID" foreign-key="none"
+ * @hibernate.collection-one-to-many
+ * class="org.apache.ode.dao.hib.bpel.hobj.HCorrelationProperty"
+ */
+ public Collection<HCorrelationProperty> getProperties() {
+ return _properties;
+ }
+
+ public void setProperties(Collection<HCorrelationProperty> properties) {
+ _properties = properties;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelator.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelator.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelator.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,117 @@
+/*
+ * 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.hib.bpel.hobj;
+
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Hibernate table representing a BPEL correlator, or message-router. This class
+ * maintains a set of <em>selectors</em> and <em>messages</em>. The
+ * selector set is a database representation of the pick/receive activities that
+ * need to be matched up to a message, while the message set is the database
+ * representation of the messages that have been received that need to be
+ * matched up to a pcik/receive.
+ *
+ * @hibernate.class table="BPEL_CORRELATOR"
+ * @hibernate.query name="SELECT_CORRELATOR_IDS_BY_PROCESS" query="select id from HCorrelator as c where c.process = :process"
+ */
+public class HCorrelator extends HObject {
+ public final static String SELECT_CORRELATOR_IDS_BY_PROCESS = "SELECT_CORRELATOR_IDS_BY_PROCESS";
+
+ private HProcess _process;
+
+ private String _correlatorId;
+
+ /** Receives/picks waiting for message. */
+ private Set<HCorrelatorSelector> _selectors = new HashSet<HCorrelatorSelector>();
+
+ /** Messages waiting for picks/receives. */
+ private Set<HCorrelatorMessage> _messages = new HashSet<HCorrelatorMessage>();
+
+ /** Constructor. */
+ public HCorrelator() {
+ super();
+ }
+
+ /**
+ * Get the set of {@link HCorrelatorMessage} objects representing the
+ * messages that need matching to a selector (i.e. pick/receive).
+ *
+ * @hibernate.set lazy="true" inverse="true"
+ * @hibernate.collection-key column="CORRELATOR" foreign-key="none"
+ * @hibernate.collection-one-to-many class="org.apache.ode.dao.hib.bpel.hobj.HCorrelatorMessage"
+ */
+ public Set<HCorrelatorMessage> getMessageCorrelations() {
+ return _messages;
+ }
+
+ /** Hibernate-mandated setter. */
+ public void setMessageCorrelations(Set<HCorrelatorMessage> messages) {
+ _messages = messages;
+ }
+
+ /**
+ * @hibernate.property
+ * @hibernate.column name="CID" index="IDX_CORRELATOR_CID"
+ */
+ public String getCorrelatorId() {
+ return _correlatorId;
+ }
+
+ /** Hibernate-mandated setter. */
+ public void setCorrelatorId(String correlatorId) {
+ _correlatorId = correlatorId;
+ }
+
+ /**
+ * @hibernate.many-to-one column="PROCESS_ID" foreign-key="none"
+ */
+ public HProcess getProcess() {
+ return _process;
+ }
+
+ /** Hibernate-mandated setter. */
+ public void setProcess(HProcess process) {
+ _process = process;
+ }
+
+ /**
+ * Get the set of {@link HCorrelatorSelector} objects representing the
+ * selectors (i.e. pick/receive) that need matching to an input message.
+ *
+ * @hibernate.set lazy="true" inverse="true"
+ * @hibernate.collection-key column="CORRELATOR" foreign-key="none"
+ * @hibernate.collection-one-to-many class="org.apache.ode.dao.hib.bpel.hobj.HCorrelatorSelector"
+ */
+ public Set<HCorrelatorSelector> getSelectors() {
+ return _selectors;
+ }
+
+ /** Hibernate-mandated setter. */
+ public void setSelectors(Set<HCorrelatorSelector> selectors) {
+ _selectors = selectors;
+ }
+
+ @Override
+ public String toString() {
+ return "{HCorrelator process=" + _process.getProcessId() + ", cid=" + _correlatorId + "}";
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelatorMessage.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelatorMessage.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelatorMessage.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,77 @@
+/*
+ * 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.hib.bpel.hobj;
+
+
+/**
+ * @hibernate.class table="BPEL_UNMATCHED" lazy="true"
+ * @hibernate.query name="SELECT_CORMESSAGE_IDS_BY_INSTANCES" query="select id from HCorrelatorMessage as m where m.messageExchange in(select mex from HMessageExchange as mex where mex.instance in (:instances))"
+ * @hibernate.query name="SELECT_CORMESSAGE_IDS_BY_MEX" query="select id from HCorrelatorMessage as m where m.messageExchange = :mex"
+ */
+public class HCorrelatorMessage extends HObject {
+ public final static String SELECT_CORMESSAGE_IDS_BY_MEX = "SELECT_CORMESSAGE_IDS_BY_MEX";
+ public final static String SELECT_CORMESSAGE_IDS_BY_INSTANCES = "SELECT_CORMESSAGE_IDS_BY_INSTANCES";
+
+ private HMessageExchange _messageExchange;
+ private HCorrelator _correlator;
+ private String _correlationKey;
+
+ /**
+ * @hibernate.many-to-one column="MEX" foreign-key="none"
+ */
+ public HMessageExchange getMessageExchange() {
+ return _messageExchange;
+ }
+
+ public void setMessageExchange(HMessageExchange data) {
+ _messageExchange = data;
+ }
+
+ @Override
+ public String toString() {
+ return "{HCorrelatorMessage correlator=" + this.getCorrelator() + ", ckey=" + getCorrelationKey() + ", mex="
+ + _messageExchange.getId() + "}";
+ }
+
+ /**
+ * @hibernate.property column="CORRELATION_KEY"
+ * @hibernate.column name="CORRELATION_KEY"
+ * index="IDX_UNMATCHED_CKEY"
+ *
+ */
+ public String getCorrelationKey() {
+ return _correlationKey;
+ }
+
+ public void setCorrelationKey(String correlationKey) {
+ _correlationKey = correlationKey;
+ }
+
+ /**
+ * @hibernate.many-to-one foreign-key="none"
+ * @hibernate.column name="CORRELATOR" index="IDX_UNMATCHED_CORRELATOR" not-null="true"
+ */
+ public HCorrelator getCorrelator() {
+ return _correlator;
+ }
+
+ public void setCorrelator(HCorrelator correlator) {
+ _correlator = correlator;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelatorMessageKey.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelatorMessageKey.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelatorMessageKey.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,71 @@
+/*
+ * 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.hib.bpel.hobj;
+
+
+/**
+ * Hibernate table for representing the pre-computed keys for a message
+ * targetted at the BPEL process with no matching instance at the time of
+ * receipt (and createInstance is not possible).
+ *
+ * @hibernate.class table="BPEL_CORRELATOR_MESSAGE_CKEY"
+ */
+public class HCorrelatorMessageKey extends HObject {
+ /** Correlation Key canonical string representation. */
+ private String _keyCanonical;
+
+ private HCorrelatorMessage _owner;
+
+ /** Constructor. */
+ public HCorrelatorMessageKey() {
+ super();
+ }
+
+ /**
+ * Canonical string representation of the correlation key.
+ *
+ * @hibernate.property
+ * column="CKEY"
+ * not-null="true"
+ * @hibernate.column
+ * name="CKEY"
+ * index="IDX_BPEL_CORRELATOR_MESSAGE_CKEY"
+ */
+ public String getCanonical() {
+ return _keyCanonical;
+ }
+
+ /** @see #getCanonical() */
+ public void setCanonical(String canonical) {
+ _keyCanonical = canonical;
+ }
+
+ /**
+ * The message with which this correlation key value is associated.
+ * @hibernate.many-to-one
+ * column="CORRELATOR_MESSAGE_ID" foreign-key="none"
+ */
+ public HCorrelatorMessage getOwner() {
+ return _owner;
+ }
+
+ public void setOwner(HCorrelatorMessage owner) {
+ _owner = owner;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelatorSelector.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelatorSelector.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelatorSelector.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,145 @@
+/*
+ * 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.hib.bpel.hobj;
+
+
+/**
+ * @hibernate.class table="BPEL_SELECTORS" lazy="true"
+ * @hibernate.query name="SELECT_MESSAGE_ROUTE_IDS_BY_PROCESS" query="select id from HCorrelatorSelector as m where m.correlator in(select c from HCorrelator c where c.process = :process)"
+ * @hibernate.query name="SELECT_MESSAGE_ROUTE_IDS_BY_INSTANCES" query="select id from HCorrelatorSelector as m where m.instance in (:instances)"
+ * @hibernate.query name="SELECT_MESSAGE_ROUTE" query="select m.id from HCorrelatorSelector as m where m.correlator = :corr and m.correlationKey = :ckey"
+ */
+public class HCorrelatorSelector extends HObject {
+ public static final String SELECT_MESSAGE_ROUTE_IDS_BY_PROCESS = "SELECT_MESSAGE_ROUTE_IDS_BY_PROCESS";
+ public static final String SELECT_MESSAGE_ROUTE_IDS_BY_INSTANCES = "SELECT_MESSAGE_ROUTE_IDS_BY_INSTANCES";
+ public static final String SELECT_MESSAGE_ROUTE = "SELECT_MESSAGE_ROUTE";
+
+ private HProcessInstance _instance;
+ private String _groupId;
+ private int _idx;
+ private HCorrelator _correlator;
+ private String _correlatorId;
+ private String _correlationKey;
+ private String _processType;
+ private String _routePolicy;
+
+ /**
+ * @hibernate.many-to-one column="PIID" not-null="true" foreign-key="none"
+ */
+ public HProcessInstance getInstance() {
+ return _instance;
+ }
+
+ public void setInstance(HProcessInstance instance) {
+ _instance = instance;
+ }
+
+ /**
+ * @hibernate.property column="SELGRPID"
+ * @hibernate.column name="SELGRPID" index="IDX_SELECTOR_SELGRPID" not-null="true"
+ */
+ public String getGroupId() {
+ return _groupId;
+ }
+
+ public void setGroupId(String groupId) {
+ _groupId = groupId;
+ }
+
+ /**
+ * @hibernate.property column="IDX" not-null="true" not-null="true"
+ */
+ public int getIndex() {
+ return _idx;
+ }
+
+ public void setIndex(int idx) {
+ _idx = idx;
+ }
+
+
+ @Override
+ public String toString() {
+ return "{HCorrelatorSelector correlator=" + this.getCorrelator() + ", ckey=" + getCorrelationKey() +
+ ", groupId=" + getGroupId() + ", idx=" + getIndex() + ", iid=" + getInstance().getId() + "}";
+ }
+
+ /**
+ * @hibernate.property column="CORRELATION_KEY" not-null="true"
+ * @hibernate.column name="CORRELATION_KEY"
+ * index="IDX_SELECTOR_CKEY"
+ * not-null="true"
+ * unique-key="UNIQ_SELECTOR"
+ *
+ */
+ public String getCorrelationKey() {
+ return _correlationKey;
+ }
+
+ public void setCorrelationKey(String correlationKey) {
+ _correlationKey = correlationKey;
+ }
+
+ /**
+ * @hibernate.property column="PROC_TYPE" not-null="true"
+ */
+ public String getProcessType() {
+ return _processType;
+ }
+
+ public void setProcessType(String _processType) {
+ this._processType = _processType;
+ }
+
+ /**
+ * @hibernate.property column="ROUTE_POLICY" not-null="false"
+ */
+ public String getRoute() {
+ return _routePolicy;
+ }
+
+ public void setRoute(String _routePolicy) {
+ this._routePolicy = _routePolicy;
+ }
+
+ /**
+ * @hibernate.many-to-one not-null="true" foreign-key="none"
+ * @hibernate.column name="CORRELATOR" not-null="true"
+ * index="IDX_SELECTOR_CORRELATOR" unique-key="UNIQ_SELECTOR"
+ */
+ public HCorrelator getCorrelator() {
+ return _correlator;
+ }
+
+ public void setCorrelator(HCorrelator correlator) {
+ _correlator = correlator;
+ }
+
+ /**
+ * @hibernate.property column="CORRELATOR" not-null="true" insert="false" update="false"
+ */
+ public String getCorrelatorId() {
+ return _correlatorId;
+ }
+
+ public void setCorrelatorId(String correlatorId) {
+ this._correlatorId = correlatorId;
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HFaultData.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HFaultData.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HFaultData.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,96 @@
+/*
+ * 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.hib.bpel.hobj;
+
+
+/**
+ * Persistent representation of a fault.
+ * @hibernate.class table="BPEL_FAULT"
+ * @hibernate.query name="SELECT_FAULT_IDS_BY_INSTANCES" query="select id from HFaultData as f where f in (select i.fault from HProcessInstance as i where i in (:instances))"
+ */
+public class HFaultData extends HObject {
+ public final static String SELECT_FAULT_IDS_BY_INSTANCES = "SELECT_FAULT_IDS_BY_INSTANCES";
+
+ private String _name;
+ private String _explanation;
+ private byte[] _data;
+ private int _lineNo;
+ private int _activityId;
+
+ /**
+ * @hibernate.property column="FAULTNAME"
+ */
+ public String getName() {
+ return _name;
+ }
+
+ public void setName(String name) {
+ _name = name;
+ }
+
+ /**
+ * @hibernate.property type="org.apache.ode.dao.hib.bpel.hobj.GZipDataType"
+ *
+ * @hibernate.column name="DATA" sql-type="blob(2G)"
+ */
+ public byte[] getData() {
+ return _data;
+ }
+
+ public void setData(byte[] data) {
+ _data = data;
+ }
+
+ /**
+ * @hibernate.property column="EXPLANATION" length="4000"
+ */
+ public String getExplanation() {
+ return _explanation;
+ }
+
+ public void setExplanation(String explanation) {
+ // Don't want to make this a blob, truncating to avoid errors
+ if (explanation != null && explanation.length() > 4000)
+ explanation = explanation.substring(0, 3999);
+ _explanation = explanation;
+ }
+
+ /**
+ * @hibernate.property column="LINE_NUM"
+ */
+ public int getLineNo() {
+ return _lineNo;
+ }
+
+ public void setLineNo(int lineNo) {
+ _lineNo = lineNo;
+ }
+
+ /**
+ * @hibernate.property column="AID"
+ */
+ public int getActivityId() {
+ return _activityId;
+ }
+
+ public void setActivityId(int activityId) {
+ _activityId = activityId;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HLargeData.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HLargeData.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HLargeData.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1 @@
+package org.apache.ode.dao.hib.bpel.hobj;
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HMessage.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HMessage.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HMessage.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,83 @@
+/*
+ * 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.hib.bpel.hobj;
+
+/**
+ * Hibernate-managed table for keeping track of messages.
+ *
+ * @hibernate.class table="BPEL_MESSAGE"
+ * @hibernate.query name="SELECT_MESSAGE_IDS_BY_MEX" query="select id from HMessage as m WHERE m.messageExchange = :messageExchange"
+ * @hibernate.query name="SELECT_MESSAGE_IDS_BY_INSTANCES" query="select m.id from HMessage m, HMessageExchange mex WHERE m.messageExchange = mex and mex.instance in (:instances)"
+ * @hibernate.query name="SELECT_MESSAGES_BY_INSTANCES" query="select m from HMessage m, HMessageExchange mex WHERE m.messageExchange = :mex"
+ */
+public class HMessage extends HObject {
+ public final static String SELECT_MESSAGE_IDS_BY_MEX = "SELECT_MESSAGE_IDS_BY_MEX";
+ public final static String SELECT_MESSAGE_IDS_BY_INSTANCES = "SELECT_MESSAGE_IDS_BY_INSTANCES";
+ public final static String SELECT_MESSAGES_BY_INSTANCES = "SELECT_MESSAGES_BY_INSTANCES";
+
+ private HMessageExchange _mex;
+ private String _type;
+ private byte[] _data;
+ private byte[] _header;
+
+ public void setMessageExchange(HMessageExchange mex) {
+ _mex = mex;
+ }
+
+ /** @hibernate.many-to-one column="MEX" foreign-key="none"*/
+ public HMessageExchange getMessageExchange() {
+ return _mex;
+ }
+
+ public void setType(String type) {
+ _type = type;
+ }
+
+ /** @hibernate.property column="TYPE" */
+ public String getType() {
+ return _type;
+ }
+
+ /**
+ * @hibernate.property type="org.apache.ode.dao.hib.bpel.hobj.GZipDataType"
+ *
+ * @hibernate.column name="MESSAGE_DATA" sql-type="blob(2G)"
+ */
+ public byte[] getMessageData() {
+ return _data;
+ }
+
+ public void setMessageData(byte[] data) {
+ _data = data;
+ }
+
+ /**
+ * @hibernate.property type="org.apache.ode.dao.hib.bpel.hobj.GZipDataType"
+ *
+ * @hibernate.column name="MESSAGE_HEADER" sql-type="blob(2G)"
+ */
+ public byte[] getHeader() {
+ return _header;
+ }
+
+ public void setHeader(byte[] header) {
+ _header = header;
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HMessageExchange.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HMessageExchange.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HMessageExchange.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,362 @@
+/*
+ * 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.hib.bpel.hobj;
+
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Hibernate-managed table for keeping track of message exchanges.
+ *
+ * @hibernate.class table="BPEL_MESSAGE_EXCHANGE" dynamic-update="true"
+ * @hibernate.query name="SELECT_MEX_IDS_BY_INSTANCES" query="select id from HMessageExchange as m where m.instance in (:instances)"
+ * @hibernate.query name="SELECT_UNMATCHED_MEX_BY_INSTANCES" query="from HMessageExchange as m where m in(select cm.messageExchange from HCorrelatorMessage as cm where cm.messageExchange.instance in (:instances))"
+ */
+public class HMessageExchange extends HObject {
+ public final static String SELECT_MEX_IDS_BY_INSTANCES = "SELECT_MEX_IDS_BY_INSTANCES";
+ public final static String SELECT_UNMATCHED_MEX_BY_INSTANCES = "SELECT_UNMATCHED_MEX_BY_INSTANCES";
+
+ private String _channelName;
+
+ private String _operationName;
+
+ private String _state;
+
+ private Date _insertTime;
+
+ private String _portType;
+
+ private byte[] _endpoint;
+
+ private byte[] _callbackEndpoint;
+
+ private HMessage _request;
+
+ private HMessage _response;
+
+ private HPartnerLink _partnerLink;
+
+ private String _clientKey;
+
+ private HProcessInstance _instance;
+
+ private HProcess _process;
+
+ private char _dir;
+
+ private int _plinkModelId;
+
+ private String _pattern;
+
+ private String _corrstatus;
+
+ private String _faultType;
+
+ private String _faultExplanation;
+
+ private String _callee;
+
+ private String _pipedMessageExchangeId;
+
+ private int _subscriberCount;
+
+ private Map<String, String> _properties = new HashMap<String, String>();
+
+ /**
+ *
+ */
+ public HMessageExchange() {
+ super();
+ }
+
+ /**
+ * @hibernate.property column="PORT_TYPE"
+ */
+ public String getPortType() {
+ return _portType;
+ }
+
+ public void setPortType(String portType) {
+ _portType = portType;
+ }
+
+ /**
+ * @hibernate.property column="CHANNEL_NAME"
+ */
+ public String getChannelName() {
+ return _channelName;
+ }
+
+ public void setChannelName(String channelName) {
+ _channelName = channelName;
+ }
+
+ /**
+ * @hibernate.property column="CLIENTKEY"
+ */
+ public String getClientKey() {
+ return _clientKey;
+ }
+
+ public void setClientKey(String clientKey) {
+ _clientKey = clientKey;
+ }
+
+ /**
+ * @hibernate.property type="org.apache.ode.dao.hib.bpel.hobj.GZipDataType"
+ *
+ * @hibernate.column name="ENDPOINT" sql-type="blob(2G)"
+ */
+ public byte[] getEndpoint() {
+ return _endpoint;
+ }
+
+ public void setEndpoint(byte[] endpoint) {
+ _endpoint = endpoint;
+ }
+
+ /**
+ * @hibernate.property type="org.apache.ode.dao.hib.bpel.hobj.GZipDataType"
+ *
+ * @hibernate.column name="CALLBACK_ENDPOINT" sql-type="blob(2G)"
+ */
+ public byte[] getCallbackEndpoint() {
+ return _callbackEndpoint;
+ }
+
+ public void setCallbackEndpoint(byte[] endpoint) {
+ _callbackEndpoint = endpoint;
+ }
+
+ /**
+ * @hibernate.many-to-one column="REQUEST" cascade="delete" foreign-key="none"
+ */
+ public HMessage getRequest() {
+ return _request;
+ }
+
+ public void setRequest(HMessage request) {
+ _request = request;
+ }
+
+ /**
+ * @hibernate.many-to-one column="RESPONSE" cascade="delete" foreign-key="none"
+ */
+ public HMessage getResponse() {
+ return _response;
+ }
+
+ public void setResponse(HMessage response) {
+ _response = response;
+ }
+
+ /**
+ * @hibernate.property column="INSERT_DT"
+ */
+ public Date getInsertTime() {
+ return _insertTime;
+ }
+
+ public void setInsertTime(Date insertTime) {
+ _insertTime = insertTime;
+ }
+
+ /**
+ * @hibernate.property column="OPERATION"
+ */
+ public String getOperationName() {
+ return _operationName;
+ }
+
+ public void setOperationName(String operationName) {
+ _operationName = operationName;
+ }
+
+ /**
+ * @hibernate.property column="STATE"
+ */
+ public String getState() {
+ return _state;
+ }
+
+ public void setState(String state) {
+ _state = state;
+ }
+
+ /**
+ * @hibernate.many-to-one column="PROCESS" foreign-key="none"
+ */
+ public HProcess getProcess() {
+ return _process;
+ }
+
+ public void setProcess(HProcess process) {
+ _process = process;
+ }
+
+ /**
+ * @hibernate.many-to-one column="PIID" foreign-key="none"
+ */
+ public HProcessInstance getInstance() {
+ return _instance;
+ }
+
+ public void setInstance(HProcessInstance instance) {
+ _instance = instance;
+ }
+
+ public void setDirection(char dir) {
+ _dir = dir;
+ }
+
+ /**
+ * @hibernate.property column="DIR"
+ */
+ public char getDirection() {
+ return _dir;
+ }
+
+ /**
+ * @hibernate.property column="PLINK_MODELID"
+ */
+ public int getPartnerLinkModelId() {
+ return _plinkModelId;
+ }
+
+ public void setPartnerLinkModelId(int id) {
+ _plinkModelId = id;
+ }
+
+ /**
+ * @hibernate.property column="PATTERN"
+ */
+ public String getPattern() {
+ return _pattern;
+ }
+
+ public void setPattern(String pattern) {
+ _pattern = pattern;
+
+ }
+
+ /**
+ * @hibernate.property column="CORR_STATUS"
+ * @return
+ */
+ public String getCorrelationStatus() {
+ return _corrstatus;
+ }
+
+ public void setCorrelationStatus(String cstatus) {
+ _corrstatus = cstatus;
+
+ }
+
+ /**
+ * @hibernate.property column="FAULT_TYPE"
+ * @return
+ */
+ public String getFault() {
+ return _faultType;
+ }
+
+ public void setFault(String faultType) {
+ _faultType = faultType;
+
+ }
+
+ /**
+ * @hibernate.property column="FAULT_EXPL"
+ * @return
+ */
+ public String getFaultExplanation() {
+ return _faultExplanation;
+ }
+
+ public void setFaultExplanation(String faultExplanation) {
+ if (faultExplanation != null && faultExplanation.length() > 255)
+ faultExplanation = faultExplanation.substring(0, 254);
+ _faultExplanation = faultExplanation;
+ }
+
+ /**
+ * @hibernate.property column="CALLEE"
+ */
+ public String getCallee() {
+ return _callee;
+ }
+
+ public void setCallee(String callee) {
+ _callee = callee;
+ }
+
+ /**
+ * @hibernate.map name="properties" table="BPEL_MEX_PROPS" lazy="true" cascade="delete"
+ * @hibernate.collection-key name="mex" column="MEX" foreign-key="none"
+ * @hibernate.collection-index column="NAME" type="string"
+ * @hibernate.collection-element column="VALUE" type="string" length="8000"
+ */
+ public Map<String, String> getProperties() {
+ return _properties;
+ }
+
+ public void setProperties(Map<String, String> props) {
+ _properties = props;
+ }
+
+ public void setPartnerLink(HPartnerLink link) {
+ _partnerLink = link;
+ }
+
+ /**
+ * @hibernate.many-to-one column="PARTNERLINK" foreign-key="none"
+ */
+ public HPartnerLink getPartnerLink() {
+ return _partnerLink;
+ }
+
+ /**
+ * @hibernate.property column="PIPED_ID"
+ */
+ public String getPipedMessageExchangeId() {
+ return _pipedMessageExchangeId;
+ }
+
+ public void setPipedMessageExchangeId(String pipedMessageExchangeId) {
+ _pipedMessageExchangeId = pipedMessageExchangeId;
+ }
+
+ /**
+ * @hibernate.property column="SUBSCRIBER_COUNT"
+ */
+ public int getSubscriberCount() {
+ return _subscriberCount;
+ }
+
+ public void setSubscriberCount(int subscriberCount) {
+ this._subscriberCount = subscriberCount;
+ }
+
+ public void incrementSubscriberCount() {
+ setSubscriberCount(getSubscriberCount() + 1);
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HMessageExchangeProperty.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HMessageExchangeProperty.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HMessageExchangeProperty.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,96 @@
+/*
+ * 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.hib.bpel.hobj;
+
+import java.io.Serializable;
+
+/**
+ * This hibernate entity enables using the BPEL_MEX_PROPS table in HQL. This entity
+ * is excluded from schema export.
+ *
+ * @hibernate.class table="BPEL_MEX_PROPS" lazy="true"
+ * @hibernate.query name="SELECT_MEX_PROPS_IDS_BY_INSTANCES" query="select p.id from HMessageExchangeProperty p, HMessageExchange e where p.mex = e and e.instance in (:instances)"
+ */
+@SuppressWarnings("serial")
+public class HMessageExchangeProperty implements Serializable {
+ public final static String SELECT_MEX_PROPS_IDS_BY_INSTANCES = "SELECT_MEX_PROPS_IDS_BY_INSTANCES";
+
+ private HMessageExchange _mex;
+ private String _name;
+ private String _value;
+
+ public HMessageExchangeProperty() {
+ }
+
+ /**
+ * @hibernate.id
+ * @return
+ */
+ public HMessageExchangeProperty getKey() {
+ return null;
+ }
+
+ public void setKey(HMessageExchangeProperty property) {
+ }
+
+ /**
+ * @hibernate.many-to-one column="MEX" insert="false" update="false"
+ */
+ public HMessageExchange getMex() {
+ return _mex;
+ }
+
+ public void setMex(HMessageExchange mex) {
+ _mex = mex;
+ }
+
+ /**
+ * @hibernate.property column="NAME" type="string" length="8000" insert="false" update="false"
+ */
+ public String getName() {
+ return _name;
+ }
+
+ public void setName(String name) {
+ _name = name;
+ }
+
+ /**
+ * @hibernate.property column="VALUE" type="string" insert="false" update="false"
+ */
+ public String getValue() {
+ return _value;
+ }
+
+ public void setValue(String value) {
+ _value = value;
+ }
+
+ public boolean equals(Object another) {
+ // fake implementation to suppress hibernate warning on key not hash-searchable;
+ // actually HMessageExchangePropery is never retrieved by the id
+ return super.equals(another);
+ }
+
+ public int hashCode() {
+ // fake implementation to suppress hibernate warning on key not hash-searchable
+ // actually HMessageExchangePropery is never retrieved by the id
+ return _mex.hashCode() * 29 + _name.hashCode() * 13;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HObject.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HObject.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HObject.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,105 @@
+/*
+ * 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.hib.bpel.hobj;
+
+import java.util.Collection;
+import java.util.Date;
+
+/**
+ * Base class for Hibernate objects providing auto-generated key, create
+ * timestamp and lock fields.
+ */
+public class HObject {
+ private Long _id;
+
+ private Date _created;
+
+ private int _lock;
+
+ /** Constructor. */
+ public HObject() {
+ super();
+ setLock(0);
+ }
+
+ /**
+ * Auto-gnerated creation timestamp.
+ *
+ * @hibernate.property column="INSERT_TIME" type="timestamp"
+ */
+ public Date getCreated() {
+ return _created;
+ }
+
+ public void setCreated(Date created) {
+ _created = created;
+ }
+
+ /**
+ * Auto-generated primary key.
+ *
+ * @hibernate.id generator-class="org.apache.ode.dao.hib.NativeHiLoGenerator" column="ID"
+ * @hibernate.generator-param name="sequence" value="hibernate_seqhilo"
+ * @hibernate.generator-param name="max_lo" value="99"
+ */
+ public Long getId() {
+ return _id;
+ }
+
+ public void setId(Long id) {
+ _id = id;
+ }
+
+ /**
+ * @hibernate.property column="MLOCK" not-null="true"
+ */
+ public int getLock() {
+ return _lock;
+ }
+
+ public void setLock(int lock) {
+ _lock = lock;
+ }
+
+ public static <T extends HObject> Object[] toIdArray(T[] objects) {
+ Object[] ids = new Object[objects.length];
+
+ int index = 0;
+ for( HObject object : objects ) {
+ ids[index++] = object.getId();
+ }
+
+ return ids;
+ }
+
+ public static Object[] toIdArray(Collection<? extends HObject> objects) {
+ Object[] ids = new Object[objects.size()];
+
+ int index = 0;
+ for( HObject object : objects ) {
+ ids[index++] = object.getId();
+ }
+
+ return ids;
+ }
+
+ public String toString() {
+ return this.getClass()+"{id="+_id+"}";
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HPartnerLink.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HPartnerLink.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HPartnerLink.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,206 @@
+/*
+ * 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.hib.bpel.hobj;
+
+import java.util.Set;
+
+/**
+ * The HEndpointReference can either be attached to a scope (when it's specific
+ * to a scope instance, for example because it has been assigned during the
+ * instance execution) or to a process definition (general endpoint
+ * configuration).
+ *
+ * @hibernate.class table="BPEL_PLINK_VAL"
+ * @hibernate.query name="SELECT_PARTNER_LINK_IDS_BY_INSTANCES" query="select l.id from HPartnerLink l, HScope s where l.scope = s and s.instance in (:instances)"
+ */
+public class HPartnerLink extends HObject {
+ public final static String SELECT_PARTNER_LINK_IDS_BY_INSTANCES = "SELECT_PARTNER_LINK_IDS_BY_INSTANCES";
+
+ private String _linkName;
+
+ private String _partnerRole;
+
+ private String _myrole;
+
+ private String _svcName;
+
+ private byte[] _myEPR;
+
+ private byte[] _partnerEPR;
+
+ private HScope _scope;
+
+ private HProcess _process;
+
+ private int _modelId;
+
+ private String _mySessionId;
+
+ private String _partnerSessionId;
+
+ private Set<HMessageExchange> _mex;
+
+ public HPartnerLink() {
+ super();
+ }
+
+ /**
+ * @hibernate.property column="PARTNER_LINK" length="100" not-null="true"
+ */
+ public String getLinkName() {
+ return _linkName;
+ }
+
+ public void setLinkName(String linkName) {
+ _linkName = linkName;
+ }
+
+ /**
+ * @hibernate.property column="PARTNERROLE" length="100"
+ */
+ public String getPartnerRole() {
+ return _partnerRole;
+ }
+
+ public void setPartnerRole(String partnerRoleName) {
+ _partnerRole = partnerRoleName;
+ }
+
+ /**
+ * @hibernate.property type="org.apache.ode.dao.hib.bpel.hobj.GZipDataType"
+ *
+ * @hibernate.column name="MYROLE_EPR_DATA" sql-type="blob(2G)"
+ */
+ public byte[] getMyEPR() {
+ return _myEPR;
+ }
+
+ public void setMyEPR(byte[] myEPR) {
+ _myEPR = myEPR;
+ }
+
+ /**
+ * @hibernate.property type="org.apache.ode.dao.hib.bpel.hobj.GZipDataType"
+ *
+ * @hibernate.column name="PARTNERROLE_EPR_DATA" sql-type="blob(2G)"
+ */
+ public byte[] getPartnerEPR() {
+ return _partnerEPR;
+ }
+
+ public void setPartnerEPR(byte[] partnerEPR) {
+ _partnerEPR = partnerEPR;
+ }
+
+ /**
+ * @hibernate.many-to-one column="PROCESS" foreign-key="none"
+ */
+ public HProcess getProcess() {
+ return _process;
+ }
+
+ public void setProcess(HProcess process) {
+ _process = process;
+ }
+
+ /**
+ * @hibernate.many-to-one column="SCOPE" foreign-key="none"
+ */
+ public HScope getScope() {
+ return _scope;
+ }
+
+ public void setScope(HScope scope) {
+ _scope = scope;
+ }
+
+ public void setServiceName(String svcName) {
+ _svcName = svcName;
+ }
+
+ /**
+ * @hibernate.property column="SVCNAME"
+ */
+ public String getServiceName() {
+ return _svcName;
+ }
+
+ /**
+ * @hibernate.property column="MYROLE" length="100"
+ * @return
+ */
+ public String getMyRole() {
+ return _myrole;
+ }
+
+ public void setMyRole(String myrole) {
+ _myrole = myrole;
+ }
+
+ /**
+ * @hibernate.property column="MODELID"
+ */
+ public int getModelId() {
+ return _modelId;
+ }
+
+ public void setModelId(int modelId) {
+ _modelId = modelId;
+ }
+
+ /**
+ * @hibernate.property column="MYSESSIONID"
+ */
+ public String getMySessionId() {
+ return _mySessionId;
+ }
+
+ /**
+ * @hibernate.property column="PARTNERSESSIONID"
+ */
+ public String getPartnerSessionId() {
+ return _partnerSessionId;
+ }
+
+ public void setPartnerSessionId(String session) {
+ _partnerSessionId = session;
+ }
+
+ public void setMySessionId(String sessionId) {
+ _mySessionId = sessionId;
+ }
+
+ /**
+ * @hibernate.set
+ * lazy="true"
+ * inverse="true"
+ * cascade="delete"
+ * @hibernate.collection-key column="PARTNERLINK" foreign-key="none"
+ * @hibernate.collection-one-to-many
+ * class="org.apache.ode.dao.hib.bpel.hobj.HMessageExchange"
+ */
+ public Set<HMessageExchange> getMessageExchanges() {
+ return _mex;
+ }
+
+ public void setMessageExchanges(Set<HMessageExchange> mex) {
+ _mex = mex;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HProcess.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HProcess.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HProcess.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,269 @@
+/*
+ * 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.hib.bpel.hobj;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Hibernate table representing a BPEL process (<em>not</em> a process instance).
+ * @hibernate.class table="BPEL_PROCESS" lazy="false"
+ *
+ */
+public class HProcess extends HObject{
+
+ /** {@link HCorrelator}s for this process. */
+ private Set<HCorrelator> _correlators = new HashSet<HCorrelator>();
+
+ /** Instances of this BPEL process. */
+ private Collection<HProcessInstance> _instances = new HashSet<HProcessInstance>();
+
+ /** Events belonging to this BPEL process. */
+ private Collection<HBpelEvent> _events = new HashSet<HBpelEvent>();
+
+ /** Partnerlinks defined on this process */
+ private Set<HPartnerLink> _plinks = new HashSet<HPartnerLink>();
+
+ /** Message exchanges associated with this process. */
+ private Set<HMessageExchange> _messageExchanges = new HashSet<HMessageExchange>();
+
+ /** 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 long _version;
+
+ /** Whether process is retired */
+ private boolean _retired;
+
+ private boolean _active;
+
+ private String _guid;
+
+ /**
+ * @hibernate.set
+ * lazy="true"
+ * inverse="true"
+ * @hibernate.collection-key
+ * column="PROCESS" foreign-key="none"
+ * @hibernate.collection-one-to-many
+ * class="org.apache.ode.dao.hib.bpel.hobj.HMessageExchange"
+ */
+ public Set<HMessageExchange> getMessageExchanges() {
+ return _messageExchanges;
+ }
+
+ public void setMessageExchanges(Set<HMessageExchange> exchanges) {
+ _messageExchanges = exchanges;
+ }
+
+ /**
+ * @hibernate.set
+ * lazy="true"
+ * inverse="true"
+ * cascade="delete"
+ * @hibernate.collection-key
+ * column="PROCESS_ID" foreign-key="none"
+ * @hibernate.collection-one-to-many
+ * class="org.apache.ode.dao.hib.bpel.hobj.HCorrelator"
+ */
+ public Set<HCorrelator> getCorrelators() {
+ return _correlators;
+ }
+
+ public void setCorrelators(Set<HCorrelator> correlators) {
+ _correlators = correlators;
+ }
+
+ /**
+ * @hibernate.bag
+ * lazy="true"
+ * inverse="true"
+ * @hibernate.collection-key
+ * column="PROCESS_ID" foreign-key="none"
+ * @hibernate.collection-one-to-many
+ * class="org.apache.ode.dao.hib.bpel.hobj.HProcessInstance"
+ */
+ public Collection<HProcessInstance> getInstances() {
+ return _instances;
+ }
+
+ public void setInstances(Collection<HProcessInstance> instances) {
+ _instances = instances;
+ }
+
+ /**
+ * @hibernate.bag
+ * lazy="true"
+ * inverse="true"
+ * @hibernate.collection-key
+ * column="PID" foreign-key="none"
+ * @hibernate.collection-one-to-many
+ * class="org.apache.ode.dao.hib.bpel.hobj.HBpelEvent"
+ */
+ public Collection<HBpelEvent> getEvents() {
+ return _events;
+ }
+
+ public void setEvents(Collection<HBpelEvent> events) {
+ _events = events;
+ }
+
+ /**
+ * Get the partner links values as deployed.
+ *
+ * @return {@link Set}<{@link HPartnerLink}> with variable values
+ * @hibernate.set lazy="true" inverse="true"
+ * @hibernate.collection-key column="PROCESS" foreign-key="none"
+ * @hibernate.collection-one-to-many class="org.apache.ode.dao.hib.bpel.hobj.HPartnerLink"
+ */
+ public Set<HPartnerLink> getDeploymentPartnerLinks() {
+ return _plinks;
+ }
+
+ /**
+ * Set the partner links as deployed.
+ * @param partnerlinks
+ */
+ public void setDeploymentPartnerLinks(Set<HPartnerLink> partnerlinks) {
+ _plinks = partnerlinks;
+ }
+
+
+ /**
+ *
+ * @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 long getVersion() {
+ return _version;
+ }
+
+ public void setVersion(long version) {
+ _version = version;
+ }
+
+ /**
+ * The process status.
+ * @hibernate.property
+ * column="ACTIVE_"
+ */
+ public boolean isActive() {
+ return _active;
+ }
+
+ public void setActive(boolean active) {
+ _active = active;
+ }
+
+ /**
+ * @hibernate.property
+ */
+ public String getGuid() {
+ return _guid;
+ }
+
+ public void setGuid(String guid) {
+ _guid = guid;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HProcessInstance.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HProcessInstance.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HProcessInstance.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,292 @@
+/*
+ * 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.hib.bpel.hobj;
+
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Hibernate table representing a BPEL process instance.
+ *
+ * @hibernate.class table="BPEL_INSTANCE" dynamic-update="true" lazy="true"
+ * @hibernate.query name="COUNT_FAILED_INSTANCES_BY_PROCESSES_IDS_AND_STATES" query="select i.process.processId as pid, count(i.id) as cnt, max(i.activityFailureDateTime) as lastFailureDt from HProcessInstance as i where i.process.processId in (:processIds) and i.state = 20 and i.activityFailureCount > 0 group by i.process.processId"
+ * @hibernate.query name="SELECT_INSTANCES_BY_PROCESS" query="from HProcessInstance as i where i.process = :process)"
+ * @hibernate.query name="SELECT_INSTANCES_BY_PROCESS_AND_STATES" query="from HProcessInstance as i where i.process = :process and i.state in (:states)"
+ * @hibernate.query name="COUNT_INSTANCES_BY_PROCESSES_IDS_AND_STATES" query="select i.process.processId as pid, count(i.id) as cnt from HProcessInstance as i where i.process.processId in (:processIds) and i.state in(:states) group by i.process.processId"
+ */
+public class HProcessInstance extends HObject {
+ public static final String COUNT_FAILED_INSTANCES_BY_PROCESSES_IDS_AND_STATES="COUNT_FAILED_INSTANCES_BY_PROCESSES_IDS_AND_STATES";
+ public static final String SELECT_INSTANCES_BY_PROCESS="SELECT_INSTANCES_BY_PROCESS";
+ public static final String SELECT_INSTANCES_BY_PROCESS_AND_STATES="SELECT_INSTANCES_BY_PROCESS_AND_STATES";
+ public static final String COUNT_INSTANCES_BY_PROCESSES_IDS_AND_STATES = "COUNT_INSTANCES_BY_PROCESSES_IDS_AND_STATES";
+
+ /** Foreign key to owner {@link HProcess}. */
+ private HProcess _process;
+
+ private Long _processId;
+
+ /** Foreign key to the instantiating {@link HCorrelator}. */
+ private HCorrelator _instantiatingCorrelator;
+
+ /** Scope instances belonging to this process instnace. */
+ private Collection<HScope> _scopes = new HashSet<HScope>();
+
+ private Collection<HCorrelationSet> _csets = new HashSet<HCorrelationSet>();
+
+ /** Events belonging to this instance. */
+ private Collection<HBpelEvent> _events = new HashSet<HBpelEvent>();
+
+ private Set<HCorrelatorSelector> _correlatorSelectors = new HashSet<HCorrelatorSelector>();
+
+ private Set<HMessageExchange> _messageExchanges = new HashSet<HMessageExchange>();
+
+ private HFaultData _fault;
+
+ private byte[] _jacobState;
+
+ private short _previousState;
+
+ private short _state;
+
+ private Date _lastActiveTime;
+
+ private Date _activityFailureDateTime;
+
+ private int _activityFailureCount;
+
+ private Collection<HActivityRecovery> _activityRecoveries = new HashSet<HActivityRecovery>();
+
+ private long _seq;
+
+ /**
+ *
+ */
+ public HProcessInstance() {
+ super();
+ }
+
+ /**
+ * @hibernate.many-to-one column="INSTANTIATING_CORRELATOR" foreign-key="none"
+ */
+ public HCorrelator getInstantiatingCorrelator() {
+ return _instantiatingCorrelator;
+ }
+
+ public void setInstantiatingCorrelator(HCorrelator instantiatingCorrelator) {
+ _instantiatingCorrelator = instantiatingCorrelator;
+ }
+
+ /**
+ * @hibernate.many-to-one column="FAULT" column="FAULT" foreign-key="none"
+ */
+ public HFaultData getFault() {
+ return _fault;
+ }
+
+ public void setFault(HFaultData fault) {
+ _fault = fault;
+ }
+
+ /**
+ * @hibernate.property type="org.apache.ode.dao.hib.bpel.hobj.GZipDataType"
+ *
+ * @hibernate.column name="JACOB_STATE_DATA" sql-type="blob(2G)"
+ */
+ public byte[] getJacobState() {
+ return _jacobState;
+ }
+
+ public void setJacobState(byte[] jacobState) {
+ _jacobState = jacobState;
+ }
+
+ /**
+ * @hibernate.bag lazy="true" inverse="true"
+ * @hibernate.collection-key column="IID" foreign-key="none"
+ * @hibernate.collection-one-to-many class="org.apache.ode.dao.hib.bpel.hobj.HBpelEvent"
+ */
+ public Collection<HBpelEvent> getEvents() {
+ return _events;
+ }
+
+ public void setEvents(Collection<HBpelEvent> events) {
+ _events = events;
+ }
+
+ /**
+ * @hibernate.set lazy="true" inverse="true"
+ * @hibernate.collection-key column="PIID" foreign-key="none"
+ * @hibernate.collection-one-to-many class="org.apache.ode.dao.hib.bpel.hobj.HCorrelatorSelector"
+ */
+ public Set<HCorrelatorSelector> getCorrelatorSelectors() {
+ return _correlatorSelectors;
+ }
+
+ /**
+ * @param selectors
+ * the _correlatorSelectors to set
+ */
+ public void setCorrelatorSelectors(Set<HCorrelatorSelector> selectors) {
+ _correlatorSelectors = selectors;
+ }
+
+ /**
+ * @hibernate.set lazy="true" inverse="true"
+ * @hibernate.collection-key column="PIID" foreign-key="none"
+ * @hibernate.collection-one-to-many class="org.apache.ode.dao.hib.bpel.hobj.HMessageExchange"
+ */
+ public Set<HMessageExchange> getMessageExchanges() {
+ return _messageExchanges;
+ }
+
+ public void setMessageExchanges(Set<HMessageExchange> exchanges) {
+ _messageExchanges = exchanges;
+ }
+
+ /**
+ * @hibernate.property column="PREVIOUS_STATE"
+ */
+ public short getPreviousState() {
+ return _previousState;
+ }
+
+ public void setPreviousState(short previousState) {
+ _previousState = previousState;
+ }
+
+ /**
+ *
+ * @hibernate.many-to-one column="PROCESS_ID" lazy="true" outer-join="true" not-found="ignore" foreign-key="none"
+ */
+ public HProcess getProcess() {
+ return _process;
+ }
+
+ public void setProcess(HProcess process) {
+ _process = process;
+ }
+
+ /**
+ * @hibernate.property column="PROCESS_ID" insert="false" update="false"
+ */
+ public Long getProcessId() {
+ return _processId;
+ }
+
+ public void setProcessId(Long processId) {
+ _processId = processId;
+ }
+
+ /**
+ * @hibernate.bag lazy="true" inverse="true"
+ * @hibernate.collection-key column="PIID" foreign-key="none"
+ * @hibernate.collection-one-to-many class="org.apache.ode.dao.hib.bpel.hobj.HScope"
+ */
+ public Collection<HScope> getScopes() {
+ return _scopes;
+ }
+
+ public void setScopes(Collection<HScope> scopes) {
+ _scopes = scopes;
+ }
+
+ /**
+ * @hibernate.bag lazy="true" inverse="true"
+ * @hibernate.collection-key column="PIID" foreign-key="none"
+ * @hibernate.collection-one-to-many class="org.apache.ode.dao.hib.bpel.hobj.HCorrelationSet"
+ */
+ public Collection<HCorrelationSet> getCorrelationSets() {
+ return _csets;
+ }
+
+ public void setCorrelationSets(Collection<HCorrelationSet> csets) {
+ _csets = csets;
+ }
+
+ /**
+ * @hibernate.property column="STATE"
+ */
+ public short getState() {
+ return _state;
+ }
+
+ public void setState(short state) {
+ _state = state;
+ }
+
+ /**
+ * @hibernate.property column="LAST_ACTIVE_DT"
+ */
+ public Date getLastActiveTime() {
+ return _lastActiveTime;
+ }
+
+ public void setLastActiveTime(Date lastActiveTime) {
+ _lastActiveTime = lastActiveTime;
+ }
+
+ public void setSequence(long seq) {
+ _seq = seq;
+ }
+
+ /**
+ * @hibernate.property column="SEQUENCE"
+ */
+ public long getSequence() {
+ return _seq;
+ }
+
+ /**
+ * @hibernate.bag lazy="true" inverse="true" cascade="delete"
+ * @hibernate.collection-key column="PIID" foreign-key="none"
+ * @hibernate.collection-one-to-many class="org.apache.ode.dao.hib.bpel.hobj.HActivityRecovery"
+ */
+ public Collection<HActivityRecovery> getActivityRecoveries() {
+ return _activityRecoveries;
+ }
+
+ public void setActivityRecoveries(Collection<HActivityRecovery> activityRecoveries) {
+ _activityRecoveries = activityRecoveries;
+ }
+
+ /**
+ * @hibernate.property column="FAILURE_COUNT"
+ */
+ public int getActivityFailureCount() {
+ return _activityFailureCount;
+ }
+
+ public void setActivityFailureCount(int count) {
+ _activityFailureCount = count;
+ }
+
+ /**
+ * @hibernate.property column="FAILURE_DT"
+ */
+ public Date getActivityFailureDateTime() {
+ return _activityFailureDateTime;
+ }
+
+ public void setActivityFailureDateTime(Date dateTime) {
+ _activityFailureDateTime = dateTime;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HScope.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HScope.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HScope.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,174 @@
+/*
+ * 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.hib.bpel.hobj;
+
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Hibernate table representing a BPEL scope instance.
+ * @hibernate.class table="BPEL_SCOPE"
+ * @hibernate.query name="SELECT_SCOPE_IDS_BY_INSTANCES" query="select id from HScope as s where s.instance in (:instances)"
+ */
+public class HScope extends HObject{
+ public final static String SELECT_SCOPE_IDS_BY_INSTANCES = "SELECT_SCOPE_IDS_BY_INSTANCES";
+
+ /** Process instance to which this scope belongs. */
+ private HProcessInstance _instance;
+
+ /** Correlation set values for csets declared in this scope. */
+ private Set<HCorrelationSet> _correlationSets = new HashSet<HCorrelationSet>();
+
+ /** Variable values for variables declared in this scope. */
+ private Set<HXmlData> _variables = new HashSet<HXmlData>();
+
+ /** Enpoint References for partner links declared in this scope */
+ private Set<HPartnerLink> _partnerLinks = new HashSet<HPartnerLink>();
+
+ /** Parent scope for this scope. */
+ private HScope _parentScope;
+
+ /** State of the scope. */
+ private String _state;
+
+ /** Scope type / name. */
+ private String _name;
+
+ private int _scopeModelId;
+
+ public HScope() {}
+
+ /**
+ * @hibernate.set
+ * lazy="true"
+ * inverse="true"
+ * cascade="delete"
+ * @hibernate.collection-key
+ * column="SCOPE_ID" foreign-key="none"
+ * @hibernate.collection-one-to-many
+ * class="org.apache.ode.dao.hib.bpel.hobj.HCorrelationSet"
+ */
+ public Set<HCorrelationSet> getCorrelationSets() {
+ return _correlationSets;
+ }
+
+ public void setCorrelationSets(Set<HCorrelationSet> correlationSets) {
+ _correlationSets = correlationSets;
+ }
+
+ /**
+ * Get the {@link HProcessInstance} to which this scope object belongs.
+ * @hibernate.many-to-one
+ * column="PIID" foreign-key="none"
+ */
+ public HProcessInstance getInstance() {
+ return _instance;
+ }
+
+ /** @see #getInstance() */
+ public void setInstance(HProcessInstance instance) {
+ _instance = instance;
+ }
+
+ /**
+ * Get the "parent" {@link HScope} of this scope.
+ * @hibernate.many-to-one column="PARENT_SCOPE_ID" foreign-key="none"
+ */
+ public HScope getParentScope() {
+ return _parentScope;
+ }
+
+ /** @see #getParentScope() */
+ public void setParentScope(HScope parentScope) {
+ _parentScope = parentScope;
+ }
+
+ /**
+ * @hibernate.property column="STATE" not-null="true"
+ */
+ public String getState() {
+ return _state;
+ }
+
+ /** @see #getState() */
+ public void setState(String state) {
+ _state = state;
+ }
+
+ /**
+ * Get the type (i.e. the name) of the scope.
+ * @hibernate.property column="NAME" not-null="true"
+ */
+ public String getName() {
+ return _name;
+ }
+
+ /** @see #getName() */
+ public void setName(String name) {
+ _name = name;
+ }
+
+ /**
+ * Get the variable values associated with this scope.
+ *
+ * @return {@link Set}<{@link HXmlData}> with variable values
+ * @hibernate.set lazy="true" inverse="true" cascade="delete"
+ * @hibernate.collection-key column="SCOPE_ID" foreign-key="none"
+ * @hibernate.collection-one-to-many class="org.apache.ode.dao.hib.bpel.hobj.HXmlData"
+ */
+ public Set<HXmlData> getVariables() {
+ return _variables;
+ }
+
+ public void setVariables(Set<HXmlData> variables){
+ _variables = variables;
+ }
+
+ /**
+ * Get the endpoint references for partner links roles associated with this scope.
+ *
+ * @return {@link Set}<{@link HPartnerLink}> with variable values
+ * @hibernate.set lazy="true" inverse="true" cascade="delete"
+ * @hibernate.collection-key column="SCOPE" foreign-key="none"
+ * @hibernate.collection-one-to-many class="org.apache.ode.dao.hib.bpel.hobj.HPartnerLink"
+ */
+ public Set<HPartnerLink> getPartnerLinks() {
+ return _partnerLinks;
+ }
+
+ public void setPartnerLinks(Set<HPartnerLink> eprs) {
+ _partnerLinks = eprs;
+ }
+
+ /**
+ * @hibernate.property column="MODELID"
+ */
+ public int getScopeModelId() {
+ return _scopeModelId;
+ }
+
+ public void setScopeModelId(int scopeModelId) {
+ _scopeModelId = scopeModelId;
+ }
+
+ public String toString() {
+ return "HScope{id="+getId()+",name="+_name+"}";
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HVariableProperty.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HVariableProperty.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HVariableProperty.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,89 @@
+/*
+ * 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.hib.bpel.hobj;
+
+
+/**
+ * Efficient storage of properties (bpel properties).
+ * Useful for identification of process instances based
+ * on indexed lookup of property values.
+ *
+ * @hibernate.class table="VAR_PROPERTY"
+ * @hibernate.query name="SELECT_VARIABLE_PROPERTY_IDS_BY_INSTANCES" query="select id from HVariableProperty as p where p.xmlData in(select x.id from HXmlData x where x.instance in (:instances))"
+ */
+public class HVariableProperty extends HObject{
+ public final static String SELECT_VARIABLE_PROPERTY_IDS_BY_INSTANCES = "SELECT_VARIABLE_PROPERTY_IDS_BY_INSTANCES";
+
+ private String _propertyValue;
+ private String _propertyName;
+ private HXmlData _variable;
+
+ /**
+ * Default constructor
+ */
+ public HVariableProperty() {
+ super();
+ }
+
+ public HVariableProperty(HXmlData var, String name, String value){
+ _variable = var;
+ _propertyName = name;
+ _propertyValue = value;
+ }
+
+ /**
+ * @hibernate.many-to-one
+ * column="XML_DATA_ID" foreign-key="none"
+ */
+ public HXmlData getXmlData(){
+ return _variable;
+ }
+
+ public void setXmlData(HXmlData xmldata){
+ _variable = xmldata;
+ }
+
+ /**
+ * @hibernate.property
+ * column="PROP_VALUE"
+ * index="PROP_VALUE_IDX"
+ */
+ public String getValue() {
+ return _propertyValue;
+ }
+
+ public void setValue(String value) {
+ _propertyValue = value;
+ }
+ /**
+ * @hibernate.property
+ * column="PROP_NAME"
+ * type="string"
+ * length="255"
+ * not-null="true"
+ * index="PROP_NAME_IDX"
+ */
+ public String getName() {
+ return _propertyName;
+ }
+
+ public void setName(String name) {
+ _propertyName = name;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HXmlData.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HXmlData.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HXmlData.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,127 @@
+/*
+ * 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.hib.bpel.hobj;
+
+
+import java.util.Collection;
+import java.util.HashSet;
+
+/**
+ * @hibernate.class table="BPEL_XML_DATA"
+ * @hibernate.query name="SELECT_XMLDATA_IDS_BY_INSTANCES" query="select id from HXmlData as x where x.instance in (:instances)"
+ */
+public class HXmlData extends HObject {
+ public static final String SELECT_XMLDATA_IDS_BY_INSTANCES = "SELECT_XMLDATA_IDS_BY_INSTANCES";
+
+ private boolean _simpleType;
+ private byte[] _data;
+ private Collection<HVariableProperty> _properties = new HashSet<HVariableProperty>();
+ private String _name;
+ private HScope _scope;
+ private HProcessInstance _instance;
+
+ /** Constructor. */
+ public HXmlData() {
+ super();
+ }
+
+ /**
+ * @hibernate.property type="org.apache.ode.dao.hib.bpel.hobj.GZipDataType"
+ *
+ * @hibernate.column name="DATA" sql-type="blob(2G)"
+ */
+ public byte[] getData() {
+ return _data;
+ }
+
+ public void setData(byte[] data) {
+ _data = data;
+ }
+
+ /**
+ * @hibernate.property
+ * column="NAME"
+ * type="string"
+ * length="255"
+ * not-null="true"
+ */
+ public String getName() {
+ return _name;
+ }
+
+ public void setName(String name) {
+ _name = name;
+ }
+
+ /**
+ * @hibernate.bag
+ * lazy="true"
+ * inverse="true"
+ * cascade="delete"
+ * @hibernate.collection-key column="XML_DATA_ID" foreign-key="none"
+ * @hibernate.collection-one-to-many
+ * class="org.apache.ode.dao.hib.bpel.hobj.HVariableProperty"
+ */
+ public Collection<HVariableProperty> getProperties() {
+ return _properties;
+ }
+
+ public void setProperties(Collection<HVariableProperty> properties) {
+ _properties = properties;
+ }
+
+ /**
+ * @hibernate.many-to-one column="SCOPE_ID" foreign-key="none"
+ */
+ public HScope getScope() {
+ return _scope;
+ }
+
+ public void setScope(HScope scope) {
+ _scope = scope;
+
+ if(scope != null) {
+ setInstance(scope.getInstance());
+ }
+ }
+
+ /**
+ * @hibernate.many-to-one
+ * column="PIID" foreign-key="none"
+ */
+ public HProcessInstance getInstance() {
+ return _instance;
+ }
+
+ public void setInstance(HProcessInstance instance) {
+ _instance = instance;
+ }
+
+ /**
+ * @hibernate.property
+ * column="IS_SIMPLE_TYPE"
+ */
+ public boolean isSimpleType() {
+ return _simpleType;
+ }
+
+ public void setSimpleType(boolean simpleType) {
+ _simpleType = simpleType;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/package.html
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/package.html (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/package.html 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,30 @@
+<!--
+ ~ 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.
+ -->
+
+<html>
+<body>
+<p>
+Hibernate POJOs for bpel.
+</p>
+
+<p>
+
+</p>
+</body>
+</html>
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/package.html
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/package.html (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/package.html 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,30 @@
+<!--
+ ~ 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.
+ -->
+
+<html>
+<body>
+<p>
+An implementation of the BPEL data access objects (DAO) api using hibernate.
+</p>
+
+<p>
+
+</p>
+</body>
+</html>
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ql/HibernateInstancesQueryCompiler.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ql/HibernateInstancesQueryCompiler.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ql/HibernateInstancesQueryCompiler.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,726 @@
+/*
+ * 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.hib.bpel.ql;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.ode.bpel.common.ProcessState;
+import org.apache.ode.dao.hib.bpel.hobj.HProcessInstance;
+import org.apache.ode.ql.Compiler;
+import org.apache.ode.ql.eval.skel.AbstractConjunction;
+import org.apache.ode.ql.eval.skel.AbstractDisjunction;
+import org.apache.ode.ql.eval.skel.AbstractEqualityEvaluator;
+import org.apache.ode.ql.eval.skel.CommandEvaluator;
+import org.apache.ode.ql.eval.skel.ConjunctionEvaluator;
+import org.apache.ode.ql.eval.skel.DisjunctionEvaluator;
+import org.apache.ode.ql.eval.skel.EqualityEvaluator;
+import org.apache.ode.ql.eval.skel.GEEvaluator;
+import org.apache.ode.ql.eval.skel.GreaterEvaluator;
+import org.apache.ode.ql.eval.skel.INEvaluator;
+import org.apache.ode.ql.eval.skel.LEEvaluator;
+import org.apache.ode.ql.eval.skel.LessEvaluator;
+import org.apache.ode.ql.eval.skel.LikeEvaluator;
+import org.apache.ode.ql.eval.skel.OrderByEvaluator;
+import org.apache.ode.ql.tree.Builder;
+import org.apache.ode.ql.tree.BuilderFactory;
+import org.apache.ode.ql.tree.nodes.*;
+import org.apache.ode.utils.ISO8601DateParser;
+import org.hibernate.Criteria;
+import org.hibernate.Session;
+import org.hibernate.criterion.Conjunction;
+import org.hibernate.criterion.Criterion;
+import org.hibernate.criterion.Disjunction;
+import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Restrictions;
+
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+public class HibernateInstancesQueryCompiler extends Compiler<List, Session> {
+ private static class DBFieldValueEq extends FieldValueEquality {
+ protected final Object fieldValue;
+
+ /**
+ * @param identifier
+ */
+ public DBFieldValueEq(String identifier, Object fieldValue) {
+ super(identifier);
+ this.fieldValue = fieldValue;
+ }
+
+ /**
+ * @see org.apache.ode.ql.eval.skel.CommandEvaluator#evaluate(java.lang.Object)
+ */
+ public Criterion evaluate(Object paramValue) {
+ return Restrictions.eq(identifier, fieldValue);
+ }
+ }
+
+ private abstract static class FieldValueEquality extends AbstractEqualityEvaluator<String, Criterion, Object> {
+
+ /**
+ * @param identifier
+ */
+ public FieldValueEquality(String identifier) {
+ super(identifier);
+ }
+
+ }
+
+ //
+ private final static String INSTANCE_ID_FIELD = "iid";
+
+ private final static String PROCESS_ID_FIELD = "pid";
+
+ private final static String PROCESS_NAME_FIELD = "name";
+
+ private final static String PROCESS_NAMESPACE_FIELD = "namespace";
+
+ private final static String INSTANCE_STATUS_FIELD = "status";
+
+ private final static String INSTANCE_STARTED_FIELD = "started";
+
+ private final static String INSTANCE_LAST_ACTIVE_FIELD = "last-active";
+
+ /*
+ * private final static String CORRELATION_NAME_FIELD = "name"; private final static String
+ * CORRELATION_NAMESPACE_FIELD = "namespace"; private final static String CORRELATION_NAMESPACE_FIELD = "namespace";
+ */
+ // DB fields
+ private final static String INSTANCE_ID_DB_FIELD = "id";
+
+ private final static String PROCESS_ID_DB_FIELD = "process.processId";
+
+ private final static String PROCESS_NAME_DB_FIELD = "process.typeName";
+
+ private final static String PROCESS_NAMESPACE_DB_FIELD = "process.typeNamespace";
+
+ private final static String INSTANCE_STATUS_DB_FIELD = "state";
+
+ private final static String PROPERTY_NS_DB_FIELD = "process.typeNamespace";
+
+ private final static String PROPERTY_NAME_DB_FIELD = "property.name";
+
+ private final static String PROPERTY_VALUE_DB_FIELD = "property.value";
+
+ private final static String INSTANCE_STARTED_DB_FIELD = "created";
+
+ private final static String INSTANCE_LAST_ACTIVE_DB_FIELD = "lastActiveTime";
+
+ // status fields
+ private final static String STATUS_ACTIVE = "active";
+
+ private final static String STATUS_SUSPENDED = "suspended";
+
+ private final static String STATUS_ERROR = "error";
+
+ private final static String STATUS_COMPLETED = "completed";
+
+ private final static String STATUS_TERMINATED = "terminated";
+
+ private final static String STATUS_FAULTED = "failed";
+
+ private final static Map<String, String> nodeIdentifierToDBField = new HashMap<String, String>(20);
+ //Whether property is used in query
+ private boolean propertyInQuery;
+ //Whether ordering by status used
+ private boolean orderByStatus;
+ private boolean orderByStatusDesc;
+
+ static {
+ nodeIdentifierToDBField.put(INSTANCE_ID_FIELD, INSTANCE_ID_DB_FIELD);
+ nodeIdentifierToDBField.put(INSTANCE_ID_FIELD, INSTANCE_ID_DB_FIELD);
+ nodeIdentifierToDBField.put(PROCESS_ID_FIELD, PROCESS_ID_DB_FIELD);
+ nodeIdentifierToDBField.put(PROCESS_NAME_FIELD, PROCESS_NAME_DB_FIELD);
+ nodeIdentifierToDBField.put(PROCESS_NAMESPACE_FIELD, PROCESS_NAMESPACE_DB_FIELD);
+ nodeIdentifierToDBField.put(INSTANCE_STARTED_FIELD, INSTANCE_STARTED_DB_FIELD);
+ nodeIdentifierToDBField.put(INSTANCE_LAST_ACTIVE_FIELD, INSTANCE_LAST_ACTIVE_DB_FIELD);
+ nodeIdentifierToDBField.put(INSTANCE_STATUS_FIELD, INSTANCE_STATUS_DB_FIELD);
+ }
+
+ private static String getDBField(String name) {
+ String dbField = nodeIdentifierToDBField.get(name);
+
+ if (dbField == null) {
+ throw new IllegalArgumentException("Unsupported field " + name);
+ }
+ return dbField;
+ }
+
+ private void init() {
+ propertyInQuery = false;
+ orderByStatus = false;
+ orderByStatusDesc = false;
+ }
+
+ @Override
+ public CommandEvaluator<List, Session> compile(final Query node) {
+ init();
+
+ final OrderByEvaluator<Collection<Order>, Object> orderEvaluator = (node.getOrder() != null) ? compileOrderBy(node
+ .getOrder()) : null;
+
+ final CommandEvaluator<Criterion, Object> selectionEvaluator = node.getChilds().size() == 0 ? null
+ : compileEvaluator(node.getChilds().iterator().next());
+
+ final boolean joinCorrelationSet = propertyInQuery;
+ final boolean sortByStatus = orderByStatus;
+ final boolean sortByStatusDesc = orderByStatusDesc;
+ final Limit limit = node.getLimit();
+
+ return new CommandEvaluator<List, Session>() {
+ public List evaluate(Session session) {
+ Criteria criteria = session.createCriteria(HProcessInstance.class).createAlias("process", "process");
+ if(joinCorrelationSet) {
+ criteria = criteria.createAlias("correlationSets", "property");
+ }
+ if(selectionEvaluator!=null) {
+ criteria.add(selectionEvaluator.evaluate(null));
+ }
+ if (orderEvaluator != null) {
+ Collection<Order> orders = orderEvaluator.evaluate(null);
+ for (Order order : orders) {
+ criteria.addOrder(order);
+ }
+ }
+ // setting limit
+ if (limit != null) {
+ criteria.setMaxResults(limit.getNumber());
+ }
+
+ List result = criteria.list();
+ //check whether ordering by status
+ if(sortByStatus) {
+ Collections.sort(result, sortByStatusDesc?StateComparator.DESC:StateComparator.ASC);
+ }
+
+ return result;
+ };
+ };
+ }
+
+ protected ConjunctionEvaluator<Criterion, Object> compileConjunction(Collection<CommandEvaluator> childs) {
+ return new AbstractConjunction<Criterion, Object>(childs) {
+ public Criterion evaluate(Object arg) {
+ Conjunction conj = Restrictions.conjunction();
+ for (CommandEvaluator eval : childs) {
+ conj.add((Criterion) eval.evaluate(null));
+ }
+ return conj;
+ }
+ };
+ }
+
+ protected DisjunctionEvaluator<Criterion, Object> compileDisjunction(Collection<CommandEvaluator> childs) {
+ return new AbstractDisjunction<Criterion, Object>(childs) {
+ public Criterion evaluate(Object arg) {
+ Disjunction conj = Restrictions.disjunction();
+ for (CommandEvaluator eval : childs) {
+ conj.add((Criterion) eval.evaluate(null));
+ }
+ return conj;
+ };
+ };
+ }
+
+ protected EqualityEvaluator<String, Criterion, Object> compileEqual(final Equality eq) {
+ if (eq.getIdentifier() instanceof Property) {
+ propertyInQuery = true;
+ final Property property = (Property) eq.getIdentifier();
+ return new EqualityEvaluator<String, Criterion, Object>() {
+ public Criterion evaluate(Object paramValue) {
+ Conjunction conj = Restrictions.conjunction();
+ if (!StringUtils.isEmpty(property.getNamespace())) {
+ conj.add(Restrictions.eq(PROPERTY_NS_DB_FIELD, property.getNamespace()));
+ }
+ conj.add(Restrictions.eq(PROPERTY_NAME_DB_FIELD, property.getName()));
+ conj.add(Restrictions.eq(PROPERTY_VALUE_DB_FIELD, eq.getValue().getValue()));
+
+ return conj;
+ };
+
+ public String getIdentifier() {
+ return property.toString();
+ };
+ };
+ } else {
+ final String fieldName = eq.getIdentifier().getName();
+ final Object value = eq.getValue().getValue();
+
+ final String dbField = getDBField(fieldName);
+
+ if (INSTANCE_STATUS_FIELD.equals(fieldName)) {
+ return new FieldValueEquality(INSTANCE_STATUS_FIELD) {
+ /**
+ * @see org.apache.ode.ql.eval.skel.CommandEvaluator#evaluate(java.lang.Object)
+ */
+ public Criterion evaluate(Object paramValue) {
+ short noState = 200; // TODO move to constants
+ Disjunction disj = Restrictions.disjunction();
+
+ if (STATUS_ACTIVE.equals(paramValue)) {
+ disj.add(Restrictions.eq(dbField, ProcessState.STATE_NEW));
+ disj.add(Restrictions.eq(dbField, ProcessState.STATE_ACTIVE));
+ disj.add(Restrictions.eq(dbField, ProcessState.STATE_READY));
+ } else if (STATUS_SUSPENDED.equals(paramValue)) {
+ disj.add(Restrictions.eq(dbField, ProcessState.STATE_SUSPENDED));
+ } else if (STATUS_ERROR.equals(value)) {
+ disj.add(Restrictions.eq(dbField, noState)); // Error instance state doesn't exist yet
+ } else if (STATUS_COMPLETED.equals(paramValue)) {
+ disj.add(Restrictions.eq(dbField, ProcessState.STATE_COMPLETED_OK));
+ } else if (STATUS_TERMINATED.equals(paramValue)) {
+ disj.add(Restrictions.eq(dbField, ProcessState.STATE_TERMINATED));
+ } else if (STATUS_FAULTED.equals(paramValue)) {
+ disj.add(Restrictions.eq(dbField, ProcessState.STATE_COMPLETED_WITH_FAULT));
+ } else {
+ disj.add(Restrictions.eq(dbField, noState)); // Non existent state
+ }
+ return disj;
+ }
+ };
+ }
+
+ return new DBFieldValueEq(dbField, value);
+ }
+ }
+
+ public CommandEvaluator compileEvaluator(Object node) {
+ /*
+ *
+ */
+ if (node instanceof In) {
+ return compileIn((In) node);
+ } else if (node instanceof org.apache.ode.ql.tree.nodes.Conjunction) {
+ return compileConjunction(evaluate((LogicExprNode) node));
+ } else if (node instanceof org.apache.ode.ql.tree.nodes.Disjunction) {
+ return compileDisjunction(evaluate((LogicExprNode) node));
+ } else if (node instanceof IdentifierToValueCMP) {
+ return compileIdentifierToValueCMP((IdentifierToValueCMP) node);
+ }
+ throw new IllegalArgumentException("Unsupported node " + node.getClass());
+ }
+
+ protected CommandEvaluator<Criterion, Object> compileIdentifierToValueCMP(IdentifierToValueCMP node) {
+ Identifier id = node.getIdentifier();
+ if (id instanceof Field) {
+ String name = id.getName();
+ Value value = node.getValue();
+ if (INSTANCE_ID_FIELD.equals(name)) {
+ value.setValue(Long.valueOf((String) value.getValue()));
+ } else if (INSTANCE_STARTED_FIELD.equals(name) || INSTANCE_LAST_ACTIVE_FIELD.equals(name)) {
+ try {
+ value.setValue(ISO8601DateParser.parse((String) value.getValue()));
+ } catch (ParseException ex) {
+ // TODO
+ throw new RuntimeException(ex);
+ }
+ }
+ }
+ if (node instanceof Equality) {
+ return compileEqual((Equality) node);
+ } else if (node instanceof Less) {
+ return compileLess((Less) node);
+ } else if (node instanceof Greater) {
+ return compileGreater((Greater) node);
+ } else if (node instanceof GE) {
+ return compileGE((GE) node);
+ } else if (node instanceof LE) {
+ return compileLE((LE) node);
+ } else if (node instanceof Like) {
+ return compileLike((Like) node);
+ } else {
+ throw new IllegalArgumentException("Unsupported node " + node.getClass());
+ }
+ }
+
+ protected GEEvaluator<String, Criterion, Object> compileGE(final GE ge) {
+ if (ge.getIdentifier() instanceof Property) {
+ propertyInQuery = true;
+ final Property property = (Property) ge.getIdentifier();
+ return new GEEvaluator<String, Criterion, Object>() {
+ public Criterion evaluate(Object paramValue) {
+ Conjunction conj = Restrictions.conjunction();
+ if (!StringUtils.isEmpty(property.getNamespace())) {
+ conj.add(Restrictions.ge(PROPERTY_NS_DB_FIELD, property.getNamespace()));
+ }
+ conj.add(Restrictions.ge(PROPERTY_NAME_DB_FIELD, property.getName()));
+ conj.add(Restrictions.ge(PROPERTY_VALUE_DB_FIELD, ge.getValue().getValue()));
+
+ return conj;
+ };
+
+ public String getIdentifier() {
+ return property.toString();
+ };
+ };
+ } else {
+ final String fieldName = ge.getIdentifier().getName();
+ final Object objValue = ge.getValue().getValue();
+
+ if (INSTANCE_STATUS_FIELD.equals(fieldName)) {
+ throw new IllegalArgumentException("Field " + INSTANCE_STATUS_FIELD + " is not supported.");
+ }
+
+ final String dbField = getDBField(fieldName);
+
+ return new GEEvaluator<String, Criterion, Object>() {
+ public Criterion evaluate(Object paramValue) {
+ return Restrictions.ge(dbField, objValue);
+ }
+
+ public String getIdentifier() {
+ return fieldName;
+ }
+ };
+ }
+ }
+
+ protected GreaterEvaluator<String, Criterion, Object> compileGreater(final Greater gt) {
+ if (gt.getIdentifier() instanceof Property) {
+ propertyInQuery = true;
+ final Property property = (Property) gt.getIdentifier();
+ return new GreaterEvaluator<String, Criterion, Object>() {
+ public Criterion evaluate(Object paramValue) {
+ Conjunction conj = Restrictions.conjunction();
+ if (!StringUtils.isEmpty(property.getNamespace())) {
+ conj.add(Restrictions.gt(PROPERTY_NS_DB_FIELD, property.getNamespace()));
+ }
+ conj.add(Restrictions.gt(PROPERTY_NAME_DB_FIELD, property.getName()));
+ conj.add(Restrictions.gt(PROPERTY_VALUE_DB_FIELD, gt.getValue().getValue()));
+
+ return conj;
+ };
+
+ public String getIdentifier() {
+ return property.toString();
+ };
+ };
+ } else {
+ final String fieldName = gt.getIdentifier().getName();
+ final Object value = gt.getValue().getValue();
+
+ if (INSTANCE_STATUS_FIELD.equals(fieldName)) {
+ throw new IllegalArgumentException("Field " + INSTANCE_STATUS_FIELD + " is not supported.");
+ }
+
+ final String dbField = getDBField(fieldName);
+
+ return new GreaterEvaluator<String, Criterion, Object>() {
+ public Criterion evaluate(Object paramValue) {
+ return Restrictions.gt(dbField, value);
+ }
+
+ public String getIdentifier() {
+ return fieldName;
+ }
+ };
+ }
+ }
+
+ protected INEvaluator<String, Criterion, Object> compileIn(final In in) {
+ if (in.getIdentifier() instanceof Property) {
+ propertyInQuery = true;
+ final Property property = (Property) in.getIdentifier();
+ return new INEvaluator<String, Criterion, Object>() {
+ public Criterion evaluate(Object paramValue) {
+ Disjunction disj = Restrictions.disjunction();
+
+ String propertyNS = property.getNamespace();
+ String propertyName = property.getName();
+
+ for (Value value : in.getValues()) {
+ Conjunction conj = Restrictions.conjunction();
+ if (!StringUtils.isEmpty(property.getNamespace())) {
+ conj.add(Restrictions.gt(PROPERTY_NS_DB_FIELD, propertyNS));
+ }
+ conj.add(Restrictions.gt(PROPERTY_NAME_DB_FIELD, propertyName));
+ conj.add(Restrictions.gt(PROPERTY_VALUE_DB_FIELD, value.getValue()));
+
+ disj.add(conj);
+ }
+ return disj;
+ };
+
+ public String getIdentifier() {
+ return property.toString();
+ };
+ };
+ } else {
+ final String fieldName = in.getIdentifier().getName();
+
+ if (INSTANCE_STATUS_FIELD.equals(fieldName)) {
+ short noState = 200; // TODO move to constants
+ final Disjunction disj = Restrictions.disjunction();
+
+ final Collection values = ValuesHelper.extract((Collection<Value>) in.getValues());
+
+ if (values.contains(STATUS_ACTIVE)) {
+ disj.add(Restrictions.eq(INSTANCE_STATUS_DB_FIELD, ProcessState.STATE_NEW));
+ disj.add(Restrictions.eq(INSTANCE_STATUS_DB_FIELD, ProcessState.STATE_ACTIVE));
+ disj.add(Restrictions.eq(INSTANCE_STATUS_DB_FIELD, ProcessState.STATE_READY));
+ }
+ if (values.contains(STATUS_SUSPENDED)) {
+ disj.add(Restrictions.eq(INSTANCE_STATUS_DB_FIELD, ProcessState.STATE_SUSPENDED));
+ }
+ if (values.contains(STATUS_ERROR)) {
+ disj.add(Restrictions.eq(INSTANCE_STATUS_DB_FIELD, noState)); // Error instance state doesn't exist yet
+ }
+ if (values.contains(STATUS_COMPLETED)) {
+ disj.add(Restrictions.eq(INSTANCE_STATUS_DB_FIELD, ProcessState.STATE_COMPLETED_OK));
+ }
+ if (values.contains(STATUS_TERMINATED)) {
+ disj.add(Restrictions.eq(INSTANCE_STATUS_DB_FIELD, ProcessState.STATE_TERMINATED));
+ }
+ if (values.contains(STATUS_FAULTED)) {
+ disj.add(Restrictions.eq(INSTANCE_STATUS_DB_FIELD, ProcessState.STATE_COMPLETED_WITH_FAULT));
+ }
+ return new INEvaluator<String, Criterion, Object>() {
+ public Criterion evaluate(Object paramValue) {
+ return disj;
+ };
+
+ public String getIdentifier() {
+ return INSTANCE_STATUS_DB_FIELD;
+ };
+ };
+ } else {
+ final Collection objValues;
+ final Collection<Value> values = in.getValues();
+ if (INSTANCE_ID_FIELD.equals(fieldName)) {
+ objValues = new ArrayList<Long>(values.size());
+ for (Value value : values) {
+ objValues.add(Long.valueOf((String) value.getValue()));
+ }
+ } else if (INSTANCE_STARTED_FIELD.equals(fieldName) || INSTANCE_LAST_ACTIVE_FIELD.equals(fieldName)) {
+ objValues = new ArrayList<Date>(values.size());
+ try {
+ for (Value value : values) {
+ objValues.add(ISO8601DateParser.parse((String) value.getValue()));
+ }
+ } catch (ParseException ex) {
+ // TODO
+ throw new RuntimeException(ex);
+ }
+ } else {
+ objValues = ValuesHelper.extract((Collection<Value>) values);
+ }
+ final String dbField = getDBField(fieldName);
+ return new INEvaluator<String, Criterion, Object>() {
+ /**
+ * @see org.apache.ode.ql.eval.skel.CommandEvaluator#evaluate(java.lang.Object)
+ */
+ public Criterion evaluate(Object paramValue) {
+ return Restrictions.in(dbField, objValues);
+ }
+
+ /**
+ * @see org.apache.ode.ql.eval.skel.Identified#getIdentifier()
+ */
+ public String getIdentifier() {
+ return dbField;
+ }
+ };
+ }
+ }
+ }
+
+ protected LEEvaluator<String, Criterion, Object> compileLE(final LE le) {
+ if (le.getIdentifier() instanceof Property) {
+ final Property property = (Property) le.getIdentifier();
+ return new LEEvaluator<String, Criterion, Object>() {
+ public Criterion evaluate(Object paramValue) {
+ Conjunction conj = Restrictions.conjunction();
+ if (!StringUtils.isEmpty(property.getNamespace())) {
+ conj.add(Restrictions.le(PROPERTY_NS_DB_FIELD, property.getNamespace()));
+ }
+ conj.add(Restrictions.le(PROPERTY_NAME_DB_FIELD, property.getName()));
+ conj.add(Restrictions.le(PROPERTY_VALUE_DB_FIELD, le.getValue().getValue()));
+
+ return conj;
+ };
+
+ public String getIdentifier() {
+ return property.toString();
+ };
+ };
+ } else {
+ final String fieldName = le.getIdentifier().getName();
+ final Object value = le.getValue().getValue();
+
+ if (INSTANCE_STATUS_FIELD.equals(fieldName)) {
+ throw new IllegalArgumentException("Field " + INSTANCE_STATUS_FIELD + " is not supported.");
+ }
+
+ final String dbField = getDBField(fieldName);
+
+ return new LEEvaluator<String, Criterion, Object>() {
+ public Criterion evaluate(Object paramValue) {
+ return Restrictions.le(dbField, value);
+ }
+
+ public String getIdentifier() {
+ return fieldName;
+ }
+ };
+ }
+ }
+
+ protected LessEvaluator<String, Criterion, Object> compileLess(final Less less) {
+ if (less.getIdentifier() instanceof Property) {
+ propertyInQuery = true;
+ final Property property = (Property) less.getIdentifier();
+ return new LessEvaluator<String, Criterion, Object>() {
+ public Criterion evaluate(Object paramValue) {
+ Conjunction conj = Restrictions.conjunction();
+ if (!StringUtils.isEmpty(property.getNamespace())) {
+ conj.add(Restrictions.lt(PROPERTY_NS_DB_FIELD, property.getNamespace()));
+ }
+ conj.add(Restrictions.lt(PROPERTY_NAME_DB_FIELD, property.getName()));
+ conj.add(Restrictions.lt(PROPERTY_VALUE_DB_FIELD, less.getValue().getValue()));
+
+ return conj;
+ };
+
+ public String getIdentifier() {
+ return property.toString();
+ };
+ };
+ } else {
+ final String fieldName = less.getIdentifier().getName();
+ final Object value = less.getValue().getValue();
+
+ if (INSTANCE_STATUS_FIELD.equals(fieldName)) {
+ throw new IllegalArgumentException("Field " + INSTANCE_STATUS_FIELD + " is not supported.");
+ }
+
+ final String dbField = getDBField(fieldName);
+
+ return new LessEvaluator<String, Criterion, Object>() {
+ public Criterion evaluate(Object paramValue) {
+ return Restrictions.lt(dbField, value);
+ }
+
+ public String getIdentifier() {
+ return fieldName;
+ }
+ };
+ }
+ }
+
+ protected LikeEvaluator<String, Criterion, Object> compileLike(final Like like) {
+ if (like.getIdentifier() instanceof Property) {
+ propertyInQuery = true;
+ final Property property = (Property) like.getIdentifier();
+ return new LikeEvaluator<String, Criterion, Object>() {
+ public Criterion evaluate(Object paramValue) {
+ Conjunction conj = Restrictions.conjunction();
+ if (!StringUtils.isEmpty(property.getNamespace())) {
+ conj.add(Restrictions.like(PROPERTY_NS_DB_FIELD, property.getNamespace()));
+ }
+ conj.add(Restrictions.like(PROPERTY_NAME_DB_FIELD, property.getName()));
+ conj.add(Restrictions.like(PROPERTY_VALUE_DB_FIELD, like.getValue().getValue()));
+
+ return conj;
+ };
+
+ public String getIdentifier() {
+ return property.toString();
+ };
+ };
+ } else {
+ final String fieldName = like.getIdentifier().getName();
+ if (INSTANCE_STATUS_FIELD.equals(fieldName)) {
+ throw new IllegalArgumentException("Field " + INSTANCE_STATUS_FIELD + " is not supported by like operation.");
+ }
+ if (INSTANCE_ID_FIELD.equals(fieldName)) {
+ throw new IllegalArgumentException("Field " + INSTANCE_ID_FIELD + " is not supported by like operation.");
+ }
+
+ final Object value = like.getValue().getValue();
+ final String dbField = getDBField(fieldName);
+
+ return new LikeEvaluator<String, Criterion, Object>() {
+ public Criterion evaluate(Object paramValue) {
+ return Restrictions.like(dbField, value);
+ };
+
+ public String getIdentifier() {
+ return dbField;
+ }
+ };
+ }
+ }
+
+ protected OrderByEvaluator<Collection<Order>, Object> compileOrderBy(OrderBy orderBy) {
+ final LinkedHashMap<String, Boolean> orders = new LinkedHashMap<String, Boolean>();
+
+ for (OrderByElement idOrder : orderBy.getOrders()) {
+ if (!(idOrder.getIdentifier() instanceof Field)) {
+ throw new IllegalArgumentException("Only field identifier supported by order by operator.");
+ }
+ String idName = idOrder.getIdentifier().getName();
+ if(INSTANCE_STATUS_FIELD.equals(idName)) {
+ if(orderBy.getOrders().size()>1) {
+ //TODO throw appropriate exception
+ throw new RuntimeException("Status field should be used alone in <order by> construction.");
+ }
+ orderByStatus = true;
+ orderByStatusDesc = idOrder.getType()==OrderByType.DESC;
+ return null;
+ }
+ String dbField = getDBField(idName);
+
+ orders.put(dbField, idOrder.getType() == null || idOrder.getType() == OrderByType.ASC);
+ }
+
+ return new OrderByEvaluator<Collection<Order>, Object>() {
+ public Collection<Order> evaluate(Object paramValue) {
+ Collection<Order> hibernateOrders = new ArrayList<Order>(orders.size());
+ for (Map.Entry<String, Boolean> order : orders.entrySet()) {
+ hibernateOrders.add(order.getValue() ? Order.asc(order.getKey()) : Order.desc(order.getKey()));
+ }
+ return hibernateOrders;
+ }
+ };
+ }
+
+ protected List<CommandEvaluator> evaluate(LogicExprNode exprNode) {
+ ArrayList<CommandEvaluator> commandsEv = new ArrayList<CommandEvaluator>(exprNode.getChilds().size());
+ for (LogicNode node : exprNode.getChilds()) {
+ commandsEv.add(compileEvaluator(node));
+ }
+ return commandsEv;
+ }
+
+ public static void main(String[] args) {
+ String queryString = "order by last-active desc limit 1000";
+ Builder<String> builder = BuilderFactory.getInstance().createBuilder();
+ Node queryNode = builder.build(queryString);
+ HibernateInstancesQueryCompiler compiler = new HibernateInstancesQueryCompiler();
+
+ compiler.compile((Query) queryNode);
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ql/StateComparator.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ql/StateComparator.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ql/StateComparator.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,63 @@
+/*
+ * 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.hib.bpel.ql;
+
+import java.util.Comparator;
+
+import org.apache.commons.lang.ArrayUtils;
+
+import org.apache.ode.bpel.common.ProcessState;
+import org.apache.ode.dao.hib.bpel.hobj.HProcessInstance;
+
+class StateComparator implements Comparator<HProcessInstance> {
+
+ private static final short[] order = {
+ //"active" status
+ ProcessState.STATE_ACTIVE,
+ ProcessState.STATE_NEW,
+ ProcessState.STATE_READY,
+ //"completed"
+ ProcessState.STATE_COMPLETED_OK,
+ //"error"
+ //TODO Create status for error
+ 200,//noState
+ //"failed"
+ ProcessState.STATE_COMPLETED_WITH_FAULT,
+ //"suspended"
+ ProcessState.STATE_SUSPENDED,
+ //"terminated"
+ ProcessState.STATE_TERMINATED};
+
+ private final int multiplier;
+
+ public final static StateComparator ASC = new StateComparator(true);
+ public final static StateComparator DESC = new StateComparator(false);
+
+ protected StateComparator(boolean asc) {
+ multiplier = asc?1:-1;
+ }
+ /**
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare(HProcessInstance o1, HProcessInstance o2) {
+ return multiplier * (ArrayUtils.indexOf(order, o1.getState()) - ArrayUtils.indexOf(order, o2.getState()));
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/package.html
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/package.html (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/package.html 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,27 @@
+<!--
+ ~ 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.
+ -->
+
+<html>
+<body>
+<p>
+Supporting classes for the Hibernate/DAO implementation used
+by both the BPEL and SFWK DAO implementations.
+</p>
+</body>
+</html>
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/ConfStoreDAOConnectionFactoryImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/ConfStoreDAOConnectionFactoryImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/ConfStoreDAOConnectionFactoryImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -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.hib.store;
+
+import static org.apache.ode.dao.hib.bpel.BpelDAOConnectionFactoryImpl.setupSessionManager;
+
+import java.util.Properties;
+
+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.hib.SessionManager;
+import org.apache.ode.dao.store.ConfStoreDAOConnectionFactory;
+
+public class ConfStoreDAOConnectionFactoryImpl implements ConfStoreDAOConnectionFactory {
+
+ private static final Log __log = LogFactory.getLog(ConfStoreDAOConnectionFactoryImpl.class);
+
+ protected SessionManager _sessionManager;
+ private TransactionManager _txm;
+ private DataSource _ds;
+
+ public void init(Properties initialProps, TransactionManager mgr, Object env) {
+ _txm = mgr;
+ _ds = (DataSource) env;
+ _sessionManager = setupSessionManager(initialProps, _txm, _ds);
+
+ }
+
+ public void shutdown() {
+ _sessionManager.shutdown();
+ }
+
+ public ConfStoreDAOConnectionImpl getConnection() {
+ final ThreadLocal<ConfStoreDAOConnectionImpl> currentConnection = ConfStoreDAOConnectionImpl.getThreadLocal();
+ ConfStoreDAOConnectionImpl conn = (ConfStoreDAOConnectionImpl) currentConnection.get();
+ if (conn != null && !conn.isClosed()) {
+ return conn;
+ } else {
+ conn = new ConfStoreDAOConnectionImpl(_sessionManager);
+ currentConnection.set(conn);
+ return conn;
+ }
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/ConfStoreDAOConnectionImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/ConfStoreDAOConnectionImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/ConfStoreDAOConnectionImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,121 @@
+/*
+ * 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.hib.store;
+
+import java.util.Collection;
+import java.util.Date;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.dao.hib.SessionManager;
+import org.apache.ode.dao.hib.store.hobj.DeploymentUnitDaoImpl;
+import org.apache.ode.dao.hib.store.hobj.ProcessConfDaoImpl;
+import org.apache.ode.dao.hib.store.hobj.VersionTrackerDAOImpl;
+import org.apache.ode.dao.store.ConfStoreDAOConnection;
+import org.apache.ode.dao.store.DeploymentUnitDAO;
+import org.apache.ode.dao.store.ProcessConfDAO;
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+
+/**
+ * Connection to a Hibernate data store. Essentially a thin wrapper around Hibernate's
+ * {@link org.hibernate.Session} interface.
+ * @author mriou <mriou at apache dot org>
+ */
+public class ConfStoreDAOConnectionImpl implements ConfStoreDAOConnection {
+
+ private static final Log __log = LogFactory.getLog(ConfStoreDAOConnectionImpl.class);
+ protected SessionManager _sm;
+
+ static final ThreadLocal<ConfStoreDAOConnectionImpl> _connections = new ThreadLocal<ConfStoreDAOConnectionImpl>();
+
+ public ConfStoreDAOConnectionImpl(SessionManager sessionManager) {
+ _sm = sessionManager;
+ }
+
+ public ProcessConfDAO getProcess(QName pid) {
+ _sm.begin();
+ try {
+ ProcessConfDAO ret = (ProcessConfDaoImpl) _sm.getSession().get(ProcessConfDaoImpl.class,pid.toString());
+ _sm.commit();
+ return ret;
+ } catch (HibernateException e) {
+ __log.error("DbError", e);
+ _sm.rollback();
+ throw e;
+ }
+ }
+
+
+ public DeploymentUnitDAO createDeploymentUnit(String name) {
+ DeploymentUnitDaoImpl du = new DeploymentUnitDaoImpl();
+ du.setName(name);
+ du.setDeployDate(new Date());
+ _sm.getSession().save(du);
+ return du;
+ }
+
+ public DeploymentUnitDAO getDeploymentUnit(String name) {
+ try {
+ DeploymentUnitDaoImpl du = (DeploymentUnitDaoImpl) _sm.getSession().get(DeploymentUnitDaoImpl.class,name);
+ return du;
+ } catch (HibernateException e) {
+ __log.error("DbError", e);
+ throw e;
+ }
+ }
+
+ public long getNextVersion() {
+ VersionTrackerDAOImpl vt = (VersionTrackerDAOImpl)
+ _sm.getSession().createQuery("from VersionTrackerDAOImpl v ").uniqueResult();
+ if (vt == null) return 1;
+ else return vt.getVersion() + 1;
+ }
+
+ public void setVersion(long version) {
+ VersionTrackerDAOImpl vt = (VersionTrackerDAOImpl)
+ _sm.getSession().createQuery("from VersionTrackerDAOImpl v ").uniqueResult();
+ if (vt == null) {
+ vt = new VersionTrackerDAOImpl();
+ vt.setId(1);
+ }
+ vt.setVersion(version);
+ _sm.getSession().save(vt);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Collection<DeploymentUnitDAO> getDeploymentUnits() {
+ Criteria c = _sm.getSession().createCriteria(DeploymentUnitDaoImpl.class);
+ return c.list();
+ }
+
+ public void close() {
+
+ }
+
+ public boolean isClosed() {
+ return _sm.isClosed();
+ }
+
+ public static ThreadLocal<ConfStoreDAOConnectionImpl> getThreadLocal() {
+ return _connections;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/HibernateDao.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/HibernateDao.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/HibernateDao.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,33 @@
+/*
+ * 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.hib.store;
+
+import org.hibernate.Session;
+
+
+public class HibernateDao {
+
+ protected Session getSession() {
+ return ConfStoreDAOConnectionImpl.getThreadLocal().get()._sm.getSession();
+ }
+
+ protected void delete() {
+ getSession().delete(this);
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/hobj/DeploymentUnitDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/hobj/DeploymentUnitDaoImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/hobj/DeploymentUnitDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,146 @@
+/*
+ * 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.hib.store.hobj;
+
+import org.apache.ode.bpel.iapi.ProcessState;
+import org.apache.ode.dao.hib.store.HibernateDao;
+import org.apache.ode.dao.store.DeploymentUnitDAO;
+import org.apache.ode.dao.store.ProcessConfDAO;
+import org.apache.ode.utils.stl.CollectionsX;
+import org.apache.ode.utils.stl.MemberOfFunction;
+
+import javax.xml.namespace.QName;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+
+/**
+ * @author mriou <mriou at apache dot org>
+ * @hibernate.class table="STORE_DU"
+ */
+public class DeploymentUnitDaoImpl extends HibernateDao implements DeploymentUnitDAO {
+
+ private Collection<ProcessConfDaoImpl> _processes = new HashSet<ProcessConfDaoImpl>();
+
+ /** User that deployed the process. */
+ private String _deployer;
+
+ /** Date of last deployment. */
+ private Date _deployDate;
+
+ private String _dir;
+
+ private String _name;
+
+ /**
+ * @hibernate.bag
+ * lazy="false"
+ * inverse="true"
+ * cascade="all"
+ * role="store_processes"
+ * @hibernate.collection-key
+ * column="DU" foreign-key="none"
+ * @hibernate.collection-one-to-many
+ * class="org.apache.ode.dao.hib.store.hobj.ProcessConfDaoImpl"
+ */
+ public Collection<? extends ProcessConfDAO> getProcesses() {
+ return _processes;
+ }
+
+
+ public void setProcesses(Collection<ProcessConfDaoImpl> processes) {
+ _processes = processes;
+ }
+
+ /**
+ * 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="DEPLOYDT"
+ */
+ public Date getDeployDate() {
+ return _deployDate;
+ }
+
+ public void setDeployDate(Date deployDate) {
+ _deployDate = deployDate;
+ }
+
+ /**
+ * @hibernate.id generator-class="assigned"
+ * @hibernate.column name="NAME"
+ */
+ public String getName() {
+ return _name;
+ }
+
+ public void setName(String name) {
+ _name = name;
+ }
+
+ /**
+ * @hibernate.property column="DIR"
+ */
+ public String getDeploymentUnitDir() {
+ return _dir;
+ }
+
+ public void setDeploymentUnitDir(String dir) {
+ _dir = dir;
+ }
+
+ public void delete() {
+ super.delete();
+ }
+
+ public ProcessConfDAO createProcess(QName pid, QName type, long version) {
+ ProcessConfDaoImpl p = new ProcessConfDaoImpl();
+ p.setPID(pid);
+ p.setType(type);
+ p.setDeploymentUnit(this);
+ p.setState(ProcessState.ACTIVE);
+ p.setVersion(version);
+ getSession().save(p);
+ _processes.add(p);
+ return p;
+ }
+
+ public ProcessConfDAO getProcess(final QName pid) {
+ return CollectionsX.find_if(_processes,new MemberOfFunction<ProcessConfDAO>() {
+ @Override
+ public boolean isMember(ProcessConfDAO o) {
+ return o.getPID().equals(pid);
+ }
+
+ });
+ }
+ }
+
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/hobj/ProcessConfDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/hobj/ProcessConfDaoImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/hobj/ProcessConfDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,185 @@
+/*
+ * 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.hib.store.hobj;
+
+import org.apache.ode.bpel.iapi.ProcessState;
+import org.apache.ode.dao.hib.store.HibernateDao;
+import org.apache.ode.dao.store.ProcessConfDAO;
+import org.apache.ode.utils.stl.CollectionsX;
+import org.apache.ode.utils.stl.UnaryFunction;
+
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author mriou <mriou at apache dot org>
+ * @hibernate.class table="STORE_PROCESS"
+ */
+public class ProcessConfDaoImpl extends HibernateDao implements ProcessConfDAO {
+
+ private DeploymentUnitDaoImpl _du;
+
+ private Map<String,String> _properties = new HashMap<String,String>();
+
+ /** Simple name of the process. */
+ private String _processId;
+
+ /** Process type. */
+ private String _type;
+
+
+ /** Process version. */
+ private long _version;
+
+ /** Process state.*/
+ private String _state;
+
+
+ /**
+ * @hibernate.many-to-one foreign-key="none"
+ * @hibernate.column name="DU"
+ */
+ public DeploymentUnitDaoImpl getDeploymentUnit() {
+ return _du;
+ }
+
+ public void setDeploymentUnit(DeploymentUnitDaoImpl du) {
+ _du = du;
+ }
+ /**
+ * @hibernate.map table="STORE_PROCESS_PROP" role="properties_"
+ * @hibernate.collection-key column="propId" foreign-key="none"
+ * @hibernate.collection-index column="name" type="string"
+ * @hibernate.collection-element column="value" type="string"
+ */
+ public Map<String,String> getProperties_() {
+ return _properties;
+ }
+
+ public void setProperties_(Map<String,String> properties) {
+ _properties = properties;
+ }
+
+ /**
+ *
+ * @hibernate.id generator-class="assigned"
+ * @hibernate.column
+ * name="PID"
+ * not-null="true"
+ */
+ public String getPID_() {
+ return _processId;
+ }
+
+ public void setPID_(String processId) {
+ _processId = processId;
+ }
+
+
+ /**
+ * The type of the process (BPEL process definition name).
+ * @hibernate.property
+ * column="TYPE"
+ */
+ public String getType_() {
+ return _type;
+ }
+
+ public void setType_(String type) {
+ _type = type;
+ }
+
+
+ /**
+ * The process version.
+ * @hibernate.property
+ * column="version"
+ */
+ public long getVersion() {
+ return _version;
+ }
+
+ public void setVersion(long version) {
+ _version = version;
+ }
+
+ /**
+ * The process state.
+ * @hibernate.property
+ * column="STATE"
+ */
+ public String getState_() {
+ return _state;
+ }
+
+ public void setState_(String state) {
+ _state = state;
+ }
+
+
+ public QName getPID() {
+ return QName.valueOf(getPID_());
+ }
+
+ public void setPID(QName pid) {
+ setPID_(pid.toString());
+ }
+
+ public void setState(ProcessState state) {
+ setState_(state.toString());
+ }
+
+ public void setProperty(QName name, String content) {
+ _properties.put(name.toString(),content);
+ }
+
+ public void delete() {
+ super.delete();
+ }
+
+ public QName getType() {
+ return QName.valueOf(getType_());
+ }
+
+ public void setType(QName type) {
+ setType_(type.toString());
+ }
+
+ public ProcessState getState() {
+ return ProcessState.valueOf(getState_());
+ }
+
+ public String getProperty(QName name) {
+ return _properties.get(name.toString());
+ }
+
+ public Collection<QName> getPropertyNames() {
+ return CollectionsX.transform(new ArrayList<QName>(), _properties.keySet(),new UnaryFunction<String,QName>() {
+ public QName apply(String x) {
+ return QName.valueOf(x);
+ }
+
+ });
+ }
+
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/hobj/VersionTrackerDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/hobj/VersionTrackerDAOImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/main/java/org/apache/ode/dao/hib/store/hobj/VersionTrackerDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,56 @@
+/*
+ * 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.hib.store.hobj;
+
+import org.apache.ode.dao.hib.store.HibernateDao;
+
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ * @hibernate.class table="STORE_VERSIONS"
+ */
+public class VersionTrackerDAOImpl extends HibernateDao {
+
+ private int _id;
+ private long _version;
+
+ /**
+ * @hibernate.id generator-class="assigned"
+ * @hibernate.column name="ID" not-null="true"
+ */
+ public int getId() {
+ return _id;
+ }
+
+ public void setId(int id) {
+ _id = id;
+ }
+
+ /**
+ * @hibernate.property column="VERSION"
+ */
+ public long getVersion() {
+ return _version;
+ }
+
+ public void setVersion(long version) {
+ _version = version;
+ }
+}
Deleted: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/BaseTestDAO.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/BaseTestDAO.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/BaseTestDAO.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,85 +0,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.
- */
-
-package org.apache.ode.daohib.bpel;
-
-import javax.resource.spi.ConnectionManager;
-import javax.sql.DataSource;
-import javax.transaction.TransactionManager;
-
-import junit.framework.TestCase;
-
-import org.apache.derby.jdbc.EmbeddedXADataSource;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.il.EmbeddedGeronimoFactory;
-import org.hibernate.cfg.Environment;
-
-import java.util.Properties;
-
-/**
- * Testing BpelDAOConnectionImpl.listInstance. We're just producing a lot
- * of different filter combinations and test if they execute ok. To really
- * test that the result is the one expected would take a huge test database
- * (with at least a process and an instance for every possible combination).
- */
-public abstract class BaseTestDAO extends TestCase {
-
- protected BpelDAOConnection daoConn;
- protected TransactionManager txm;
- protected ConnectionManager connectionManager;
- private DataSource ds;
-
- protected void initTM() throws Exception {
- EmbeddedGeronimoFactory factory = new EmbeddedGeronimoFactory();
- connectionManager = new org.apache.geronimo.connector.outbound.GenericConnectionManager();
- txm = factory.getTransactionManager();
- ds = getDataSource();
- txm.begin();
-
- BpelDAOConnectionFactoryImpl factoryImpl = new BpelDAOConnectionFactoryImpl();
- factoryImpl.setTransactionManager(txm);
- factoryImpl.setDataSource(ds);
- Properties props = new Properties();
- props.put(Environment.HBM2DDL_AUTO, "create-drop");
- factoryImpl.init(props);
-
- daoConn = factoryImpl.getConnection();
- }
-
- protected void stopTM() throws Exception {
- txm.commit();
- }
-
- protected DataSource getDataSource() {
- if (ds == null) {
- EmbeddedXADataSource ds = new EmbeddedXADataSource();
- ds.setCreateDatabase("create");
- ds.setDatabaseName("target/testdb");
- ds.setUser("sa");
- ds.setPassword("");
- this.ds = ds;
- }
- return ds;
- }
-
- protected TransactionManager getTransactionManager() {
- return txm;
- }
-
-}
\ No newline at end of file
Deleted: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/ListInstanceTest.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/ListInstanceTest.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/ListInstanceTest.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,109 +0,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.
- */
-
-package org.apache.ode.daohib.bpel;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.ode.bpel.common.InstanceFilter;
-
-/**
- * Testing BpelDAOConnectionImpl.listInstance. We're just producing a lot
- * of different filter combinations and test if they execute ok. To really
- * test that the result is the one expected would take a huge test database
- * (with at least a process and an instance for every possible combination).
- */
-public class ListInstanceTest extends BaseTestDAO {
-
- private Map<String, List> filterElmts;
- private ArrayList<String> order;
-
- protected void setUp() throws Exception {
- initTM();
- buildFilterElements();
- }
-
- protected void tearDown() throws Exception {
- stopTM();
- }
-
- public void testListInstance() throws Exception {
- for (int index = 0; index < 7; index++) {
- StringBuffer filter = new StringBuffer();
- for (Map.Entry<String, List> entry : filterElmts.entrySet()) {
- filter.append(entry.getKey());
- filter.append(entry.getValue().get((index < entry.getValue().size()) ? index : index % entry.getValue().size()));
- InstanceFilter ifilter = new InstanceFilter(filter.toString(),
- order.get((index < order.size()) ? index : index % order.size()), 0);
- daoConn.instanceQuery(ifilter);
- }
- }
- }
-
- private void buildFilterElements() {
- filterElmts = new HashMap<String, List>();
- ArrayList<String> nameList = new ArrayList<String>();
- nameList.add("=Hello* ");
- nameList.add("=HelloWorld ");
- filterElmts.put("name", nameList);
-
- ArrayList<String> namespaceList = new ArrayList<String>();
- namespaceList.add("=http://ode* ");
- namespaceList.add("=http://ode ");
- filterElmts.put("namespace", namespaceList);
-
- ArrayList<String> statusList = new ArrayList<String>();
- statusList.add("=active ");
- statusList.add("=suspended ");
- statusList.add("=error ");
- statusList.add("=completed|terminated ");
- statusList.add("=faulted|terminated ");
- statusList.add("=error|active ");
- filterElmts.put("status", statusList);
-
- ArrayList<String> startedList = new ArrayList<String>();
- startedList.add(">=2005-11-29T15:11 ");
- startedList.add("<=2005-11-29T15:11 ");
- startedList.add("<2005-11-29T15:11 started>=2005-11-29T15:11 ");
- startedList.add(">2005-11-29T15:11 started<=2005-11-29T15:11 ");
- startedList.add("=2005-11-29T15:11 ");
- filterElmts.put("started", startedList);
-
- ArrayList<String> lastActiveList = new ArrayList<String>();
- lastActiveList.add(">=2005-11-29T15:11 ");
- lastActiveList.add("<=2005-11-29T15:11 ");
- lastActiveList.add("<2005-11-29T15:11 last-active>=2005-11-29T15:11 ");
- lastActiveList.add(">2005-11-29T15:11 last-active<=2005-11-29T15:11 ");
- lastActiveList.add("=2005-11-29T15:11 ");
- filterElmts.put("last-active", lastActiveList);
-
- order = new ArrayList<String>();
- order.add("pid");
- order.add("name pid");
- order.add("namespace -name");
- order.add("version -pid +name");
- order.add("status namespace");
- order.add("-started -version status");
- order.add("+last-active name -pid +version -status namespace");
- }
-
-}
Deleted: branches/ODE/ODE-1.x-jpa/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/ProcessManagementDaoTest.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/ProcessManagementDaoTest.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/ProcessManagementDaoTest.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,78 +0,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.
- */
-
-package org.apache.ode.daohib.bpel;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.namespace.QName;
-
-import org.apache.ode.bpel.common.InstanceFilter;
-import org.apache.ode.bpel.common.ProcessState;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
-import org.apache.ode.bpel.dao.ProcessManagementDAO.FailedSummaryValue;
-import org.apache.ode.bpel.dao.ProcessManagementDAO.InstanceSummaryKey;
-
-/**
- * Testing BpelDAOConnectionImpl.listInstance. We're just producing a lot of
- * different filter combinations and test if they execute ok. To really test
- * that the result is the one expected would take a huge test database (with at
- * least a process and an instance for every possible combination).
- */
-public class ProcessManagementDaoTest extends BaseTestDAO {
-
- protected void setUp() throws Exception {
- initTM();
- }
-
- protected void tearDown() throws Exception {
- stopTM();
- }
-
-
- public void testInstanceSummary() throws Exception {
- Set<String> pids = new HashSet<String>();
- QName pid = QName.valueOf("{ns}pid");
- pids.add(pid.toString());
- ProcessDAO p = daoConn.createProcess(pid, QName.valueOf("{ns}type"), "abc", 1);
- ProcessInstanceDAO i = p.createInstance(p.addCorrelator("cor"));
- i.setState(ProcessState.STATE_COMPLETED_OK);
- Map<InstanceSummaryKey, Long> r = daoConn.getProcessManagement().countInstancesSummary(pids);
- System.out.println("resultSummary:" + r);
- assertEquals(1, r.size());
- }
-
- public void testInstanceSummaryFailures() throws Exception {
- Set<String> pids = new HashSet<String>();
- QName pid = QName.valueOf("{ns}pid");
- pids.add(pid.toString());
- ProcessDAO p = daoConn.createProcess(pid, QName.valueOf("{ns}type"), "abc", 1);
- ProcessInstanceDAO i = p.createInstance(p.addCorrelator("cor"));
- Map<String, FailedSummaryValue> r = daoConn.getProcessManagement().findFailedCountAndLastFailedDateForProcessIds(pids);
- System.out.println("resultSummary:" + r);
- assertEquals(0, r.size());
- }
-
-}
Modified: branches/ODE/ODE-1.x-jpa/dao-jpa/pom.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/pom.xml 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/pom.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -117,6 +117,23 @@
</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>
Deleted: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ActivityRecoveryDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ActivityRecoveryDAOImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ActivityRecoveryDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,150 +0,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.
- */
-
-package org.apache.ode.dao.jpa;
-
-import org.apache.ode.bpel.dao.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.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}) @Column(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;
- }
-}
Deleted: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionFactoryImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionFactoryImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionFactoryImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,144 +0,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.
- */
-package org.apache.ode.dao.jpa;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.BpelDAOConnectionFactoryJDBC;
-import org.apache.openjpa.ee.ManagedRuntime;
-import org.apache.openjpa.util.GeneralException;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
-import javax.sql.DataSource;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * @author Matthieu Riou <mriou at apache dot org>
- */
-public class BPELDAOConnectionFactoryImpl implements BpelDAOConnectionFactoryJDBC {
- static final Log __log = LogFactory.getLog(BPELDAOConnectionFactoryImpl.class);
-
- protected EntityManagerFactory _emf;
- private TransactionManager _tm;
- private DataSource _ds;
- private Object _dbdictionary;
-
- static ThreadLocal<BPELDAOConnectionImpl> _connections = new ThreadLocal<BPELDAOConnectionImpl>();
-
- public BPELDAOConnectionFactoryImpl() {
- }
-
- @SuppressWarnings("unchecked")
- public BpelDAOConnection getConnection() {
- try {
- _tm.getTransaction().registerSynchronization(new Synchronization() {
- // OpenJPA allows cross-transaction entity managers, which we don't want
- public void afterCompletion(int i) {
- if (_connections.get() != null)
- _connections.get().getEntityManager().close();
- _connections.set(null);
- }
- public void beforeCompletion() { }
- });
- } catch (RollbackException e) {
- throw new RuntimeException("Coulnd't register synchronizer!");
- } catch (SystemException e) {
- throw new RuntimeException("Coulnd't register synchronizer!");
- }
- if (_connections.get() != null) {
- return _connections.get();
- } else {
- HashMap propMap2 = new HashMap();
- propMap2.put("openjpa.TransactionMode", "managed");
- EntityManager em = _emf.createEntityManager(propMap2);
- BPELDAOConnectionImpl conn = createBPELDAOConnection(em);
- _connections.set(conn);
- return conn;
- }
- }
-
- protected BPELDAOConnectionImpl createBPELDAOConnection(EntityManager em) {
- return new BPELDAOConnectionImpl(em);
- }
-
- @SuppressWarnings("unchecked")
- public void init(Properties properties) {
- HashMap<String, Object> propMap = new HashMap<String,Object>();
-
-// propMap.put("openjpa.Log", "DefaultLevel=TRACE");
- propMap.put("openjpa.Log", "commons");
-// propMap.put("openjpa.jdbc.DBDictionary", "org.apache.openjpa.jdbc.sql.DerbyDictionary");
-
- propMap.put("openjpa.ManagedRuntime", new JpaTxMgrProvider(_tm));
- propMap.put("openjpa.ConnectionFactory", _ds);
- propMap.put("openjpa.ConnectionFactoryMode", "managed");
-// propMap.put("openjpa.FlushBeforeQueries", "false");
- propMap.put("openjpa.FetchBatchSize", 1000);
- propMap.put("openjpa.jdbc.TransactionIsolation", "read-committed");
-
- if (_dbdictionary != null)
- propMap.put("openjpa.jdbc.DBDictionary", _dbdictionary);
-
- if (properties != null)
- for (Map.Entry me : properties.entrySet())
- propMap.put((String)me.getKey(),me.getValue());
-
- _emf = Persistence.createEntityManagerFactory("ode-dao", propMap);
- }
-
- public void setTransactionManager(TransactionManager tm) {
- _tm = tm;
- }
-
- public void setDataSource(DataSource datasource) {
- _ds = datasource;
-
- }
-
- public void setDBDictionary(String dbd) {
- _dbdictionary = dbd;
- }
-
- public void setTransactionManager(Object tm) {
- _tm = (TransactionManager) tm;
-
- }
-
- public void setUnmanagedDataSource(DataSource ds) {
- }
-
- public void shutdown() {
- _emf.close();
- }
-
- public DataSource getDataSource() {
- return _ds;
- }
-}
Deleted: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,370 +0,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.
- */
-
-package org.apache.ode.dao.jpa;
-
-import java.io.Serializable;
-import java.sql.Timestamp;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import javax.xml.namespace.QName;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.common.BpelEventFilter;
-import org.apache.ode.bpel.common.Filter;
-import org.apache.ode.bpel.common.InstanceFilter;
-import org.apache.ode.bpel.common.ProcessState;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.CorrelationSetDAO;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
-import org.apache.ode.bpel.dao.ProcessManagementDAO;
-import org.apache.ode.bpel.dao.ScopeDAO;
-import org.apache.ode.bpel.evt.BpelEvent;
-import org.apache.ode.bpel.evt.ScopeEvent;
-import org.apache.ode.utils.ISO8601DateParser;
-import org.apache.openjpa.persistence.OpenJPAPersistence;
-import org.apache.openjpa.persistence.OpenJPAQuery;
-
-/**
- * @author Matthieu Riou <mriou at apache dot org>
- */
-public class BPELDAOConnectionImpl implements BpelDAOConnection {
- static final Log __log = LogFactory.getLog(BPELDAOConnectionImpl.class);
-
- protected EntityManager _em;
-
- public BPELDAOConnectionImpl(EntityManager em) {
- _em = em;
- }
-
- public List<BpelEvent> bpelEventQuery(InstanceFilter ifilter,
- BpelEventFilter efilter) {
- // TODO
- throw new UnsupportedOperationException();
- }
-
- public List<Date> bpelEventTimelineQuery(InstanceFilter ifilter,
- BpelEventFilter efilter) {
- // TODO
- throw new UnsupportedOperationException();
- }
-
- public ProcessInstanceDAO getInstance(Long iid) {
- ProcessInstanceDAOImpl instance = _em.find(ProcessInstanceDAOImpl.class, iid);
- return instance;
- }
-
- public void close() {
- _em = null;
- }
-
- public MessageExchangeDAO createMessageExchange(char dir) {
- MessageExchangeDAOImpl ret = new MessageExchangeDAOImpl(dir);
- _em.persist(ret);
- return ret;
- }
-
- public ProcessDAO createProcess(QName pid, QName type, String guid, long version) {
- ProcessDAOImpl ret = new ProcessDAOImpl(pid,type,guid,version);
- _em.persist(ret);
- return ret;
- }
-
- public ProcessDAO createTransientProcess(Serializable id) {
- ProcessDAOImpl ret = new ProcessDAOImpl(null, null, null, 0);
- ret.setId((Long)id);
-
- return ret;
- }
-
- @SuppressWarnings("unchecked")
- public ProcessDAO getProcess(QName processId) {
- List l = _em.createQuery("select x from ProcessDAOImpl x where x._processId = ?1")
- .setParameter(1, processId.toString()).getResultList();
- if (l.size() == 0) return null;
- ProcessDAOImpl p = (ProcessDAOImpl) l.get(0);
- return p;
- }
-
- public int getNumInstances(QName processId) {
- ProcessDAO process = getProcess(processId);
- if (process != null)
- return process.getNumInstances();
- else return -1;
- }
-
- public ScopeDAO getScope(Long siidl) {
- return _em.find(ScopeDAOImpl.class, siidl);
- }
-
- public void insertBpelEvent(BpelEvent event, ProcessDAO process, ProcessInstanceDAO instance) {
- EventDAOImpl eventDao = new EventDAOImpl();
- eventDao.setTstamp(new Timestamp(System.currentTimeMillis()));
- eventDao.setType(BpelEvent.eventName(event));
- String evtStr = event.toString();
- eventDao.setDetail(evtStr.substring(0, Math.min(254, evtStr.length())));
- if (process != null)
- eventDao.setProcess((ProcessDAOImpl) process);
- if (instance != null)
- eventDao.setInstance((ProcessInstanceDAOImpl) instance);
- if (event instanceof ScopeEvent)
- eventDao.setScopeId(((ScopeEvent) event).getScopeId());
- eventDao.setEvent(event);
- _em.persist(eventDao);
- }
-
- private static String dateFilter(String filter) {
- String date = Filter.getDateWithoutOp(filter);
- String op = filter.substring(0,filter.indexOf(date));
- Date dt = null;
- try {
- dt = ISO8601DateParser.parse(date);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- Timestamp ts = new Timestamp(dt.getTime());
- return op + " '" + ts.toString() + "'";
- }
-
- @SuppressWarnings("unchecked")
- public Collection<ProcessInstanceDAO> instanceQuery(InstanceFilter criteria) {
- StringBuffer query = new StringBuffer();
- query.append("select pi from ProcessInstanceDAOImpl as pi left join fetch pi._fault ");
-
- if (criteria != null) {
- // Building each clause
- ArrayList<String> clauses = new ArrayList<String>();
-
- // iid filter
- if ( criteria.getIidFilter() != null ) {
- StringBuffer filters = new StringBuffer();
- List<String> iids = criteria.getIidFilter();
- for (int m = 0; m < iids.size(); m++) {
- filters.append(" pi._instanceId = ").append(iids.get(m));
- if (m < iids.size() - 1) filters.append(" or");
- }
- clauses.add(" (" + filters + ")");
- }
-
- // pid filter
- if (criteria.getPidFilter() != null) {
- StringBuffer filters = new StringBuffer();
- List<String> pids = criteria.getPidFilter();
- for (int m = 0; m < pids.size(); m++) {
- filters.append(" pi._process._processId = '").append(pids.get(m)).append("'");
- if (m < pids.size() - 1) filters.append(" or");
- }
- clauses.add(" (" + filters + ")");
- }
-
- // name filter
- if (criteria.getNameFilter() != null) {
- String val = criteria.getNameFilter();
- if (val.endsWith("*")) {
- val = val.substring(0, val.length()-1) + "%";
- }
- //process type string begins with name space
- //this could possibly match more than you want
- //because the name space and name are stored together
- clauses.add(" pi._process._processType like '%" + val + "'");
- }
-
- // name space filter
- if (criteria.getNamespaceFilter() != null) {
- //process type string begins with name space
- //this could possibly match more than you want
- //because the name space and name are stored together
- clauses.add(" pi._process._processType like '{" +
- criteria.getNamespaceFilter() + "%'");
- }
-
- // started filter
- if (criteria.getStartedDateFilter() != null) {
- for ( String ds : criteria.getStartedDateFilter() ) {
- clauses.add(" pi._dateCreated " + dateFilter(ds));
- }
- }
-
- // last-active filter
- if (criteria.getLastActiveDateFilter() != null) {
- for ( String ds : criteria.getLastActiveDateFilter() ) {
- clauses.add(" pi._lastActive " + dateFilter(ds));
- }
- }
-
- // status filter
- if (criteria.getStatusFilter() != null) {
- StringBuffer filters = new StringBuffer();
- List<Short> states = criteria.convertFilterState();
- for (int m = 0; m < states.size(); m++) {
- filters.append(" pi._state = ").append(states.get(m));
- if (m < states.size() - 1) filters.append(" or");
- }
- clauses.add(" (" + filters.toString() + ")");
- }
-
- // $property filter
- if (criteria.getPropertyValuesFilter() != null) {
- Map<String,String> props = criteria.getPropertyValuesFilter();
- // join to correlation sets
- query.append(" inner join pi._rootScope._correlationSets as cs");
- int i = 0;
- for (String propKey : props.keySet()) {
- i++;
- // join to props for each prop
- query.append(" inner join cs._props as csp"+i);
- // add clause for prop key and value
- clauses.add(" csp"+i+".propertyKey = '"+propKey+
- "' and csp"+i+".propertyValue = '"+
- // spaces have to be escaped, might be better handled in InstanceFilter
- props.get(propKey).replaceAll(" ", " ")+"'");
- }
- }
-
- // order by
- StringBuffer orderby = new StringBuffer("");
- if (criteria.getOrders() != null) {
- orderby.append(" order by");
- List<String> orders = criteria.getOrders();
- for (int m = 0; m < orders.size(); m++) {
- String field = orders.get(m);
- String ord = " asc";
- if (field.startsWith("-")) {
- ord = " desc";
- }
- String fieldName = " pi._instanceId";
- if ( field.endsWith("name") || field.endsWith("namespace")) {
- fieldName = " pi._process._processType";
- }
- if ( field.endsWith("version")) {
- fieldName = " pi._process._version";
- }
- if ( field.endsWith("status")) {
- fieldName = " pi._state";
- }
- if ( field.endsWith("started")) {
- fieldName = " pi._dateCreated";
- }
- if ( field.endsWith("last-active")) {
- fieldName = " pi._lastActive";
- }
- orderby.append(fieldName + ord);
- if (m < orders.size() - 1) orderby.append(", ");
- }
-
- }
-
- // Preparing the statement
- if (clauses.size() > 0) {
- query.append(" where");
- for (int m = 0; m < clauses.size(); m++) {
- query.append(clauses.get(m));
- if (m < clauses.size() - 1) query.append(" and");
- }
- }
-
- query.append(orderby);
- }
-
- if (__log.isDebugEnabled()) {
- __log.debug(query.toString());
- }
-
- // criteria limit
- Query pq = _em.createQuery(query.toString());
- OpenJPAQuery kq = OpenJPAPersistence.cast(pq);
- kq.getFetchPlan().setFetchBatchSize(criteria.getLimit());
- List<ProcessInstanceDAO> ql = pq.getResultList();
-
- Collection<ProcessInstanceDAO> list = new ArrayList<ProcessInstanceDAO>();
- int num = 0;
- for (Iterator iterator = ql.iterator(); iterator.hasNext();) {
- if(num++ > criteria.getLimit()) break;
- ProcessInstanceDAO processInstanceDAO = (ProcessInstanceDAO) iterator.next();
- list.add(processInstanceDAO);
- }
-
- return list;
- }
-
-
- public Collection<ProcessInstanceDAO> instanceQuery(String expression) {
- return instanceQuery(new InstanceFilter(expression));
- }
-
- public void setEntityManger(EntityManager em) {
- _em = em;
- }
-
- public MessageExchangeDAO getMessageExchange(String mexid) {
- return _em.find(MessageExchangeDAOImpl.class, mexid);
- }
-
- public void deleteMessageExchange(MessageExchangeDAO mexDao) {
- _em.remove(mexDao);
- }
-
- public EntityManager getEntityManager() {
- return _em;
- }
-
- @SuppressWarnings("unchecked")
- public Map<Long, Collection<CorrelationSetDAO>> getCorrelationSets(Collection<ProcessInstanceDAO> instances) {
- if (instances.size() == 0) {
- return new HashMap<Long, Collection<CorrelationSetDAO>>();
- }
- ArrayList<Long> iids = new ArrayList<Long>(instances.size());
- for (ProcessInstanceDAO dao: instances) {
- iids.add(dao.getInstanceId());
- }
- Collection<CorrelationSetDAOImpl> csets = _em.createNamedQuery(CorrelationSetDAOImpl.SELECT_CORRELATION_SETS_BY_INSTANCES).setParameter("instances", iids).getResultList();
- Map<Long, Collection<CorrelationSetDAO>> map = new HashMap<Long, Collection<CorrelationSetDAO>>();
- for (CorrelationSetDAOImpl cset: csets) {
- Long id = cset.getScope().getProcessInstance().getInstanceId();
- Collection<CorrelationSetDAO> existing = map.get(id);
- if (existing == null) {
- existing = new ArrayList<CorrelationSetDAO>();
- map.put(id, existing);
- }
- existing.add(cset);
- }
- return map;
- }
-
- @SuppressWarnings("unchecked")
- public Collection<CorrelationSetDAO> getActiveCorrelationSets() {
- return _em.createNamedQuery(CorrelationSetDAOImpl.SELECT_ACTIVE_SETS).setParameter("state", ProcessState.STATE_ACTIVE).getResultList();
- }
-
- public ProcessManagementDAO getProcessManagement() {
- return new ProcessManagementDAOImpl(_em);
- }
-}
Deleted: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrSetProperty.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrSetProperty.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrSetProperty.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,91 +0,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.
- */
-package org.apache.ode.dao.jpa;
-
-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.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-
-/**
- * @author Matthieu Riou <mriou at apache dot org>
- */
-@Entity
-@Table(name="ODE_CORSET_PROP")
-@NamedQueries({
- @NamedQuery(name=CorrSetProperty.DELETE_CORSET_PROPERTIES_BY_PROPERTY_IDS, query="delete from CorrSetProperty as p where p.corrSetId in(:corrSetIds)")
-})
-public class CorrSetProperty {
- public final static String DELETE_CORSET_PROPERTIES_BY_PROPERTY_IDS = "DELETE_CORSET_PROPERTIES_BY_PROPERTY_IDS";
-
- @Id @Column(name="ID")
- @GeneratedValue(strategy=GenerationType.AUTO)
- @SuppressWarnings("unused")
- private Long _id;
- @Basic @Column(name="PROP_KEY")
- private String propertyKey;
- @Basic @Column(name="PROP_VALUE")
- private String propertyValue;
-
- @SuppressWarnings("unused")
- @Basic @Column(name="CORRSET_ID", insertable=false, updatable=false, nullable=true)
- private Long corrSetId;
-
- @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="CORRSET_ID")
- private CorrelationSetDAOImpl _corrSet;
-
- public CorrSetProperty() {
- }
- public CorrSetProperty(String propertyKey, String propertyValue) {
- this.propertyKey = propertyKey;
- this.propertyValue = propertyValue;
- }
-
- public String getPropertyKey() {
- return propertyKey;
- }
-
- public void setPropertyKey(String propertyKey) {
- this.propertyKey = propertyKey;
- }
-
- public String getPropertyValue() {
- return propertyValue;
- }
-
- public void setPropertyValue(String propertyValue) {
- this.propertyValue = propertyValue;
- }
-
- public CorrelationSetDAOImpl getCorrSet() {
- return _corrSet;
- }
-
- public void setCorrSet(CorrelationSetDAOImpl corrSet) {
- _corrSet = corrSet;
- }
-}
Deleted: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelationSetDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelationSetDAOImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelationSetDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,123 +0,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.
- */
-
-package org.apache.ode.dao.jpa;
-
-import org.apache.ode.bpel.common.CorrelationKey;
-import org.apache.ode.bpel.dao.CorrelationSetDAO;
-import org.apache.ode.bpel.dao.ScopeDAO;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
-
-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.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
-import javax.xml.namespace.QName;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-@Entity
-@Table(name="ODE_CORRELATION_SET")
-@NamedQueries({
- @NamedQuery(name=CorrelationSetDAOImpl.DELETE_CORRELATION_SETS_BY_IDS, query="delete from CorrelationSetDAOImpl as c where c._correlationSetId in (:ids)"),
- @NamedQuery(name=CorrelationSetDAOImpl.SELECT_CORRELATION_SETS_BY_INSTANCES, query="select c from CorrelationSetDAOImpl as c left join fetch c._scope left join fetch c._props where c._scope._processInstance._instanceId in (:instances)"),
- @NamedQuery(name=CorrelationSetDAOImpl.SELECT_CORRELATION_SET_IDS_BY_PROCESS, query="select c._correlationSetId from CorrelationSetDAOImpl as c where c._scope._processInstance._process = :process"),
- @NamedQuery(name=CorrelationSetDAOImpl.SELECT_CORRELATION_SET_IDS_BY_INSTANCE, query="select c._correlationSetId from CorrelationSetDAOImpl as c where c._scope._processInstance = :instance"),
- @NamedQuery(name=CorrelationSetDAOImpl.SELECT_ACTIVE_SETS, query="select c from CorrelationSetDAOImpl as c left join fetch c._scope where c._scope._processInstance._state = (:state)")
-})
-public class CorrelationSetDAOImpl implements CorrelationSetDAO {
- public final static String DELETE_CORRELATION_SETS_BY_IDS = "DELETE_CORRELATION_SETS_BY_IDS";
- public final static String SELECT_CORRELATION_SETS_BY_INSTANCES = "SELECT_CORRELATION_SETS_BY_INSTANCES";
- public final static String SELECT_CORRELATION_SET_IDS_BY_PROCESS = "SELECT_CORRELATION_SET_IDS_BY_PROCESS";
- public final static String SELECT_CORRELATION_SET_IDS_BY_INSTANCE = "SELECT_CORRELATION_SET_IDS_BY_INSTANCE";
- public final static String SELECT_ACTIVE_SETS = "SELECT_ACTIVE_SETS";
-
- @Id @Column(name="CORRELATION_SET_ID")
- @GeneratedValue(strategy=GenerationType.AUTO)
- private Long _correlationSetId;
- @Basic @Column(name="NAME")
- private String _name;
- @Basic @Column(name="CORRELATION_KEY")
- private String _correlationKey;
-
- @OneToMany(targetEntity=CorrSetProperty.class,mappedBy="_corrSet",fetch=FetchType.LAZY,cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH})
- private Collection<CorrSetProperty> _props = new ArrayList<CorrSetProperty>();
- @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="SCOPE_ID")
- private ScopeDAOImpl _scope;
-
- public CorrelationSetDAOImpl() {}
- public CorrelationSetDAOImpl(ScopeDAOImpl scope, String name) {
- _name = name;
- _scope = scope;
- }
-
- public Long getCorrelationSetId() {
- return _correlationSetId;
- }
-
- public String getName() {
- return _name;
- }
-
- public Map<QName, String> getProperties() {
- HashMap<QName, String> map = new HashMap<QName, String>();
- for (CorrSetProperty prop : _props) {
- map.put(QName.valueOf(prop.getPropertyKey()), prop.getPropertyValue());
- }
- return map;
- }
-
- public ScopeDAO getScope() {
- return _scope;
- }
-
- public CorrelationKey getValue() {
- if (_correlationKey == null) return null;
- return new CorrelationKey(_correlationKey);
- }
-
- public void setValue(QName[] names, CorrelationKey values) {
- _correlationKey = values.toCanonicalString();
- if (names != null)
- for (int m = 0; m < names.length; m++) {
- CorrSetProperty prop = new CorrSetProperty(names[m].toString(), values.getValues()[m]);
- _props.add(prop);
- prop.setCorrSet(this);
- }
- }
-
- public ProcessDAO getProcess() {
- return _scope.getProcessInstance().getProcess();
- }
- public ProcessInstanceDAO getInstance() {
- return _scope.getProcessInstance();
- }
-}
Deleted: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelatorDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelatorDAOImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelatorDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,198 +0,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.
- */
-
-package org.apache.ode.dao.jpa;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.common.CorrelationKeySet;
-import org.apache.ode.bpel.dao.*;
-
-import javax.persistence.*;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-@Entity
-@Table(name = "ODE_CORRELATOR")
-@NamedQueries( { @NamedQuery(name = CorrelatorDAOImpl.DELETE_CORRELATORS_BY_PROCESS, query = "delete from CorrelatorDAOImpl as c where c._process = :process") })
-public class CorrelatorDAOImpl extends OpenJPADAO implements CorrelatorDAO {
- private static Log __log = LogFactory.getLog(CorrelatorDAOImpl.class);
- public final static String DELETE_CORRELATORS_BY_PROCESS = "DELETE_CORRELATORS_BY_PROCESS";
- private final static String ROUTE_BY_CKEY_HEADER = "select route from MessageRouteDAOImpl as route where route._correlator._process._processType = :ptype and route._correlator._correlatorKey = :corrkey";
-
- @Id
- @Column(name = "CORRELATOR_ID")
- @GeneratedValue(strategy = GenerationType.AUTO)
- @SuppressWarnings("unused")
- private Long _correlatorId;
- @Basic
- @Column(name = "CORRELATOR_KEY")
- private String _correlatorKey;
- @OneToMany(targetEntity = MessageRouteDAOImpl.class, mappedBy = "_correlator", fetch = FetchType.EAGER, cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH })
- private Collection<MessageRouteDAOImpl> _routes = new ArrayList<MessageRouteDAOImpl>();
- @OneToMany(targetEntity = MessageExchangeDAOImpl.class, mappedBy = "_correlator", fetch = FetchType.LAZY, cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH })
- private Collection<MessageExchangeDAOImpl> _exchanges = new ArrayList<MessageExchangeDAOImpl>();
- @ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST })
- @Column(name = "PROC_ID")
- private ProcessDAOImpl _process;
-
- public CorrelatorDAOImpl() {
- }
-
- public CorrelatorDAOImpl(String correlatorKey, ProcessDAOImpl process) {
- _correlatorKey = correlatorKey;
- _process = process;
- }
-
- public void addRoute(String routeGroupId, ProcessInstanceDAO target, int index, CorrelationKeySet correlationKeySet, String routePolicy) {
- if (__log.isDebugEnabled()) {
- __log.debug("addRoute " + routeGroupId + " " + target + " " + index + " " + correlationKeySet + " " + routePolicy);
- }
- MessageRouteDAOImpl mr = new MessageRouteDAOImpl(correlationKeySet, routeGroupId, index, (ProcessInstanceDAOImpl) target, this, routePolicy);
- _routes.add(mr);
- getEM().flush();
- }
-
- public MessageExchangeDAO dequeueMessage(CorrelationKeySet correlationKeySet) {
- // TODO: this thing does not seem to be scalable: loading up based on a correlator???
- for (Iterator<MessageExchangeDAOImpl> itr = _exchanges.iterator(); itr.hasNext();) {
- MessageExchangeDAOImpl mex = itr.next();
- if (mex.getCorrelationKeySet().isRoutableTo(correlationKeySet, false)) {
- itr.remove();
- return mex;
- }
- }
- return null;
- }
-
- public void enqueueMessage(MessageExchangeDAO mex, CorrelationKeySet correlationKeySet) {
- MessageExchangeDAOImpl mexImpl = (MessageExchangeDAOImpl) mex;
- mexImpl.setCorrelationKeySet(correlationKeySet);
- _exchanges.add(mexImpl);
- mexImpl.setCorrelator(this);
- }
-
- public Collection<CorrelatorMessageDAO> getAllMessages() {
- return new ArrayList<CorrelatorMessageDAO>(_exchanges);
- }
-
- @SuppressWarnings("unchecked")
- public List<MessageRouteDAO> findRoute(CorrelationKeySet correlationKeySet) {
- if (__log.isDebugEnabled()) {
- __log.debug("findRoute " + correlationKeySet);
- }
- List<CorrelationKeySet> subSets = correlationKeySet.findSubSets();
- Query qry = getEM().createQuery(generateSelectorQuery(ROUTE_BY_CKEY_HEADER, subSets));
- qry.setParameter("ptype", _process.getType().toString());
- qry.setParameter("corrkey", _correlatorKey);
- for (int i = 0; i < subSets.size(); i++) {
- qry.setParameter("s" + i, subSets.get(i).toCanonicalString());
- }
-
- List<MessageRouteDAO> candidateRoutes = (List<MessageRouteDAO>) qry.getResultList();
- if (candidateRoutes.size() > 0) {
- List<MessageRouteDAO> matchingRoutes = new ArrayList<MessageRouteDAO>();
- boolean routed = false;
- for (int i = 0; i < candidateRoutes.size(); i++) {
- MessageRouteDAO route = candidateRoutes.get(i);
- if ("all".equals(route.getRoute())) {
- matchingRoutes.add(route);
- } else {
- if (!routed) {
- matchingRoutes.add(route);
- }
- routed = true;
- }
- }
- if (__log.isDebugEnabled()) {
- __log.debug("findRoute found " + matchingRoutes);
- }
- return matchingRoutes;
- } else {
- if (__log.isDebugEnabled()) {
- __log.debug("findRoute found nothing");
- }
- return null;
- }
- }
-
- private String generateSelectorQuery(String header, List<CorrelationKeySet> subSets) {
- StringBuffer filterQuery = new StringBuffer(header);
-
- if (subSets.size() == 1) {
- filterQuery.append(" and route._correlationKey = :s0");
- } else if (subSets.size() > 1) {
- filterQuery.append(" and route._correlationKey in(");
- for (int i = 0; i < subSets.size(); i++) {
- if (i > 0) {
- filterQuery.append(", ");
- }
- filterQuery.append(":s").append(i);
- }
- filterQuery.append(")");
- }
-
- return filterQuery.toString();
- }
-
- public String getCorrelatorId() {
- return _correlatorKey;
- }
-
- public void setCorrelatorId(String newId) {
- _correlatorKey = newId;
- }
-
- public void removeRoutes(String routeGroupId, ProcessInstanceDAO target) {
- // remove route across all correlators of the process
- ((ProcessInstanceDAOImpl) target).removeRoutes(routeGroupId);
- }
-
- void removeLocalRoutes(String routeGroupId, ProcessInstanceDAO target) {
- if (__log.isDebugEnabled()) {
- __log.debug("removeLocalRoutes " + routeGroupId);
- }
- boolean flush = false;
- for (Iterator<MessageRouteDAOImpl> itr = _routes.iterator(); itr.hasNext();) {
- MessageRouteDAOImpl mr = itr.next();
- if (mr.getGroupId().equals(routeGroupId) && mr.getTargetInstance().equals(target)) {
- if (__log.isDebugEnabled()) {
- __log.debug("removing " + mr.getCorrelationKey() + " " + mr.getIndex() + " " + mr.getRoute());
- }
- itr.remove();
- getEM().remove(mr);
- flush = true;
- }
- }
- if (flush) {
- getEM().flush();
- }
- }
-
- public Collection<MessageRouteDAO> getAllRoutes() {
- return new ArrayList<MessageRouteDAO>(_routes);
- }
-
- public boolean checkRoute(CorrelationKeySet correlationKeySet) {
- // TODO Auto-generated method stub
- return true;
- }
-}
Deleted: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/EventDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/EventDAOImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/EventDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,138 +0,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.
- */
-
-package org.apache.ode.dao.jpa;
-
-import org.apache.ode.bpel.evt.BpelEvent;
-
-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.Lob;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-import java.sql.Timestamp;
-
-/**
- * @author Matthieu Riou <mriou at apache dot org>
- */
-@Entity
-@Table(name="ODE_EVENT")
-@NamedQueries({
- @NamedQuery(name=EventDAOImpl.SELECT_EVENT_IDS_BY_PROCESS, query="select e._id from EventDAOImpl as e where e._instance._process = :process"),
- @NamedQuery(name=EventDAOImpl.DELETE_EVENTS_BY_IDS, query="delete from EventDAOImpl as e where e._id in (:ids)"),
- @NamedQuery(name=EventDAOImpl.DELETE_EVENTS_BY_INSTANCE, query="delete from EventDAOImpl as e where e._instance = :instance")
-})
-public class EventDAOImpl extends OpenJPADAO {
- public final static String SELECT_EVENT_IDS_BY_PROCESS = "SELECT_EVENT_IDS_BY_PROCESS";
- public final static String DELETE_EVENTS_BY_IDS = "DELETE_EVENTS_BY_IDS";
- public final static String DELETE_EVENTS_BY_INSTANCE = "DELETE_EVENTS_BY_INSTANCE";
-
- @Id @Column(name="EVENT_ID")
- @GeneratedValue(strategy= GenerationType.AUTO)
- private Long _id;
- @Basic @Column(name="TSTAMP")
- private Timestamp _tstamp;
- @Basic @Column(name="TYPE")
- private String _type;
- @Basic @Column(name="DETAIL")
- private String _detail;
-
- /** Scope identifier, possibly null. */
- @Basic @Column(name="SCOPE_ID")
- private Long _scopeId;
-
- @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PROCESS_ID")
- private ProcessDAOImpl _process;
- @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="INSTANCE_ID")
- private ProcessInstanceDAOImpl _instance;
- @Lob @Column(name="DATA")
- private BpelEvent _event;
-
- public BpelEvent getEvent() {
- return _event;
- }
-
- public void setEvent(BpelEvent event) {
- _event = event;
- }
-
- public String getDetail() {
- return _detail;
- }
-
- public void setDetail(String detail) {
- _detail = detail;
- }
-
- public Long getId() {
- return _id;
- }
-
- public void setId(Long id) {
- _id = id;
- }
-
- public ProcessInstanceDAOImpl getInstance() {
- return _instance;
- }
-
- public void setInstance(ProcessInstanceDAOImpl instance) {
- _instance = instance;
- }
-
- public ProcessDAOImpl getProcess() {
- return _process;
- }
-
- public void setProcess(ProcessDAOImpl process) {
- _process = process;
- }
-
- public Timestamp getTstamp() {
- return _tstamp;
- }
-
- public void setTstamp(Timestamp tstamp) {
- _tstamp = tstamp;
- }
-
- public String getType() {
- return _type;
- }
-
- public void setType(String type) {
- _type = type;
- }
-
- public Long getScopeId() {
- return _scopeId;
- }
-
- public void setScopeId(Long scopeId) {
- _scopeId = scopeId;
- }
-}
Deleted: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/FaultDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/FaultDAOImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/FaultDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,100 +0,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.
- */
-
-package org.apache.ode.dao.jpa;
-
-import org.apache.ode.bpel.dao.FaultDAO;
-import org.apache.ode.utils.DOMUtils;
-import org.w3c.dom.Element;
-
-import javax.persistence.Basic;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Lob;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-import javax.xml.namespace.QName;
-
-
-@Entity
-@Table(name="ODE_FAULT")
-@NamedQueries({
- @NamedQuery(name=FaultDAOImpl.DELETE_FAULTS_BY_IDS, query="delete from FaultDAOImpl as f where f._id in(:ids)")
-})
-public class FaultDAOImpl implements FaultDAO {
- public final static String DELETE_FAULTS_BY_IDS = "DELETE_FAULTS_BY_IDS";
-
- @Id @Column(name="FAULT_ID")
- @GeneratedValue(strategy=GenerationType.AUTO)
- @SuppressWarnings("unused")
- private Long _id;
- @Basic @Column(name="NAME")
- private String _name;
- @Basic @Column(name="MESSAGE", length=4000)
- private String _explanation;
- @Lob @Column(name="DATA")
- private String _data;
- @Basic @Column(name="LINE_NUMBER")
- private int _lineNo;
- @Basic @Column(name="ACTIVITY_ID")
- private int _activityId;
-
- public FaultDAOImpl() {}
- public FaultDAOImpl(QName faultName, String explanation, int faultLineNo,
- int activityId, Element faultMessage) {
- _name = faultName.toString();
- _explanation = explanation;
- _lineNo = faultLineNo;
- _activityId = activityId;
- _data = (faultMessage == null)?null:DOMUtils.domToString(faultMessage);
- }
-
- public int getActivityId() {
- return _activityId;
- }
-
- public Element getData() {
- Element ret = null;
-
- try {
- ret = (_data == null)?null:DOMUtils.stringToDOM(_data);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- return ret;
- }
-
- public String getExplanation() {
- return _explanation;
- }
-
- public int getLineNo() {
- return _lineNo;
- }
-
- public QName getName() {
- return _name == null ? null : QName.valueOf(_name);
- }
-
-}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaConnection.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaConnection.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaConnection.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaOperator.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaOperator.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaOperator.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -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
Deleted: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaTxMgrProvider.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaTxMgrProvider.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaTxMgrProvider.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,86 +0,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.
- */
-
-package org.apache.ode.dao.jpa;
-
-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
Deleted: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageDAOImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,129 +0,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.
- */
-
-package org.apache.ode.dao.jpa;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.dao.MessageDAO;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
-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.Lob;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-import javax.persistence.Transient;
-import javax.xml.namespace.QName;
-
-@Entity
-@Table(name = "ODE_MESSAGE")
-@NamedQueries( { @NamedQuery(name = MessageDAOImpl.DELETE_MESSAGES_BY_PROCESS, query = "delete from MessageDAOImpl as m where m._messageExchange._process = :process") })
-public class MessageDAOImpl implements MessageDAO {
- private static Log __log = LogFactory.getLog(MessageDAOImpl.class);
- public final static String DELETE_MESSAGES_BY_PROCESS = "DELETE_MESSAGES_BY_PROCESS";
-
- @Id
- @Column(name = "MESSAGE_ID")
- @GeneratedValue(strategy = GenerationType.AUTO)
- @SuppressWarnings("unused")
- private Long _id;
- @Basic
- @Column(name = "TYPE")
- private String _type;
- @Lob
- @Column(name = "DATA")
- private String _data;
- @Lob
- @Column(name = "HEADER")
- private String _header;
- @ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.ALL })
- @Column(name = "MESSAGE_EXCHANGE_ID")
- private MessageExchangeDAOImpl _messageExchange;
-
- public MessageDAOImpl() {
- }
-
- public MessageDAOImpl(QName type, MessageExchangeDAOImpl me) {
- _type = type.toString();
- _messageExchange = me;
- }
-
- public Element getData() {
- if (__log.isDebugEnabled()) {
- __log.debug("getData " + _id + " " + _data);
- }
- try {
- return _data == null ? null : DOMUtils.stringToDOM(_data);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public void setData(Element value) {
- if (value == null) {
- if (__log.isDebugEnabled()) {
- __log.debug("setData " + _id + " null");
- }
- return;
- }
- _data = DOMUtils.domToString(value);
-
- if (__log.isDebugEnabled()) {
- __log.debug("setData " + _id + " " + _data);
- }
- }
-
- public Element getHeader() {
- try {
- return _header == null ? null : DOMUtils.stringToDOM(_header);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public void setHeader(Element value) {
- if (value == null)
- return;
- _header = DOMUtils.domToString(value);
- }
-
- public MessageExchangeDAO getMessageExchange() {
- return _messageExchange;
- }
-
- public QName getType() {
- return _type == null ? null : QName.valueOf(_type);
- }
-
- public void setType(QName type) {
- _type = type.toString();
- }
-
-}
Deleted: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageExchangeDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageExchangeDAOImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageExchangeDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,385 +0,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.
- */
-
-package org.apache.ode.dao.jpa;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.common.CorrelationKeySet;
-import org.apache.ode.bpel.common.CorrelationKey;
-import org.apache.ode.bpel.dao.*;
-import org.apache.ode.utils.DOMUtils;
-import org.apache.ode.utils.uuid.UUID;
-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.Id;
-import javax.persistence.Lob;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.OneToMany;
-import javax.persistence.OneToOne;
-import javax.persistence.Table;
-import javax.persistence.Transient;
-import javax.xml.namespace.QName;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
-
-@Entity
-@Table(name="ODE_MESSAGE_EXCHANGE")
-@NamedQueries({
- @NamedQuery(name=MessageExchangeDAOImpl.DELETE_MEXS_BY_PROCESS, query="delete from MessageExchangeDAOImpl as m where m._process = :process"),
- @NamedQuery(name=MessageExchangeDAOImpl.SELECT_MEX_IDS_BY_PROCESS, query="select m._id from MessageExchangeDAOImpl as m where m._process = :process")
-})
-public class MessageExchangeDAOImpl extends OpenJPADAO implements MessageExchangeDAO, CorrelatorMessageDAO {
- private static final Log __log = LogFactory.getLog(MessageExchangeDAOImpl.class);
-
- public final static String DELETE_MEXS_BY_PROCESS = "DELETE_MEXS_BY_PROCESS";
- public final static String SELECT_MEX_IDS_BY_PROCESS = "SELECT_MEX_IDS_BY_PROCESS";
-
- @Id @Column(name="MESSAGE_EXCHANGE_ID")
- private String _id;
- @Basic @Column(name="CALLEE")
- private String _callee;
- @Basic @Column(name="CHANNEL")
- private String _channel;
- @Basic @Column(name="CORRELATION_ID")
- private String _correlationId;
- @Basic @Column(name="CORRELATION_STATUS")
- private String _correlationStatus;
- @Basic @Column(name="CREATE_TIME")
- private Date _createTime;
- @Basic @Column(name="DIRECTION")
- private char _direction;
- @Lob @Column(name="EPR")
- private String _epr;
- @Transient private
- Element _eprElement;
- @Basic @Column(name="FAULT")
- private String _fault;
- @Basic @Column(name="FAULT_EXPLANATION")
- private String _faultExplanation;
- @Basic @Column(name="OPERATION")
- private String _operation;
- @Basic @Column(name="PARTNER_LINK_MODEL_ID")
- private int _partnerLinkModelId;
- @Basic @Column(name="PATTERN")
- private String _pattern;
- @Basic @Column(name="PORT_TYPE")
- private String _portType;
- @Basic @Column(name="PROPAGATE_TRANS")
- private boolean _propagateTransactionFlag;
- @Basic @Column(name="STATUS")
- private String _status;
- @Basic @Column(name="CORRELATION_KEYS")
- private String _correlationKeys;
- @Basic @Column(name="PIPED_ID")
- private String _pipedMessageExchangeId;
- @Basic @Column(name="SUBSCRIBER_COUNT")
- private int _subscriberCount;
-
- @OneToMany(targetEntity=MexProperty.class,mappedBy="_mex",fetch=FetchType.EAGER,cascade={CascadeType.ALL})
- private Collection<MexProperty> _props = new ArrayList<MexProperty>();
- @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PROCESS_INSTANCE_ID")
- private ProcessInstanceDAOImpl _processInst;
- @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PARTNER_LINK_ID")
- private PartnerLinkDAOImpl _partnerLink;
- @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PROCESS_ID")
- private ProcessDAOImpl _process;
- @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.ALL}) @Column(name="REQUEST_MESSAGE_ID")
- private MessageDAOImpl _request;
- @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.ALL}) @Column(name="RESPONSE_MESSAGE_ID")
- private MessageDAOImpl _response;
-
- @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="CORR_ID")
- private CorrelatorDAOImpl _correlator;
-
- public MessageExchangeDAOImpl() {
- }
-
- public MessageExchangeDAOImpl(char direction){
- _direction = direction;
- _id = new UUID().toString();
- }
-
- public MessageDAO createMessage(QName type) {
- MessageDAOImpl ret = new MessageDAOImpl(type,this);
- return ret ;
- }
-
- public QName getCallee() {
- return _callee == null ? null : QName.valueOf(_callee);
- }
-
- public String getChannel() {
- return _channel;
- }
-
- public String getCorrelationId() {
- return _correlationId;
- }
-
- public String getCorrelationStatus() {
- return _correlationStatus;
- }
-
- public Date getCreateTime() {
- return _createTime;
- }
-
- public char getDirection() {
- return _direction;
- }
-
- public Element getEPR() {
- if ( _eprElement == null && _epr != null && !"".equals(_epr)) {
- try {
- _eprElement = DOMUtils.stringToDOM(_epr);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- return _eprElement;
- }
-
- public QName getFault() {
- return _fault == null ? null : QName.valueOf(_fault);
- }
-
- public String getFaultExplanation() {
- return _faultExplanation;
- }
-
- public ProcessInstanceDAO getInstance() {
- return _processInst;
- }
-
- public String getMessageExchangeId() {
- //return _messageExchangeId;
- return _id.toString();
- }
-
- public String getOperation() {
- return _operation;
- }
-
- public PartnerLinkDAO getPartnerLink() {
- return _partnerLink;
- }
-
- public int getPartnerLinkModelId() {
- return _partnerLinkModelId;
- }
-
- public String getPattern() {
- return _pattern;
- }
-
- public QName getPortType() {
- return _portType == null ? null : QName.valueOf(_portType);
- }
-
- public ProcessDAO getProcess() {
- return _process;
- }
-
- public boolean getPropagateTransactionFlag() {
- return _propagateTransactionFlag;
- }
-
- public String getProperty(String key) {
- for (MexProperty prop : _props) {
- if (prop.getPropertyKey().equals(key)) return prop.getPropertyValue();
- }
- return null;
- }
-
- public Set<String> getPropertyNames() {
- HashSet<String> propNames = new HashSet<String>();
- for (MexProperty prop : _props) {
- propNames.add(prop.getPropertyKey());
- }
- return propNames;
- }
-
- public MessageDAO getRequest() {
- return _request;
- }
-
- public MessageDAO getResponse() {
- return _response;
- }
-
- public String getStatus() {
- return _status;
- }
-
- public void setCallee(QName callee) {
- _callee = callee.toString();
- }
-
- public void setChannel(String channel) {
- _channel = channel;
- }
-
- public void setCorrelationId(String correlationId) {
- _correlationId = correlationId;
- }
-
- public void setCorrelationStatus(String cstatus) {
- _correlationStatus = cstatus;
- }
-
- public void setEPR(Element epr) {
- _eprElement = epr;
- _epr = DOMUtils.domToString(epr);
- }
-
- public void setFault(QName faultType) {
- _fault = faultType == null ? null : faultType.toString();
- }
-
- public void setFaultExplanation(String explanation) {
- if(explanation != null && explanation.length() > 255)
- explanation = explanation.substring(0,254);
- _faultExplanation = explanation;
- }
-
- public void setInstance(ProcessInstanceDAO dao) {
- _processInst = (ProcessInstanceDAOImpl)dao;
- }
-
- public void setOperation(String opname) {
- _operation = opname;
- }
-
- public void setPartnerLink(PartnerLinkDAO plinkDAO) {
- _partnerLink = (PartnerLinkDAOImpl)plinkDAO;
- }
-
- public void setPartnerLinkModelId(int modelId) {
- _partnerLinkModelId = modelId;
- }
-
- public void setPattern(String pattern) {
- _pattern = pattern;
- }
-
- public void setPortType(QName porttype) {
- _portType = porttype.toString();
- }
-
- public void setProcess(ProcessDAO process) {
- _process = (ProcessDAOImpl)process;
- }
-
- public void setProperty(String key, String value) {
- _props.add(new MexProperty(key, value, this));
- }
-
- public void setRequest(MessageDAO msg) {
- _request = (MessageDAOImpl)msg;
- }
-
- public void setResponse(MessageDAO msg) {
- _response = (MessageDAOImpl)msg;
- }
-
- public void setStatus(String status) {
- _status = status;
- }
-
- public String getPipedMessageExchangeId() {
- return _pipedMessageExchangeId;
- }
-
- public void setPipedMessageExchangeId(String pipedMessageExchangeId) {
- _pipedMessageExchangeId = pipedMessageExchangeId;
- }
-
- void setCorrelationKeySet(CorrelationKeySet correlationKeySet) {
- _correlationKeys = correlationKeySet.toCanonicalString();
- }
-
- CorrelationKeySet getCorrelationKeySet() {
- return new CorrelationKeySet(_correlationKeys);
- }
-
- public CorrelationKey getCorrelationKey() {
- if (_correlationKeys == null) return null;
- return getCorrelationKeySet().iterator().next();
- }
-
- public void setCorrelationKey(CorrelationKey ckey) {
- _correlationKeys = ckey.toCanonicalString();
- }
-
-
- public void release(boolean doClean) {
- if( doClean ) {
- deleteMessages();
- }
- }
-
- public void releasePremieMessages() {
- // do nothing; early messages are deleted during CorrelatorDaoImpl().dequeueMessage()
- }
-
- public void deleteMessages() {
- if( __log.isDebugEnabled() ) __log.debug("Deleting message on MEX release.");
-
- getEM().remove(this); // This deletes MexProperty, REQUEST MessageDAO, RESPONSE MessageDAO
- }
-
- public CorrelatorDAOImpl getCorrelator() {
- return _correlator;
- }
-
- public void setCorrelator(CorrelatorDAOImpl correlator) {
- _correlator = correlator;
- }
-
- public int getSubscriberCount() {
- return _subscriberCount;
- }
-
- public void setSubscriberCount(int subscriberCount) {
- this._subscriberCount = subscriberCount;
- }
-
- public void incrementSubscriberCount() {
- ++_subscriberCount;
- }
-
- public void release() {
- // no-op for now, could be used to do some cleanup
- }
-
- public void setCreateTime(Date createTime) {
- _createTime = createTime;
- }
-}
Deleted: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageRouteDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageRouteDAOImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageRouteDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,118 +0,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.
- */
-
-package org.apache.ode.dao.jpa;
-
-import org.apache.ode.bpel.common.CorrelationKey;
-import org.apache.ode.bpel.common.CorrelationKeySet;
-import org.apache.ode.bpel.dao.MessageRouteDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
-
-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.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-
-@Entity
-@Table(name="ODE_MESSAGE_ROUTE")
-@NamedQueries ({
- @NamedQuery(name=MessageRouteDAOImpl.DELETE_MESSAGE_ROUTES_BY_INSTANCE_IDS, query="delete from MessageRouteDAOImpl as r where r._instanceId in(:instanceIds)"),
- @NamedQuery(name=MessageRouteDAOImpl.DELETE_MESSAGE_ROUTES_BY_INSTANCE, query="delete from MessageRouteDAOImpl as r where r._processInst = :instance")
-})
-public class MessageRouteDAOImpl implements MessageRouteDAO {
- public final static String DELETE_MESSAGE_ROUTES_BY_INSTANCE = "DELETE_MESSAGE_ROUTES_BY_INSTANCE";
- public final static String DELETE_MESSAGE_ROUTES_BY_INSTANCE_IDS = "DELETE_MESSAGE_ROUTES_BY_INSTANCE_IDS";
-
- @Id @Column(name="MESSAGE_ROUTE_ID")
- @GeneratedValue(strategy=GenerationType.AUTO)
- private Long _id;
- @Basic @Column(name="GROUP_ID")
- private String _groupId;
- @Basic @Column(name="ROUTE_INDEX")
- private int _index;
- @Basic @Column(name="CORRELATION_KEY")
- private String _correlationKey;
- @Basic @Column(name="ROUTE_POLICY", length=16)
- private String _routePolicy;
-
- @SuppressWarnings("unused")
- @Basic @Column(name="PROCESS_INSTANCE_ID", insertable=false, updatable=false, nullable=true)
- private int _instanceId;
- @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PROCESS_INSTANCE_ID")
- private ProcessInstanceDAOImpl _processInst;
-
- @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="CORR_ID")
- @SuppressWarnings("unused")
- private CorrelatorDAOImpl _correlator;
-
- public MessageRouteDAOImpl() {}
- public MessageRouteDAOImpl(CorrelationKeySet keySet, String groupId, int index,
- ProcessInstanceDAOImpl processInst, CorrelatorDAOImpl correlator, String routePolicy) {
- _correlationKey = keySet.toCanonicalString();
- _groupId = groupId;
- _index = index;
- _processInst = processInst;
- _correlator = correlator;
- _routePolicy = routePolicy;
- }
-
- public Long getId() {
- return _id;
- }
-
- public CorrelationKey getCorrelationKey() {
- return new CorrelationKey(_correlationKey);
- }
-
- public void setCorrelationKey(CorrelationKey key) {
- _correlationKey = key.toCanonicalString();
- }
-
- public String getGroupId() {
- return _groupId;
- }
-
- public int getIndex() {
- return _index;
- }
-
- public ProcessInstanceDAO getTargetInstance() {
- return _processInst;
- }
-
- public String getRoute() {
- return _routePolicy;
- }
-
- public CorrelationKeySet getCorrelationKeySet() {
- return new CorrelationKeySet(_correlationKey);
- }
-
- public void setCorrelationKeySet(CorrelationKeySet keySet) {
- _correlationKey = keySet.toCanonicalString();
- }
-}
Deleted: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MexProperty.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MexProperty.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MexProperty.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,86 +0,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.
- */
-
-package org.apache.ode.dao.jpa;
-
-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.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-
-/**
- * @author Matthieu Riou <mriou at apache dot org>
- */
-@Entity
-@Table(name="ODE_MEX_PROP")
-@NamedQueries({
- @NamedQuery(name=MexProperty.DELETE_MEX_PROPERTIES_BY_MEX_IDS, query="delete from MexProperty as p where p._mexId in (:mexIds)")
-})
-public class MexProperty {
- public final static String DELETE_MEX_PROPERTIES_BY_MEX_IDS = "DELETE_MEX_PROPERTIES_BY_MEX_IDS";
-
- @Id @Column(name="ID")
- @GeneratedValue(strategy=GenerationType.AUTO)
- @SuppressWarnings("unused")
- private Long _id;
- @Basic @Column(name="PROP_KEY")
- private String propertyKey;
- @Basic @Column(name="PROP_VALUE", length=2000)
- private String propertyValue;
-
- @SuppressWarnings("unused")
- @Basic @Column(name="MEX_ID", insertable=false, updatable=false, nullable=true)
- private String _mexId;
- @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST})
- @Column(name="MEX_ID")
- @SuppressWarnings("unused")
- private MessageExchangeDAOImpl _mex;
-
- public MexProperty() {
- }
- public MexProperty(String propertyKey, String propertyValue, MessageExchangeDAOImpl mex) {
- this.propertyKey = propertyKey;
- this.propertyValue = propertyValue;
- this._mex = mex;
- }
-
- public String getPropertyKey() {
- return propertyKey;
- }
-
- public void setPropertyKey(String propertyKey) {
- this.propertyKey = propertyKey;
- }
-
- public String getPropertyValue() {
- return propertyValue;
- }
-
- public void setPropertyValue(String propertyValue) {
- this.propertyValue = propertyValue;
- }
-}
Deleted: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/OpenJPADAO.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/OpenJPADAO.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/OpenJPADAO.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,78 +0,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.
- */
-package org.apache.ode.dao.jpa;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.openjpa.persistence.OpenJPAPersistence;
-import org.apache.openjpa.persistence.OpenJPAQuery;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @author Matthieu Riou <mriou at apache dot org>
- */
-public class OpenJPADAO {
- private static final Log __log = LogFactory.getLog(OpenJPADAO.class);
-
- protected BPELDAOConnectionImpl getConn() {
- return BPELDAOConnectionFactoryImpl._connections.get();
- }
-
- protected EntityManager getEM() {
- return OpenJPAPersistence.getEntityManager(this);
- }
-
- /**
- * 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) {
- 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();
- }
- }
- }
-}
\ No newline at end of file
Deleted: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/PartnerLinkDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/PartnerLinkDAOImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/PartnerLinkDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,174 +0,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.
- */
-
-package org.apache.ode.dao.jpa;
-
-
-import org.apache.ode.bpel.dao.PartnerLinkDAO;
-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.Lob;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-import javax.persistence.Transient;
-import javax.xml.namespace.QName;
-
-@Entity
-@Table(name="ODE_PARTNER_LINK")
-@NamedQueries({
- @NamedQuery(name=PartnerLinkDAOImpl.DELETE_PARTNER_LINKS_BY_SCOPE_IDS, query="delete from PartnerLinkDAOImpl as l where l._scopeId in (:scopeIds)")
-})
-public class PartnerLinkDAOImpl implements PartnerLinkDAO {
- public final static String DELETE_PARTNER_LINKS_BY_SCOPE_IDS = "DELETE_PARTNER_LINKS_BY_SCOPE_IDS";
-
- @Id @Column(name="PARTNER_LINK_ID")
- @GeneratedValue(strategy=GenerationType.AUTO)
- @SuppressWarnings("unused")
- private Long _id;
- @Lob @Column(name="MY_EPR")
- private String _myEPR;
- @Transient
- private Element _myEPRElement;
- @Basic @Column(name="MY_ROLE_NAME")
- private String _myRoleName;
- @Basic @Column(name="MY_ROLE_SERVICE_NAME")
- private String _myRoleServiceName;
- @Basic @Column(name="MY_SESSION_ID")
- private String _mySessionId;
- @Lob @Column(name="PARTNER_EPR")
- private String _partnerEPR;
- @Transient
- private Element _partnerEPRElement;
- @Basic @Column(name="PARTNER_LINK_MODEL_ID")
- private int _partnerLinkModelId;
- @Basic @Column(name="PARTNER_LINK_NAME")
- private String _partnerLinkName;
- @Basic @Column(name="PARTNER_ROLE_NAME")
- private String _partnerRoleName;
- @Basic @Column(name="PARTNER_SESSION_ID")
- private String _partnerSessionId;
-
- @SuppressWarnings("unused")
- @Basic @Column(name="SCOPE_ID", nullable=true, insertable=false, updatable=false)
- private Long _scopeId;
- @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="SCOPE_ID")
- @SuppressWarnings("unused")
- private ScopeDAOImpl _scope;
-
- public PartnerLinkDAOImpl() {}
- public PartnerLinkDAOImpl(int modelId, String name, String myRole, String partnerRole) {
- _partnerLinkModelId = modelId;
- _partnerLinkName = name;
- _myRoleName = myRole;
- _partnerRoleName = partnerRole;
- }
-
- public Element getMyEPR() {
- if (_myEPRElement == null && _myEPR != null && !"".equals(_myEPR)) {
- try {
- _myEPRElement = DOMUtils.stringToDOM(_myEPR);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- return _myEPRElement;
- }
-
- public String getMyRoleName() {
- return _myRoleName;
- }
-
- public QName getMyRoleServiceName() {
- return _myRoleServiceName == null ? null : QName.valueOf(_myRoleServiceName);
- }
-
- public String getMySessionId() {
- return _mySessionId;
- }
-
- public Element getPartnerEPR() {
- if ( _partnerEPRElement == null && _partnerEPR != null && !"".equals(_partnerEPR)) {
- try {
- _partnerEPRElement = DOMUtils.stringToDOM(_partnerEPR);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- return _partnerEPRElement;
- }
-
- public int getPartnerLinkModelId() {
- return _partnerLinkModelId;
- }
-
- public String getPartnerLinkName() {
- return _partnerLinkName;
- }
-
- public String getPartnerRoleName() {
- return _partnerRoleName;
- }
-
- public String getPartnerSessionId() {
- return _partnerSessionId;
- }
-
- public void setMyEPR(Element val) {
- _myEPRElement = val;
- _myEPR = DOMUtils.domToString(val);
-
- }
-
- public void setMyRoleServiceName(QName svcName) {
- _myRoleServiceName = svcName.toString();
-
- }
-
- public void setMySessionId(String sessionId) {
- _mySessionId = sessionId;
-
- }
-
- public void setPartnerEPR(Element val) {
- _partnerEPRElement = val;
- _partnerEPR = DOMUtils.domToString(val);
-
- }
-
- public void setPartnerSessionId(String session) {
- _partnerSessionId = session;
-
- }
-
- public void setScope(ScopeDAOImpl scope) {
- _scope = scope;
- }
-}
Deleted: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessDAOImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,229 +0,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.
- */
-
-package org.apache.ode.dao.jpa;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.common.CorrelationKey;
-import org.apache.ode.bpel.common.ProcessState;
-import org.apache.ode.bpel.dao.CorrelatorDAO;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
-
-import javax.persistence.*;
-import javax.xml.namespace.QName;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * @author Matthieu Riou <mriou at apache dot org>
- */
-@Entity
-@Table(name="ODE_PROCESS")
-@NamedQueries({
- @NamedQuery(name="ActiveInstances", query="select i from ProcessInstanceDAOImpl as i where i._process = :process and i._state = :state"),
- @NamedQuery(name="InstanceByCKey", query="select cs._scope._processInstance from CorrelationSetDAOImpl as cs where cs._correlationKey = :ckey"),
- @NamedQuery(name="CorrelatorByKey", query="select c from CorrelatorDAOImpl as c where c._correlatorKey = :ckey and c._process = :process")
-})
-public class ProcessDAOImpl extends OpenJPADAO implements ProcessDAO {
- private static final Log __log = LogFactory.getLog(ProcessDAOImpl.class);
-
- @Id @Column(name="ID")
- @GeneratedValue(strategy= GenerationType.AUTO)
- private Long _id;
-
- @Basic @Column(name="PROCESS_ID")
- private String _processId;
- @Basic @Column(name="PROCESS_TYPE")
- private String _processType;
- @Basic @Column(name="GUID")
- private String _guid;
- @Basic @Column(name="VERSION")
- private long _version;
-
- @OneToMany(targetEntity=CorrelatorDAOImpl.class,mappedBy="_process",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
- private Collection<CorrelatorDAOImpl> _correlators = new ArrayList<CorrelatorDAOImpl>();
-
- public ProcessDAOImpl() {}
- public ProcessDAOImpl(QName pid, QName type, String guid, long version) {
- _processId = pid.toString();
- _processType = type.toString();
- _guid = guid;
- _version = version;
- }
-
- public Serializable getId() {
- return _id;
- }
-
- public void setId(Long id) {
- _id = id;
- }
-
- public CorrelatorDAO addCorrelator(String correlator) {
- CorrelatorDAOImpl corr = new CorrelatorDAOImpl(correlator, this);
- _correlators.add(corr);
- return corr;
- }
-
- @SuppressWarnings("unchecked")
- public CorrelatorDAO getCorrelator(String correlatorId) {
- Query qry = getEM().createNamedQuery("CorrelatorByKey");
- qry.setParameter("ckey", correlatorId);
- qry.setParameter("process", this);
- List res = qry.getResultList();
- if (res.size() == 0) return null;
- return (CorrelatorDAO) res.get(0);
- }
-
- public ProcessInstanceDAO createInstance(CorrelatorDAO instantiatingCorrelator) {
- ProcessInstanceDAOImpl inst = new ProcessInstanceDAOImpl((CorrelatorDAOImpl)instantiatingCorrelator, this);
- getEM().persist(inst);
- return inst;
- }
-
- public ProcessInstanceDAO createInstance(CorrelatorDAO instantiatingCorrelator, MessageExchangeDAO mex) {
- ProcessInstanceDAOImpl inst = new ProcessInstanceDAOImpl((CorrelatorDAOImpl)instantiatingCorrelator, this);
- getEM().persist(inst);
- return inst;
- }
-
- @SuppressWarnings("unchecked")
- public Collection<ProcessInstanceDAO> findInstance(CorrelationKey ckey) {
- Query qry = getEM().createNamedQuery("InstanceByCKey");
- qry.setParameter("ckey", ckey.toCanonicalString());
- return qry.getResultList();
- }
-
- public ProcessInstanceDAO getInstance(Long iid) {
- return getEM().find(ProcessInstanceDAOImpl.class, iid);
- }
-
- public QName getProcessId() {
- return QName.valueOf(_processId);
- }
-
- public QName getType() {
- return QName.valueOf(_processType);
- }
-
- @SuppressWarnings("unchecked")
- public void deleteProcessAndRoutes() {
- // delete routes
- Collection instanceIds = getEM().createNamedQuery(ProcessInstanceDAOImpl.SELECT_INSTANCE_IDS_BY_PROCESS).setParameter("process", this).getResultList();
- batchUpdateByIds(instanceIds.iterator(), getEM().createNamedQuery(MessageRouteDAOImpl.DELETE_MESSAGE_ROUTES_BY_INSTANCE_IDS), "instanceIds");
- getEM().createNamedQuery(CorrelatorDAOImpl.DELETE_CORRELATORS_BY_PROCESS).setParameter("process", this).executeUpdate();
-
- deleteInstances(Integer.MAX_VALUE);
-
- // delete process dao
- getEM().remove(this); // This deletes CorrelatorDAO
- getEM().flush();
- }
-
- private int deleteInstances(int transactionSize) {
- if(__log.isDebugEnabled()) __log.debug("Cleaning up process data.");
-
- deleteEvents();
- deleteCorrelations();
- deleteMessages();
- deleteVariables();
- deleteProcessInstances();
-
- return 0;
- }
-
- @SuppressWarnings("unchecked")
- private void deleteProcessInstances() {
- Collection faultIds = getEM().createNamedQuery(ProcessInstanceDAOImpl.SELECT_FAULT_IDS_BY_PROCESS).setParameter("process", this).getResultList();
- batchUpdateByIds(faultIds.iterator(), getEM().createNamedQuery(FaultDAOImpl.DELETE_FAULTS_BY_IDS), "ids");
- Collection instanceIds = getEM().createNamedQuery(ProcessInstanceDAOImpl.SELECT_INSTANCE_IDS_BY_PROCESS).setParameter("process", this).getResultList();
- batchUpdateByIds(instanceIds.iterator(), getEM().createNamedQuery(ActivityRecoveryDAOImpl.DELETE_ACTIVITY_RECOVERIES_BY_IDS), "ids");
- getEM().createNamedQuery(ProcessInstanceDAOImpl.DELETE_INSTANCES_BY_PROCESS).setParameter("process", this).executeUpdate();
- }
-
- @SuppressWarnings("unchecked")
- private void deleteVariables() {
- Collection xmlDataIds = getEM().createNamedQuery(XmlDataDAOImpl.SELECT_XMLDATA_IDS_BY_PROCESS).setParameter("process", this).getResultList();
- batchUpdateByIds(xmlDataIds.iterator(), getEM().createNamedQuery(XmlDataProperty.DELETE_XML_DATA_PROPERTIES_BY_XML_DATA_IDS), "xmlDataIds");
- Collection scopeIds = getEM().createNamedQuery(ScopeDAOImpl.SELECT_SCOPE_IDS_BY_PROCESS).setParameter("process", this).getResultList();
- batchUpdateByIds(scopeIds.iterator(), getEM().createNamedQuery(XmlDataDAOImpl.DELETE_XMLDATA_BY_SCOPE_IDS), "scopeIds");
-
-// Collection scopeIds = getEM().createNamedQuery(ScopeDAOImpl.SELECT_SCOPE_IDS_BY_PROCESS).setParameter("process", this).getResultList();
- batchUpdateByIds(scopeIds.iterator(), getEM().createNamedQuery(PartnerLinkDAOImpl.DELETE_PARTNER_LINKS_BY_SCOPE_IDS), "scopeIds");
- batchUpdateByIds(scopeIds.iterator(), getEM().createNamedQuery(ScopeDAOImpl.DELETE_SCOPES_BY_SCOPE_IDS), "ids");
- }
-
- @SuppressWarnings("unchecked")
- private void deleteMessages() {
- getEM().createNamedQuery(MessageDAOImpl.DELETE_MESSAGES_BY_PROCESS).setParameter("process", this).executeUpdate();
- Collection mexIds = getEM().createNamedQuery(MessageExchangeDAOImpl.SELECT_MEX_IDS_BY_PROCESS).setParameter("process", this).getResultList();
- batchUpdateByIds(mexIds.iterator(), getEM().createNamedQuery(MexProperty.DELETE_MEX_PROPERTIES_BY_MEX_IDS), "mexIds");
- getEM().createNamedQuery(MessageExchangeDAOImpl.DELETE_MEXS_BY_PROCESS).setParameter("process", this).executeUpdate();
- }
-
- @SuppressWarnings("unchecked")
- private void deleteCorrelations() {
- Collection corrSetIds = getEM().createNamedQuery(CorrelationSetDAOImpl.SELECT_CORRELATION_SET_IDS_BY_PROCESS).setParameter("process", this).getResultList();
- batchUpdateByIds(corrSetIds.iterator(), getEM().createNamedQuery(CorrSetProperty.DELETE_CORSET_PROPERTIES_BY_PROPERTY_IDS), "corrSetIds");
- batchUpdateByIds(corrSetIds.iterator(), getEM().createNamedQuery(CorrelationSetDAOImpl.DELETE_CORRELATION_SETS_BY_IDS), "ids");
- }
-
- @SuppressWarnings("unchecked")
- private void deleteEvents() {
- Collection eventIds = getEM().createNamedQuery(EventDAOImpl.SELECT_EVENT_IDS_BY_PROCESS).setParameter("process", this).getResultList();
- batchUpdateByIds(eventIds.iterator(), getEM().createNamedQuery(EventDAOImpl.DELETE_EVENTS_BY_IDS), "ids");
- }
-
- public int getNumInstances() {
- Long instanceCount = (Long) getSingleResult(getEM().createNamedQuery(ProcessInstanceDAOImpl.COUNT_INSTANCE_IDS_BY_PROCESS).setParameter("process", this));
- return (instanceCount == null ? 0 : instanceCount.intValue());
- }
-
- public long getVersion() {
- return _version;
- }
-
- public void instanceCompleted(ProcessInstanceDAO instance) {
- // nothing to do here (yet?)
- }
-
- public void removeRoutes(String routeId, ProcessInstanceDAO target) {
- for (CorrelatorDAO c : _correlators) {
- ((CorrelatorDAOImpl)c).removeLocalRoutes(routeId, target);
- }
- }
-
- public String getGuid() {
- return _guid;
- }
-
- @SuppressWarnings("unchecked")
- public Collection<ProcessInstanceDAO> getActiveInstances() {
- Query qry = getEM().createNamedQuery("ActiveInstances");
- qry.setParameter("process", this);
- qry.setParameter("state", ProcessState.STATE_ACTIVE);
- return qry.getResultList();
- }
-}
\ No newline at end of file
Deleted: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessInstanceDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessInstanceDAOImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessInstanceDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,407 +0,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.
- */
-
-package org.apache.ode.dao.jpa;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.common.ProcessState;
-import org.apache.ode.bpel.dao.ActivityRecoveryDAO;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.CorrelationSetDAO;
-import org.apache.ode.bpel.dao.CorrelatorDAO;
-import org.apache.ode.bpel.dao.FaultDAO;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
-import org.apache.ode.bpel.dao.ScopeDAO;
-import org.apache.ode.bpel.dao.ScopeStateEnum;
-import org.apache.ode.bpel.dao.XmlDataDAO;
-import org.apache.ode.bpel.evt.ProcessInstanceEvent;
-import org.apache.ode.bpel.iapi.ProcessConf.CLEANUP_CATEGORY;
-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.Lob;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.OneToMany;
-import javax.persistence.OneToOne;
-import javax.persistence.Table;
-import javax.xml.namespace.QName;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-@Entity
-@Table(name="ODE_PROCESS_INSTANCE")
-@NamedQueries({
- @NamedQuery(name=ProcessInstanceDAOImpl.DELETE_INSTANCES_BY_PROCESS, query="delete from ProcessInstanceDAOImpl as i where i._process = :process"),
- @NamedQuery(name=ProcessInstanceDAOImpl.SELECT_INSTANCE_IDS_BY_PROCESS, query="select i._instanceId from ProcessInstanceDAOImpl as i where i._process = :process"),
- @NamedQuery(name=ProcessInstanceDAOImpl.COUNT_INSTANCE_IDS_BY_PROCESS, query="select count(i._instanceId) from ProcessInstanceDAOImpl as i where i._process = :process"),
- @NamedQuery(name=ProcessInstanceDAOImpl.SELECT_FAULT_IDS_BY_PROCESS, query="select i._faultId from ProcessInstanceDAOImpl as i where i._process = :process and i._faultId is not null"),
- @NamedQuery(name=ProcessInstanceDAOImpl.COUNT_FAILED_INSTANCES_BY_STATUS_AND_PROCESS_ID,
- query="select count(i._instanceId), max(i._lastRecovery) from ProcessInstanceDAOImpl as i where i._process._processId = :processId and i._state in(:states) and exists(select r from ActivityRecoveryDAOImpl r where i = r._instance)")
-})
-public class ProcessInstanceDAOImpl extends OpenJPADAO implements ProcessInstanceDAO {
- private static final Log __log = LogFactory.getLog(ProcessInstanceDAOImpl.class);
-
- public final static String DELETE_INSTANCES_BY_PROCESS = "DELETE_INSTANCES_BY_PROCESS";
- public final static String SELECT_INSTANCE_IDS_BY_PROCESS = "SELECT_INSTANCE_IDS_BY_PROCESS";
- public final static String COUNT_INSTANCE_IDS_BY_PROCESS = "COUNT_INSTANCE_IDS_BY_PROCESS";
-
- public final static String SELECT_FAULT_IDS_BY_PROCESS = "SELECT_FAULT_IDS_BY_PROCESS";
- public final static String COUNT_FAILED_INSTANCES_BY_STATUS_AND_PROCESS_ID = "COUNT_FAILED_INSTANCES_BY_STATUS_AND_PROCESS_ID";
-
- @Id @Column(name="ID")
- @GeneratedValue(strategy=GenerationType.AUTO)
- private Long _instanceId;
- @Basic @Column(name="LAST_RECOVERY_DATE")
- private Date _lastRecovery;
- @Basic @Column(name="LAST_ACTIVE_TIME")
- private Date _lastActive;
- @Basic @Column(name="INSTANCE_STATE")
- private short _state;
- @Basic @Column(name="PREVIOUS_STATE")
- private short _previousState;
- @Lob @Column(name="EXECUTION_STATE")
- private byte[] _executionState;
- @Basic @Column(name="SEQUENCE")
- private long _sequence;
- @Basic @Column(name="DATE_CREATED")
- private Date _dateCreated = new Date();
-
- @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}) @Column(name="ROOT_SCOPE_ID")
- private ScopeDAOImpl _rootScope;
- @OneToMany(targetEntity=ScopeDAOImpl.class,mappedBy="_processInstance",fetch=FetchType.LAZY,cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH})
- private Collection<ScopeDAO> _scopes = new ArrayList<ScopeDAO>();
- @OneToMany(targetEntity=ActivityRecoveryDAOImpl.class,mappedBy="_instance",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
- private Collection<ActivityRecoveryDAO> _recoveries = new ArrayList<ActivityRecoveryDAO>();
-
- @SuppressWarnings("unused")
- @Basic @Column(name="FAULT_ID", insertable=false, updatable=false, nullable=true)
- private long _faultId;
- @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}) @Column(name="FAULT_ID")
- private FaultDAOImpl _fault;
- @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PROCESS_ID")
- private ProcessDAOImpl _process;
- @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="INSTANTIATING_CORRELATOR_ID")
- private CorrelatorDAOImpl _instantiatingCorrelator;
-
- @OneToMany(targetEntity=MessageExchangeDAOImpl.class,mappedBy="_processInst",fetch=FetchType.LAZY)
- @SuppressWarnings("unused")
- private Collection<MessageExchangeDAO> _messageExchanges = new ArrayList<MessageExchangeDAO>();
-
- private transient int _activityFailureCount = -1;
-
- public ProcessInstanceDAOImpl() {}
- public ProcessInstanceDAOImpl(CorrelatorDAOImpl correlator, ProcessDAOImpl process) {
- _instantiatingCorrelator = correlator;
- _process = process;
- }
-
- public void createActivityRecovery(String channel, long activityId,
- String reason, Date dateTime, Element data, String[] actions,
- int retries) {
- ActivityRecoveryDAOImpl ar = new ActivityRecoveryDAOImpl(channel, activityId, reason, dateTime, data, actions, retries);
- _recoveries.add(ar);
- ar.setInstance(this);
- _lastRecovery = dateTime;
- }
-
- public ScopeDAO createScope(ScopeDAO parentScope, String name, int scopeModelId) {
- ScopeDAOImpl ret = new ScopeDAOImpl((ScopeDAOImpl)parentScope,name,scopeModelId,this);
- ret.setState(ScopeStateEnum.ACTIVE);
- _scopes.add(ret);
- _rootScope = (parentScope == null)?ret:_rootScope;
-
- // Must persist the scope to generate a scope ID
- getEM().persist(ret);
- return ret;
- }
-
- @SuppressWarnings("unchecked")
- public Collection<CorrelationSetDAO> selectCorrelationSets(Collection<ProcessInstanceDAO> instances) {
- return getEM().createNamedQuery(CorrelationSetDAOImpl.SELECT_CORRELATION_SETS_BY_INSTANCES).setParameter("instances", instances).getResultList();
- }
-
- public void delete(Set<CLEANUP_CATEGORY> cleanupCategories) {
- delete(cleanupCategories, true);
- }
-
- public void delete(Set<CLEANUP_CATEGORY> cleanupCategories, boolean deleteMyRoleMex) {
- if(__log.isDebugEnabled()) __log.debug("Cleaning up instance Data with " + cleanupCategories);
-
- // remove jacob state
- setExecutionState(null);
- if (getEM() != null) {
- if( !cleanupCategories.isEmpty() ) {
- // by default, we do not flush before select; flush it, so we can delete no matter if an entity is loaded up
- // or not; more importantly, OpenJPA will secretly load from the entire table if some entities reside only
- // in memory
- getEM().flush();
- }
-
- if (cleanupCategories.contains(CLEANUP_CATEGORY.EVENTS)) {
- deleteEvents();
- }
- if (cleanupCategories.contains(CLEANUP_CATEGORY.CORRELATIONS)) {
- deleteCorrelations();
- }
- if( cleanupCategories.contains(CLEANUP_CATEGORY.MESSAGES) ) {
- deleteMessageRoutes();
- }
- if (cleanupCategories.contains(CLEANUP_CATEGORY.VARIABLES)) {
- deleteVariables();
- }
- if (cleanupCategories.contains(CLEANUP_CATEGORY.INSTANCE)) {
- deleteInstance();
- }
-
- getEM().flush();
- }
- }
-
- private void deleteInstance() {
- if( _fault != null ) {
- getEM().remove(_fault);
- }
- getEM().remove(this); // This deletes ActivityRecoveryDAO
- }
-
- @SuppressWarnings("unchecked")
- private void deleteVariables() {
- Collection xmlDataIds = getEM().createNamedQuery(XmlDataDAOImpl.SELECT_XMLDATA_IDS_BY_INSTANCE).setParameter("instance", this).getResultList();
- batchUpdateByIds(xmlDataIds.iterator(), getEM().createNamedQuery(XmlDataProperty.DELETE_XML_DATA_PROPERTIES_BY_XML_DATA_IDS), "xmlDataIds");
- Collection scopeIds = getEM().createNamedQuery(ScopeDAOImpl.SELECT_SCOPE_IDS_BY_INSTANCE).setParameter("instance", this).getResultList();
- batchUpdateByIds(scopeIds.iterator(), getEM().createNamedQuery(XmlDataDAOImpl.DELETE_XMLDATA_BY_SCOPE_IDS), "scopeIds");
-
- batchUpdateByIds(scopeIds.iterator(), getEM().createNamedQuery(PartnerLinkDAOImpl.DELETE_PARTNER_LINKS_BY_SCOPE_IDS), "scopeIds");
- batchUpdateByIds(scopeIds.iterator(), getEM().createNamedQuery(ScopeDAOImpl.DELETE_SCOPES_BY_SCOPE_IDS), "ids");
- }
-
- private void deleteMessageRoutes() {
- getEM().createNamedQuery(MessageRouteDAOImpl.DELETE_MESSAGE_ROUTES_BY_INSTANCE).setParameter ("instance", this).executeUpdate();
- }
-
- @SuppressWarnings("unchecked")
- private void deleteCorrelations() {
- Collection corrSetIds = getEM().createNamedQuery(CorrelationSetDAOImpl.SELECT_CORRELATION_SET_IDS_BY_INSTANCE).setParameter("instance", this).getResultList();
- batchUpdateByIds(corrSetIds.iterator(), getEM().createNamedQuery(CorrSetProperty.DELETE_CORSET_PROPERTIES_BY_PROPERTY_IDS), "corrSetIds");
- batchUpdateByIds(corrSetIds.iterator(), getEM().createNamedQuery(CorrelationSetDAOImpl.DELETE_CORRELATION_SETS_BY_IDS), "ids");
- }
-
- private void deleteEvents() {
- getEM().createNamedQuery(EventDAOImpl.DELETE_EVENTS_BY_INSTANCE).setParameter ("instance", this).executeUpdate();
- }
-
- public void deleteActivityRecovery(String channel) {
- ActivityRecoveryDAOImpl toRemove = null;
- for (ActivityRecoveryDAO _recovery : _recoveries) {
- ActivityRecoveryDAOImpl arElement = (ActivityRecoveryDAOImpl) _recovery;
- if (arElement.getChannel().equals(channel)) {
- toRemove = arElement;
- break;
- }
- }
- if (toRemove != null) {
- getEM().remove(toRemove);
- _recoveries.remove(toRemove);
- }
-
- }
-
- public void finishCompletion() {
- // make sure we have completed.
- assert (ProcessState.isFinished(this.getState()));
- // let our process know that we've done our work.
- }
-
- public long genMonotonic() {
- return _sequence++;
- }
-
- public int getActivityFailureCount() {
- if( _activityFailureCount == -1 ) {
- _activityFailureCount = _recoveries.size();
- }
-
- return _activityFailureCount;
- }
-
- public void setActivityFailureCount(int activityFailureCount) {
- _activityFailureCount = activityFailureCount;
- }
-
- public Date getActivityFailureDateTime() {
- return _lastRecovery;
- }
-
- public Collection<ActivityRecoveryDAO> getActivityRecoveries() {
- return _recoveries;
- }
-
- public CorrelationSetDAO getCorrelationSet(String name) {
- // TODO: should this method be deprecated?
-
- // Its not clear where the correlation set for the process is used
- // or populated.
-
- throw new UnsupportedOperationException();
-
- //return null;
- }
-
- public Set<CorrelationSetDAO> getCorrelationSets() {
- // TODO: should this method be deprecated?
- // Its not clear where the correlation set for the process is used
- // or populated.
- return new HashSet<CorrelationSetDAO>();
- }
-
- public Date getCreateTime() {
- return _dateCreated;
- }
-
- public EventsFirstLastCountTuple getEventsFirstLastCount() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public byte[] getExecutionState() {
- return _executionState;
- }
-
- public FaultDAO getFault() {
- return _fault;
- }
-
- public Long getInstanceId() {
- return _instanceId;
- }
-
- public CorrelatorDAO getInstantiatingCorrelator() {
- return _instantiatingCorrelator;
- }
-
- public Date getLastActiveTime() {
- return _lastActive;
- }
-
- public short getPreviousState() {
- return _previousState;
- }
-
- public ProcessDAO getProcess() {
- return _process;
- }
-
- public ScopeDAO getRootScope() {
- return _rootScope;
- }
-
- public ScopeDAO getScope(Long scopeInstanceId) {
- return getEM().find(ScopeDAOImpl.class, scopeInstanceId);
- }
-
- public Collection<ScopeDAO> getScopes(String scopeName) {
- Collection<ScopeDAO> ret = new ArrayList<ScopeDAO>();
-
- for (ScopeDAO sElement : _scopes) {
- if ( sElement.getName().equals(scopeName)) ret.add(sElement);
- }
- return ret;
- }
-
- public Collection<ScopeDAO> getScopes() {
- return _scopes;
- }
-
- public short getState() {
- return _state;
- }
-
- public XmlDataDAO[] getVariables(String variableName, int scopeModelId) {
-
- //TODO: This method is not used and should be considered a deprecation candidate.
-
- List<XmlDataDAO> results = new ArrayList<XmlDataDAO>();
-
- for (ScopeDAO sElement : _scopes) {
- if ( sElement.getModelId() == scopeModelId) {
- XmlDataDAO var = sElement.getVariable(variableName);
- if ( var != null ) results.add(var);
- }
- }
- return results.toArray(new XmlDataDAO[results.size()]);
- }
-
- public void insertBpelEvent(ProcessInstanceEvent event) {
- getConn().insertBpelEvent(event, getProcess(), this);
- }
-
- public void setExecutionState(byte[] execState) {
- _executionState = execState;
- }
-
- public void setFault(FaultDAO fault) {
- _fault = (FaultDAOImpl)fault;
- }
-
- public void setFault(QName faultName, String explanation, int faultLineNo,
- int activityId, Element faultMessage) {
- _fault = new FaultDAOImpl(faultName,explanation,faultLineNo,activityId,faultMessage);
- }
-
- public void setLastActiveTime(Date dt) {
- _lastActive = dt;
- }
-
- public void setState(short state) {
- _previousState = _state;
- _state = state;
- }
-
- void removeRoutes(String routeGroupId) {
- _process.removeRoutes(routeGroupId, this);
- }
-
- public BpelDAOConnection getConnection() {
- return new BPELDAOConnectionImpl(getEM());
- }
-
- public Collection<String> getMessageExchangeIds() {
- Collection<String> c = new HashSet<String>();
- for (MessageExchangeDAO m : _messageExchanges) {
- c.add(m.getMessageExchangeId());
- }
- return c;
- }
-}
Deleted: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessManagementDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessManagementDAOImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessManagementDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,94 +0,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.
- */
-
-package org.apache.ode.dao.jpa;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import javax.xml.namespace.QName;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.common.InstanceFilter;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
-import org.apache.ode.bpel.dao.ProcessManagementDAO;
-import org.apache.ode.bpel.dao.ProcessManagementDAO.FailedSummaryValue;
-import org.apache.ode.bpel.dao.ProcessManagementDAO.InstanceSummaryKey;
-
-public class ProcessManagementDAOImpl implements ProcessManagementDAO {
- private static final Log __log = LogFactory.getLog(ProcessManagementDAOImpl.class);
-
- private EntityManager em;
-
- public ProcessManagementDAOImpl(EntityManager em) {
- this.em = em;
- }
-
- public Object[] findFailedCountAndLastFailedDateForProcessId(BpelDAOConnection conn, String status, String processId) {
- Query query = em.createNamedQuery(ProcessInstanceDAOImpl.COUNT_FAILED_INSTANCES_BY_STATUS_AND_PROCESS_ID);
- query.setParameter("states", new InstanceFilter("status=" + status).convertFilterState());
- query.setParameter("processId", processId);
-
- return (Object[])query.getSingleResult();
- }
-
- public void prefetchActivityFailureCounts(Collection<ProcessInstanceDAO> instances) {
- if(__log.isTraceEnabled()) __log.trace("Prefetching activity failure counts for " + instances.size() + " instances.");
-
- if( instances.isEmpty() ) return;
-
- Query query = em.createNamedQuery(ActivityRecoveryDAOImpl.COUNT_ACTIVITY_RECOVERIES_BY_INSTANCES);
- query.setParameter("instances", instances);
-
- Map<Long, Long> countsByInstanceId = new HashMap<Long, Long>();
- for( Object instanceIdAndCount : query.getResultList() ) {
- Object instanceId = ((Object[])instanceIdAndCount)[0];
- Object count = ((Object[])instanceIdAndCount)[0];
- countsByInstanceId.put((Long)instanceId, (Long)count);
- }
-
- for( ProcessInstanceDAO instance : instances ) {
- Long count = countsByInstanceId.get(instance.getInstanceId());
- if( count != null ) {
- ((ProcessInstanceDAOImpl)instance).setActivityFailureCount(count.intValue());
- }
- }
- }
-
- public int countInstancesByPidAndString(BpelDAOConnection conn, QName pid, String status) {
- InstanceFilter instanceFilter = new InstanceFilter("status=" + status + " pid="+ pid);
-
- // TODO: this is grossly inefficient
- return conn.instanceQuery(instanceFilter).size();
- }
-
- public Map<InstanceSummaryKey, Long> countInstancesSummary(Set<String> pids) {
- return new HashMap<InstanceSummaryKey, Long>();
- }
-
- public Map<String, FailedSummaryValue> findFailedCountAndLastFailedDateForProcessIds(Set<String> pids) {
- return new HashMap<String, FailedSummaryValue>();
- }
-}
Deleted: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ScopeDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ScopeDAOImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ScopeDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,200 +0,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.
- */
-
-package org.apache.ode.dao.jpa;
-
-import org.apache.ode.bpel.dao.CorrelationSetDAO;
-import org.apache.ode.bpel.dao.PartnerLinkDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
-import org.apache.ode.bpel.dao.ScopeDAO;
-import org.apache.ode.bpel.dao.ScopeStateEnum;
-import org.apache.ode.bpel.dao.XmlDataDAO;
-import org.apache.ode.bpel.evt.BpelEvent;
-
-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.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.OneToMany;
-import javax.persistence.Query;
-import javax.persistence.Table;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-@Entity
-@Table(name="ODE_SCOPE")
-@NamedQueries({
- @NamedQuery(name="ScopeEvents", query="SELECT se FROM EventDAOImpl as se WHERE se._scopeId = :sid"),
- @NamedQuery(name=ScopeDAOImpl.SELECT_SCOPE_IDS_BY_PROCESS, query="select s._scopeInstanceId from ScopeDAOImpl as s where s._processInstance._process = :process"),
- @NamedQuery(name=ScopeDAOImpl.SELECT_SCOPE_IDS_BY_INSTANCE, query="select s._scopeInstanceId from ScopeDAOImpl as s where s._processInstance = :instance"),
- @NamedQuery(name=ScopeDAOImpl.DELETE_SCOPES_BY_SCOPE_IDS, query="delete from ScopeDAOImpl as s where s._scopeInstanceId in(:ids)")
-})
-public class ScopeDAOImpl extends OpenJPADAO implements ScopeDAO {
- public final static String SELECT_SCOPE_IDS_BY_PROCESS = "SELECT_SCOPE_IDS_BY_PROCESS";
- public final static String SELECT_SCOPE_IDS_BY_INSTANCE = "SELECT_SCOPE_IDS_BY_INSTANCE";
- public final static String DELETE_SCOPES_BY_SCOPE_IDS = "DELETE_SCOPES_BY_SCOPE_IDS";
-
- @Id @Column(name="SCOPE_ID")
- @GeneratedValue(strategy= GenerationType.AUTO)
- private Long _scopeInstanceId;
-
- @Basic @Column(name="MODEL_ID")
- private int _modelId;
- @Basic @Column(name="SCOPE_NAME")
- private String _name;
- @Basic @Column(name="SCOPE_STATE")
- private String _scopeState;
-
- @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST})
- @Column(name="PARENT_SCOPE_ID")
- private ScopeDAOImpl _parentScope;
-
- @OneToMany(targetEntity=ScopeDAOImpl.class,mappedBy="_parentScope",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
- private Collection<ScopeDAO> _childScopes = new ArrayList<ScopeDAO>();
- @OneToMany(targetEntity=CorrelationSetDAOImpl.class,mappedBy="_scope",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
- private Collection<CorrelationSetDAO> _correlationSets = new ArrayList<CorrelationSetDAO>();
- @OneToMany(targetEntity=PartnerLinkDAOImpl.class,mappedBy="_scope",fetch= FetchType.LAZY,cascade={CascadeType.MERGE, CascadeType.REFRESH, CascadeType.PERSIST})
- private Collection<PartnerLinkDAO> _partnerLinks = new ArrayList<PartnerLinkDAO>();
- @OneToMany(targetEntity=XmlDataDAOImpl.class,mappedBy="_scope",fetch=FetchType.LAZY,cascade={CascadeType.MERGE, CascadeType.REFRESH, CascadeType.PERSIST})
- private Collection<XmlDataDAO> _variables = new ArrayList<XmlDataDAO>();
- @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PROCESS_INSTANCE_ID")
- private ProcessInstanceDAOImpl _processInstance;
-
- public ScopeDAOImpl() {}
- public ScopeDAOImpl(ScopeDAOImpl parentScope, String name, int scopeModelId, ProcessInstanceDAOImpl pi) {
- _parentScope = parentScope;
- _name = name;
- _modelId = scopeModelId;
- _processInstance = pi;
- }
-
- public PartnerLinkDAO createPartnerLink(int plinkModelId, String pLinkName,
- String myRole, String partnerRole) {
- PartnerLinkDAOImpl pl = new PartnerLinkDAOImpl(plinkModelId, pLinkName, myRole, partnerRole);
- pl.setScope(this);
- _partnerLinks.add(pl);
- return pl;
- }
-
- public Collection<ScopeDAO> getChildScopes() {
- return _childScopes;
- }
-
- public CorrelationSetDAO getCorrelationSet(String corrSetName) {
- CorrelationSetDAO ret = null;
- for (CorrelationSetDAO csElement : _correlationSets) {
- if ( csElement.getName().equals(corrSetName)) ret = csElement;
- }
-
- if ( ret == null ) {
- // Apparently the caller knows there should be a correlation set
- // in here. Create a new set if one does not exist.
- // Not sure I understand this implied object creation and why
- // an explicit create pattern isn't used ( i.e. similar to
- // PartnerLink creation )
- ret = new CorrelationSetDAOImpl(this,corrSetName);
- // Persist the new correlation set to generate an ID
- getEM().persist(ret);
- _correlationSets.add(ret);
- }
-
- return ret;
- }
-
- public Collection<CorrelationSetDAO> getCorrelationSets() {
- return _correlationSets;
- }
-
- public int getModelId() {
- return _modelId;
- }
-
- public String getName() {
- return _name;
- }
-
- public ScopeDAO getParentScope() {
- return _parentScope;
- }
-
- public PartnerLinkDAO getPartnerLink(int plinkModelId) {
- for (PartnerLinkDAO pLink : getPartnerLinks()) {
- if (pLink.getPartnerLinkModelId() == plinkModelId) {
- return pLink;
- }
- }
- return null;
- }
-
- public Collection<PartnerLinkDAO> getPartnerLinks() {
- return _partnerLinks;
- }
-
- public ProcessInstanceDAO getProcessInstance() {
- return _processInstance;
- }
-
- public Long getScopeInstanceId() {
- return _scopeInstanceId;
- }
-
- public ScopeStateEnum getState() {
- return new ScopeStateEnum(_scopeState);
- }
-
- public XmlDataDAO getVariable(String varName) {
- XmlDataDAO ret = null;
-
- for (XmlDataDAO xmlElement : _variables) {
- if ( xmlElement.getName().equals(varName)) return xmlElement;
- }
-
- ret = new XmlDataDAOImpl(this,varName);
- _variables.add(ret);
-
- return ret;
- }
-
- public Collection<XmlDataDAO> getVariables() {
- return _variables;
- }
-
- public List<BpelEvent> listEvents() {
- List<BpelEvent> result = new ArrayList<BpelEvent>();
- Query qry = getEM().createNamedQuery("ScopeEvents");
- qry.setParameter("sid", _scopeInstanceId);
- for (Object eventDao : qry.getResultList()) {
- result.add(((EventDAOImpl)eventDao).getEvent());
- }
- return result;
- }
-
- public void setState(ScopeStateEnum state) {
- _scopeState = state.toString();
- }
-
-}
Deleted: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/XmlDataDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/XmlDataDAOImpl.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/XmlDataDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,165 +0,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.
- */
-
-package org.apache.ode.dao.jpa;
-
-import org.apache.ode.bpel.dao.ScopeDAO;
-import org.apache.ode.bpel.dao.XmlDataDAO;
-import org.apache.ode.utils.DOMUtils;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
-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.Lob;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
-import javax.persistence.Transient;
-import java.util.ArrayList;
-import java.util.Collection;
-
-/**
- * @author Matthieu Riou <mriou at apache dot org>
- */
-@Entity
-@Table(name="ODE_XML_DATA")
-@NamedQueries({
- @NamedQuery(name=XmlDataDAOImpl.SELECT_XMLDATA_IDS_BY_PROCESS, query="select distinct x._id from XmlDataDAOImpl as x where x._scope._processInstance._process = :process"),
- @NamedQuery(name=XmlDataDAOImpl.SELECT_XMLDATA_IDS_BY_INSTANCE, query="select distinct x._id from XmlDataDAOImpl as x where x._scope._processInstance = :instance"),
- @NamedQuery(name=XmlDataDAOImpl.DELETE_XMLDATA_BY_SCOPE_IDS, query="delete from XmlDataDAOImpl as x where x._scopeId in(:scopeIds)")
-})
-public class XmlDataDAOImpl implements XmlDataDAO {
- public final static String SELECT_XMLDATA_IDS_BY_PROCESS = "SELECT_XMLDATA_IDS_BY_PROCESS";
- public final static String SELECT_XMLDATA_IDS_BY_INSTANCE = "SELECT_XMLDATA_IDS_BY_INSTANCE";
- public final static String DELETE_XMLDATA_BY_SCOPE_IDS = "DELETE_XMLDATA_BY_SCOPE_IDS";
-
- @Id @Column(name="XML_DATA_ID")
- @GeneratedValue(strategy=GenerationType.AUTO)
- @SuppressWarnings("unused")
- private Long _id;
- @Lob @Column(name="DATA")
- private String _data;
- @Transient
- private Node _node;
- @Basic @Column(name="IS_SIMPLE_TYPE")
- private boolean _isSimpleType;
- @Basic @Column(name="NAME")
- private String _name;
-
- @OneToMany(targetEntity=XmlDataProperty.class,mappedBy="_xmlData",fetch=FetchType.EAGER,cascade={CascadeType.ALL})
- private Collection<XmlDataProperty> _props = new ArrayList<XmlDataProperty>();
-
- @SuppressWarnings("unused")
- @Basic @Column(name="SCOPE_ID", nullable=true, insertable=false, updatable=false)
- private Long _scopeId;
- @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="SCOPE_ID")
- private ScopeDAOImpl _scope;
-
- public XmlDataDAOImpl() {}
- public XmlDataDAOImpl(ScopeDAOImpl scope, String name){
- _scope = scope;
- _name = name;
- }
-
- public Node get() {
- if ( _node == null && _data != null ) {
- if(_isSimpleType){
- Document d = DOMUtils.newDocument();
- // we create a dummy wrapper element
- // prevents some apps from complaining
- // when text node is not actual child of document
- Element e = d.createElement("text-node-wrapper");
- Text tnode = d.createTextNode(_data);
- d.appendChild(e);
- e.appendChild(tnode);
- _node = tnode;
- }else{
- try{
- _node = DOMUtils.stringToDOM(_data);
- }catch(Exception e){
- throw new RuntimeException(e);
- }
- }
- }
-
- return _node;
- }
-
- public String getName() {
- return _name;
- }
-
- public String getProperty(String propertyName) {
- for (XmlDataProperty prop : _props) {
- if (prop.getPropertyKey().equals(propertyName)) return prop.getPropertyValue();
- }
- return null;
- }
-
- private XmlDataProperty getPropertyObject(String propertyName) {
- for (XmlDataProperty prop : _props) {
- if (prop.getPropertyKey().equals(propertyName)) return prop;
- }
- return null;
- }
-
- public ScopeDAO getScopeDAO() {
- return _scope;
- }
-
- public boolean isNull() {
- return _data == null;
- }
-
- public void remove() {
-
- }
-
- public void set(Node val) {
- _node = val;
- if ( val instanceof Element ) {
- _isSimpleType = false;
- _data = DOMUtils.domToString(val);
- } else if (_node != null) {
- _isSimpleType = true;
- _data = _node.getNodeValue();
- }
- }
-
- public void setProperty(String pname, String pvalue) {
- XmlDataProperty prop = getPropertyObject(pname);
- if (prop == null) {
- _props.add(new XmlDataProperty(pname, pvalue, this));
- } else {
- prop.setPropertyValue(pvalue);
- }
- }
-
-}
Deleted: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/XmlDataProperty.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/XmlDataProperty.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/XmlDataProperty.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,87 +0,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.
- */
-
-package org.apache.ode.dao.jpa;
-
-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.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-
-/**
- * @author Matthieu Riou <mriou at apache dot org>
- */
-@Entity
-@Table(name="ODE_XML_DATA_PROP")
-@NamedQueries({
- @NamedQuery(name=XmlDataProperty.DELETE_XML_DATA_PROPERTIES_BY_XML_DATA_IDS, query="delete from XmlDataProperty as p where p._xmlDataId in (:xmlDataIds)")
-})
-public class XmlDataProperty {
- public final static String DELETE_XML_DATA_PROPERTIES_BY_XML_DATA_IDS = "DELETE_XML_DATA_PROPERTIES_BY_XML_DATA_IDS";
-
- @Id @Column(name="ID")
- @GeneratedValue(strategy= GenerationType.AUTO)
- @SuppressWarnings("unused")
- private Long _id;
- @Basic @Column(name="PROP_KEY")
- private String propertyKey;
- @Basic @Column(name="PROP_VALUE")
- private String propertyValue;
-
- @SuppressWarnings("unused")
- @Basic @Column(name="XML_DATA_ID", insertable=false, updatable=false, nullable=true)
- private Long _xmlDataId;
- @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST})
- @Column(name="XML_DATA_ID")
- @SuppressWarnings("unused")
- private XmlDataDAOImpl _xmlData;
-
- public XmlDataProperty() {
- }
- public XmlDataProperty(String propertyKey, String propertyValue, XmlDataDAOImpl xmlData) {
- this.propertyKey = propertyKey;
- this.propertyValue = propertyValue;
- this._xmlData = xmlData;
- }
-
- public String getPropertyKey() {
- return propertyKey;
- }
-
- public void setPropertyKey(String propertyKey) {
- this.propertyKey = propertyKey;
- }
-
- public String getPropertyValue() {
- return propertyValue;
- }
-
- public void setPropertyValue(String propertyValue) {
- this.propertyValue = propertyValue;
- }
-
-}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ActivityRecoveryDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ActivityRecoveryDAOImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ActivityRecoveryDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,151 @@
+/*
+ * 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: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAO.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAO.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAO.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -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.bpel;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @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
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAOConnectionImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAOConnectionImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAOConnectionImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,369 @@
+/*
+ * 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 java.io.Serializable;
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import javax.transaction.TransactionManager;
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.common.BpelEventFilter;
+import org.apache.ode.bpel.common.Filter;
+import org.apache.ode.bpel.common.InstanceFilter;
+import org.apache.ode.bpel.common.ProcessState;
+import org.apache.ode.bpel.evt.BpelEvent;
+import org.apache.ode.bpel.evt.ScopeEvent;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.CorrelationSetDAO;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.ProcessManagementDAO;
+import org.apache.ode.dao.bpel.ScopeDAO;
+import org.apache.ode.dao.jpa.JpaConnection;
+import org.apache.ode.dao.jpa.JpaOperator;
+import org.apache.ode.utils.ISO8601DateParser;
+import org.apache.openjpa.persistence.OpenJPAPersistence;
+import org.apache.openjpa.persistence.OpenJPAQuery;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+public class BpelDAOConnectionImpl extends JpaConnection implements BpelDAOConnection {
+ static final Log __log = LogFactory.getLog(BpelDAOConnectionImpl.class);
+
+ static final ThreadLocal<BpelDAOConnectionImpl> _connections = new ThreadLocal<BpelDAOConnectionImpl>();
+
+ public BpelDAOConnectionImpl(EntityManager mgr, TransactionManager txMgr, JpaOperator operator) {
+ super(mgr, txMgr, operator);
+ }
+
+ public static ThreadLocal<BpelDAOConnectionImpl> getThreadLocal() {
+ return _connections;
+ }
+
+ public List<BpelEvent> bpelEventQuery(InstanceFilter ifilter,
+ BpelEventFilter efilter) {
+ // TODO
+ throw new UnsupportedOperationException();
+ }
+
+ public List<Date> bpelEventTimelineQuery(InstanceFilter ifilter,
+ BpelEventFilter efilter) {
+ // TODO
+ throw new UnsupportedOperationException();
+ }
+
+ public ProcessInstanceDAO getInstance(Long iid) {
+ ProcessInstanceDAOImpl instance = _em.find(ProcessInstanceDAOImpl.class, iid);
+ return instance;
+ }
+
+ public MessageExchangeDAO createMessageExchange(char dir) {
+ MessageExchangeDAOImpl ret = new MessageExchangeDAOImpl(dir);
+ _em.persist(ret);
+ return ret;
+ }
+
+ public ProcessDAO createProcess(QName pid, QName type, String guid, long version) {
+ ProcessDAOImpl ret = new ProcessDAOImpl(pid,type,guid,version);
+ _em.persist(ret);
+ return ret;
+ }
+
+ public ProcessDAO createTransientProcess(Serializable id) {
+ ProcessDAOImpl ret = new ProcessDAOImpl(null, null, null, 0);
+ ret.setId((Long)id);
+
+ return ret;
+ }
+
+ @SuppressWarnings("unchecked")
+ public ProcessDAO getProcess(QName processId) {
+ List l = _em.createQuery("select x from ProcessDAOImpl x where x._processId = ?1")
+ .setParameter(1, processId.toString()).getResultList();
+ if (l.size() == 0) return null;
+ ProcessDAOImpl p = (ProcessDAOImpl) l.get(0);
+ return p;
+ }
+
+ public int getNumInstances(QName processId) {
+ ProcessDAO process = getProcess(processId);
+ if (process != null)
+ return process.getNumInstances();
+ else return -1;
+ }
+
+ public ScopeDAO getScope(Long siidl) {
+ return _em.find(ScopeDAOImpl.class, siidl);
+ }
+
+ public void insertBpelEvent(BpelEvent event, ProcessDAO process, ProcessInstanceDAO instance) {
+ EventDAOImpl eventDao = new EventDAOImpl();
+ eventDao.setTstamp(new Timestamp(System.currentTimeMillis()));
+ eventDao.setType(BpelEvent.eventName(event));
+ String evtStr = event.toString();
+ eventDao.setDetail(evtStr.substring(0, Math.min(254, evtStr.length())));
+ if (process != null)
+ eventDao.setProcess((ProcessDAOImpl) process);
+ if (instance != null)
+ eventDao.setInstance((ProcessInstanceDAOImpl) instance);
+ if (event instanceof ScopeEvent)
+ eventDao.setScopeId(((ScopeEvent) event).getScopeId());
+ eventDao.setEvent(event);
+ _em.persist(eventDao);
+ }
+
+ private static String dateFilter(String filter) {
+ String date = Filter.getDateWithoutOp(filter);
+ String op = filter.substring(0,filter.indexOf(date));
+ Date dt = null;
+ try {
+ dt = ISO8601DateParser.parse(date);
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ Timestamp ts = new Timestamp(dt.getTime());
+ return op + " '" + ts.toString() + "'";
+ }
+
+ @SuppressWarnings("unchecked")
+ public Collection<ProcessInstanceDAO> instanceQuery(InstanceFilter criteria) {
+ StringBuffer query = new StringBuffer();
+ query.append("select pi from ProcessInstanceDAOImpl as pi left join fetch pi._fault ");
+
+ if (criteria != null) {
+ // Building each clause
+ ArrayList<String> clauses = new ArrayList<String>();
+
+ // iid filter
+ if ( criteria.getIidFilter() != null ) {
+ StringBuffer filters = new StringBuffer();
+ List<String> iids = criteria.getIidFilter();
+ for (int m = 0; m < iids.size(); m++) {
+ filters.append(" pi._instanceId = ").append(iids.get(m));
+ if (m < iids.size() - 1) filters.append(" or");
+ }
+ clauses.add(" (" + filters + ")");
+ }
+
+ // pid filter
+ if (criteria.getPidFilter() != null) {
+ StringBuffer filters = new StringBuffer();
+ List<String> pids = criteria.getPidFilter();
+ for (int m = 0; m < pids.size(); m++) {
+ filters.append(" pi._process._processId = '").append(pids.get(m)).append("'");
+ if (m < pids.size() - 1) filters.append(" or");
+ }
+ clauses.add(" (" + filters + ")");
+ }
+
+ // name filter
+ if (criteria.getNameFilter() != null) {
+ String val = criteria.getNameFilter();
+ if (val.endsWith("*")) {
+ val = val.substring(0, val.length()-1) + "%";
+ }
+ //process type string begins with name space
+ //this could possibly match more than you want
+ //because the name space and name are stored together
+ clauses.add(" pi._process._processType like '%" + val + "'");
+ }
+
+ // name space filter
+ if (criteria.getNamespaceFilter() != null) {
+ //process type string begins with name space
+ //this could possibly match more than you want
+ //because the name space and name are stored together
+ clauses.add(" pi._process._processType like '{" +
+ criteria.getNamespaceFilter() + "%'");
+ }
+
+ // started filter
+ if (criteria.getStartedDateFilter() != null) {
+ for ( String ds : criteria.getStartedDateFilter() ) {
+ clauses.add(" pi._dateCreated " + dateFilter(ds));
+ }
+ }
+
+ // last-active filter
+ if (criteria.getLastActiveDateFilter() != null) {
+ for ( String ds : criteria.getLastActiveDateFilter() ) {
+ clauses.add(" pi._lastActive " + dateFilter(ds));
+ }
+ }
+
+ // status filter
+ if (criteria.getStatusFilter() != null) {
+ StringBuffer filters = new StringBuffer();
+ List<Short> states = criteria.convertFilterState();
+ for (int m = 0; m < states.size(); m++) {
+ filters.append(" pi._state = ").append(states.get(m));
+ if (m < states.size() - 1) filters.append(" or");
+ }
+ clauses.add(" (" + filters.toString() + ")");
+ }
+
+ // $property filter
+ if (criteria.getPropertyValuesFilter() != null) {
+ Map<String,String> props = criteria.getPropertyValuesFilter();
+ // join to correlation sets
+ query.append(" inner join pi._rootScope._correlationSets as cs");
+ int i = 0;
+ for (String propKey : props.keySet()) {
+ i++;
+ // join to props for each prop
+ query.append(" inner join cs._props as csp"+i);
+ // add clause for prop key and value
+ clauses.add(" csp"+i+".propertyKey = '"+propKey+
+ "' and csp"+i+".propertyValue = '"+
+ // spaces have to be escaped, might be better handled in InstanceFilter
+ props.get(propKey).replaceAll(" ", " ")+"'");
+ }
+ }
+
+ // order by
+ StringBuffer orderby = new StringBuffer("");
+ if (criteria.getOrders() != null) {
+ orderby.append(" order by");
+ List<String> orders = criteria.getOrders();
+ for (int m = 0; m < orders.size(); m++) {
+ String field = orders.get(m);
+ String ord = " asc";
+ if (field.startsWith("-")) {
+ ord = " desc";
+ }
+ String fieldName = " pi._instanceId";
+ if ( field.endsWith("name") || field.endsWith("namespace")) {
+ fieldName = " pi._process._processType";
+ }
+ if ( field.endsWith("version")) {
+ fieldName = " pi._process._version";
+ }
+ if ( field.endsWith("status")) {
+ fieldName = " pi._state";
+ }
+ if ( field.endsWith("started")) {
+ fieldName = " pi._dateCreated";
+ }
+ if ( field.endsWith("last-active")) {
+ fieldName = " pi._lastActive";
+ }
+ orderby.append(fieldName + ord);
+ if (m < orders.size() - 1) orderby.append(", ");
+ }
+
+ }
+
+ // Preparing the statement
+ if (clauses.size() > 0) {
+ query.append(" where");
+ for (int m = 0; m < clauses.size(); m++) {
+ query.append(clauses.get(m));
+ if (m < clauses.size() - 1) query.append(" and");
+ }
+ }
+
+ query.append(orderby);
+ }
+
+ if (__log.isDebugEnabled()) {
+ __log.debug(query.toString());
+ }
+
+ // criteria limit
+ Query pq = _em.createQuery(query.toString());
+ OpenJPAQuery kq = OpenJPAPersistence.cast(pq);
+ kq.getFetchPlan().setFetchBatchSize(criteria.getLimit());
+ List<ProcessInstanceDAO> ql = pq.getResultList();
+
+ Collection<ProcessInstanceDAO> list = new ArrayList<ProcessInstanceDAO>();
+ int num = 0;
+ for (Iterator iterator = ql.iterator(); iterator.hasNext();) {
+ if(num++ > criteria.getLimit()) break;
+ ProcessInstanceDAO processInstanceDAO = (ProcessInstanceDAO) iterator.next();
+ list.add(processInstanceDAO);
+ }
+
+ return list;
+ }
+
+
+ public Collection<ProcessInstanceDAO> instanceQuery(String expression) {
+ return instanceQuery(new InstanceFilter(expression));
+ }
+
+ public MessageExchangeDAO getMessageExchange(String mexid) {
+ return _em.find(MessageExchangeDAOImpl.class, mexid);
+ }
+
+ public void deleteMessageExchange(MessageExchangeDAO mexDao) {
+ _em.remove(mexDao);
+ }
+
+ public EntityManager getEntityManager() {
+ return _em;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Map<Long, Collection<CorrelationSetDAO>> getCorrelationSets(Collection<ProcessInstanceDAO> instances) {
+ if (instances.size() == 0) {
+ return new HashMap<Long, Collection<CorrelationSetDAO>>();
+ }
+ ArrayList<Long> iids = new ArrayList<Long>(instances.size());
+ for (ProcessInstanceDAO dao: instances) {
+ iids.add(dao.getInstanceId());
+ }
+ Collection<CorrelationSetDAOImpl> csets = _em.createNamedQuery(CorrelationSetDAOImpl.SELECT_CORRELATION_SETS_BY_INSTANCES).setParameter("instances", iids).getResultList();
+ Map<Long, Collection<CorrelationSetDAO>> map = new HashMap<Long, Collection<CorrelationSetDAO>>();
+ for (CorrelationSetDAOImpl cset: csets) {
+ Long id = cset.getScope().getProcessInstance().getInstanceId();
+ Collection<CorrelationSetDAO> existing = map.get(id);
+ if (existing == null) {
+ existing = new ArrayList<CorrelationSetDAO>();
+ map.put(id, existing);
+ }
+ existing.add(cset);
+ }
+ return map;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Collection<CorrelationSetDAO> getActiveCorrelationSets() {
+ return _em.createNamedQuery(CorrelationSetDAOImpl.SELECT_ACTIVE_SETS).setParameter("state", ProcessState.STATE_ACTIVE).getResultList();
+ }
+
+ public ProcessManagementDAO getProcessManagement() {
+ return new ProcessManagementDAOImpl(_em);
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/CorrSetProperty.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/CorrSetProperty.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/CorrSetProperty.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,92 @@
+/*
+ * 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 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.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+@Entity
+@Table(name="ODE_CORSET_PROP")
+@NamedQueries({
+ @NamedQuery(name=CorrSetProperty.DELETE_CORSET_PROPERTIES_BY_PROPERTY_IDS, query="delete from CorrSetProperty as p where p.corrSetId in(:corrSetIds)")
+})
+public class CorrSetProperty {
+ public final static String DELETE_CORSET_PROPERTIES_BY_PROPERTY_IDS = "DELETE_CORSET_PROPERTIES_BY_PROPERTY_IDS";
+
+ @Id @Column(name="ID")
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ @SuppressWarnings("unused")
+ private Long _id;
+ @Basic @Column(name="PROP_KEY")
+ private String propertyKey;
+ @Basic @Column(name="PROP_VALUE")
+ private String propertyValue;
+
+ @SuppressWarnings("unused")
+ @Basic @Column(name="CORRSET_ID", insertable=false, updatable=false, nullable=true)
+ private Long corrSetId;
+
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="CORRSET_ID")
+ private CorrelationSetDAOImpl _corrSet;
+
+ public CorrSetProperty() {
+ }
+ public CorrSetProperty(String propertyKey, String propertyValue) {
+ this.propertyKey = propertyKey;
+ this.propertyValue = propertyValue;
+ }
+
+ public String getPropertyKey() {
+ return propertyKey;
+ }
+
+ public void setPropertyKey(String propertyKey) {
+ this.propertyKey = propertyKey;
+ }
+
+ public String getPropertyValue() {
+ return propertyValue;
+ }
+
+ public void setPropertyValue(String propertyValue) {
+ this.propertyValue = propertyValue;
+ }
+
+ public CorrelationSetDAOImpl getCorrSet() {
+ return _corrSet;
+ }
+
+ public void setCorrSet(CorrelationSetDAOImpl corrSet) {
+ _corrSet = corrSet;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/CorrelationSetDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/CorrelationSetDAOImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/CorrelationSetDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,124 @@
+/*
+ * 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.bpel.common.CorrelationKey;
+import org.apache.ode.dao.bpel.CorrelationSetDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.ScopeDAO;
+
+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.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+@Entity
+@Table(name="ODE_CORRELATION_SET")
+@NamedQueries({
+ @NamedQuery(name=CorrelationSetDAOImpl.DELETE_CORRELATION_SETS_BY_IDS, query="delete from CorrelationSetDAOImpl as c where c._correlationSetId in (:ids)"),
+ @NamedQuery(name=CorrelationSetDAOImpl.SELECT_CORRELATION_SETS_BY_INSTANCES, query="select c from CorrelationSetDAOImpl as c left join fetch c._scope left join fetch c._props where c._scope._processInstance._instanceId in (:instances)"),
+ @NamedQuery(name=CorrelationSetDAOImpl.SELECT_CORRELATION_SET_IDS_BY_PROCESS, query="select c._correlationSetId from CorrelationSetDAOImpl as c where c._scope._processInstance._process = :process"),
+ @NamedQuery(name=CorrelationSetDAOImpl.SELECT_CORRELATION_SET_IDS_BY_INSTANCE, query="select c._correlationSetId from CorrelationSetDAOImpl as c where c._scope._processInstance = :instance"),
+ @NamedQuery(name=CorrelationSetDAOImpl.SELECT_ACTIVE_SETS, query="select c from CorrelationSetDAOImpl as c left join fetch c._scope where c._scope._processInstance._state = (:state)")
+})
+public class CorrelationSetDAOImpl implements CorrelationSetDAO {
+ public final static String DELETE_CORRELATION_SETS_BY_IDS = "DELETE_CORRELATION_SETS_BY_IDS";
+ public final static String SELECT_CORRELATION_SETS_BY_INSTANCES = "SELECT_CORRELATION_SETS_BY_INSTANCES";
+ public final static String SELECT_CORRELATION_SET_IDS_BY_PROCESS = "SELECT_CORRELATION_SET_IDS_BY_PROCESS";
+ public final static String SELECT_CORRELATION_SET_IDS_BY_INSTANCE = "SELECT_CORRELATION_SET_IDS_BY_INSTANCE";
+ public final static String SELECT_ACTIVE_SETS = "SELECT_ACTIVE_SETS";
+
+ @Id @Column(name="CORRELATION_SET_ID")
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ private Long _correlationSetId;
+ @Basic @Column(name="NAME")
+ private String _name;
+ @Basic @Column(name="CORRELATION_KEY")
+ private String _correlationKey;
+
+ @OneToMany(targetEntity=CorrSetProperty.class,mappedBy="_corrSet",fetch=FetchType.LAZY,cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH})
+ private Collection<CorrSetProperty> _props = new ArrayList<CorrSetProperty>();
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="SCOPE_ID")
+ private ScopeDAOImpl _scope;
+
+ public CorrelationSetDAOImpl() {}
+ public CorrelationSetDAOImpl(ScopeDAOImpl scope, String name) {
+ _name = name;
+ _scope = scope;
+ }
+
+ public Long getCorrelationSetId() {
+ return _correlationSetId;
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+ public Map<QName, String> getProperties() {
+ HashMap<QName, String> map = new HashMap<QName, String>();
+ for (CorrSetProperty prop : _props) {
+ map.put(QName.valueOf(prop.getPropertyKey()), prop.getPropertyValue());
+ }
+ return map;
+ }
+
+ public ScopeDAO getScope() {
+ return _scope;
+ }
+
+ public CorrelationKey getValue() {
+ if (_correlationKey == null) return null;
+ return new CorrelationKey(_correlationKey);
+ }
+
+ public void setValue(QName[] names, CorrelationKey values) {
+ _correlationKey = values.toCanonicalString();
+ if (names != null)
+ for (int m = 0; m < names.length; m++) {
+ CorrSetProperty prop = new CorrSetProperty(names[m].toString(), values.getValues()[m]);
+ _props.add(prop);
+ prop.setCorrSet(this);
+ }
+ }
+
+ public ProcessDAO getProcess() {
+ return _scope.getProcessInstance().getProcess();
+ }
+ public ProcessInstanceDAO getInstance() {
+ return _scope.getProcessInstance();
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/CorrelatorDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/CorrelatorDAOImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/CorrelatorDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,199 @@
+/*
+ * 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 org.apache.ode.bpel.common.CorrelationKeySet;
+import org.apache.ode.dao.bpel.*;
+
+import javax.persistence.*;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+@Entity
+@Table(name = "ODE_CORRELATOR")
+@NamedQueries( { @NamedQuery(name = CorrelatorDAOImpl.DELETE_CORRELATORS_BY_PROCESS, query = "delete from CorrelatorDAOImpl as c where c._process = :process") })
+public class CorrelatorDAOImpl extends BpelDAO implements CorrelatorDAO {
+ private static Log __log = LogFactory.getLog(CorrelatorDAOImpl.class);
+ public final static String DELETE_CORRELATORS_BY_PROCESS = "DELETE_CORRELATORS_BY_PROCESS";
+ private final static String ROUTE_BY_CKEY_HEADER = "select route from MessageRouteDAOImpl as route where route._correlator._process._processType = :ptype and route._correlator._correlatorKey = :corrkey";
+
+ @Id
+ @Column(name = "CORRELATOR_ID")
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @SuppressWarnings("unused")
+ private Long _correlatorId;
+ @Basic
+ @Column(name = "CORRELATOR_KEY")
+ private String _correlatorKey;
+ @OneToMany(targetEntity = MessageRouteDAOImpl.class, mappedBy = "_correlator", fetch = FetchType.EAGER, cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH })
+ private Collection<MessageRouteDAOImpl> _routes = new ArrayList<MessageRouteDAOImpl>();
+ @OneToMany(targetEntity = MessageExchangeDAOImpl.class, mappedBy = "_correlator", fetch = FetchType.LAZY, cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH })
+ private Collection<MessageExchangeDAOImpl> _exchanges = new ArrayList<MessageExchangeDAOImpl>();
+ @ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST })
+ @JoinColumn(name = "PROC_ID")
+ private ProcessDAOImpl _process;
+
+ public CorrelatorDAOImpl() {
+ }
+
+ public CorrelatorDAOImpl(String correlatorKey, ProcessDAOImpl process) {
+ _correlatorKey = correlatorKey;
+ _process = process;
+ }
+
+ public void addRoute(String routeGroupId, ProcessInstanceDAO target, int index, CorrelationKeySet correlationKeySet, String routePolicy) {
+ if (__log.isDebugEnabled()) {
+ __log.debug("addRoute " + routeGroupId + " " + target + " " + index + " " + correlationKeySet + " " + routePolicy);
+ }
+ MessageRouteDAOImpl mr = new MessageRouteDAOImpl(correlationKeySet, routeGroupId, index, (ProcessInstanceDAOImpl) target, this, routePolicy);
+ _routes.add(mr);
+ getEM().flush();
+ }
+
+ public MessageExchangeDAO dequeueMessage(CorrelationKeySet correlationKeySet) {
+ // TODO: this thing does not seem to be scalable: loading up based on a correlator???
+ for (Iterator<MessageExchangeDAOImpl> itr = _exchanges.iterator(); itr.hasNext();) {
+ MessageExchangeDAOImpl mex = itr.next();
+ if (mex.getCorrelationKeySet().isRoutableTo(correlationKeySet, false)) {
+ itr.remove();
+ return mex;
+ }
+ }
+ return null;
+ }
+
+ public void enqueueMessage(MessageExchangeDAO mex, CorrelationKeySet correlationKeySet) {
+ MessageExchangeDAOImpl mexImpl = (MessageExchangeDAOImpl) mex;
+ mexImpl.setCorrelationKeySet(correlationKeySet);
+ _exchanges.add(mexImpl);
+ mexImpl.setCorrelator(this);
+ }
+
+ public Collection<CorrelatorMessageDAO> getAllMessages() {
+ return new ArrayList<CorrelatorMessageDAO>(_exchanges);
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<MessageRouteDAO> findRoute(CorrelationKeySet correlationKeySet) {
+ if (__log.isDebugEnabled()) {
+ __log.debug("findRoute " + correlationKeySet);
+ }
+ List<CorrelationKeySet> subSets = correlationKeySet.findSubSets();
+ Query qry = getEM().createQuery(generateSelectorQuery(ROUTE_BY_CKEY_HEADER, subSets));
+ qry.setParameter("ptype", _process.getType().toString());
+ qry.setParameter("corrkey", _correlatorKey);
+ for (int i = 0; i < subSets.size(); i++) {
+ qry.setParameter("s" + i, subSets.get(i).toCanonicalString());
+ }
+
+ List<MessageRouteDAO> candidateRoutes = (List<MessageRouteDAO>) qry.getResultList();
+ if (candidateRoutes.size() > 0) {
+ List<MessageRouteDAO> matchingRoutes = new ArrayList<MessageRouteDAO>();
+ boolean routed = false;
+ for (int i = 0; i < candidateRoutes.size(); i++) {
+ MessageRouteDAO route = candidateRoutes.get(i);
+ if ("all".equals(route.getRoute())) {
+ matchingRoutes.add(route);
+ } else {
+ if (!routed) {
+ matchingRoutes.add(route);
+ }
+ routed = true;
+ }
+ }
+ if (__log.isDebugEnabled()) {
+ __log.debug("findRoute found " + matchingRoutes);
+ }
+ return matchingRoutes;
+ } else {
+ if (__log.isDebugEnabled()) {
+ __log.debug("findRoute found nothing");
+ }
+ return null;
+ }
+ }
+
+ private String generateSelectorQuery(String header, List<CorrelationKeySet> subSets) {
+ StringBuffer filterQuery = new StringBuffer(header);
+
+ if (subSets.size() == 1) {
+ filterQuery.append(" and route._correlationKey = :s0");
+ } else if (subSets.size() > 1) {
+ filterQuery.append(" and route._correlationKey in(");
+ for (int i = 0; i < subSets.size(); i++) {
+ if (i > 0) {
+ filterQuery.append(", ");
+ }
+ filterQuery.append(":s").append(i);
+ }
+ filterQuery.append(")");
+ }
+
+ return filterQuery.toString();
+ }
+
+ public String getCorrelatorId() {
+ return _correlatorKey;
+ }
+
+ public void setCorrelatorId(String newId) {
+ _correlatorKey = newId;
+ }
+
+ public void removeRoutes(String routeGroupId, ProcessInstanceDAO target) {
+ // remove route across all correlators of the process
+ ((ProcessInstanceDAOImpl) target).removeRoutes(routeGroupId);
+ }
+
+ void removeLocalRoutes(String routeGroupId, ProcessInstanceDAO target) {
+ if (__log.isDebugEnabled()) {
+ __log.debug("removeLocalRoutes " + routeGroupId);
+ }
+ boolean flush = false;
+ for (Iterator<MessageRouteDAOImpl> itr = _routes.iterator(); itr.hasNext();) {
+ MessageRouteDAOImpl mr = itr.next();
+ if (mr.getGroupId().equals(routeGroupId) && mr.getTargetInstance().equals(target)) {
+ if (__log.isDebugEnabled()) {
+ __log.debug("removing " + mr.getCorrelationKey() + " " + mr.getIndex() + " " + mr.getRoute());
+ }
+ itr.remove();
+ getEM().remove(mr);
+ flush = true;
+ }
+ }
+ if (flush) {
+ getEM().flush();
+ }
+ }
+
+ public Collection<MessageRouteDAO> getAllRoutes() {
+ return new ArrayList<MessageRouteDAO>(_routes);
+ }
+
+ public boolean checkRoute(CorrelationKeySet correlationKeySet) {
+ // TODO Auto-generated method stub
+ return true;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/EventDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/EventDAOImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/EventDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,139 @@
+/*
+ * 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.bpel.evt.BpelEvent;
+
+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.sql.Timestamp;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+@Entity
+@Table(name="ODE_EVENT")
+@NamedQueries({
+ @NamedQuery(name=EventDAOImpl.SELECT_EVENT_IDS_BY_PROCESS, query="select e._id from EventDAOImpl as e where e._instance._process = :process"),
+ @NamedQuery(name=EventDAOImpl.DELETE_EVENTS_BY_IDS, query="delete from EventDAOImpl as e where e._id in (:ids)"),
+ @NamedQuery(name=EventDAOImpl.DELETE_EVENTS_BY_INSTANCE, query="delete from EventDAOImpl as e where e._instance = :instance")
+})
+public class EventDAOImpl extends BpelDAO {
+ public final static String SELECT_EVENT_IDS_BY_PROCESS = "SELECT_EVENT_IDS_BY_PROCESS";
+ public final static String DELETE_EVENTS_BY_IDS = "DELETE_EVENTS_BY_IDS";
+ public final static String DELETE_EVENTS_BY_INSTANCE = "DELETE_EVENTS_BY_INSTANCE";
+
+ @Id @Column(name="EVENT_ID")
+ @GeneratedValue(strategy= GenerationType.AUTO)
+ private Long _id;
+ @Basic @Column(name="TSTAMP")
+ private Timestamp _tstamp;
+ @Basic @Column(name="TYPE")
+ private String _type;
+ @Basic @Column(name="DETAIL")
+ private String _detail;
+
+ /** Scope identifier, possibly null. */
+ @Basic @Column(name="SCOPE_ID")
+ private Long _scopeId;
+
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="PROCESS_ID")
+ private ProcessDAOImpl _process;
+ @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="INSTANCE_ID")
+ private ProcessInstanceDAOImpl _instance;
+ @Lob @Column(name="DATA")
+ private BpelEvent _event;
+
+ public BpelEvent getEvent() {
+ return _event;
+ }
+
+ public void setEvent(BpelEvent event) {
+ _event = event;
+ }
+
+ public String getDetail() {
+ return _detail;
+ }
+
+ public void setDetail(String detail) {
+ _detail = detail;
+ }
+
+ public Long getId() {
+ return _id;
+ }
+
+ public void setId(Long id) {
+ _id = id;
+ }
+
+ public ProcessInstanceDAOImpl getInstance() {
+ return _instance;
+ }
+
+ public void setInstance(ProcessInstanceDAOImpl instance) {
+ _instance = instance;
+ }
+
+ public ProcessDAOImpl getProcess() {
+ return _process;
+ }
+
+ public void setProcess(ProcessDAOImpl process) {
+ _process = process;
+ }
+
+ public Timestamp getTstamp() {
+ return _tstamp;
+ }
+
+ public void setTstamp(Timestamp tstamp) {
+ _tstamp = tstamp;
+ }
+
+ public String getType() {
+ return _type;
+ }
+
+ public void setType(String type) {
+ _type = type;
+ }
+
+ public Long getScopeId() {
+ return _scopeId;
+ }
+
+ public void setScopeId(Long scopeId) {
+ _scopeId = scopeId;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/FaultDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/FaultDAOImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/FaultDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,100 @@
+/*
+ * 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.FaultDAO;
+import org.apache.ode.utils.DOMUtils;
+import org.w3c.dom.Element;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.xml.namespace.QName;
+
+
+@Entity
+@Table(name="ODE_FAULT")
+@NamedQueries({
+ @NamedQuery(name=FaultDAOImpl.DELETE_FAULTS_BY_IDS, query="delete from FaultDAOImpl as f where f._id in(:ids)")
+})
+public class FaultDAOImpl implements FaultDAO {
+ public final static String DELETE_FAULTS_BY_IDS = "DELETE_FAULTS_BY_IDS";
+
+ @Id @Column(name="FAULT_ID")
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ @SuppressWarnings("unused")
+ private Long _id;
+ @Basic @Column(name="NAME")
+ private String _name;
+ @Basic @Column(name="MESSAGE", length=4000)
+ private String _explanation;
+ @Lob @Column(name="DATA")
+ private String _data;
+ @Basic @Column(name="LINE_NUMBER")
+ private int _lineNo;
+ @Basic @Column(name="ACTIVITY_ID")
+ private int _activityId;
+
+ public FaultDAOImpl() {}
+ public FaultDAOImpl(QName faultName, String explanation, int faultLineNo,
+ int activityId, Element faultMessage) {
+ _name = faultName.toString();
+ _explanation = explanation;
+ _lineNo = faultLineNo;
+ _activityId = activityId;
+ _data = (faultMessage == null)?null:DOMUtils.domToString(faultMessage);
+ }
+
+ public int getActivityId() {
+ return _activityId;
+ }
+
+ public Element getData() {
+ Element ret = null;
+
+ try {
+ ret = (_data == null)?null:DOMUtils.stringToDOM(_data);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ return ret;
+ }
+
+ public String getExplanation() {
+ return _explanation;
+ }
+
+ public int getLineNo() {
+ return _lineNo;
+ }
+
+ public QName getName() {
+ return _name == null ? null : QName.valueOf(_name);
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/JpaTxMgrProvider.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/JpaTxMgrProvider.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/JpaTxMgrProvider.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -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.bpel;
+
+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: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MessageDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MessageDAOImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MessageDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,130 @@
+/*
+ * 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 org.apache.ode.dao.bpel.MessageDAO;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
+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 javax.persistence.Transient;
+import javax.xml.namespace.QName;
+
+@Entity
+@Table(name = "ODE_MESSAGE")
+@NamedQueries( { @NamedQuery(name = MessageDAOImpl.DELETE_MESSAGES_BY_PROCESS, query = "delete from MessageDAOImpl as m where m._messageExchange._process = :process") })
+public class MessageDAOImpl implements MessageDAO {
+ private static Log __log = LogFactory.getLog(MessageDAOImpl.class);
+ public final static String DELETE_MESSAGES_BY_PROCESS = "DELETE_MESSAGES_BY_PROCESS";
+
+ @Id
+ @Column(name = "MESSAGE_ID")
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @SuppressWarnings("unused")
+ private Long _id;
+ @Basic
+ @Column(name = "TYPE")
+ private String _type;
+ @Lob
+ @Column(name = "DATA")
+ private String _data;
+ @Lob
+ @Column(name = "HEADER")
+ private String _header;
+ @ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.ALL })
+ @JoinColumn(name = "MESSAGE_EXCHANGE_ID")
+ private MessageExchangeDAOImpl _messageExchange;
+
+ public MessageDAOImpl() {
+ }
+
+ public MessageDAOImpl(QName type, MessageExchangeDAOImpl me) {
+ _type = type.toString();
+ _messageExchange = me;
+ }
+
+ public Element getData() {
+ if (__log.isDebugEnabled()) {
+ __log.debug("getData " + _id + " " + _data);
+ }
+ try {
+ return _data == null ? null : DOMUtils.stringToDOM(_data);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void setData(Element value) {
+ if (value == null) {
+ if (__log.isDebugEnabled()) {
+ __log.debug("setData " + _id + " null");
+ }
+ return;
+ }
+ _data = DOMUtils.domToString(value);
+
+ if (__log.isDebugEnabled()) {
+ __log.debug("setData " + _id + " " + _data);
+ }
+ }
+
+ public Element getHeader() {
+ try {
+ return _header == null ? null : DOMUtils.stringToDOM(_header);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void setHeader(Element value) {
+ if (value == null)
+ return;
+ _header = DOMUtils.domToString(value);
+ }
+
+ public MessageExchangeDAO getMessageExchange() {
+ return _messageExchange;
+ }
+
+ public QName getType() {
+ return _type == null ? null : QName.valueOf(_type);
+ }
+
+ public void setType(QName type) {
+ _type = type.toString();
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MessageExchangeDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MessageExchangeDAOImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MessageExchangeDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,386 @@
+/*
+ * 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 org.apache.ode.bpel.common.CorrelationKeySet;
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.dao.bpel.*;
+import org.apache.ode.utils.DOMUtils;
+import org.apache.ode.utils.uuid.UUID;
+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.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+@Entity
+@Table(name="ODE_MESSAGE_EXCHANGE")
+@NamedQueries({
+ @NamedQuery(name=MessageExchangeDAOImpl.DELETE_MEXS_BY_PROCESS, query="delete from MessageExchangeDAOImpl as m where m._process = :process"),
+ @NamedQuery(name=MessageExchangeDAOImpl.SELECT_MEX_IDS_BY_PROCESS, query="select m._id from MessageExchangeDAOImpl as m where m._process = :process")
+})
+public class MessageExchangeDAOImpl extends BpelDAO implements MessageExchangeDAO, CorrelatorMessageDAO {
+ private static final Log __log = LogFactory.getLog(MessageExchangeDAOImpl.class);
+
+ public final static String DELETE_MEXS_BY_PROCESS = "DELETE_MEXS_BY_PROCESS";
+ public final static String SELECT_MEX_IDS_BY_PROCESS = "SELECT_MEX_IDS_BY_PROCESS";
+
+ @Id @Column(name="MESSAGE_EXCHANGE_ID")
+ private String _id;
+ @Basic @Column(name="CALLEE")
+ private String _callee;
+ @Basic @Column(name="CHANNEL")
+ private String _channel;
+ @Basic @Column(name="CORRELATION_ID")
+ private String _correlationId;
+ @Basic @Column(name="CORRELATION_STATUS")
+ private String _correlationStatus;
+ @Basic @Column(name="CREATE_TIME")
+ private Date _createTime;
+ @Basic @Column(name="DIRECTION")
+ private char _direction;
+ @Lob @Column(name="EPR")
+ private String _epr;
+ @Transient private
+ Element _eprElement;
+ @Basic @Column(name="FAULT")
+ private String _fault;
+ @Basic @Column(name="FAULT_EXPLANATION")
+ private String _faultExplanation;
+ @Basic @Column(name="OPERATION")
+ private String _operation;
+ @Basic @Column(name="PARTNER_LINK_MODEL_ID")
+ private int _partnerLinkModelId;
+ @Basic @Column(name="PATTERN")
+ private String _pattern;
+ @Basic @Column(name="PORT_TYPE")
+ private String _portType;
+ @Basic @Column(name="PROPAGATE_TRANS")
+ private boolean _propagateTransactionFlag;
+ @Basic @Column(name="STATUS")
+ private String _status;
+ @Basic @Column(name="CORRELATION_KEYS")
+ private String _correlationKeys;
+ @Basic @Column(name="PIPED_ID")
+ private String _pipedMessageExchangeId;
+ @Basic @Column(name="SUBSCRIBER_COUNT")
+ private int _subscriberCount;
+
+ @OneToMany(targetEntity=MexProperty.class,mappedBy="_mex",fetch=FetchType.EAGER,cascade={CascadeType.ALL})
+ private Collection<MexProperty> _props = new ArrayList<MexProperty>();
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="PROCESS_INSTANCE_ID")
+ private ProcessInstanceDAOImpl _processInst;
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="PARTNER_LINK_ID")
+ private PartnerLinkDAOImpl _partnerLink;
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="PROCESS_ID")
+ private ProcessDAOImpl _process;
+ @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.ALL}) @JoinColumn(name="REQUEST_MESSAGE_ID")
+ private MessageDAOImpl _request;
+ @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.ALL}) @JoinColumn(name="RESPONSE_MESSAGE_ID")
+ private MessageDAOImpl _response;
+
+ @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="CORR_ID")
+ private CorrelatorDAOImpl _correlator;
+
+ public MessageExchangeDAOImpl() {
+ }
+
+ public MessageExchangeDAOImpl(char direction){
+ _direction = direction;
+ _id = new UUID().toString();
+ }
+
+ public MessageDAO createMessage(QName type) {
+ MessageDAOImpl ret = new MessageDAOImpl(type,this);
+ return ret ;
+ }
+
+ public QName getCallee() {
+ return _callee == null ? null : QName.valueOf(_callee);
+ }
+
+ public String getChannel() {
+ return _channel;
+ }
+
+ public String getCorrelationId() {
+ return _correlationId;
+ }
+
+ public String getCorrelationStatus() {
+ return _correlationStatus;
+ }
+
+ public Date getCreateTime() {
+ return _createTime;
+ }
+
+ public char getDirection() {
+ return _direction;
+ }
+
+ public Element getEPR() {
+ if ( _eprElement == null && _epr != null && !"".equals(_epr)) {
+ try {
+ _eprElement = DOMUtils.stringToDOM(_epr);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return _eprElement;
+ }
+
+ public QName getFault() {
+ return _fault == null ? null : QName.valueOf(_fault);
+ }
+
+ public String getFaultExplanation() {
+ return _faultExplanation;
+ }
+
+ public ProcessInstanceDAO getInstance() {
+ return _processInst;
+ }
+
+ public String getMessageExchangeId() {
+ //return _messageExchangeId;
+ return _id.toString();
+ }
+
+ public String getOperation() {
+ return _operation;
+ }
+
+ public PartnerLinkDAO getPartnerLink() {
+ return _partnerLink;
+ }
+
+ public int getPartnerLinkModelId() {
+ return _partnerLinkModelId;
+ }
+
+ public String getPattern() {
+ return _pattern;
+ }
+
+ public QName getPortType() {
+ return _portType == null ? null : QName.valueOf(_portType);
+ }
+
+ public ProcessDAO getProcess() {
+ return _process;
+ }
+
+ public boolean getPropagateTransactionFlag() {
+ return _propagateTransactionFlag;
+ }
+
+ public String getProperty(String key) {
+ for (MexProperty prop : _props) {
+ if (prop.getPropertyKey().equals(key)) return prop.getPropertyValue();
+ }
+ return null;
+ }
+
+ public Set<String> getPropertyNames() {
+ HashSet<String> propNames = new HashSet<String>();
+ for (MexProperty prop : _props) {
+ propNames.add(prop.getPropertyKey());
+ }
+ return propNames;
+ }
+
+ public MessageDAO getRequest() {
+ return _request;
+ }
+
+ public MessageDAO getResponse() {
+ return _response;
+ }
+
+ public String getStatus() {
+ return _status;
+ }
+
+ public void setCallee(QName callee) {
+ _callee = callee.toString();
+ }
+
+ public void setChannel(String channel) {
+ _channel = channel;
+ }
+
+ public void setCorrelationId(String correlationId) {
+ _correlationId = correlationId;
+ }
+
+ public void setCorrelationStatus(String cstatus) {
+ _correlationStatus = cstatus;
+ }
+
+ public void setEPR(Element epr) {
+ _eprElement = epr;
+ _epr = DOMUtils.domToString(epr);
+ }
+
+ public void setFault(QName faultType) {
+ _fault = faultType == null ? null : faultType.toString();
+ }
+
+ public void setFaultExplanation(String explanation) {
+ if(explanation != null && explanation.length() > 255)
+ explanation = explanation.substring(0,254);
+ _faultExplanation = explanation;
+ }
+
+ public void setInstance(ProcessInstanceDAO dao) {
+ _processInst = (ProcessInstanceDAOImpl)dao;
+ }
+
+ public void setOperation(String opname) {
+ _operation = opname;
+ }
+
+ public void setPartnerLink(PartnerLinkDAO plinkDAO) {
+ _partnerLink = (PartnerLinkDAOImpl)plinkDAO;
+ }
+
+ public void setPartnerLinkModelId(int modelId) {
+ _partnerLinkModelId = modelId;
+ }
+
+ public void setPattern(String pattern) {
+ _pattern = pattern;
+ }
+
+ public void setPortType(QName porttype) {
+ _portType = porttype.toString();
+ }
+
+ public void setProcess(ProcessDAO process) {
+ _process = (ProcessDAOImpl)process;
+ }
+
+ public void setProperty(String key, String value) {
+ _props.add(new MexProperty(key, value, this));
+ }
+
+ public void setRequest(MessageDAO msg) {
+ _request = (MessageDAOImpl)msg;
+ }
+
+ public void setResponse(MessageDAO msg) {
+ _response = (MessageDAOImpl)msg;
+ }
+
+ public void setStatus(String status) {
+ _status = status;
+ }
+
+ public String getPipedMessageExchangeId() {
+ return _pipedMessageExchangeId;
+ }
+
+ public void setPipedMessageExchangeId(String pipedMessageExchangeId) {
+ _pipedMessageExchangeId = pipedMessageExchangeId;
+ }
+
+ void setCorrelationKeySet(CorrelationKeySet correlationKeySet) {
+ _correlationKeys = correlationKeySet.toCanonicalString();
+ }
+
+ CorrelationKeySet getCorrelationKeySet() {
+ return new CorrelationKeySet(_correlationKeys);
+ }
+
+ public CorrelationKey getCorrelationKey() {
+ if (_correlationKeys == null) return null;
+ return getCorrelationKeySet().iterator().next();
+ }
+
+ public void setCorrelationKey(CorrelationKey ckey) {
+ _correlationKeys = ckey.toCanonicalString();
+ }
+
+
+ public void release(boolean doClean) {
+ if( doClean ) {
+ deleteMessages();
+ }
+ }
+
+ public void releasePremieMessages() {
+ // do nothing; early messages are deleted during CorrelatorDaoImpl().dequeueMessage()
+ }
+
+ public void deleteMessages() {
+ if( __log.isDebugEnabled() ) __log.debug("Deleting message on MEX release.");
+
+ getEM().remove(this); // This deletes MexProperty, REQUEST MessageDAO, RESPONSE MessageDAO
+ }
+
+ public CorrelatorDAOImpl getCorrelator() {
+ return _correlator;
+ }
+
+ public void setCorrelator(CorrelatorDAOImpl correlator) {
+ _correlator = correlator;
+ }
+
+ public int getSubscriberCount() {
+ return _subscriberCount;
+ }
+
+ public void setSubscriberCount(int subscriberCount) {
+ this._subscriberCount = subscriberCount;
+ }
+
+ public void incrementSubscriberCount() {
+ ++_subscriberCount;
+ }
+
+ public void release() {
+ // no-op for now, could be used to do some cleanup
+ }
+
+ public void setCreateTime(Date createTime) {
+ _createTime = createTime;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MessageRouteDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MessageRouteDAOImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MessageRouteDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,119 @@
+/*
+ * 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.bpel.common.CorrelationKey;
+import org.apache.ode.bpel.common.CorrelationKeySet;
+import org.apache.ode.dao.bpel.MessageRouteDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+
+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.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="ODE_MESSAGE_ROUTE")
+@NamedQueries ({
+ @NamedQuery(name=MessageRouteDAOImpl.DELETE_MESSAGE_ROUTES_BY_INSTANCE_IDS, query="delete from MessageRouteDAOImpl as r where r._instanceId in(:instanceIds)"),
+ @NamedQuery(name=MessageRouteDAOImpl.DELETE_MESSAGE_ROUTES_BY_INSTANCE, query="delete from MessageRouteDAOImpl as r where r._processInst = :instance")
+})
+public class MessageRouteDAOImpl implements MessageRouteDAO {
+ public final static String DELETE_MESSAGE_ROUTES_BY_INSTANCE = "DELETE_MESSAGE_ROUTES_BY_INSTANCE";
+ public final static String DELETE_MESSAGE_ROUTES_BY_INSTANCE_IDS = "DELETE_MESSAGE_ROUTES_BY_INSTANCE_IDS";
+
+ @Id @Column(name="MESSAGE_ROUTE_ID")
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ private Long _id;
+ @Basic @Column(name="GROUP_ID")
+ private String _groupId;
+ @Basic @Column(name="ROUTE_INDEX")
+ private int _index;
+ @Basic @Column(name="CORRELATION_KEY")
+ private String _correlationKey;
+ @Basic @Column(name="ROUTE_POLICY", length=16)
+ private String _routePolicy;
+
+ @SuppressWarnings("unused")
+ @Basic @Column(name="PROCESS_INSTANCE_ID", insertable=false, updatable=false, nullable=true)
+ private int _instanceId;
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="PROCESS_INSTANCE_ID")
+ private ProcessInstanceDAOImpl _processInst;
+
+ @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="CORR_ID")
+ @SuppressWarnings("unused")
+ private CorrelatorDAOImpl _correlator;
+
+ public MessageRouteDAOImpl() {}
+ public MessageRouteDAOImpl(CorrelationKeySet keySet, String groupId, int index,
+ ProcessInstanceDAOImpl processInst, CorrelatorDAOImpl correlator, String routePolicy) {
+ _correlationKey = keySet.toCanonicalString();
+ _groupId = groupId;
+ _index = index;
+ _processInst = processInst;
+ _correlator = correlator;
+ _routePolicy = routePolicy;
+ }
+
+ public Long getId() {
+ return _id;
+ }
+
+ public CorrelationKey getCorrelationKey() {
+ return new CorrelationKey(_correlationKey);
+ }
+
+ public void setCorrelationKey(CorrelationKey key) {
+ _correlationKey = key.toCanonicalString();
+ }
+
+ public String getGroupId() {
+ return _groupId;
+ }
+
+ public int getIndex() {
+ return _index;
+ }
+
+ public ProcessInstanceDAO getTargetInstance() {
+ return _processInst;
+ }
+
+ public String getRoute() {
+ return _routePolicy;
+ }
+
+ public CorrelationKeySet getCorrelationKeySet() {
+ return new CorrelationKeySet(_correlationKey);
+ }
+
+ public void setCorrelationKeySet(CorrelationKeySet keySet) {
+ _correlationKey = keySet.toCanonicalString();
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MexProperty.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MexProperty.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MexProperty.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,87 @@
+/*
+ * 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 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.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+@Entity
+@Table(name="ODE_MEX_PROP")
+@NamedQueries({
+ @NamedQuery(name=MexProperty.DELETE_MEX_PROPERTIES_BY_MEX_IDS, query="delete from MexProperty as p where p._mexId in (:mexIds)")
+})
+public class MexProperty {
+ public final static String DELETE_MEX_PROPERTIES_BY_MEX_IDS = "DELETE_MEX_PROPERTIES_BY_MEX_IDS";
+
+ @Id @Column(name="ID")
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ @SuppressWarnings("unused")
+ private Long _id;
+ @Basic @Column(name="PROP_KEY")
+ private String propertyKey;
+ @Basic @Column(name="PROP_VALUE", length=2000)
+ private String propertyValue;
+
+ @SuppressWarnings("unused")
+ @Basic @Column(name="MEX_ID", insertable=false, updatable=false, nullable=true)
+ private String _mexId;
+ @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST})
+ @JoinColumn(name="MEX_ID")
+ @SuppressWarnings("unused")
+ private MessageExchangeDAOImpl _mex;
+
+ public MexProperty() {
+ }
+ public MexProperty(String propertyKey, String propertyValue, MessageExchangeDAOImpl mex) {
+ this.propertyKey = propertyKey;
+ this.propertyValue = propertyValue;
+ this._mex = mex;
+ }
+
+ public String getPropertyKey() {
+ return propertyKey;
+ }
+
+ public void setPropertyKey(String propertyKey) {
+ this.propertyKey = propertyKey;
+ }
+
+ public String getPropertyValue() {
+ return propertyValue;
+ }
+
+ public void setPropertyValue(String propertyValue) {
+ this.propertyValue = propertyValue;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/PartnerLinkDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/PartnerLinkDAOImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/PartnerLinkDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,175 @@
+/*
+ * 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.PartnerLinkDAO;
+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 javax.persistence.Transient;
+import javax.xml.namespace.QName;
+
+@Entity
+@Table(name="ODE_PARTNER_LINK")
+@NamedQueries({
+ @NamedQuery(name=PartnerLinkDAOImpl.DELETE_PARTNER_LINKS_BY_SCOPE_IDS, query="delete from PartnerLinkDAOImpl as l where l._scopeId in (:scopeIds)")
+})
+public class PartnerLinkDAOImpl implements PartnerLinkDAO {
+ public final static String DELETE_PARTNER_LINKS_BY_SCOPE_IDS = "DELETE_PARTNER_LINKS_BY_SCOPE_IDS";
+
+ @Id @Column(name="PARTNER_LINK_ID")
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ @SuppressWarnings("unused")
+ private Long _id;
+ @Lob @Column(name="MY_EPR")
+ private String _myEPR;
+ @Transient
+ private Element _myEPRElement;
+ @Basic @Column(name="MY_ROLE_NAME")
+ private String _myRoleName;
+ @Basic @Column(name="MY_ROLE_SERVICE_NAME")
+ private String _myRoleServiceName;
+ @Basic @Column(name="MY_SESSION_ID")
+ private String _mySessionId;
+ @Lob @Column(name="PARTNER_EPR")
+ private String _partnerEPR;
+ @Transient
+ private Element _partnerEPRElement;
+ @Basic @Column(name="PARTNER_LINK_MODEL_ID")
+ private int _partnerLinkModelId;
+ @Basic @Column(name="PARTNER_LINK_NAME")
+ private String _partnerLinkName;
+ @Basic @Column(name="PARTNER_ROLE_NAME")
+ private String _partnerRoleName;
+ @Basic @Column(name="PARTNER_SESSION_ID")
+ private String _partnerSessionId;
+
+ @SuppressWarnings("unused")
+ @Basic @Column(name="SCOPE_ID", nullable=true, insertable=false, updatable=false)
+ private Long _scopeId;
+ @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="SCOPE_ID")
+ @SuppressWarnings("unused")
+ private ScopeDAOImpl _scope;
+
+ public PartnerLinkDAOImpl() {}
+ public PartnerLinkDAOImpl(int modelId, String name, String myRole, String partnerRole) {
+ _partnerLinkModelId = modelId;
+ _partnerLinkName = name;
+ _myRoleName = myRole;
+ _partnerRoleName = partnerRole;
+ }
+
+ public Element getMyEPR() {
+ if (_myEPRElement == null && _myEPR != null && !"".equals(_myEPR)) {
+ try {
+ _myEPRElement = DOMUtils.stringToDOM(_myEPR);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ return _myEPRElement;
+ }
+
+ public String getMyRoleName() {
+ return _myRoleName;
+ }
+
+ public QName getMyRoleServiceName() {
+ return _myRoleServiceName == null ? null : QName.valueOf(_myRoleServiceName);
+ }
+
+ public String getMySessionId() {
+ return _mySessionId;
+ }
+
+ public Element getPartnerEPR() {
+ if ( _partnerEPRElement == null && _partnerEPR != null && !"".equals(_partnerEPR)) {
+ try {
+ _partnerEPRElement = DOMUtils.stringToDOM(_partnerEPR);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return _partnerEPRElement;
+ }
+
+ public int getPartnerLinkModelId() {
+ return _partnerLinkModelId;
+ }
+
+ public String getPartnerLinkName() {
+ return _partnerLinkName;
+ }
+
+ public String getPartnerRoleName() {
+ return _partnerRoleName;
+ }
+
+ public String getPartnerSessionId() {
+ return _partnerSessionId;
+ }
+
+ public void setMyEPR(Element val) {
+ _myEPRElement = val;
+ _myEPR = DOMUtils.domToString(val);
+
+ }
+
+ public void setMyRoleServiceName(QName svcName) {
+ _myRoleServiceName = svcName.toString();
+
+ }
+
+ public void setMySessionId(String sessionId) {
+ _mySessionId = sessionId;
+
+ }
+
+ public void setPartnerEPR(Element val) {
+ _partnerEPRElement = val;
+ _partnerEPR = DOMUtils.domToString(val);
+
+ }
+
+ public void setPartnerSessionId(String session) {
+ _partnerSessionId = session;
+
+ }
+
+ public void setScope(ScopeDAOImpl scope) {
+ _scope = scope;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessDAOImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,229 @@
+/*
+ * 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 org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.bpel.common.ProcessState;
+import org.apache.ode.dao.bpel.CorrelatorDAO;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+
+import javax.persistence.*;
+import javax.xml.namespace.QName;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+@Entity
+@Table(name="ODE_PROCESS")
+@NamedQueries({
+ @NamedQuery(name="ActiveInstances", query="select i from ProcessInstanceDAOImpl as i where i._process = :process and i._state = :state"),
+ @NamedQuery(name="InstanceByCKey", query="select cs._scope._processInstance from CorrelationSetDAOImpl as cs where cs._correlationKey = :ckey"),
+ @NamedQuery(name="CorrelatorByKey", query="select c from CorrelatorDAOImpl as c where c._correlatorKey = :ckey and c._process = :process")
+})
+public class ProcessDAOImpl extends BpelDAO implements ProcessDAO {
+ private static final Log __log = LogFactory.getLog(ProcessDAOImpl.class);
+
+ @Id @Column(name="ID")
+ @GeneratedValue(strategy= GenerationType.AUTO)
+ private Long _id;
+
+ @Basic @Column(name="PROCESS_ID")
+ private String _processId;
+ @Basic @Column(name="PROCESS_TYPE")
+ private String _processType;
+ @Basic @Column(name="GUID")
+ private String _guid;
+ @Basic @Column(name="VERSION")
+ private long _version;
+
+ @OneToMany(targetEntity=CorrelatorDAOImpl.class,mappedBy="_process",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
+ private Collection<CorrelatorDAOImpl> _correlators = new ArrayList<CorrelatorDAOImpl>();
+
+ public ProcessDAOImpl() {}
+ public ProcessDAOImpl(QName pid, QName type, String guid, long version) {
+ _processId = pid.toString();
+ _processType = type.toString();
+ _guid = guid;
+ _version = version;
+ }
+
+ public Serializable getId() {
+ return _id;
+ }
+
+ public void setId(Long id) {
+ _id = id;
+ }
+
+ public CorrelatorDAO addCorrelator(String correlator) {
+ CorrelatorDAOImpl corr = new CorrelatorDAOImpl(correlator, this);
+ _correlators.add(corr);
+ return corr;
+ }
+
+ @SuppressWarnings("unchecked")
+ public CorrelatorDAO getCorrelator(String correlatorId) {
+ Query qry = getEM().createNamedQuery("CorrelatorByKey");
+ qry.setParameter("ckey", correlatorId);
+ qry.setParameter("process", this);
+ List res = qry.getResultList();
+ if (res.size() == 0) return null;
+ return (CorrelatorDAO) res.get(0);
+ }
+
+ public ProcessInstanceDAO createInstance(CorrelatorDAO instantiatingCorrelator) {
+ ProcessInstanceDAOImpl inst = new ProcessInstanceDAOImpl((CorrelatorDAOImpl)instantiatingCorrelator, this);
+ getEM().persist(inst);
+ return inst;
+ }
+
+ public ProcessInstanceDAO createInstance(CorrelatorDAO instantiatingCorrelator, MessageExchangeDAO mex) {
+ ProcessInstanceDAOImpl inst = new ProcessInstanceDAOImpl((CorrelatorDAOImpl)instantiatingCorrelator, this);
+ getEM().persist(inst);
+ return inst;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Collection<ProcessInstanceDAO> findInstance(CorrelationKey ckey) {
+ Query qry = getEM().createNamedQuery("InstanceByCKey");
+ qry.setParameter("ckey", ckey.toCanonicalString());
+ return qry.getResultList();
+ }
+
+ public ProcessInstanceDAO getInstance(Long iid) {
+ return getEM().find(ProcessInstanceDAOImpl.class, iid);
+ }
+
+ public QName getProcessId() {
+ return QName.valueOf(_processId);
+ }
+
+ public QName getType() {
+ return QName.valueOf(_processType);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void deleteProcessAndRoutes() {
+ // delete routes
+ Collection instanceIds = getEM().createNamedQuery(ProcessInstanceDAOImpl.SELECT_INSTANCE_IDS_BY_PROCESS).setParameter("process", this).getResultList();
+ batchUpdateByIds(instanceIds.iterator(), getEM().createNamedQuery(MessageRouteDAOImpl.DELETE_MESSAGE_ROUTES_BY_INSTANCE_IDS), "instanceIds");
+ getEM().createNamedQuery(CorrelatorDAOImpl.DELETE_CORRELATORS_BY_PROCESS).setParameter("process", this).executeUpdate();
+
+ deleteInstances(Integer.MAX_VALUE);
+
+ // delete process dao
+ getEM().remove(this); // This deletes CorrelatorDAO
+ getEM().flush();
+ }
+
+ private int deleteInstances(int transactionSize) {
+ if(__log.isDebugEnabled()) __log.debug("Cleaning up process data.");
+
+ deleteEvents();
+ deleteCorrelations();
+ deleteMessages();
+ deleteVariables();
+ deleteProcessInstances();
+
+ return 0;
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteProcessInstances() {
+ Collection faultIds = getEM().createNamedQuery(ProcessInstanceDAOImpl.SELECT_FAULT_IDS_BY_PROCESS).setParameter("process", this).getResultList();
+ batchUpdateByIds(faultIds.iterator(), getEM().createNamedQuery(FaultDAOImpl.DELETE_FAULTS_BY_IDS), "ids");
+ Collection instanceIds = getEM().createNamedQuery(ProcessInstanceDAOImpl.SELECT_INSTANCE_IDS_BY_PROCESS).setParameter("process", this).getResultList();
+ batchUpdateByIds(instanceIds.iterator(), getEM().createNamedQuery(ActivityRecoveryDAOImpl.DELETE_ACTIVITY_RECOVERIES_BY_IDS), "ids");
+ getEM().createNamedQuery(ProcessInstanceDAOImpl.DELETE_INSTANCES_BY_PROCESS).setParameter("process", this).executeUpdate();
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteVariables() {
+ Collection xmlDataIds = getEM().createNamedQuery(XmlDataDAOImpl.SELECT_XMLDATA_IDS_BY_PROCESS).setParameter("process", this).getResultList();
+ batchUpdateByIds(xmlDataIds.iterator(), getEM().createNamedQuery(XmlDataProperty.DELETE_XML_DATA_PROPERTIES_BY_XML_DATA_IDS), "xmlDataIds");
+ Collection scopeIds = getEM().createNamedQuery(ScopeDAOImpl.SELECT_SCOPE_IDS_BY_PROCESS).setParameter("process", this).getResultList();
+ batchUpdateByIds(scopeIds.iterator(), getEM().createNamedQuery(XmlDataDAOImpl.DELETE_XMLDATA_BY_SCOPE_IDS), "scopeIds");
+
+// Collection scopeIds = getEM().createNamedQuery(ScopeDAOImpl.SELECT_SCOPE_IDS_BY_PROCESS).setParameter("process", this).getResultList();
+ batchUpdateByIds(scopeIds.iterator(), getEM().createNamedQuery(PartnerLinkDAOImpl.DELETE_PARTNER_LINKS_BY_SCOPE_IDS), "scopeIds");
+ batchUpdateByIds(scopeIds.iterator(), getEM().createNamedQuery(ScopeDAOImpl.DELETE_SCOPES_BY_SCOPE_IDS), "ids");
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteMessages() {
+ getEM().createNamedQuery(MessageDAOImpl.DELETE_MESSAGES_BY_PROCESS).setParameter("process", this).executeUpdate();
+ Collection mexIds = getEM().createNamedQuery(MessageExchangeDAOImpl.SELECT_MEX_IDS_BY_PROCESS).setParameter("process", this).getResultList();
+ batchUpdateByIds(mexIds.iterator(), getEM().createNamedQuery(MexProperty.DELETE_MEX_PROPERTIES_BY_MEX_IDS), "mexIds");
+ getEM().createNamedQuery(MessageExchangeDAOImpl.DELETE_MEXS_BY_PROCESS).setParameter("process", this).executeUpdate();
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteCorrelations() {
+ Collection corrSetIds = getEM().createNamedQuery(CorrelationSetDAOImpl.SELECT_CORRELATION_SET_IDS_BY_PROCESS).setParameter("process", this).getResultList();
+ batchUpdateByIds(corrSetIds.iterator(), getEM().createNamedQuery(CorrSetProperty.DELETE_CORSET_PROPERTIES_BY_PROPERTY_IDS), "corrSetIds");
+ batchUpdateByIds(corrSetIds.iterator(), getEM().createNamedQuery(CorrelationSetDAOImpl.DELETE_CORRELATION_SETS_BY_IDS), "ids");
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteEvents() {
+ Collection eventIds = getEM().createNamedQuery(EventDAOImpl.SELECT_EVENT_IDS_BY_PROCESS).setParameter("process", this).getResultList();
+ batchUpdateByIds(eventIds.iterator(), getEM().createNamedQuery(EventDAOImpl.DELETE_EVENTS_BY_IDS), "ids");
+ }
+
+ public int getNumInstances() {
+ Long instanceCount = (Long) getSingleResult(getEM().createNamedQuery(ProcessInstanceDAOImpl.COUNT_INSTANCE_IDS_BY_PROCESS).setParameter("process", this));
+ return (instanceCount == null ? 0 : instanceCount.intValue());
+ }
+
+ public long getVersion() {
+ return _version;
+ }
+
+ public void instanceCompleted(ProcessInstanceDAO instance) {
+ // nothing to do here (yet?)
+ }
+
+ public void removeRoutes(String routeId, ProcessInstanceDAO target) {
+ for (CorrelatorDAO c : _correlators) {
+ ((CorrelatorDAOImpl)c).removeLocalRoutes(routeId, target);
+ }
+ }
+
+ public String getGuid() {
+ return _guid;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Collection<ProcessInstanceDAO> getActiveInstances() {
+ Query qry = getEM().createNamedQuery("ActiveInstances");
+ qry.setParameter("process", this);
+ qry.setParameter("state", ProcessState.STATE_ACTIVE);
+ return qry.getResultList();
+ }
+}
\ No newline at end of file
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessInstanceDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessInstanceDAOImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessInstanceDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,408 @@
+/*
+ * 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 org.apache.ode.bpel.common.ProcessState;
+import org.apache.ode.bpel.evt.ProcessInstanceEvent;
+import org.apache.ode.bpel.iapi.ProcessConf.CLEANUP_CATEGORY;
+import org.apache.ode.dao.bpel.ActivityRecoveryDAO;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.CorrelationSetDAO;
+import org.apache.ode.dao.bpel.CorrelatorDAO;
+import org.apache.ode.dao.bpel.FaultDAO;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.ScopeDAO;
+import org.apache.ode.dao.bpel.ScopeStateEnum;
+import org.apache.ode.dao.bpel.XmlDataDAO;
+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.OneToMany;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+@Entity
+@Table(name="ODE_PROCESS_INSTANCE")
+@NamedQueries({
+ @NamedQuery(name=ProcessInstanceDAOImpl.DELETE_INSTANCES_BY_PROCESS, query="delete from ProcessInstanceDAOImpl as i where i._process = :process"),
+ @NamedQuery(name=ProcessInstanceDAOImpl.SELECT_INSTANCE_IDS_BY_PROCESS, query="select i._instanceId from ProcessInstanceDAOImpl as i where i._process = :process"),
+ @NamedQuery(name=ProcessInstanceDAOImpl.COUNT_INSTANCE_IDS_BY_PROCESS, query="select count(i._instanceId) from ProcessInstanceDAOImpl as i where i._process = :process"),
+ @NamedQuery(name=ProcessInstanceDAOImpl.SELECT_FAULT_IDS_BY_PROCESS, query="select i._faultId from ProcessInstanceDAOImpl as i where i._process = :process and i._faultId is not null"),
+ @NamedQuery(name=ProcessInstanceDAOImpl.COUNT_FAILED_INSTANCES_BY_STATUS_AND_PROCESS_ID,
+ query="select count(i._instanceId), max(i._lastRecovery) from ProcessInstanceDAOImpl as i where i._process._processId = :processId and i._state in(:states) and exists(select r from ActivityRecoveryDAOImpl r where i = r._instance)")
+})
+public class ProcessInstanceDAOImpl extends BpelDAO implements ProcessInstanceDAO {
+ private static final Log __log = LogFactory.getLog(ProcessInstanceDAOImpl.class);
+
+ public final static String DELETE_INSTANCES_BY_PROCESS = "DELETE_INSTANCES_BY_PROCESS";
+ public final static String SELECT_INSTANCE_IDS_BY_PROCESS = "SELECT_INSTANCE_IDS_BY_PROCESS";
+ public final static String COUNT_INSTANCE_IDS_BY_PROCESS = "COUNT_INSTANCE_IDS_BY_PROCESS";
+
+ public final static String SELECT_FAULT_IDS_BY_PROCESS = "SELECT_FAULT_IDS_BY_PROCESS";
+ public final static String COUNT_FAILED_INSTANCES_BY_STATUS_AND_PROCESS_ID = "COUNT_FAILED_INSTANCES_BY_STATUS_AND_PROCESS_ID";
+
+ @Id @Column(name="ID")
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ private Long _instanceId;
+ @Basic @Column(name="LAST_RECOVERY_DATE")
+ private Date _lastRecovery;
+ @Basic @Column(name="LAST_ACTIVE_TIME")
+ private Date _lastActive;
+ @Basic @Column(name="INSTANCE_STATE")
+ private short _state;
+ @Basic @Column(name="PREVIOUS_STATE")
+ private short _previousState;
+ @Lob @Column(name="EXECUTION_STATE")
+ private byte[] _executionState;
+ @Basic @Column(name="SEQUENCE")
+ private long _sequence;
+ @Basic @Column(name="DATE_CREATED")
+ private Date _dateCreated = new Date();
+
+ @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}) @JoinColumn(name="ROOT_SCOPE_ID")
+ private ScopeDAOImpl _rootScope;
+ @OneToMany(targetEntity=ScopeDAOImpl.class,mappedBy="_processInstance",fetch=FetchType.LAZY,cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH})
+ private Collection<ScopeDAO> _scopes = new ArrayList<ScopeDAO>();
+ @OneToMany(targetEntity=ActivityRecoveryDAOImpl.class,mappedBy="_instance",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
+ private Collection<ActivityRecoveryDAO> _recoveries = new ArrayList<ActivityRecoveryDAO>();
+
+ @SuppressWarnings("unused")
+ @Basic @Column(name="FAULT_ID", insertable=false, updatable=false, nullable=true)
+ private long _faultId;
+ @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}) @JoinColumn(name="FAULT_ID")
+ private FaultDAOImpl _fault;
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="PROCESS_ID")
+ private ProcessDAOImpl _process;
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="INSTANTIATING_CORRELATOR_ID")
+ private CorrelatorDAOImpl _instantiatingCorrelator;
+
+ @OneToMany(targetEntity=MessageExchangeDAOImpl.class,mappedBy="_processInst",fetch=FetchType.LAZY)
+ @SuppressWarnings("unused")
+ private Collection<MessageExchangeDAO> _messageExchanges = new ArrayList<MessageExchangeDAO>();
+
+ private transient int _activityFailureCount = -1;
+
+ public ProcessInstanceDAOImpl() {}
+ public ProcessInstanceDAOImpl(CorrelatorDAOImpl correlator, ProcessDAOImpl process) {
+ _instantiatingCorrelator = correlator;
+ _process = process;
+ }
+
+ public void createActivityRecovery(String channel, long activityId,
+ String reason, Date dateTime, Element data, String[] actions,
+ int retries) {
+ ActivityRecoveryDAOImpl ar = new ActivityRecoveryDAOImpl(channel, activityId, reason, dateTime, data, actions, retries);
+ _recoveries.add(ar);
+ ar.setInstance(this);
+ _lastRecovery = dateTime;
+ }
+
+ public ScopeDAO createScope(ScopeDAO parentScope, String name, int scopeModelId) {
+ ScopeDAOImpl ret = new ScopeDAOImpl((ScopeDAOImpl)parentScope,name,scopeModelId,this);
+ ret.setState(ScopeStateEnum.ACTIVE);
+ _scopes.add(ret);
+ _rootScope = (parentScope == null)?ret:_rootScope;
+
+ // Must persist the scope to generate a scope ID
+ getEM().persist(ret);
+ return ret;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Collection<CorrelationSetDAO> selectCorrelationSets(Collection<ProcessInstanceDAO> instances) {
+ return getEM().createNamedQuery(CorrelationSetDAOImpl.SELECT_CORRELATION_SETS_BY_INSTANCES).setParameter("instances", instances).getResultList();
+ }
+
+ public void delete(Set<CLEANUP_CATEGORY> cleanupCategories) {
+ delete(cleanupCategories, true);
+ }
+
+ public void delete(Set<CLEANUP_CATEGORY> cleanupCategories, boolean deleteMyRoleMex) {
+ if(__log.isDebugEnabled()) __log.debug("Cleaning up instance Data with " + cleanupCategories);
+
+ // remove jacob state
+ setExecutionState(null);
+ if (getEM() != null) {
+ if( !cleanupCategories.isEmpty() ) {
+ // by default, we do not flush before select; flush it, so we can delete no matter if an entity is loaded up
+ // or not; more importantly, OpenJPA will secretly load from the entire table if some entities reside only
+ // in memory
+ getEM().flush();
+ }
+
+ if (cleanupCategories.contains(CLEANUP_CATEGORY.EVENTS)) {
+ deleteEvents();
+ }
+ if (cleanupCategories.contains(CLEANUP_CATEGORY.CORRELATIONS)) {
+ deleteCorrelations();
+ }
+ if( cleanupCategories.contains(CLEANUP_CATEGORY.MESSAGES) ) {
+ deleteMessageRoutes();
+ }
+ if (cleanupCategories.contains(CLEANUP_CATEGORY.VARIABLES)) {
+ deleteVariables();
+ }
+ if (cleanupCategories.contains(CLEANUP_CATEGORY.INSTANCE)) {
+ deleteInstance();
+ }
+
+ getEM().flush();
+ }
+ }
+
+ private void deleteInstance() {
+ if( _fault != null ) {
+ getEM().remove(_fault);
+ }
+ getEM().remove(this); // This deletes ActivityRecoveryDAO
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteVariables() {
+ Collection xmlDataIds = getEM().createNamedQuery(XmlDataDAOImpl.SELECT_XMLDATA_IDS_BY_INSTANCE).setParameter("instance", this).getResultList();
+ batchUpdateByIds(xmlDataIds.iterator(), getEM().createNamedQuery(XmlDataProperty.DELETE_XML_DATA_PROPERTIES_BY_XML_DATA_IDS), "xmlDataIds");
+ Collection scopeIds = getEM().createNamedQuery(ScopeDAOImpl.SELECT_SCOPE_IDS_BY_INSTANCE).setParameter("instance", this).getResultList();
+ batchUpdateByIds(scopeIds.iterator(), getEM().createNamedQuery(XmlDataDAOImpl.DELETE_XMLDATA_BY_SCOPE_IDS), "scopeIds");
+
+ batchUpdateByIds(scopeIds.iterator(), getEM().createNamedQuery(PartnerLinkDAOImpl.DELETE_PARTNER_LINKS_BY_SCOPE_IDS), "scopeIds");
+ batchUpdateByIds(scopeIds.iterator(), getEM().createNamedQuery(ScopeDAOImpl.DELETE_SCOPES_BY_SCOPE_IDS), "ids");
+ }
+
+ private void deleteMessageRoutes() {
+ getEM().createNamedQuery(MessageRouteDAOImpl.DELETE_MESSAGE_ROUTES_BY_INSTANCE).setParameter ("instance", this).executeUpdate();
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteCorrelations() {
+ Collection corrSetIds = getEM().createNamedQuery(CorrelationSetDAOImpl.SELECT_CORRELATION_SET_IDS_BY_INSTANCE).setParameter("instance", this).getResultList();
+ batchUpdateByIds(corrSetIds.iterator(), getEM().createNamedQuery(CorrSetProperty.DELETE_CORSET_PROPERTIES_BY_PROPERTY_IDS), "corrSetIds");
+ batchUpdateByIds(corrSetIds.iterator(), getEM().createNamedQuery(CorrelationSetDAOImpl.DELETE_CORRELATION_SETS_BY_IDS), "ids");
+ }
+
+ private void deleteEvents() {
+ getEM().createNamedQuery(EventDAOImpl.DELETE_EVENTS_BY_INSTANCE).setParameter ("instance", this).executeUpdate();
+ }
+
+ public void deleteActivityRecovery(String channel) {
+ ActivityRecoveryDAOImpl toRemove = null;
+ for (ActivityRecoveryDAO _recovery : _recoveries) {
+ ActivityRecoveryDAOImpl arElement = (ActivityRecoveryDAOImpl) _recovery;
+ if (arElement.getChannel().equals(channel)) {
+ toRemove = arElement;
+ break;
+ }
+ }
+ if (toRemove != null) {
+ getEM().remove(toRemove);
+ _recoveries.remove(toRemove);
+ }
+
+ }
+
+ public void finishCompletion() {
+ // make sure we have completed.
+ assert (ProcessState.isFinished(this.getState()));
+ // let our process know that we've done our work.
+ }
+
+ public long genMonotonic() {
+ return _sequence++;
+ }
+
+ public int getActivityFailureCount() {
+ if( _activityFailureCount == -1 ) {
+ _activityFailureCount = _recoveries.size();
+ }
+
+ return _activityFailureCount;
+ }
+
+ public void setActivityFailureCount(int activityFailureCount) {
+ _activityFailureCount = activityFailureCount;
+ }
+
+ public Date getActivityFailureDateTime() {
+ return _lastRecovery;
+ }
+
+ public Collection<ActivityRecoveryDAO> getActivityRecoveries() {
+ return _recoveries;
+ }
+
+ public CorrelationSetDAO getCorrelationSet(String name) {
+ // TODO: should this method be deprecated?
+
+ // Its not clear where the correlation set for the process is used
+ // or populated.
+
+ throw new UnsupportedOperationException();
+
+ //return null;
+ }
+
+ public Set<CorrelationSetDAO> getCorrelationSets() {
+ // TODO: should this method be deprecated?
+ // Its not clear where the correlation set for the process is used
+ // or populated.
+ return new HashSet<CorrelationSetDAO>();
+ }
+
+ public Date getCreateTime() {
+ return _dateCreated;
+ }
+
+ public EventsFirstLastCountTuple getEventsFirstLastCount() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public byte[] getExecutionState() {
+ return _executionState;
+ }
+
+ public FaultDAO getFault() {
+ return _fault;
+ }
+
+ public Long getInstanceId() {
+ return _instanceId;
+ }
+
+ public CorrelatorDAO getInstantiatingCorrelator() {
+ return _instantiatingCorrelator;
+ }
+
+ public Date getLastActiveTime() {
+ return _lastActive;
+ }
+
+ public short getPreviousState() {
+ return _previousState;
+ }
+
+ public ProcessDAO getProcess() {
+ return _process;
+ }
+
+ public ScopeDAO getRootScope() {
+ return _rootScope;
+ }
+
+ public ScopeDAO getScope(Long scopeInstanceId) {
+ return getEM().find(ScopeDAOImpl.class, scopeInstanceId);
+ }
+
+ public Collection<ScopeDAO> getScopes(String scopeName) {
+ Collection<ScopeDAO> ret = new ArrayList<ScopeDAO>();
+
+ for (ScopeDAO sElement : _scopes) {
+ if ( sElement.getName().equals(scopeName)) ret.add(sElement);
+ }
+ return ret;
+ }
+
+ public Collection<ScopeDAO> getScopes() {
+ return _scopes;
+ }
+
+ public short getState() {
+ return _state;
+ }
+
+ public XmlDataDAO[] getVariables(String variableName, int scopeModelId) {
+
+ //TODO: This method is not used and should be considered a deprecation candidate.
+
+ List<XmlDataDAO> results = new ArrayList<XmlDataDAO>();
+
+ for (ScopeDAO sElement : _scopes) {
+ if ( sElement.getModelId() == scopeModelId) {
+ XmlDataDAO var = sElement.getVariable(variableName);
+ if ( var != null ) results.add(var);
+ }
+ }
+ return results.toArray(new XmlDataDAO[results.size()]);
+ }
+
+ public void insertBpelEvent(ProcessInstanceEvent event) {
+ getConn().insertBpelEvent(event, getProcess(), this);
+ }
+
+ public void setExecutionState(byte[] execState) {
+ _executionState = execState;
+ }
+
+ public void setFault(FaultDAO fault) {
+ _fault = (FaultDAOImpl)fault;
+ }
+
+ public void setFault(QName faultName, String explanation, int faultLineNo,
+ int activityId, Element faultMessage) {
+ _fault = new FaultDAOImpl(faultName,explanation,faultLineNo,activityId,faultMessage);
+ }
+
+ public void setLastActiveTime(Date dt) {
+ _lastActive = dt;
+ }
+
+ public void setState(short state) {
+ _previousState = _state;
+ _state = state;
+ }
+
+ void removeRoutes(String routeGroupId) {
+ _process.removeRoutes(routeGroupId, this);
+ }
+
+ public BpelDAOConnection getConnection() {
+ return BpelDAOConnectionImpl.getThreadLocal().get();
+ }
+
+ public Collection<String> getMessageExchangeIds() {
+ Collection<String> c = new HashSet<String>();
+ for (MessageExchangeDAO m : _messageExchanges) {
+ c.add(m.getMessageExchangeId());
+ }
+ return c;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessManagementDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessManagementDAOImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessManagementDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,94 @@
+/*
+ * 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 java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import javax.xml.namespace.QName;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.common.InstanceFilter;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.ProcessManagementDAO;
+import org.apache.ode.dao.bpel.ProcessManagementDAO.FailedSummaryValue;
+import org.apache.ode.dao.bpel.ProcessManagementDAO.InstanceSummaryKey;
+
+public class ProcessManagementDAOImpl implements ProcessManagementDAO {
+ private static final Log __log = LogFactory.getLog(ProcessManagementDAOImpl.class);
+
+ private EntityManager em;
+
+ public ProcessManagementDAOImpl(EntityManager em) {
+ this.em = em;
+ }
+
+ public Object[] findFailedCountAndLastFailedDateForProcessId(BpelDAOConnection conn, String status, String processId) {
+ Query query = em.createNamedQuery(ProcessInstanceDAOImpl.COUNT_FAILED_INSTANCES_BY_STATUS_AND_PROCESS_ID);
+ query.setParameter("states", new InstanceFilter("status=" + status).convertFilterState());
+ query.setParameter("processId", processId);
+
+ return (Object[])query.getSingleResult();
+ }
+
+ public void prefetchActivityFailureCounts(Collection<ProcessInstanceDAO> instances) {
+ if(__log.isTraceEnabled()) __log.trace("Prefetching activity failure counts for " + instances.size() + " instances.");
+
+ if( instances.isEmpty() ) return;
+
+ Query query = em.createNamedQuery(ActivityRecoveryDAOImpl.COUNT_ACTIVITY_RECOVERIES_BY_INSTANCES);
+ query.setParameter("instances", instances);
+
+ Map<Long, Long> countsByInstanceId = new HashMap<Long, Long>();
+ for( Object instanceIdAndCount : query.getResultList() ) {
+ Object instanceId = ((Object[])instanceIdAndCount)[0];
+ Object count = ((Object[])instanceIdAndCount)[0];
+ countsByInstanceId.put((Long)instanceId, (Long)count);
+ }
+
+ for( ProcessInstanceDAO instance : instances ) {
+ Long count = countsByInstanceId.get(instance.getInstanceId());
+ if( count != null ) {
+ ((ProcessInstanceDAOImpl)instance).setActivityFailureCount(count.intValue());
+ }
+ }
+ }
+
+ public int countInstancesByPidAndString(BpelDAOConnection conn, QName pid, String status) {
+ InstanceFilter instanceFilter = new InstanceFilter("status=" + status + " pid="+ pid);
+
+ // TODO: this is grossly inefficient
+ return conn.instanceQuery(instanceFilter).size();
+ }
+
+ public Map<InstanceSummaryKey, Long> countInstancesSummary(Set<String> pids) {
+ return new HashMap<InstanceSummaryKey, Long>();
+ }
+
+ public Map<String, FailedSummaryValue> findFailedCountAndLastFailedDateForProcessIds(Set<String> pids) {
+ return new HashMap<String, FailedSummaryValue>();
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ScopeDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ScopeDAOImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ScopeDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,201 @@
+/*
+ * 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.CorrelationSetDAO;
+import org.apache.ode.dao.bpel.PartnerLinkDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.ScopeDAO;
+import org.apache.ode.dao.bpel.ScopeStateEnum;
+import org.apache.ode.dao.bpel.XmlDataDAO;
+import org.apache.ode.bpel.evt.BpelEvent;
+
+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.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.Query;
+import javax.persistence.Table;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+@Entity
+@Table(name="ODE_SCOPE")
+@NamedQueries({
+ @NamedQuery(name="ScopeEvents", query="SELECT se FROM EventDAOImpl as se WHERE se._scopeId = :sid"),
+ @NamedQuery(name=ScopeDAOImpl.SELECT_SCOPE_IDS_BY_PROCESS, query="select s._scopeInstanceId from ScopeDAOImpl as s where s._processInstance._process = :process"),
+ @NamedQuery(name=ScopeDAOImpl.SELECT_SCOPE_IDS_BY_INSTANCE, query="select s._scopeInstanceId from ScopeDAOImpl as s where s._processInstance = :instance"),
+ @NamedQuery(name=ScopeDAOImpl.DELETE_SCOPES_BY_SCOPE_IDS, query="delete from ScopeDAOImpl as s where s._scopeInstanceId in(:ids)")
+})
+public class ScopeDAOImpl extends BpelDAO implements ScopeDAO {
+ public final static String SELECT_SCOPE_IDS_BY_PROCESS = "SELECT_SCOPE_IDS_BY_PROCESS";
+ public final static String SELECT_SCOPE_IDS_BY_INSTANCE = "SELECT_SCOPE_IDS_BY_INSTANCE";
+ public final static String DELETE_SCOPES_BY_SCOPE_IDS = "DELETE_SCOPES_BY_SCOPE_IDS";
+
+ @Id @Column(name="SCOPE_ID")
+ @GeneratedValue(strategy= GenerationType.AUTO)
+ private Long _scopeInstanceId;
+
+ @Basic @Column(name="MODEL_ID")
+ private int _modelId;
+ @Basic @Column(name="SCOPE_NAME")
+ private String _name;
+ @Basic @Column(name="SCOPE_STATE")
+ private String _scopeState;
+
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST})
+ @JoinColumn(name="PARENT_SCOPE_ID")
+ private ScopeDAOImpl _parentScope;
+
+ @OneToMany(targetEntity=ScopeDAOImpl.class,mappedBy="_parentScope",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
+ private Collection<ScopeDAO> _childScopes = new ArrayList<ScopeDAO>();
+ @OneToMany(targetEntity=CorrelationSetDAOImpl.class,mappedBy="_scope",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
+ private Collection<CorrelationSetDAO> _correlationSets = new ArrayList<CorrelationSetDAO>();
+ @OneToMany(targetEntity=PartnerLinkDAOImpl.class,mappedBy="_scope",fetch= FetchType.LAZY,cascade={CascadeType.MERGE, CascadeType.REFRESH, CascadeType.PERSIST})
+ private Collection<PartnerLinkDAO> _partnerLinks = new ArrayList<PartnerLinkDAO>();
+ @OneToMany(targetEntity=XmlDataDAOImpl.class,mappedBy="_scope",fetch=FetchType.LAZY,cascade={CascadeType.MERGE, CascadeType.REFRESH, CascadeType.PERSIST})
+ private Collection<XmlDataDAO> _variables = new ArrayList<XmlDataDAO>();
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="PROCESS_INSTANCE_ID")
+ private ProcessInstanceDAOImpl _processInstance;
+
+ public ScopeDAOImpl() {}
+ public ScopeDAOImpl(ScopeDAOImpl parentScope, String name, int scopeModelId, ProcessInstanceDAOImpl pi) {
+ _parentScope = parentScope;
+ _name = name;
+ _modelId = scopeModelId;
+ _processInstance = pi;
+ }
+
+ public PartnerLinkDAO createPartnerLink(int plinkModelId, String pLinkName,
+ String myRole, String partnerRole) {
+ PartnerLinkDAOImpl pl = new PartnerLinkDAOImpl(plinkModelId, pLinkName, myRole, partnerRole);
+ pl.setScope(this);
+ _partnerLinks.add(pl);
+ return pl;
+ }
+
+ public Collection<ScopeDAO> getChildScopes() {
+ return _childScopes;
+ }
+
+ public CorrelationSetDAO getCorrelationSet(String corrSetName) {
+ CorrelationSetDAO ret = null;
+ for (CorrelationSetDAO csElement : _correlationSets) {
+ if ( csElement.getName().equals(corrSetName)) ret = csElement;
+ }
+
+ if ( ret == null ) {
+ // Apparently the caller knows there should be a correlation set
+ // in here. Create a new set if one does not exist.
+ // Not sure I understand this implied object creation and why
+ // an explicit create pattern isn't used ( i.e. similar to
+ // PartnerLink creation )
+ ret = new CorrelationSetDAOImpl(this,corrSetName);
+ // Persist the new correlation set to generate an ID
+ getEM().persist(ret);
+ _correlationSets.add(ret);
+ }
+
+ return ret;
+ }
+
+ public Collection<CorrelationSetDAO> getCorrelationSets() {
+ return _correlationSets;
+ }
+
+ public int getModelId() {
+ return _modelId;
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+ public ScopeDAO getParentScope() {
+ return _parentScope;
+ }
+
+ public PartnerLinkDAO getPartnerLink(int plinkModelId) {
+ for (PartnerLinkDAO pLink : getPartnerLinks()) {
+ if (pLink.getPartnerLinkModelId() == plinkModelId) {
+ return pLink;
+ }
+ }
+ return null;
+ }
+
+ public Collection<PartnerLinkDAO> getPartnerLinks() {
+ return _partnerLinks;
+ }
+
+ public ProcessInstanceDAO getProcessInstance() {
+ return _processInstance;
+ }
+
+ public Long getScopeInstanceId() {
+ return _scopeInstanceId;
+ }
+
+ public ScopeStateEnum getState() {
+ return new ScopeStateEnum(_scopeState);
+ }
+
+ public XmlDataDAO getVariable(String varName) {
+ XmlDataDAO ret = null;
+
+ for (XmlDataDAO xmlElement : _variables) {
+ if ( xmlElement.getName().equals(varName)) return xmlElement;
+ }
+
+ ret = new XmlDataDAOImpl(this,varName);
+ _variables.add(ret);
+
+ return ret;
+ }
+
+ public Collection<XmlDataDAO> getVariables() {
+ return _variables;
+ }
+
+ public List<BpelEvent> listEvents() {
+ List<BpelEvent> result = new ArrayList<BpelEvent>();
+ Query qry = getEM().createNamedQuery("ScopeEvents");
+ qry.setParameter("sid", _scopeInstanceId);
+ for (Object eventDao : qry.getResultList()) {
+ result.add(((EventDAOImpl)eventDao).getEvent());
+ }
+ return result;
+ }
+
+ public void setState(ScopeStateEnum state) {
+ _scopeState = state.toString();
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/XmlDataDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/XmlDataDAOImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/XmlDataDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,166 @@
+/*
+ * 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.ScopeDAO;
+import org.apache.ode.dao.bpel.XmlDataDAO;
+import org.apache.ode.utils.DOMUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
+
+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.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+@Entity
+@Table(name="ODE_XML_DATA")
+@NamedQueries({
+ @NamedQuery(name=XmlDataDAOImpl.SELECT_XMLDATA_IDS_BY_PROCESS, query="select distinct x._id from XmlDataDAOImpl as x where x._scope._processInstance._process = :process"),
+ @NamedQuery(name=XmlDataDAOImpl.SELECT_XMLDATA_IDS_BY_INSTANCE, query="select distinct x._id from XmlDataDAOImpl as x where x._scope._processInstance = :instance"),
+ @NamedQuery(name=XmlDataDAOImpl.DELETE_XMLDATA_BY_SCOPE_IDS, query="delete from XmlDataDAOImpl as x where x._scopeId in(:scopeIds)")
+})
+public class XmlDataDAOImpl implements XmlDataDAO {
+ public final static String SELECT_XMLDATA_IDS_BY_PROCESS = "SELECT_XMLDATA_IDS_BY_PROCESS";
+ public final static String SELECT_XMLDATA_IDS_BY_INSTANCE = "SELECT_XMLDATA_IDS_BY_INSTANCE";
+ public final static String DELETE_XMLDATA_BY_SCOPE_IDS = "DELETE_XMLDATA_BY_SCOPE_IDS";
+
+ @Id @Column(name="XML_DATA_ID")
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ @SuppressWarnings("unused")
+ private Long _id;
+ @Lob @Column(name="DATA")
+ private String _data;
+ @Transient
+ private Node _node;
+ @Basic @Column(name="IS_SIMPLE_TYPE")
+ private boolean _isSimpleType;
+ @Basic @Column(name="NAME")
+ private String _name;
+
+ @OneToMany(targetEntity=XmlDataProperty.class,mappedBy="_xmlData",fetch=FetchType.EAGER,cascade={CascadeType.ALL})
+ private Collection<XmlDataProperty> _props = new ArrayList<XmlDataProperty>();
+
+ @SuppressWarnings("unused")
+ @Basic @Column(name="SCOPE_ID", nullable=true, insertable=false, updatable=false)
+ private Long _scopeId;
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="SCOPE_ID")
+ private ScopeDAOImpl _scope;
+
+ public XmlDataDAOImpl() {}
+ public XmlDataDAOImpl(ScopeDAOImpl scope, String name){
+ _scope = scope;
+ _name = name;
+ }
+
+ public Node get() {
+ if ( _node == null && _data != null ) {
+ if(_isSimpleType){
+ Document d = DOMUtils.newDocument();
+ // we create a dummy wrapper element
+ // prevents some apps from complaining
+ // when text node is not actual child of document
+ Element e = d.createElement("text-node-wrapper");
+ Text tnode = d.createTextNode(_data);
+ d.appendChild(e);
+ e.appendChild(tnode);
+ _node = tnode;
+ }else{
+ try{
+ _node = DOMUtils.stringToDOM(_data);
+ }catch(Exception e){
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ return _node;
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+ public String getProperty(String propertyName) {
+ for (XmlDataProperty prop : _props) {
+ if (prop.getPropertyKey().equals(propertyName)) return prop.getPropertyValue();
+ }
+ return null;
+ }
+
+ private XmlDataProperty getPropertyObject(String propertyName) {
+ for (XmlDataProperty prop : _props) {
+ if (prop.getPropertyKey().equals(propertyName)) return prop;
+ }
+ return null;
+ }
+
+ public ScopeDAO getScopeDAO() {
+ return _scope;
+ }
+
+ public boolean isNull() {
+ return _data == null;
+ }
+
+ public void remove() {
+
+ }
+
+ public void set(Node val) {
+ _node = val;
+ if ( val instanceof Element ) {
+ _isSimpleType = false;
+ _data = DOMUtils.domToString(val);
+ } else if (_node != null) {
+ _isSimpleType = true;
+ _data = _node.getNodeValue();
+ }
+ }
+
+ public void setProperty(String pname, String pvalue) {
+ XmlDataProperty prop = getPropertyObject(pname);
+ if (prop == null) {
+ _props.add(new XmlDataProperty(pname, pvalue, this));
+ } else {
+ prop.setPropertyValue(pvalue);
+ }
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/XmlDataProperty.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/XmlDataProperty.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/XmlDataProperty.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,88 @@
+/*
+ * 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 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.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+@Entity
+@Table(name="ODE_XML_DATA_PROP")
+@NamedQueries({
+ @NamedQuery(name=XmlDataProperty.DELETE_XML_DATA_PROPERTIES_BY_XML_DATA_IDS, query="delete from XmlDataProperty as p where p._xmlDataId in (:xmlDataIds)")
+})
+public class XmlDataProperty {
+ public final static String DELETE_XML_DATA_PROPERTIES_BY_XML_DATA_IDS = "DELETE_XML_DATA_PROPERTIES_BY_XML_DATA_IDS";
+
+ @Id @Column(name="ID")
+ @GeneratedValue(strategy= GenerationType.AUTO)
+ @SuppressWarnings("unused")
+ private Long _id;
+ @Basic @Column(name="PROP_KEY")
+ private String propertyKey;
+ @Basic @Column(name="PROP_VALUE")
+ private String propertyValue;
+
+ @SuppressWarnings("unused")
+ @Basic @Column(name="XML_DATA_ID", insertable=false, updatable=false, nullable=true)
+ private Long _xmlDataId;
+ @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST})
+ @JoinColumn(name="XML_DATA_ID")
+ @SuppressWarnings("unused")
+ private XmlDataDAOImpl _xmlData;
+
+ public XmlDataProperty() {
+ }
+ public XmlDataProperty(String propertyKey, String propertyValue, XmlDataDAOImpl xmlData) {
+ this.propertyKey = propertyKey;
+ this.propertyValue = propertyValue;
+ this._xmlData = xmlData;
+ }
+
+ public String getPropertyKey() {
+ return propertyKey;
+ }
+
+ public void setPropertyKey(String propertyKey) {
+ this.propertyKey = propertyKey;
+ }
+
+ public String getPropertyValue() {
+ return propertyValue;
+ }
+
+ public void setPropertyValue(String propertyValue) {
+ this.propertyValue = propertyValue;
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ConfStoreDAO.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ConfStoreDAO.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ConfStoreDAO.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,36 @@
+/*
+ * 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.store;
+
+import javax.persistence.EntityManager;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+public class ConfStoreDAO {
+
+ EntityManager getEM() {
+ return ConfStoreDAOConnectionImpl.getThreadLocal().get().getEntityManager();
+ }
+
+ protected void delete() {
+ getEM().remove(this);
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ConfStoreDAOConnectionImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ConfStoreDAOConnectionImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ConfStoreDAOConnectionImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,90 @@
+/*
+ * 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.store;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.dao.jpa.JpaConnection;
+import org.apache.ode.dao.jpa.JpaOperator;
+import org.apache.ode.dao.store.ConfStoreDAOConnection;
+import org.apache.ode.dao.store.DeploymentUnitDAO;
+
+import javax.persistence.EntityManager;
+import javax.transaction.TransactionManager;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+public class ConfStoreDAOConnectionImpl extends JpaConnection implements ConfStoreDAOConnection {
+ private static Log LOG = LogFactory.getLog(ConfStoreDAOConnectionImpl.class);
+
+ static final ThreadLocal<ConfStoreDAOConnectionImpl> _connections = new ThreadLocal<ConfStoreDAOConnectionImpl>();
+
+
+ public ConfStoreDAOConnectionImpl(EntityManager mgr, TransactionManager txMgr, JpaOperator operator) {
+ super(mgr, txMgr, operator);
+ }
+
+ public void close() {
+ }
+
+ public DeploymentUnitDAO createDeploymentUnit(String name) {
+ DeploymentUnitDaoImpl du = new DeploymentUnitDaoImpl();
+ du.setName(name);
+ du.setDeployDate(new Date());
+ _em.persist(du);
+ return du;
+ }
+
+ public DeploymentUnitDAO getDeploymentUnit(String name) {
+ return _em.find(DeploymentUnitDaoImpl.class, name);
+ }
+
+ public Collection<DeploymentUnitDAO> getDeploymentUnits() {
+ return _em.createQuery("SELECT du from DeploymentUnitDaoImpl du").getResultList();
+ }
+
+ public long getNextVersion() {
+ List<VersionTrackerDAOImpl> res = _em.createQuery("select v from VersionTrackerDAOImpl v").getResultList();
+ if (res.size() == 0) return 1;
+ else {
+ VersionTrackerDAOImpl vt = res.get(0);
+ return vt.getVersion() + 1;
+ }
+ }
+
+ public void setVersion(long version) {
+ List<VersionTrackerDAOImpl> res = _em.createQuery("select v from VersionTrackerDAOImpl v").getResultList();
+ VersionTrackerDAOImpl vt;
+ if (res.size() == 0) vt = new VersionTrackerDAOImpl();
+ else vt = res.get(0);
+ vt.setVersion(version);
+ _em.persist(vt);
+ }
+
+ public static ThreadLocal<ConfStoreDAOConnectionImpl> getThreadLocal() {
+ return _connections;
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/DeploymentUnitDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/DeploymentUnitDaoImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/DeploymentUnitDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,140 @@
+/*
+ * 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.store;
+
+import org.apache.ode.bpel.iapi.ProcessState;
+import org.apache.ode.dao.store.DeploymentUnitDAO;
+import org.apache.ode.dao.store.ProcessConfDAO;
+import org.apache.ode.utils.stl.CollectionsX;
+import org.apache.ode.utils.stl.MemberOfFunction;
+
+import javax.persistence.*;
+import javax.xml.namespace.QName;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+@Entity
+@Table(name="STORE_DU")
+public class DeploymentUnitDaoImpl extends ConfStoreDAO implements DeploymentUnitDAO {
+
+ @OneToMany(targetEntity=ProcessConfDaoImpl.class,mappedBy="_du",fetch=FetchType.EAGER,cascade={CascadeType.ALL})
+ private Collection<ProcessConfDaoImpl> _processes = new HashSet<ProcessConfDaoImpl>();
+
+ @Basic @Column(name="DEPLOYER")
+ private String _deployer;
+
+ @Basic @Column(name="DEPLOYDT")
+ private Date _deployDate;
+
+ @Basic @Column(name="DIR")
+ private String _dir;
+
+ @Id @Column(name="NAME")
+ private String _name;
+
+ public Collection<? extends ProcessConfDAO> getProcesses() {
+ return _processes;
+ }
+
+ public void setProcesses(Collection<ProcessConfDaoImpl> processes) {
+ _processes = processes;
+ }
+
+ /**
+ * 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="DEPLOYDT"
+ */
+ public Date getDeployDate() {
+ return _deployDate;
+ }
+
+ public void setDeployDate(Date deployDate) {
+ _deployDate = deployDate;
+ }
+
+ /**
+ * @hibernate.id generator-class="assigned"
+ * @hibernate.column name="NAME"
+ */
+ public String getName() {
+ return _name;
+ }
+
+ public void setName(String name) {
+ _name = name;
+ }
+
+ /**
+ * @hibernate.property column="DIR"
+ */
+ public String getDeploymentUnitDir() {
+ return _dir;
+ }
+
+ public void setDeploymentUnitDir(String dir) {
+ _dir = dir;
+ }
+
+ public void delete() {
+ super.delete();
+ }
+
+ public ProcessConfDAO createProcess(QName pid, QName type, long version) {
+ ProcessConfDaoImpl p = new ProcessConfDaoImpl();
+ p.setPID(pid);
+ p.setType(type);
+ p.setDeploymentUnit(this);
+ p.setState(ProcessState.ACTIVE);
+ p.setVersion(version);
+ getEM().persist(p);
+ _processes.add(p);
+ getEM().persist(this);
+ return p;
+ }
+
+ public ProcessConfDAO getProcess(final QName pid) {
+ return CollectionsX.find_if(_processes,new MemberOfFunction<ProcessConfDAO>() {
+ @Override
+ public boolean isMember(ProcessConfDAO o) {
+ return o.getPID().equals(pid);
+ }
+
+ });
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ProcessConfDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ProcessConfDaoImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ProcessConfDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,170 @@
+/*
+ * 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.store;
+
+import org.apache.ode.bpel.iapi.ProcessState;
+import org.apache.ode.dao.store.ProcessConfDAO;
+import org.apache.ode.utils.stl.CollectionsX;
+import org.apache.ode.utils.stl.UnaryFunction;
+
+import javax.persistence.*;
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+@Entity
+@Table(name="STORE_PROCESS")
+public class ProcessConfDaoImpl extends ConfStoreDAO implements ProcessConfDAO {
+
+ @ManyToOne(targetEntity=DeploymentUnitDaoImpl.class,fetch=FetchType.EAGER,cascade={CascadeType.ALL})
+ @JoinColumn(name="DU")
+ private DeploymentUnitDaoImpl _du;
+
+ @OneToMany(fetch=FetchType.EAGER,cascade={CascadeType.ALL})
+ @MapKey(name="_key")
+ @JoinTable(name="STORE_PROC_TO_PROP", inverseJoinColumns={ @JoinColumn(name = "STORE_PROPERTY_ID")})
+ private HashMap<String,ProcessConfPropertyDaoImpl> _properties = new HashMap<String,ProcessConfPropertyDaoImpl>();
+
+ @Id @Column(name="PID")
+ private String _processId;
+
+ @Basic @Column(name="TYPE")
+ private String _type;
+
+ @Basic @Column(name="VERSION")
+ private long _version;
+
+ @Basic @Column(name="STATE")
+ private String _state;
+
+ public DeploymentUnitDaoImpl getDeploymentUnit() {
+ return _du;
+ }
+
+ public void setDeploymentUnit(DeploymentUnitDaoImpl du) {
+ _du = du;
+ }
+
+ /**
+ *
+ * @hibernate.id generator-class="assigned"
+ * @hibernate.column
+ * name="PID"
+ * not-null="true"
+ */
+ public String getPID_() {
+ return _processId;
+ }
+
+ public void setPID_(String processId) {
+ _processId = processId;
+ }
+
+
+ /**
+ * The type of the process (BPEL process definition name).
+ * @hibernate.property
+ * column="TYPE"
+ */
+ public String getType_() {
+ return _type;
+ }
+
+ public void setType_(String type) {
+ _type = type;
+ }
+
+
+ /**
+ * The process version.
+ * @hibernate.property
+ * column="version"
+ */
+ public long getVersion() {
+ return _version;
+ }
+
+ public void setVersion(long version) {
+ _version = version;
+ }
+
+ public String getState_() {
+ return _state;
+ }
+
+ public void setState_(String state) {
+ _state = state;
+ }
+
+ public QName getPID() {
+ return QName.valueOf(getPID_());
+ }
+
+ public void setPID(QName pid) {
+ setPID_(pid.toString());
+ }
+
+ public void setState(ProcessState state) {
+ setState_(state.toString());
+ }
+
+ public void setProperty(QName name, String content) {
+ ProcessConfPropertyDaoImpl prop = new ProcessConfPropertyDaoImpl();
+ prop.setKey(name.toString());
+ prop.setValue(content);
+ getEM().persist(prop);
+ _properties.put(name.toString(),prop);
+ getEM().persist(this);
+ }
+
+ public void delete() {
+ super.delete();
+ }
+
+ public QName getType() {
+ return QName.valueOf(getType_());
+ }
+
+ public void setType(QName type) {
+ setType_(type.toString());
+ }
+
+ public ProcessState getState() {
+ return ProcessState.valueOf(getState_());
+ }
+
+ public String getProperty(QName name) {
+ return _properties.get(name.toString()).getValue();
+ }
+
+ public Collection<QName> getPropertyNames() {
+ return CollectionsX.transform(new ArrayList<QName>(), _properties.keySet(),new UnaryFunction<String,QName>() {
+ public QName apply(String x) {
+ return QName.valueOf(x);
+ }
+
+ });
+ }
+
+}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ProcessConfPropertyDaoImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ProcessConfPropertyDaoImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ProcessConfPropertyDaoImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,68 @@
+/*
+ * 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.store;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+@Entity
+@Table(name="STORE_PROCESS_PROP")
+public class ProcessConfPropertyDaoImpl {
+
+ @Id @Column(name="ID")
+ @GeneratedValue
+ private Long _id;
+
+ @Basic @Column(name="PROP_KEY")
+ private String _key;
+ @Basic @Column(name="PROP_VAL")
+ private String _value;
+
+ public String getKey() {
+ return _key;
+ }
+
+ public void setKey(String key) {
+ _key = key;
+ }
+
+ public String getValue() {
+ return _value;
+ }
+
+ public void setValue(String value) {
+ _value = value;
+ }
+
+ public Long getId() {
+ return _id;
+ }
+
+ public void setId(Long id) {
+ this._id = id;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/VersionTrackerDAOImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/VersionTrackerDAOImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/VersionTrackerDAOImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,58 @@
+/*
+ * 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.store;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+@Entity
+@Table(name="STORE_VERSIONS")
+public class VersionTrackerDAOImpl {
+
+ @Id @Column(name="ID")
+ @GeneratedValue
+ private Long _id;
+
+ @Basic @Column(name="VERSION")
+ private long _version;
+
+ public long getVersion() {
+ return _version;
+ }
+
+ public void setVersion(long version) {
+ _version = version;
+ }
+
+ public Long getId() {
+ return _id;
+ }
+
+ public void setId(Long id) {
+ this._id = id;
+ }
+}
Added: branches/ODE/ODE-1.x-jpa/dao-jpa-db/build.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-db/build.xml (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-db/build.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,88 @@
+<?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.
+ -->
+<project>
+
+ <property name="db.scripts.dir" value="${basedir}/target" />
+ <property name="descriptor.dir" value="${basedir}/src/main/descriptors"/>
+ <property name="scripts.dir" value="${basedir}/src/main/scripts"/>
+
+ <path id="classpath">
+ <pathelement path="${maven.runtime.classpath}"/>
+ </path>
+
+ <target name="create-schema">
+
+ <taskdef name="mappingtool" classname="org.apache.openjpa.jdbc.ant.MappingToolTask" classpathref="classpath"/>
+
+ <mkdir dir="target"/>
+ <mkdir dir="${db.scripts.dir}" />
+
+ <!-- Derby -->
+ <create-ddl db="derby"/>
+
+ <!-- HSQL -->
+ <create-ddl db="hsql"/>
+
+ <!-- MySQL -->
+ <create-ddl db="mysql"/>
+
+ <!-- Oracle -->
+ <create-ddl db="oracle"/>
+
+ <!-- Postgres -->
+ <create-ddl db="postgres"/>
+
+ </target>
+
+ <target name="zip-derby-db">
+ <zip destfile="${basedir}/target/ode-dao-jpa-db-${ode.version}.zip" basedir="${basedir}/target/derby" />
+ </target>
+
+ <!--
+ ============================================
+ Macro defs, no need to change anything below
+ ============================================
+ -->
+
+ <macrodef name="create-ddl">
+ <attribute name="db"/>
+
+ <sequential>
+ <echo></echo>
+ <echo>=====================</echo>
+ <echo>Create DDL @{db}</echo>
+ <mappingtool schemaAction="build" sqlFile="${db.scripts.dir}/partial.(a){db}.sql" readSchema="false">
+ <config propertiesFile="${descriptor.dir}/persistence.(a){db}.xml"/>
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+ </mappingtool>
+ <concat destfile="${db.scripts.dir}/scripts/(a){db}.sql">
+ <fileset file="${scripts.dir}/license-header.sql"/>
+ <fileset file="${scripts.dir}/common.sql"/>
+ <fileset file="${scripts.dir}/simplesched-(a){db}.sql"/>
+ <fileset file="${db.scripts.dir}/partial.(a){db}.sql"/>
+ </concat>
+ <echo>Done.</echo>
+ <echo>=====================</echo>
+ </sequential>
+ </macrodef>
+
+</project>
Property changes on: branches/ODE/ODE-1.x-jpa/dao-jpa-db/build.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: branches/ODE/ODE-1.x-jpa/dao-jpa-db/pom.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-db/pom.xml (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-db/pom.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,216 @@
+<?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>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-dao-jpa-db</artifactId>
+ <name>ODE :: JPA DDL Generation</name>
+ <packaging>pom</packaging>
+ <parent>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>ode</artifactId>
+ <version>2.1.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </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>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-bpel-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-bpel-dao</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-bpel-runtime</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-bpel-epr</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-dao-jpa</artifactId>
+ <classifier>openjpa</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-bpel-store</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>net.sourceforge.serp</groupId>
+ <artifactId>serp</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>wsdl4j</groupId>
+ <artifactId>wsdl4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-ejb_2.1_spec</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derbytools</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.modules</groupId>
+ <artifactId>geronimo-kernel</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.components</groupId>
+ <artifactId>geronimo-transaction</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.components</groupId>
+ <artifactId>geronimo-connector</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>backport-util-concurrent</groupId>
+ <artifactId>backport-util-concurrent</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-pool</groupId>
+ <artifactId>commons-pool</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create-db-schemas</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <property name="maven.runtime.classpath" refid="maven.compile.classpath"/>
+ <ant antfile="build.xml" target="create-schema" />
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>sql-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create-derby-db</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <driver>org.apache.derby.jdbc.EmbeddedDriver</driver>
+ <url>jdbc:derby:${basedir}/target/ode-db;create=true</url>
+ <username>sa</username>
+ <password />
+ <autocommit>true</autocommit>
+ <onError>continue</onError>
+ <srcFiles>
+ <srcFile>target/scripts/derby.sql</srcFile>
+ </srcFiles>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <finalName>ode-db-derby-ojpa-${project.version}</finalName>
+ <appendAssemblyId>false</appendAssemblyId>
+ <descriptors>
+ <descriptor>src/main/assembly/bin.xml</descriptor>
+ </descriptors>
+ <tarLongFileMode>gnu</tarLongFileMode>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Property changes on: branches/ODE/ODE-1.x-jpa/dao-jpa-db/pom.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: branches/ODE/ODE-1.x-jpa/dao-jpa-db/shutdown.sql
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-db/shutdown.sql (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-db/shutdown.sql 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1 @@
+connect 'jdbc:derby:;shutdown=true';
Property changes on: branches/ODE/ODE-1.x-jpa/dao-jpa-db/shutdown.sql
___________________________________________________________________
Name: svn:executable
+ *
Added: branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/assembly/bin.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/assembly/bin.xml (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/assembly/bin.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,43 @@
+<?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.
+ -->
+<assembly>
+ <!-- id typically identifies the "type" (src vs bin etc) of the assembly -->
+ <id></id>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <fileSets>
+ <fileSet>
+ <outputDirectory>/</outputDirectory>
+ <directory>target</directory>
+ <includes>
+ <include>scripts/*.sql</include>
+ <include>ode-db/**</include>
+ </includes>
+ <excludes>
+ <exclude>partial.*.sql</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+
+</assembly>
Added: branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.derby.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.derby.xml (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.derby.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,60 @@
+<?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.bpel.EventDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.FaultDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.MessageRouteDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.ResourceRouteDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.MessageExchangeDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.MexProperty</class>
+ <class>org.apache.ode.dao.jpa.bpel.ActivityRecoveryDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.ProcessDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.ContextValueDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.CorrelatorDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.CorrSetProperty</class>
+ <class>org.apache.ode.dao.jpa.bpel.ProcessInstanceDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.XmlDataDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.XmlDataProperty</class>
+ <class>org.apache.ode.dao.jpa.bpel.PartnerLinkDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.CorrelationSetDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.ScopeDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.MessageDAOImpl</class>
+
+ <class>org.apache.ode.dao.jpa.store.ProcessConfDaoImpl</class>
+ <class>org.apache.ode.dao.jpa.store.ProcessConfPropertyDaoImpl</class>
+ <class>org.apache.ode.dao.jpa.store.DeploymentUnitDaoImpl</class>
+ <class>org.apache.ode.dao.jpa.store.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>
+
Property changes on: branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.derby.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.hsql.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.hsql.xml (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.hsql.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,60 @@
+<?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.bpel.EventDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.FaultDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.MessageRouteDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.ResourceRouteDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.MessageExchangeDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.MexProperty</class>
+ <class>org.apache.ode.dao.jpa.bpel.ActivityRecoveryDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.ProcessDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.ContextValueDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.CorrelatorDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.CorrSetProperty</class>
+ <class>org.apache.ode.dao.jpa.bpel.ProcessInstanceDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.XmlDataDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.XmlDataProperty</class>
+ <class>org.apache.ode.dao.jpa.bpel.PartnerLinkDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.CorrelationSetDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.ScopeDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.MessageDAOImpl</class>
+
+ <class>org.apache.ode.dao.jpa.store.ProcessConfDaoImpl</class>
+ <class>org.apache.ode.dao.jpa.store.ProcessConfPropertyDaoImpl</class>
+ <class>org.apache.ode.dao.jpa.store.DeploymentUnitDaoImpl</class>
+ <class>org.apache.ode.dao.jpa.store.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.H2Dictionary"/>
+ <!-- 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>
+
Property changes on: branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.hsql.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.mysql.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.mysql.xml (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.mysql.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,60 @@
+<?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.bpel.EventDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.FaultDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.MessageRouteDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.ResourceRouteDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.MessageExchangeDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.MexProperty</class>
+ <class>org.apache.ode.dao.jpa.bpel.ActivityRecoveryDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.ProcessDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.ContextValueDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.CorrelatorDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.CorrSetProperty</class>
+ <class>org.apache.ode.dao.jpa.bpel.ProcessInstanceDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.XmlDataDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.XmlDataProperty</class>
+ <class>org.apache.ode.dao.jpa.bpel.PartnerLinkDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.CorrelationSetDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.ScopeDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.MessageDAOImpl</class>
+
+ <class>org.apache.ode.dao.jpa.store.ProcessConfDaoImpl</class>
+ <class>org.apache.ode.dao.jpa.store.ProcessConfPropertyDaoImpl</class>
+ <class>org.apache.ode.dao.jpa.store.DeploymentUnitDaoImpl</class>
+ <class>org.apache.ode.dao.jpa.store.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>
+
Property changes on: branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.mysql.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.oracle.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.oracle.xml (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.oracle.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,61 @@
+<?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.bpel.EventDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.FaultDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.MessageRouteDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.ResourceRouteDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.MessageExchangeDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.MexProperty</class>
+ <class>org.apache.ode.dao.jpa.bpel.ActivityRecoveryDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.ProcessDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.ContextValueDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.CorrelatorDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.CorrSetProperty</class>
+ <class>org.apache.ode.dao.jpa.bpel.ProcessInstanceDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.XmlDataDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.XmlDataProperty</class>
+ <class>org.apache.ode.dao.jpa.bpel.PartnerLinkDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.CorrelationSetDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.ScopeDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.MessageDAOImpl</class>
+
+ <class>org.apache.ode.dao.jpa.store.ProcessConfDaoImpl</class>
+ <class>org.apache.ode.dao.jpa.store.ProcessConfPropertyDaoImpl</class>
+ <class>org.apache.ode.dao.jpa.store.DeploymentUnitDaoImpl</class>
+ <class>org.apache.ode.dao.jpa.store.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>
+
Property changes on: branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.oracle.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.postgres.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.postgres.xml (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.postgres.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,60 @@
+<?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.bpel.EventDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.FaultDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.MessageRouteDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.ResourceRouteDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.MessageExchangeDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.MexProperty</class>
+ <class>org.apache.ode.dao.jpa.bpel.ActivityRecoveryDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.ProcessDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.ContextValueDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.CorrelatorDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.CorrSetProperty</class>
+ <class>org.apache.ode.dao.jpa.bpel.ProcessInstanceDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.XmlDataDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.XmlDataProperty</class>
+ <class>org.apache.ode.dao.jpa.bpel.PartnerLinkDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.CorrelationSetDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.ScopeDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.MessageDAOImpl</class>
+
+ <class>org.apache.ode.dao.jpa.store.ProcessConfDaoImpl</class>
+ <class>org.apache.ode.dao.jpa.store.ProcessConfPropertyDaoImpl</class>
+ <class>org.apache.ode.dao.jpa.store.DeploymentUnitDaoImpl</class>
+ <class>org.apache.ode.dao.jpa.store.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>
+
Property changes on: branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/descriptors/persistence.postgres.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/common.sql
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/common.sql (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/common.sql 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,2 @@
+create table ODE_SCHEMA_VERSION (VERSION integer);
+insert into ODE_SCHEMA_VERSION values (6);
Property changes on: branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/common.sql
___________________________________________________________________
Name: svn:executable
+ *
Added: branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/license-header.sql
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/license-header.sql (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/license-header.sql 2010-05-25 16:20:16 UTC (rev 663)
@@ -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.
+--
+
Property changes on: branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/license-header.sql
___________________________________________________________________
Name: svn:executable
+ *
Added: branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/simplesched-derby.sql
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/simplesched-derby.sql (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/simplesched-derby.sql 2010-05-25 16:20:16 UTC (rev 663)
@@ -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),
+ correlationKeySet 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: branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/simplesched-hsql.sql
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/simplesched-hsql.sql (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/simplesched-hsql.sql 2010-05-25 16:20:16 UTC (rev 663)
@@ -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),
+ correlationKeySet varchar(255),
+ retryCount int,
+ inMem int,
+ detailsExt varbinary,
+
+ PRIMARY KEY(jobid));
+
+CREATE INDEX IDX_ODE_JOB_TS ON ode_job(ts);
+CREATE INDEX IDX_ODE_JOB_NODEID ON ode_job(nodeid);
+
+
Added: branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/simplesched-mysql.sql
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/simplesched-mysql.sql (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/simplesched-mysql.sql 2010-05-25 16:20:16 UTC (rev 663)
@@ -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),
+ correlationKeySet 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: branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/simplesched-oracle.sql
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/simplesched-oracle.sql (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/simplesched-oracle.sql 2010-05-25 16:20:16 UTC (rev 663)
@@ -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),
+ correlationKeySet 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: branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/simplesched-postgres.sql
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/simplesched-postgres.sql (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/main/scripts/simplesched-postgres.sql 2010-05-25 16:20:16 UTC (rev 663)
@@ -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),
+ correlationKeySet 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: branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/test/resources/META-INF/persistence.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/test/resources/META-INF/persistence.xml (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/test/resources/META-INF/persistence.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,61 @@
+<?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>
+ <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"/>
+
+ <property name="openjpa.ConnectionProperties"
+ value="DriverClassName=org.apache.derby.jdbc.EmbeddedDriver,Url=jdbc:derby:target/database/derby/ode-test-db;userid=sa;create=false,MaxActive=100,MaxWait=10000,TestOnBorrow=true"/>
+ -->
+
+ <!-- Properties for an embedded Derby connection -->
+ <property name="openjpa.ConnectionDriverName" value="org.apache.derby.jdbc.EmbeddedDriver"/>
+ <property name="openjpa.ConnectionURL" value="jdbc:derby:target/database/derby/ode-test-db;create=false"/>
+ <property name="openjpa.ConnectionUserName" value="SA"/>
+ <property name="openjpa.jdbc.DBDictionary" value="org.apache.openjpa.jdbc.sql.DerbyDictionary"/>
+
+ <!-- Use this property to generate DDL at runtime
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ -->
+
+
+ </properties>
+ </persistence-unit>
+</persistence>
+
Property changes on: branches/ODE/ODE-1.x-jpa/dao-jpa-db/src/test/resources/META-INF/persistence.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/pom.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/pom.xml (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/pom.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,68 @@
+<?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.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-dao-jpa-hibernate</artifactId>
+ <name>ODE :: JPA Hibernate DAO Impl</name>
+
+ <parent>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>ode</artifactId>
+ <version>2.1.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-bpel-schemas</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-bpel-epr</artifactId>
+ </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>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-dao-jpa</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
+
Added: branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/descriptors/persistence.derby.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/descriptors/persistence.derby.xml (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/descriptors/persistence.derby.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,56 @@
+<?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.hibernate.ejb.HibernatePersistence</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>
+ <property name="hibernate.show_sql" value="false" />
+ <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect" />
+ <property name="hibernate.connection.datasource" value="java:BPELDB" />
+ <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory" />
+ <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" />
+ <property name="jta.UserTransaction" value="jta.UserTransaction" />
+ </properties>
+ </persistence-unit>
+</persistence>
+
Added: branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/descriptors/persistence.mysql.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/descriptors/persistence.mysql.xml (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/descriptors/persistence.mysql.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,54 @@
+<?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>
+ <property name="hibernate.show_sql" value="false" />
+ <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect" />
+ <property name="hibernate.connection.datasource" value="java:BPELDB" />
+ <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory" />
+ <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" />
+ <property name="jta.UserTransaction" value="jta.UserTransaction" />
+ </properties>
+ </persistence-unit>
+</persistence>
+
Added: branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/descriptors/persistence.oracle.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/descriptors/persistence.oracle.xml (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/descriptors/persistence.oracle.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,54 @@
+<?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>
+ <property name="hibernate.show_sql" value="false" />
+ <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect" />
+ <property name="hibernate.connection.datasource" value="java:BPELDB" />
+ <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory" />
+ <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" />
+ <property name="jta.UserTransaction" value="jta.UserTransaction" />
+ </properties>
+ </persistence-unit>
+</persistence>
+
Added: branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/descriptors/persistence.postgres.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/descriptors/persistence.postgres.xml (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/descriptors/persistence.postgres.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,54 @@
+<?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>
+ <property name="hibernate.show_sql" value="false" />
+ <property name="hibernate.dialect" value="org.hibernate.dialect.PostgresDialect" />
+ <property name="hibernate.connection.datasource" value="java:BPELDB" />
+ <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory" />
+ <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" />
+ <property name="jta.UserTransaction" value="jta.UserTransaction" />
+ </properties>
+ </persistence-unit>
+</persistence>
+
Added: branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/files/hibernate.cfg/hsql.properties
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/files/hibernate.cfg/hsql.properties (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/files/hibernate.cfg/hsql.properties 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1 @@
+dialect=org.hibernate.dialect.HSQLDialect
\ No newline at end of file
Added: branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/files/hibernate.cfg/mysql.properties
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/files/hibernate.cfg/mysql.properties (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/files/hibernate.cfg/mysql.properties 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1 @@
+dialect=org.hibernate.dialect.MySQLInnoDBDialect
\ No newline at end of file
Added: branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/BpelDAOConnectionFactoryImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/BpelDAOConnectionFactoryImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/BpelDAOConnectionFactoryImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/ConfStoreDAOConnectionFactoryImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/ConfStoreDAOConnectionFactoryImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/ConfStoreDAOConnectionFactoryImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/DataSourceConnectionProvider.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/DataSourceConnectionProvider.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/DataSourceConnectionProvider.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/HibernateTransactionManagerLookup.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/HibernateTransactionManagerLookup.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/HibernateTransactionManagerLookup.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/HibernateUtil.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/HibernateUtil.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/HibernateUtil.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/JpaOperatorImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/JpaOperatorImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/java/org/apache/ode/dao/jpa/hibernate/JpaOperatorImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/scripts/license-header.sql
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/scripts/license-header.sql (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/scripts/license-header.sql 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/scripts/simplesched-derby.sql
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/scripts/simplesched-derby.sql (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/scripts/simplesched-derby.sql 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/scripts/simplesched-mysql.sql
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/scripts/simplesched-mysql.sql (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/scripts/simplesched-mysql.sql 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/scripts/simplesched-oracle.sql
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/scripts/simplesched-oracle.sql (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/scripts/simplesched-oracle.sql 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/scripts/simplesched-postgres.sql
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/scripts/simplesched-postgres.sql (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-hibernate/src/main/scripts/simplesched-postgres.sql 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/pom.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/pom.xml (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/pom.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -0,0 +1,86 @@
+<?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.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-dao-jpa-ojpa</artifactId>
+ <name>ODE :: JPA OpenJPA DAO Impl</name>
+
+ <parent>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>ode</artifactId>
+ <version>2.1.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-bpel-schemas</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-bpel-epr</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-dao-jpa</artifactId>
+ <classifier>openjpa</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-dao-jpa</artifactId>
+ </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: branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/descriptors/persistence.derby.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/descriptors/persistence.derby.xml (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/descriptors/persistence.derby.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/descriptors/persistence.mysql.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/descriptors/persistence.mysql.xml (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/descriptors/persistence.mysql.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/descriptors/persistence.oracle.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/descriptors/persistence.oracle.xml (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/descriptors/persistence.oracle.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/descriptors/persistence.postgres.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/descriptors/persistence.postgres.xml (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/descriptors/persistence.postgres.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/BpelDAOConnectionFactoryImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/BpelDAOConnectionFactoryImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/BpelDAOConnectionFactoryImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/ConfStoreDAOConnectionFactoryImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/ConfStoreDAOConnectionFactoryImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/ConfStoreDAOConnectionFactoryImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaOperatorImpl.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaOperatorImpl.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaOperatorImpl.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaTxMgrProvider.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaTxMgrProvider.java (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaTxMgrProvider.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/scripts/license-header.sql
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/scripts/license-header.sql (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/scripts/license-header.sql 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/scripts/simplesched-derby.sql
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/scripts/simplesched-derby.sql (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/scripts/simplesched-derby.sql 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/scripts/simplesched-mysql.sql
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/scripts/simplesched-mysql.sql (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/scripts/simplesched-mysql.sql 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/scripts/simplesched-oracle.sql
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/scripts/simplesched-oracle.sql (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/scripts/simplesched-oracle.sql 2010-05-25 16:20:16 UTC (rev 663)
@@ -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: branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/scripts/simplesched-postgres.sql
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/scripts/simplesched-postgres.sql (rev 0)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa/src/main/scripts/simplesched-postgres.sql 2010-05-25 16:20:16 UTC (rev 663)
@@ -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);
+
+
Deleted: branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa-derby/src/test/java/org/apache/ode/dao/jpa/test/InsertObjectTest.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa-derby/src/test/java/org/apache/ode/dao/jpa/test/InsertObjectTest.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa-derby/src/test/java/org/apache/ode/dao/jpa/test/InsertObjectTest.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,193 +0,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.
- */
-
-package org.apache.ode.dao.jpa.test;
-
-import junit.framework.TestCase;
-import org.apache.ode.bpel.common.CorrelationKey;
-import org.apache.ode.bpel.common.CorrelationKeySet;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.CorrelationSetDAO;
-import org.apache.ode.bpel.dao.CorrelatorDAO;
-import org.apache.ode.bpel.dao.MessageDAO;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
-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.ScopeDAO;
-import org.apache.ode.bpel.dao.ScopeStateEnum;
-import org.apache.ode.bpel.dao.XmlDataDAO;
-import org.apache.ode.dao.jpa.BPELDAOConnectionFactoryImpl;
-import org.apache.ode.il.EmbeddedGeronimoFactory;
-import org.apache.ode.utils.DOMUtils;
-import org.apache.ode.utils.GUID;
-import org.hsqldb.jdbc.jdbcDataSource;
-import org.xml.sax.SAXException;
-
-import javax.sql.DataSource;
-import javax.transaction.TransactionManager;
-import javax.xml.namespace.QName;
-import java.io.IOException;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.Properties;
-
-public class InsertObjectTest extends TestCase {
-
- private static final String TEST_NS = "http://org.apache.ode.jpa.test";
- private static final String CORRELATOR_ID1 = "testCorrelator1";
- private static final String CORRELATOR_ID2 = "testCorrelator2";
- private static final Calendar cal = new GregorianCalendar();
-
- TransactionManager _txm;
- DataSource _ds;
- BPELDAOConnectionFactoryImpl factory;
- ProcessDAO _process;
-
- @Override
- protected void setUp() throws Exception {
- jdbcDataSource hsqlds = new jdbcDataSource();
- hsqlds.setDatabase("jdbc:hsqldb:mem:" + new GUID().toString());
- hsqlds.setUser("sa");
- hsqlds.setPassword("");
- _ds = hsqlds;
-
- _txm = new EmbeddedGeronimoFactory().getTransactionManager();
-
- factory = new BPELDAOConnectionFactoryImpl();
- factory.setDataSource(_ds);
- factory.setTransactionManager(_txm);
- Properties props = new Properties();
- props.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=false)");
- factory.init(props);
-
- _txm.begin();
- }
-
- public void testStart() throws Exception {
- createStuff(factory);
- }
-
- void createStuff(BPELDAOConnectionFactoryImpl factory) throws Exception {
- BpelDAOConnection conn = factory.getConnection();
-
- CorrelatorDAO corr = createProcess(conn,"testPID1","testType");
- ProcessInstanceDAO pi1 = createProcessInstance(_process, corr);
- }
-
- @Override
- protected void tearDown() throws Exception {
- _txm.commit();
- _ds = null;
- _txm = null;
- }
-
- private MessageExchangeDAO createMessageExchange(ProcessDAO p, ProcessInstanceDAO pi, PartnerLinkDAO pl ) throws SAXException, IOException {
- MessageExchangeDAO me = pi.getConnection().createMessageExchange('0');
-
- me.setCallee(new QName(TEST_NS,"testCallee"));
- me.setChannel("testChannel");
- me.setCorrelationId("testCorrelationId");
- me.setCorrelationStatus("testCorrelationStatus");
- me.setEPR(DOMUtils.stringToDOM("<testEPR>EPR</testEPR>"));
- me.setFault(new QName("testFault"));
- me.setFaultExplanation("testFaultExplanation");
- me.setInstance(pi);
- me.setOperation("testOperation");
- me.setPartnerLink(pl);
- me.setPartnerLinkModelId(1);
- me.setPattern("testPattern");
- me.setPortType(new QName(TEST_NS,"testPortType"));
- me.setProcess(p);
- me.setProperty("testProp1Key", "testProp1");
- me.setProperty("testProp2Key", "testProp2");
- me.setRequest(createMessage(me,"testRequest"));
- me.setResponse(createMessage(me,"testResponse"));
- me.setStatus("testStatus");
-
- return me;
- }
-
- private MessageDAO createMessage(MessageExchangeDAO me, String name) throws SAXException, IOException {
- MessageDAO m = me.createMessage(new QName(TEST_NS,name));
-
- m.setType(new QName(TEST_NS,name));
- m.setData(DOMUtils.stringToDOM("<testData>some test data</testData>"));
-
- return m;
- }
-
- private CorrelatorDAO createProcess(BpelDAOConnection conn, String pid, String type) {
- _process = conn.createProcess(new QName(TEST_NS,pid), new QName(TEST_NS,type),"GUID1",1);
- CorrelatorDAO corr = _process.addCorrelator(CORRELATOR_ID1);
- _process.addCorrelator(CORRELATOR_ID2);
- return corr;
- }
-
- private ProcessInstanceDAO createProcessInstance(ProcessDAO process, CorrelatorDAO corr) throws SAXException, IOException {
- ProcessInstanceDAO pi = null;
- String[] actions = { "action1","action2" };
- String[] correlationKeys = { "key1", "key2" };
- CorrelationKey key1 = new CorrelationKey("key1",correlationKeys);
- CorrelationKey key2 = new CorrelationKey("key2",correlationKeys);
- CorrelationKey[] corrkeys = {key1,key2};
- QName[] names = { new QName(TEST_NS,"name1"), new QName(TEST_NS,"name2") };
-
- pi = process.createInstance(corr);
-
- pi.setExecutionState(new String("test execution state").getBytes());
- pi.setFault(new QName(TEST_NS,"testFault"), "testExplanation", 1, 1, DOMUtils.stringToDOM("<testFaultMessage>testMessage</testFaultMessage>"));
- pi.setLastActiveTime(cal.getTime());
- pi.setState((short) 1);
-
- pi.createActivityRecovery("testChannel1", 3, "testReason1", cal.getTime(), DOMUtils.stringToDOM("<testData>testData1</testData>"), actions, 2);
- pi.createActivityRecovery("testChannel2", 4, "testReason2", cal.getTime(), DOMUtils.stringToDOM("<testData>testData2</testData>"), actions, 2);
-
- ScopeDAO root = pi.createScope(null, "Root", 1);
- root.setState(ScopeStateEnum.ACTIVE);
- ScopeDAO child1 = pi.createScope(root, "Child1", 2);
- child1.setState(ScopeStateEnum.ACTIVE);
- XmlDataDAO var1 = child1.getVariable("var1");
- var1.set(DOMUtils.stringToDOM("<testData>testData</testData>"));
- var1.setProperty("key1", "prop1");
- var1.setProperty("key2", "prop2");
- XmlDataDAO var2 = child1.getVariable("var2");
- var2.set(DOMUtils.stringToDOM("<testData>testData</testData>"));
- var2.setProperty("key1", "prop1");
- var2.setProperty("key2", "prop2");
-
- CorrelationSetDAO cs1 = child1.getCorrelationSet("TestCorrelationSet1");
- cs1.setValue(names,key1);
-
- PartnerLinkDAO pl1 = child1.createPartnerLink(1, "Test PartnerLink1", "MyRole1", "PartnerRole1");
- pl1.setMyEPR(DOMUtils.stringToDOM("<testEPR>testMyEPR</testEPR>"));
- pl1.setMyRoleServiceName(new QName(TEST_NS,"testRoleService"));
- pl1.setMySessionId("TestMySessionID");
- pl1.setPartnerEPR(DOMUtils.stringToDOM("<testEPR>testPartnerEPR</testEPR>"));
- pl1.setPartnerSessionId("TestPartnerSessionID");
-
- MessageExchangeDAO mex = createMessageExchange(process,pi,pl1);
-
- corr.addRoute("testRoute", pi, 1, new CorrelationKeySet().add(key1), "one");
- corr.enqueueMessage(mex, new CorrelationKeySet().add(corrkeys[0]).add(corrkeys[1]));
-
- return pi;
- }
-
-}
Deleted: branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa-derby/src/test/java/org/apache/ode/dao/jpa/test/SelectObjectTest.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa-derby/src/test/java/org/apache/ode/dao/jpa/test/SelectObjectTest.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa-ojpa-derby/src/test/java/org/apache/ode/dao/jpa/test/SelectObjectTest.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -1,300 +0,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.
- */
-
-package org.apache.ode.dao.jpa.test;
-
-import junit.framework.TestCase;
-import org.apache.ode.bpel.common.CorrelationKey;
-import org.apache.ode.bpel.common.CorrelationKeySet;
-import org.apache.ode.bpel.dao.ActivityRecoveryDAO;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.CorrelationSetDAO;
-import org.apache.ode.bpel.dao.CorrelatorDAO;
-import org.apache.ode.bpel.dao.FaultDAO;
-import org.apache.ode.bpel.dao.MessageDAO;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
-import org.apache.ode.bpel.dao.MessageRouteDAO;
-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.ScopeDAO;
-import org.apache.ode.bpel.dao.ScopeStateEnum;
-import org.apache.ode.bpel.dao.XmlDataDAO;
-import org.apache.ode.dao.jpa.BPELDAOConnectionFactoryImpl;
-import org.apache.ode.il.EmbeddedGeronimoFactory;
-import org.apache.ode.utils.GUID;
-import org.hsqldb.jdbc.jdbcDataSource;
-
-import javax.persistence.EntityManager;
-import javax.sql.DataSource;
-import javax.transaction.TransactionManager;
-import javax.xml.namespace.QName;
-import java.util.Collection;
-import java.util.Properties;
-import java.util.List;
-
-public class SelectObjectTest extends TestCase {
-
- private EntityManager em;
- private static final String TEST_NS = "http://org.apache.ode.jpa.test";
- private String[] correlationKeys = { "key1", "key2" };
- private String[] actions = { "action1","action2" };
- private CorrelationKey key1 = new CorrelationKey("key1",correlationKeys);
- private static final String CORRELATOR_ID1 = "testCorrelator1";
- private static final String CORRELATOR_ID2 = "testCorrelator2";
-
- TransactionManager _txm;
- DataSource _ds;
- BPELDAOConnectionFactoryImpl factory;
-
- @Override
- protected void setUp() throws Exception {
- jdbcDataSource hsqlds = new jdbcDataSource();
- hsqlds.setDatabase("jdbc:hsqldb:mem:" + new GUID().toString());
- hsqlds.setUser("sa");
- hsqlds.setPassword("");
- _ds = hsqlds;
-
- _txm = new EmbeddedGeronimoFactory().getTransactionManager();
-
- factory = new BPELDAOConnectionFactoryImpl();
- factory.setDataSource(_ds);
- factory.setTransactionManager(_txm);
- Properties props = new Properties();
- props.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=false)");
- factory.init(props);
-
- _txm.begin();
- }
-
- public void testGetObject() throws Exception {
- new InsertObjectTest().createStuff(factory);
-
- _txm.commit();
- _txm.begin();
-
- BpelDAOConnection conn = factory.getConnection();
-
- // Assert the ProcessDAO
- ProcessDAO p = conn.getProcess(new QName(TEST_NS,"testPID1"));
- assertNotNull( p );
- Collection<ProcessInstanceDAO> insts = p.findInstance(key1);
- assertNotNull( insts );
- assertTrue( insts.size() > 0 );
- assertNotNull(p.getType());
- assertNotNull(p.getProcessId());
- assertEquals( p.getVersion() , 1 );
-
- // Assert the CorrelatorDAO
- CorrelatorDAO corr = p.getCorrelator(CORRELATOR_ID1);
- assertNotNull( corr );
- assertEquals(corr.getCorrelatorId(),CORRELATOR_ID1);
-
- // Assert the MessageRouteDAO
- List<MessageRouteDAO> routes = corr.findRoute(new CorrelationKeySet().add(key1));
- MessageRouteDAO route = null;
- if (routes != null && routes.size() > 0) {
- route = routes.get(0);
- }
- assertNotNull( route );
- assertEquals(route.getGroupId(),"testRoute" );
- assertEquals(route.getIndex() , 1 );
- assertNotNull(route.getTargetInstance() );
-
- // Assert the ProcessInstanceDAO
- for ( ProcessInstanceDAO inst : insts ) {
- Long id = inst.getInstanceId();
- assertNotNull( id );
-
- ProcessInstanceDAO inst2 = conn.getInstance(id);
- assertSame(inst2,inst);
-
- ProcessInstanceDAO inst3 = p.getInstance(id);
- assertSame( inst3 , inst );
-
- Long mon = inst.genMonotonic();
- assertEquals(inst.getActivityFailureCount() , 2);
- assertNotNull(inst.getActivityFailureDateTime() );
- assertNotNull(inst.getCreateTime() );
- assertTrue(inst.getExecutionState().length > 0 );
- assertNotNull(inst.getLastActiveTime() );
- assertSame(inst.getProcess() , p );
- assertEquals(inst.getPreviousState() , 0);
- assertEquals(inst.getState() , 1);
-
- // Assert the Root ScopeDAO
- ScopeDAO rs = inst.getRootScope();
- assertNotNull( rs );
- assertNotNull(rs.getChildScopes());
- ScopeDAO child1 = null;
- for ( ScopeDAO childItr : rs.getChildScopes()){
- child1 = childItr;
- break;
- }
- assertNotNull(child1);
- assertNotNull(rs.getCorrelationSets());
- assertEquals(rs.getCorrelationSets().size() , 0 );
- assertEquals(rs.getModelId(),1);
- assertEquals(rs.getName(),"Root");
- assertTrue(rs.getParentScope() == null);
- assertNotNull(rs.getPartnerLinks());
- assertEquals(rs.getPartnerLinks().size() ,0);
- assertSame(rs.getProcessInstance(),inst);
- assertNotNull(rs.getScopeInstanceId());
- assertEquals(rs.getState(),ScopeStateEnum.ACTIVE);
- assertNotNull(rs.getVariables());
- assertEquals(rs.getVariables().size(),0);
-
-
- // Assert the ActivityRecoveryDAO
- assertNotNull(inst.getActivityRecoveries());
- ActivityRecoveryDAO rec1 = null;
- for (ActivityRecoveryDAO recItr : inst.getActivityRecoveries()) {
- if (recItr.getActivityId() == 3) {
- rec1 = recItr;break;
- }
- }
- assertNotNull(rec1);
- String tmpAct = rec1.getActions();
-// assertEquals(rec1.getActionsList(),actions);
- assertEquals(rec1.getActivityId(),3);
- assertEquals(rec1.getChannel(),"testChannel1");
- assertNotNull(rec1.getDateTime());
-// assertNotNull(rec1.getDetails());
- assertEquals(rec1.getReason(),"testReason1");
- assertEquals(rec1.getRetries(),2);
-
- // Assert the CorrelationSetDAO
- //assertNotNull(inst.getCorrelationSets());
- //CorrelationSetDAO cs1 = null;
- //for ( CorrelationSetDAO csItr : inst.getCorrelationSets() ) {
- // cs1 = csItr;
- // break;
- //}
- //assertNotNull(cs1);
-
- // Assert the FaultDAO
- FaultDAO fault = inst.getFault();
- assertNotNull(fault);
- assertEquals(fault.getActivityId(),1);
- assertNotNull(fault.getData());
- assertEquals(fault.getExplanation(),"testExplanation");
- assertEquals(fault.getLineNo(),1);
- assertEquals(fault.getName(),new QName(TEST_NS,"testFault"));
-
- // Assert MessageExchangeDAO
- CorrelatorDAO ic = inst.getInstantiatingCorrelator();
- assertNotNull(ic);
- assertEquals(ic.getCorrelatorId(),CORRELATOR_ID1);
- // The message is dequeued but not persisted
- MessageExchangeDAO me = ic.dequeueMessage(new CorrelationKeySet().add(key1));
- assertNotNull(me);
- assertEquals(me.getCallee(),new QName(TEST_NS,"testCallee"));
- assertEquals(me.getPropagateTransactionFlag(),false);
- assertEquals(me.getChannel(),"testChannel");
- assertEquals(me.getCorrelationId(),"testCorrelationId");
- //assertNotNull(me.getCreateTime());
- assertEquals(me.getDirection(),'0');
- assertNotNull(me.getEPR());
- assertEquals(me.getFault().toString(),"testFault");
- assertEquals(me.getFaultExplanation(),"testFaultExplanation");
- assertSame(me.getInstance(),inst);
- assertEquals(me.getOperation(),"testOperation");
- assertNotNull(me.getPartnerLink());
- assertEquals(me.getPartnerLinkModelId(),1);
- assertEquals(me.getPattern(),"testPattern");
- assertEquals(me.getPortType(),new QName(TEST_NS,"testPortType"));
- assertSame(me.getProcess(),p);
- assertEquals(me.getProperty("testProp1Key"),"testProp1");
- assertNotNull(me.getRequest());
- assertNotNull(me.getResponse());
- assertEquals(me.getStatus(),"testStatus");
-
- // Assert MessageDAO
- MessageDAO m = me.getRequest();
- assertNotNull(m.getData());
- assertSame(m.getMessageExchange(),me);
- assertEquals(m.getType(),new QName(TEST_NS,"testRequest"));
-
-
- //Assert Child ScopeDAO
- assertNotNull(inst.getScopes());
- assertTrue(inst.getScopes().size() > 0);
- assertNotNull(inst.getScopes("Child1"));
- assertTrue(inst.getScopes("Child1").size() == 1);
- ScopeDAO childS = inst.getScopes("Child1").iterator().next();
- assertSame(childS,child1);
- assertSame(childS.getParentScope(),rs);
- assertNotNull(childS.getChildScopes());
- assertEquals(childS.getChildScopes().size(), 0);
- assertNotNull(childS.getVariables());
- assertTrue(childS.getVariables().size() > 0);
- assertNotNull(childS.getVariable("var1"));
- XmlDataDAO chsVar = childS.getVariable("var1");
- assertNotNull(childS.getPartnerLinks());
- assertTrue(childS.getPartnerLinks().size() > 0);
- PartnerLinkDAO spl = childS.getPartnerLinks().iterator().next();
- assertSame(spl,me.getPartnerLink());
- assertSame(spl,childS.getPartnerLink(spl.getPartnerLinkModelId()));
- assertNotNull(childS.getCorrelationSets());
- assertTrue(childS.getCorrelationSets().size() > 0);
- assertNotNull(childS.getCorrelationSet("TestCorrelationSet1"));
-
- // Assert CorrelationSetDAO
- CorrelationSetDAO cs = childS.getCorrelationSet("TestCorrelationSet1");
- assertEquals(cs.getName(),"TestCorrelationSet1");
- assertNotNull(cs.getProperties());
- assertTrue(cs.getProperties().size() > 0);
- assertSame(cs.getScope(),childS);
- assertNotNull(cs.getValue());
- assertEquals(cs.getProperties().get(new QName(TEST_NS,"name1")),"key1");
-
-
- // Assert PartnerLinkDAO
- assertNotNull(spl.getMyEPR());
- assertEquals(spl.getMyRoleName(),"MyRole1");
- assertEquals(spl.getMyRoleServiceName(),new QName(TEST_NS,"testRoleService"));
- assertEquals(spl.getMySessionId(),"TestMySessionID");
- assertNotNull(spl.getPartnerEPR());
- assertEquals(spl.getPartnerLinkModelId(),1);
- assertEquals(spl.getPartnerLinkName(),"Test PartnerLink1");
- assertEquals(spl.getPartnerRoleName(),"PartnerRole1");
- assertEquals(spl.getPartnerSessionId(),"TestPartnerSessionID");
-
- // Assert Variables
- assertNotNull(inst.getVariables("var1", 2));
- assertEquals(inst.getVariables("var1", 2).length,1);
- XmlDataDAO[] vars = inst.getVariables("var1", 2);
- assertSame(chsVar,vars[0]);
- assertNotNull(vars[0].get());
- assertEquals(vars[0].getName(),"var1");
- // assertEquals(vars[0].getProperty("key1"),"prop1");
- assertSame(vars[0].getScopeDAO(),childS);
-
- }
- }
-
- @Override
- protected void tearDown() throws Exception {
- _txm.commit();
- _txm = null;
- _ds = null;
- }
-
-}
Modified: branches/ODE/ODE-1.x-jpa/jbi/pom.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/jbi/pom.xml 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/jbi/pom.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -129,8 +129,8 @@
<artifactId>hibernate-core</artifactId>
</exclusion>
<exclusion>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
@@ -203,7 +203,7 @@
<dependency>
<groupId>org.jboss.soa.bpel</groupId>
<artifactId>riftsaw-bpel-ql</artifactId>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.apache.servicemix.specs</groupId>
<artifactId>org.apache.servicemix.specs.jbi-api-1.0</artifactId>
@@ -227,14 +227,13 @@
<dependency>
<groupId>org.jboss.soa.bpel</groupId>
<artifactId>riftsaw-dao-hibernate</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate</artifactId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.jboss.soa.bpel</groupId>
<artifactId>riftsaw-bpel-api-jca</artifactId>
</dependency>
@@ -318,6 +317,15 @@
<artifactId>geronimo-javamail_1.4_spec</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-dao-jpa-ojpa</artifactId>
+ <scope>test</scope>
+ </dependency>
<!-- for JBI packaging -->
<dependency>
@@ -470,17 +478,44 @@
<goal>copy-resources</goal>
</goals>
<configuration>
- <outputDirectory>${project.build.directory}/test/smx/ode</outputDirectory>
+ <outputDirectory>target/test/smx/ode</outputDirectory>
<resources>
<resource>
- <directory>${basedir}/../dao-jpa-ojpa-derby/target/derby</directory>
+ <directory>${basedir}/../dao-jpa-db/target/ode-db</directory>
</resource>
+ </resources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-resources2</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>target/test/resources</outputDirectory>
+ <resources>
<resource>
- <directory>${basedir}/../dao-hibernate-db/target/derby</directory>
+ <directory>src/test/resources</directory>
</resource>
</resources>
</configuration>
</execution>
+ <execution>
+ <id>copy-resources3</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>target/test/smx/ode/hibdb</outputDirectory>
+ <resources>
+ <resource>
+ <directory>${basedir}/../dao-hibernate-db/target/ode-db-hib</directory>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
</executions>
</plugin>
</plugins>
@@ -488,22 +523,16 @@
<testResources>
<testResource>
<directory>src/test/resources</directory>
- <targetPath>${project.build.directory}/test/resources</targetPath>
</testResource>
<testResource>
- <directory>src/test/resources</directory>
- <targetPath>${project.build.testOutputDirectory}</targetPath>
- </testResource>
- <testResource>
<directory>src/test/jbi</directory>
- <targetPath>${project.build.directory}/test/smx/ode</targetPath>
+ <targetPath>../test/smx/ode</targetPath>
</testResource>
<testResource>
<directory>src/main/jbi</directory>
<includes><include>hibernate.properties</include></includes>
- <targetPath>${project.build.directory}/test/smx/ode</targetPath>
+ <targetPath>../test/smx/ode</targetPath>
</testResource>
</testResources>
</build>
-
</project>
Modified: branches/ODE/ODE-1.x-jpa/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -40,7 +40,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ode.agents.memory.SizingAgent;
-import org.apache.ode.bpel.dao.BpelDAOConnectionFactory;
import org.apache.ode.bpel.engine.BpelServerImpl;
import org.apache.ode.bpel.engine.ProcessAndInstanceManagementImpl;
import org.apache.ode.bpel.iapi.Endpoint;
@@ -51,6 +50,8 @@
import org.apache.ode.bpel.o.Serializer;
import org.apache.ode.bpel.pmapi.InstanceManagement;
import org.apache.ode.bpel.pmapi.ProcessManagement;
+import org.apache.ode.dao.bpel.BpelDAOConnectionFactory;
+import org.apache.ode.dao.store.ConfStoreDAOConnectionFactory;
import org.apache.ode.jbi.msgmap.Mapper;
import org.apache.ode.jbi.util.WSDLFlattener;
import org.apache.ode.scheduler.simple.SimpleScheduler;
@@ -99,6 +100,8 @@
ExecutorService _executorService;
BpelDAOConnectionFactory _daocf;
+
+ ConfStoreDAOConnectionFactory _cdaocf;
OdeConfigProperties _config;
Modified: branches/ODE/ODE-1.x-jpa/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java
===================================================================
--- branches/ODE/ODE-1.x-jpa/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java 2010-05-25 16:20:16 UTC (rev 663)
@@ -34,13 +34,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ode.bpel.connector.BpelServerConnector;
-import org.apache.ode.bpel.dao.BpelDAOConnectionFactoryJDBC;
import org.apache.ode.bpel.engine.BpelServerImpl;
import org.apache.ode.bpel.engine.ProcessAndInstanceManagementMBean;
import org.apache.ode.bpel.extvar.jdbc.JdbcExternalVariableModule;
import org.apache.ode.bpel.iapi.BpelEventListener;
import org.apache.ode.bpel.intercept.MessageExchangeInterceptor;
+import org.apache.ode.dao.bpel.BpelDAOConnectionFactory;
+import org.apache.ode.dao.store.ConfStoreDAOConnectionFactory;
import org.apache.ode.il.dbutil.Database;
import org.apache.ode.il.dbutil.DatabaseConfigException;
import org.apache.ode.jbi.msgmap.Mapper;
@@ -234,7 +235,7 @@
_ode._scheduler.setExecutorService(_ode._executorService);
_ode._scheduler.setTransactionManager((TransactionManager) _ode.getContext().getTransactionManager());
- _ode._store = new ProcessStoreImpl(_ode._eprContext , _ode._dataSource, _ode._config.getDAOConnectionFactory(), _ode._config, false);
+ _ode._store = new ProcessStoreImpl(_ode._eprContext , _ode.getTransactionManager(), _ode._cdaocf);
registerExternalVariableModules();
_ode._store.loadAll();
@@ -264,14 +265,17 @@
* @throws JBIException
*/
private void initDao() throws JBIException {
- BpelDAOConnectionFactoryJDBC cf;
+ BpelDAOConnectionFactory bcf;
+ ConfStoreDAOConnectionFactory ccf;
try {
- cf = _db.createDaoCF();
+ bcf = _db.createDaoCF();
+ ccf = _db.createDaoStoreCF();
} catch (DatabaseConfigException e) {
String errmsg = __msgs.msgDAOInstantiationFailed(_ode._config.getDAOConnectionFactory());
throw new JBIException(errmsg,e);
}
- _ode._daocf = cf;
+ _ode._daocf = bcf;
+ _ode._cdaocf = ccf;
}
private void initConnector() throws JBIException {
Modified: branches/ODE/ODE-1.x-jpa/pom.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/pom.xml 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/pom.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -65,6 +65,7 @@
<woodstox.version>3.2.4</woodstox.version>
<javax.mail.version>1.4</javax.mail.version>
<hibernate.version>3.3.2.GA</hibernate.version>
+ <hibernate.entitymanager.version>3.4.0.GA</hibernate.entitymanager.version>
<spring.version>2.5.6</spring.version>
<geronimo.specs.version>1.0</geronimo.specs.version>
<geronimo.version>2.0.1</geronimo.version>
@@ -101,6 +102,7 @@
<xml-apis.version>1.3.04</xml-apis.version>
<servicemix.nmr.version>1.1.0-SNAPSHOT</servicemix.nmr.version>
<javassist.version>3.9.0.GA</javassist.version>
+ <h2.version>1.2.131</h2.version>
</properties>
@@ -123,19 +125,20 @@
<module>bpel-ql</module>
<module>dao-hibernate</module>
<module>tools</module>
+ <module>dao-jpa-hibernate</module>
+ <module>dao-jpa-ojpa</module>
+ <module>dao-jpa-db</module>
+ <module>dao-hibernate-db</module>
<module>bpel-store</module>
- <module>dao-jpa-ojpa-derby</module>
- <module>dao-hibernate-db</module>
<module>bpel-runtime</module>
<module>bpel-connector</module>
- <module>bpel-test</module>
- <module>axis2</module>
- <module>jbi</module>
- <module>jbi-bundle</module>
- <module>jbi-karaf</module>
- <!--module>distro/src/examples-jbi/maven2/ping-pong-osgi</module-->
- <module>axis2-war</module>
- <module>distro</module>
+ <module>bpel-test</module>
+ <module>axis2</module>
+ <module>jbi</module>
+ <module>jbi-bundle</module>
+ <module>jbi-karaf</module>
+ <module>axis2-war</module>
+ <module>distro</module>
</modules>
<build>
@@ -371,6 +374,12 @@
</dependency>
<dependency>
<groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-dao-jpa</artifactId>
+ <version>${ode.version}</version>
+ <classifier>openjpa</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.soa.bpel</groupId>
<artifactId>riftsaw-jca-ra</artifactId>
<version>${ode.version}</version>
</dependency>
@@ -391,6 +400,16 @@
</dependency>
<dependency>
<groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-dao-jpa-hibernate</artifactId>
+ <version>${ode.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.soa.bpel</groupId>
+ <artifactId>riftsaw-dao-jpa-ojpa</artifactId>
+ <version>${ode.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.soa.bpel</groupId>
<artifactId>riftsaw-scheduler-simple</artifactId>
<version>${ode.version}</version>
</dependency>
@@ -684,15 +703,24 @@
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
- <!--
<exclusions>
<exclusion>
<artifactId>jta</artifactId>
<groupId>javax.transaction</groupId>
</exclusion>
</exclusions>
- -->
</dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <version>${hibernate.entitymanager.version}</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>jta</artifactId>
+ <groupId>javax.transaction</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>log4j</groupId>
@@ -786,9 +814,9 @@
<version>${derby.version}</version>
</dependency>
<dependency>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
- <version>${hsqldb.version}</version>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>${h2.version}</version>
</dependency>
<!-- AXIS2 dependencies -->
Modified: branches/ODE/ODE-1.x-jpa/scheduler-simple/pom.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/scheduler-simple/pom.xml 2010-05-25 08:54:00 UTC (rev 662)
+++ branches/ODE/ODE-1.x-jpa/scheduler-simple/pom.xml 2010-05-25 16:20:16 UTC (rev 663)
@@ -57,8 +57,8 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
14 years, 1 month
riftsaw SVN: r662 - branches/ODE.
by riftsaw-commits@lists.jboss.org
Author: jeff.yuchang
Date: 2010-05-25 04:54:00 -0400 (Tue, 25 May 2010)
New Revision: 662
Added:
branches/ODE/ODE-1.x-jpa/
Log:
* creating a new branch, which will be a branch for jpa refacotring for ode 1.x code.
Copied: branches/ODE/ODE-1.x-jpa (from rev 661, branches/ODE/ODE-1.x-fixes)
14 years, 1 month
riftsaw SVN: r661 - branches/ODE.
by riftsaw-commits@lists.jboss.org
Author: jeff.yuchang
Date: 2010-05-25 04:42:40 -0400 (Tue, 25 May 2010)
New Revision: 661
Removed:
branches/ODE/ODE-1.x-jpa/
Log:
* remove this old branch, as it is out of date.
14 years, 1 month
riftsaw SVN: r660 - branches/ODE.
by riftsaw-commits@lists.jboss.org
Author: jeff.yuchang
Date: 2010-05-25 04:36:49 -0400 (Tue, 25 May 2010)
New Revision: 660
Removed:
branches/ODE/ODE-2.0-maven/
Log:
* remove this branch, as it has already been merged in the ODE.
14 years, 1 month
riftsaw SVN: r659 - branches/ODE/ODE-1.x-fixes/bpel-store/src/main/java/org/apache/ode/store and 2 other directories.
by riftsaw-commits@lists.jboss.org
Author: bbrodt
Date: 2010-05-18 22:30:41 -0400 (Tue, 18 May 2010)
New Revision: 659
Modified:
branches/ODE/ODE-1.x-fixes/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java
branches/ODE/ODE-1.x-fixes/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java
trunk/runtime/engine/src/main/java/org/apache/ode/store/RiftSawProcessStore.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/BPELEngineImpl.java
Log:
https://jira.jboss.org/browse/RIFTSAW-155
1. ProcessStoreImpl.retirePreviousPackageVersions() is different for Riftsaw vs ODE, so had to change base class visibility of this method to protected and override in RiftSawProcessStore.
2. applied "incomplete.patch" from https://issues.apache.org/jira/browse/ODE-697 - this sure helped.
3. override for ProcessStore.setState() in RiftSawProcessStore adds code to retire currently active process version if a different version is activated
Modified: branches/ODE/ODE-1.x-fixes/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java
===================================================================
--- branches/ODE/ODE-1.x-fixes/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java 2010-05-18 16:38:39 UTC (rev 658)
+++ branches/ODE/ODE-1.x-fixes/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java 2010-05-19 02:30:41 UTC (rev 659)
@@ -317,7 +317,11 @@
List<BpelProcess> processes = _serviceMap.get(e.serviceName);
if (processes == null) {
processes = new ArrayList<BpelProcess>();
- _serviceMap.put(e.serviceName, processes);
+ // https://jira.jboss.org/browse/RIFTSAW-155
+ // this is the "incomplete.patch" from
+ // https://issues.apache.org/jira/browse/ODE-697
+ if (process.getConf().getState() == ProcessState.ACTIVE)
+ _serviceMap.put(e.serviceName, processes);
}
// Remove any older version of the process from the list
Iterator<BpelProcess> processesIter = processes.iterator();
@@ -339,7 +343,11 @@
}
}
- processes.add(process);
+ // https://jira.jboss.org/browse/RIFTSAW-155
+ // this is the "incomplete.patch" from
+ // https://issues.apache.org/jira/browse/ODE-697
+ if (process.getConf().getState() == ProcessState.ACTIVE)
+ processes.add(process);
}
process.activate(this);
}
Modified: branches/ODE/ODE-1.x-fixes/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java
===================================================================
--- branches/ODE/ODE-1.x-fixes/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java 2010-05-18 16:38:39 UTC (rev 658)
+++ branches/ODE/ODE-1.x-fixes/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java 2010-05-19 02:30:41 UTC (rev 659)
@@ -73,7 +73,7 @@
private Map<QName, ProcessConfImpl> _processes = new HashMap<QName, ProcessConfImpl>();
- private Map<String, DeploymentUnitDir> _deploymentUnits = new HashMap<String, DeploymentUnitDir>();
+ protected Map<String, DeploymentUnitDir> _deploymentUnits = new HashMap<String, DeploymentUnitDir>();
/** Guards access to the _processes and _deploymentUnits */
private final ReadWriteLock _rw = new ReentrantReadWriteLock();
@@ -326,7 +326,10 @@
* "AbsenceRequest([-\\.](\d)+)?/AbsenceRequest.ode" will be matched against
* "AbsenceRequest-2/AbsenceRequest.ode" and setRetirePackage() will be called accordingly.
*/
- private void retirePreviousPackageVersions(DeploymentUnitDir du) {
+ // https://jira.jboss.org/browse/RIFTSAW-155
+ // need to override this in RiftSawProcessStore because Riftsaw deployment unit naming
+ // is different from ODE.
+ protected void retirePreviousPackageVersions(DeploymentUnitDir du) {
//retire all the other versions of the same DU
String[] nameParts = du.getName().split("/");
/* Replace the version number (if any) with regexp to match any version number */
@@ -424,6 +427,24 @@
} finally {
_rw.readLock().unlock();
}
+
+ // https://jira.jboss.org/browse/RIFTSAW-155
+ if (ProcessState.ACTIVE.equals(state)) {
+ // this version is being activated: check if another version of this
+ // process type is already active and if so, retire it.
+ Iterator<ProcessConfImpl> processesIter = _processes.values().iterator();;
+ while (processesIter.hasNext()) {
+ ProcessConfImpl other_pconf = processesIter.next();
+ QName other_pid = other_pconf.getProcessId();
+ __log.debug("other pid " + other_pid + " vs this pid " + pid);
+ if (ProcessState.ACTIVE.equals(other_pconf.getState()) &&
+ pconf.getType().equals(other_pconf.getType()) &&
+ !pid.equals(other_pid))
+ {
+ setState(other_pconf.getProcessId(),ProcessState.RETIRED);
+ }
+ }
+ }
final DeploymentUnitDir dudir = pconf.getDeploymentUnit();
Modified: trunk/runtime/engine/src/main/java/org/apache/ode/store/RiftSawProcessStore.java
===================================================================
--- trunk/runtime/engine/src/main/java/org/apache/ode/store/RiftSawProcessStore.java 2010-05-18 16:38:39 UTC (rev 658)
+++ trunk/runtime/engine/src/main/java/org/apache/ode/store/RiftSawProcessStore.java 2010-05-19 02:30:41 UTC (rev 659)
@@ -19,7 +19,11 @@
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import javax.naming.InitialContext;
import javax.sql.DataSource;
@@ -28,12 +32,14 @@
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.engine.BpelProcess;
//import org.apache.ode.bpel.extension.ExtensionValidator;
import org.apache.ode.bpel.iapi.ContextException;
import org.apache.ode.bpel.iapi.EndpointReferenceContext;
import org.apache.ode.bpel.iapi.ProcessState;
import org.apache.ode.bpel.iapi.ProcessStoreEvent;
import org.apache.ode.il.config.OdeConfigProperties;
+import org.apache.ode.store.ProcessStoreImpl.Callable;
import org.jboss.soa.bpel.deployer.BPELDeployer;
import org.jboss.soa.bpel.deployer.BPELDeploymentUnit;
@@ -87,6 +93,22 @@
}
*/
+ // https://jira.jboss.org/browse/RIFTSAW-155
+ protected void retirePreviousPackageVersions(DeploymentUnitDir du) {
+ //retire all the other versions of the same DU
+ // Riftsaw deployment units are slightly different
+ String name = du.getName();
+ name = name.replaceAll("-(\\d)+\\.jar", "-(\\\\d)+\\\\.jar");
+
+ Pattern duNamePattern = Pattern.compile(name);
+ for (String deployedDUname : _deploymentUnits.keySet()) {
+ Matcher matcher = duNamePattern.matcher(deployedDUname);
+ if (matcher.matches()) {
+ setRetiredPackage(deployedDUname, true);
+ }
+ }
+ }
+
public class DeployScheduler extends Thread {
public DeployScheduler() {
Modified: trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/BPELEngineImpl.java
===================================================================
--- trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/BPELEngineImpl.java 2010-05-18 16:38:39 UTC (rev 658)
+++ trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/BPELEngineImpl.java 2010-05-19 02:30:41 UTC (rev 659)
@@ -569,7 +569,9 @@
case ACTVIATED:
// bounce the process
_bpelServer.unregister(pse.pid);
- if (pconf != null) {
+ if (pconf != null && ProcessState.ACTIVE.equals(pconf.getState())) {
+ // https://jira.jboss.org/browse/RIFTSAW-155
+ // only re-register if this process is still active
_bpelServer.register(pconf);
} else {
__log.debug("slighly odd: recevied event " +
@@ -582,7 +584,9 @@
// remove the process
_bpelServer.unregister(pse.pid);
// bounce the process if necessary
- if (instantiated) {
+ if (instantiated && pconf!=null && ProcessState.ACTIVE.equals(pconf.getState())) {
+ // https://jira.jboss.org/browse/RIFTSAW-155
+ // only re-register if this process is still active
if (pconf != null) {
_bpelServer.register(pconf);
} else {
14 years, 1 month
riftsaw SVN: r658 - trunk/docs.
by riftsaw-commits@lists.jboss.org
Author: kurt.stam(a)jboss.com
Date: 2010-05-18 12:38:39 -0400 (Tue, 18 May 2010)
New Revision: 658
Removed:
trunk/docs/commit-test.txt
Log:
test
Deleted: trunk/docs/commit-test.txt
===================================================================
14 years, 1 month
riftsaw SVN: r657 - trunk/docs.
by riftsaw-commits@lists.jboss.org
Author: kurt.stam(a)jboss.com
Date: 2010-05-18 12:37:40 -0400 (Tue, 18 May 2010)
New Revision: 657
Added:
trunk/docs/commit-test.txt
Log:
test
Added: trunk/docs/commit-test.txt
===================================================================
14 years, 1 month