Java 类org.hibernate.boot.registry.classloading.spi.ClassLoaderService 实例源码

项目:hibernate-ogm-redis    文件:RedisDatastoreProvider.java   
@Override
public void configure(Map configurationValues) {
    ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
    ConfigurationPropertyReader propertyReader = new ConfigurationPropertyReader(
            configurationValues,
            classLoaderService
    );

    try {
        this.config = new RedisConfiguration( propertyReader );
    }
    catch (Exception e) {
        // Wrap Exception in a ServiceException to make the stack trace more friendly
        // Otherwise a generic unable to request service is thrown
        throw log.unableToConfigureDatastoreProvider( e );
    }
}
项目:lams    文件:BatchBuilderInitiator.java   
@Override
public BatchBuilder initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
    final Object builder = configurationValues.get( BUILDER );
    if ( builder == null ) {
        return new BatchBuilderImpl(
                ConfigurationHelper.getInt( Environment.STATEMENT_BATCH_SIZE, configurationValues, 1 )
        );
    }

    if ( BatchBuilder.class.isInstance( builder ) ) {
        return (BatchBuilder) builder;
    }

    final String builderClassName = builder.toString();
    try {
        return (BatchBuilder) registry.getService( ClassLoaderService.class ).classForName( builderClassName ).newInstance();
    }
    catch (Exception e) {
        throw new ServiceException( "Could not build explicit BatchBuilder [" + builderClassName + "]", e );
    }
}
项目:lams    文件:SessionFactoryImpl.java   
@Override
public String getImportedClassName(String className) {
    String result = imports.get( className );
    if ( result == null ) {
        try {
            serviceRegistry.getService( ClassLoaderService.class ).classForName( className );
            imports.put( className, className );
            return className;
        }
        catch ( ClassLoadingException cnfe ) {
            return null;
        }
    }
    else {
        return result;
    }
}
项目:lams    文件:StrategySelectorBuilder.java   
/**
 * Builds the selector.
 *
 * @param classLoaderService The class loading service used to (attempt to) resolve any un-registered
 * strategy implementations.
 *
 * @return The selector.
 */
public StrategySelector buildSelector(ClassLoaderService classLoaderService) {
    final StrategySelectorImpl strategySelector = new StrategySelectorImpl( classLoaderService );

    // build the baseline...
    addDialects( strategySelector );
    addJtaPlatforms( strategySelector );
    addTransactionFactories( strategySelector );
    addMultiTableBulkIdStrategies( strategySelector );
    addEntityCopyObserverStrategies( strategySelector );

    // apply auto-discovered registrations
    for ( StrategyRegistrationProvider provider : classLoaderService.loadJavaServices( StrategyRegistrationProvider.class ) ) {
        for ( StrategyRegistration discoveredStrategyRegistration : provider.getStrategyRegistrations() ) {
            applyFromStrategyRegistration( strategySelector, discoveredStrategyRegistration );
        }
    }

    // apply customizations
    for ( StrategyRegistration explicitStrategyRegistration : explicitStrategyRegistrations ) {
        applyFromStrategyRegistration( strategySelector, explicitStrategyRegistration );
    }

    return strategySelector;
}
项目:lams    文件:BootstrapServiceRegistryImpl.java   
/**
 * Constructs a BootstrapServiceRegistryImpl.
 *
 * Do not use directly generally speaking.  Use {@link org.hibernate.boot.registry.BootstrapServiceRegistryBuilder}
 * instead.
 *
 * @param autoCloseRegistry See discussion on
 * {@link org.hibernate.boot.registry.BootstrapServiceRegistryBuilder#disableAutoClose}
 * @param classLoaderService The ClassLoaderService to use
 * @param providedIntegrators The group of explicitly provided integrators
 *
 * @see org.hibernate.boot.registry.BootstrapServiceRegistryBuilder
 */
