org.hibernate.service.internal.ProvidedService Java Examples

The following examples show how to use org.hibernate.service.internal.ProvidedService. 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: FastBootHibernatePersistenceProvider.java    From quarkus with Apache License 2.0 6 votes vote down vote up
private StandardServiceRegistry rewireMetadataAndExtractServiceRegistry(RuntimeSettings runtimeSettings,
        RecordedState rs) {
    PreconfiguredServiceRegistryBuilder serviceRegistryBuilder = new PreconfiguredServiceRegistryBuilder(rs);

    runtimeSettings.getSettings().forEach((key, value) -> {
        serviceRegistryBuilder.applySetting(key, value);
    });

    for (ProvidedService<?> providedService : rs.getProvidedServices()) {
        serviceRegistryBuilder.addService(providedService);
    }

    // TODO serviceRegistryBuilder.addInitiator( )

    StandardServiceRegistryImpl standardServiceRegistry = serviceRegistryBuilder.buildNewServiceRegistry();
    return standardServiceRegistry;
}
 
Example #2
Source File: FastBootHibernateReactivePersistenceProvider.java    From quarkus with Apache License 2.0 6 votes vote down vote up
private StandardServiceRegistry rewireMetadataAndExtractServiceRegistry(RuntimeSettings runtimeSettings,
        RecordedState rs,
        String persistenceUnitName) {
    PreconfiguredReactiveServiceRegistryBuilder serviceRegistryBuilder = new PreconfiguredReactiveServiceRegistryBuilder(
            rs);

    registerVertxPool(persistenceUnitName, runtimeSettings, serviceRegistryBuilder);

    runtimeSettings.getSettings().forEach((key, value) -> {
        serviceRegistryBuilder.applySetting(key, value);
    });

    for (ProvidedService<?> providedService : rs.getProvidedServices()) {
        serviceRegistryBuilder.addService(providedService);
    }

    StandardServiceRegistryImpl standardServiceRegistry = serviceRegistryBuilder.buildNewServiceRegistry();

    standardServiceRegistry.getService(SchemaManagementTool.class)
            .setCustomDatabaseGenerationTarget(new ReactiveGenerationTarget(standardServiceRegistry));

    return standardServiceRegistry;
}
 
Example #3
Source File: RecordedState.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public RecordedState(Dialect dialect, PrevalidatedQuarkusMetadata metadata,
        BuildTimeSettings settings, Collection<Integrator> integrators,
        Collection<ProvidedService> providedServices, IntegrationSettings integrationSettings,
        ProxyDefinitions classDefinitions, MultiTenancyStrategy strategy) {
    this.dialect = dialect;
    this.metadata = metadata;
    this.settings = settings;
    this.integrators = integrators;
    this.providedServices = providedServices;
    this.integrationSettings = integrationSettings;
    this.proxyClassDefinitions = classDefinitions;
    this.multiTenancyStrategy = strategy;
}
 
Example #4
Source File: StandardServiceRegistryImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
Source File: RecordableBootstrap.java    From quarkus with Apache License 2.0 4 votes vote down vote up
public List<ProvidedService> getProvidedServices() {
    return providedServices;
}
 
Example #6
Source File: RecordedState.java    From quarkus with Apache License 2.0 4 votes vote down vote up
public Collection<ProvidedService> getProvidedServices() {
    return providedServices;
}
 
