Java Code Examples for org.hibernate.boot.registry.StandardServiceInitiator

The following examples show how to use org.hibernate.boot.registry.StandardServiceInitiator. These examples are extracted from open source projects. 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
@Override
public void contribute(StandardServiceRegistryBuilder serviceRegistryBuilder) {
  serviceRegistryBuilder
      // The custom Hibernate schema management tool for Spanner.
      .addInitiator(new StandardServiceInitiator() {
        @Override
        public Service initiateService(Map configurationValues,
            ServiceRegistryImplementor registry) {
          return SCHEMA_MANAGEMENT_TOOL;
        }

        @Override
        public Class getServiceInitiated() {
          return SchemaManagementTool.class;
        }
      })
      // The user agent JDBC connection property to identify the library.
      .applySetting("hibernate.connection.userAgent", HIBERNATE_API_CLIENT_LIB_TOKEN)
      // Create a unique index for a table if it does not already exist when in UPDATE mode.
      .applySetting(
          "hibernate.schema_update.unique_constraint_strategy",
          UniqueConstraintSchemaUpdateStrategy.RECREATE_QUIETLY)
      // Allows entities to be used with InheritanceType.JOINED in Spanner.
      .applySetting("hibernate.hql.bulk_id_strategy", InlineIdsOrClauseBulkIdStrategy.INSTANCE);
}
 
Example 2
/**
 * Intended for use exclusively from Quarkus boot-strapping, or extensions of
 * this class which need to override the standard ServiceInitiator list.
 * Consider this an SPI.
 */
protected ReactiveServiceRegistryBuilder(
        BootstrapServiceRegistry bootstrapServiceRegistry,
        Map settings,
        LoadedConfig loadedConfig,
        @SuppressWarnings("rawtypes")
        List<StandardServiceInitiator> initiators) {
    this.bootstrapServiceRegistry = bootstrapServiceRegistry;
    this.configLoader = new ConfigLoader( bootstrapServiceRegistry );
    this.settings = settings;
    this.aggregatedCfgXml = loadedConfig;
    this.initiators = initiators;
}
 
Example 3
Source Project: quarkus   Source File: RecordableBootstrap.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Adds a service initiator.
 *
 * @param initiator The initiator to be added
 *
 * @return this, for method chaining
 */
@Override
@SuppressWarnings({ "UnusedDeclaration" })
public StandardServiceRegistryBuilder addInitiator(StandardServiceInitiator initiator) {
    initiators.add(initiator);
    postBuildProvidedServices.add(initiator.getServiceInitiated());
    return this;
}
 
Example 4
/**
 * Constructs a StandardServiceRegistryImpl.  Should not be instantiated directly; use
 * {@link org.hibernate.boot.registry.StandardServiceRegistryBuilder} instead
 *
 * @param autoCloseRegistry See discussion on
 * {@link org.hibernate.boot.registry.StandardServiceRegistryBuilder#disableAutoClose}
 * @param bootstrapServiceRegistry The bootstrap service registry.
 * @param serviceInitiators Any StandardServiceInitiators provided by the user to the builder
 * @param providedServices Any standard services provided directly to the builder
 * @param configurationValues Configuration values
 *
 * @see org.hibernate.boot.registry.StandardServiceRegistryBuilder
 */
@SuppressWarnings( {"unchecked"})
public StandardServiceRegistryImpl(
		boolean autoCloseRegistry,
		BootstrapServiceRegistry bootstrapServiceRegistry,
		List<StandardServiceInitiator> serviceInitiators,
		List<ProvidedService> providedServices,
		Map<?, ?> configurationValues) {
	super( bootstrapServiceRegistry, autoCloseRegistry );

	this.configurationValues = configurationValues;

	try {
		// process initiators
		for ( ServiceInitiator initiator : serviceInitiators ) {
			createServiceBinding( initiator );
		}

		// then, explicitly provided service instances
		for ( ProvidedService providedService : providedServices ) {
			createServiceBinding( providedService );
		}
	}
	catch (RuntimeException e) {
		visitServiceBindings( binding -> binding.getLifecycleOwner().stopService( binding ) );
		throw e;
	}
}
 
