org.hibernate.bytecode.spi.BytecodeProvider Java Examples

The following examples show how to use org.hibernate.bytecode.spi.BytecodeProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Environment.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private static BytecodeProvider buildBytecodeProvider(String providerName) {
	if ( BYTECODE_PROVIDER_NAME_BYTEBUDDY.equals( providerName ) ) {
		return new org.hibernate.bytecode.internal.bytebuddy.BytecodeProviderImpl();
	}

	if ( BYTECODE_PROVIDER_NAME_JAVASSIST.equals( providerName ) ) {
		return new org.hibernate.bytecode.internal.javassist.BytecodeProviderImpl();
	}

	LOG.bytecodeProvider( providerName );

	// 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.bytebuddy.BytecodeProviderImpl();
}
 
Example #2
Source File: SerializableProxy.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private Object readResolve() {
	BytecodeProvider bytecodeProvider = Environment.getBytecodeProvider();
	if ( !( bytecodeProvider instanceof BytecodeProviderImpl ) ) {
		throw new IllegalStateException( "The bytecode provider is not ByteBuddy, unable to deserialize a ByteBuddy proxy." );
	}

	HibernateProxy proxy = ( (BytecodeProviderImpl) bytecodeProvider ).getByteBuddyProxyHelper().deserializeProxy( this );
	afterDeserialization( (ByteBuddyInterceptor) proxy.getHibernateLazyInitializer() );
	return proxy;
}
 
Example #3
Source File: HibernateSubstitutions.java    From micronaut-sql with Apache License 2.0 4 votes vote down vote up
@Substitute
public static BytecodeProvider buildBytecodeProvider(Properties properties) {
    return new org.hibernate.bytecode.internal.none.BytecodeProviderImpl();
}
 
Example #4
Source File: FastBootEntityManagerFactoryBuilder.java    From quarkus with Apache License 2.0 4 votes vote down vote up
protected void populate(SessionFactoryOptionsBuilder options, StandardServiceRegistry ssr, MultiTenancyStrategy strategy) {

        // will use user override value or default to false if not supplied to follow
        // JPA spec.
        final boolean jtaTransactionAccessEnabled = runtimeSettings.getBoolean(
                AvailableSettings.ALLOW_JTA_TRANSACTION_ACCESS);
        if (!jtaTransactionAccessEnabled) {
            options.disableJtaTransactionAccess();
        }

        final boolean allowRefreshDetachedEntity = runtimeSettings.getBoolean(
                org.hibernate.cfg.AvailableSettings.ALLOW_REFRESH_DETACHED_ENTITY);
        if (!allowRefreshDetachedEntity) {
            options.disableRefreshDetachedEntity();
        }

        // Locate and apply any requested SessionFactoryObserver
        final Object sessionFactoryObserverSetting = runtimeSettings.get(AvailableSettings.SESSION_FACTORY_OBSERVER);
        if (sessionFactoryObserverSetting != null) {

            final StrategySelector strategySelector = ssr.getService(StrategySelector.class);
            final SessionFactoryObserver suppliedSessionFactoryObserver = strategySelector
                    .resolveStrategy(SessionFactoryObserver.class, sessionFactoryObserverSetting);
            options.addSessionFactoryObservers(suppliedSessionFactoryObserver);
        }

        options.addSessionFactoryObservers(new ServiceRegistryCloser());

        options.applyEntityNotFoundDelegate(new JpaEntityNotFoundDelegate());

        if (this.validatorFactory != null) {
            options.applyValidatorFactory(validatorFactory);
        }
        if (this.cdiBeanManager != null) {
            options.applyBeanManager(cdiBeanManager);
        }

        //Small memory optimisations: ensure the class transformation caches of the bytecode enhancer
        //are cleared both on start and on close of the SessionFactory.
        //(On start is useful especially in Quarkus as we won't do any more enhancement after this point)
        BytecodeProvider bytecodeProvider = ssr.getService(BytecodeProvider.class);
        options.addSessionFactoryObservers(new SessionFactoryObserverForBytecodeEnhancer(bytecodeProvider));

        if (strategy != null && strategy != MultiTenancyStrategy.NONE) {
            options.applyMultiTenancyStrategy(strategy);
            options.applyCurrentTenantIdentifierResolver(new HibernateCurrentTenantIdentifierResolver());
        }

    }
 
Example #5
Source File: DisabledBytecodeProviderInitiator.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public BytecodeProvider initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
    //This one disables any use of bytecode enhancement at runtime.
    return new BytecodeProviderImpl();
}
 
Example #6
Source File: DisabledBytecodeProviderInitiator.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public Class<BytecodeProvider> getServiceInitiated() {
    return BytecodeProvider.class;
}
 
Example #7
Source File: Environment.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public static BytecodeProvider buildBytecodeProvider(Properties properties) {
	String provider = ConfigurationHelper.getString( BYTECODE_PROVIDER, properties, BYTECODE_PROVIDER_NAME_DEFAULT );
	return buildBytecodeProvider( provider );
}
 
Example #8
Source File: Environment.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * @deprecated Deprecated to indicate that the method will be moved to
 * {@link org.hibernate.boot.spi.SessionFactoryOptions} /
 * {@link org.hibernate.boot.SessionFactoryBuilder} - probably in 6.0.
 * See <a href="https://hibernate.atlassian.net/browse/HHH-12194">HHH-12194</a> and
 * <a href="https://hibernate.atlassian.net/browse/HHH-12193">HHH-12193</a> for details
 */
@Deprecated
public static BytecodeProvider getBytecodeProvider() {
	return BYTECODE_PROVIDER_INSTANCE;
}