Merge branch 'master' into metamodel

Conflicts:
	hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/internal/ClassLoaderServiceImpl.java
	hibernate-core/src/main/java/org/hibernate/cache/internal/NoCachingRegionFactory.java
	hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java
	hibernate-core/src/main/java/org/hibernate/cfg/SettingsFactory.java
	hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationIntegrator.java
	hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/UserSuppliedConnectionProviderImpl.java
	hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesImpl.java
	hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/JdbcServices.java
	hibernate-core/src/main/java/org/hibernate/internal/AbstractSessionImpl.java
	hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java
	hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java
	hibernate-core/src/main/java/org/hibernate/internal/StoredProcedureCallImpl.java
	hibernate-core/src/main/java/org/hibernate/jaxb/internal/JaxbConfigurationProcessor.java
	hibernate-core/src/main/java/org/hibernate/jaxb/internal/JaxbMappingProcessor.java
	hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataBuilderImpl.java
	hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/AnnotationMetadataSourceProcessorImpl.java
	hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/Helper.java
	hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/HibernateMappingProcessor.java
	hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/IdentifierGeneratorResolver.java
	hibernate-core/src/main/java/org/hibernate/service/ConfigLoader.java
	hibernate-core/src/main/java/org/hibernate/service/ServiceRegistryBuilder.java
	hibernate-core/src/main/java/org/hibernate/service/StandardServiceInitiators.java
	hibernate-core/src/main/java/org/hibernate/stat/internal/StatisticsInitiator.java
	hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java
	hibernate-core/src/main/java/org/hibernate/type/EnumType.java
	hibernate-core/src/test/java/org/hibernate/metamodel/binding/AbstractBasicBindingTests.java
	hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/MetadataImplTest.java
	hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/entity/IdentifierGeneratorTest.java
	hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/entity/MapsIdTest.java
	hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/global/FetchProfileBinderTest.java
	hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/global/QueryBinderTest.java
	hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/util/BaseAnnotationIndexTestCase.java
	hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/util/JandexHelperTest.java
	hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/xml/OrmXmlParserTests.java
	hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/xml/mocker/XmlHelper.java
	hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/SimpleValueBindingTests.java
	hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/UnidirectionalManyToManyBindingTests.java
	hibernate-core/src/test/java/org/hibernate/test/annotations/id/sequences/HibernateSequenceTest.java
	hibernate-core/src/test/java/org/hibernate/test/annotations/manytomany/ManyToManyTest.java
	hibernate-core/src/test/java/org/hibernate/test/common/BasicTestingJdbcServiceImpl.java
	hibernate-core/src/test/java/org/hibernate/test/common/JdbcConnectionAccessImpl.java
	hibernate-core/src/test/java/org/hibernate/test/connections/AggressiveReleaseTest.java
	hibernate-core/src/test/java/org/hibernate/test/connections/ConnectionManagementTestCase.java
	hibernate-core/src/test/java/org/hibernate/test/connections/ThreadLocalCurrentSessionTest.java
	hibernate-core/src/test/java/org/hibernate/test/events/CallbackTest.java
	hibernate-core/src/test/java/org/hibernate/test/flush/TestAutoFlushBeforeQueryExecution.java
	hibernate-core/src/test/java/org/hibernate/test/flush/TestCollectionInitializingDuringFlush.java
	hibernate-core/src/test/java/org/hibernate/test/interceptor/InterceptorTest.java
	hibernate-core/src/test/java/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java
	hibernate-core/src/test/java/org/hibernate/test/propertyref/DoesNotWorkTest.java
	hibernate-core/src/test/java/org/hibernate/test/propertyref/DoesNotWorkWithHbmTest.java
	hibernate-core/src/test/java/org/hibernate/test/service/ClassLoaderServiceImplTest.java
	hibernate-core/src/test/resources/org/hibernate/jmx/Entity.hbm.xml
	hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/AbstractEhcacheRegionFactory.java
	hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java
	hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/PersistenceXmlParser.java
	hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/internal/jpa/CallbackProcessorImpl.java
	hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/spi/JpaIntegrator.java
	hibernate-envers/src/main/java/org/hibernate/envers/event/EnversIntegrator.java
	hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/tm/HibernateTransactionManagerLookup.java
	hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanRegionFactoryTestCase.java
	hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/NodeEnvironment.java
	hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/JBossStandaloneJtaExampleTest.java
	hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseAnnotationBindingTestCase.java
	hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java
This commit is contained in:
Steve Ebersole 2012-09-10 14:20:38 -05:00
commit af115fe5a8
361 changed files with 6258 additions and 3512 deletions

View File