Example 5
@SuppressWarnings("rawtypes")
private static List<StandardServiceInitiator> defaultReactiveInitiatorList() {
    final List<StandardServiceInitiator> initiators = new ArrayList<>( ReactiveServiceInitiators.LIST.size() );
    initiators.addAll( ReactiveServiceInitiators.LIST );
    return initiators;
}
 
Example 6
private static List<StandardServiceInitiator> buildInitialServiceInitiatorList() {
    final ArrayList<StandardServiceInitiator> serviceInitiators = new ArrayList<StandardServiceInitiator>();

    // Definitely exclusive to Hibernate Reactive, as it marks the registry as Reactive:
    serviceInitiators.add( ReactiveMarkerServiceInitiator.INSTANCE );

    // Exclusive to Hibernate Reactive:
    serviceInitiators.add( VertxInstanceInitiator.INSTANCE );

    // Exclusive to Hibernate Reactive:
    serviceInitiators.add( SqlClientPoolInitiator.INSTANCE );

    //Custom for Hibernate Reactive:
    serviceInitiators.add( ReactiveSessionFactoryBuilderInitiator.INSTANCE );

    serviceInitiators.add( BytecodeProviderInitiator.INSTANCE );
    serviceInitiators.add( ProxyFactoryFactoryInitiator.INSTANCE );

    serviceInitiators.add( CfgXmlAccessServiceInitiator.INSTANCE );
    serviceInitiators.add( ConfigurationServiceInitiator.INSTANCE );
    serviceInitiators.add( PropertyAccessStrategyResolverInitiator.INSTANCE );

    serviceInitiators.add( ImportSqlCommandExtractorInitiator.INSTANCE );
    serviceInitiators.add( SchemaManagementToolInitiator.INSTANCE );

    //Custom for Hibernate Reactive:
    serviceInitiators.add( NoJdbcEnvironmentInitiator.INSTANCE );

    serviceInitiators.add( JndiServiceInitiator.INSTANCE );
    serviceInitiators.add( JmxServiceInitiator.INSTANCE );

    //Custom for Hibernate Reactive:
    serviceInitiators.add( ReactivePersisterClassResolverInitiator.INSTANCE );
    serviceInitiators.add( PersisterFactoryInitiator.INSTANCE );

    //Custom for Hibernate Reactive:
    serviceInitiators.add( NoJdbcConnectionProviderInitiator.INSTANCE );

    serviceInitiators.add( MultiTenantConnectionProviderInitiator.INSTANCE );
    serviceInitiators.add( DialectResolverInitiator.INSTANCE );
    serviceInitiators.add( DialectFactoryInitiator.INSTANCE );
    serviceInitiators.add( BatchBuilderInitiator.INSTANCE );
    serviceInitiators.add( JdbcServicesInitiator.INSTANCE );
    serviceInitiators.add( RefCursorSupportInitiator.INSTANCE );

    //Custom for Hibernate Reactive:
    serviceInitiators.add( ReactiveQueryTranslatorFactoryInitiator.INSTANCE );

    //Custom for Hibernate Reactive:
    serviceInitiators.add( ReactiveIdentifierGeneratorFactoryInitiator.INSTANCE);


    //Custom for Hibernate Reactive:
    serviceInitiators.add( NoJtaPlatformInitiator.INSTANCE );

    serviceInitiators.add( SessionFactoryServiceRegistryFactoryInitiator.INSTANCE );

    serviceInitiators.add( RegionFactoryInitiator.INSTANCE );

    serviceInitiators.add( TransactionCoordinatorBuilderInitiator.INSTANCE );

    serviceInitiators.add( ManagedBeanRegistryInitiator.INSTANCE );
    serviceInitiators.add( EntityCopyObserverFactoryInitiator.INSTANCE );

    serviceInitiators.trimToSize();

    return Collections.unmodifiableList( serviceInitiators );
}
 
