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(); }
final ReflectionManager reflectionManager = buildingContext.getBootstrapContext().getReflectionManager(); final ResolvedType declaringClassType = classmateContext.getTypeResolver().resolve( reflectionManager.toClass( xProperty.getDeclaringClass() ) ); final ResolvedTypeWithMembers declaringClassWithMembers = classmateContext.getMemberResolver().resolve( declaringClassType, null,
@Override public void release() { classmateContext.release(); classLoaderAccess.release(); scanOptions = null; scanEnvironment = null; scannerSetting = null; archiveDescriptorFactory = null; jandexView = null; if ( sqlFunctionMap != null ) { sqlFunctionMap.clear(); } if ( auxiliaryDatabaseObjectList != null ) { auxiliaryDatabaseObjectList.clear(); } if ( attributeConverterInfoMap != null ) { attributeConverterInfoMap.clear(); } if ( cacheRegionDefinitions != null ) { cacheRegionDefinitions.clear(); } }
@SuppressWarnings("WeakerAccess") public AbstractConverterDescriptor( Class<? extends AttributeConverter> converterClass, Boolean forceAutoApply, ClassmateContext classmateContext) { this.converterClass = converterClass; final ResolvedType converterType = classmateContext.getTypeResolver().resolve( converterClass ); final List<ResolvedType> converterParamTypes = converterType.typeParametersFor( AttributeConverter.class ); if ( converterParamTypes == null ) { throw new AnnotationException( "Could not extract type parameter information from AttributeConverter implementation [" + converterClass.getName() + "]" ); } else if ( converterParamTypes.size() != 2 ) { throw new AnnotationException( "Unexpected type parameter information for AttributeConverter implementation [" + converterClass.getName() + "]; expected 2 parameter types, but found " + converterParamTypes.size() ); } this.domainType = converterParamTypes.get( 0 ); this.jdbcType = converterParamTypes.get( 1 ); this.autoApplicableDescriptor = resolveAutoApplicableDescriptor( converterClass, forceAutoApply ); }
@SuppressWarnings("WeakerAccess") public AbstractConverterDescriptor( Class<? extends AttributeConverter> converterClass, Boolean forceAutoApply, ClassmateContext classmateContext) { this.converterClass = converterClass; final ResolvedType converterType = classmateContext.getTypeResolver().resolve( converterClass ); final List<ResolvedType> converterParamTypes = converterType.typeParametersFor( AttributeConverter.class ); if ( converterParamTypes == null ) { throw new AnnotationException( "Could not extract type parameter information from AttributeConverter implementation [" + converterClass.getName() + "]" ); } else if ( converterParamTypes.size() != 2 ) { throw new AnnotationException( "Unexpected type parameter information for AttributeConverter implementation [" + converterClass.getName() + "]; expected 2 parameter types, but found " + converterParamTypes.size() ); } this.domainType = converterParamTypes.get( 0 ); this.jdbcType = converterParamTypes.get( 1 ); this.autoApplicableDescriptor = resolveAutoApplicableDescriptor( converterClass, forceAutoApply ); }
@Test public void testBasicOperation() { SimpleValue simpleValue = new SimpleValue( new MetadataBuildingContextTestingImpl() ); simpleValue.setJpaAttributeConverterDescriptor( new InstanceBasedConverterDescriptor( new StringClobConverter(), new ClassmateContext() ) ); simpleValue.setTypeUsingReflection( IrrelevantEntity.class.getName(), "name" ); Type type = simpleValue.getType(); assertNotNull( type ); if ( !AttributeConverterTypeAdapter.class.isInstance( type ) ) { fail( "AttributeConverter not applied" ); } AbstractStandardBasicType basicType = assertTyping( AbstractStandardBasicType.class, type ); assertSame( StringTypeDescriptor.INSTANCE, basicType.getJavaTypeDescriptor() ); assertEquals( Types.CLOB, basicType.getSqlTypeDescriptor().getSqlType() ); }
final ReflectionManager reflectionManager = buildingContext.getBootstrapContext().getReflectionManager(); final ResolvedType declaringClassType = classmateContext.getTypeResolver().resolve( reflectionManager.toClass( xProperty.getDeclaringClass() ) ); final ResolvedTypeWithMembers declaringClassWithMembers = classmateContext.getMemberResolver().resolve( declaringClassType, null,
@Override public void release() { classmateContext.release(); classLoaderAccess.release(); scanOptions = null; scanEnvironment = null; scannerSetting = null; archiveDescriptorFactory = null; jandexView = null; if ( sqlFunctionMap != null ) { sqlFunctionMap.clear(); } if ( auxiliaryDatabaseObjectList != null ) { auxiliaryDatabaseObjectList.clear(); } if ( attributeConverterDescriptorMap != null ) { attributeConverterDescriptorMap.clear(); } if ( cacheRegionDefinitions != null ) { cacheRegionDefinitions.clear(); } }
/** * Get a builder for metadata where non-default options can be specified. * * @return The built metadata. */ public MetadataBuilder getMetadataBuilder(StandardServiceRegistry serviceRegistry) { return getMetadataBuilder( serviceRegistry, new ClassmateContext() ); }
public Configuration(BootstrapServiceRegistry serviceRegistry) { this.bootstrapServiceRegistry = serviceRegistry; this.metadataSources = new MetadataSources( serviceRegistry ); this.classmateContext = new ClassmateContext(); reset(); }
public MetadataBuilderImpl(MetadataSources sources) { this( sources, getStandardServiceRegistry( sources.getServiceRegistry() ) , new ClassmateContext()); }
public Configuration(MetadataSources metadataSources) { this.bootstrapServiceRegistry = getBootstrapRegistry( metadataSources.getServiceRegistry() ); this.metadataSources = metadataSources; this.classmateContext = new ClassmateContext(); reset(); }