public BootstrapServiceRegistryImpl(
        boolean autoCloseRegistry,
        ClassLoaderService classLoaderService,
        LinkedHashSet<Integrator> providedIntegrators) {
    this.autoCloseRegistry = autoCloseRegistry;

    this.classLoaderServiceBinding = new ServiceBinding<ClassLoaderService>(
            this,
            ClassLoaderService.class,
            classLoaderService
    );

    final StrategySelectorImpl strategySelector = new StrategySelectorImpl( classLoaderService );
    this.strategySelectorBinding = new ServiceBinding<StrategySelector>(
            this,
            StrategySelector.class,
            strategySelector
    );

    this.integratorServiceBinding = new ServiceBinding<IntegratorService>(
            this,
            IntegratorService.class,
            new IntegratorServiceImpl( providedIntegrators, classLoaderService )
    );
}
项目:lams    文件:BootstrapServiceRegistryImpl.java   
/**
 * Constructs a BootstrapServiceRegistryImpl.
 *
 * Do not use directly generally speaking.  Use {@link org.hibernate.boot.registry.BootstrapServiceRegistryBuilder}
 * instead.
 *
 * @param autoCloseRegistry See discussion on
 * {@link org.hibernate.boot.registry.BootstrapServiceRegistryBuilder#disableAutoClose}
 * @param classLoaderService The ClassLoaderService to use
 * @param strategySelector The StrategySelector to use
 * @param integratorService The IntegratorService to use
 *
 * @see org.hibernate.boot.registry.BootstrapServiceRegistryBuilder
 */
