1 24 25 package org.ofbiz.entity.transaction; 26 27 import java.sql.Connection ; 28 import java.sql.SQLException ; 29 30 import javax.transaction.HeuristicMixedException ; 31 import javax.transaction.HeuristicRollbackException ; 32 import javax.transaction.InvalidTransactionException ; 33 import javax.transaction.NotSupportedException ; 34 import javax.transaction.RollbackException ; 35 import javax.transaction.SystemException ; 36 import javax.transaction.Transaction ; 37 import javax.transaction.TransactionManager ; 38 import javax.transaction.UserTransaction ; 39 40 import org.ofbiz.base.util.Debug; 41 import org.ofbiz.entity.GenericEntityException; 42 import org.ofbiz.entity.config.DatasourceInfo; 43 import org.ofbiz.entity.config.EntityConfigUtil; 44 import org.ofbiz.entity.jdbc.ConnectionFactory; 45 46 54 public class DumbFactory implements TransactionFactoryInterface { 55 56 public static final String module = DumbFactory.class.getName(); 57 58 public TransactionManager getTransactionManager() { 59 return new TransactionManager () { 60 public void begin() throws NotSupportedException , SystemException { 61 } 62 63 public void commit() throws RollbackException , HeuristicMixedException , HeuristicRollbackException , SecurityException , IllegalStateException , SystemException { 64 } 65 66 public int getStatus() throws SystemException { 67 return TransactionUtil.STATUS_NO_TRANSACTION; 68 } 69 70 public Transaction getTransaction() throws SystemException { 71 return null; 72 } 73 74 public void resume(Transaction transaction) throws InvalidTransactionException , IllegalStateException , SystemException { 75 } 76 77 public void rollback() throws IllegalStateException , SecurityException , SystemException { 78 } 79 80 public void setRollbackOnly() throws IllegalStateException , SystemException { 81 } 82 83 public void setTransactionTimeout(int i) throws SystemException { 84 } 85 86 public Transaction suspend() throws SystemException { 87 return null; 88 } 89 }; 90 } 91 92 public UserTransaction getUserTransaction() { 93 return new UserTransaction () { 94 public void begin() throws NotSupportedException , SystemException { 95 } 96 97 public void commit() throws RollbackException , HeuristicMixedException , HeuristicRollbackException , SecurityException , IllegalStateException , SystemException { 98 } 99 100 public int getStatus() throws SystemException { 101 return TransactionUtil.STATUS_NO_TRANSACTION; 102 } 103 104 public void rollback() throws IllegalStateException , SecurityException , SystemException { 105 } 106 107 public void setRollbackOnly() throws IllegalStateException , SystemException { 108 } 109 110 public void setTransactionTimeout(int i) throws SystemException { 111 } 112 }; 113 } 114 115 public String getTxMgrName() { 116 return "dumb"; 117 } 118 119 public Connection getConnection(String helperName) throws SQLException , GenericEntityException { 120 DatasourceInfo datasourceInfo = EntityConfigUtil.getDatasourceInfo(helperName); 121 122 if (datasourceInfo.inlineJdbcElement != null) { 123 Connection otherCon = ConnectionFactory.tryGenericConnectionSources(helperName, datasourceInfo.inlineJdbcElement); 124 return TransactionFactory.getCursorConnection(helperName, otherCon); 125 } else { 126 Debug.logError("Dumb/Empty is the configured transaction manager but no inline-jdbc element was specified in the " + helperName + " datasource. Please check your configuration", module); 127 return null; 128 } 129 } 130 131 public void shutdown() {} 132 } 133 | Popular Tags |