@ -120,7 +120,6 @@ subprojects { subProject ->
testCompile files( toolsJar )
}
}
ext.aptDumpDir = subProject.file( "${buildDir}/tmp/apt" )
sourceSets.main {
compileClasspath += configurations.provided
@ -133,6 +132,7 @@ subprojects { subProject ->
}
task generateMainLoggingClasses(type: Compile) {
ext.aptDumpDir = subProject.file( "${buildDir}/tmp/apt/logging" )
classpath = compileJava.classpath + configurations.jbossLoggingTool
source = sourceSets.main.originalJavaSrcDirs
destinationDir = aptDumpDir
@ -153,6 +153,9 @@ subprojects { subProject ->
doFirst {
sourceSets.main.generatedLoggingSrcDir.mkdirs()
}
doLast {
aptDumpDir.delete()
}
}
// for the time being eat the annoying output from running the annotation processors

View File

@ -256,7 +256,7 @@ https://hibernate.onjira.com/browse/HHH/fixforversion/11223
** Task
* [HHH-6082] - Incorporate EntityManager documentation into main dev guide
* [HHH-6336] - Add TenantIdentifierResolver
* [HHH-6656] - Document org.hibernate.service.classloading.spi.ClassLoaderService
* [HHH-6656] - Document org.hibernate.boot.registry.classloading.spi.ClassLoaderService
* [HHH-6966] - Re apply HHH-6782
* [HHH-6985] - Change up tests for PostgreSQL LockMode issues
* [HHH-7011] - Document multi-tenancy

View File

@ -32,9 +32,9 @@
<para>
Hibernate obtains JDBC connections as needed though the
<interfacename>org.hibernate.service.jdbc.connections.spi.ConnectionProvider</interfacename> interface
<interfacename>ConnectionProvider</interfacename> interface
which is a service contract. Applications may also supply their own
<interfacename>org.hibernate.service.jdbc.connections.spi.ConnectionProvider</interfacename> implementation
<interfacename>ConnectionProvider</interfacename> implementation
to define a custom approach for supplying connections to Hibernate (from a different connection pool
implementation, for example).
</para>
@ -232,7 +232,7 @@
</para>
<para>
You can define your own plugin strategy for obtaining JDBC connections by implementing the interface
<interfacename>org.hibernate.service.jdbc.connections.spi.ConnectionProvider</interfacename> and specifying your custom
<interfacename>ConnectionProvider</interfacename> and specifying your custom
implementation with the <property>hibernate.connection.provider_class</property> property.
</para>
</section>
@ -386,22 +386,22 @@
<section>
<title>Dialect resolution</title>
<para>
Assuming a <interfacename>org.hibernate.service.jdbc.connections.spi.ConnectionProvider</interfacename> has been
Assuming a <interfacename>ConnectionProvider</interfacename> has been
set up, Hibernate will attempt to automatically determine the Dialect to use based on the
<interfacename>java.sql.DatabaseMetaData</interfacename> reported by a
<interfacename>java.sql.Connection</interfacename> obtained from that
<interfacename>org.hibernate.service.jdbc.connections.spi.ConnectionProvider</interfacename>.
<interfacename>ConnectionProvider</interfacename>.
</para>
<para>
This functionality is provided by a series of
<interfacename>org.hibernate.service.jdbc.dialect.spi.DialectResolver</interfacename> instances registered
<interfacename>org.hibernate.engine.jdbc.dialect.spi.DialectResolver</interfacename> instances registered
with Hibernate internally. Hibernate comes with a standard set of recognitions. If your application
requires extra Dialect resolution capabilities, it would simply register a custom implementation
of <interfacename>org.hibernate.service.jdbc.dialect.spi.DialectResolver</interfacename> as follows:
of <interfacename>org.hibernate.engine.jdbc.dialect.spi.DialectResolver</interfacename> as follows:
</para>
<!-- document an example using the service registry -->
<para>
Registered <interfacename>org.hibernate.service.jdbc.dialect.spi.DialectResolver</interfacename> are
Registered <interfacename>org.hibernate.engine.jdbc.dialect.spi.DialectResolver</interfacename> are
<emphasis>prepended</emphasis> to an internal list of resolvers, so they take precedence
before any already registered resolvers including the standard one.
</para>

View File

@ -149,7 +149,7 @@
<para>
Correlates to the separate schema approach. It is an error to attempt to open a session without
a tenant identifier using this strategy. Additionally, a
<interfacename>org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider</interfacename>
<interfacename>MultiTenantConnectionProvider</interfacename>
must be specified.
</para>
</listitem>
@ -160,7 +160,7 @@
<para>
Correlates to the separate database approach. It is an error to attempt to open a session without
a tenant identifier using this strategy. Additionally, a
<interfacename>org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider</interfacename>
<interfacename>MultiTenantConnectionProvider</interfacename>
must be specified.
</para>
</listitem>
@ -182,7 +182,7 @@
<para>
When using either the DATABASE or SCHEMA approach, Hibernate needs to be able to obtain Connections
in a tenant specific manner. That is the role of the
<interfacename>org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider</interfacename>
<interfacename>MultiTenantConnectionProvider</interfacename>
contract. Application developers will need to provide an implementation of this
contract. Most of its methods are extremely self-explanatory. The only ones which might not be are
<methodname>getAnyConnection</methodname> and <methodname>releaseAnyConnection</methodname>. It is
@ -205,7 +205,7 @@
</listitem>
<listitem>
<para>
Passed directly to the <classname>org.hibernate.service.ServiceRegistryBuilder</classname>.
Passed directly to the <classname>org.hibernate.boot.registry.StandardServiceRegistryBuilder</classname>.
</para>
</listitem>
<listitem>
@ -213,7 +213,7 @@
If none of the above options match, but the settings do specify a
<property>hibernate.connection.datasource</property> value, Hibernate will assume it should
use the specific
<classname>org.hibernate.service.jdbc.connections.spi.DataSourceBasedMultiTenantConnectionProviderImpl</classname>
<classname>DataSourceBasedMultiTenantConnectionProviderImpl</classname>
implementation which works on a number of pretty reasonable assumptions when running inside of
an app server and using one <interfacename>javax.sql.DataSource</interfacename> per tenant.
See its javadocs for more details.

View File

@ -81,7 +81,7 @@
same registry as well as any parent registries.
</para>
<para>
Use <classname>org.hibernate.service.ServiceRegistryBuilder</classname> to build a
Use <classname>org.hibernate.boot.registry.StandardServiceRegistryBuilder</classname> to build a
<interfacename>org.hibernate.service.ServiceRegistry</interfacename> instance.
</para>
</section>
@ -121,7 +121,7 @@
</section>
<section xml:id="services-ConfigurationService">
<title><interfacename>org.hibernate.service.config.spi.ConfigurationService</interfacename></title>
<title><interfacename>org.hibernate.engine.config.spi.ConfigurationService</interfacename></title>
<variablelist>
<varlistentry>
<term>Notes</term>
@ -137,7 +137,7 @@
<term>Initiator</term>
<listitem>
<para>
<classname>org.hibernate.service.config.internal.ConfigurationServiceInitiator</classname>
<classname>org.hibernate.engine.config.internal.ConfigurationServiceInitiator</classname>
</para>
</listitem>
</varlistentry>
@ -145,7 +145,7 @@
<term>Implementations</term>
<listitem>
<para>
<classname>org.hibernate.service.config.internal.ConfigurationServiceImpl</classname>
<classname>org.hibernate.engine.config.internal.ConfigurationServiceImpl</classname>
</para>
</listitem>
</varlistentry>
@ -153,7 +153,7 @@
</section>
<section xml:id="services-ConnectionProvider">
<title><interfacename>org.hibernate.service.jdbc.connections.spi.ConnectionProvider</interfacename></title>
<title><interfacename>ConnectionProvider</interfacename></title>
<variablelist>
<varlistentry>
<term>Notes</term>
@ -168,7 +168,7 @@
<term>Initiator</term>
<listitem>
<para>
<classname>org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator</classname>
<classname>ConnectionProviderInitiator</classname>
</para>
</listitem>
</varlistentry>
@ -184,14 +184,14 @@
</listitem>
<listitem>
<para>
<classname>org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl</classname> -
<classname>DatasourceConnectionProviderImpl</classname> -
provides connection managed delegated to a
<interfacename>javax.sql.DataSource</interfacename>
</para>
</listitem>
<listitem>
<para>
<classname>org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl</classname> -
<classname>DriverManagerConnectionProviderImpl</classname> -
provides rudimentary connection pooling based on simple custom pool. Note intended
production use!
</para>
@ -204,7 +204,7 @@
</listitem>
<listitem>
<para>
<classname>org.hibernate.service.jdbc.connections.internal.UserSuppliedConnectionProviderImpl</classname> -
<classname>UserSuppliedConnectionProviderImpl</classname> -
Provides no connection support. Indicates the user will supply connections to Hibernate directly.
Not recommended for use.
</para>
@ -216,7 +216,7 @@
</section>
<section xml:id="services-DialectFactory">
<title><interfacename>org.hibernate.service.jdbc.dialect.spi.DialectFactory</interfacename></title>
<title><interfacename>org.hibernate.engine.jdbc.dialect.spi.DialectFactory</interfacename></title>
<variablelist>
<varlistentry>
<term>Notes</term>
@ -233,7 +233,7 @@
<term>Initiator</term>
<listitem>
<para>
<classname>org.hibernate.service.jdbc.dialect.internal.DialectFactoryInitiator</classname>
<classname>org.hibernate.engine.jdbc.dialect.internal.DialectFactoryInitiator</classname>
</para>
</listitem>
</varlistentry>
@ -241,7 +241,7 @@
<term>Implementations</term>
<listitem>
<para>
<classname>org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl</classname>
<classname>org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl</classname>
</para>
</listitem>
</varlistentry>
@ -249,7 +249,7 @@
</section>
<section xml:id="services-DialectResolver">
<title><interfacename>org.hibernate.service.jdbc.dialect.spi.DialectResolver</interfacename></title>
<title><interfacename>org.hibernate.engine.jdbc.dialect.spi.DialectResolver</interfacename></title>
<variablelist>
<varlistentry>
<term>Notes</term>
@ -261,8 +261,8 @@
<para>
The standard resolver implementation acts as a chain, delegating to a series of individual
resolvers. The standard Hibernate resolution behavior is contained in
<classname>org.hibernate.service.jdbc.dialect.internal.StandardDialectResolver</classname>.
<classname>org.hibernate.service.jdbc.dialect.internal.DialectResolverInitiator</classname>
<classname>org.hibernate.engine.jdbc.dialect.internal.StandardDialectResolver</classname>.
<classname>org.hibernate.engine.jdbc.dialect.internal.DialectResolverInitiator</classname>
also consults with the <property>hibernate.dialect_resolvers</property> setting for any
custom resolvers.
</para>
@ -272,7 +272,7 @@
<term>Initiator</term>
<listitem>
<para>
<classname>org.hibernate.service.jdbc.dialect.internal.DialectResolverInitiator</classname>
<classname>org.hibernate.engine.jdbc.dialect.internal.DialectResolverInitiator</classname>
</para>
</listitem>
</varlistentry>
@ -280,7 +280,7 @@
<term>Implementations</term>
<listitem>
<para>
<classname>org.hibernate.service.jdbc.dialect.internal.DialectResolverSet</classname>
<classname>org.hibernate.engine.jdbc.dialect.internal.DialectResolverSet</classname>
</para>
</listitem>
</varlistentry>
@ -319,7 +319,7 @@
</section>
<section xml:id="services-JmxService">
<title><interfacename>org.hibernate.service.jmx.spi.JmxService</interfacename></title>
<title><interfacename>org.hibernate.jmx.spi.JmxService</interfacename></title>
<variablelist>
<varlistentry>
<term>Notes</term>
@ -333,7 +333,7 @@
<term>Initiator</term>
<listitem>
<para>
<classname>org.hibernate.service.jmx.internal.JmxServiceInitiator</classname>
<classname>org.hibernate.jmx.internal.JmxServiceInitiator</classname>
</para>
</listitem>
</varlistentry>
@ -343,13 +343,13 @@
<itemizedlist>
<listitem>
<para>
<classname>org.hibernate.service.jmx.internal.DisabledJmxServiceImpl</classname> -
<classname>org.hibernate.jmx.internal.DisabledJmxServiceImpl</classname> -
A no-op implementation when JMX functionality is disabled.
</para>
</listitem>
<listitem>
<para>
<classname>org.hibernate.service.jmx.internal.JmxServiceImpl</classname> -
<classname>org.hibernate.jmx.internal.JmxServiceImpl</classname> -
Standard implementation of JMX handling
</para>
</listitem>
@ -360,7 +360,7 @@
</section>
<section xml:id="services-JndiService">
<title><interfacename>org.hibernate.service.jndi.spi.JndiService</interfacename></title>
<title><interfacename>org.hibernate.engine.jndi.spi.JndiService</interfacename></title>
<variablelist>
<varlistentry>
<term>Notes</term>
@ -374,7 +374,7 @@
<term>Initiator</term>
<listitem>
<para>
<classname>org.hibernate.service.jndi.internal.JndiServiceInitiator</classname>
<classname>org.hibernate.engine.jndi.internal.JndiServiceInitiator</classname>
</para>
</listitem>
</varlistentry>
@ -382,7 +382,7 @@
<term>Implementations</term>
<listitem>
<para>
<classname>org.hibernate.service.jndi.internal.JndiServiceImpl</classname>
<classname>org.hibernate.engine.jndi.internal.JndiServiceImpl</classname>
</para>
</listitem>
</varlistentry>
@ -390,7 +390,7 @@
</section>
<section xml:id="services-JtaPlatform">
<title><interfacename>org.hibernate.service.jta.platform.spi.JtaPlatform</interfacename></title>
<title><interfacename>org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform</interfacename></title>
<variablelist>
<varlistentry>
<term>Notes</term>
@ -404,15 +404,16 @@
<term>Initiator</term>
<listitem>
<para>
<classname>org.hibernate.service.jta.platform.internal.JtaPlatformInitiator</classname>
<classname>org.hibernate.engine.transaction.jta.platform.internal.JtaPlatformInitiator</classname>
</para>
<important>
<para>
<classname>JtaPlatformInitiator</classname> provides mapping against the legacy,
now-deprecated <interfacename>org.hibernate.transaction.TransactionManagerLookup</interfacename>
names internally for the Hibernate-provided
As of 5.0 support has been completely removed for mapping against legacy
<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>
</important>
</listitem>
@ -423,104 +424,110 @@
<itemizedlist>
<listitem>
<para>
<classname>org.hibernate.service.jta.platform.internal.BitronixJtaPlatform</classname> -
Integration with the Bitronix stand-alone transaction manager.
<classname>org.hibernate.engine.transaction.jta.platform.internal.BitronixJtaPlatform</classname> -
Integration with the Bitronix stand-alone transaction manager. Can also be referenced
using the <property>Bitronix</property> configuration short name
</para>
</listitem>
<listitem>
<para>
<classname>org.hibernate.service.jta.platform.internal.BorlandEnterpriseServerJtaPlatform</classname> -
Integration with the transaction manager as deployed within a Borland Enterprise Server
<classname>org.hibernate.engine.transaction.jta.platform.internal.BorlandEnterpriseServerJtaPlatform</classname> -
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>
</listitem>
<listitem>
<para>
<classname>org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform</classname> -
Integration with the transaction manager as deployed within a JBoss Application Server
<classname>org.hibernate.engine.transaction.jta.platform.internal.JBossAppServerJtaPlatform</classname> -
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>
</listitem>
<listitem>
<para>
<classname>org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform</classname> -
Integration with the JBoss Transactions stand-alone transaction manager
<classname>org.hibernate.engine.transaction.jta.platform.internal.JBossStandAloneJtaPlatform</classname> -
Integration with the JBoss Transactions stand-alone transaction manager.
Can also be referenced using the <property>JBossTS</property> configuration short name
</para>
</listitem>
<listitem>
<para>
<classname>org.hibernate.service.jta.platform.internal.JOTMJtaPlatform</classname> -
Integration with the JOTM stand-alone transaction manager
<classname>org.hibernate.engine.transaction.jta.platform.internal.JOTMJtaPlatform</classname> -
Integration with the JOTM stand-alone transaction manager. Can also be referenced
using the <property>JOTM</property> configuration short name
</para>
</listitem>
<listitem>
<para>
<classname>org.hibernate.service.jta.platform.internal.JOnASJtaPlatform</classname> -
Integration with the JOnAS transaction manager.
<classname>org.hibernate.engine.transaction.jta.platform.internal.JOnASJtaPlatform</classname> -
Integration with the JOnAS transaction manager. Can also be referenced using the
<property>JOnAS</property> configuration short name
</para>
</listitem>
<listitem>
<para>
<classname>org.hibernate.service.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.
Can also be referenced using the <property>JRun4</property> configuration short name
</para>
</listitem>
<listitem>
<para>
<classname>org.hibernate.service.jta.platform.internal.NoJtaPlatform</classname> -
<classname>org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform</classname> -
No-op version when no JTA set up is configured
</para>
</listitem>
<listitem>
<para>
<classname>org.hibernate.service.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
Can also be referenced using the <property>OC4J</property> configuration short name
server.
</para>
</listitem>
<listitem>
<para>
<classname>org.hibernate.service.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.
Can also be referenced using the <property>Orion</property> configuration short name
</para>
</listitem>
<listitem>
<para>
<classname>org.hibernate.service.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.
Can also be referenced using the <property>Resin</property> configuration short name
</para>
</listitem>
<listitem>
<para>
<classname>org.hibernate.service.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)
application server.
application server. Can also be referenced using the <property>SunOne</property>
configuration short name
</para>
</listitem>
<listitem>
<para>
<classname>org.hibernate.service.jta.platform.internal.TransactionManagerLookupBridge</classname> -
Provides a bridge to legacy (and deprecated)
<interfacename>org.hibernate.transaction.TransactionManagerLookup</interfacename>
implementations
</para>
</listitem>
<listitem>
<para>
<classname>org.hibernate.service.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
(6 and above).
(6 and above). Can also be referenced using the <property>WebSphereExtended</property>
configuration short name
</para>
</listitem>
<listitem>
<para>
<classname>org.hibernate.service.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
(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>
</listitem>
<listitem>
<para>
<classname>org.hibernate.service.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.
Can also be referenced using the <property>Weblogic</property> configuration short name
</para>
</listitem>
</itemizedlist>
@ -530,7 +537,7 @@
</section>
<section xml:id="services-MultiTenantConnectionProvider">
<title><interfacename>org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider</interfacename></title>
<title><interfacename>MultiTenantConnectionProvider</interfacename></title>
<variablelist>
<varlistentry>
<term>Notes</term>
@ -875,27 +882,27 @@
Once a <interfacename>org.hibernate.service.ServiceRegistry</interfacename> is built it is considered
immutable; the services themselves might accept re-configuration, but immutability here means
adding/replacing services. So another role provided by the
<classname>org.hibernate.service.ServiceRegistryBuilder</classname> is to allow tweaking of the services
<classname>org.hibernate.boot.registry.StandardServiceRegistryBuilder</classname> is to allow tweaking of the services
that will be contained in the <interfacename>org.hibernate.service.ServiceRegistry</interfacename>
generated from it.
</para>
<para>
There are 2 means to tell a <classname>org.hibernate.service.ServiceRegistryBuilder</classname> about
There are 2 means to tell a <classname>org.hibernate.boot.registry.StandardServiceRegistryBuilder</classname> about
custom services.
</para>
<itemizedlist>
<listitem>
<para>
Implement a <interfacename>org.hibernate.service.spi.BasicServiceInitiator</interfacename> class
Implement a <interfacename>org.hibernate.boot.registry.StandardServiceInitiator</interfacename> class
to control on-demand construction of the service class and add it to the
<classname>org.hibernate.service.ServiceRegistryBuilder</classname> via its
<classname>org.hibernate.boot.registry.StandardServiceRegistryBuilder</classname> via its
<methodname>addInitiator</methodname> method.
</para>
</listitem>
<listitem>
<para>
Just instantiate the service class and add it to the
<classname>org.hibernate.service.ServiceRegistryBuilder</classname> via its
<classname>org.hibernate.boot.registry.StandardServiceRegistryBuilder</classname> via its
<methodname>addService</methodname> method.
</para>
</listitem>
@ -921,7 +928,7 @@
<para>
Instances of boot-strap registries are built using the
<classname>org.hibernate.service.BootstrapServiceRegistryBuilder</classname> class.
<classname>org.hibernate.boot.registry.BootstrapServiceRegistryBuilder</classname> class.
</para>
<example xml:id="BootstrapServiceRegistryBuilder-example">
@ -932,7 +939,7 @@
<section id="services-registry-bootstrap-services">
<title>Bootstrap registry services</title>
<section id="services-ClassLoaderService">
<title><interfacename>org.hibernate.service.classloading.spi.ClassLoaderService</interfacename></title>
<title><interfacename>org.hibernate.boot.registry.classloading.spi.ClassLoaderService</interfacename></title>
<para>
Hibernate needs to interact with ClassLoaders. However, the manner in which Hibernate
(or any library) should interact with ClassLoaders varies based on the runtime environment
@ -986,7 +993,7 @@
<para>
This service focuses on the discovery aspect. It leverages the standard Java
<classname>java.util.ServiceLoader</classname> capability provided by the
<interfacename>org.hibernate.service.classloading.spi.ClassLoaderService</interfacename>
<interfacename>org.hibernate.boot.registry.classloading.spi.ClassLoaderService</interfacename>
in order to discover implementations of the
<interfacename>org.hibernate.integrator.spi.Integrator</interfacename> contract.
Integrators would simply define a file named

View File

@ -95,7 +95,7 @@
<para>
JTA-based transaction approach which leverages the
<interfacename>javax.transaction.UserTransaction</interfacename> interface as obtained from
<interfacename>org.hibernate.service.jta.platform.spi.JtaPlatform</interfacename> API. This approach
<interfacename>org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform</interfacename> API. This approach
is represented by the
<classname>org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory</classname> class.
</para>
@ -111,7 +111,7 @@
<para>
Another JTA-based transaction approach which leverages the JTA
<interfacename>javax.transaction.TransactionManager</interfacename> interface as obtained from
<interfacename>org.hibernate.service.jta.platform.spi.JtaPlatform</interfacename> API. This approach
<interfacename>org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform</interfacename> API. This approach
is represented by the
<classname>org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory</classname> class. In
an actual JEE CMT environment, access to the

View File

@ -167,21 +167,6 @@
</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">
<title>Contextual sessions</title>
<para>
@ -259,7 +244,7 @@
The <literal>hibernate.current_session_context_class</literal> configuration parameter
defines which <literal>org.hibernate.context.spi.CurrentSessionContext</literal> implementation
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>.
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

View File

@ -1734,74 +1734,5 @@ hibernate.dialect = org.hibernate.dialect.PostgreSQL82Dialect</programlisting>
transaction demarcation with CMT is preferred.</para>
</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">&lt;?xml version="1.0"?&gt;
&lt;server&gt;
&lt;mbean code="org.hibernate.jmx.HibernateService"
name="jboss.jca:service=HibernateFactory,name=HibernateFactory"&gt;
&lt;!-- Required services --&gt;
&lt;depends&gt;jboss.jca:service=RARDeployer&lt;/depends&gt;
&lt;depends&gt;jboss.jca:service=LocalTxCM,name=HsqlDS&lt;/depends&gt;
&lt;!-- Bind the Hibernate service to JNDI --&gt;
&lt;attribute name="JndiName"&gt;java:/hibernate/SessionFactory&lt;/attribute&gt;
&lt;!-- Datasource settings --&gt;
&lt;attribute name="Datasource"&gt;java:HsqlDS&lt;/attribute&gt;
&lt;attribute name="Dialect"&gt;org.hibernate.dialect.HSQLDialect&lt;/attribute&gt;
&lt;!-- Transaction integration --&gt;
&lt;attribute name="TransactionStrategy"&gt;
org.hibernate.transaction.JTATransactionFactory&lt;/attribute&gt;
&lt;attribute name="TransactionManagerLookupStrategy"&gt;
org.hibernate.transaction.JBossTransactionManagerLookup&lt;/attribute&gt;
&lt;attribute name="FlushBeforeCompletionEnabled"&gt;true&lt;/attribute&gt;
&lt;attribute name="AutoCloseSessionEnabled"&gt;true&lt;/attribute&gt;
&lt;!-- Fetching options --&gt;
&lt;attribute name="MaximumFetchDepth"&gt;5&lt;/attribute&gt;
&lt;!-- Second-level caching --&gt;
&lt;attribute name="SecondLevelCacheEnabled"&gt;true&lt;/attribute&gt;
&lt;attribute name="CacheProviderClass"&gt;org.hibernate.cache.internal.EhCacheProvider&lt;/attribute&gt;
&lt;attribute name="QueryCacheEnabled"&gt;true&lt;/attribute&gt;
&lt;!-- Logging --&gt;
&lt;attribute name="ShowSqlEnabled"&gt;true&lt;/attribute&gt;
&lt;!-- Mapping files --&gt;
&lt;attribute name="MapResources"&gt;auction/Item.hbm.xml,auction/Category.hbm.xml&lt;/attribute&gt;
&lt;/mbean&gt;
&lt;/server&gt;</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>
</chapter>

View File

@ -4,7 +4,7 @@
<title>Tutorial Using Native Hibernate APIs and Annotation Mappings</title>
<para>
This tutorial is located within the download bundle under <filename>basic</filename>.
This tutorial is located within the download bundle under <filename>annotations</filename>.
</para>
<itemizedlist>
<title>Objectives</title>
@ -55,8 +55,7 @@ public class Event {
It functions the same as the <varname>class</varname> mapping element discussed in <xref
linkend="hibernate-gsg-tutorial-basic-mapping"/>. Additionally the
<interfacename>@javax.persistence.Table</interfacename> annotation explicitly specifies the table
name. Without this specification, the default table name would be <literal>EVENT</literal>).<!-- It is a
literal value, not a table as a table -->
name. Without this specification, the default table name would be <database class="table">EVENT</database>).
</para>
<example xml:id="hibernate-gsg-tutorial-annotations-entity-id">

View File

@ -35,11 +35,12 @@ import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
import org.hibernate.cfg.Environment;
import org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.UnknownUnwrapTypeException;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.classloading.spi.ClassLoadingException;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.spi.Configurable;
import org.hibernate.service.spi.ServiceRegistryAwareService;
import org.hibernate.service.spi.ServiceRegistryImplementor;

View File

@ -32,7 +32,7 @@ import org.junit.Test;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;

View File

@ -81,7 +81,7 @@ public interface SessionFactory extends Referenceable, Serializable {
* Open a {@link Session}.
* <p/>
* JDBC {@link Connection connection(s} will be obtained from the
* configured {@link org.hibernate.service.jdbc.connections.spi.ConnectionProvider} as needed
* configured {@link org.hibernate.engine.jdbc.connections.spi.ConnectionProvider} as needed
* to perform requested work.
*
* @return The created session.

View File

@ -0,0 +1,35 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2012, 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.boot.registry;
import org.hibernate.service.ServiceRegistry;
/**
* Specialization of the {@link org.hibernate.service.ServiceRegistry} contract mainly to make the
* {@link StandardServiceRegistryBuilder#StandardServiceRegistryBuilder(BootstrapServiceRegistry)} signature type-safe
*
* @author Steve Ebersole
*/
public interface BootstrapServiceRegistry extends ServiceRegistry {
}

View File

@ -0,0 +1,171 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2012, 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.boot.registry;
import java.util.LinkedHashSet;
import org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl;
import org.hibernate.boot.registry.selector.Availability;
import org.hibernate.boot.registry.selector.AvailabilityAnnouncer;
import org.hibernate.integrator.internal.IntegratorServiceImpl;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
import org.hibernate.boot.registry.selector.internal.StrategySelectorBuilder;
/**
* Builder for bootstrap {@link org.hibernate.service.ServiceRegistry} instances.
*
* @author Steve Ebersole
*
* @see BootstrapServiceRegistryImpl
* @see StandardServiceRegistryBuilder#StandardServiceRegistryBuilder(org.hibernate.boot.registry.BootstrapServiceRegistry)
*/
public class BootstrapServiceRegistryBuilder {
private final LinkedHashSet<Integrator> providedIntegrators = new LinkedHashSet<Integrator>();
private ClassLoader applicationClassLoader;
private ClassLoader resourcesClassLoader;
private ClassLoader hibernateClassLoader;
private ClassLoader environmentClassLoader;
private StrategySelectorBuilder strategySelectorBuilder = new StrategySelectorBuilder();
/**
* Add an {@link Integrator} to be applied to the bootstrap registry.
*
* @param integrator The integrator to add.
* @return {@code this}, for method chaining
*/
public BootstrapServiceRegistryBuilder with(Integrator integrator) {
providedIntegrators.add( integrator );
return this;
}
/**
* Applies the specified {@link ClassLoader} as the application class loader for the bootstrap registry
*
* @param classLoader The class loader to use
* @return {@code this}, for method chaining
*/
@SuppressWarnings( {"UnusedDeclaration"})
public BootstrapServiceRegistryBuilder withApplicationClassLoader(ClassLoader classLoader) {
this.applicationClassLoader = classLoader;
return this;
}
/**
* Applies the specified {@link ClassLoader} as the resource class loader for the bootstrap registry
*
* @param classLoader The class loader to use
* @return {@code this}, for method chaining
*/
@SuppressWarnings( {"UnusedDeclaration"})
public BootstrapServiceRegistryBuilder withResourceClassLoader(ClassLoader classLoader) {
this.resourcesClassLoader = classLoader;
return this;
}
/**
* Applies the specified {@link ClassLoader} as the Hibernate class loader for the bootstrap registry
*
* @param classLoader The class loader to use
* @return {@code this}, for method chaining
*/
@SuppressWarnings( {"UnusedDeclaration"})
public BootstrapServiceRegistryBuilder withHibernateClassLoader(ClassLoader classLoader) {
this.hibernateClassLoader = classLoader;
return this;
}
/**
* Applies the specified {@link ClassLoader} as the environment (or system) class loader for the bootstrap registry
*
* @param classLoader The class loader to use
* @return {@code this}, for method chaining
*/
@SuppressWarnings( {"UnusedDeclaration"})
public BootstrapServiceRegistryBuilder withEnvironmentClassLoader(ClassLoader classLoader) {
this.environmentClassLoader = classLoader;
return this;
}
/**
* Applies a named strategy implementation to the bootstrap registry
*
* @param strategy The strategy
* @param name The registered name
* @param implementation The strategy implementation Class
*
* @return {@code this}, for method chaining
*
* @see org.hibernate.boot.registry.selector.spi.StrategySelector#registerStrategyImplementor(Class, String, Class)
*/
@SuppressWarnings( {"UnusedDeclaration"})
public <T> BootstrapServiceRegistryBuilder withStrategySelector(Class<T> strategy, String name, Class<? extends T> implementation) {
this.strategySelectorBuilder.addExplicitAvailability( strategy, implementation, name );
return this;
}
/**
* Applies one or more strategy selectors announced as available by the passed announcer.
*
* @param availabilityAnnouncer An announcer for one or more available selectors
*
* @return {@code this}, for method chaining
*
* @see org.hibernate.boot.registry.selector.spi.StrategySelector#registerStrategyImplementor(Class, String, Class)
*/
@SuppressWarnings( {"UnusedDeclaration"})
public <T> BootstrapServiceRegistryBuilder withStrategySelectors(AvailabilityAnnouncer availabilityAnnouncer) {
for ( Availability availability : availabilityAnnouncer.getAvailabilities() ) {
this.strategySelectorBuilder.addExplicitAvailability( availability );
}
return this;
}
/**
* Build the bootstrap registry.
*
* @return The built bootstrap registry
*/
public BootstrapServiceRegistry build() {
final ClassLoaderServiceImpl classLoaderService = new ClassLoaderServiceImpl(
applicationClassLoader,
resourcesClassLoader,
hibernateClassLoader,
environmentClassLoader
);
final IntegratorServiceImpl integratorService = new IntegratorServiceImpl(
providedIntegrators,
classLoaderService
);
return new BootstrapServiceRegistryImpl(
classLoaderService,
strategySelectorBuilder.buildSelector( classLoaderService ),
integratorService
);
}
}

View File

@ -21,18 +21,20 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.spi;
package org.hibernate.boot.registry;
import java.util.Map;
import org.hibernate.service.Service;
import org.hibernate.service.spi.ServiceInitiator;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
* Contract for an initiator of services that target the standard {@link org.hibernate.service.ServiceRegistry}
*
* @author Steve Ebersole
*/
public interface BasicServiceInitiator<R extends Service> extends ServiceInitiator<R> {
public interface StandardServiceInitiator<R extends Service> extends ServiceInitiator<R> {
/**
* Initiates the managed service.
*

View File

@ -0,0 +1,224 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2012, 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.boot.registry;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.hibernate.cfg.Environment;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.integrator.spi.IntegratorService;
import org.hibernate.integrator.spi.ServiceContributingIntegrator;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl;
import org.hibernate.jaxb.spi.cfg.JaxbHibernateConfiguration;
import org.hibernate.service.ConfigLoader;
import org.hibernate.service.Service;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.StandardServiceInitiators;
import org.hibernate.service.internal.ProvidedService;
import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
/**
* Builder for standard {@link org.hibernate.service.ServiceRegistry} instances.
*
* @author Steve Ebersole
*
* @see StandardServiceRegistryImpl
* @see org.hibernate.boot.registry.BootstrapServiceRegistryBuilder
*/
public class StandardServiceRegistryBuilder {
public static final String DEFAULT_CFG_RESOURCE_NAME = "hibernate.cfg.xml";
private final Map settings;
private final List<StandardServiceInitiator> initiators = standardInitiatorList();
private final List<ProvidedService> providedServices = new ArrayList<ProvidedService>();
private final BootstrapServiceRegistry bootstrapServiceRegistry;
private final ConfigLoader configLoader;
/**
* Create a default builder
*/
public StandardServiceRegistryBuilder() {
this( new BootstrapServiceRegistryImpl() );
}
/**
* Create a builder with the specified bootstrap services.
*
* @param bootstrapServiceRegistry Provided bootstrap registry to use.
*/
public StandardServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry) {
this.settings = Environment.getProperties();
this.bootstrapServiceRegistry = bootstrapServiceRegistry;
this.configLoader = new ConfigLoader( bootstrapServiceRegistry );
}
/**
* Used from the {@link #initiators} variable initializer
*
* @return List of standard initiators
*/
private static List<StandardServiceInitiator> standardInitiatorList() {
final List<StandardServiceInitiator> initiators = new ArrayList<StandardServiceInitiator>();
initiators.addAll( StandardServiceInitiators.LIST );
return initiators;
}
/**
* Read settings from a {@link Properties} file. Differs from {@link #configure()} and {@link #configure(String)}
* in that here we read a {@link Properties} file while for {@link #configure} we read the XML variant.
*
* @param resourceName The name by which to perform a resource look up for the properties file.
*
* @return this, for method chaining
*
* @see #configure()
* @see #configure(String)
*/
@SuppressWarnings( {"unchecked"})
public StandardServiceRegistryBuilder loadProperties(String resourceName) {
settings.putAll( configLoader.loadProperties( resourceName ) );
return this;
}
/**
* Read setting information from an XML file using the standard resource location
*
* @return this, for method chaining
*
* @see #DEFAULT_CFG_RESOURCE_NAME
* @see #configure(String)
* @see #loadProperties(String)
*/
public StandardServiceRegistryBuilder configure() {
return configure( DEFAULT_CFG_RESOURCE_NAME );
}
/**
* Read setting information from an XML file using the named resource location
*
* @param resourceName The named resource
*
* @return this, for method chaining
*
* @see #loadProperties(String)
*/
@SuppressWarnings( {"unchecked"})
public StandardServiceRegistryBuilder configure(String resourceName) {
JaxbHibernateConfiguration configurationElement = configLoader.loadConfigXmlResource( resourceName );
for ( JaxbHibernateConfiguration.JaxbSessionFactory.JaxbProperty xmlProperty : configurationElement.getSessionFactory().getProperty() ) {
settings.put( xmlProperty.getName(), xmlProperty.getValue() );
}
return this;
}
/**
* Apply a setting value
*
* @param settingName The name of the setting
* @param value The value to use.
*
* @return this, for method chaining
*/
@SuppressWarnings( {"unchecked", "UnusedDeclaration"})
public StandardServiceRegistryBuilder applySetting(String settingName, Object value) {
settings.put( settingName, value );
return this;
}
/**
* Apply a groups of setting values
*
* @param settings The incoming settings to apply
*
* @return this, for method chaining
*/
@SuppressWarnings( {"unchecked", "UnusedDeclaration"})
public StandardServiceRegistryBuilder applySettings(Map settings) {
this.settings.putAll( settings );
return this;
}
/**
* Adds a service initiator.
*
* @param initiator The initiator to be added
*
* @return this, for method chaining
*/
@SuppressWarnings( {"UnusedDeclaration"})
public StandardServiceRegistryBuilder addInitiator(StandardServiceInitiator initiator) {
initiators.add( initiator );
return this;
}
/**
* Adds a user-provided service
*
* @param serviceRole The role of the service being added
* @param service The service implementation
*
* @return this, for method chaining
*/
@SuppressWarnings( {"unchecked"})
public StandardServiceRegistryBuilder addService(final Class serviceRole, final Service service) {
providedServices.add( new ProvidedService( serviceRole, service ) );
return this;
}
/**
* Build the service registry accounting for all settings and service initiators and services.
*
* @return The built service registry
*/
public ServiceRegistry buildServiceRegistry() {
Map<?,?> settingsCopy = new HashMap();
settingsCopy.putAll( settings );
Environment.verifyProperties( settingsCopy );
ConfigurationHelper.resolvePlaceHolders( settingsCopy );
for ( Integrator integrator : bootstrapServiceRegistry.getService( IntegratorService.class ).getIntegrators() ) {
if ( ServiceContributingIntegrator.class.isInstance( integrator ) ) {
ServiceContributingIntegrator.class.cast( integrator ).prepareServices( this );
}
}
return new StandardServiceRegistryImpl( bootstrapServiceRegistry, initiators, providedServices, settingsCopy );
}
/**
* Destroy a service registry. Applications should only destroy registries they have explicitly created.
*
* @param serviceRegistry The registry to be closed.
*/
public static void destroy(ServiceRegistry serviceRegistry) {
( (StandardServiceRegistryImpl) serviceRegistry ).destroy();
}
}

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.classloading.internal;
package org.hibernate.boot.registry.classloading.internal;
import java.io.IOException;
import java.io.InputStream;
@ -38,9 +38,8 @@ import java.util.ServiceLoader;
import org.jboss.logging.Logger;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.classloading.spi.ClassLoadingException;
import org.hibernate.service.classloading.spi.StrategyInstanceResolver;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
/**
* Standard implementation of the service for interacting with class loaders
@ -54,8 +53,6 @@ public class ClassLoaderServiceImpl implements ClassLoaderService {
private final ClassLoader resourcesClassLoader;
private final ClassLoader serviceLoaderClassLoader;
private final StrategyInstanceResolverImpl strategyInstanceResolver = new StrategyInstanceResolverImpl( this );
public ClassLoaderServiceImpl() {
this( ClassLoaderServiceImpl.class.getClassLoader() );
}
@ -334,9 +331,4 @@ public class ClassLoaderServiceImpl implements ClassLoaderService {
}
}
@Override
public StrategyInstanceResolver getStrategyInstanceResolver() {
return strategyInstanceResolver;
}
}

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.classloading.spi;
package org.hibernate.boot.registry.classloading.spi;
import java.io.InputStream;
import java.net.URL;
@ -86,11 +86,4 @@ public interface ClassLoaderService extends Service {
* @return The ordered set of discovered services.
*/
public <S> LinkedHashSet<S> loadJavaServices(Class<S> serviceContract);
/**
* Retrieve a StrategyInstanceResolver instance. See StrategyInstanceResolver docs for details.
*
* @return The StrategyInstanceResolver instance.
*/
public StrategyInstanceResolver getStrategyInstanceResolver();
}

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.classloading.spi;
package org.hibernate.boot.registry.classloading.spi;
import org.hibernate.HibernateException;
/**

View File

@ -1,7 +1,7 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
* Copyright (c) 2012, 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.
@ -21,18 +21,20 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.internal;
package org.hibernate.boot.registry.internal;
import java.util.LinkedHashSet;
import org.hibernate.integrator.internal.IntegratorServiceImpl;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.integrator.spi.IntegratorService;
import org.hibernate.service.BootstrapServiceRegistry;
import org.hibernate.boot.registry.BootstrapServiceRegistry;
import org.hibernate.service.Service;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.classloading.internal.ClassLoaderServiceImpl;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.selector.internal.StrategySelectorImpl;
import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.service.spi.ServiceBinding;
import org.hibernate.service.spi.ServiceException;
import org.hibernate.service.spi.ServiceInitiator;
@ -44,6 +46,11 @@ import org.hibernate.service.spi.ServiceRegistryImplementor;
* <li>{@link IntegratorService}</li>
* </ul>
*
* IMPL NOTE : Currently implements the deprecated {@link org.hibernate.service.BootstrapServiceRegistry} contract
* so that the registry returned from the builder works on the deprecated sense. Once
* {@link org.hibernate.service.BootstrapServiceRegistry} goes away, this should be updated to instead implement
* {@link org.hibernate.boot.registry.BootstrapServiceRegistry}.
*
* @author Steve Ebersole
*/
public class BootstrapServiceRegistryImpl
@ -51,6 +58,7 @@ public class BootstrapServiceRegistryImpl
private static final LinkedHashSet<Integrator> NO_INTEGRATORS = new LinkedHashSet<Integrator>();
private final ServiceBinding<ClassLoaderService> classLoaderServiceBinding;
private final ServiceBinding<StrategySelector> strategySelectorBinding;
private final ServiceBinding<IntegratorService> integratorServiceBinding;
public BootstrapServiceRegistryImpl() {
@ -59,6 +67,30 @@ public class BootstrapServiceRegistryImpl
public BootstrapServiceRegistryImpl(
ClassLoaderService classLoaderService,
LinkedHashSet<Integrator> providedIntegrators) {
this.classLoaderServiceBinding = new ServiceBinding<ClassLoaderService>(
this,
ClassLoaderService.class,
classLoaderService
);
final StrategySelectorImpl strategySelector = new StrategySelectorImpl( classLoaderService );
this.strategySelectorBinding = new ServiceBinding<StrategySelector>(
this,
StrategySelector.class,
strategySelector
);
this.integratorServiceBinding = new ServiceBinding<IntegratorService>(
this,
IntegratorService.class,
new IntegratorServiceImpl( providedIntegrators, classLoaderService )
);
}
public BootstrapServiceRegistryImpl(
ClassLoaderService classLoaderService,
StrategySelector strategySelector,
IntegratorService integratorService) {
this.classLoaderServiceBinding = new ServiceBinding<ClassLoaderService>(
this,
@ -66,6 +98,12 @@ public class BootstrapServiceRegistryImpl
classLoaderService
);
this.strategySelectorBinding = new ServiceBinding<StrategySelector>(
this,
StrategySelector.class,
strategySelector
);
this.integratorServiceBinding = new ServiceBinding<IntegratorService>(
this,
IntegratorService.class,
@ -74,13 +112,6 @@ public class BootstrapServiceRegistryImpl
}
public BootstrapServiceRegistryImpl(
ClassLoaderService classLoaderService,
LinkedHashSet<Integrator> providedIntegrators) {
this( classLoaderService, new IntegratorServiceImpl( providedIntegrators, classLoaderService ) );
}
@Override
public <R extends Service> R getService(Class<R> serviceRole) {
@ -94,6 +125,9 @@ public class BootstrapServiceRegistryImpl
if ( ClassLoaderService.class.equals( serviceRole ) ) {
return (ServiceBinding<R>) classLoaderServiceBinding;
}
else if ( StrategySelector.class.equals( serviceRole) ) {
return (ServiceBinding<R>) strategySelectorBinding;
}
else if ( IntegratorService.class.equals( serviceRole ) ) {
return (ServiceBinding<R>) integratorServiceBinding;
}

View File

@ -21,15 +21,17 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.internal;
package org.hibernate.boot.registry.internal;
import java.util.List;
import java.util.Map;
import org.hibernate.service.BootstrapServiceRegistry;
import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.boot.registry.BootstrapServiceRegistry;
import org.hibernate.service.Service;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.spi.BasicServiceInitiator;
import org.hibernate.service.internal.AbstractServiceRegistryImpl;
import org.hibernate.service.internal.ProvidedService;
import org.hibernate.service.spi.Configurable;
import org.hibernate.service.spi.ServiceBinding;
import org.hibernate.service.spi.ServiceInitiator;
@ -45,7 +47,7 @@ public class StandardServiceRegistryImpl extends AbstractServiceRegistryImpl imp
@SuppressWarnings( {"unchecked"})
public StandardServiceRegistryImpl(
BootstrapServiceRegistry bootstrapServiceRegistry,
List<BasicServiceInitiator> serviceInitiators,
List<StandardServiceInitiator> serviceInitiators,
List<ProvidedService> providedServices,
Map<?, ?> configurationValues) {
super( bootstrapServiceRegistry );
@ -66,7 +68,7 @@ public class StandardServiceRegistryImpl extends AbstractServiceRegistryImpl imp
@Override
public <R extends Service> R initiateService(ServiceInitiator<R> serviceInitiator) {
// todo : add check/error for unexpected initiator types?
return ( (BasicServiceInitiator<R>) serviceInitiator ).initiateService( configurationValues, this );
return ( (StandardServiceInitiator<R>) serviceInitiator ).initiateService( configurationValues, this );
}
@Override

View File

@ -0,0 +1,33 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2012, 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.boot.registry.selector;
/**
* @author Steve Ebersole
*/
public interface Availability {
public Class getStrategyRole();
public Iterable<String> getSelectorNames();
public Class getStrategyImplementation();
}

View File

@ -0,0 +1,36 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2012, 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.boot.registry.selector;
/**
* Responsible for announcing the availability of strategy selector(s). Can be registered directly with the
* {@link org.hibernate.boot.registry.BootstrapServiceRegistry} or located via discovery
*
* todo : better name?
*
* @author Steve Ebersole
*/
public interface AvailabilityAnnouncer {
public Iterable<Availability> getAvailabilities();
}

View File

@ -0,0 +1,66 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2012, 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.boot.registry.selector;
import java.util.Arrays;
/**
* @author Steve Ebersole
*/
public class SimpleAvailabilityImpl implements Availability {
private final Class strategyRole;
private final Class strategyImplementation;
private final Iterable<String> selectorNames;
public SimpleAvailabilityImpl(
Class strategyRole,
Class strategyImplementation,
Iterable<String> selectorNames) {
this.strategyRole = strategyRole;
this.strategyImplementation = strategyImplementation;
this.selectorNames = selectorNames;
}
public SimpleAvailabilityImpl(
Class strategyRole,
Class strategyImplementation,
String... selectorNames) {
this( strategyRole, strategyImplementation, Arrays.asList( selectorNames ) );
}
@Override
public Class getStrategyRole() {
return strategyRole;
}
@Override
public Iterable<String> getSelectorNames() {
return selectorNames;
}
@Override
public Class getStrategyImplementation() {
return strategyImplementation;
}
}

View File

@ -0,0 +1,330 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2012, 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.boot.registry.selector.internal;
import java.util.ArrayList;
import java.util.List;
import org.jboss.logging.Logger;
import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
import org.hibernate.boot.registry.selector.Availability;
import org.hibernate.boot.registry.selector.AvailabilityAnnouncer;
import org.hibernate.boot.registry.selector.SimpleAvailabilityImpl;
import org.hibernate.boot.registry.selector.spi.StrategySelectionException;
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
*/
public class StrategySelectorBuilder {
private static final Logger log = Logger.getLogger( StrategySelectorBuilder.class );
private final List<Availability> explicitAvailabilities = new ArrayList<Availability>();
@SuppressWarnings("unchecked")
public <T> void addExplicitAvailability(Class<T> strategy, Class<? extends T> implementation, String name) {
addExplicitAvailability( new SimpleAvailabilityImpl( strategy, implementation, name ) );
}
public void addExplicitAvailability(Availability availability) {
if ( !availability.getStrategyRole().isInterface() ) {
// not good form...
log.debug( "Registering non-interface strategy implementation : " + availability.getStrategyRole().getName() );
}
if ( ! availability.getStrategyRole().isAssignableFrom( availability.getStrategyImplementation() ) ) {
throw new StrategySelectionException(
"Implementation class [" + availability.getStrategyImplementation().getName()
+ "] does not implement strategy interface ["
+ availability.getStrategyRole().getName() + "]"
);
}
explicitAvailabilities.add( availability );
}
public StrategySelector buildSelector(ClassLoaderServiceImpl classLoaderService) {
StrategySelectorImpl strategySelector = new StrategySelectorImpl( classLoaderService );
// build the baseline...
addDialects( strategySelector );
addJtaPlatforms( strategySelector );
addTransactionFactories( strategySelector );
// apply auto-discovered registrations
for ( AvailabilityAnnouncer announcer : classLoaderService.loadJavaServices( AvailabilityAnnouncer.class ) ) {
for ( Availability discoveredAvailability : announcer.getAvailabilities() ) {
applyFromAvailability( strategySelector, discoveredAvailability );
}
}
// apply customizations
for ( Availability explicitAvailability : explicitAvailabilities ) {
applyFromAvailability( strategySelector, explicitAvailability );
}
return strategySelector;
}
@SuppressWarnings("unchecked")
private void applyFromAvailability(StrategySelectorImpl strategySelector, Availability availability) {
for ( String name : availability.getSelectorNames() ) {
strategySelector.registerStrategyImplementor(
availability.getStrategyRole(),
name,
availability.getStrategyImplementation()
);
}
}
private void addDialects(StrategySelectorImpl strategySelector) {
addDialect( strategySelector, Cache71Dialect.class );
addDialect( strategySelector, CUBRIDDialect.class );
addDialect( strategySelector, DB2Dialect.class );
addDialect( strategySelector, DB2390Dialect.class );
addDialect( strategySelector, DB2400Dialect.class );
addDialect( strategySelector, DerbyTenFiveDialect.class );
addDialect( strategySelector, DerbyTenSixDialect.class );
addDialect( strategySelector, DerbyTenSevenDialect.class );
addDialect( strategySelector, FirebirdDialect.class );
addDialect( strategySelector, FrontBaseDialect.class );
addDialect( strategySelector, H2Dialect.class );
addDialect( strategySelector, HSQLDialect.class );
addDialect( strategySelector, InformixDialect.class );
addDialect( strategySelector, IngresDialect.class );
addDialect( strategySelector, Ingres9Dialect.class );
addDialect( strategySelector, Ingres10Dialect.class );
addDialect( strategySelector, InterbaseDialect.class );
addDialect( strategySelector, JDataStoreDialect.class );
addDialect( strategySelector, MckoiDialect.class );
addDialect( strategySelector, MimerSQLDialect.class );
addDialect( strategySelector, MySQL5Dialect.class );
addDialect( strategySelector, MySQL5InnoDBDialect.class );
addDialect( strategySelector, MySQL5Dialect.class );
addDialect( strategySelector, MySQL5InnoDBDialect.class );
addDialect( strategySelector, Oracle8iDialect.class );
addDialect( strategySelector, Oracle9iDialect.class );
addDialect( strategySelector, Oracle10gDialect.class );
addDialect( strategySelector, PointbaseDialect.class );
addDialect( strategySelector, PostgresPlusDialect.class );
addDialect( strategySelector, PostgreSQL81Dialect.class );
addDialect( strategySelector, PostgreSQL82Dialect.class );
addDialect( strategySelector, ProgressDialect.class );
addDialect( strategySelector, SAPDBDialect.class );
addDialect( strategySelector, SQLServerDialect.class );
addDialect( strategySelector, SQLServer2005Dialect.class );
addDialect( strategySelector, SQLServer2008Dialect.class );
addDialect( strategySelector, Sybase11Dialect.class );
addDialect( strategySelector, SybaseAnywhereDialect.class );
addDialect( strategySelector, SybaseASE15Dialect.class );
addDialect( strategySelector, SybaseASE157Dialect.class );
addDialect( strategySelector, TeradataDialect.class );
addDialect( strategySelector, TimesTenDialect.class );
}
private void addDialect(StrategySelectorImpl strategySelector, Class<? extends Dialect> dialectClass) {
String simpleName = dialectClass.getSimpleName();
if ( simpleName.endsWith( "Dialect" ) ) {
simpleName = simpleName.substring( 0, simpleName.length() - "Dialect".length() );
}
strategySelector.registerStrategyImplementor( Dialect.class, simpleName, dialectClass );
}
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) {
strategySelector.registerStrategyImplementor( TransactionFactory.class, JdbcTransactionFactory.SHORT_NAME, JdbcTransactionFactory.class );
strategySelector.registerStrategyImplementor( TransactionFactory.class, "org.hibernate.transaction.JDBCTransactionFactory", JdbcTransactionFactory.class );
strategySelector.registerStrategyImplementor( TransactionFactory.class, JtaTransactionFactory.SHORT_NAME, JtaTransactionFactory.class );
strategySelector.registerStrategyImplementor( TransactionFactory.class, "org.hibernate.transaction.JTATransactionFactory", JtaTransactionFactory.class );
strategySelector.registerStrategyImplementor( TransactionFactory.class, CMTTransactionFactory.SHORT_NAME, CMTTransactionFactory.class );
strategySelector.registerStrategyImplementor( TransactionFactory.class, "org.hibernate.transaction.CMTTransactionFactory", CMTTransactionFactory.class );
}
}

View File

@ -0,0 +1,161 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2012, 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.boot.registry.selector.internal;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.jboss.logging.Logger;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.boot.registry.selector.spi.StrategySelectionException;
import org.hibernate.boot.registry.selector.spi.StrategySelector;
/**
* @author Steve Ebersole
*/
public class StrategySelectorImpl implements StrategySelector {
private static final Logger log = Logger.getLogger( StrategySelectorImpl.class );
private final Map<Class,Map<String,Class>> namedStrategyImplementorByStrategyMap
= new ConcurrentHashMap<Class, Map<String, Class>>();
private final ClassLoaderService classLoaderService;
public StrategySelectorImpl(ClassLoaderService classLoaderService) {
this.classLoaderService = classLoaderService;
}
@Override
public <T> void registerStrategyImplementor(Class<T> strategy, String name, Class<? extends T> implementation) {
Map<String,Class> namedStrategyImplementorMap = namedStrategyImplementorByStrategyMap.get( strategy );
if ( namedStrategyImplementorMap == null ) {
namedStrategyImplementorMap = new ConcurrentHashMap<String, Class>();
namedStrategyImplementorByStrategyMap.put( strategy, namedStrategyImplementorMap );
}
Class old = namedStrategyImplementorMap.put( name, implementation );
if ( old == null ) {
log.trace(
String.format(
"Registering named strategy selector [%s] : [%s] -> [%s]",
strategy.getName(),
name,
implementation.getName()
)
);
}
else {
log.debug(
String.format(
"Registering named strategy selector [%s] : [%s] -> [%s] (replacing [%s])",
strategy.getName(),
name,
implementation.getName(),
old.getName()
)
);
}
}
@Override
public <T> void unRegisterStrategyImplementor(Class<T> strategy, Class<? extends T> implementation) {
Map<String,Class> namedStrategyImplementorMap = namedStrategyImplementorByStrategyMap.get( strategy );
if ( namedStrategyImplementorMap == null ) {
log.debug( "Named strategy map did not exist on call to un-register" );
return;
}
final Iterator itr = namedStrategyImplementorMap.values().iterator();
while ( itr.hasNext() ) {
final Class registered = (Class) itr.next();
if ( registered.equals( implementation ) ) {
itr.remove();
}
}
// try tp clean up after ourselves...
if ( namedStrategyImplementorMap.isEmpty() ) {
namedStrategyImplementorByStrategyMap.remove( strategy );
}
}
@Override
@SuppressWarnings("unchecked")
public <T> Class<? extends T> selectStrategyImplementor(Class<T> strategy, String name) {
Map<String,Class> namedStrategyImplementorMap = namedStrategyImplementorByStrategyMap.get( strategy );
if ( namedStrategyImplementorMap != null ) {
final Class registered = namedStrategyImplementorMap.get( name );
if ( registered != null ) {
return (Class<T>) registered;
}
}
try {
return classLoaderService.classForName( name );
}
catch (ClassLoadingException e) {
throw new StrategySelectionException(
"Unable to resolve name [" + name + "] as strategy [" + strategy.getName() + "]"
);
}
}
@Override
public <T> T resolveStrategy(Class<T> strategy, Object strategyReference) {
return resolveDefaultableStrategy( strategy, strategyReference, null );
}
@Override
@SuppressWarnings("unchecked")
public <T> T resolveDefaultableStrategy(Class<T> strategy, Object strategyReference, T defaultValue) {
if ( strategyReference == null ) {
return defaultValue;
}
if ( strategy.isInstance( strategyReference ) ) {
return strategy.cast( strategyReference );
}
final Class<? extends T> implementationClass;
if ( Class.class.isInstance( strategyReference ) ) {
implementationClass = (Class<T>) strategyReference;
}
else {
implementationClass = selectStrategyImplementor( strategy, strategyReference.toString() );
}
try {
return implementationClass.newInstance();
}
catch (Exception e) {
throw new StrategySelectionException(
String.format( "Could not instantiate named strategy class [%s]", implementationClass.getName() ),
e
);
}
}
}

View File

@ -0,0 +1 @@
package org.hibernate.boot.registry.selector;

View File

@ -1,7 +1,7 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* Copyright (c) 2012, 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.
@ -21,36 +21,19 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.jmx;
package org.hibernate.boot.registry.selector.spi;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.hibernate.HibernateException;
/**
* @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();
}
public class StrategySelectionException extends HibernateException {
public StrategySelectionException(String message) {
super( message );
}
public StrategySelectionException(String message, Throwable root) {
super( message, root );
}
}

View File

@ -0,0 +1,98 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2012, 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.boot.registry.selector.spi;
import org.hibernate.service.Service;
/**
* Service which acts as a registry for named strategy implementations.
*
* @author Steve Ebersole
*/
public interface StrategySelector extends Service {
/**
* Registers a named implementor of a particular strategy contract.
*
* @param strategy The strategy contract.
* @param name The registration name
* @param implementation The implementation Class
*/
public <T> void registerStrategyImplementor(Class<T> strategy, String name, Class<? extends T> implementation);
/**
* Un-registers a named implementor of a particular strategy contract. Un-registers all named registrations
* for the given strategy contract naming the given class.
*
* @param strategy The strategy contract.
* @param implementation The implementation Class
*/
public <T> void unRegisterStrategyImplementor(Class<T> strategy, Class<? extends T> implementation);
/**
* Locate the named strategy implementation.
*
* @param strategy The type of strategy to be resolved.
* @param name The name of the strategy to locate; might be either a registered name or the implementation FQN.
*
* @return The named strategy implementation class.
*/
public <T> Class<? extends T> selectStrategyImplementor(Class<T> strategy, String name);
/**
* Resolve strategy instances. See discussion on {@link #resolveDefaultableStrategy}.
* Only difference is that here, the implied default value is {@code null}.
*
* @param strategy The type (interface) of the strategy to be resolved.
* @param strategyReference The reference to the strategy for which we need to resolve an instance.
*
* @return The strategy instance
*/
public <T> T resolveStrategy(Class<T> strategy, Object strategyReference);
/**
* Resolve strategy instances. The incoming reference might be:<ul>
* <li>
* {@code null} - in which case defaultValue is returned.
* </li>
* <li>
* An actual instance of the strategy type - it is returned, as is
* </li>
* <li>
* A reference to the implementation {@link Class} - an instance is created by calling
* {@link Class#newInstance()} (aka, the class's no-arg ctor).
* </li>
* <li>
* The name of the implementation class - First the implementation's {@link Class} reference
* is resolved, and then an instance is created by calling {@link Class#newInstance()}
* </li>
* </ul>
*
* @param strategy The type (interface) of the strategy to be resolved.
* @param strategyReference The reference to the strategy for which we need to resolve an instance.
* @param defaultValue THe default value to use if strategyReference is null
*
* @return The strategy instance
*/
public <T> T resolveDefaultableStrategy(Class<T> strategy, Object strategyReference, T defaultValue);
}

View File

@ -25,9 +25,13 @@ package org.hibernate.bytecode.buildtime.internal;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Set;
import javassist.ClassClassPath;
import javassist.ClassPool;
import javassist.bytecode.ClassFile;
import org.hibernate.bytecode.buildtime.spi.AbstractInstrumenter;
@ -44,6 +48,7 @@ import org.hibernate.bytecode.spi.ClassTransformer;
*
* @author Steve Ebersole
* @author Muga Nishizawa
* @author Dustin Schultz
*/
public class JavassistInstrumenter extends AbstractInstrumenter {
@ -70,6 +75,20 @@ public class JavassistInstrumenter extends AbstractInstrumenter {
return provider.getTransformer( CLASS_FILTER, new CustomFieldFilter( descriptor, classNames ) );
}
}
@Override
public void execute(Set<File> files) {
ClassPool cp = ClassPool.getDefault();
cp.insertClassPath(new ClassClassPath(this.getClass()));
try {
for (File file : files) {
cp.makeClass(new FileInputStream(file));
}
} catch (IOException e) {
throw new RuntimeException(e.getMessage(), e);
}
super.execute(files);
}
private static class CustomClassDescriptor implements ClassDescriptor {
private final byte[] bytes;

View File

@ -32,6 +32,7 @@ import java.util.Iterator;
import java.util.List;
import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.bytecode.AccessFlag;
import javassist.bytecode.BadBytecode;
import javassist.bytecode.Bytecode;
@ -43,6 +44,8 @@ import javassist.bytecode.Descriptor;
import javassist.bytecode.FieldInfo;
import javassist.bytecode.MethodInfo;
import javassist.bytecode.Opcode;
import javassist.bytecode.StackMapTable;
import javassist.bytecode.stackmap.MapMaker;
/**
* The thing that handles actual class enhancement in regards to
@ -50,6 +53,7 @@ import javassist.bytecode.Opcode;
*
* @author Muga Nishizawa
* @author Steve Ebersole
* @author Dustin Schultz
*/
public class FieldTransformer {
@ -130,7 +134,7 @@ public class FieldTransformer {
}
private void addGetFieldHandlerMethod(ClassFile classfile)
throws CannotCompileException {
throws CannotCompileException, BadBytecode {
ConstPool cp = classfile.getConstPool();
int this_class_index = cp.getThisClassInfo();
MethodInfo minfo = new MethodInfo(cp, GETFIELDHANDLER_METHOD_NAME,
@ -148,11 +152,13 @@ public class FieldTransformer {
code.addOpcode(Opcode.ARETURN);
minfo.setCodeAttribute(code.toCodeAttribute());
minfo.setAccessFlags(AccessFlag.PUBLIC);
StackMapTable smt = MapMaker.make(ClassPool.getDefault(), minfo);
minfo.getCodeAttribute().setAttribute(smt);
classfile.addMethod(minfo);
}
private void addSetFieldHandlerMethod(ClassFile classfile)
throws CannotCompileException {
throws CannotCompileException, BadBytecode {
ConstPool cp = classfile.getConstPool();
int this_class_index = cp.getThisClassInfo();
MethodInfo minfo = new MethodInfo(cp, SETFIELDHANDLER_METHOD_NAME,
@ -172,6 +178,8 @@ public class FieldTransformer {
code.addOpcode(Opcode.RETURN);
minfo.setCodeAttribute(code.toCodeAttribute());
minfo.setAccessFlags(AccessFlag.PUBLIC);
StackMapTable smt = MapMaker.make(ClassPool.getDefault(), minfo);
minfo.getCodeAttribute().setAttribute(smt);
classfile.addMethod(minfo);
}
@ -185,7 +193,7 @@ public class FieldTransformer {
}
private void addReadWriteMethods(ClassFile classfile)
throws CannotCompileException {
throws CannotCompileException, BadBytecode {
List fields = classfile.getFields();
for (Iterator field_iter = fields.iterator(); field_iter.hasNext();) {
FieldInfo finfo = (FieldInfo) field_iter.next();
@ -205,7 +213,7 @@ public class FieldTransformer {
}
private void addReadMethod(ClassFile classfile, FieldInfo finfo)
throws CannotCompileException {
throws CannotCompileException, BadBytecode {
ConstPool cp = classfile.getConstPool();
int this_class_index = cp.getThisClassInfo();
String desc = "()" + finfo.getDescriptor();
@ -254,11 +262,13 @@ public class FieldTransformer {
minfo.setCodeAttribute(code.toCodeAttribute());
minfo.setAccessFlags(AccessFlag.PUBLIC);
StackMapTable smt = MapMaker.make(ClassPool.getDefault(), minfo);
minfo.getCodeAttribute().setAttribute(smt);
classfile.addMethod(minfo);
}
private void addWriteMethod(ClassFile classfile, FieldInfo finfo)
throws CannotCompileException {
throws CannotCompileException, BadBytecode {
ConstPool cp = classfile.getConstPool();
int this_class_index = cp.getThisClassInfo();
String desc = "(" + finfo.getDescriptor() + ")V";
@ -320,11 +330,13 @@ public class FieldTransformer {
minfo.setCodeAttribute(code.toCodeAttribute());
minfo.setAccessFlags(AccessFlag.PUBLIC);
StackMapTable smt = MapMaker.make(ClassPool.getDefault(), minfo);
minfo.getCodeAttribute().setAttribute(smt);
classfile.addMethod(minfo);
}
private void transformInvokevirtualsIntoPutAndGetfields(ClassFile classfile)
throws CannotCompileException {
throws CannotCompileException, BadBytecode {
List methods = classfile.getMethods();
for (Iterator method_iter = methods.iterator(); method_iter.hasNext();) {
MethodInfo minfo = (MethodInfo) method_iter.next();
@ -341,15 +353,13 @@ public class FieldTransformer {
}
CodeIterator iter = codeAttr.iterator();
while (iter.hasNext()) {
try {
int pos = iter.next();
pos = transformInvokevirtualsIntoGetfields(classfile, iter, pos);
pos = transformInvokevirtualsIntoPutfields(classfile, iter, pos);
} catch (BadBytecode e) {
throw new CannotCompileException(e);
}
int pos = iter.next();
pos = transformInvokevirtualsIntoGetfields(classfile, iter, pos);
pos = transformInvokevirtualsIntoPutfields(classfile, iter, pos);
}
StackMapTable smt = MapMaker.make(ClassPool.getDefault(), minfo);
minfo.getCodeAttribute().setAttribute(smt);
}
}

View File

@ -33,7 +33,6 @@ import org.hibernate.cache.spi.CollectionRegion;
import org.hibernate.cache.spi.EntityRegion;
import org.hibernate.cache.spi.NaturalIdRegion;
import org.hibernate.cache.spi.QueryResultsRegion;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.TimestampsRegion;
import org.hibernate.cache.spi.access.AccessType;
@ -43,7 +42,7 @@ import org.hibernate.cache.spi.access.AccessType;
* @author Steve Ebersole
*/
public class NoCachingRegionFactory extends AbstractRegionFactory {
public static RegionFactory INSTANCE = new NoCachingRegionFactory();
public static NoCachingRegionFactory INSTANCE = new NoCachingRegionFactory();
@Override
public void start() {

View File

@ -25,14 +25,16 @@ package org.hibernate.cache.internal;
import org.jboss.logging.Logger;
import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.config.spi.ConfigurationService;
import org.hibernate.service.config.spi.StandardConverters;
import org.hibernate.service.spi.ServiceException;
import org.hibernate.service.spi.ServiceRegistryImplementor;
@ -72,50 +74,21 @@ public class RegionFactoryInitiator implements SessionFactoryServiceInitiator<Re
}
private RegionFactory initiateService(SessionFactoryImplementor sessionFactory, ServiceRegistryImplementor registry){
final Object impl = registry.getService( ConfigurationService.class ).getSettings().get( IMPL_NAME );
boolean isCacheEnabled = isCacheEnabled( registry );
RegionFactory factory;
if ( !isCacheEnabled ) {
LOG.debugf(
"Second level cache has been disabled, so using % as cache region factory",
NoCachingRegionFactory.class.getName()
);
factory = NoCachingRegionFactory.INSTANCE;
}
else if ( impl == null ) {
LOG.debugf(
"No 'hibernate.cache.region.factory_class' is provided, so using %s as default",
NoCachingRegionFactory.class.getName()
);
factory = NoCachingRegionFactory.INSTANCE;
}
else {
LOG.debugf( "Cache region factory : %s", impl.toString() );
if ( getServiceInitiated().isInstance( impl ) ) {
factory = (RegionFactory) impl;
}
else {
Class<? extends RegionFactory> customImplClass = null;
if ( Class.class.isInstance( impl ) ) {
customImplClass = (Class<? extends RegionFactory>) impl;
}
else {
customImplClass = registry.getService( ClassLoaderService.class )
.classForName( mapLegacyNames( impl.toString() ) );
}
try {
factory = customImplClass.newInstance();
}
catch ( Exception e ) {
throw new ServiceException(
"Could not initialize custom RegionFactory impl [" + customImplClass.getName() + "]", e
);
}
}
return NoCachingRegionFactory.INSTANCE;
}
return factory;
final Object setting = registry.getService( ConfigurationService.class ).getSettings().get( IMPL_NAME );
return registry.getService( StrategySelector.class ).resolveDefaultableStrategy(
RegionFactory.class,
setting,
NoCachingRegionFactory.INSTANCE
);
}
private static boolean isCacheEnabled(ServiceRegistryImplementor serviceRegistry) {

View File

@ -40,10 +40,10 @@ import org.hibernate.cache.spi.QueryResultsRegion;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.UpdateTimestampsCache;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.service.config.spi.ConfigurationService;
import org.hibernate.service.config.spi.StandardConverters;
import org.hibernate.type.Type;
import org.hibernate.type.TypeHelper;

View File

@ -1,3 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2012, 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.cache.spi;
import java.util.Properties;
@ -8,8 +31,8 @@ import org.hibernate.cache.CacheException;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Settings;
import org.hibernate.cfg.SettingsFactory;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.service.config.spi.ConfigurationService;
import org.hibernate.service.config.spi.StandardConverters;
import org.hibernate.service.spi.ServiceRegistryAwareService;
import org.hibernate.service.spi.ServiceRegistryImplementor;

View File

@ -53,6 +53,7 @@ import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
@ -1393,17 +1394,42 @@ public final class AnnotationBinder {
if ( element.isAnnotationPresent( Id.class ) && element.isAnnotationPresent( Column.class ) ) {
String columnName = element.getAnnotation( Column.class ).name();
for ( XProperty prop : declaringClass.getDeclaredProperties( AccessType.FIELD.getType() ) ) {
if ( prop.isAnnotationPresent( JoinColumn.class )
&& prop.getAnnotation( JoinColumn.class ).name().equals( columnName )
&& !prop.isAnnotationPresent( MapsId.class ) ) {
//create a PropertyData fpr the specJ property holding the mapping
PropertyData specJPropertyData = new PropertyInferredData(
declaringClass, //same dec
prop, // the actual @XToOne property
propertyAccessor, //TODO we should get the right accessor but the same as id would do
mappings.getReflectionManager()
);
mappings.addPropertyAnnotatedWithMapsIdSpecj( entity, specJPropertyData, element.toString() );
if ( !prop.isAnnotationPresent( MapsId.class ) ) {
/**
* The detection of a configured individual JoinColumn differs between Annotation
* and XML configuration processing.
*/
boolean isRequiredAnnotationPresent = false;
JoinColumns groupAnnotation = prop.getAnnotation( JoinColumns.class );
if ( (prop.isAnnotationPresent( JoinColumn.class )
&& prop.getAnnotation( JoinColumn.class ).name().equals( columnName )) ) {
isRequiredAnnotationPresent = true;
}
else if ( prop.isAnnotationPresent( JoinColumns.class ) ) {
for ( JoinColumn columnAnnotation : groupAnnotation.value() ) {
if ( columnName.equals( columnAnnotation.name() ) ) {
isRequiredAnnotationPresent = true;
break;
}
}
}
if ( isRequiredAnnotationPresent ) {
//create a PropertyData fpr the specJ property holding the mapping
PropertyData specJPropertyData = new PropertyInferredData(
declaringClass,
//same dec
prop,
// the actual @XToOne property
propertyAccessor,
//TODO we should get the right accessor but the same as id would do
mappings.getReflectionManager()
);
mappings.addPropertyAnnotatedWithMapsIdSpecj(
entity,
specJPropertyData,
element.toString()
);
}
}
}
}
@ -2495,7 +2521,7 @@ public final class AnnotationBinder {
value.setColumns( columns );
value.setPersistentClassName( persistentClassName );
value.setMappings( mappings );
value.setType( inferredData.getProperty(), inferredData.getClassOrElement() );
value.setType( inferredData.getProperty(), inferredData.getClassOrElement(), persistentClassName );
value.setAccessType( propertyAccessor );
id = value.make();
}

View File

@ -44,10 +44,10 @@ public interface AvailableSettings {
public static final String SESSION_FACTORY_NAME_IS_JNDI = "hibernate.session_factory_name_is_jndi";
/**
* Names the {@link org.hibernate.service.jdbc.connections.spi.ConnectionProvider} to use for obtaining
* Names the {@link org.hibernate.engine.jdbc.connections.spi.ConnectionProvider} to use for obtaining
* JDBC connections. Can either reference an instance of
* {@link org.hibernate.service.jdbc.connections.spi.ConnectionProvider} or a {@link Class} or {@link String}
* reference to the {@link org.hibernate.service.jdbc.connections.spi.ConnectionProvider} implementation
* {@link org.hibernate.engine.jdbc.connections.spi.ConnectionProvider} or a {@link Class} or {@link String}
* reference to the {@link org.hibernate.engine.jdbc.connections.spi.ConnectionProvider} implementation
* class.
*/
public static final String CONNECTION_PROVIDER ="hibernate.connection.provider_class";
@ -64,7 +64,7 @@ public interface AvailableSettings {
/**
* Names the connection user. This might mean one of 2 things in out-of-the-box Hibernate
* {@link org.hibernate.service.jdbc.connections.spi.ConnectionProvider}: <ul>
* {@link org.hibernate.engine.jdbc.connections.spi.ConnectionProvider}: <ul>
* <li>The username used to pass along to creating the JDBC connection</li>
* <li>The username used to obtain a JDBC connection from a data source</li>
* </ul>
@ -129,8 +129,8 @@ public interface AvailableSettings {
public static final String DIALECT ="hibernate.dialect";
/**
* Names any additional {@link org.hibernate.service.jdbc.dialect.spi.DialectResolver} implementations to
* register with the standard {@link org.hibernate.service.jdbc.dialect.spi.DialectFactory}.
* Names any additional {@link org.hibernate.engine.jdbc.dialect.spi.DialectResolver} implementations to
* register with the standard {@link org.hibernate.engine.jdbc.dialect.spi.DialectFactory}.
*/
public static final String DIALECT_RESOLVERS = "hibernate.dialect_resolvers";
@ -275,30 +275,13 @@ public interface AvailableSettings {
public static final String TRANSACTION_STRATEGY = "hibernate.transaction.factory_class";
/**
* Names the {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation to use for integrating
* with {@literal JTA} systems. Can reference either a {@link org.hibernate.service.jta.platform.spi.JtaPlatform}
* instance or the name of the {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation class
* Names the {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation to use for integrating
* with {@literal JTA} systems. Can reference either a {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform}
* instance or the name of the {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation class
* @since 4.0
*/
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
*/
@ -570,9 +553,9 @@ public interface AvailableSettings {
public static final String MULTI_TENANT = "hibernate.multiTenancy";
/**
* Names a {@link org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider} implementation to
* Names a {@link org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider} implementation to
* use. As MultiTenantConnectionProvider is also a service, can be configured directly through the
* {@link org.hibernate.service.ServiceRegistryBuilder}
* {@link org.hibernate.boot.registry.StandardServiceRegistryBuilder}
*
* @since 4.1
*/

View File

@ -81,6 +81,7 @@ import org.hibernate.annotations.common.reflection.MetadataProviderInjector;
import org.hibernate.annotations.common.reflection.ReflectionManager;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.java.JavaReflectionManager;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.annotations.reflection.JPAMetadataProvider;
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.hibernate.dialect.Dialect;
@ -136,8 +137,7 @@ import org.hibernate.mapping.UniqueKey;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.secure.internal.JACCConfiguration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;
import org.hibernate.service.internal.StandardServiceRegistryImpl;
import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
import org.hibernate.tool.hbm2ddl.IndexMetadata;
import org.hibernate.tool.hbm2ddl.TableMetadata;
@ -163,7 +163,7 @@ import org.hibernate.usertype.UserType;
* A new <tt>Configuration</tt> will use the properties specified in
* <tt>hibernate.properties</tt> by default.
* <p/>
* NOTE : This will be replaced by use of {@link ServiceRegistryBuilder} and
* NOTE : This will be replaced by use of {@link org.hibernate.boot.registry.StandardServiceRegistryBuilder} and
* {@link org.hibernate.metamodel.MetadataSources} instead after the 4.0 release at which point this class will become
* deprecated and scheduled for removal in 5.0. See
* <a href="http://opensource.atlassian.com/projects/hibernate/browse/HHH-6183">HHH-6183</a>,
@ -1425,7 +1425,7 @@ public class Configuration implements Serializable {
if ( sp.isInPrimaryKey() ) {
String referenceEntityName = sp.getReferencedEntityName();
PersistentClass classMapping = getClassMapping( referenceEntityName );
String dependentTable = classMapping.getTable().getQuotedName();
String dependentTable = quotedTableName(classMapping.getTable());
if ( !isADependencyOf.containsKey( dependentTable ) ) {
isADependencyOf.put( dependentTable, new HashSet<FkSecondPass>() );
}
@ -1495,7 +1495,7 @@ public class Configuration implements Serializable {
}
for ( FkSecondPass sp : dependencies ) {
String dependentTable = sp.getValue().getTable().getQuotedName();
String dependentTable = quotedTableName(sp.getValue().getTable());
if ( dependentTable.compareTo( startTable ) == 0 ) {
StringBuilder sb = new StringBuilder(
"Foreign key circularity dependency involving the following tables: "
@ -1509,6 +1509,10 @@ public class Configuration implements Serializable {
}
}
private String quotedTableName(Table table) {
return Table.qualify( table.getCatalog(), table.getQuotedSchema(), table.getQuotedName() );
}
private void processEndOfQueue(List<FkSecondPass> endOfQueueFkSecondPasses) {
/*
* If a second pass raises a recoverableException, queue it for next round
@ -1770,7 +1774,7 @@ public class Configuration implements Serializable {
public SessionFactory buildSessionFactory() throws HibernateException {
Environment.verifyProperties( properties );
ConfigurationHelper.resolvePlaceHolders( properties );
final ServiceRegistry serviceRegistry = new ServiceRegistryBuilder()
final ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()
.applySettings( properties )
.buildServiceRegistry();
setSessionFactoryObserver(

View File

@ -76,7 +76,7 @@ import org.hibernate.internal.util.config.ConfigurationHelper;
* </tr>
* <tr>
* <td><tt>hibernate.connection.provider_class</tt></td>
* <td>classname of <tt>org.hibernate.service.jdbc.connections.spi.ConnectionProvider</tt>
* <td>classname of <tt>ConnectionProvider</tt>
* subclass (if not specified hueristics are used)</td>
* </tr>
* <tr><td><tt>hibernate.connection.username</tt></td><td>database username</td></tr>

View File

@ -95,6 +95,7 @@ import org.hibernate.mapping.TypeDef;
import org.hibernate.mapping.UnionSubclass;
import org.hibernate.mapping.UniqueKey;
import org.hibernate.mapping.Value;
import org.hibernate.type.BasicType;
import org.hibernate.type.DiscriminatorType;
import org.hibernate.type.ForeignKeyDirection;
import org.hibernate.type.Type;
@ -1212,6 +1213,11 @@ public final class HbmBinder {
}
}
resolveAndBindTypeDef(simpleValue, mappings, typeName, parameters);
}
private static void resolveAndBindTypeDef(SimpleValue simpleValue,
Mappings mappings, String typeName, Properties parameters) {
TypeDef typeDef = mappings.getTypeDef( typeName );
if ( typeDef != null ) {
typeName = typeDef.getTypeClass();
@ -1221,6 +1227,19 @@ public final class HbmBinder {
allParameters.putAll( typeDef.getParameters() );
allParameters.putAll( parameters );
parameters = allParameters;
}else if (typeName!=null && !mappings.isInSecondPass()){
BasicType basicType=mappings.getTypeResolver().basic(typeName);
if (basicType==null) {
/*
* If the referenced typeName isn't a basic-type, it's probably a typedef defined
* in a mapping file not read yet.
* It should be solved by deferring the resolution and binding of this type until
* all mapping files are read - the second passes.
* Fixes issue HHH-7300
*/
SecondPass resolveUserTypeMappingSecondPass=new ResolveUserTypeMappingSecondPass(simpleValue,typeName,mappings,parameters);
mappings.addSecondPass(resolveUserTypeMappingSecondPass);
}
}
if ( !parameters.isEmpty() ) simpleValue.setTypeParameters( parameters );
@ -3148,4 +3167,27 @@ public final class HbmBinder {
private static interface EntityElementHandler {
public void handleEntity(String entityName, String className, Mappings mappings);
}
private static class ResolveUserTypeMappingSecondPass implements SecondPass{
private SimpleValue simpleValue;
private String typeName;
private Mappings mappings;
private Properties parameters;
public ResolveUserTypeMappingSecondPass(SimpleValue simpleValue,
String typeName, Mappings mappings, Properties parameters) {
this.simpleValue=simpleValue;
this.typeName=typeName;
this.parameters=parameters;
this.mappings=mappings;
}
@Override
public void doSecondPass(java.util.Map persistentClasses)
throws MappingException {
resolveAndBindTypeDef(simpleValue, mappings, typeName, parameters);
}
}
}

View File

@ -30,7 +30,7 @@ import org.hibernate.EntityMode;
import org.hibernate.MultiTenancyStrategy;
import org.hibernate.cache.spi.QueryCacheFactory;
import org.hibernate.hql.spi.QueryTranslatorFactory;
import org.hibernate.service.jta.platform.spi.JtaPlatform;
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.tuple.entity.EntityTuplizerFactory;
/**

View File

@ -45,11 +45,11 @@ import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider;
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.service.jdbc.env.spi.ExtractedDatabaseMetaData;
import org.hibernate.service.jta.platform.spi.JtaPlatform;
import org.hibernate.tuple.entity.EntityTuplizerFactory;
/**

View File

@ -1316,7 +1316,7 @@ public abstract class CollectionBinder {
column.setTable( collValue.getCollectionTable() );
}
elementBinder.setColumns( elementColumns );
elementBinder.setType( property, elementClass );
elementBinder.setType( property, elementClass, collValue.getOwnerEntityName() );
elementBinder.setPersistentClassName( propertyHolder.getEntityName() );
elementBinder.setAccessType( accessType );
collValue.setElement( elementBinder.make() );

View File

@ -282,7 +282,7 @@ public class MapBinder extends CollectionBinder {
elementBinder.setExplicitType( mapKeyTypeAnnotation.value() );
}
else {
elementBinder.setType( property, elementClass );
elementBinder.setType( property, elementClass, this.collection.getOwnerEntityName() );
}
elementBinder.setPersistentClassName( propertyHolder.getEntityName() );
elementBinder.setAccessType( accessType );

View File

@ -185,7 +185,7 @@ public class PropertyBinder {
simpleValueBinder.setReturnedClassName( returnedClassName );
simpleValueBinder.setColumns( columns );
simpleValueBinder.setPersistentClassName( containerClassName );
simpleValueBinder.setType( property, returnedClass );
simpleValueBinder.setType( property, returnedClass, containerClassName );
simpleValueBinder.setMappings( mappings );
simpleValueBinder.setReferencedEntityName( referencedEntityName );
simpleValueBinder.setAccessType( accessType );

View File

@ -142,10 +142,11 @@ public class SimpleValueBinder {
//TODO execute it lazily to be order safe
public void setType(XProperty property, XClass returnedClass) {
public void setType(XProperty property, XClass returnedClass, String declaringClassName) {
if ( returnedClass == null ) {
// we cannot guess anything
return;
} //we cannot guess anything
}
XClass returnedClassOrElement = returnedClass;
boolean isArray = false;
if ( property.isArray() ) {
@ -239,6 +240,17 @@ public class SimpleValueBinder {
}
else if ( ( !key && property.isAnnotationPresent( Enumerated.class ) )
|| ( key && property.isAnnotationPresent( MapKeyEnumerated.class ) ) ) {
final Class attributeJavaType = mappings.getReflectionManager().toClass( returnedClassOrElement );
if ( !Enum.class.isAssignableFrom( attributeJavaType ) ) {
throw new AnnotationException(
String.format(
"Attribute [%s.%s] was annotated as enumerated, but its java type is not an enum [%s]",
declaringClassName,
xproperty.getName(),
attributeJavaType.getName()
)
);
}
type = EnumType.class.getName();
explicitType = type;
}
@ -629,4 +641,4 @@ public class SimpleValueBinder {
public void setAccessType(AccessType accessType) {
this.accessType = accessType;
}
}
}

View File

@ -41,8 +41,8 @@ import org.hibernate.event.service.spi.EventListenerRegistry;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
/**

View File

@ -44,6 +44,8 @@ import org.jboss.logging.Logger;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.cfg.beanvalidation.ddl.DigitsSchemaConstraint;
import org.hibernate.cfg.beanvalidation.ddl.LengthSchemaConstraint;
import org.hibernate.cfg.beanvalidation.ddl.MaxSchemaConstraint;
@ -63,8 +65,6 @@ import org.hibernate.metamodel.spi.binding.AttributeBinding;
import org.hibernate.metamodel.spi.binding.BasicAttributeBinding;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.binding.EntityIdentifier;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.classloading.spi.ClassLoadingException;
/**
* @author Emmanuel Bernard

View File

@ -271,14 +271,35 @@ public class PersistentMap extends AbstractPersistentCollection implements Map {
return map.toString();
}
public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
throws HibernateException, SQLException {
Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
Object index = persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() );
if ( element!=null ) map.put(index, element);
private transient List<Object[]> loadingEntries;
public Object readFrom(
ResultSet rs,
CollectionPersister persister,
CollectionAliases descriptor,
Object owner) throws HibernateException, SQLException {
final Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
if ( element != null ) {
final Object index = persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() );
if ( loadingEntries == null ) {
loadingEntries = new ArrayList<Object[]>();
}
loadingEntries.add( new Object[] { index, element } );
}
return element;
}
@Override
@SuppressWarnings("unchecked")
public boolean endRead() {
if ( loadingEntries != null ) {
for ( Object[] entry : loadingEntries ) {
map.put( entry[0], entry[1] );
}
}
return super.endRead();
}
public Iterator entries(CollectionPersister persister) {
return map.entrySet().iterator();
}

View File

@ -39,7 +39,7 @@ import org.hibernate.context.spi.CurrentSessionContext;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.service.jta.platform.spi.JtaPlatform;
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
/**
* An implementation of {@link CurrentSessionContext} which scopes the notion

View File

@ -71,4 +71,7 @@ public class DB2400Dialect extends DB2Dialect {
.toString();
}
public String getForUpdateString() {
return " for update with rs";
}
}

View File

@ -56,7 +56,9 @@ public class DerbyDialect extends DB2Dialect {
public DerbyDialect() {
super();
LOG.deprecatedDerbyDialect();
if (this.getClass() == DerbyDialect.class) {
LOG.deprecatedDerbyDialect();
}
registerFunction( "concat", new DerbyConcatFunction() );
registerFunction( "trim", new AnsiTrimFunction() );
registerColumnType( Types.BLOB, "blob" );

View File

@ -2409,4 +2409,14 @@ public abstract class Dialect implements ConversionContext {
// oddly most database in fact seem to, so true is the default.
return true;
}
/**
* Return the limit that the underlying database places on the number elements in an {@code IN} predicate.
* If the database defines no such limits, simply return zero or less-than-zero.
*
* @return int The limit, or zero-or-less to indicate no limit.
*/
public int getInExpressionCountLimit() {
return 0;
}
}

View File

@ -58,6 +58,8 @@ import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
* @author Steve Ebersole
*/
public class Oracle8iDialect extends Dialect {
private static final int PARAM_LIST_SIZE_LIMIT = 1000;
public Oracle8iDialect() {
super();
@ -551,15 +553,22 @@ public class Oracle8iDialect extends Dialect {
return false;
}
// Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@Override
public boolean supportsEmptyInList() {
return false;
}
@Override
public boolean supportsExistsInSelect() {
return false;
}
/* (non-Javadoc)
* @see org.hibernate.dialect.Dialect#getInExpressionCountLimit()
*/
@Override
public int getInExpressionCountLimit() {
return PARAM_LIST_SIZE_LIMIT;
}
}

View File

@ -52,6 +52,8 @@ import org.hibernate.type.StandardBasicTypes;
*/
@Deprecated
public class Oracle9Dialect extends Dialect {
private static final int PARAM_LIST_SIZE_LIMIT = 1000;
private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, Oracle9Dialect.class.getName());
@ -360,9 +362,6 @@ public class Oracle9Dialect extends Dialect {
return false;
}
// Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public boolean supportsEmptyInList() {
return false;
}
@ -370,4 +369,12 @@ public class Oracle9Dialect extends Dialect {
public boolean supportsExistsInSelect() {
return false;
}
/* (non-Javadoc)
* @see org.hibernate.dialect.Dialect#getInExpressionCountLimit()
*/
@Override
public int getInExpressionCountLimit() {
return PARAM_LIST_SIZE_LIMIT;
}
}

View File

@ -39,6 +39,8 @@ import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
* @author Gavin King
*/
public class SQLServerDialect extends AbstractTransactSQLDialect {
private static final int PARAM_LIST_SIZE_LIMIT = 2100;
public SQLServerDialect() {
registerColumnType( Types.VARBINARY, "image" );
@ -188,5 +190,13 @@ public class SQLServerDialect extends AbstractTransactSQLDialect {
protected SqlTypeDescriptor getSqlTypeDescriptorOverride( int sqlCode ) {
return sqlCode == Types.TINYINT ? SmallIntTypeDescriptor.INSTANCE : super.getSqlTypeDescriptorOverride(sqlCode);
}
/* (non-Javadoc)
* @see org.hibernate.dialect.Dialect#getInExpressionCountLimit()
*/
@Override
public int getInExpressionCountLimit() {
return PARAM_LIST_SIZE_LIMIT;
}
}

View File

@ -29,7 +29,7 @@ import org.hibernate.sql.Sybase11JoinFragment;
* A SQL dialect suitable for use with Sybase 11.9.2 (specifically: avoids ANSI JOIN syntax)
* @author Colm O' Flaherty
*/
public class Sybase11Dialect extends AbstractTransactSQLDialect {
public class Sybase11Dialect extends SybaseDialect {
public Sybase11Dialect() {
super();
}

View File

@ -40,7 +40,7 @@ import org.hibernate.type.descriptor.sql.TinyIntTypeDescriptor;
*
* @author Gavin King
*/
public class SybaseASE15Dialect extends AbstractTransactSQLDialect {
public class SybaseASE15Dialect extends SybaseDialect {
public SybaseASE15Dialect() {
super();

View File

@ -30,7 +30,7 @@ package org.hibernate.dialect;
* (Tested on ASA 8.x)
* @author ?
*/
public class SybaseAnywhereDialect extends AbstractTransactSQLDialect {
public class SybaseAnywhereDialect extends SybaseDialect {
/**
* Sybase Anywhere syntax would require a "DEFAULT" for each column specified,
* but I suppose Hibernate use this syntax only with tables with just 1 column

View File

@ -25,16 +25,19 @@ package org.hibernate.dialect;
/**
* This dialect is being deprecated; it had been used both as the base class
* for TransactSQL-based dialects as well as the physical dialect for handling
* Sybase. Those functions have now been split.
* {@link AbstractTransactSQLDialect} should be used as the base class for
* TransactSQL-based dialects.
* All Sybase dialects share an IN list size limit.
*
* @deprecated use {@link AbstractTransactSQLDialect}, {@link SybaseASE15Dialect} or {@link SQLServerDialect}
* instead depending on need.
*
* @author Gail Badner
* @author Brett Meyer
*/
public class SybaseDialect extends AbstractTransactSQLDialect {
private static final int PARAM_LIST_SIZE_LIMIT = 250000;
/* (non-Javadoc)
* @see org.hibernate.dialect.Dialect#getInExpressionCountLimit()
*/
@Override
public int getInExpressionCountLimit() {
return PARAM_LIST_SIZE_LIMIT;
}
}

View File

@ -37,6 +37,8 @@ import org.hibernate.type.StandardBasicTypes;
* @author Jay Nance
*/
public class TeradataDialect extends Dialect {
private static final int PARAM_LIST_SIZE_LIMIT = 1024;
/**
* Constructor
@ -256,4 +258,12 @@ public class TeradataDialect extends Dialect {
public boolean supportsBindAsCallableArgument() {
return false;
}
/* (non-Javadoc)
* @see org.hibernate.dialect.Dialect#getInExpressionCountLimit()
*/
@Override
public int getInExpressionCountLimit() {
return PARAM_LIST_SIZE_LIMIT;
}
}

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.config.internal;
package org.hibernate.engine.config.internal;
import java.util.Collections;
import java.util.Map;
@ -29,9 +29,9 @@ import java.util.Map;
import org.jboss.logging.Logger;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.classloading.spi.ClassLoadingException;
import org.hibernate.service.config.spi.ConfigurationService;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.service.spi.ServiceRegistryAwareService;
import org.hibernate.service.spi.ServiceRegistryImplementor;

View File

@ -21,18 +21,18 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.config.internal;
package org.hibernate.engine.config.internal;
import java.util.Map;
import org.hibernate.service.config.spi.ConfigurationService;
import org.hibernate.service.spi.BasicServiceInitiator;
import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
* @author Steve Ebersole
*/
public class ConfigurationServiceInitiator implements BasicServiceInitiator<ConfigurationService> {
public class ConfigurationServiceInitiator implements StandardServiceInitiator<ConfigurationService> {
public static final ConfigurationServiceInitiator INSTANCE = new ConfigurationServiceInitiator();
public ConfigurationService initiateService(Map configurationValues, ServiceRegistryImplementor registry) {

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.config.spi;
package org.hibernate.engine.config.spi;
import java.util.Map;

View File

@ -135,19 +135,7 @@ public abstract class AbstractBatchImpl implements Batch {
}
private PreparedStatement buildBatchStatement(String sql, boolean callable) {
sql = jdbcCoordinator.getTransactionCoordinator().getTransactionContext().onPrepareStatement( sql );
try {
if ( callable ) {
return jdbcCoordinator.getLogicalConnection().getShareableConnectionProxy().prepareCall( sql );
}
else {
return jdbcCoordinator.getLogicalConnection().getShareableConnectionProxy().prepareStatement( sql );
}
}
catch ( SQLException sqle ) {
LOG.sqlExceptionEscapedProxy( sqle );
throw sqlExceptionHelper().convert( sqle, "could not prepare batch statement", sql );
}
return jdbcCoordinator.getStatementPreparer().prepareStatement( sql, callable );
}
@Override

View File

@ -25,11 +25,11 @@ package org.hibernate.engine.jdbc.batch.internal;
import java.util.Map;
import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.cfg.Environment;
import org.hibernate.engine.jdbc.batch.spi.BatchBuilder;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.spi.BasicServiceInitiator;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.service.spi.ServiceException;
import org.hibernate.service.spi.ServiceRegistryImplementor;
@ -38,7 +38,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor;
*
* @author Steve Ebersole
*/
public class BatchBuilderInitiator implements BasicServiceInitiator<BatchBuilder> {
public class BatchBuilderInitiator implements StandardServiceInitiator<BatchBuilder> {
public static final BatchBuilderInitiator INSTANCE = new BatchBuilderInitiator();
public static final String BUILDER = "hibernate.jdbc.batch.builder";

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.connections.internal;
package org.hibernate.engine.jdbc.connections.internal;
import java.beans.BeanInfo;
import java.beans.PropertyDescriptor;
@ -36,13 +36,13 @@ import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
import org.hibernate.MultiTenancyStrategy;
import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Environment;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.beans.BeanInfoHelper;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.spi.BasicServiceInitiator;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
@ -51,7 +51,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor;
* @author Gavin King
* @author Steve Ebersole
*/
public class ConnectionProviderInitiator implements BasicServiceInitiator<ConnectionProvider> {
public class ConnectionProviderInitiator implements StandardServiceInitiator<ConnectionProvider> {
public static final ConnectionProviderInitiator INSTANCE = new ConnectionProviderInitiator();
private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class,

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.connections.internal;
package org.hibernate.engine.jdbc.connections.internal;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Map;
@ -29,15 +29,15 @@ import javax.sql.DataSource;
import org.hibernate.HibernateException;
import org.hibernate.cfg.Environment;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.UnknownUnwrapTypeException;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.jndi.spi.JndiService;
import org.hibernate.engine.jndi.spi.JndiService;
import org.hibernate.service.spi.Configurable;
import org.hibernate.service.spi.InjectService;
import org.hibernate.service.spi.Stoppable;
/**
* A {@link ConnectionProvider} that manages connections from an underlying {@link DataSource}.
* A {@link org.hibernate.engine.jdbc.connections.spi.ConnectionProvider} that manages connections from an underlying {@link DataSource}.
* <p/>
* The {@link DataSource} to use may be specified by either:<ul>
* <li>injection via {@link #setDataSource}</li>

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.connections.internal;
package org.hibernate.engine.jdbc.connections.internal;
import java.sql.Connection;
import java.sql.DriverManager;
@ -35,13 +35,13 @@ import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Environment;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.UnknownUnwrapTypeException;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.classloading.spi.ClassLoadingException;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.service.spi.Configurable;
import org.hibernate.service.spi.ServiceRegistryAwareService;
import org.hibernate.service.spi.ServiceRegistryImplementor;

View File

@ -21,26 +21,26 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.connections.internal;
package org.hibernate.engine.jdbc.connections.internal;
import java.util.Map;
import org.jboss.logging.Logger;
import org.hibernate.MultiTenancyStrategy;
import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.classloading.spi.ClassLoadingException;
import org.hibernate.service.jdbc.connections.spi.DataSourceBasedMultiTenantConnectionProviderImpl;
import org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider;
import org.hibernate.service.spi.BasicServiceInitiator;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.engine.jdbc.connections.spi.DataSourceBasedMultiTenantConnectionProviderImpl;
import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider;
import org.hibernate.service.spi.ServiceException;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
* @author Steve Ebersole
*/
public class MultiTenantConnectionProviderInitiator implements BasicServiceInitiator<MultiTenantConnectionProvider> {
public class MultiTenantConnectionProviderInitiator implements StandardServiceInitiator<MultiTenantConnectionProvider> {
public static final MultiTenantConnectionProviderInitiator INSTANCE = new MultiTenantConnectionProviderInitiator();
private static final Logger log = Logger.getLogger( MultiTenantConnectionProviderInitiator.class );
@ -60,7 +60,7 @@ public class MultiTenantConnectionProviderInitiator implements BasicServiceIniti
final Object configValue = configurationValues.get( AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER );
if ( configValue == null ) {
// if they also specified the data source *name*, then lets assume they want
// org.hibernate.service.jdbc.connections.spi.DataSourceBasedMultiTenantConnectionProviderImpl
// DataSourceBasedMultiTenantConnectionProviderImpl
final Object dataSourceConfigValue = configurationValues.get( AvailableSettings.DATASOURCE );
if ( dataSourceConfigValue != null && String.class.isInstance( dataSourceConfigValue ) ) {
return new DataSourceBasedMultiTenantConnectionProviderImpl();

View File

@ -21,13 +21,14 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.connections.internal;
package org.hibernate.engine.jdbc.connections.internal;
import java.sql.Connection;
import java.sql.SQLException;
import org.hibernate.service.UnknownUnwrapTypeException;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.jdbc.connections.internal.UserSuppliedConnectionException;
/**
* An implementation of the {@link ConnectionProvider} interface that simply throws an exception when a connection

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.connections.spi;
package org.hibernate.engine.jdbc.connections.spi;
import java.sql.Connection;
import java.sql.SQLException;

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.connections.spi;
package org.hibernate.engine.jdbc.connections.spi;
import java.sql.Connection;
import java.sql.SQLException;

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.connections.spi;
package org.hibernate.engine.jdbc.connections.spi;
import java.sql.Connection;
import java.sql.SQLException;

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.connections.spi;
package org.hibernate.engine.jdbc.connections.spi;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ -30,8 +30,8 @@ import javax.sql.DataSource;
import org.hibernate.HibernateException;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.service.config.spi.ConfigurationService;
import org.hibernate.service.jndi.spi.JndiService;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.jndi.spi.JndiService;
import org.hibernate.service.spi.ServiceRegistryAwareService;
import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.service.spi.Stoppable;

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.connections.spi;
package org.hibernate.engine.jdbc.connections.spi;
import java.sql.Connection;
import java.sql.SQLException;

View File

@ -21,18 +21,18 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.cursor.internal;
package org.hibernate.engine.jdbc.cursor.internal;
import java.util.Map;
import org.hibernate.service.jdbc.cursor.spi.RefCursorSupport;
import org.hibernate.service.spi.BasicServiceInitiator;
import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.engine.jdbc.cursor.spi.RefCursorSupport;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
* @author Steve Ebersole
*/
public class RefCursorSupportInitiator implements BasicServiceInitiator<RefCursorSupport> {
public class RefCursorSupportInitiator implements StandardServiceInitiator<RefCursorSupport> {
public static final RefCursorSupportInitiator INSTANCE = new RefCursorSupportInitiator();
@Override

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.cursor.internal;
package org.hibernate.engine.jdbc.cursor.internal;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@ -35,7 +35,7 @@ import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.service.jdbc.cursor.spi.RefCursorSupport;
import org.hibernate.engine.jdbc.cursor.spi.RefCursorSupport;
import org.hibernate.service.spi.InjectService;
/**

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.cursor.spi;
package org.hibernate.engine.jdbc.cursor.spi;
import java.sql.CallableStatement;
import java.sql.ResultSet;

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.dialect.internal;
package org.hibernate.engine.jdbc.dialect.internal;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
@ -33,7 +33,7 @@ import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.resolver.BasicSQLExceptionConverter;
import org.hibernate.exception.JDBCConnectionException;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.service.jdbc.dialect.spi.DialectResolver;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
/**
* A templated resolver impl which delegates to the {@link #resolveDialectInternal} method

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.dialect.internal;
package org.hibernate.engine.jdbc.dialect.internal;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.dialect.internal;
package org.hibernate.engine.jdbc.dialect.internal;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
@ -29,12 +29,11 @@ import java.sql.SQLException;
import java.util.Map;
import org.hibernate.HibernateException;
import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.Dialect;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.classloading.spi.ClassLoadingException;
import org.hibernate.service.jdbc.dialect.spi.DialectFactory;
import org.hibernate.service.jdbc.dialect.spi.DialectResolver;
import org.hibernate.engine.jdbc.dialect.spi.DialectFactory;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
import org.hibernate.service.spi.InjectService;
/**
@ -43,11 +42,11 @@ import org.hibernate.service.spi.InjectService;
* @author Steve Ebersole
*/
public class DialectFactoryImpl implements DialectFactory {
private ClassLoaderService classLoaderService;
private StrategySelector strategySelector;
@InjectService
public void setClassLoaderService(ClassLoaderService classLoaderService) {
this.classLoaderService = classLoaderService;
public void setStrategySelector(StrategySelector strategySelector) {
this.strategySelector = strategySelector;
}
private DialectResolver dialectResolver;
@ -69,17 +68,19 @@ public class DialectFactoryImpl implements DialectFactory {
}
private Dialect constructDialect(String dialectName) {
final Dialect dialect;
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+ "]" );
}
return dialect;
}
catch ( ClassLoadingException e ) {
throw new HibernateException( "Dialect class not found: " + dialectName, e );
}
catch ( HibernateException e ) {
catch (HibernateException e) {
throw e;
}
catch ( Exception e ) {
throw new HibernateException( "Could not instantiate dialect class", e );
catch (Exception e) {
throw new HibernateException( "Unable to construct requested dialect [" + dialectName+ "]", e );
}
}

View File

@ -21,12 +21,12 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.dialect.internal;
package org.hibernate.engine.jdbc.dialect.internal;
import java.util.Map;
import org.hibernate.service.jdbc.dialect.spi.DialectFactory;
import org.hibernate.service.spi.BasicServiceInitiator;
import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.engine.jdbc.dialect.spi.DialectFactory;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
@ -34,7 +34,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor;
*
* @author Steve Ebersole
*/
public class DialectFactoryInitiator implements BasicServiceInitiator<DialectFactory> {
public class DialectFactoryInitiator implements StandardServiceInitiator<DialectFactory> {
public static final DialectFactoryInitiator INSTANCE = new DialectFactoryInitiator();
@Override

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.dialect.internal;
package org.hibernate.engine.jdbc.dialect.internal;
import java.util.ArrayList;
import java.util.List;
@ -30,9 +30,9 @@ import java.util.Map;
import org.hibernate.HibernateException;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.jdbc.dialect.spi.DialectResolver;
import org.hibernate.service.spi.BasicServiceInitiator;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.service.spi.ServiceException;
import org.hibernate.service.spi.ServiceRegistryImplementor;
@ -41,7 +41,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor;
*
* @author Steve Ebersole
*/
public class DialectResolverInitiator implements BasicServiceInitiator<DialectResolver> {
public class DialectResolverInitiator implements StandardServiceInitiator<DialectResolver> {
public static final DialectResolverInitiator INSTANCE = new DialectResolverInitiator();
@Override

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.dialect.internal;
package org.hibernate.engine.jdbc.dialect.internal;
import java.sql.DatabaseMetaData;
import java.util.ArrayList;
@ -33,7 +33,7 @@ import org.jboss.logging.Logger;
import org.hibernate.dialect.Dialect;
import org.hibernate.exception.JDBCConnectionException;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.service.jdbc.dialect.spi.DialectResolver;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
/**
* A {@link DialectResolver} implementation which coordinates resolution by delegating to sub-resolvers.

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.dialect.internal;
package org.hibernate.engine.jdbc.dialect.internal;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.dialect.spi;
package org.hibernate.engine.jdbc.dialect.spi;
import java.sql.Connection;
import java.util.Map;

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.dialect.spi;
package org.hibernate.engine.jdbc.dialect.spi;
import java.sql.DatabaseMetaData;

View File

@ -29,12 +29,12 @@ import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.LobCreationContext;
import org.hibernate.engine.jdbc.LobCreator;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.jdbc.spi.ResultSetWrapper;
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.jdbc.env.spi.ExtractedDatabaseMetaData;
import org.hibernate.service.jdbc.env.spi.JdbcEnvironment;
import org.hibernate.service.spi.Configurable;
@ -50,9 +50,10 @@ public class JdbcServicesImpl implements JdbcServices, ServiceRegistryAwareServi
private ServiceRegistryImplementor serviceRegistry;
private JdbcEnvironment jdbcEnvironment;
private ConnectionProvider connectionProvider;
private SqlStatementLogger sqlStatementLogger;
private ConnectionProvider connectionProvider;
@Override
public void injectServices(ServiceRegistryImplementor serviceRegistry) {
this.serviceRegistry = serviceRegistry;

View File

@ -25,8 +25,8 @@ package org.hibernate.engine.jdbc.internal;
import java.util.Map;
import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.service.spi.BasicServiceInitiator;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
@ -36,7 +36,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor;
*
* @author Steve Ebersole
*/
public class JdbcServicesInitiator implements BasicServiceInitiator<JdbcServices> {
public class JdbcServicesInitiator implements StandardServiceInitiator<JdbcServices> {
public static final JdbcServicesInitiator INSTANCE = new JdbcServicesInitiator();
@Override

View File

@ -29,7 +29,7 @@ import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.LobCreationContext;
import org.hibernate.engine.jdbc.LobCreator;
import org.hibernate.service.Service;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.jdbc.env.spi.ExtractedDatabaseMetaData;
import org.hibernate.service.jdbc.env.spi.JdbcEnvironment;

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jndi;
package org.hibernate.engine.jndi;
import org.hibernate.HibernateException;
/**

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jndi;
package org.hibernate.engine.jndi;
import org.hibernate.HibernateException;

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jndi.internal;
package org.hibernate.engine.jndi.internal;
import java.util.Hashtable;
import java.util.Map;
@ -38,9 +38,9 @@ import org.jboss.logging.Logger;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.jndi.JndiHelper;
import org.hibernate.service.jndi.JndiException;
import org.hibernate.service.jndi.JndiNameException;
import org.hibernate.service.jndi.spi.JndiService;
import org.hibernate.engine.jndi.JndiException;
import org.hibernate.engine.jndi.JndiNameException;
import org.hibernate.engine.jndi.spi.JndiService;
/**
* Standard implementation of JNDI services.

View File

@ -21,12 +21,12 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jndi.internal;
package org.hibernate.engine.jndi.internal;
import java.util.Map;
import org.hibernate.service.jndi.spi.JndiService;
import org.hibernate.service.spi.BasicServiceInitiator;
import org.hibernate.engine.jndi.spi.JndiService;
import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
@ -34,7 +34,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor;
*
* @author Steve Ebersole
*/
public class JndiServiceInitiator implements BasicServiceInitiator<JndiService> {
public class JndiServiceInitiator implements StandardServiceInitiator<JndiService> {
public static final JndiServiceInitiator INSTANCE = new JndiServiceInitiator();
@Override

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jndi.spi;
package org.hibernate.engine.jndi.spi;
import javax.naming.event.NamespaceChangeListener;

View File

@ -52,7 +52,7 @@ import org.hibernate.id.IdentifierGenerator;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.stat.spi.StatisticsImplementor;
import org.hibernate.type.Type;

View File

@ -51,7 +51,7 @@ import org.hibernate.engine.transaction.synchronization.internal.Synchronization
import org.hibernate.engine.transaction.synchronization.spi.SynchronizationCallbackCoordinator;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.service.jta.platform.spi.JtaPlatform;
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
/**
* Standard implementation of the Hibernate {@link TransactionCoordinator}

View File

@ -27,17 +27,13 @@ import java.util.Map;
import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
import org.hibernate.cfg.Environment;
import org.hibernate.cfg.AvailableSettings;
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.engine.transaction.spi.TransactionImplementor;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.classloading.spi.ClassLoadingException;
import org.hibernate.service.spi.BasicServiceInitiator;
import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
@ -46,7 +42,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor;
* @author Steve Ebersole
*/
public class TransactionFactoryInitiator<T extends TransactionImplementor>
implements BasicServiceInitiator<TransactionFactory> {
implements StandardServiceInitiator<TransactionFactory> {
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
CoreMessageLogger.class,
@ -64,86 +60,14 @@ public class TransactionFactoryInitiator<T extends TransactionImplementor>
@Override
@SuppressWarnings( {"unchecked"})
public TransactionFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
final Object strategy = configurationValues.get( Environment.TRANSACTION_STRATEGY );
final Object strategy = configurationValues.get( AvailableSettings.TRANSACTION_STRATEGY );
if ( strategy == null ) {
LOG.usingDefaultTransactionStrategy();
return new JdbcTransactionFactory();
}
if ( TransactionFactory.class.isInstance( strategy ) ) {
return (TransactionFactory) strategy;
}
Class<? extends TransactionFactory> transactionFactoryClass;
if ( Class.class.isInstance( strategy ) ) {
final Class theClass = (Class) strategy;
LOG.transactionStrategy( theClass.getName() );
try {
transactionFactoryClass = (Class<? extends TransactionFactory>) theClass;
}
catch (ClassCastException e) {
throw new ClassLoadingException(
String.format(
"TransactionFactory implementation class [%s] did not implement TransactionFactory interface",
theClass.getName()
)
);
}
}
else {
final String strategyClassName = mapName( strategy.toString() );
LOG.transactionStrategy( strategyClassName );
try {
transactionFactoryClass = registry.getService( ClassLoaderService.class ).classForName( strategyClassName );
}
catch (ClassCastException e) {
throw new ClassLoadingException(
String.format(
"TransactionFactory implementation class [%s] did not implement TransactionFactory interface",
strategyClassName
)
);
}
}
try {
return transactionFactoryClass.newInstance();
}
catch ( Exception e ) {
throw new HibernateException( "Unable to instantiate specified TransactionFactory class [" + transactionFactoryClass.getName() + "]", e );
}
}
private String mapName(String name) {
// check legacy names ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if ( "org.hibernate.transaction.JDBCTransactionFactory".equals( name ) ) {
return JdbcTransactionFactory.class.getName();
}
if ( "org.hibernate.transaction.JTATransactionFactory".equals( name ) ) {
return JtaTransactionFactory.class.getName();
}
if ( "org.hibernate.transaction.CMTTransactionFactory".equals( name ) ) {
return CMTTransactionFactory.class.getName();
}
// check short names ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if ( JdbcTransactionFactory.SHORT_NAME.endsWith( name ) ) {
return JdbcTransactionFactory.class.getName();
}
if ( JtaTransactionFactory.SHORT_NAME.equals( name ) ) {
return JtaTransactionFactory.class.getName();
}
if ( CMTTransactionFactory.SHORT_NAME.equals( name ) ) {
return CMTTransactionFactory.class.getName();
}
return name;
return registry.getService( StrategySelector.class ).resolveStrategy( TransactionFactory.class, strategy );
}
}

View File

@ -30,7 +30,7 @@ import org.hibernate.ConnectionReleaseMode;
import org.hibernate.TransactionException;
import org.hibernate.engine.transaction.spi.TransactionCoordinator;
import org.hibernate.engine.transaction.spi.TransactionFactory;
import org.hibernate.service.jta.platform.spi.JtaPlatform;
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
/**
* Factory for {@link JtaTransaction} instances.

Some files were not shown because too many files have changed in this diff Show More