01: //$Id: TransactionFactory.java 9595 2006-03-10 18:14:21Z steve.ebersole@jboss.com $
02: package org.hibernate.transaction;
03:
04: import java.util.Properties;
05:
06: import org.hibernate.ConnectionReleaseMode;
07: import org.hibernate.HibernateException;
08: import org.hibernate.Transaction;
09: import org.hibernate.jdbc.JDBCContext;
10: import org.hibernate.engine.SessionFactoryImplementor;
11:
12: /**
13: * An abstract factory for <tt>Transaction</tt> instances. Concrete implementations
14: * are specified by <tt>hibernate.transaction.factory_class</tt>.<br>
15: * <br>
16: * Implementors must be threadsafe and should declare a public default constructor.
17: * @see Transaction
18: *
19: * @author Anton van Straaten, Gavin King
20: */
21: public interface TransactionFactory {
22:
23: public static interface Context {
24: public SessionFactoryImplementor getFactory();
25:
26: // public boolean isOpen();
27: public boolean isClosed();
28:
29: public boolean isFlushModeNever();
30:
31: public boolean isFlushBeforeCompletionEnabled();
32:
33: public void managedFlush();
34:
35: public boolean shouldAutoClose();
36:
37: public void managedClose();
38: }
39:
40: /**
41: * Begin a transaction and return the associated <tt>Transaction</tt> instance.
42: *
43: * @param jdbcContext The jdbc context to which the transaction belongs
44: * @param context The contract regarding the context in which this transaction will operate.
45: * @return Transaction
46: * @throws HibernateException
47: */
48: public Transaction createTransaction(JDBCContext jdbcContext,
49: Context context) throws HibernateException;
50:
51: /**
52: * Configure from the given properties.
53: * @param props
54: * @throws HibernateException
55: */
56: public void configure(Properties props) throws HibernateException;
57:
58: /**
59: * Get the default connection release mode
60: */
61: public ConnectionReleaseMode getDefaultReleaseMode();
62:
63: /**
64: * Do we require access to the JTA TransactionManager for
65: * this strategy?
66: */
67: public boolean isTransactionManagerRequired();
68:
69: /**
70: * Are all transaction callbacks local to Hibernate Transactions?
71: * Or can the callbacks originate from some other source (e.g.
72: * a JTA Synchronization).
73: *
74: * @return true if callbacks only ever originate from
75: * the Hibernate {@link Transaction}; false otherwise.
76: */
77: public boolean areCallbacksLocalToHibernateTransactions();
78:
79: /**
80: * Determine whether an underlying transaction is in progress.
81: * <p/>
82: * Mainly this is used in determining whether to register a
83: * synchronization as well as whether or not to circumvent
84: * auto flushing outside transactions.
85: *
86: * @param jdbcContext
87: * @param transactionContext
88: * @param transaction
89: * @return true if an underlying transaction is know to be in effect.
90: */
91: public boolean isTransactionInProgress(JDBCContext jdbcContext,
92: Context transactionContext, Transaction transaction);
93: }
|