HHH-6823 - Short-name config values : transactions

This commit is contained in:
Steve Ebersole 2012-08-15 14:33:34 -05:00
parent 773d0793f1
commit 5739392572
7 changed files with 111 additions and 29 deletions

View File

@ -1,10 +1,58 @@
<?xml version='1.0' encoding='utf-8' ?>
<appendix xmlns="http://docbook.org/ns/docbook"
xmlns:xl="http://www.w3.org/1999/xlink">
xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Configuration properties</title>
<section revision="1">
<title>Configuration properties</title>
<section xml:id="config-strategy">
<title>Strategy configurations</title>
<para>
Many configuration settings define pluggable strategies that Hibernate uses for various purposes.
The configuration of many of these strategy type settings accept definition in various forms. The
documentation of such configuration settings refer here. The types of forms available in such cases
include:
</para>
<variablelist>
<varlistentry>
<term>short name (if defined)</term>
<listitem>
<para>
Certain built-in strategy implementations have a corresponding short name.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>strategy instance</term>
<listitem>
<para>
An instance of the strategy implementation to use can be specified
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>strategy Class reference</term>
<listitem>
<para>
A <classname>java.lang.Class</classname> reference of the strategy implementation to use can
be specified
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>strategy Class name</term>
<listitem>
<para>
The class name (<classname>java.lang.String</classname>) of the strategy implementation to
use can be specified
</para>
</listitem>
</varlistentry>
</variablelist>
</section>
<section>
<title>General Configuration</title>
<informaltable>
<tgroup cols="3">
@ -228,9 +276,16 @@
<tbody>
<row>
<entry>hibernate.transaction.factory_class</entry>
<entry>A fully-qualified classname</entry>
<entry>The classname of a <classname>TransactionFactory</classname> to use with Hibernate Transaction API. The
default is <classname>JDBCTransactionFactory</classname>).</entry>
<entry>
<para><property>jdbc</property> or <property></property></para>
</entry>
<entry>
<para>
Names the <interfacename>org.hibernate.engine.transaction.spi.TransactionFactory</interfacename>
strategy implementation to use. See <xref linkend="config-strategy"/> and
<xref linkend="services-TransactionFactory"/>
</para>
</entry>
</row>
<row>
<entry>jta.UserTransaction</entry>
@ -358,7 +413,7 @@
<note>
<para>
For information on specific configuration of Proxool, refer to the Proxool documentation available from
<link xl:href="http://proxool.sourceforge.net/" />.
<link xlink:href="http://proxool.sourceforge.net/" />.
</para>
</note>
</section>

View File

@ -774,14 +774,13 @@
<term>Initiator</term>
<listitem>
<para>
<classname>org.hibernate.stat.internal.StatisticsInitiator</classname>
<classname>org.hibernate.engine.transaction.internal.TransactionFactoryInitiator</classname>
</para>
<para>
Defines a <property>hibernate.stats.factory</property> setting to allow
configuring the
<interfacename>org.hibernate.stat.spi.StatisticsFactory</interfacename> to use internally
when building the actual
<interfacename>org.hibernate.stat.Statistics</interfacename> instance.
Defines a <property>hibernate.transaction.factory_class</property> setting to allow
configuring which <interfacename>TransactionFactory</interfacename> to use.
<property>hibernate.transaction.factory_class</property> follows the rules set forth
under <xref linkend="config-strategy"/>.
</para>
</listitem>
</varlistentry>
@ -791,18 +790,20 @@
<itemizedlist>
<listitem>
<para>
<classname>org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory</classname> -
A JTA-based strategy in which Hibernate is not controlling the transactions. An
important distinction here is that interaction with the underlying JTA implementation
is done through the
<interfacename>javax.transaction.TransactionManager</interfacename>
<classname>org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory</classname> -
A non-JTA strategy in which the transactions are managed using the JDBC
<interfacename>java.sql.Connection</interfacename>. This implementation's short
name is <property>jdbc</property>.
</para>
</listitem>
<listitem>
<para>
<classname>org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory</classname> -
A non-JTA strategy in which the transactions are managed using the JDBC
<interfacename>java.sql.Connection</interfacename>
<classname>org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory</classname> -
A JTA-based strategy in which Hibernate is not controlling the transactions. An
important distinction here is that interaction with the underlying JTA implementation
is done through the
<interfacename>javax.transaction.TransactionManager</interfacename>. This
implementation's short name is <property>cmt</property>.
</para>
</listitem>
<listitem>
@ -811,7 +812,8 @@
A JTA-based strategy in which Hibernate *may* be controlling the transactions. An
important distinction here is that interaction with the underlying JTA
implementation is done through the
<interfacename>javax.transaction.UserTransaction</interfacename>
<interfacename>javax.transaction.UserTransaction</interfacename>. This
implementation's short name is <property>jta</property>.
</para>
</listitem>
</itemizedlist>

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding="UTF-8"?>
<chapter xml:id="transactions" revision="2" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<chapter xml:id="transactions" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Transactions and Concurrency</title>
<para>

