1 5 package org.exoplatform.services.workflow.impl; 6 7 import net.sf.hibernate.HibernateException; 8 import net.sf.hibernate.connection.ConnectionProvider; 9 10 import javax.sql.DataSource ; 11 import org.exoplatform.commons.Environment; 12 import org.exoplatform.container.PortalContainer; 13 import org.exoplatform.services.database.DatabaseService; 14 import java.sql.Connection ; 15 import java.sql.SQLException ; 16 import java.util.Properties ; 17 18 public class WorkflowConnectionProvider implements ConnectionProvider { 19 private boolean autocommit_ ; 20 21 public WorkflowConnectionProvider() { 22 int platform = Environment.getInstance().getPlatform() ; 23 autocommit_ = true ; 24 if (platform == Environment.JBOSS_PLATFORM) { 25 autocommit_ = false ; 26 } 27 } 28 29 32 public void configure(Properties props) throws HibernateException { 33 } 34 35 38 public Connection getConnection() throws SQLException { 39 PortalContainer container = PortalContainer.getInstance(); 40 DatabaseService dbService = 41 (DatabaseService) container.getComponentInstanceOfType(DatabaseService.class); 42 DataSource ds = dbService.getDataSource(DatabaseService.EXO_WORKFLOW_DATASOURCE_NAME) ; 43 Connection conn = ds.getConnection() ; 44 conn.setAutoCommit(autocommit_) ; 45 return conn ; 46 } 47 48 51 public void closeConnection(Connection conn) throws SQLException { 52 conn.close() ; 53 } 54 55 public void close() { 56 } 57 } 58 | Popular Tags |