001: /*
002: * $Id: DumbFactory.java,v 1.2 2003/08/17 04:56:26 jonesde Exp $
003: *
004: * Copyright (c) 2001, 2002 The Open For Business Project - www.ofbiz.org
005: *
006: * Permission is hereby granted, free of charge, to any person obtaining a
007: * copy of this software and associated documentation files (the "Software"),
008: * to deal in the Software without restriction, including without limitation
009: * the rights to use, copy, modify, merge, publish, distribute, sublicense,
010: * and/or sell copies of the Software, and to permit persons to whom the
011: * Software is furnished to do so, subject to the following conditions:
012: *
013: * The above copyright notice and this permission notice shall be included
014: * in all copies or substantial portions of the Software.
015: *
016: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
017: * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
018: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
019: * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
020: * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
021: * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
022: * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
023: */
024:
025: package org.ofbiz.entity.transaction;
026:
027: import java.sql.Connection;
028: import java.sql.SQLException;
029:
030: import javax.transaction.HeuristicMixedException;
031: import javax.transaction.HeuristicRollbackException;
032: import javax.transaction.InvalidTransactionException;
033: import javax.transaction.NotSupportedException;
034: import javax.transaction.RollbackException;
035: import javax.transaction.SystemException;
036: import javax.transaction.Transaction;
037: import javax.transaction.TransactionManager;
038: import javax.transaction.UserTransaction;
039:
040: import org.ofbiz.base.util.Debug;
041: import org.ofbiz.entity.GenericEntityException;
042: import org.ofbiz.entity.config.EntityConfigUtil;
043: import org.ofbiz.entity.jdbc.ConnectionFactory;
044:
045: /**
046: * A dumb, non-working transaction manager.
047: *
048: * @author <a href="mailto:plightbo@hotmail.com">Pat Lightbody</a>
049: * @author <a href="mailto:jonesde@ofbiz.org">David E. Jones</a>
050: * @version $Revision: 1.2 $
051: * @since 2.0
052: */
053: public class DumbFactory implements TransactionFactoryInterface {
054:
055: public static final String module = DumbFactory.class.getName();
056:
057: public TransactionManager getTransactionManager() {
058: return new TransactionManager() {
059: public void begin() throws NotSupportedException,
060: SystemException {
061: }
062:
063: public void commit() throws RollbackException,
064: HeuristicMixedException,
065: HeuristicRollbackException, SecurityException,
066: IllegalStateException, SystemException {
067: }
068:
069: public int getStatus() throws SystemException {
070: return TransactionUtil.STATUS_NO_TRANSACTION;
071: }
072:
073: public Transaction getTransaction() throws SystemException {
074: return null;
075: }
076:
077: public void resume(Transaction transaction)
078: throws InvalidTransactionException,
079: IllegalStateException, SystemException {
080: }
081:
082: public void rollback() throws IllegalStateException,
083: SecurityException, SystemException {
084: }
085:
086: public void setRollbackOnly() throws IllegalStateException,
087: SystemException {
088: }
089:
090: public void setTransactionTimeout(int i)
091: throws SystemException {
092: }
093:
094: public Transaction suspend() throws SystemException {
095: return null;
096: }
097: };
098: }
099:
100: public UserTransaction getUserTransaction() {
101: return new UserTransaction() {
102: public void begin() throws NotSupportedException,
103: SystemException {
104: }
105:
106: public void commit() throws RollbackException,
107: HeuristicMixedException,
108: HeuristicRollbackException, SecurityException,
109: IllegalStateException, SystemException {
110: }
111:
112: public int getStatus() throws SystemException {
113: return TransactionUtil.STATUS_NO_TRANSACTION;
114: }
115:
116: public void rollback() throws IllegalStateException,
117: SecurityException, SystemException {
118: }
119:
120: public void setRollbackOnly() throws IllegalStateException,
121: SystemException {
122: }
123:
124: public void setTransactionTimeout(int i)
125: throws SystemException {
126: }
127: };
128: }
129:
130: public String getTxMgrName() {
131: return "dumb";
132: }
133:
134: public Connection getConnection(String helperName)
135: throws SQLException, GenericEntityException {
136: EntityConfigUtil.DatasourceInfo datasourceInfo = EntityConfigUtil
137: .getDatasourceInfo(helperName);
138:
139: if (datasourceInfo.inlineJdbcElement != null) {
140: Connection otherCon = ConnectionFactory
141: .tryGenericConnectionSources(helperName,
142: datasourceInfo.inlineJdbcElement);
143: return otherCon;
144: } else {
145: Debug
146: .logError(
147: "Dumb/Empty is the configured transaction manager but no inline-jdbc element was specified in the "
148: + helperName
149: + " datasource. Please check your configuration",
150: module);
151: return null;
152: }
153: }
154:
155: public void shutdown() {
156: }
157: }
|