public MetadataBuildingContextTestingImpl(StandardServiceRegistry serviceRegistry) { buildingOptions = new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry ); bootstrapContext = new BootstrapContextImpl( serviceRegistry, buildingOptions ); mappingDefaults = new MetadataBuilderImpl.MappingDefaultsImpl( serviceRegistry ); metadataCollector = new InFlightMetadataCollectorImpl( bootstrapContext, buildingOptions ); objectNameNormalizer = new ObjectNameNormalizer() { @Override protected MetadataBuildingContext getBuildingContext() { return MetadataBuildingContextTestingImpl.this; } }; }
@Override public MetadataBuilder applyAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxiliaryDatabaseObject) { this.bootstrapContext.addAuxiliaryDatabaseObject( auxiliaryDatabaseObject ); return this; }
@Override public MetadataBuilder applyCacheRegionDefinition(CacheRegionDefinition cacheRegionDefinition) { this.bootstrapContext.addCacheRegionDefinition( cacheRegionDefinition ); return this; }
@Override public TypeConfiguration getTypeConfiguration() { return bootstrapContext.getTypeConfiguration(); }
@Override public MetadataBuilder applySqlFunction(String functionName, SQLFunction function) { this.bootstrapContext.addSqlFunction( functionName, function ); return this; }
private JavaReflectionManager generateHcannReflectionManager() { final JavaReflectionManager reflectionManager = new JavaReflectionManager(); reflectionManager.setMetadataProvider( new JPAMetadataProvider( this ) ); reflectionManager.injectClassLoaderDelegate( generateHcannClassLoaderDelegate() ); return reflectionManager; }
void injectJpaTempClassLoader(ClassLoader jpaTempClassLoader) { log.debugf( "Injecting JPA temp ClassLoader [%s] into BootstrapContext; was [%s]", jpaTempClassLoader, this.getJpaTempClassLoader() ); this.classLoaderAccess.injectTempClassLoader( jpaTempClassLoader ); }
private ClassLoaderDelegate generateHcannClassLoaderDelegate() { // class loading here needs to be drastically different for 7.0 // but luckily 7.0 will do away with HCANN use and be easier to // implement this. // // todo (6.0) : *if possible* make similar change in 6.0 // possibly using the JPA temp class loader or create our own "throw awy" ClassLoader; // the trouble there is that we eventually need to load the Class into the real // ClassLoader prior to use final ClassLoaderService classLoaderService = getServiceRegistry().getService( ClassLoaderService.class ); return new ClassLoaderDelegate() { @Override public <T> Class<T> classForName(String className) throws ClassLoadingException { try { return classLoaderService.classForName( className ); } catch (org.hibernate.boot.registry.classloading.spi.ClassLoadingException e) { return StandardClassLoaderDelegateImpl.INSTANCE.classForName( className ); } } }; } }
public BootstrapContextImpl( StandardServiceRegistry serviceRegistry, MetadataBuildingOptions metadataBuildingOptions) { this.serviceRegistry = serviceRegistry; this.classmateContext = new ClassmateContext(); this.metadataBuildingOptions = metadataBuildingOptions; final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class ); this.classLoaderAccess = new ClassLoaderAccessImpl( classLoaderService ); this.hcannReflectionManager = generateHcannReflectionManager(); final StrategySelector strategySelector = serviceRegistry.getService( StrategySelector.class ); final ConfigurationService configService = serviceRegistry.getService( ConfigurationService.class ); this.jpaCompliance = new MutableJpaComplianceImpl( configService.getSettings(), false ); this.scanOptions = new StandardScanOptions( (String) configService.getSettings().get( AvailableSettings.SCANNER_DISCOVERY ), false ); // ScanEnvironment must be set explicitly this.scannerSetting = configService.getSettings().get( AvailableSettings.SCANNER ); if ( this.scannerSetting == null ) { this.scannerSetting = configService.getSettings().get( AvailableSettings.SCANNER_DEPRECATED ); if ( this.scannerSetting != null ) { DEPRECATION_LOGGER.logDeprecatedScannerSetting(); } } this.archiveDescriptorFactory = strategySelector.resolveStrategy( ArchiveDescriptorFactory.class, configService.getSettings().get( AvailableSettings.SCANNER_ARCHIVE_INTERPRETER ) ); this.typeConfiguration = new TypeConfiguration(); }
@Override public void contributeJavaTypeDescriptor(JavaTypeDescriptor descriptor) { this.bootstrapContext.getTypeConfiguration().getJavaTypeDescriptorRegistry().addDescriptor( descriptor ); }
@Override public MetadataBuilder applySqlFunction(String functionName, SqmFunctionTemplate function) { this.bootstrapContext.addSqlFunction( functionName, function ); return this; }
private JavaReflectionManager generateHcannReflectionManager() { final JavaReflectionManager reflectionManager = new JavaReflectionManager(); reflectionManager.setMetadataProvider( new JPAMetadataProvider( this ) ); reflectionManager.injectClassLoaderDelegate( generateHcannClassLoaderDelegate() ); return reflectionManager; }
void injectJpaTempClassLoader(ClassLoader jpaTempClassLoader) { log.debugf( "Injecting JPA temp ClassLoader [%s] into BootstrapContext; was [%s]", jpaTempClassLoader, this.getJpaTempClassLoader() ); this.classLoaderAccess.injectTempClassLoader( jpaTempClassLoader ); }
private ClassLoaderDelegate generateHcannClassLoaderDelegate() { // class loading here needs to be drastically different for 7.0 // but luckily 7.0 will do away with HCANN use and be easier to // implement this. // // todo (6.0) : *if possible* make similar change in 6.0 // possibly using the JPA temp class loader or create our own "throw awy" ClassLoader; // the trouble there is that we eventually need to load the Class into the real // ClassLoader prior to use final ClassLoaderService classLoaderService = getServiceRegistry().getService( ClassLoaderService.class ); return new ClassLoaderDelegate() { @Override public <T> Class<T> classForName(String className) throws ClassLoadingException { try { return classLoaderService.classForName( className ); } catch (org.hibernate.boot.registry.classloading.spi.ClassLoadingException e) { return StandardClassLoaderDelegateImpl.INSTANCE.classForName( className ); } } }; }
this.hcannReflectionManager = generateHcannReflectionManager();
private BootstrapContextImpl() { StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build(); MetadataBuildingOptions buildingOptions = new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry ); delegate = new org.hibernate.boot.internal.BootstrapContextImpl( serviceRegistry, buildingOptions ); }
@Override public void contributeSqlTypeDescriptor(SqlTypeDescriptor descriptor) { this.bootstrapContext.getTypeConfiguration().getSqlTypeDescriptorRegistry().addDescriptor( descriptor ); }
@Override public MetadataBuilder applyCacheRegionDefinition(CacheRegionDefinition cacheRegionDefinition) { this.bootstrapContext.addCacheRegionDefinition( cacheRegionDefinition ); return this; }
@Override public MetadataBuilder applyAuxiliaryDatabaseObject(MappedAuxiliaryDatabaseObject auxiliaryDatabaseObject) { this.bootstrapContext.addAuxiliaryDatabaseObject( auxiliaryDatabaseObject ); return this; }
public MetadataBuilderImpl(MetadataSources sources, StandardServiceRegistry serviceRegistry) { this.sources = sources; this.options = new MetadataBuildingOptionsImpl( serviceRegistry ); this.bootstrapContext = new BootstrapContextImpl( serviceRegistry, options ); //this is needed only fro implementig deprecated method options.setBootstrapContext( bootstrapContext ); for ( MetadataSourcesContributor contributor : sources.getServiceRegistry() .getService( ClassLoaderService.class ) .loadJavaServices( MetadataSourcesContributor.class ) ) { contributor.contribute( sources ); } // todo : not so sure this is needed anymore. // these should be set during the StandardServiceRegistryBuilder.configure call applyCfgXmlValues( serviceRegistry.getService( CfgXmlAccessService.class ) ); final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class ); for ( MetadataBuilderInitializer contributor : classLoaderService.loadJavaServices( MetadataBuilderInitializer.class ) ) { contributor.contribute( this, serviceRegistry ); } }