Example #7
Source File: FastBootMetadataBuilder.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public FastBootMetadataBuilder(final PersistenceUnitDescriptor persistenceUnit, Scanner scanner,
        Collection<Class<? extends Integrator>> additionalIntegrators, PreGeneratedProxies preGeneratedProxies,
        MultiTenancyStrategy strategy) {
    this.persistenceUnit = persistenceUnit;
    this.additionalIntegrators = additionalIntegrators;
    this.preGeneratedProxies = preGeneratedProxies;
    final ClassLoaderService providedClassLoaderService = FlatClassLoaderService.INSTANCE;

    // Copying semantics from: new EntityManagerFactoryBuilderImpl( unit,
    // integration, instance );
    // Except we remove support for several legacy features and XML binding
    final ClassLoader providedClassLoader = null;

    LogHelper.logPersistenceUnitInformation(persistenceUnit);

    // Build the boot-strap service registry, which mainly handles class loader
    // interactions
    final BootstrapServiceRegistry bsr = buildBootstrapServiceRegistry(providedClassLoaderService);

    // merge configuration sources and build the "standard" service registry
    final RecordableBootstrap ssrBuilder = new RecordableBootstrap(bsr);

    final MergedSettings mergedSettings = mergeSettings(persistenceUnit);
    this.buildTimeSettings = new BuildTimeSettings(mergedSettings.getConfigurationValues());

    // Build the "standard" service registry
    ssrBuilder.applySettings(buildTimeSettings.getSettings());
    this.standardServiceRegistry = ssrBuilder.build();
    registerIdentifierGenerators(standardServiceRegistry);

    this.providedServices = ssrBuilder.getProvidedServices();

    /**
     * This is required to properly integrate Hibernate Envers.
     *
     * The EnversService requires multiple steps to be properly built, the most important ones are:
     *
     * 1. The EnversServiceContributor contributes the EnversServiceInitiator to the RecordableBootstrap.
     * 2. After RecordableBootstrap builds a StandardServiceRegistry, the first time the EnversService is
     * requested, it is created by the initiator and configured by the registry.
     * 3. The MetadataBuildingProcess completes by calling the AdditionalJaxbMappingProducer which
     * initializes the EnversService and produces some additional mapping documents.
     * 4. After that point the EnversService appears to be fully functional.
     *
     * The following trick uses the aforementioned steps to setup the EnversService and then turns it into
     * a ProvidedService so that it is not necessary to repeat all these complex steps during the reactivation
     * of the destroyed service registry in PreconfiguredServiceRegistryBuilder.
     *
     */
    for (Class<? extends Service> postBuildProvidedService : ssrBuilder.getPostBuildProvidedServices()) {
        providedServices.add(new ProvidedService(postBuildProvidedService,
                standardServiceRegistry.getService(postBuildProvidedService)));
    }

    final MetadataSources metadataSources = new MetadataSources(bsr);
    addPUManagedClassNamesToMetadataSources(persistenceUnit, metadataSources);

    this.metamodelBuilder = (MetadataBuilderImplementor) metadataSources
            .getMetadataBuilder(standardServiceRegistry);
    if (scanner != null) {
        this.metamodelBuilder.applyScanner(scanner);
    }
    populate(metamodelBuilder, mergedSettings.cacheRegionDefinitions, standardServiceRegistry);

    this.managedResources = MetadataBuildingProcess.prepare(metadataSources,
            metamodelBuilder.getBootstrapContext());

    applyMetadataBuilderContributor();

    // BVAL integration:
    this.validatorFactory = withValidatorFactory(
            buildTimeSettings.get(org.hibernate.cfg.AvailableSettings.JPA_VALIDATION_FACTORY));

    // Unable to automatically handle:
    // AvailableSettings.ENHANCER_ENABLE_DIRTY_TRACKING,
    // AvailableSettings.ENHANCER_ENABLE_LAZY_INITIALIZATION,
    // AvailableSettings.ENHANCER_ENABLE_ASSOCIATION_MANAGEMENT

    // for the time being we want to revoke access to the temp ClassLoader if one
    // was passed
    metamodelBuilder.applyTempClassLoader(null);

    if (strategy != null && strategy != MultiTenancyStrategy.NONE) {
        ssrBuilder.addService(MultiTenantConnectionProvider.class, new HibernateMultiTenantConnectionProvider());
    }
    this.multiTenancyStrategy = strategy;

}
 
Example #8
Source File: PreconfiguredServiceRegistryBuilder.java    From quarkus with Apache License 2.0 4 votes vote down vote up
public PreconfiguredServiceRegistryBuilder addService(ProvidedService providedService) {
    providedServices.add(providedService);
    return this;
}
 
Example #9
Source File: PreconfiguredReactiveServiceRegistryBuilder.java    From quarkus with Apache License 2.0 4 votes vote down vote up
public PreconfiguredReactiveServiceRegistryBuilder addService(ProvidedService providedService) {
    providedServices.add(providedService);
    return this;
}
 
Example #10
Source File: RecordableBootstrap.java    From quarkus with Apache License 2.0 3 votes vote down vote up
/**
 * Adds a user-provided service.
 *
 * @param serviceRole The role of the service being added
 * @param service The service implementation
 *
 * @return this, for method chaining
 */
@Override
@SuppressWarnings({ "unchecked" })
public StandardServiceRegistryBuilder addService(final Class serviceRole, final Service service) {
    providedServices.add(new ProvidedService(serviceRole, service));
    return this;
}
 
Example #11
Source File: StandardServiceRegistryImpl.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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 #12
Source File: ReactiveServiceRegistryBuilder.java    From hibernate-reactive with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * 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", "rawtypes"})
public StandardServiceRegistryBuilder addService(final Class serviceRole, final Service service) {
    providedServices.add( new ProvidedService( serviceRole, service ) );
    return this;
}
 
Example #13
Source File: StandardServiceRegistryBuilder.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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;
}