Example 7
public PreconfiguredServiceRegistryBuilder addInitiator(StandardServiceInitiator initiator) {
    initiators.add(initiator);
    return this;
}
 
Example 8
/**
 * Modified copy from
 * org.hibernate.service.StandardServiceInitiators#buildStandardServiceInitiatorList
 *
 * N.B. not to be confused with
 * org.hibernate.service.internal.StandardSessionFactoryServiceInitiators#buildStandardServiceInitiatorList()
 *
 * @return
 */
private static List<StandardServiceInitiator> buildQuarkusServiceInitiatorList(RecordedState rs) {
    final ArrayList<StandardServiceInitiator> serviceInitiators = new ArrayList<StandardServiceInitiator>();

    //Enforces no bytecode enhancement will happen at runtime:
    serviceInitiators.add(DisabledBytecodeProviderInitiator.INSTANCE);

    //Use a custom ProxyFactoryFactory which is able to use the class definitions we already created:
    serviceInitiators.add(new QuarkusRuntimeProxyFactoryFactoryInitiator(rs));

    // Replaces org.hibernate.boot.cfgxml.internal.CfgXmlAccessServiceInitiator :
    // not used
    // (Original disabled)
    serviceInitiators.add(CfgXmlAccessServiceInitiatorQuarkus.INSTANCE);

    // Useful as-is
    serviceInitiators.add(ConfigurationServiceInitiator.INSTANCE);

    // TODO (optional): assume entities are already enhanced?
    serviceInitiators.add(PropertyAccessStrategyResolverInitiator.INSTANCE);

    // TODO (optional): not a priority
    serviceInitiators.add(ImportSqlCommandExtractorInitiator.INSTANCE);

    // TODO disable?
    serviceInitiators.add(SchemaManagementToolInitiator.INSTANCE);

    // Replaces JdbcEnvironmentInitiator.INSTANCE :
    serviceInitiators.add(new QuarkusJdbcEnvironmentInitiator(rs.getDialect()));

    // Custom one!
    serviceInitiators.add(QuarkusJndiServiceInitiator.INSTANCE);

    // Custom one!
    serviceInitiators.add(DisabledJMXInitiator.INSTANCE);

    serviceInitiators.add(PersisterClassResolverInitiator.INSTANCE);
    serviceInitiators.add(PersisterFactoryInitiator.INSTANCE);

    // Custom one!
    serviceInitiators.add(QuarkusConnectionProviderInitiator.INSTANCE);
    serviceInitiators.add(MultiTenantConnectionProviderInitiator.INSTANCE);

    // Disabled: Dialect is injected explicitly
    // serviceInitiators.add( DialectResolverInitiator.INSTANCE );

    // Disabled: Dialect is injected explicitly
    // serviceInitiators.add( DialectFactoryInitiator.INSTANCE );

    serviceInitiators.add(BatchBuilderInitiator.INSTANCE);
    serviceInitiators.add(JdbcServicesInitiator.INSTANCE);
    serviceInitiators.add(RefCursorSupportInitiator.INSTANCE);

    serviceInitiators.add(QueryTranslatorFactoryInitiator.INSTANCE);

    // Disabled: IdentifierGenerators are no longer initiated after Metadata was generated.
    // serviceInitiators.add(MutableIdentifierGeneratorFactoryInitiator.INSTANCE);

    serviceInitiators.add(new QuarkusJtaPlatformInitiator(true));

    serviceInitiators.add(SessionFactoryServiceRegistryFactoryInitiator.INSTANCE);

    // Replaces RegionFactoryInitiator.INSTANCE
    serviceInitiators.add(QuarkusRegionFactoryInitiator.INSTANCE);

    serviceInitiators.add(TransactionCoordinatorBuilderInitiator.INSTANCE);

    serviceInitiators.add(ManagedBeanRegistryInitiator.INSTANCE);

    serviceInitiators.add(EntityCopyObserverFactoryInitiator.INSTANCE);

    serviceInitiators.trimToSize();
    return serviceInitiators;
}
 