public BootstrapServiceRegistryImpl(
        boolean autoCloseRegistry,
        ClassLoaderService classLoaderService,
        StrategySelector strategySelector,
        IntegratorService integratorService) {
    this.autoCloseRegistry = autoCloseRegistry;

    this.classLoaderServiceBinding = new ServiceBinding<ClassLoaderService>(
            this,
            ClassLoaderService.class,
            classLoaderService
    );

    this.strategySelectorBinding = new ServiceBinding<StrategySelector>(
            this,
            StrategySelector.class,
            strategySelector
    );

    this.integratorServiceBinding = new ServiceBinding<IntegratorService>(
            this,
            IntegratorService.class,
            integratorService
    );
}
项目:gorm-hibernate5    文件:GrailsDomainBinder.java   
@Override
public void contribute(InFlightMetadataCollector metadataCollector, IndexView jandexIndex) {
    MetadataBuildingOptions options = metadataCollector.getMetadataBuildingOptions();
    ClassLoaderService classLoaderService = options.getServiceRegistry().getService(ClassLoaderService.class);

    final ClassLoaderAccess classLoaderAccess = new ClassLoaderAccessImpl(
            options.getTempClassLoader(),
            classLoaderService
    );

    this.metadataBuildingContext = new MetadataBuildingContextRootImpl(
            options,
            classLoaderAccess,
            metadataCollector
    );

        java.util.Collection<PersistentEntity> persistentEntities = hibernateMappingContext.getPersistentEntities();
    for (PersistentEntity persistentEntity : persistentEntities) {
        if(!persistentEntity.getJavaClass().isAnnotationPresent(Entity.class)) {
            if(ConnectionSourcesSupport.usesConnectionSource(persistentEntity, dataSourceName) && persistentEntity.isRoot()) {
                bindRoot((HibernatePersistentEntity) persistentEntity, metadataCollector, sessionFactoryName);
            }
        }
    }
}
项目:lams    文件:BeanValidationIntegrator.java   
private boolean isBeanValidationApiAvailable(ClassLoaderService classLoaderService) {
    try {
        classLoaderService.classForName( BV_CHECK_CLASS );
        return true;
    }
    catch (Exception e) {
        return false;
    }
}
项目:lams    文件:BeanValidationIntegrator.java   
private Class loadTypeSafeActivatorClass(ClassLoaderService classLoaderService) {
    try {
        return classLoaderService.classForName( ACTIVATOR_CLASS_NAME );
    }
    catch (Exception e) {
        throw new HibernateException( "Unable to load TypeSafeActivator class", e );
    }
}
项目:lams    文件:SettingsFactory.java   
protected QueryCacheFactory createQueryCacheFactory(Properties properties, ServiceRegistry serviceRegistry) {
    String queryCacheFactoryClassName = ConfigurationHelper.getString(
            AvailableSettings.QUERY_CACHE_FACTORY, properties, StandardQueryCacheFactory.class.getName()
    );
    LOG.debugf( "Query cache factory: %s", queryCacheFactoryClassName );
    try {
        return (QueryCacheFactory) serviceRegistry.getService( ClassLoaderService.class )
                .classForName( queryCacheFactoryClassName )
                .newInstance();
    }
    catch (Exception e) {
        throw new HibernateException( "could not instantiate QueryCacheFactory: " + queryCacheFactoryClassName, e );
    }
}
项目:lams    文件:SettingsFactory.java   
protected QueryTranslatorFactory createQueryTranslatorFactory(Properties properties, ServiceRegistry serviceRegistry) {
    String className = ConfigurationHelper.getString(
            AvailableSettings.QUERY_TRANSLATOR, properties, "org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory"
    );
    LOG.debugf( "Query translator: %s", className );
    try {
        return (QueryTranslatorFactory) serviceRegistry.getService( ClassLoaderService.class )
                .classForName( className )
                .newInstance();
    }
    catch ( Exception e ) {
        throw new HibernateException( "could not instantiate QueryTranslatorFactory: " + className, e );
    }
}
项目:lams    文件:Helper.java   
public static Class classForName(String className, ServiceRegistry serviceRegistry) {
    ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
    try {
        return classLoaderService.classForName( className );
    }
    catch ( ClassLoadingException e ) {
        throw new MappingException( "Could not find class: " + className );
    }
}
项目:lams    文件:JandexHelper.java   
public static <T> T getValue(AnnotationInstance annotation, String element, Class<T> type,
        ClassLoaderService classLoaderService) throws AssertionFailure {
    if ( Class.class.equals( type ) ) {
        throw new AssertionFailure(
                "Annotation parameters of type Class should be retrieved as strings (fully qualified class names)"
        );
    }

    if ( type.isPrimitive() ) {
        type = PrimitiveWrapperHelper.getDescriptorByPrimitiveType( type ).getWrapperClass();
    }

    // try getting the untyped value from Jandex
    AnnotationValue annotationValue = annotation.value( element );

    try {
        if ( annotationValue != null ) {
            return explicitAnnotationParameter( annotationValue, type );
        }
        else {
            return defaultAnnotationParameter( getDefaultValue( annotation, element, classLoaderService ), type );
        }
    }
    catch ( ClassCastException e ) {
        throw new AssertionFailure(
                String.format(
                        "the annotation property %s of annotation %s is not of type %s",
                        element,
                        annotation.name(),
                        type.getName()
                ),
                e
        );
    }
}
项目:lams    文件:JandexHelper.java   
/**
 * Creates a jandex index for the specified classes
 *
 * @param classLoaderService class loader service
 * @param classes the classes to index
 *
 * @return an annotation repository w/ all the annotation discovered in the specified classes
 */
