HHH-6823 - Short-name config values
This commit is contained in:
parent
4ad49a02c9
commit
37542fe1f1
|
@ -408,11 +408,12 @@
|
||||||
</para>
|
</para>
|
||||||
<important>
|
<important>
|
||||||
<para>
|
<para>
|
||||||
<classname>JtaPlatformInitiator</classname> provides mapping against the legacy,
|
As of 5.0 support has been completely removed for mapping against legacy
|
||||||
now-deprecated <interfacename>org.hibernate.transaction.TransactionManagerLookup</interfacename>
|
|
||||||
names internally for the Hibernate-provided
|
|
||||||
<interfacename>org.hibernate.transaction.TransactionManagerLookup</interfacename>
|
<interfacename>org.hibernate.transaction.TransactionManagerLookup</interfacename>
|
||||||
implementations.
|
names and custom implementations. Applications implementing
|
||||||
|
<interfacename>org.hibernate.transaction.TransactionManagerLookup</interfacename>
|
||||||
|
or using the <property>hibernate.transaction.manager_lookup_class</property> setting
|
||||||
|
should update to use JtaPlatform.
|
||||||
</para>
|
</para>
|
||||||
</important>
|
</important>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
@ -424,43 +425,50 @@
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
<classname>org.hibernate.engine.transaction.jta.platform.internal.BitronixJtaPlatform</classname> -
|
<classname>org.hibernate.engine.transaction.jta.platform.internal.BitronixJtaPlatform</classname> -
|
||||||
Integration with the Bitronix stand-alone transaction manager.
|
Integration with the Bitronix stand-alone transaction manager. Can also be referenced
|
||||||
|
using the <property>Bitronix</property> configuration short name
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
<classname>org.hibernate.engine.transaction.jta.platform.internal.BorlandEnterpriseServerJtaPlatform</classname> -
|
<classname>org.hibernate.engine.transaction.jta.platform.internal.BorlandEnterpriseServerJtaPlatform</classname> -
|
||||||
Integration with the transaction manager as deployed within a Borland Enterprise Server
|
Integration with the transaction manager as deployed within a Borland Enterprise Server.
|
||||||
|
Can also be referenced using the <property>Borland</property> configuration short name
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
<classname>org.hibernate.engine.transaction.jta.platform.internal.JBossAppServerJtaPlatform</classname> -
|
<classname>org.hibernate.engine.transaction.jta.platform.internal.JBossAppServerJtaPlatform</classname> -
|
||||||
Integration with the transaction manager as deployed within a JBoss Application Server
|
Integration with the transaction manager as deployed within a JBoss Application Server.
|
||||||
|
Can also be referenced using the <property>JBossAS</property> configuration short name
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
<classname>org.hibernate.engine.transaction.jta.platform.internal.JBossStandAloneJtaPlatform</classname> -
|
<classname>org.hibernate.engine.transaction.jta.platform.internal.JBossStandAloneJtaPlatform</classname> -
|
||||||
Integration with the JBoss Transactions stand-alone transaction manager
|
Integration with the JBoss Transactions stand-alone transaction manager.
|
||||||
|
Can also be referenced using the <property>JBossTS</property> configuration short name
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
<classname>org.hibernate.engine.transaction.jta.platform.internal.JOTMJtaPlatform</classname> -
|
<classname>org.hibernate.engine.transaction.jta.platform.internal.JOTMJtaPlatform</classname> -
|
||||||
Integration with the JOTM stand-alone transaction manager
|
Integration with the JOTM stand-alone transaction manager. Can also be referenced
|
||||||
|
using the <property>JOTM</property> configuration short name
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
<classname>org.hibernate.engine.transaction.jta.platform.internal.JOnASJtaPlatform</classname> -
|
<classname>org.hibernate.engine.transaction.jta.platform.internal.JOnASJtaPlatform</classname> -
|
||||||
Integration with the JOnAS transaction manager.
|
Integration with the JOnAS transaction manager. Can also be referenced using the
|
||||||
|
<property>JOnAS</property> configuration short name
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
<classname>org.hibernate.engine.transaction.jta.platform.internal.JRun4JtaPlatform</classname> -
|
<classname>org.hibernate.engine.transaction.jta.platform.internal.JRun4JtaPlatform</classname> -
|
||||||
Integration with the transaction manager as deployed in a JRun 4 application server.
|
Integration with the transaction manager as deployed in a JRun 4 application server.
|
||||||
|
Can also be referenced using the <property>JRun4</property> configuration short name
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
@ -473,6 +481,7 @@
|
||||||
<para>
|
<para>
|
||||||
<classname>org.hibernate.engine.transaction.jta.platform.internal.OC4JJtaPlatform</classname> -
|
<classname>org.hibernate.engine.transaction.jta.platform.internal.OC4JJtaPlatform</classname> -
|
||||||
Integration with transaction manager as deployed in an OC4J (Oracle) application
|
Integration with transaction manager as deployed in an OC4J (Oracle) application
|
||||||
|
Can also be referenced using the <property>OC4J</property> configuration short name
|
||||||
server.
|
server.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
@ -480,47 +489,45 @@
|
||||||
<para>
|
<para>
|
||||||
<classname>org.hibernate.engine.transaction.jta.platform.internal.OrionJtaPlatform</classname> -
|
<classname>org.hibernate.engine.transaction.jta.platform.internal.OrionJtaPlatform</classname> -
|
||||||
Integration with transaction manager as deployed in an Orion application server.
|
Integration with transaction manager as deployed in an Orion application server.
|
||||||
|
Can also be referenced using the <property>Orion</property> configuration short name
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
<classname>org.hibernate.engine.transaction.jta.platform.internal.ResinJtaPlatform</classname> -
|
<classname>org.hibernate.engine.transaction.jta.platform.internal.ResinJtaPlatform</classname> -
|
||||||
Integration with transaction manager as deployed in a Resin application server.
|
Integration with transaction manager as deployed in a Resin application server.
|
||||||
|
Can also be referenced using the <property>Resin</property> configuration short name
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
<classname>org.hibernate.engine.transaction.jta.platform.internal.SunOneJtaPlatform</classname> -
|
<classname>org.hibernate.engine.transaction.jta.platform.internal.SunOneJtaPlatform</classname> -
|
||||||
Integration with transaction manager as deployed in a Sun ONE (7 and above)
|
Integration with transaction manager as deployed in a Sun ONE (7 and above)
|
||||||
application server.
|
application server. Can also be referenced using the <property>SunOne</property>
|
||||||
</para>
|
configuration short name
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
<classname>org.hibernate.engine.transaction.jta.platform.internal.TransactionManagerLookupBridge</classname> -
|
|
||||||
Provides a bridge to legacy (and deprecated)
|
|
||||||
<interfacename>org.hibernate.transaction.TransactionManagerLookup</interfacename>
|
|
||||||
implementations
|
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
<classname>org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform</classname> -
|
<classname>org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform</classname> -
|
||||||
Integration with transaction manager as deployed in a WebSphere Application Server
|
Integration with transaction manager as deployed in a WebSphere Application Server
|
||||||
(6 and above).
|
(6 and above). Can also be referenced using the <property>WebSphereExtended</property>
|
||||||
|
configuration short name
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
<classname>org.hibernate.engine.transaction.jta.platform.internal.WebSphereJtaPlatform</classname> -
|
<classname>org.hibernate.engine.transaction.jta.platform.internal.WebSphereJtaPlatform</classname> -
|
||||||
Integration with transaction manager as deployed in a WebSphere Application Server
|
Integration with transaction manager as deployed in a WebSphere Application Server
|
||||||
(4, 5.0 and 5.1).
|
(4, 5.0 and 5.1). Can also be referenced using the <property>WebSphere</property>
|
||||||
|
configuration short name
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
<classname>org.hibernate.engine.transaction.jta.platform.internal.WeblogicJtaPlatform</classname> -
|
<classname>org.hibernate.engine.transaction.jta.platform.internal.WeblogicJtaPlatform</classname> -
|
||||||
Integration with transaction manager as deployed in a Weblogic application server.
|
Integration with transaction manager as deployed in a Weblogic application server.
|
||||||
|
Can also be referenced using the <property>Weblogic</property> configuration short name
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
|
|
@ -167,21 +167,6 @@
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section xml:id="architecture-jmx" revision="1">
|
|
||||||
<title>JMX Integration</title>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
JMX is the J2EE standard for the management of Java components. Hibernate can be managed via
|
|
||||||
a JMX standard service. AN MBean implementation is provided in the distribution:
|
|
||||||
<literal>org.hibernate.jmx.HibernateService</literal>.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
Another feature available as a JMX service is runtime Hibernate statistics. See
|
|
||||||
<xref linkend="configuration-optional-statistics"/> for more information.
|
|
||||||
</para>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section xml:id="architecture-current-session" revision="2">
|
<section xml:id="architecture-current-session" revision="2">
|
||||||
<title>Contextual sessions</title>
|
<title>Contextual sessions</title>
|
||||||
<para>
|
<para>
|
||||||
|
@ -259,7 +244,7 @@
|
||||||
The <literal>hibernate.current_session_context_class</literal> configuration parameter
|
The <literal>hibernate.current_session_context_class</literal> configuration parameter
|
||||||
defines which <literal>org.hibernate.context.spi.CurrentSessionContext</literal> implementation
|
defines which <literal>org.hibernate.context.spi.CurrentSessionContext</literal> implementation
|
||||||
should be used. For backwards compatibility, if this configuration parameter is not set
|
should be used. For backwards compatibility, if this configuration parameter is not set
|
||||||
but a <literal>org.hibernate.transaction.TransactionManagerLookup</literal> is configured,
|
but a <literal>org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform</literal> is configured,
|
||||||
Hibernate will use the <literal>org.hibernate.context.internal.JTASessionContext</literal>.
|
Hibernate will use the <literal>org.hibernate.context.internal.JTASessionContext</literal>.
|
||||||
Typically, the value of this parameter would just name the implementation class to
|
Typically, the value of this parameter would just name the implementation class to
|
||||||
use. For the three out-of-the-box implementations, however, there are three corresponding
|
use. For the three out-of-the-box implementations, however, there are three corresponding
|
||||||
|
|
|
@ -1734,74 +1734,5 @@ hibernate.dialect = org.hibernate.dialect.PostgreSQL82Dialect</programlisting>
|
||||||
transaction demarcation with CMT is preferred.</para>
|
transaction demarcation with CMT is preferred.</para>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section xml:id="configuration-j2ee-jmx" revision="1">
|
|
||||||
<title>JMX deployment</title>
|
|
||||||
|
|
||||||
<para>The line <literal>cfg.buildSessionFactory()</literal> still has to
|
|
||||||
be executed somewhere to get a <literal>SessionFactory</literal> into
|
|
||||||
JNDI. You can do this either in a <literal>static</literal> initializer
|
|
||||||
block, like the one in <literal>HibernateUtil</literal>, or you can
|
|
||||||
deploy Hibernate as a <emphasis>managed service</emphasis>.</para>
|
|
||||||
|
|
||||||
<para>Hibernate is distributed with
|
|
||||||
<literal>org.hibernate.jmx.HibernateService</literal> for deployment on
|
|
||||||
an application server with JMX capabilities, such as JBoss AS. The
|
|
||||||
actual deployment and configuration is vendor-specific. Here is an
|
|
||||||
example <literal>jboss-service.xml</literal> for JBoss 4.0.x:</para>
|
|
||||||
|
|
||||||
<programlisting role="XML"><?xml version="1.0"?>
|
|
||||||
<server>
|
|
||||||
|
|
||||||
<mbean code="org.hibernate.jmx.HibernateService"
|
|
||||||
name="jboss.jca:service=HibernateFactory,name=HibernateFactory">
|
|
||||||
|
|
||||||
<!-- Required services -->
|
|
||||||
<depends>jboss.jca:service=RARDeployer</depends>
|
|
||||||
<depends>jboss.jca:service=LocalTxCM,name=HsqlDS</depends>
|
|
||||||
|
|
||||||
<!-- Bind the Hibernate service to JNDI -->
|
|
||||||
<attribute name="JndiName">java:/hibernate/SessionFactory</attribute>
|
|
||||||
|
|
||||||
<!-- Datasource settings -->
|
|
||||||
<attribute name="Datasource">java:HsqlDS</attribute>
|
|
||||||
<attribute name="Dialect">org.hibernate.dialect.HSQLDialect</attribute>
|
|
||||||
|
|
||||||
<!-- Transaction integration -->
|
|
||||||
<attribute name="TransactionStrategy">
|
|
||||||
org.hibernate.transaction.JTATransactionFactory</attribute>
|
|
||||||
<attribute name="TransactionManagerLookupStrategy">
|
|
||||||
org.hibernate.transaction.JBossTransactionManagerLookup</attribute>
|
|
||||||
<attribute name="FlushBeforeCompletionEnabled">true</attribute>
|
|
||||||
<attribute name="AutoCloseSessionEnabled">true</attribute>
|
|
||||||
|
|
||||||
<!-- Fetching options -->
|
|
||||||
<attribute name="MaximumFetchDepth">5</attribute>
|
|
||||||
|
|
||||||
<!-- Second-level caching -->
|
|
||||||
<attribute name="SecondLevelCacheEnabled">true</attribute>
|
|
||||||
<attribute name="CacheProviderClass">org.hibernate.cache.internal.EhCacheProvider</attribute>
|
|
||||||
<attribute name="QueryCacheEnabled">true</attribute>
|
|
||||||
|
|
||||||
<!-- Logging -->
|
|
||||||
<attribute name="ShowSqlEnabled">true</attribute>
|
|
||||||
|
|
||||||
<!-- Mapping files -->
|
|
||||||
<attribute name="MapResources">auction/Item.hbm.xml,auction/Category.hbm.xml</attribute>
|
|
||||||
|
|
||||||
</mbean>
|
|
||||||
|
|
||||||
</server></programlisting>
|
|
||||||
|
|
||||||
<para>This file is deployed in a directory called
|
|
||||||
<literal>META-INF</literal> and packaged in a JAR file with the
|
|
||||||
extension <literal>.sar</literal> (service archive). You also need to
|
|
||||||
package Hibernate, its required third-party libraries, your compiled
|
|
||||||
persistent classes, as well as your mapping files in the same archive.
|
|
||||||
Your enterprise beans (usually session beans) can be kept in their own
|
|
||||||
JAR file, but you can include this EJB JAR file in the main service
|
|
||||||
archive to get a single (hot-)deployable unit. Consult the JBoss AS
|
|
||||||
documentation for more information about JMX service and EJB
|
|
||||||
deployment.</para>
|
|
||||||
</section>
|
|
||||||
</section>
|
</section>
|
||||||
</chapter>
|
</chapter>
|
||||||
|
|
|
@ -28,13 +28,69 @@ import java.util.List;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
import org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory;
|
|
||||||
import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
|
|
||||||
import org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory;
|
|
||||||
import org.hibernate.engine.transaction.spi.TransactionFactory;
|
|
||||||
import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
|
import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
|
||||||
import org.hibernate.boot.registry.selector.spi.StrategySelectionException;
|
import org.hibernate.boot.registry.selector.spi.StrategySelectionException;
|
||||||
import org.hibernate.boot.registry.selector.spi.StrategySelector;
|
import org.hibernate.boot.registry.selector.spi.StrategySelector;
|
||||||
|
import org.hibernate.dialect.CUBRIDDialect;
|
||||||
|
import org.hibernate.dialect.Cache71Dialect;
|
||||||
|
import org.hibernate.dialect.DB2390Dialect;
|
||||||
|
import org.hibernate.dialect.DB2400Dialect;
|
||||||
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
|
import org.hibernate.dialect.DerbyTenFiveDialect;
|
||||||
|
import org.hibernate.dialect.DerbyTenSevenDialect;
|
||||||
|
import org.hibernate.dialect.DerbyTenSixDialect;
|
||||||
|
import org.hibernate.dialect.Dialect;
|
||||||
|
import org.hibernate.dialect.FirebirdDialect;
|
||||||
|
import org.hibernate.dialect.FrontBaseDialect;
|
||||||
|
import org.hibernate.dialect.H2Dialect;
|
||||||
|
import org.hibernate.dialect.HSQLDialect;
|
||||||
|
import org.hibernate.dialect.InformixDialect;
|
||||||
|
import org.hibernate.dialect.Ingres10Dialect;
|
||||||
|
import org.hibernate.dialect.Ingres9Dialect;
|
||||||
|
import org.hibernate.dialect.IngresDialect;
|
||||||
|
import org.hibernate.dialect.InterbaseDialect;
|
||||||
|
import org.hibernate.dialect.JDataStoreDialect;
|
||||||
|
import org.hibernate.dialect.MckoiDialect;
|
||||||
|
import org.hibernate.dialect.MimerSQLDialect;
|
||||||
|
import org.hibernate.dialect.MySQL5Dialect;
|
||||||
|
import org.hibernate.dialect.MySQL5InnoDBDialect;
|
||||||
|
import org.hibernate.dialect.Oracle10gDialect;
|
||||||
|
import org.hibernate.dialect.Oracle8iDialect;
|
||||||
|
import org.hibernate.dialect.Oracle9iDialect;
|
||||||
|
import org.hibernate.dialect.PointbaseDialect;
|
||||||
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
|
import org.hibernate.dialect.PostgreSQL82Dialect;
|
||||||
|
import org.hibernate.dialect.PostgresPlusDialect;
|
||||||
|
import org.hibernate.dialect.ProgressDialect;
|
||||||
|
import org.hibernate.dialect.SAPDBDialect;
|
||||||
|
import org.hibernate.dialect.SQLServer2005Dialect;
|
||||||
|
import org.hibernate.dialect.SQLServer2008Dialect;
|
||||||
|
import org.hibernate.dialect.SQLServerDialect;
|
||||||
|
import org.hibernate.dialect.Sybase11Dialect;
|
||||||
|
import org.hibernate.dialect.SybaseASE157Dialect;
|
||||||
|
import org.hibernate.dialect.SybaseASE15Dialect;
|
||||||
|
import org.hibernate.dialect.SybaseAnywhereDialect;
|
||||||
|
import org.hibernate.dialect.TeradataDialect;
|
||||||
|
import org.hibernate.dialect.TimesTenDialect;
|
||||||
|
import org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory;
|
||||||
|
import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
|
||||||
|
import org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory;
|
||||||
|
import org.hibernate.engine.transaction.jta.platform.internal.BitronixJtaPlatform;
|
||||||
|
import org.hibernate.engine.transaction.jta.platform.internal.BorlandEnterpriseServerJtaPlatform;
|
||||||
|
import org.hibernate.engine.transaction.jta.platform.internal.JBossAppServerJtaPlatform;
|
||||||
|
import org.hibernate.engine.transaction.jta.platform.internal.JBossStandAloneJtaPlatform;
|
||||||
|
import org.hibernate.engine.transaction.jta.platform.internal.JOTMJtaPlatform;
|
||||||
|
import org.hibernate.engine.transaction.jta.platform.internal.JOnASJtaPlatform;
|
||||||
|
import org.hibernate.engine.transaction.jta.platform.internal.JRun4JtaPlatform;
|
||||||
|
import org.hibernate.engine.transaction.jta.platform.internal.OC4JJtaPlatform;
|
||||||
|
import org.hibernate.engine.transaction.jta.platform.internal.OrionJtaPlatform;
|
||||||
|
import org.hibernate.engine.transaction.jta.platform.internal.ResinJtaPlatform;
|
||||||
|
import org.hibernate.engine.transaction.jta.platform.internal.SunOneJtaPlatform;
|
||||||
|
import org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform;
|
||||||
|
import org.hibernate.engine.transaction.jta.platform.internal.WebSphereJtaPlatform;
|
||||||
|
import org.hibernate.engine.transaction.jta.platform.internal.WeblogicJtaPlatform;
|
||||||
|
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
|
||||||
|
import org.hibernate.engine.transaction.spi.TransactionFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
|
@ -80,6 +136,8 @@ public class StrategySelectorBuilder {
|
||||||
StrategySelectorImpl strategySelector = new StrategySelectorImpl( classLoaderService );
|
StrategySelectorImpl strategySelector = new StrategySelectorImpl( classLoaderService );
|
||||||
|
|
||||||
// build the baseline...
|
// build the baseline...
|
||||||
|
addDialects( strategySelector );
|
||||||
|
addJtaPlatforms( strategySelector );
|
||||||
addTransactionFactories( strategySelector );
|
addTransactionFactories( strategySelector );
|
||||||
|
|
||||||
// todo : apply auto-discovered registrations
|
// todo : apply auto-discovered registrations
|
||||||
|
@ -92,6 +150,157 @@ public class StrategySelectorBuilder {
|
||||||
return strategySelector;
|
return strategySelector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addDialects(StrategySelectorImpl strategySelector) {
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "Cache71", Cache71Dialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "CUBRID", CUBRIDDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "DB2", DB2Dialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "DB2-390", DB2390Dialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "DB2-400", DB2400Dialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "Derby10.5", DerbyTenFiveDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "Derby10.6", DerbyTenSixDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "Derby10.7", DerbyTenSevenDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "Firebird", FirebirdDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "FrontBase", FrontBaseDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "H2", H2Dialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "HSQL", HSQLDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "Informix", InformixDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "Ingres", IngresDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "Ingres9", Ingres9Dialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "Ingres10", Ingres10Dialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "Interbase", InterbaseDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "JDataStore", JDataStoreDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "Mckoi", MckoiDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "MimerSQL", MimerSQLDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "MySQL5", MySQL5Dialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "MySQL5-InnoDB", MySQL5InnoDBDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "MySQL", MySQL5Dialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "MySQL-InnoDB", MySQL5InnoDBDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "Oracle8i", Oracle8iDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "Oracle9i", Oracle9iDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "Oracle10g", Oracle10gDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "Pointbase", PointbaseDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "PostgresPlus", PostgresPlusDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "PostgreSQL81", PostgreSQL81Dialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "PostgreSQL82", PostgreSQL82Dialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "Progress", ProgressDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "SAP", SAPDBDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "SQLServer", SQLServerDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "SQLServer2005", SQLServer2005Dialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "SQLServer2008", SQLServer2008Dialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "Sybase11", Sybase11Dialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "SybaseAnywhere", SybaseAnywhereDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "SybaseASE15", SybaseASE15Dialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "SybaseASE157", SybaseASE157Dialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "Teradata", TeradataDialect.class );
|
||||||
|
strategySelector.registerStrategyImplementor( Dialect.class, "TimesTen", TimesTenDialect.class );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addJtaPlatforms(StrategySelectorImpl strategySelector) {
|
||||||
|
addJtaPlatforms(
|
||||||
|
strategySelector,
|
||||||
|
BorlandEnterpriseServerJtaPlatform.class,
|
||||||
|
"Borland",
|
||||||
|
"org.hibernate.service.jta.platform.internal.BorlandEnterpriseServerJtaPlatform"
|
||||||
|
);
|
||||||
|
|
||||||
|
addJtaPlatforms(
|
||||||
|
strategySelector,
|
||||||
|
BitronixJtaPlatform.class,
|
||||||
|
"Bitronix",
|
||||||
|
"org.hibernate.service.jta.platform.internal.BitronixJtaPlatform"
|
||||||
|
);
|
||||||
|
|
||||||
|
addJtaPlatforms(
|
||||||
|
strategySelector,
|
||||||
|
JBossAppServerJtaPlatform.class,
|
||||||
|
"JBossAS",
|
||||||
|
"org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform"
|
||||||
|
);
|
||||||
|
|
||||||
|
addJtaPlatforms(
|
||||||
|
strategySelector,
|
||||||
|
JBossStandAloneJtaPlatform.class,
|
||||||
|
"JBossTS",
|
||||||
|
"org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform"
|
||||||
|
);
|
||||||
|
|
||||||
|
addJtaPlatforms(
|
||||||
|
strategySelector,
|
||||||
|
JOnASJtaPlatform.class,
|
||||||
|
"JOnAS",
|
||||||
|
"org.hibernate.service.jta.platform.internal.JOnASJtaPlatform"
|
||||||
|
);
|
||||||
|
|
||||||
|
addJtaPlatforms(
|
||||||
|
strategySelector,
|
||||||
|
JOTMJtaPlatform.class,
|
||||||
|
"JOTM",
|
||||||
|
"org.hibernate.service.jta.platform.internal.JOTMJtaPlatform"
|
||||||
|
);
|
||||||
|
|
||||||
|
addJtaPlatforms(
|
||||||
|
strategySelector,
|
||||||
|
JRun4JtaPlatform.class,
|
||||||
|
"JRun4",
|
||||||
|
"org.hibernate.service.jta.platform.internal.JRun4JtaPlatform"
|
||||||
|
);
|
||||||
|
|
||||||
|
addJtaPlatforms(
|
||||||
|
strategySelector,
|
||||||
|
OC4JJtaPlatform.class,
|
||||||
|
"OC4J",
|
||||||
|
"org.hibernate.service.jta.platform.internal.OC4JJtaPlatform"
|
||||||
|
);
|
||||||
|
|
||||||
|
addJtaPlatforms(
|
||||||
|
strategySelector,
|
||||||
|
OrionJtaPlatform.class,
|
||||||
|
"Orion",
|
||||||
|
"org.hibernate.service.jta.platform.internal.OrionJtaPlatform"
|
||||||
|
);
|
||||||
|
|
||||||
|
addJtaPlatforms(
|
||||||
|
strategySelector,
|
||||||
|
ResinJtaPlatform.class,
|
||||||
|
"Resin",
|
||||||
|
"org.hibernate.service.jta.platform.internal.ResinJtaPlatform"
|
||||||
|
);
|
||||||
|
|
||||||
|
addJtaPlatforms(
|
||||||
|
strategySelector,
|
||||||
|
SunOneJtaPlatform.class,
|
||||||
|
"SunOne",
|
||||||
|
"org.hibernate.service.jta.platform.internal.SunOneJtaPlatform"
|
||||||
|
);
|
||||||
|
|
||||||
|
addJtaPlatforms(
|
||||||
|
strategySelector,
|
||||||
|
WeblogicJtaPlatform.class,
|
||||||
|
"Weblogic",
|
||||||
|
"org.hibernate.service.jta.platform.internal.WeblogicJtaPlatform"
|
||||||
|
);
|
||||||
|
|
||||||
|
addJtaPlatforms(
|
||||||
|
strategySelector,
|
||||||
|
WebSphereJtaPlatform.class,
|
||||||
|
"WebSphere",
|
||||||
|
"org.hibernate.service.jta.platform.internal.WebSphereJtaPlatform"
|
||||||
|
);
|
||||||
|
|
||||||
|
addJtaPlatforms(
|
||||||
|
strategySelector,
|
||||||
|
WebSphereExtendedJtaPlatform.class,
|
||||||
|
"WebSphereExtended",
|
||||||
|
"org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addJtaPlatforms(StrategySelectorImpl strategySelector, Class<? extends JtaPlatform> impl, String... names) {
|
||||||
|
for ( String name : names ) {
|
||||||
|
strategySelector.registerStrategyImplementor( JtaPlatform.class, name, impl );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void addTransactionFactories(StrategySelectorImpl strategySelector) {
|
private void addTransactionFactories(StrategySelectorImpl strategySelector) {
|
||||||
strategySelector.registerStrategyImplementor( TransactionFactory.class, JdbcTransactionFactory.SHORT_NAME, JdbcTransactionFactory.class );
|
strategySelector.registerStrategyImplementor( TransactionFactory.class, JdbcTransactionFactory.SHORT_NAME, JdbcTransactionFactory.class );
|
||||||
strategySelector.registerStrategyImplementor( TransactionFactory.class, "org.hibernate.transaction.JDBCTransactionFactory", JdbcTransactionFactory.class );
|
strategySelector.registerStrategyImplementor( TransactionFactory.class, "org.hibernate.transaction.JDBCTransactionFactory", JdbcTransactionFactory.class );
|
||||||
|
|
|
@ -282,23 +282,6 @@ public interface AvailableSettings {
|
||||||
*/
|
*/
|
||||||
public static final String JTA_PLATFORM = "hibernate.transaction.jta.platform";
|
public static final String JTA_PLATFORM = "hibernate.transaction.jta.platform";
|
||||||
|
|
||||||
/**
|
|
||||||
* Names the {@link org.hibernate.transaction.TransactionManagerLookup} implementation to use for obtaining
|
|
||||||
* reference to the {@literal JTA} {@link javax.transaction.TransactionManager}
|
|
||||||
*
|
|
||||||
* @deprecated See {@link #JTA_PLATFORM}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static final String TRANSACTION_MANAGER_STRATEGY = "hibernate.transaction.manager_lookup_class";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JNDI name of JTA <tt>UserTransaction</tt> object
|
|
||||||
*
|
|
||||||
* @deprecated See {@link #JTA_PLATFORM}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static final String USER_TRANSACTION = "jta.UserTransaction";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link org.hibernate.cache.spi.RegionFactory} implementation class
|
* The {@link org.hibernate.cache.spi.RegionFactory} implementation class
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -29,10 +29,9 @@ import java.sql.SQLException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.boot.registry.selector.spi.StrategySelector;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
|
||||||
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
|
||||||
import org.hibernate.engine.jdbc.dialect.spi.DialectFactory;
|
import org.hibernate.engine.jdbc.dialect.spi.DialectFactory;
|
||||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
|
import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
|
||||||
import org.hibernate.service.spi.InjectService;
|
import org.hibernate.service.spi.InjectService;
|
||||||
|
@ -43,11 +42,11 @@ import org.hibernate.service.spi.InjectService;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class DialectFactoryImpl implements DialectFactory {
|
public class DialectFactoryImpl implements DialectFactory {
|
||||||
private ClassLoaderService classLoaderService;
|
private StrategySelector strategySelector;
|
||||||
|
|
||||||
@InjectService
|
@InjectService
|
||||||
public void setClassLoaderService(ClassLoaderService classLoaderService) {
|
public void setStrategySelector(StrategySelector strategySelector) {
|
||||||
this.classLoaderService = classLoaderService;
|
this.strategySelector = strategySelector;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DialectResolver dialectResolver;
|
private DialectResolver dialectResolver;
|
||||||
|
@ -69,17 +68,19 @@ public class DialectFactoryImpl implements DialectFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dialect constructDialect(String dialectName) {
|
private Dialect constructDialect(String dialectName) {
|
||||||
|
final Dialect dialect;
|
||||||
try {
|
try {
|
||||||
return ( Dialect ) classLoaderService.classForName( dialectName ).newInstance();
|
dialect = strategySelector.resolveStrategy( Dialect.class, dialectName );
|
||||||
|
if ( dialect == null ) {
|
||||||
|
throw new HibernateException( "Unable to construct requested dialect [" + dialectName+ "]" );
|
||||||
}
|
}
|
||||||
catch ( ClassLoadingException e ) {
|
return dialect;
|
||||||
throw new HibernateException( "Dialect class not found: " + dialectName, e );
|
|
||||||
}
|
}
|
||||||
catch ( HibernateException e ) {
|
catch (HibernateException e) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
catch ( Exception e ) {
|
catch (Exception e) {
|
||||||
throw new HibernateException( "Could not instantiate dialect class", e );
|
throw new HibernateException( "Unable to construct requested dialect [" + dialectName+ "]", e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,16 +28,11 @@ import java.util.Map;
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
import org.hibernate.boot.registry.StandardServiceInitiator;
|
import org.hibernate.boot.registry.StandardServiceInitiator;
|
||||||
|
import org.hibernate.boot.registry.selector.spi.StrategySelector;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.cfg.Environment;
|
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
|
||||||
import org.hibernate.internal.util.jndi.JndiHelper;
|
|
||||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
|
||||||
import org.hibernate.engine.config.spi.ConfigurationService;
|
|
||||||
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
|
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
|
||||||
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
||||||
import org.hibernate.transaction.TransactionManagerLookup;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard initiator for the standard {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform}
|
* Standard initiator for the standard {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform}
|
||||||
|
@ -57,106 +52,12 @@ public class JtaPlatformInitiator implements StandardServiceInitiator<JtaPlatfor
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings( {"unchecked"})
|
@SuppressWarnings( {"unchecked"})
|
||||||
public JtaPlatform initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
|
public JtaPlatform initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
|
||||||
final Object platform = getConfiguredPlatform( configurationValues, registry );
|
final Object setting = configurationValues.get( AvailableSettings.JTA_PLATFORM );
|
||||||
|
final JtaPlatform platform = registry.getService( StrategySelector.class ).resolveStrategy( JtaPlatform.class, setting );
|
||||||
if ( platform == null ) {
|
if ( platform == null ) {
|
||||||
|
LOG.debugf( " No JtaPlatform was specified, using default [%s]", NoJtaPlatform.class.getName() );
|
||||||
return new NoJtaPlatform();
|
return new NoJtaPlatform();
|
||||||
}
|
}
|
||||||
return registry.getService( ConfigurationService.class )
|
|
||||||
.cast( JtaPlatform.class, platform );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object getConfiguredPlatform(Map configVales, ServiceRegistryImplementor registry) {
|
|
||||||
Object platform = configVales.get( AvailableSettings.JTA_PLATFORM );
|
|
||||||
if ( platform == null ) {
|
|
||||||
final String transactionManagerLookupImplName = (String) configVales.get( Environment.TRANSACTION_MANAGER_STRATEGY );
|
|
||||||
if ( transactionManagerLookupImplName != null ) {
|
|
||||||
LOG.deprecatedTransactionManagerStrategy(TransactionManagerLookup.class.getName(),
|
|
||||||
Environment.TRANSACTION_MANAGER_STRATEGY,
|
|
||||||
JtaPlatform.class.getName(),
|
|
||||||
AvailableSettings.JTA_PLATFORM);
|
|
||||||
platform = mapLegacyClasses( transactionManagerLookupImplName, configVales, registry );
|
|
||||||
LOG.debugf("Mapped %s -> %s", transactionManagerLookupImplName, platform);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return platform;
|
return platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JtaPlatform mapLegacyClasses(String tmlImplName, Map configVales, ServiceRegistryImplementor registry) {
|
|
||||||
if ( tmlImplName == null ) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG.legacyTransactionManagerStrategy(JtaPlatform.class.getName(), AvailableSettings.JTA_PLATFORM);
|
|
||||||
|
|
||||||
if ( "org.hibernate.transaction.BESTransactionManagerLookup".equals( tmlImplName ) ) {
|
|
||||||
return new BorlandEnterpriseServerJtaPlatform();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( "org.hibernate.transaction.BTMTransactionManagerLookup".equals( tmlImplName ) ) {
|
|
||||||
return new BitronixJtaPlatform();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( "org.hibernate.transaction.JBossTransactionManagerLookup".equals( tmlImplName ) ) {
|
|
||||||
return new JBossAppServerJtaPlatform();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( "org.hibernate.transaction.JBossTSStandaloneTransactionManagerLookup".equals( tmlImplName ) ) {
|
|
||||||
return new JBossStandAloneJtaPlatform();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( "org.hibernate.transaction.JOnASTransactionManagerLookup".equals( tmlImplName ) ) {
|
|
||||||
return new JOnASJtaPlatform();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( "org.hibernate.transaction.JOTMTransactionManagerLookup".equals( tmlImplName ) ) {
|
|
||||||
return new JOTMJtaPlatform();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( "org.hibernate.transaction.JRun4TransactionManagerLookup".equals( tmlImplName ) ) {
|
|
||||||
return new JRun4JtaPlatform();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( "org.hibernate.transaction.OC4JTransactionManagerLookup".equals( tmlImplName ) ) {
|
|
||||||
return new OC4JJtaPlatform();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( "org.hibernate.transaction.OrionTransactionManagerLookup".equals( tmlImplName ) ) {
|
|
||||||
return new OrionJtaPlatform();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( "org.hibernate.transaction.ResinTransactionManagerLookup".equals( tmlImplName ) ) {
|
|
||||||
return new ResinJtaPlatform();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( "org.hibernate.transaction.SunONETransactionManagerLookup".equals( tmlImplName ) ) {
|
|
||||||
return new SunOneJtaPlatform();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( "org.hibernate.transaction.WeblogicTransactionManagerLookup".equals( tmlImplName ) ) {
|
|
||||||
return new WeblogicJtaPlatform();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( "org.hibernate.transaction.WebSphereTransactionManagerLookup".equals( tmlImplName ) ) {
|
|
||||||
return new WebSphereJtaPlatform();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( "org.hibernate.transaction.WebSphereExtendedJTATransactionLookup".equals( tmlImplName ) ) {
|
|
||||||
return new WebSphereExtendedJtaPlatform();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
TransactionManagerLookup lookup = (TransactionManagerLookup) registry.getService( ClassLoaderService.class )
|
|
||||||
.classForName( tmlImplName )
|
|
||||||
.newInstance();
|
|
||||||
return new TransactionManagerLookupBridge( lookup, JndiHelper.extractJndiProperties( configVales ) );
|
|
||||||
}
|
|
||||||
catch ( Exception e ) {
|
|
||||||
throw new JtaPlatformException(
|
|
||||||
"Unable to build " + TransactionManagerLookupBridge.class.getName() + " from specified " +
|
|
||||||
TransactionManagerLookup.class.getName() + " implementation: " +
|
|
||||||
tmlImplName
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
|
|
||||||
* indicated by the @author tags or express copyright attribution
|
|
||||||
* statements applied by the authors. All third-party contributions are
|
|
||||||
* distributed under license by Red Hat Inc.
|
|
||||||
*
|
|
||||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
|
||||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
|
||||||
* Lesser General Public License, as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this distribution; if not, write to:
|
|
||||||
* Free Software Foundation, Inc.
|
|
||||||
* 51 Franklin Street, Fifth Floor
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package org.hibernate.engine.transaction.jta.platform.internal;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
import javax.transaction.Transaction;
|
|
||||||
import javax.transaction.TransactionManager;
|
|
||||||
import javax.transaction.UserTransaction;
|
|
||||||
|
|
||||||
import org.hibernate.engine.jndi.spi.JndiService;
|
|
||||||
import org.hibernate.transaction.TransactionManagerLookup;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Steve Ebersole
|
|
||||||
*/
|
|
||||||
public class TransactionManagerLookupBridge extends AbstractJtaPlatform {
|
|
||||||
private final TransactionManagerLookup lookup;
|
|
||||||
private final Properties jndiProperties;
|
|
||||||
|
|
||||||
public TransactionManagerLookupBridge(TransactionManagerLookup lookup, Properties jndiProperties) {
|
|
||||||
this.lookup = lookup;
|
|
||||||
this.jndiProperties = jndiProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TransactionManager locateTransactionManager() {
|
|
||||||
return lookup.getTransactionManager( jndiProperties );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected UserTransaction locateUserTransaction() {
|
|
||||||
return (UserTransaction) serviceRegistry().getService( JndiService.class ).locate( lookup.getUserTransactionName() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getTransactionIdentifier(Transaction transaction) {
|
|
||||||
return lookup.getTransactionIdentifier( transaction );
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1501,12 +1501,12 @@ public interface CoreMessageLogger extends BasicLogger {
|
||||||
@Message(value = "You should set hibernate.transaction.manager_lookup_class if cache is enabled", id = 426)
|
@Message(value = "You should set hibernate.transaction.manager_lookup_class if cache is enabled", id = 426)
|
||||||
void setManagerLookupClass();
|
void setManagerLookupClass();
|
||||||
|
|
||||||
@LogMessage(level = WARN)
|
// @LogMessage(level = WARN)
|
||||||
@Message(value = "Using deprecated %s strategy [%s], use newer %s strategy instead [%s]", id = 427)
|
// @Message(value = "Using deprecated %s strategy [%s], use newer %s strategy instead [%s]", id = 427)
|
||||||
void deprecatedTransactionManagerStrategy(String name,
|
// void deprecatedTransactionManagerStrategy(String name,
|
||||||
String transactionManagerStrategy,
|
// String transactionManagerStrategy,
|
||||||
String name2,
|
// String name2,
|
||||||
String jtaPlatform);
|
// String jtaPlatform);
|
||||||
|
|
||||||
@LogMessage(level = INFO)
|
@LogMessage(level = INFO)
|
||||||
@Message(value = "Encountered legacy TransactionManagerLookup specified; convert to newer %s contract specified via %s setting",
|
@Message(value = "Encountered legacy TransactionManagerLookup specified; convert to newer %s contract specified via %s setting",
|
||||||
|
|
|
@ -1,200 +0,0 @@
|
||||||
//$Id: HibernateService.java 6100 2005-03-17 10:48:03Z turin42 $
|
|
||||||
package org.hibernate.jmx;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
import javax.naming.InitialContext;
|
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
|
||||||
import org.hibernate.SessionFactory;
|
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
|
||||||
import org.hibernate.cfg.Environment;
|
|
||||||
import org.hibernate.cfg.ExternalSessionFactoryConfig;
|
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
|
||||||
import org.hibernate.internal.util.jndi.JndiHelper;
|
|
||||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of <tt>HibernateServiceMBean</tt>. Creates a
|
|
||||||
* <tt>SessionFactory</tt> and binds it to the specified JNDI name.<br>
|
|
||||||
* <br>
|
|
||||||
* All mapping documents are loaded as resources by the MBean.
|
|
||||||
* @see HibernateServiceMBean
|
|
||||||
* @see org.hibernate.SessionFactory
|
|
||||||
* @author John Urberg, Gavin King
|
|
||||||
* @deprecated See <a href="http://opensource.atlassian.com/projects/hibernate/browse/HHH-6190">HHH-6190</a> for details
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class HibernateService extends ExternalSessionFactoryConfig implements HibernateServiceMBean {
|
|
||||||
|
|
||||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, HibernateService.class.getName());
|
|
||||||
|
|
||||||
private String boundName;
|
|
||||||
private Properties properties = new Properties();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start() throws HibernateException {
|
|
||||||
boundName = getJndiName();
|
|
||||||
try {
|
|
||||||
buildSessionFactory();
|
|
||||||
}
|
|
||||||
catch (HibernateException he) {
|
|
||||||
LOG.unableToBuildSessionFactoryUsingMBeanClasspath(he.getMessage());
|
|
||||||
LOG.debug("Error was", he);
|
|
||||||
new SessionFactoryStub(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void stop() {
|
|
||||||
LOG.stoppingService();
|
|
||||||
try {
|
|
||||||
InitialContext context = JndiHelper.getInitialContext( buildProperties() );
|
|
||||||
( (SessionFactory) context.lookup(boundName) ).close();
|
|
||||||
//context.unbind(boundName);
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
LOG.unableToStopHibernateService(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SessionFactory buildSessionFactory() throws HibernateException {
|
|
||||||
LOG.startingServiceAtJndiName( boundName );
|
|
||||||
LOG.serviceProperties( properties );
|
|
||||||
return buildConfiguration().buildSessionFactory(
|
|
||||||
new StandardServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Map getExtraProperties() {
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTransactionStrategy() {
|
|
||||||
return getProperty(Environment.TRANSACTION_STRATEGY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setTransactionStrategy(String txnStrategy) {
|
|
||||||
setProperty(Environment.TRANSACTION_STRATEGY, txnStrategy);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUserTransactionName() {
|
|
||||||
return getProperty(Environment.USER_TRANSACTION);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setUserTransactionName(String utName) {
|
|
||||||
setProperty(Environment.USER_TRANSACTION, utName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getJtaPlatformName() {
|
|
||||||
return getProperty( AvailableSettings.JTA_PLATFORM );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setJtaPlatformName(String name) {
|
|
||||||
setProperty( AvailableSettings.JTA_PLATFORM, name );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPropertyList() {
|
|
||||||
return buildProperties().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getProperty(String property) {
|
|
||||||
return properties.getProperty(property);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setProperty(String property, String value) {
|
|
||||||
properties.setProperty(property, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dropSchema() {
|
|
||||||
new SchemaExport( buildConfiguration() ).drop(false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void createSchema() {
|
|
||||||
new SchemaExport( buildConfiguration() ).create(false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return getProperty(Environment.SESSION_FACTORY_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDatasource() {
|
|
||||||
return getProperty(Environment.DATASOURCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setDatasource(String datasource) {
|
|
||||||
setProperty(Environment.DATASOURCE, datasource);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getJndiName() {
|
|
||||||
return getProperty(Environment.SESSION_FACTORY_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setJndiName(String jndiName) {
|
|
||||||
setProperty(Environment.SESSION_FACTORY_NAME, jndiName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUserName() {
|
|
||||||
return getProperty(Environment.USER);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setUserName(String userName) {
|
|
||||||
setProperty(Environment.USER, userName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPassword() {
|
|
||||||
return getProperty(Environment.PASS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPassword(String password) {
|
|
||||||
setProperty(Environment.PASS, password);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setFlushBeforeCompletionEnabled(String enabled) {
|
|
||||||
setProperty(Environment.FLUSH_BEFORE_COMPLETION, enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getFlushBeforeCompletionEnabled() {
|
|
||||||
return getProperty(Environment.FLUSH_BEFORE_COMPLETION);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setAutoCloseSessionEnabled(String enabled) {
|
|
||||||
setProperty(Environment.AUTO_CLOSE_SESSION, enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getAutoCloseSessionEnabled() {
|
|
||||||
return getProperty(Environment.AUTO_CLOSE_SESSION);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Properties getProperties() {
|
|
||||||
return buildProperties();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,337 +0,0 @@
|
||||||
//$Id: HibernateServiceMBean.java 10860 2006-11-22 00:02:55Z steve.ebersole@jboss.com $
|
|
||||||
package org.hibernate.jmx;
|
|
||||||
import org.hibernate.HibernateException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hibernate JMX Management API
|
|
||||||
* @see HibernateService
|
|
||||||
* @author John Urberg, Gavin King
|
|
||||||
* @deprecated See <a href="http://opensource.atlassian.com/projects/hibernate/browse/HHH-6190">HHH-6190</a> for details
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public interface HibernateServiceMBean {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Hibernate mapping files (might be overridden by subclasses
|
|
||||||
* that want to specify the mapping files by some other mechanism)
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
public String getMapResources();
|
|
||||||
/**
|
|
||||||
* Specify the Hibernate mapping files
|
|
||||||
* @param mappingFiles
|
|
||||||
*/
|
|
||||||
public void setMapResources(String mappingFiles);
|
|
||||||
/**
|
|
||||||
* Add a mapping file
|
|
||||||
* @param mapResource
|
|
||||||
*/
|
|
||||||
public void addMapResource(String mapResource);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set a property
|
|
||||||
* @param property the property name
|
|
||||||
* @param value the property value
|
|
||||||
*/
|
|
||||||
public void setProperty(String property, String value);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a property
|
|
||||||
* @param property the property name
|
|
||||||
* @return the property value
|
|
||||||
*/
|
|
||||||
public String getProperty(String property);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display the properties
|
|
||||||
* @return a list of property names and values
|
|
||||||
*/
|
|
||||||
public String getPropertyList();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The JNDI name of the datasource to use in this <tt>SessionFactory</tt>
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
public String getDatasource();
|
|
||||||
/**
|
|
||||||
* Set the JNDI name of the datasource to use in this <tt>SessionFactory</tt>
|
|
||||||
* @param datasource
|
|
||||||
*/
|
|
||||||
public void setDatasource(String datasource);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Log into the database with this name
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
public String getUserName();
|
|
||||||
/**
|
|
||||||
* Log into the database with this name
|
|
||||||
* @param userName
|
|
||||||
*/
|
|
||||||
public void setUserName(String userName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Log into the database with this password
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
public String getPassword();
|
|
||||||
/**
|
|
||||||
* Log into the database with this password
|
|
||||||
* @param password
|
|
||||||
*/
|
|
||||||
public void setPassword(String password);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The JNDI name of the dialect class to use in this <tt>SessionFactory</tt>
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
public String getDialect();
|
|
||||||
/**
|
|
||||||
* The name of the dialect class to use in this <tt>SessionFactory</tt>
|
|
||||||
* @param dialect fully qualified class name of <tt>Dialect</tt> subclass
|
|
||||||
* @see org.hibernate.dialect.Dialect
|
|
||||||
*/
|
|
||||||
public void setDialect(String dialect);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The JNDI name to bind to the <tt>SessionFactory</tt>
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
public String getJndiName();
|
|
||||||
/**
|
|
||||||
* The JNDI name to bind to the <tt>SessionFactory</tt>
|
|
||||||
* @param jndiName
|
|
||||||
*/
|
|
||||||
public void setJndiName(String jndiName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The fully qualified class name of the Hibernate {@link org.hibernate.engine.transaction.spi.TransactionFactory}
|
|
||||||
* implementation to use
|
|
||||||
*
|
|
||||||
* @return the class name
|
|
||||||
*/
|
|
||||||
public String getTransactionStrategy();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the fully qualified class name of the Hibernate {@link org.hibernate.engine.transaction.spi.TransactionFactory}
|
|
||||||
* implementation to use.
|
|
||||||
*
|
|
||||||
* @param txnStrategy the class name
|
|
||||||
*/
|
|
||||||
public void setTransactionStrategy(String txnStrategy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The JNDI name of the JTA UserTransaction object (used only be <tt>JtaTransaction</tt>).
|
|
||||||
* @return the JNDI name
|
|
||||||
* @see org.hibernate.engine.transaction.internal.jta.JtaTransaction
|
|
||||||
*/
|
|
||||||
public String getUserTransactionName();
|
|
||||||
/**
|
|
||||||
* Set the JNDI name of the JTA UserTransaction object (used only by <tt>JtaTransaction</tt>).
|
|
||||||
* @param utName the JNDI name
|
|
||||||
* @see org.hibernate.engine.transaction.internal.jta.JtaTransaction
|
|
||||||
*/
|
|
||||||
public void setUserTransactionName(String utName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the name of the {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation to use.
|
|
||||||
*
|
|
||||||
* @return The name of the {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation to use.
|
|
||||||
*/
|
|
||||||
public String getJtaPlatformName();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the name of the {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation to use.
|
|
||||||
*
|
|
||||||
* @param name The implementation class name.
|
|
||||||
*/
|
|
||||||
public void setJtaPlatformName(String name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Is SQL logging enabled?
|
|
||||||
*/
|
|
||||||
public String getShowSqlEnabled();
|
|
||||||
/**
|
|
||||||
* Enable logging of SQL to console
|
|
||||||
*/
|
|
||||||
public void setShowSqlEnabled(String showSql);
|
|
||||||
/**
|
|
||||||
* Get the maximum outer join fetch depth
|
|
||||||
*/
|
|
||||||
public String getMaximumFetchDepth();
|
|
||||||
/**
|
|
||||||
* Set the maximum outer join fetch depth
|
|
||||||
*/
|
|
||||||
public void setMaximumFetchDepth(String fetchDepth);
|
|
||||||
/**
|
|
||||||
* Get the maximum JDBC batch size
|
|
||||||
*/
|
|
||||||
public String getJdbcBatchSize();
|
|
||||||
/**
|
|
||||||
* Set the maximum JDBC batch size
|
|
||||||
*/
|
|
||||||
public void setJdbcBatchSize(String batchSize);
|
|
||||||
/**
|
|
||||||
* Get the JDBC fetch size
|
|
||||||
*/
|
|
||||||
public String getJdbcFetchSize();
|
|
||||||
/**
|
|
||||||
* Set the JDBC fetch size
|
|
||||||
*/
|
|
||||||
public void setJdbcFetchSize(String fetchSize);
|
|
||||||
/**
|
|
||||||
* Get the query language substitutions
|
|
||||||
*/
|
|
||||||
public String getQuerySubstitutions();
|
|
||||||
/**
|
|
||||||
* Set the query language substitutions
|
|
||||||
*/
|
|
||||||
public void setQuerySubstitutions(String querySubstitutions);
|
|
||||||
/**
|
|
||||||
* Get the default schema
|
|
||||||
*/
|
|
||||||
public String getDefaultSchema();
|
|
||||||
/**
|
|
||||||
* Set the default schema
|
|
||||||
*/
|
|
||||||
public void setDefaultSchema(String schema);
|
|
||||||
/**
|
|
||||||
* Get the default catalog
|
|
||||||
*/
|
|
||||||
public String getDefaultCatalog();
|
|
||||||
/**
|
|
||||||
* Set the default catalog
|
|
||||||
*/
|
|
||||||
public void setDefaultCatalog(String catalog);
|
|
||||||
/**
|
|
||||||
* Is use of scrollable resultsets enabled?
|
|
||||||
*/
|
|
||||||
public String getJdbcScrollableResultSetEnabled();
|
|
||||||
/**
|
|
||||||
* Enable or disable the use of scrollable resultsets
|
|
||||||
*/
|
|
||||||
public void setJdbcScrollableResultSetEnabled(String enabled);
|
|
||||||
/**
|
|
||||||
* Is use of JDBC3 <tt>getGeneratedKeys()</tt> enabled?
|
|
||||||
*/
|
|
||||||
public String getGetGeneratedKeysEnabled();
|
|
||||||
/**
|
|
||||||
* Enable or disable the use <tt>getGeneratedKeys()</tt>
|
|
||||||
*/
|
|
||||||
public void setGetGeneratedKeysEnabled(String enabled);
|
|
||||||
/**
|
|
||||||
* Get the second-level cache provider class name
|
|
||||||
*/
|
|
||||||
public String getCacheRegionFactory();
|
|
||||||
/**
|
|
||||||
* Set the second-level cache provider class name
|
|
||||||
*/
|
|
||||||
public void setCacheRegionFactory(String cacheRegionFactory);
|
|
||||||
/**
|
|
||||||
* For cache providers which support this setting, get the
|
|
||||||
* provider's specific configuration resource.
|
|
||||||
*/
|
|
||||||
public String getCacheProviderConfig();
|
|
||||||
/**
|
|
||||||
* For cache providers which support this setting, specify the
|
|
||||||
* provider's specific configuration resource.
|
|
||||||
*/
|
|
||||||
public void setCacheProviderConfig(String cacheProviderConfig);
|
|
||||||
/**
|
|
||||||
* Is the query cache enabled?
|
|
||||||
*/
|
|
||||||
public String getQueryCacheEnabled();
|
|
||||||
/**
|
|
||||||
* Enable or disable the query cache
|
|
||||||
*/
|
|
||||||
public void setQueryCacheEnabled(String enabled);
|
|
||||||
/**
|
|
||||||
* Is the second-level cache enabled?
|
|
||||||
*/
|
|
||||||
public String getSecondLevelCacheEnabled();
|
|
||||||
/**
|
|
||||||
* Enable or disable the second-level cache
|
|
||||||
*/
|
|
||||||
public void setSecondLevelCacheEnabled(String enabled);
|
|
||||||
/**
|
|
||||||
* Get the cache region prefix
|
|
||||||
*/
|
|
||||||
public String getCacheRegionPrefix();
|
|
||||||
/**
|
|
||||||
* Set the cache region prefix
|
|
||||||
*/
|
|
||||||
public void setCacheRegionPrefix(String prefix);
|
|
||||||
/**
|
|
||||||
* Is the second-level cache optimized for miminal puts?
|
|
||||||
*/
|
|
||||||
public String getMinimalPutsEnabled();
|
|
||||||
/**
|
|
||||||
* Enable or disable optimization of second-level cache
|
|
||||||
* for minimal puts
|
|
||||||
*/
|
|
||||||
public void setMinimalPutsEnabled(String enabled);
|
|
||||||
/**
|
|
||||||
* Are SQL comments enabled?
|
|
||||||
*/
|
|
||||||
public String getCommentsEnabled();
|
|
||||||
/**
|
|
||||||
* Enable or disable the inclusion of comments in
|
|
||||||
* generated SQL
|
|
||||||
*/
|
|
||||||
public void setCommentsEnabled(String enabled);
|
|
||||||
/**
|
|
||||||
* Is JDBC batch update for versioned entities enabled?
|
|
||||||
*/
|
|
||||||
public String getBatchVersionedDataEnabled();
|
|
||||||
/**
|
|
||||||
* Enable or disable the use of batch updates for
|
|
||||||
* versioned entities
|
|
||||||
*/
|
|
||||||
public void setBatchVersionedDataEnabled(String enabled);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable automatic flushing of the Session when JTA transaction ends.
|
|
||||||
*/
|
|
||||||
public void setFlushBeforeCompletionEnabled(String enabled);
|
|
||||||
/**
|
|
||||||
* Is automatic Session flusing enabled?
|
|
||||||
*/
|
|
||||||
public String getFlushBeforeCompletionEnabled();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable automatic closing of Session when JTA transaction ends.
|
|
||||||
*/
|
|
||||||
public void setAutoCloseSessionEnabled(String enabled);
|
|
||||||
/**
|
|
||||||
* Is automatic Session closing enabled?
|
|
||||||
*/
|
|
||||||
public String getAutoCloseSessionEnabled();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Export the <tt>CREATE</tt> DDL to the database
|
|
||||||
* @throws HibernateException
|
|
||||||
*/
|
|
||||||
public void createSchema() throws HibernateException;
|
|
||||||
/**
|
|
||||||
* Export the <tt>DROP</tt> DDL to the database
|
|
||||||
* @throws HibernateException
|
|
||||||
*/
|
|
||||||
public void dropSchema() throws HibernateException;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the <tt>SessionFactory</tt> and bind to the jndi name on startup
|
|
||||||
*/
|
|
||||||
public void start() throws HibernateException;
|
|
||||||
/**
|
|
||||||
* Unbind the <tt>SessionFactory</tt> or stub from JNDI
|
|
||||||
*/
|
|
||||||
public void stop();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,258 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
|
|
||||||
* indicated by the @author tags or express copyright attribution
|
|
||||||
* statements applied by the authors. All third-party contributions are
|
|
||||||
* distributed under license by Red Hat Inc.
|
|
||||||
*
|
|
||||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
|
||||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
|
||||||
* Lesser General Public License, as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this distribution; if not, write to:
|
|
||||||
* Free Software Foundation, Inc.
|
|
||||||
* 51 Franklin Street, Fifth Floor
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package org.hibernate.jmx;
|
|
||||||
|
|
||||||
import java.io.InvalidObjectException;
|
|
||||||
import java.io.ObjectStreamException;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import javax.naming.NamingException;
|
|
||||||
import javax.naming.Reference;
|
|
||||||
import javax.naming.StringRefAddr;
|
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
|
||||||
|
|
||||||
import org.hibernate.AssertionFailure;
|
|
||||||
import org.hibernate.Cache;
|
|
||||||
import org.hibernate.HibernateException;
|
|
||||||
import org.hibernate.Session;
|
|
||||||
import org.hibernate.SessionBuilder;
|
|
||||||
import org.hibernate.SessionFactory;
|
|
||||||
import org.hibernate.StatelessSession;
|
|
||||||
import org.hibernate.StatelessSessionBuilder;
|
|
||||||
import org.hibernate.TypeHelper;
|
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
|
||||||
import org.hibernate.engine.spi.FilterDefinition;
|
|
||||||
import org.hibernate.id.IdentifierGenerator;
|
|
||||||
import org.hibernate.id.UUIDGenerator;
|
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
|
||||||
import org.hibernate.internal.SessionFactoryRegistry;
|
|
||||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
|
||||||
import org.hibernate.metadata.ClassMetadata;
|
|
||||||
import org.hibernate.metadata.CollectionMetadata;
|
|
||||||
import org.hibernate.engine.jndi.internal.JndiServiceImpl;
|
|
||||||
import org.hibernate.stat.Statistics;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A flyweight for <tt>SessionFactory</tt>. If the MBean itself does not
|
|
||||||
* have classpath to the persistent classes, then a stub will be registered
|
|
||||||
* with JNDI and the actual <tt>SessionFactoryImpl</tt> built upon first
|
|
||||||
* access.
|
|
||||||
*
|
|
||||||
* @author Gavin King
|
|
||||||
*
|
|
||||||
* @deprecated See <a href="http://opensource.atlassian.com/projects/hibernate/browse/HHH-6190">HHH-6190</a> for details
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@SuppressWarnings( {"deprecation"})
|
|
||||||
public class SessionFactoryStub implements SessionFactory {
|
|
||||||
private static final IdentifierGenerator UUID_GENERATOR = UUIDGenerator.buildSessionFactoryUniqueIdentifierGenerator();
|
|
||||||
|
|
||||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, SessionFactoryStub.class.getName());
|
|
||||||
|
|
||||||
private transient SessionFactory impl;
|
|
||||||
private transient HibernateService service;
|
|
||||||
private String uuid;
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
SessionFactoryStub(HibernateService service) {
|
|
||||||
this.service = service;
|
|
||||||
this.name = service.getJndiName();
|
|
||||||
try {
|
|
||||||
uuid = (String) UUID_GENERATOR.generate(null, null);
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
throw new AssertionFailure("Could not generate UUID");
|
|
||||||
}
|
|
||||||
|
|
||||||
SessionFactoryRegistry.INSTANCE.addSessionFactory(
|
|
||||||
uuid,
|
|
||||||
name,
|
|
||||||
ConfigurationHelper.getBoolean(
|
|
||||||
AvailableSettings.SESSION_FACTORY_NAME_IS_JNDI,
|
|
||||||
service.getProperties(),
|
|
||||||
true
|
|
||||||
),
|
|
||||||
this,
|
|
||||||
new JndiServiceImpl( service.getProperties() )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SessionFactoryOptions getSessionFactoryOptions() {
|
|
||||||
return impl.getSessionFactoryOptions();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SessionBuilder withOptions() {
|
|
||||||
return getImpl().withOptions();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Session openSession() throws HibernateException {
|
|
||||||
return getImpl().openSession();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Session getCurrentSession() {
|
|
||||||
return getImpl().getCurrentSession();
|
|
||||||
}
|
|
||||||
|
|
||||||
private synchronized SessionFactory getImpl() {
|
|
||||||
if (impl==null) impl = service.buildSessionFactory();
|
|
||||||
return impl;
|
|
||||||
}
|
|
||||||
|
|
||||||
//readResolveObject
|
|
||||||
private Object readResolve() throws ObjectStreamException {
|
|
||||||
// look for the instance by uuid
|
|
||||||
Object result = SessionFactoryRegistry.INSTANCE.getSessionFactory( uuid ) ;
|
|
||||||
if ( result == null ) {
|
|
||||||
// in case we were deserialized in a different JVM, look for an instance with the same name
|
|
||||||
// (alternatively we could do an actual JNDI lookup here....)
|
|
||||||
result = SessionFactoryRegistry.INSTANCE.getNamedSessionFactory( name );
|
|
||||||
if ( result == null ) {
|
|
||||||
throw new InvalidObjectException( "Could not find a SessionFactory [uuid=" + uuid + ",name=" + name + "]" );
|
|
||||||
}
|
|
||||||
LOG.debug("Resolved stub SessionFactory by name");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LOG.debug("Resolved stub SessionFactory by UUID");
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see javax.naming.Referenceable#getReference()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Reference getReference() throws NamingException {
|
|
||||||
return new Reference(
|
|
||||||
SessionFactoryStub.class.getName(),
|
|
||||||
new StringRefAddr("uuid", uuid),
|
|
||||||
SessionFactoryRegistry.ObjectFactoryImpl.class.getName(),
|
|
||||||
null
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClassMetadata getClassMetadata(Class persistentClass) throws HibernateException {
|
|
||||||
return getImpl().getClassMetadata(persistentClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClassMetadata getClassMetadata(String entityName)
|
|
||||||
throws HibernateException {
|
|
||||||
return getImpl().getClassMetadata(entityName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CollectionMetadata getCollectionMetadata(String roleName) throws HibernateException {
|
|
||||||
return getImpl().getCollectionMetadata(roleName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String,ClassMetadata> getAllClassMetadata() throws HibernateException {
|
|
||||||
return getImpl().getAllClassMetadata();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map getAllCollectionMetadata() throws HibernateException {
|
|
||||||
return getImpl().getAllCollectionMetadata();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void close() throws HibernateException {
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isClosed() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Cache getCache() {
|
|
||||||
return getImpl().getCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void evict(Class persistentClass, Serializable id)
|
|
||||||
throws HibernateException {
|
|
||||||
getImpl().evict(persistentClass, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void evict(Class persistentClass) throws HibernateException {
|
|
||||||
getImpl().evict(persistentClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void evictEntity(String entityName, Serializable id)
|
|
||||||
throws HibernateException {
|
|
||||||
getImpl().evictEntity(entityName, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void evictEntity(String entityName) throws HibernateException {
|
|
||||||
getImpl().evictEntity(entityName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void evictCollection(String roleName, Serializable id)
|
|
||||||
throws HibernateException {
|
|
||||||
getImpl().evictCollection(roleName, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void evictCollection(String roleName) throws HibernateException {
|
|
||||||
getImpl().evictCollection(roleName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void evictQueries() throws HibernateException {
|
|
||||||
getImpl().evictQueries();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void evictQueries(String cacheRegion) throws HibernateException {
|
|
||||||
getImpl().evictQueries(cacheRegion);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Statistics getStatistics() {
|
|
||||||
return getImpl().getStatistics();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public StatelessSessionBuilder withStatelessOptions() {
|
|
||||||
return getImpl().withStatelessOptions();
|
|
||||||
}
|
|
||||||
|
|
||||||
public StatelessSession openStatelessSession() {
|
|
||||||
return getImpl().openStatelessSession();
|
|
||||||
}
|
|
||||||
|
|
||||||
public StatelessSession openStatelessSession(Connection conn) {
|
|
||||||
return getImpl().openStatelessSession(conn);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set getDefinedFilterNames() {
|
|
||||||
return getImpl().getDefinedFilterNames();
|
|
||||||
}
|
|
||||||
|
|
||||||
public FilterDefinition getFilterDefinition(String filterName) throws HibernateException {
|
|
||||||
return getImpl().getFilterDefinition( filterName );
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean containsFetchProfileDefinition(String name) {
|
|
||||||
return getImpl().containsFetchProfileDefinition( name );
|
|
||||||
}
|
|
||||||
|
|
||||||
public TypeHelper getTypeHelper() {
|
|
||||||
return getImpl().getTypeHelper();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,367 +0,0 @@
|
||||||
package org.hibernate.jmx;
|
|
||||||
|
|
||||||
import javax.naming.InitialContext;
|
|
||||||
import javax.naming.NameNotFoundException;
|
|
||||||
import javax.naming.NamingException;
|
|
||||||
import javax.naming.Reference;
|
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
|
||||||
|
|
||||||
import org.hibernate.SessionFactory;
|
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
|
||||||
import org.hibernate.internal.SessionFactoryRegistry;
|
|
||||||
import org.hibernate.stat.CollectionStatistics;
|
|
||||||
import org.hibernate.stat.EntityStatistics;
|
|
||||||
import org.hibernate.stat.NaturalIdCacheStatistics;
|
|
||||||
import org.hibernate.stat.QueryStatistics;
|
|
||||||
import org.hibernate.stat.SecondLevelCacheStatistics;
|
|
||||||
import org.hibernate.stat.Statistics;
|
|
||||||
import org.hibernate.stat.internal.ConcurrentStatisticsImpl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JMX service for Hibernate statistics<br>
|
|
||||||
* <br>
|
|
||||||
* Register this MBean in your JMX server for a specific session factory
|
|
||||||
* <pre>
|
|
||||||
* //build the ObjectName you want
|
|
||||||
* Hashtable tb = new Hashtable();
|
|
||||||
* tb.put("type", "statistics");
|
|
||||||
* tb.put("sessionFactory", "myFinancialApp");
|
|
||||||
* ObjectName on = new ObjectName("hibernate", tb);
|
|
||||||
* StatisticsService stats = new StatisticsService();
|
|
||||||
* stats.setSessionFactory(sessionFactory);
|
|
||||||
* server.registerMBean(stats, on);
|
|
||||||
* </pre>
|
|
||||||
* And call the MBean the way you want<br>
|
|
||||||
* <br>
|
|
||||||
* Register this MBean in your JMX server with no specific session factory
|
|
||||||
* <pre>
|
|
||||||
* //build the ObjectName you want
|
|
||||||
* Hashtable tb = new Hashtable();
|
|
||||||
* tb.put("type", "statistics");
|
|
||||||
* tb.put("sessionFactory", "myFinancialApp");
|
|
||||||
* ObjectName on = new ObjectName("hibernate", tb);
|
|
||||||
* StatisticsService stats = new StatisticsService();
|
|
||||||
* server.registerMBean(stats, on);
|
|
||||||
* </pre>
|
|
||||||
* And call the MBean by providing the <code>SessionFactoryJNDIName</code> first.
|
|
||||||
* Then the session factory will be retrieved from JNDI and the statistics
|
|
||||||
* loaded.
|
|
||||||
*
|
|
||||||
* @author Emmanuel Bernard
|
|
||||||
* @deprecated See <a href="http://opensource.atlassian.com/projects/hibernate/browse/HHH-6190">HHH-6190</a> for details
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class StatisticsService implements StatisticsServiceMBean {
|
|
||||||
|
|
||||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, StatisticsService.class.getName() );
|
|
||||||
//TODO: We probably should have a StatisticsNotPublishedException, to make it clean
|
|
||||||
|
|
||||||
SessionFactory sf;
|
|
||||||
String sfJNDIName;
|
|
||||||
Statistics stats = new ConcurrentStatisticsImpl();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#setSessionFactoryJNDIName(java.lang.String)
|
|
||||||
*/
|
|
||||||
public void setSessionFactoryJNDIName(String sfJNDIName) {
|
|
||||||
this.sfJNDIName = sfJNDIName;
|
|
||||||
try {
|
|
||||||
final SessionFactory sessionFactory;
|
|
||||||
final Object jndiValue = new InitialContext().lookup( sfJNDIName );
|
|
||||||
if ( jndiValue instanceof Reference ) {
|
|
||||||
final String uuid = (String) ( (Reference) jndiValue ).get( 0 ).getContent();
|
|
||||||
sessionFactory = SessionFactoryRegistry.INSTANCE.getSessionFactory( uuid );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sessionFactory = (SessionFactory) jndiValue;
|
|
||||||
}
|
|
||||||
setSessionFactory( sessionFactory );
|
|
||||||
}
|
|
||||||
catch (NameNotFoundException e) {
|
|
||||||
LOG.noSessionFactoryWithJndiName( sfJNDIName, e );
|
|
||||||
setSessionFactory(null);
|
|
||||||
}
|
|
||||||
catch (NamingException e) {
|
|
||||||
LOG.unableToAccessSessionFactory( sfJNDIName, e );
|
|
||||||
setSessionFactory(null);
|
|
||||||
}
|
|
||||||
catch (ClassCastException e) {
|
|
||||||
LOG.jndiNameDoesNotHandleSessionFactoryReference( sfJNDIName, e );
|
|
||||||
setSessionFactory(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Useful to init this MBean wo a JNDI session factory name
|
|
||||||
*
|
|
||||||
* @param sf session factory to register
|
|
||||||
*/
|
|
||||||
public void setSessionFactory(SessionFactory sf) {
|
|
||||||
this.sf = sf;
|
|
||||||
if (sf == null) {
|
|
||||||
stats = new ConcurrentStatisticsImpl();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
stats = sf.getStatistics();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#clear()
|
|
||||||
*/
|
|
||||||
public void clear() {
|
|
||||||
stats.clear();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#getEntityStatistics(java.lang.String)
|
|
||||||
*/
|
|
||||||
public EntityStatistics getEntityStatistics(String entityName) {
|
|
||||||
return stats.getEntityStatistics(entityName);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#getCollectionStatistics(java.lang.String)
|
|
||||||
*/
|
|
||||||
public CollectionStatistics getCollectionStatistics(String role) {
|
|
||||||
return stats.getCollectionStatistics(role);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#getSecondLevelCacheStatistics(java.lang.String)
|
|
||||||
*/
|
|
||||||
public SecondLevelCacheStatistics getSecondLevelCacheStatistics(String regionName) {
|
|
||||||
return stats.getSecondLevelCacheStatistics(regionName);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#getQueryStatistics(java.lang.String)
|
|
||||||
*/
|
|
||||||
public QueryStatistics getQueryStatistics(String hql) {
|
|
||||||
return stats.getQueryStatistics(hql);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#getEntityDeleteCount()
|
|
||||||
*/
|
|
||||||
public long getEntityDeleteCount() {
|
|
||||||
return stats.getEntityDeleteCount();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#getEntityInsertCount()
|
|
||||||
*/
|
|
||||||
public long getEntityInsertCount() {
|
|
||||||
return stats.getEntityInsertCount();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#getEntityLoadCount()
|
|
||||||
*/
|
|
||||||
public long getEntityLoadCount() {
|
|
||||||
return stats.getEntityLoadCount();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#getEntityFetchCount()
|
|
||||||
*/
|
|
||||||
public long getEntityFetchCount() {
|
|
||||||
return stats.getEntityFetchCount();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#getEntityUpdateCount()
|
|
||||||
*/
|
|
||||||
public long getEntityUpdateCount() {
|
|
||||||
return stats.getEntityUpdateCount();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#getQueryExecutionCount()
|
|
||||||
*/
|
|
||||||
public long getQueryExecutionCount() {
|
|
||||||
return stats.getQueryExecutionCount();
|
|
||||||
}
|
|
||||||
public long getQueryCacheHitCount() {
|
|
||||||
return stats.getQueryCacheHitCount();
|
|
||||||
}
|
|
||||||
public long getQueryExecutionMaxTime() {
|
|
||||||
return stats.getQueryExecutionMaxTime();
|
|
||||||
}
|
|
||||||
public long getQueryCacheMissCount() {
|
|
||||||
return stats.getQueryCacheMissCount();
|
|
||||||
}
|
|
||||||
public long getQueryCachePutCount() {
|
|
||||||
return stats.getQueryCachePutCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getUpdateTimestampsCacheHitCount() {
|
|
||||||
return stats.getUpdateTimestampsCacheHitCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getUpdateTimestampsCacheMissCount() {
|
|
||||||
return stats.getUpdateTimestampsCacheMissCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getUpdateTimestampsCachePutCount() {
|
|
||||||
return stats.getUpdateTimestampsCachePutCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#getFlushCount()
|
|
||||||
*/
|
|
||||||
public long getFlushCount() {
|
|
||||||
return stats.getFlushCount();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#getConnectCount()
|
|
||||||
*/
|
|
||||||
public long getConnectCount() {
|
|
||||||
return stats.getConnectCount();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#getSecondLevelCacheHitCount()
|
|
||||||
*/
|
|
||||||
public long getSecondLevelCacheHitCount() {
|
|
||||||
return stats.getSecondLevelCacheHitCount();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#getSecondLevelCacheMissCount()
|
|
||||||
*/
|
|
||||||
public long getSecondLevelCacheMissCount() {
|
|
||||||
return stats.getSecondLevelCacheMissCount();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#getSecondLevelCachePutCount()
|
|
||||||
*/
|
|
||||||
public long getSecondLevelCachePutCount() {
|
|
||||||
return stats.getSecondLevelCachePutCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
public NaturalIdCacheStatistics getNaturalIdCacheStatistics(String regionName) {
|
|
||||||
return stats.getNaturalIdCacheStatistics( regionName );
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getNaturalIdCacheHitCount() {
|
|
||||||
return stats.getNaturalIdCacheHitCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getNaturalIdCacheMissCount() {
|
|
||||||
return stats.getNaturalIdCacheMissCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getNaturalIdCachePutCount() {
|
|
||||||
return stats.getNaturalIdCachePutCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getNaturalIdQueryExecutionCount() {
|
|
||||||
return stats.getNaturalIdQueryExecutionCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getNaturalIdQueryExecutionMaxTime() {
|
|
||||||
return stats.getNaturalIdQueryExecutionMaxTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getNaturalIdQueryExecutionMaxTimeRegion() {
|
|
||||||
return stats.getNaturalIdQueryExecutionMaxTimeRegion();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#getSessionCloseCount()
|
|
||||||
*/
|
|
||||||
public long getSessionCloseCount() {
|
|
||||||
return stats.getSessionCloseCount();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#getSessionOpenCount()
|
|
||||||
*/
|
|
||||||
public long getSessionOpenCount() {
|
|
||||||
return stats.getSessionOpenCount();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#getCollectionLoadCount()
|
|
||||||
*/
|
|
||||||
public long getCollectionLoadCount() {
|
|
||||||
return stats.getCollectionLoadCount();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#getCollectionFetchCount()
|
|
||||||
*/
|
|
||||||
public long getCollectionFetchCount() {
|
|
||||||
return stats.getCollectionFetchCount();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#getCollectionUpdateCount()
|
|
||||||
*/
|
|
||||||
public long getCollectionUpdateCount() {
|
|
||||||
return stats.getCollectionUpdateCount();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#getCollectionRemoveCount()
|
|
||||||
*/
|
|
||||||
public long getCollectionRemoveCount() {
|
|
||||||
return stats.getCollectionRemoveCount();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#getCollectionRecreateCount()
|
|
||||||
*/
|
|
||||||
public long getCollectionRecreateCount() {
|
|
||||||
return stats.getCollectionRecreateCount();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#getStartTime()
|
|
||||||
*/
|
|
||||||
public long getStartTime() {
|
|
||||||
return stats.getStartTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#isStatisticsEnabled()
|
|
||||||
*/
|
|
||||||
public boolean isStatisticsEnabled() {
|
|
||||||
return stats.isStatisticsEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see StatisticsServiceMBean#setStatisticsEnabled(boolean)
|
|
||||||
*/
|
|
||||||
public void setStatisticsEnabled(boolean enable) {
|
|
||||||
stats.setStatisticsEnabled(enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void logSummary() {
|
|
||||||
stats.logSummary();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getCollectionRoleNames() {
|
|
||||||
return stats.getCollectionRoleNames();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getEntityNames() {
|
|
||||||
return stats.getEntityNames();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getQueries() {
|
|
||||||
return stats.getQueries();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getSecondLevelCacheRegionNames() {
|
|
||||||
return stats.getSecondLevelCacheRegionNames();
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getSuccessfulTransactionCount() {
|
|
||||||
return stats.getSuccessfulTransactionCount();
|
|
||||||
}
|
|
||||||
public long getTransactionCount() {
|
|
||||||
return stats.getTransactionCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getCloseStatementCount() {
|
|
||||||
return stats.getCloseStatementCount();
|
|
||||||
}
|
|
||||||
public long getPrepareStatementCount() {
|
|
||||||
return stats.getPrepareStatementCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getOptimisticFailureCount() {
|
|
||||||
return stats.getOptimisticFailureCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getQueryExecutionMaxTimeQueryString() {
|
|
||||||
return stats.getQueryExecutionMaxTimeQueryString();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
//$Id: StatisticsServiceMBean.java 4332 2004-08-15 12:55:28Z oneovthafew $
|
|
||||||
package org.hibernate.jmx;
|
|
||||||
import org.hibernate.stat.Statistics;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MBean exposing Session Factory statistics
|
|
||||||
*
|
|
||||||
* @see org.hibernate.stat.Statistics
|
|
||||||
* @author Emmanuel Bernard
|
|
||||||
* @deprecated See <a href="http://opensource.atlassian.com/projects/hibernate/browse/HHH-6190">HHH-6190</a> for details
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public interface StatisticsServiceMBean extends Statistics {
|
|
||||||
/**
|
|
||||||
* Publish the statistics of a session factory bound to
|
|
||||||
* the default JNDI context
|
|
||||||
* @param sfJNDIName session factory jndi name
|
|
||||||
*/
|
|
||||||
public abstract void setSessionFactoryJNDIName(String sfJNDIName);
|
|
||||||
}
|
|
|
@ -1,74 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
|
|
||||||
* indicated by the @author tags or express copyright attribution
|
|
||||||
* statements applied by the authors. All third-party contributions are
|
|
||||||
* distributed under license by Red Hat Middleware LLC.
|
|
||||||
*
|
|
||||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
|
||||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
|
||||||
* Lesser General Public License, as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this distribution; if not, write to:
|
|
||||||
* Free Software Foundation, Inc.
|
|
||||||
* 51 Franklin Street, Fifth Floor
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.hibernate.transaction;
|
|
||||||
import java.util.Properties;
|
|
||||||
import javax.transaction.Transaction;
|
|
||||||
import javax.transaction.TransactionManager;
|
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contract for locating the JTA {@link TransactionManager} on given platform.
|
|
||||||
* <p/>
|
|
||||||
* NOTE: this contract has expanded over time, and basically is a platform
|
|
||||||
* abstraction contract for JTA-related information.
|
|
||||||
*
|
|
||||||
* @author Gavin King
|
|
||||||
*/
|
|
||||||
public interface TransactionManagerLookup {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Obtain the JTA {@link TransactionManager}.
|
|
||||||
*
|
|
||||||
* @param props The configuration properties.
|
|
||||||
* @return The JTA {@link TransactionManager}.
|
|
||||||
*
|
|
||||||
* @throws HibernateException Indicates problem locating {@link TransactionManager}.
|
|
||||||
*/
|
|
||||||
public TransactionManager getTransactionManager(Properties props) throws HibernateException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the JNDI namespace of the JTA
|
|
||||||
* {@link javax.transaction.UserTransaction} for this platform or <tt>null</tt>;
|
|
||||||
* optional operation.
|
|
||||||
*
|
|
||||||
* @return The JNDI namespace where we can locate the
|
|
||||||
* {@link javax.transaction.UserTransaction} for this platform.
|
|
||||||
*/
|
|
||||||
public String getUserTransactionName();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine an identifier for the given transaction appropriate for use in caching/lookup usages.
|
|
||||||
* <p/>
|
|
||||||
* Generally speaking the transaction itself will be returned here. This method was added specifically
|
|
||||||
* for use in WebSphere and other unfriendly JEE containers (although WebSphere is still the only known
|
|
||||||
* such brain-dead, sales-driven impl).
|
|
||||||
*
|
|
||||||
* @param transaction The transaction to be identified.
|
|
||||||
* @return An appropropriate identifier
|
|
||||||
*/
|
|
||||||
public Object getTransactionIdentifier(Transaction transaction);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
<!--
|
|
||||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
~
|
|
||||||
~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
|
|
||||||
~ indicated by the @author tags or express copyright attribution
|
|
||||||
~ statements applied by the authors. All third-party contributions are
|
|
||||||
~ distributed under license by Red Hat Middleware LLC.
|
|
||||||
~
|
|
||||||
~ This copyrighted material is made available to anyone wishing to use, modify,
|
|
||||||
~ copy, or redistribute it subject to the terms and conditions of the GNU
|
|
||||||
~ Lesser General Public License, as published by the Free Software Foundation.
|
|
||||||
~
|
|
||||||
~ This program is distributed in the hope that it will be useful,
|
|
||||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
||||||
~ for more details.
|
|
||||||
~
|
|
||||||
~ You should have received a copy of the GNU Lesser General Public License
|
|
||||||
~ along with this distribution; if not, write to:
|
|
||||||
~ Free Software Foundation, Inc.
|
|
||||||
~ 51 Franklin Street, Fifth Floor
|
|
||||||
~ Boston, MA 02110-1301 USA
|
|
||||||
~
|
|
||||||
-->
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<head></head>
|
|
||||||
<body>
|
|
||||||
<p>
|
|
||||||
This package abstracts the underlying transaction mechanism
|
|
||||||
(JTA or JDBC) and provides strategies for obtaining application
|
|
||||||
server <tt>TransactionManager</tt>s.
|
|
||||||
</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -29,10 +29,11 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
|
||||||
|
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
||||||
|
import org.hibernate.boot.registry.selector.internal.StrategySelectorBuilder;
|
||||||
|
import org.hibernate.boot.registry.selector.spi.StrategySelectionException;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.dialect.DB2400Dialect;
|
import org.hibernate.dialect.DB2400Dialect;
|
||||||
import org.hibernate.dialect.DB2Dialect;
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
|
@ -55,12 +56,14 @@ import org.hibernate.dialect.SQLServerDialect;
|
||||||
import org.hibernate.dialect.SybaseASE15Dialect;
|
import org.hibernate.dialect.SybaseASE15Dialect;
|
||||||
import org.hibernate.dialect.SybaseAnywhereDialect;
|
import org.hibernate.dialect.SybaseAnywhereDialect;
|
||||||
import org.hibernate.dialect.TestingDialects;
|
import org.hibernate.dialect.TestingDialects;
|
||||||
import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
|
|
||||||
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
|
||||||
import org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl;
|
import org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl;
|
||||||
import org.hibernate.engine.jdbc.dialect.internal.DialectResolverSet;
|
import org.hibernate.engine.jdbc.dialect.internal.DialectResolverSet;
|
||||||
import org.hibernate.engine.jdbc.dialect.internal.StandardDialectResolver;
|
import org.hibernate.engine.jdbc.dialect.internal.StandardDialectResolver;
|
||||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
|
import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
@ -76,10 +79,23 @@ public class DialectFactoryTest extends BaseUnitTestCase {
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
dialectFactory = new DialectFactoryImpl();
|
dialectFactory = new DialectFactoryImpl();
|
||||||
dialectFactory.setClassLoaderService( new ClassLoaderServiceImpl( getClass().getClassLoader() ) );
|
dialectFactory.setStrategySelector(
|
||||||
|
new StrategySelectorBuilder().buildSelector( new ClassLoaderServiceImpl( getClass().getClassLoader() ) )
|
||||||
|
);
|
||||||
dialectFactory.setDialectResolver( new StandardDialectResolver() );
|
dialectFactory.setDialectResolver( new StandardDialectResolver() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExplicitShortNameUse() {
|
||||||
|
final Map<String, String> configValues = new HashMap<String, String>();
|
||||||
|
|
||||||
|
configValues.put( Environment.DIALECT, "H2" );
|
||||||
|
assertEquals( H2Dialect.class, dialectFactory.buildDialect( configValues, null ).getClass() );
|
||||||
|
|
||||||
|
configValues.put( Environment.DIALECT, "Oracle10g" );
|
||||||
|
assertEquals( Oracle10gDialect.class, dialectFactory.buildDialect( configValues, null ).getClass() );
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExplicitlySuppliedDialectClassName() {
|
public void testExplicitlySuppliedDialectClassName() {
|
||||||
final Map<String, String> configValues = new HashMap<String, String>();
|
final Map<String, String> configValues = new HashMap<String, String>();
|
||||||
|
@ -93,7 +109,7 @@ public class DialectFactoryTest extends BaseUnitTestCase {
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
catch ( HibernateException e ) {
|
catch ( HibernateException e ) {
|
||||||
assertEquals( "unexpected exception type", ClassLoadingException.class, e.getCause().getClass() );
|
assertEquals( "unexpected exception type", StrategySelectionException.class, e.getClass() );
|
||||||
}
|
}
|
||||||
|
|
||||||
configValues.put( Environment.DIALECT, "java.lang.Object" );
|
configValues.put( Environment.DIALECT, "java.lang.Object" );
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
<!DOCTYPE hibernate-mapping PUBLIC
|
|
||||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
|
||||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
|
||||||
|
|
||||||
<hibernate-mapping>
|
|
||||||
|
|
||||||
<class name="org.hibernate.jmx.Entity">
|
|
||||||
<id name="id" type="long" column="id_">
|
|
||||||
<generator class="assigned"/>
|
|
||||||
</id>
|
|
||||||
<property name="name"/>
|
|
||||||
</class>
|
|
||||||
|
|
||||||
</hibernate-mapping>
|
|
|
@ -1,28 +0,0 @@
|
||||||
package org.hibernate.jmx;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* @author Steve Ebersole
|
|
||||||
*/
|
|
||||||
public class Entity {
|
|
||||||
private Long id;
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
|
|
||||||
* indicated by the @author tags or express copyright attribution
|
|
||||||
* statements applied by the authors. All third-party contributions are
|
|
||||||
* distributed under license by Red Hat Inc.
|
|
||||||
*
|
|
||||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
|
||||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
|
||||||
* Lesser General Public License, as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this distribution; if not, write to:
|
|
||||||
* Free Software Foundation, Inc.
|
|
||||||
* 51 Franklin Street, Fifth Floor
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package org.hibernate.jmx;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Steve Ebersole
|
|
||||||
*/
|
|
||||||
public class TrivialTest extends BaseUnitTestCase {
|
|
||||||
@Test
|
|
||||||
public void testService() throws Exception {
|
|
||||||
HibernateService hs = new HibernateService();
|
|
||||||
hs.setJndiName( "SessionFactory" );
|
|
||||||
hs.setMapResources( "org/hibernate/jmx/Entity.hbm.xml" );
|
|
||||||
hs.setShowSqlEnabled( "true" );
|
|
||||||
hs.start();
|
|
||||||
hs.stop();
|
|
||||||
hs.setProperty( "foo", "bar" );
|
|
||||||
hs.start();
|
|
||||||
hs.stop();
|
|
||||||
try {
|
|
||||||
hs.setMapResources( "non-existent" );
|
|
||||||
hs.start();
|
|
||||||
}
|
|
||||||
catch( Throwable t ) {
|
|
||||||
// expected behavior
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
hs.stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,55 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* Copyright (c) 2007, Red Hat, Inc. and/or it's affiliates or third-party contributors as
|
|
||||||
* indicated by the @author tags or express copyright attribution
|
|
||||||
* statements applied by the authors. All third-party contributions are
|
|
||||||
* distributed under license by Red Hat, Inc. and/or it's affiliates.
|
|
||||||
*
|
|
||||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
|
||||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
|
||||||
* Lesser General Public License, as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this distribution; if not, write to:
|
|
||||||
* Free Software Foundation, Inc.
|
|
||||||
* 51 Franklin Street, Fifth Floor
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package org.hibernate.test.cache.infinispan.functional.cluster;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
import javax.transaction.Transaction;
|
|
||||||
import javax.transaction.TransactionManager;
|
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
|
||||||
import org.hibernate.transaction.TransactionManagerLookup;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SimpleJtaTransactionManagerLookupImpl subclass that finds a different DualNodeTransactionManager
|
|
||||||
* based on the value of property {@link DualNodeTestUtil#NODE_ID_PROP}.
|
|
||||||
*
|
|
||||||
* @author Brian Stansberry
|
|
||||||
*/
|
|
||||||
public class DualNodeTransactionManagerLookup implements TransactionManagerLookup {
|
|
||||||
|
|
||||||
public TransactionManager getTransactionManager(Properties props) throws HibernateException {
|
|
||||||
String nodeId = props.getProperty(DualNodeTestCase.NODE_ID_PROP);
|
|
||||||
if (nodeId == null)
|
|
||||||
throw new HibernateException(DualNodeTestCase.NODE_ID_PROP + " not configured");
|
|
||||||
return DualNodeJtaTransactionManagerImpl.getInstance(nodeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUserTransactionName() {
|
|
||||||
throw new UnsupportedOperationException("jndi currently not implemented for these tests");
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getTransactionIdentifier(Transaction transaction) {
|
|
||||||
return transaction;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -61,6 +61,9 @@ import org.hibernate.engine.transaction.jta.platform.internal.JBossStandAloneJta
|
||||||
import org.hibernate.stat.Statistics;
|
import org.hibernate.stat.Statistics;
|
||||||
import org.hibernate.test.cache.infinispan.functional.Item;
|
import org.hibernate.test.cache.infinispan.functional.Item;
|
||||||
import org.hibernate.testing.ServiceRegistryBuilder;
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
|
import org.hibernate.testing.jta.JtaAwareConnectionProviderImpl;
|
||||||
|
import org.hibernate.testing.jta.TestingJtaBootstrap;
|
||||||
|
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
@ -87,10 +90,9 @@ public class JBossStandaloneJtaExampleTest {
|
||||||
jndiServer = startJndiServer();
|
jndiServer = startJndiServer();
|
||||||
ctx = createJndiContext();
|
ctx = createJndiContext();
|
||||||
// Inject configuration to initialise transaction manager from config classloader
|
// Inject configuration to initialise transaction manager from config classloader
|
||||||
lookup.init(new org.infinispan.config.Configuration());
|
lookup.init( new org.infinispan.config.Configuration() );
|
||||||
bindTransactionManager();
|
bindTransactionManager();
|
||||||
bindUserTransaction();
|
bindUserTransaction();
|
||||||
bindDataSource();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
@ -177,51 +179,20 @@ public class JBossStandaloneJtaExampleTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ExtendedXADataSource extends StandardXADataSource { // XAPOOL
|
|
||||||
@Override
|
|
||||||
public Connection getConnection() throws SQLException {
|
|
||||||
|
|
||||||
if (getTransactionManager() == null) { // although already set before, it results null again after retrieving the datasource by jndi
|
|
||||||
TransactionManager tm; // this is because the TransactionManager information is not serialized.
|
|
||||||
try {
|
|
||||||
tm = lookup.getTransactionManager();
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new SQLException(e);
|
|
||||||
}
|
|
||||||
setTransactionManager(tm); // resets the TransactionManager on the datasource retrieved by jndi,
|
|
||||||
// this makes the datasource JTA-aware
|
|
||||||
}
|
|
||||||
|
|
||||||
// According to Enhydra documentation, here we must return the connection of our XAConnection
|
|
||||||
// see http://cvs.forge.objectweb.org/cgi-bin/viewcvs.cgi/xapool/xapool/examples/xapooldatasource/DatabaseHelper.java?sortby=rev
|
|
||||||
return super.getXAConnection().getConnection();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> T unwrap(Class<T> iface) throws SQLException {
|
|
||||||
return null; // JDK6 stuff
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isWrapperFor(Class<?> iface) throws SQLException {
|
|
||||||
return false; // JDK6 stuff
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Main startJndiServer() throws Exception {
|
private Main startJndiServer() throws Exception {
|
||||||
// Create an in-memory jndi
|
// Create an in-memory jndi
|
||||||
NamingServer namingServer = new NamingServer();
|
NamingServer namingServer = new NamingServer();
|
||||||
NamingContext.setLocal(namingServer);
|
NamingContext.setLocal(namingServer);
|
||||||
Main namingMain = new Main();
|
Main namingMain = new Main();
|
||||||
namingMain.setInstallGlobalService(true);
|
namingMain.setInstallGlobalService(true);
|
||||||
namingMain.setPort(-1);
|
namingMain.setPort( -1 );
|
||||||
namingMain.start();
|
namingMain.start();
|
||||||
return namingMain;
|
return namingMain;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Context createJndiContext() throws Exception {
|
private Context createJndiContext() throws Exception {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
|
props.put( Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory" );
|
||||||
props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
|
props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
|
||||||
return new InitialContext(props);
|
return new InitialContext(props);
|
||||||
}
|
}
|
||||||
|
@ -233,14 +204,7 @@ public class JBossStandaloneJtaExampleTest {
|
||||||
|
|
||||||
private void bindUserTransaction() throws Exception {
|
private void bindUserTransaction() throws Exception {
|
||||||
// also the UserTransaction must be registered on jndi: org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory#getUserTransaction() requires this
|
// also the UserTransaction must be registered on jndi: org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory#getUserTransaction() requires this
|
||||||
bind("UserTransaction", lookup.getUserTransaction(), lookup.getUserTransaction().getClass(), ctx);
|
bind( "UserTransaction", lookup.getUserTransaction(), lookup.getUserTransaction().getClass(), ctx );
|
||||||
}
|
|
||||||
|
|
||||||
private void bindDataSource() throws Exception {
|
|
||||||
ExtendedXADataSource xads = new ExtendedXADataSource();
|
|
||||||
xads.setDriverName("org.h2.Driver");
|
|
||||||
xads.setUrl("jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE");
|
|
||||||
ctx.bind("java:/MyDatasource", xads);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -282,12 +246,11 @@ public class JBossStandaloneJtaExampleTest {
|
||||||
private SessionFactory buildSessionFactory() {
|
private SessionFactory buildSessionFactory() {
|
||||||
// Extra options located in src/test/resources/hibernate.properties
|
// Extra options located in src/test/resources/hibernate.properties
|
||||||
Configuration cfg = new Configuration();
|
Configuration cfg = new Configuration();
|
||||||
cfg.setProperty(Environment.DIALECT, "org.hibernate.dialect.HSQLDialect");
|
cfg.setProperty( Environment.DIALECT, "HSQL" );
|
||||||
cfg.setProperty(Environment.HBM2DDL_AUTO, "create-drop");
|
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
||||||
cfg.setProperty(Environment.DATASOURCE, "java:/MyDatasource");
|
cfg.setProperty( Environment.CONNECTION_PROVIDER, JtaAwareConnectionProviderImpl.class.getName() );
|
||||||
cfg.setProperty(Environment.JNDI_CLASS, "org.jnp.interfaces.NamingContextFactory");
|
cfg.setProperty(Environment.JNDI_CLASS, "org.jnp.interfaces.NamingContextFactory");
|
||||||
cfg.setProperty(Environment.TRANSACTION_MANAGER_STRATEGY, "org.hibernate.transaction.JBossTransactionManagerLookup");
|
cfg.setProperty(Environment.TRANSACTION_STRATEGY, "jta");
|
||||||
cfg.setProperty(Environment.TRANSACTION_STRATEGY, "org.hibernate.transaction.JTATransactionFactory");
|
|
||||||
cfg.setProperty(Environment.CURRENT_SESSION_CONTEXT_CLASS, "jta");
|
cfg.setProperty(Environment.CURRENT_SESSION_CONTEXT_CLASS, "jta");
|
||||||
cfg.setProperty(Environment.RELEASE_CONNECTIONS, "auto");
|
cfg.setProperty(Environment.RELEASE_CONNECTIONS, "auto");
|
||||||
cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
|
cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* Copyright (c) 2007, Red Hat, Inc. and/or it's affiliates or third-party contributors as
|
|
||||||
* indicated by the @author tags or express copyright attribution
|
|
||||||
* statements applied by the authors. All third-party contributions are
|
|
||||||
* distributed under license by Red Hat, Inc. and/or it's affiliates.
|
|
||||||
*
|
|
||||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
|
||||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
|
||||||
* Lesser General Public License, as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this distribution; if not, write to:
|
|
||||||
* Free Software Foundation, Inc.
|
|
||||||
* 51 Franklin Street, Fifth Floor
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package org.hibernate.test.cache.infinispan.util;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
import javax.transaction.Transaction;
|
|
||||||
import javax.transaction.TransactionManager;
|
|
||||||
|
|
||||||
import org.infinispan.transaction.tm.BatchModeTransactionManager;
|
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
|
||||||
import org.hibernate.transaction.TransactionManagerLookup;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Uses the JBoss Cache BatchModeTransactionManager. Should not be used in
|
|
||||||
* any tests that simulate usage of database connections.
|
|
||||||
*
|
|
||||||
* @author Brian Stansberry
|
|
||||||
*/
|
|
||||||
public class BatchModeTransactionManagerLookup
|
|
||||||
implements TransactionManagerLookup {
|
|
||||||
|
|
||||||
public TransactionManager getTransactionManager(Properties props) throws HibernateException {
|
|
||||||
try {
|
|
||||||
return BatchModeTransactionManager.getInstance();
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
throw new HibernateException("Failed getting BatchModeTransactionManager", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUserTransactionName() {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getTransactionIdentifier(Transaction transaction) {
|
|
||||||
return transaction;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue