org.hibernate.boot.registry.internal.StandardServiceRegistryImpl Java Examples

The following examples show how to use org.hibernate.boot.registry.internal.StandardServiceRegistryImpl. 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: ReactiveServiceRegistryBuilder.java    From hibernate-reactive with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Build the StandardServiceRegistry.
 *
 * @return The StandardServiceRegistry.
 */
@SuppressWarnings("unchecked")
public StandardServiceRegistry build() {
    applyServiceContributingIntegrators();
    applyServiceContributors();

    @SuppressWarnings("rawtypes")
    final Map settingsCopy = new HashMap( settings );
    settingsCopy.put( org.hibernate.boot.cfgxml.spi.CfgXmlAccessService.LOADED_CONFIG_KEY, aggregatedCfgXml );
    ConfigurationHelper.resolvePlaceHolders( settingsCopy );

    return new StandardServiceRegistryImpl(
            autoCloseRegistry,
            bootstrapServiceRegistry,
            initiators,
            providedServices,
            settingsCopy
    );
}
 
Example #2
Source File: BaseEntityManagerFunctionalTestCase.java    From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * The entityManagerFactory in this method has been changed from original. It is now STATIC
 * because the teardown method annotated @AfterClass is now run just once and AfterClass methods
 * must be static. The entityManagerFactory is the only dependency of that method and it needed to
 * become a static single reference as a result.
 */
@Before
@SuppressWarnings({"UnusedDeclaration"})
public void buildEntityManagerFactory() {
  if (entityManagerFactory == null) {
    log.trace("Building EntityManagerFactory");

    entityManagerFactory = Bootstrap.getEntityManagerFactoryBuilder(
        buildPersistenceUnitDescriptor(),
        buildSettings()
    ).build().unwrap(SessionFactoryImplementor.class);

    serviceRegistry = (StandardServiceRegistryImpl) entityManagerFactory.getServiceRegistry()
        .getParentServiceRegistry();

    afterEntityManagerFactoryBuilt();
  }
  cleanTables();
}
 
Example #3
Source File: StandardServiceRegistryBuilder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Build the StandardServiceRegistry.
 *
 * @return The StandardServiceRegistry.
 */
@SuppressWarnings("unchecked")
public StandardServiceRegistry build() {
	applyServiceContributingIntegrators();
	applyServiceContributors();

	final Map settingsCopy = new HashMap();
	settingsCopy.putAll( settings );
	settingsCopy.put( org.hibernate.boot.cfgxml.spi.CfgXmlAccessService.LOADED_CONFIG_KEY, aggregatedCfgXml );
	Environment.verifyProperties( settingsCopy );
	ConfigurationHelper.resolvePlaceHolders( settingsCopy );

	return new StandardServiceRegistryImpl(
			autoCloseRegistry,
			bootstrapServiceRegistry,
			initiators,
			providedServices,
			settingsCopy
	);
}
 
Example #4
Source File: PreconfiguredReactiveServiceRegistryBuilder.java    From quarkus with Apache License 2.0 6 votes vote down vote up
public StandardServiceRegistryImpl buildNewServiceRegistry() {
    final BootstrapServiceRegistry bootstrapServiceRegistry = buildEmptyBootstrapServiceRegistry();

    // Can skip, it's only deprecated stuff:
    // applyServiceContributingIntegrators( bootstrapServiceRegistry );

    // This is NOT deprecated stuff.. yet they will at best contribute stuff we
    // already recorded as part of #applyIntegrator, #addInitiator, #addService
    // applyServiceContributors( bootstrapServiceRegistry );

    final Map settingsCopy = new HashMap();
    settingsCopy.putAll(configurationValues);

    destroyedRegistry.resetAndReactivate(bootstrapServiceRegistry, initiators, providedServices, settingsCopy);
    return destroyedRegistry;
}
 
Example #5
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 #6
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 #7
Source File: PreconfiguredServiceRegistryBuilder.java    From quarkus with Apache License 2.0 6 votes vote down vote up
public StandardServiceRegistryImpl buildNewServiceRegistry() {
    final BootstrapServiceRegistry bootstrapServiceRegistry = buildEmptyBootstrapServiceRegistry();

    // Can skip, it's only deprecated stuff:
    // applyServiceContributingIntegrators( bootstrapServiceRegistry );

    // This is NOT deprecated stuff.. yet they will at best contribute stuff we
    // already recorded as part of #applyIntegrator, #addInitiator, #addService
    // applyServiceContributors( bootstrapServiceRegistry );

    final Map settingsCopy = new HashMap();
    settingsCopy.putAll(configurationValues);

    destroyedRegistry.resetAndReactivate(bootstrapServiceRegistry, initiators, providedServices, settingsCopy);
    return destroyedRegistry;

    //		return new StandardServiceRegistryImpl(
    //				true,
    //				bootstrapServiceRegistry,
    //				initiators,
    //				providedServices,
    //				settingsCopy
    //		);
}
 