Example 9
public PreconfiguredReactiveServiceRegistryBuilder addInitiator(StandardServiceInitiator initiator) {
    initiators.add(initiator);
    return this;
}
 
Example 10
/**
 * Modified copy from
 * org.hibernate.service.StandardServiceInitiators#buildStandardServiceInitiatorList
 *
 * N.B. not to be confused with
 * org.hibernate.service.internal.StandardSessionFactoryServiceInitiators#buildStandardServiceInitiatorList()
 *
 * @return
 */
private static List<StandardServiceInitiator> buildQuarkusServiceInitiatorList(RecordedState rs) {
    final ArrayList<StandardServiceInitiator> serviceInitiators = new ArrayList<StandardServiceInitiator>();

    // Definitely exclusive to Hibernate Reactive, as it marks the registry as Reactive:
    serviceInitiators.add(ReactiveMarkerServiceInitiator.INSTANCE);

    //Custom for Hibernate Reactive:
    serviceInitiators.add(ReactiveSessionFactoryBuilderInitiator.INSTANCE);

    //Enforces no bytecode enhancement will happen at runtime:
    serviceInitiators.add(DisabledBytecodeProviderInitiator.INSTANCE);

    //Use a custom ProxyFactoryFactory which is able to use the class definitions we already created:
    serviceInitiators.add(new QuarkusRuntimeProxyFactoryFactoryInitiator(rs));

    // Replaces org.hibernate.boot.cfgxml.internal.CfgXmlAccessServiceInitiator :
    // not used
    // (Original disabled)
    serviceInitiators.add(CfgXmlAccessServiceInitiatorQuarkus.INSTANCE);

    // Useful as-is
    serviceInitiators.add(ConfigurationServiceInitiator.INSTANCE);

    // TODO (optional): assume entities are already enhanced?
    serviceInitiators.add(PropertyAccessStrategyResolverInitiator.INSTANCE);

    // TODO (optional): not a priority
    serviceInitiators.add(ImportSqlCommandExtractorInitiator.INSTANCE);

    // TODO disable?
    serviceInitiators.add(SchemaManagementToolInitiator.INSTANCE);

    // Replaces JdbcEnvironmentInitiator.INSTANCE :
    serviceInitiators.add(new QuarkusNoJdbcEnvironmentInitiator(rs.getDialect()));

    // Custom one!
    serviceInitiators.add(QuarkusJndiServiceInitiator.INSTANCE);

    // Custom one!
    serviceInitiators.add(DisabledJMXInitiator.INSTANCE);

    //Custom for Hibernate Reactive:
    serviceInitiators.add(ReactivePersisterClassResolverInitiator.INSTANCE);
    serviceInitiators.add(PersisterFactoryInitiator.INSTANCE);

    //Custom for Hibernate Reactive:
    serviceInitiators.add(NoJdbcConnectionProviderInitiator.INSTANCE);
    //serviceInitiators.add(QuarkusConnectionProviderInitiator.INSTANCE);
    serviceInitiators.add(MultiTenantConnectionProviderInitiator.INSTANCE);

    // Disabled: Dialect is injected explicitly
    // serviceInitiators.add( DialectResolverInitiator.INSTANCE );

    // Disabled: Dialect is injected explicitly
    // serviceInitiators.add( DialectFactoryInitiator.INSTANCE );

    serviceInitiators.add(BatchBuilderInitiator.INSTANCE);
    serviceInitiators.add(JdbcServicesInitiator.INSTANCE);
    serviceInitiators.add(RefCursorSupportInitiator.INSTANCE);

    //serviceInitiators.add(QueryTranslatorFactoryInitiator.INSTANCE);
    serviceInitiators.add(ReactiveQueryTranslatorFactoryInitiator.INSTANCE);

    // Disabled: IdentifierGenerators are no longer initiated after Metadata was generated.
    // serviceInitiators.add(MutableIdentifierGeneratorFactoryInitiator.INSTANCE);

    serviceInitiators.add(new QuarkusJtaPlatformInitiator(false));

    serviceInitiators.add(SessionFactoryServiceRegistryFactoryInitiator.INSTANCE);

    // Replaces RegionFactoryInitiator.INSTANCE
    serviceInitiators.add(QuarkusRegionFactoryInitiator.INSTANCE);

    serviceInitiators.add(TransactionCoordinatorBuilderInitiator.INSTANCE);

    serviceInitiators.add(ManagedBeanRegistryInitiator.INSTANCE);

    serviceInitiators.add(EntityCopyObserverFactoryInitiator.INSTANCE);

    serviceInitiators.add(ReactiveIdentifierGeneratorFactoryInitiator.INSTANCE);

    serviceInitiators.trimToSize();
    return serviceInitiators;
}
 