public static Index indexForClass(ClassLoaderService classLoaderService, Class<?>... classes) {
    Indexer indexer = new Indexer();
    for ( Class<?> clazz : classes ) {
        InputStream stream = classLoaderService.locateResourceStream(
                clazz.getName().replace( '.', '/' ) + ".class"
        );
        try {
            indexer.index( stream );
        }
        catch ( IOException e ) {
            StringBuilder builder = new StringBuilder();
            builder.append( "[" );
            int count = 0;
            for ( Class<?> c : classes ) {
                builder.append( c.getName() );
                if ( count < classes.length - 1 ) {
                    builder.append( "," );
                }
                count++;
            }
            builder.append( "]" );
            throw new HibernateException( "Unable to create annotation index for " + builder.toString() );
        }
    }
    return indexer.complete();
}
项目:lams    文件:AnnotationBindingContextImpl.java   
public AnnotationBindingContextImpl(MetadataImplementor metadata, Index index) {
    this.metadata = metadata;
    this.classLoaderService = new ValueHolder<ClassLoaderService>(
            new ValueHolder.DeferredInitializer<ClassLoaderService>() {
                @Override
                public ClassLoaderService initialize() {
                    return AnnotationBindingContextImpl.this.metadata
                            .getServiceRegistry()
                            .getService( ClassLoaderService.class );
                }
            }
    );
    this.index = index;
}
项目:lams    文件:MockHelper.java   
static AnnotationTarget getTarget(ServiceRegistry serviceRegistry, ClassInfo classInfo, String name, TargetType type) {
    Class clazz = serviceRegistry.getService( ClassLoaderService.class ).classForName( classInfo.toString() );
    switch ( type ) {
        case FIELD:
            Field field = getField( clazz, name );
            if ( field == null ) {
                throw new HibernateException(
                        "Unable to load field "
                                + name
                                + " of class " + clazz.getName()
                );
            }

            return FieldInfo.create(
                    classInfo, name, getType( field.getType() ), (short) ( field.getModifiers() )
            );
        case METHOD:
            Method method = getMethod( clazz, name );
            if ( method == null ) {
                throw new HibernateException(
                        "Unable to load method "
                                + name
                                + " of class " + clazz.getName()
                );
            }
            return getMethodInfo( classInfo, method );
        case PROPERTY:
            method = getterMethod( clazz, name );
            if ( method == null ) {
                throw new HibernateException(
                        "Unable to load property "
                                + name
                                + " of class " + clazz.getName()
                );
            }
            return getMethodInfo( classInfo, method );

    }
    throw new HibernateException( "" );
}
项目:lams    文件:AnnotationMetadataSourceProcessorImpl.java   
private void indexClass(Indexer indexer, String className) {
    InputStream stream = metadata.getServiceRegistry().getService( ClassLoaderService.class ).locateResourceStream(
            className
    );
    try {
        indexer.index( stream );
    }
    catch ( IOException e ) {
        throw new HibernateException( "Unable to open input stream for class " + className, e );
    }
}
项目:lams    文件:JavaType.java   
public JavaType(final String name, final ClassLoaderService classLoaderService) {
    this.name = name;
    this.classReference = new ValueHolder<Class<?>>(
            new ValueHolder.DeferredInitializer<Class<?>>() {
                @Override
                public Class<?> initialize() {
                    return classLoaderService.classForName( name );
                }
            }
    );
}
项目:lams    文件:ImportSqlCommandExtractorInitiator.java   
@Override
public ImportSqlCommandExtractor initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
    String extractorClassName = (String) configurationValues.get( Environment.HBM2DDL_IMPORT_FILES_SQL_EXTRACTOR );
    if ( StringHelper.isEmpty( extractorClassName ) ) {
        return DEFAULT_EXTRACTOR;
    }
    final ClassLoaderService classLoaderService = registry.getService( ClassLoaderService.class );
    return instantiateExplicitCommandExtractor( extractorClassName, classLoaderService );
}
项目:lams    文件:ImportSqlCommandExtractorInitiator.java   
private ImportSqlCommandExtractor instantiateExplicitCommandExtractor(String extractorClassName,
                                                                      ClassLoaderService classLoaderService) {
    try {
        return (ImportSqlCommandExtractor) classLoaderService.classForName( extractorClassName ).newInstance();
    }
    catch ( Exception e ) {
        throw new HibernateException(
                "Could not instantiate import sql command extractor [" + extractorClassName + "]", e
        );
    }
}
项目:lams    文件:BitronixJtaPlatform.java   
@Override
protected TransactionManager locateTransactionManager() {
    try {
        Class transactionManagerServicesClass = serviceRegistry().getService( ClassLoaderService.class ).classForName( TM_CLASS_NAME );
        final Method getTransactionManagerMethod = transactionManagerServicesClass.getMethod( "getTransactionManager" );
        return (TransactionManager) getTransactionManagerMethod.invoke( null );
    }
    catch (Exception e) {
        throw new JtaPlatformException( "Could not locate Bitronix TransactionManager", e );
    }
}
项目:lams    文件:JBossStandAloneJtaPlatform.java   
@Override
protected TransactionManager locateTransactionManager() {
    try {
        final Class jbossTmClass = serviceRegistry()
                .getService( ClassLoaderService.class )
                .classForName( JBOSS_TM_CLASS_NAME );
        return (TransactionManager) jbossTmClass.getMethod( "transactionManager" ).invoke( null );
    }
    catch ( Exception e ) {
        throw new JtaPlatformException( "Could not obtain JBoss Transactions transaction manager instance", e );
    }
}
项目:lams    文件:JBossStandAloneJtaPlatform.java   
@Override
protected UserTransaction locateUserTransaction() {
    try {
        final Class jbossUtClass = serviceRegistry()
                .getService( ClassLoaderService.class )
                .classForName( JBOSS_UT_CLASS_NAME );
        return (UserTransaction) jbossUtClass.getMethod( "userTransaction" ).invoke( null );
    }
    catch ( Exception e ) {
        throw new JtaPlatformException( "Could not obtain JBoss Transactions user transaction instance", e );
    }
}
项目:lams    文件:JOTMJtaPlatform.java   
@Override
protected TransactionManager locateTransactionManager() {
    try {
        final Class tmClass = serviceRegistry().getService( ClassLoaderService.class ).classForName( TM_CLASS_NAME );
        final Method getTransactionManagerMethod = tmClass.getMethod( "getTransactionManager" );
        return (TransactionManager) getTransactionManagerMethod.invoke( null, (Object[]) null );
    }
    catch (Exception e) {
        throw new JtaPlatformException( "Could not obtain JOTM transaction manager instance", e );
    }
}
项目:lams    文件:DriverManagerConnectionProviderImpl.java   
private Driver loadDriverIfPossible(String driverClassName) {
    if ( driverClassName == null ) {
        log.debug( "No driver class specified" );
        return null;
    }

    if ( serviceRegistry != null ) {
        final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
        final Class<Driver> driverClass = classLoaderService.classForName( driverClassName );
        try {
            return driverClass.newInstance();
        }
        catch ( Exception e ) {
            throw new ServiceException( "Specified JDBC Driver " + driverClassName + " could not be loaded", e );
        }
    }

    try {
        return (Driver) Class.forName( driverClassName ).newInstance();
    }
    catch ( Exception e1 ) {
        try{
            return (Driver) ReflectHelper.classForName( driverClassName ).newInstance();
        }
        catch ( Exception e2 ) {
            throw new ServiceException( "Specified JDBC Driver " + driverClassName + " could not be loaded", e2 );
        }
    }
}
项目:lams    文件:ConfigLoader.java   
public JaxbHibernateConfiguration loadConfigXmlResource(String cfgXmlResourceName) {
    final InputStream stream = bootstrapServiceRegistry.getService( ClassLoaderService.class ).locateResourceStream( cfgXmlResourceName );
    if ( stream == null ) {
        throw new ConfigurationException( "Could not locate cfg.xml resource [" + cfgXmlResourceName + "]" );
    }
    return jaxbProcessorHolder.getValue().unmarshal( stream, new Origin( SourceType.RESOURCE, cfgXmlResourceName ) );
}
项目:lams    文件:SessionFactoryImpl.java   
private CurrentSessionContext buildCurrentSessionContext() {
    String impl = properties.getProperty( Environment.CURRENT_SESSION_CONTEXT_CLASS );
    // for backward-compatibility
    if ( impl == null ) {
        if ( canAccessTransactionManager() ) {
            impl = "jta";
        }
        else {
            return null;
        }
    }

    if ( "jta".equals( impl ) ) {
        if ( ! transactionFactory().compatibleWithJtaSynchronization() ) {
            LOG.autoFlushWillNotWork();
        }
        return new JTASessionContext( this );
    }
    else if ( "thread".equals( impl ) ) {
        return new ThreadLocalSessionContext( this );
    }
    else if ( "managed".equals( impl ) ) {
        return new ManagedSessionContext( this );
    }
    else {
        try {
            Class implClass = serviceRegistry.getService( ClassLoaderService.class ).classForName( impl );
            return ( CurrentSessionContext ) implClass
                    .getConstructor( new Class[] { SessionFactoryImplementor.class } )
                    .newInstance( this );
        }
        catch( Throwable t ) {
            LOG.unableToConstructCurrentSessionContext( impl, t );
            return null;
        }
    }
}
项目:lams    文件:StandardServiceRegistryBuilder.java   
private void applyServiceContributors() {
    final LinkedHashSet<ServiceContributor> serviceContributors =
            bootstrapServiceRegistry.getService( ClassLoaderService.class )
                    .loadJavaServices( ServiceContributor.class );

    for ( ServiceContributor serviceContributor : serviceContributors ) {
        serviceContributor.contribute( this );
    }
}
项目:lams    文件:BootstrapServiceRegistryImpl.java   
@Override
@SuppressWarnings( {"unchecked"})
public <R extends Service> ServiceBinding<R> locateServiceBinding(Class<R> serviceRole) {
    if ( ClassLoaderService.class.equals( serviceRole ) ) {
        return (ServiceBinding<R>) classLoaderServiceBinding;
    }
    else if ( StrategySelector.class.equals( serviceRole) ) {
        return (ServiceBinding<R>) strategySelectorBinding;
    }
    else if ( IntegratorService.class.equals( serviceRole ) ) {
        return (ServiceBinding<R>) integratorServiceBinding;
    }

    return null;
}
项目:cibet    文件:CibetIntegrator.java   
@Override
public void integrate(Configuration configuration, SessionFactoryImplementor sessionFactory,
      SessionFactoryServiceRegistry serviceRegistry) {
   log.info("start CibetIntegrator");
   final boolean autoRegister = ConfigurationHelper.getBoolean(AUTO_REGISTER, configuration.getProperties(), true);
   if (autoRegister) {
      log.debug("Skipping Cibet Envers listener auto registration");
      return;
   }

   log.info("CibetIntegrator registers Cibet Envers listeners");

   EventListenerRegistry listenerRegistry = serviceRegistry.getService(EventListenerRegistry.class);
   listenerRegistry.addDuplicationStrategy(EnversListenerDuplicationStrategy.INSTANCE);

   enversConfiguration = AuditConfiguration.getFor(configuration,
         serviceRegistry.getService(ClassLoaderService.class));

   if (enversConfiguration.getEntCfg().hasAuditedEntities()) {
      listenerRegistry.appendListeners(EventType.POST_DELETE, new CibetPostDeleteEventListener(enversConfiguration));
      listenerRegistry.appendListeners(EventType.POST_INSERT, new CibetPostInsertEventListener(enversConfiguration));
      listenerRegistry.appendListeners(EventType.POST_UPDATE, new CibetPostUpdateEventListener(enversConfiguration));
      listenerRegistry.appendListeners(EventType.POST_COLLECTION_RECREATE,
            new CibetPostCollectionRecreateEventListener(enversConfiguration));
      listenerRegistry.appendListeners(EventType.PRE_COLLECTION_REMOVE,
            new CibetPreCollectionRemoveEventListener(enversConfiguration));
      listenerRegistry.appendListeners(EventType.PRE_COLLECTION_UPDATE,
            new CibetPreCollectionUpdateEventListener(enversConfiguration));
   }
}
项目:UMLS-Terminology-Server    文件:TermServerEnversIntegrator.java   
@Override
public void integrate(Configuration configuration,
  SessionFactoryImplementor sessionFactory,
  SessionFactoryServiceRegistry serviceRegistry) {

  // Avoid custom behavior is autoregister is true
  try {
    if (!"true".equals(ConfigUtility.getConfigProperties()
        .getProperty("hibernate.listeners.envers.autoRegister"))) {

      super.integrate(configuration, sessionFactory, serviceRegistry);

      final AuditConfiguration enversConfiguration =
          AuditConfiguration.getFor(configuration,
              serviceRegistry.getService(ClassLoaderService.class));
      EventListenerRegistry listenerRegistry =
          serviceRegistry.getService(EventListenerRegistry.class);

      listenerRegistry
          .addDuplicationStrategy(EnversListenerDuplicationStrategy.INSTANCE);

      if (enversConfiguration.getEntCfg().hasAuditedEntities()) {
        listenerRegistry.appendListeners(EventType.POST_INSERT,
            new EmptyEnversPostInsertEventListenerImpl(enversConfiguration));
        listenerRegistry.appendListeners(EventType.POST_DELETE,
            new CustomEnversPostDeleteEventListenerImpl(enversConfiguration));
      }
    }
  } catch (Exception e) {
    throw new RuntimeException(e);
  }

}
项目:spletne-seje    文件:HibernateUtil.java   
public HibernateUtil(ArgumentParser argumentParser, WebLogParser logParser) throws ExceptionInInitializerError, IOException, CannotCompileException, NotFoundException {
    try {
        /** Izbrisemo razrede, ki jih je uprabnik podal za ignoriranje */
        List<LogFieldType> list = logParser.getFieldType();
        if (logParser.getIgnoreFieldTypes() != null) {
            list.removeAll(logParser.getIgnoreFieldTypes());
        }
        /** Inicializacija ClassLoaderja */
        this.loader = initClassLoader(argumentParser);
        /** Nastavi dodatne lastnosti za Hibernate */
        Properties props = initProperties(argumentParser);
        /** Nastavi nastavitve za Hibernate */
        serviceRegistry = new StandardServiceRegistryBuilder()
                /** Dodaj nov ClassLoader Hibernatu */
                .addService(ClassLoaderService.class, new ClassLoaderServiceImpl(loader))
                /** Podaj nastavitve za Hibernate */
                .applySettings(props)
                .build();
        /** Posreduj potrebene razrede za izdelavo in delovanje podatkovne baze Hibernatu */
        MetadataSources sources = new MetadataSources(serviceRegistry);
        for (Class c : initClasses(list, loader)) {
            sources.addAnnotatedClass(c);
        }
        /** Izdelaj podatkovno bazo */
        factory = sources.buildMetadata().buildSessionFactory();
    } catch (Exception e) {
        StandardServiceRegistryBuilder.destroy(serviceRegistry);
        throw new ExceptionInInitializerError(e);
    }
}
项目:lams    文件:MetadataSources.java   
private ClassLoaderService classLoaderService() {
    return serviceRegistry.getService( ClassLoaderService.class );
}
项目:lams    文件:HibernateMappingProcessor.java   
@Override
public ClassLoaderService initialize() {
    return metadata.getServiceRegistry().getService( ClassLoaderService.class );
}
项目:lams    文件:MetadataImpl.java   
public MetadataImpl(MetadataSources metadataSources, Options options) {
    this.serviceRegistry =  options.getServiceRegistry();
    this.options = options;
    this.identifierGeneratorFactory = serviceRegistry.getService( MutableIdentifierGeneratorFactory.class );
            //new DefaultIdentifierGeneratorFactory( dialect );
    this.database = new Database( options );

    this.mappingDefaults = new MappingDefaultsImpl();

    final MetadataSourceProcessor[] metadataSourceProcessors;
    if ( options.getMetadataSourceProcessingOrder() == MetadataSourceProcessingOrder.HBM_FIRST ) {
        metadataSourceProcessors = new MetadataSourceProcessor[] {
                new HbmMetadataSourceProcessorImpl( this ),
                new AnnotationMetadataSourceProcessorImpl( this )
        };
    }
    else {
        metadataSourceProcessors = new MetadataSourceProcessor[] {
                new AnnotationMetadataSourceProcessorImpl( this ),
                new HbmMetadataSourceProcessorImpl( this )
        };
    }

    this.classLoaderService = new ValueHolder<ClassLoaderService>(
            new ValueHolder.DeferredInitializer<ClassLoaderService>() {
                @Override
                public ClassLoaderService initialize() {
                    return serviceRegistry.getService( ClassLoaderService.class );
                }
            }
    );
    this.persisterClassResolverService = new ValueHolder<PersisterClassResolver>(
            new ValueHolder.DeferredInitializer<PersisterClassResolver>() {
                @Override
                public PersisterClassResolver initialize() {
                    return serviceRegistry.getService( PersisterClassResolver.class );
                }
            }
    );


    final ArrayList<String> processedEntityNames = new ArrayList<String>();

    prepare( metadataSourceProcessors, metadataSources );
    bindIndependentMetadata( metadataSourceProcessors, metadataSources );
    bindTypeDependentMetadata( metadataSourceProcessors, metadataSources );
    bindMappingMetadata( metadataSourceProcessors, metadataSources, processedEntityNames );
    bindMappingDependentMetadata( metadataSourceProcessors, metadataSources );

    // todo : remove this by coordinated ordering of entity processing
    new AssociationResolver( this ).resolve();
    new HibernateTypeResolver( this ).resolve();
    // IdentifierGeneratorResolver.resolve() must execute after AttributeTypeResolver.resolve()
    new IdentifierGeneratorResolver( this ).resolve();
}
项目:lams    文件:MetadataImpl.java   
private ClassLoaderService classLoaderService() {
    return classLoaderService.getValue();
}
项目:lams    文件:IndexBuilder.java   
ClassInfo createClassInfo(String className) {
    if ( StringHelper.isEmpty( className ) ) {
        throw new AssertionFailure( "Class Name used to create ClassInfo is empty." );
    }
    DotName classDotName = DotName.createSimple( className );
    if ( classes.containsKey( classDotName ) ) {
        //classInfoAnnotationsMap.put( classDotName, new HashMap<DotName, List<AnnotationInstance>>(classes.get( classDotName ).annotations()) );
        return classes.get( classDotName );
    }
    Class clazz = serviceRegistry.getService( ClassLoaderService.class ).classForName( className );
    DotName superName = null;
    DotName[] interfaces = null;
    short access_flag;
    ClassInfo annClassInfo = index.getClassByName( classDotName );
    if ( annClassInfo != null ) {
        superName = annClassInfo.superName();
        interfaces = annClassInfo.interfaces();
        access_flag = annClassInfo.flags();
    }
    else {
        Class superClass = clazz.getSuperclass();
        if ( superClass != null ) {
            superName = DotName.createSimple( superClass.getName() );
        }
        Class[] classInterfaces = clazz.getInterfaces();
        if ( classInterfaces != null && classInterfaces.length > 0 ) {
            interfaces = new DotName[classInterfaces.length];
            for ( int i = 0; i < classInterfaces.length; i++ ) {
                interfaces[i] = DotName.createSimple( classInterfaces[i].getName() );
            }
        }
        access_flag = (short) ( clazz.getModifiers() | 0x20 );//(modifiers | ACC_SUPER)
    }
    Map<DotName, List<AnnotationInstance>> map = new HashMap<DotName, List<AnnotationInstance>>();
    classInfoAnnotationsMap.put( classDotName, map );
    ClassInfo classInfo = ClassInfo.create(
            classDotName, superName, access_flag, interfaces, map
    );
    classes.put( classDotName, classInfo );
    addSubClasses( superName, classInfo );
    addImplementors( interfaces, classInfo );
    return classInfo;
}
项目:lams    文件:MockHelper.java   
private static Type getType(String className, ServiceRegistry serviceRegistry) {
    return getType( serviceRegistry.getService( ClassLoaderService.class ).classForName( className ) );
}
项目:lams    文件:PersisterFactoryInitiator.java   
private Class<? extends PersisterFactory> locate(ServiceRegistryImplementor registry, String className) {
    return registry.getService( ClassLoaderService.class ).classForName( className );
}
项目:lams    文件:PersisterClassResolverInitiator.java   
private Class<? extends PersisterClassResolver> locate(ServiceRegistryImplementor registry, String className) {
    return registry.getService( ClassLoaderService.class ).classForName( className );
}