HHH-11152 - Byte Buddy BytecodeProvider

This commit is contained in:
Steve Ebersole 2016-11-16 13:46:24 -06:00
parent ba3359fe62
commit 2e49586adc
3 changed files with 21 additions and 10 deletions

View File

@ -23,7 +23,8 @@ configurations {
dependencies { dependencies {
compile( libraries.jpa ) compile( libraries.jpa )
compile( libraries.javassist ) compile( libraries.javassist )
compile( libraries.byteBuddy ) // provided until 6.0 when we make it the default and drop Javassist support
provided( libraries.byteBuddy )
compile( libraries.antlr ) compile( libraries.antlr )
compile( libraries.jta ) compile( libraries.jta )
compile( libraries.jandex ) compile( libraries.jandex )

View File

@ -151,7 +151,7 @@ import org.jboss.logging.Logger;
* @author Gavin King * @author Gavin King
*/ */
public final class Environment implements AvailableSettings { public final class Environment implements AvailableSettings {
private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, Environment.class.getName()); private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, Environment.class.getName());
private static final BytecodeProvider BYTECODE_PROVIDER_INSTANCE; private static final BytecodeProvider BYTECODE_PROVIDER_INSTANCE;
private static final boolean ENABLE_BINARY_STREAMS; private static final boolean ENABLE_BINARY_STREAMS;
@ -313,21 +313,31 @@ public final class Environment implements AvailableSettings {
return ConnectionProviderInitiator.toIsolationNiceName( isolation ); return ConnectionProviderInitiator.toIsolationNiceName( isolation );
} }
public static final String BYTECODE_PROVIDER_NAME_JAVASSIST = "javassist";
public static final String BYTECODE_PROVIDER_NAME_BYTEBUDDY = "bytebuddy";
public static final String BYTECODE_PROVIDER_NAME_DEFAULT = BYTECODE_PROVIDER_NAME_JAVASSIST;
public static BytecodeProvider buildBytecodeProvider(Properties properties) { public static BytecodeProvider buildBytecodeProvider(Properties properties) {
String provider = ConfigurationHelper.getString( BYTECODE_PROVIDER, properties, "bytebuddy" ); String provider = ConfigurationHelper.getString( BYTECODE_PROVIDER, properties, BYTECODE_PROVIDER_NAME_DEFAULT );
LOG.bytecodeProvider( provider );
return buildBytecodeProvider( provider ); return buildBytecodeProvider( provider );
} }
private static BytecodeProvider buildBytecodeProvider(String providerName) { private static BytecodeProvider buildBytecodeProvider(String providerName) {
if ( "bytebuddy".equals( providerName ) ) { if ( BYTECODE_PROVIDER_NAME_BYTEBUDDY.equals( providerName ) ) {
return new org.hibernate.bytecode.internal.bytebuddy.BytecodeProviderImpl(); return new org.hibernate.bytecode.internal.bytebuddy.BytecodeProviderImpl();
} }
if ( "javassist".equals( providerName ) ) {
if ( BYTECODE_PROVIDER_NAME_JAVASSIST.equals( providerName ) ) {
return new org.hibernate.bytecode.internal.javassist.BytecodeProviderImpl(); return new org.hibernate.bytecode.internal.javassist.BytecodeProviderImpl();
} }
LOG.unknownBytecodeProvider( providerName ); LOG.bytecodeProvider( providerName );
return new org.hibernate.bytecode.internal.bytebuddy.BytecodeProviderImpl();
// todo : allow a custom class name - just check if the config is a FQN
// currently we assume it is only ever the Strings "javassist" or "bytebuddy"...
LOG.unknownBytecodeProvider( providerName, BYTECODE_PROVIDER_NAME_DEFAULT );
return new org.hibernate.bytecode.internal.javassist.BytecodeProviderImpl();
} }
} }

View File

@ -1327,8 +1327,8 @@ public interface CoreMessageLogger extends BasicLogger {
void unexpectedRowCounts(); void unexpectedRowCounts();
@LogMessage(level = WARN) @LogMessage(level = WARN)
@Message(value = "unrecognized bytecode provider [%s], using 'bytebuddy' by default", id = 382) @Message(value = "unrecognized bytecode provider [%s], using [%s] by default", id = 382)
void unknownBytecodeProvider(String providerName); void unknownBytecodeProvider(String providerName, String defaultProvider);
@LogMessage(level = WARN) @LogMessage(level = WARN)
@Message(value = "Unknown Ingres major version [%s]; using Ingres 9.2 dialect", id = 383) @Message(value = "Unknown Ingres major version [%s]; using Ingres 9.2 dialect", id = 383)