Example 11
private static List<StandardServiceInitiator> buildStandardServiceInitiatorList() {
	final List<StandardServiceInitiator> serviceInitiators = new ArrayList<StandardServiceInitiator>();

	serviceInitiators.add( CfgXmlAccessServiceInitiator.INSTANCE );
	serviceInitiators.add( ConfigurationServiceInitiator.INSTANCE );
	serviceInitiators.add( PropertyAccessStrategyResolverInitiator.INSTANCE );

	serviceInitiators.add( ImportSqlCommandExtractorInitiator.INSTANCE );
	serviceInitiators.add( SchemaManagementToolInitiator.INSTANCE );

	serviceInitiators.add( JdbcEnvironmentInitiator.INSTANCE );
	serviceInitiators.add( JndiServiceInitiator.INSTANCE );
	serviceInitiators.add( JmxServiceInitiator.INSTANCE );

	serviceInitiators.add( PersisterClassResolverInitiator.INSTANCE );
	serviceInitiators.add( PersisterFactoryInitiator.INSTANCE );

	serviceInitiators.add( ConnectionProviderInitiator.INSTANCE );
	serviceInitiators.add( MultiTenantConnectionProviderInitiator.INSTANCE );
	serviceInitiators.add( DialectResolverInitiator.INSTANCE );
	serviceInitiators.add( DialectFactoryInitiator.INSTANCE );
	serviceInitiators.add( BatchBuilderInitiator.INSTANCE );
	serviceInitiators.add( JdbcServicesInitiator.INSTANCE );
	serviceInitiators.add( RefCursorSupportInitiator.INSTANCE );

	serviceInitiators.add( QueryTranslatorFactoryInitiator.INSTANCE );
	serviceInitiators.add( MutableIdentifierGeneratorFactoryInitiator.INSTANCE);

	serviceInitiators.add( JtaPlatformResolverInitiator.INSTANCE );
	serviceInitiators.add( JtaPlatformInitiator.INSTANCE );

	serviceInitiators.add( SessionFactoryServiceRegistryFactoryInitiator.INSTANCE );

	serviceInitiators.add( RegionFactoryInitiator.INSTANCE );

	serviceInitiators.add( TransactionCoordinatorBuilderInitiator.INSTANCE );

	serviceInitiators.add( ManagedBeanRegistryInitiator.INSTANCE );

	return Collections.unmodifiableList( serviceInitiators );
}
 
Example 12
@Override
public <R extends Service> R initiateService(ServiceInitiator<R> serviceInitiator) {
	// todo : add check/error for unexpected initiator types?
	return ( (StandardServiceInitiator<R>) serviceInitiator ).initiateService( configurationValues, this );
}
 