View File

@ -41,13 +41,17 @@ import org.hibernate.service.spi.BasicServiceInitiator;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
* Standard instantiator for the standard {@link TransactionFactory} service.
* Standard initiator for {@link TransactionFactory} service.
*
* @author Steve Ebersole
*/
public class TransactionFactoryInitiator<T extends TransactionImplementor> implements BasicServiceInitiator<TransactionFactory> {
private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class,
TransactionFactoryInitiator.class.getName());
public class TransactionFactoryInitiator<T extends TransactionImplementor>
implements BasicServiceInitiator<TransactionFactory> {
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
CoreMessageLogger.class,
TransactionFactoryInitiator.class.getName()
);
public static final TransactionFactoryInitiator INSTANCE = new TransactionFactoryInitiator();
@ -87,7 +91,7 @@ public class TransactionFactoryInitiator<T extends TransactionImplementor> imple
}
}
else {
final String strategyClassName = mapLegacyNames( strategy.toString() );
final String strategyClassName = mapName( strategy.toString() );
LOG.transactionStrategy( strategyClassName );
try {
@ -111,7 +115,8 @@ public class TransactionFactoryInitiator<T extends TransactionImplementor> imple
}
}
private String mapLegacyNames(String name) {
private String mapName(String name) {
// check legacy names ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if ( "org.hibernate.transaction.JDBCTransactionFactory".equals( name ) ) {
return JdbcTransactionFactory.class.getName();
}
@ -124,6 +129,20 @@ public class TransactionFactoryInitiator<T extends TransactionImplementor> imple
return CMTTransactionFactory.class.getName();
}
// check short names ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if ( JdbcTransactionFactory.SHORT_NAME.endsWith( name ) ) {
return JdbcTransactionFactory.class.getName();
}
if ( JtaTransactionFactory.SHORT_NAME.equals( name ) ) {
return JtaTransactionFactory.class.getName();
}
if ( CMTTransactionFactory.SHORT_NAME.equals( name ) ) {
return CMTTransactionFactory.class.getName();
}
return name;
}
}

View File

@ -34,6 +34,8 @@ import org.hibernate.engine.transaction.spi.TransactionFactory;
* @author Steve Ebersole
*/
public final class JdbcTransactionFactory implements TransactionFactory<JdbcTransaction> {
public static final String SHORT_NAME = "jdbc";
@Override
public JdbcTransaction createTransaction(TransactionCoordinator transactionCoordinator) {
return new JdbcTransaction( transactionCoordinator );

View File

@ -37,6 +37,8 @@ import org.hibernate.engine.transaction.spi.TransactionFactory;
* @author Gavin King
*/
public class CMTTransactionFactory implements TransactionFactory<CMTTransaction> {
public static final String SHORT_NAME = "cmt";
@Override
public CMTTransaction createTransaction(TransactionCoordinator transactionCoordinator) {
return new CMTTransaction( transactionCoordinator );

View File

@ -40,6 +40,8 @@ import org.hibernate.service.jta.platform.spi.JtaPlatform;
* @author Les Hazlewood
*/
public class JtaTransactionFactory implements TransactionFactory<JtaTransaction> {
public static final String SHORT_NAME = "jta";
@Override
public JtaTransaction createTransaction(TransactionCoordinator transactionCoordinator) {
return new JtaTransaction( transactionCoordinator );