Skip to content

Commit

Permalink
HHH-6823 - Short-name config values : transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
sebersole committed Aug 16, 2012
1 parent 773d079 commit 5739392
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -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">
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand Down
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,17 @@
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();

Expand Down Expand Up @@ -87,7 +91,7 @@ public TransactionFactory initiateService(Map configurationValues, ServiceRegist
}
}
else {
final String strategyClassName = mapLegacyNames( strategy.toString() );
final String strategyClassName = mapName( strategy.toString() );
LOG.transactionStrategy( strategyClassName );

try {
Expand All @@ -111,7 +115,8 @@ public TransactionFactory initiateService(Map configurationValues, ServiceRegist
}
}

private String mapLegacyNames(String name) {
private String mapName(String name) {
// check legacy names ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if ( "org.hibernate.transaction.JDBCTransactionFactory".equals( name ) ) {
return JdbcTransactionFactory.class.getName();
}
Expand All @@ -124,6 +129,20 @@ private String mapLegacyNames(String name) {
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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
* @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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
* @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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
* @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 );
Expand Down

0 comments on commit 5739392

Please sign in to comment.