Example 13
/**
 * Constructs a StandardServiceRegistryImpl.  Should not be instantiated directly; use
 * {@link org.hibernate.boot.registry.StandardServiceRegistryBuilder} instead
 *
 * @param bootstrapServiceRegistry The bootstrap service registry.
 * @param serviceInitiators Any StandardServiceInitiators provided by the user to the builder
 * @param providedServices Any standard services provided directly to the builder
 * @param configurationValues Configuration values
 *
 * @see org.hibernate.boot.registry.StandardServiceRegistryBuilder
 */
@SuppressWarnings( {"unchecked"})
public StandardServiceRegistryImpl(
		BootstrapServiceRegistry bootstrapServiceRegistry,
		List<StandardServiceInitiator> serviceInitiators,
		List<ProvidedService> providedServices,
		Map<?, ?> configurationValues) {
	this( true, bootstrapServiceRegistry, serviceInitiators, providedServices, configurationValues );
}
 
Example 14
/**
 * 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;
}
 
Example 15
Source Project: quarkus   Source File: RecordableBootstrap.java    License: Apache License 2.0 2 votes vote down vote up
private static List<StandardServiceInitiator> standardInitiatorList() {
    final ArrayList<StandardServiceInitiator> serviceInitiators = new ArrayList<StandardServiceInitiator>();

    //This one needs to be replaced after Metadata has been recorded:
    serviceInitiators.add(BootstrapOnlyProxyFactoryFactoryInitiator.INSTANCE);

    serviceInitiators.add(CfgXmlAccessServiceInitiator.INSTANCE);
    serviceInitiators.add(ConfigurationServiceInitiator.INSTANCE);
    serviceInitiators.add(PropertyAccessStrategyResolverInitiator.INSTANCE);

    serviceInitiators.add(ImportSqlCommandExtractorInitiator.INSTANCE);
    serviceInitiators.add(SchemaManagementToolInitiator.INSTANCE);

    serviceInitiators.add(JdbcEnvironmentInitiator.INSTANCE);

    // Custom one!
    serviceInitiators.add(QuarkusJndiServiceInitiator.INSTANCE);

    // Custom one!
    serviceInitiators.add(DisabledJMXInitiator.INSTANCE);

    serviceInitiators.add(PersisterClassResolverInitiator.INSTANCE);
    serviceInitiators.add(PersisterFactoryInitiator.INSTANCE);

    // Custom one!
    serviceInitiators.add(QuarkusConnectionProviderInitiator.INSTANCE);
    serviceInitiators.add(MultiTenantConnectionProviderInitiator.INSTANCE);
    serviceInitiators.add(DialectResolverInitiator.INSTANCE);

    // Custom one!
    serviceInitiators.add(DialectFactoryInitiator.INSTANCE);
    serviceInitiators.add(BatchBuilderInitiator.INSTANCE);
    serviceInitiators.add(JdbcServicesInitiator.INSTANCE);
    serviceInitiators.add(RefCursorSupportInitiator.INSTANCE);

    serviceInitiators.add(QueryTranslatorFactoryInitiator.INSTANCE);

    // Custom one! Also, this one has state so can't use the singleton.
    serviceInitiators.add(new QuarkusMutableIdentifierGeneratorFactoryInitiator());// MutableIdentifierGeneratorFactoryInitiator.INSTANCE);

    serviceInitiators.add(new QuarkusJtaPlatformInitiator(true));

    serviceInitiators.add(SessionFactoryServiceRegistryFactoryInitiator.INSTANCE);

    serviceInitiators.add(QuarkusRegionFactoryInitiator.INSTANCE);

    serviceInitiators.add(TransactionCoordinatorBuilderInitiator.INSTANCE);

    serviceInitiators.add(ManagedBeanRegistryInitiator.INSTANCE);

    serviceInitiators.add(EntityCopyObserverFactoryInitiator.INSTANCE);

    serviceInitiators.trimToSize();

    return serviceInitiators;
}