Example #8
Source File: Hbm2ddl.java    From wallride with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
	String locationPattern = "classpath:/org/wallride/domain/*";

	final BootstrapServiceRegistry registry = new BootstrapServiceRegistryBuilder().build();
	final MetadataSources metadataSources = new MetadataSources(registry);
	final StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder(registry);

	registryBuilder.applySetting(AvailableSettings.DIALECT, ExtendedMySQL5InnoDBDialect.class.getCanonicalName());
	registryBuilder.applySetting(AvailableSettings.GLOBALLY_QUOTED_IDENTIFIERS, true);
	registryBuilder.applySetting(AvailableSettings.PHYSICAL_NAMING_STRATEGY, PhysicalNamingStrategySnakeCaseImpl.class);

	final PathMatchingResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
	final Resource[] resources = resourcePatternResolver.getResources(locationPattern);
	final SimpleMetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
	for (Resource resource : resources) {
		MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
		AnnotationMetadata metadata = metadataReader.getAnnotationMetadata();
		if (metadata.hasAnnotation(Entity.class.getName())) {
			metadataSources.addAnnotatedClass(Class.forName(metadata.getClassName()));
		}
	}

	final StandardServiceRegistryImpl registryImpl = (StandardServiceRegistryImpl) registryBuilder.build();
	final MetadataBuilder metadataBuilder = metadataSources.getMetadataBuilder(registryImpl);

	new SchemaExport()
			.setHaltOnError(true)
			.setDelimiter(";")
			.create(EnumSet.of(TargetType.STDOUT), metadataBuilder.build());
}
 
Example #9
Source File: StandardServiceRegistryBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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) {
	if ( serviceRegistry == null ) {
		return;
	}

	( (StandardServiceRegistryImpl) serviceRegistry ).destroy();
}
 
Example #10
Source File: PreconfiguredReactiveServiceRegistryBuilder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public PreconfiguredReactiveServiceRegistryBuilder(RecordedState rs) {
    this.initiators = buildQuarkusServiceInitiatorList(rs);
    this.integrators = rs.getIntegrators();
    this.destroyedRegistry = (StandardServiceRegistryImpl) rs.getMetadata().getOriginalMetadata()
            .getMetadataBuildingOptions()
            .getServiceRegistry();
}
 
Example #11
Source File: PreconfiguredServiceRegistryBuilder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public PreconfiguredServiceRegistryBuilder(RecordedState rs) {
    this.initiators = buildQuarkusServiceInitiatorList(rs);
    this.integrators = rs.getIntegrators();
    this.destroyedRegistry = (StandardServiceRegistryImpl) rs.getMetadata().getOriginalMetadata()
            .getMetadataBuildingOptions()
            .getServiceRegistry();
}
 
Example #12
Source File: RecordableBootstrap.java    From quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * 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) {
    if (serviceRegistry == null) {
        return;
    }

    ((StandardServiceRegistryImpl) serviceRegistry).destroy();
}
 
Example #13
Source File: RecordableBootstrap.java    From quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Build the StandardServiceRegistry.
 *
 * @return The StandardServiceRegistry.
 */
@Override
@SuppressWarnings("unchecked")
public StandardServiceRegistry build() {
    applyServiceContributors();

    final Map settingsCopy = new HashMap();
    settingsCopy.putAll(settings);
    settingsCopy.put(org.hibernate.boot.cfgxml.spi.CfgXmlAccessService.LOADED_CONFIG_KEY, aggregatedCfgXml);

    return new StandardServiceRegistryImpl(autoCloseRegistry, bootstrapServiceRegistry, initiators,
            providedServices, settingsCopy);
}
 
Example #14
Source File: BaseCoreFunctionalTestCase.java    From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected StandardServiceRegistryImpl buildServiceRegistry(BootstrapServiceRegistry bootRegistry, Configuration configuration) {
  Properties properties = new Properties();
  properties.putAll( configuration.getProperties() );
  ConfigurationHelper.resolvePlaceHolders( properties );

  StandardServiceRegistryBuilder cfgRegistryBuilder = configuration.getStandardServiceRegistryBuilder();

  StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder( bootRegistry, cfgRegistryBuilder.getAggregatedCfgXml() )
      .applySettings( properties );

  prepareBasicRegistryBuilder( registryBuilder );
  return (StandardServiceRegistryImpl) registryBuilder.build();
}
 
Example #15
Source File: ReactiveServiceRegistryBuilder.java    From hibernate-reactive with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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) {
    if ( serviceRegistry == null ) {
        return;
    }

    ( (StandardServiceRegistryImpl) serviceRegistry ).destroy();
}
 
Example #16
Source File: ManagedProviderConnectionHelper.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private static StandardServiceRegistryImpl createServiceRegistry(Properties properties) {
	Environment.verifyProperties( properties );
	ConfigurationHelper.resolvePlaceHolders( properties );
	return (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().applySettings( properties ).build();
}
 
Example #17
Source File: BaseCoreFunctionalTestCase.java    From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected StandardServiceRegistryImpl serviceRegistry() {
  return serviceRegistry;
}
 
Example #18
Source File: BaseEntityManagerFunctionalTestCase.java    From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected StandardServiceRegistryImpl serviceRegistry() {
  return serviceRegistry;
}