Java 类org.hibernate.service.spi.ServiceRegistryImplementor 实例源码

项目:lams    文件:PersisterFactoryInitiator.java   
@Override
@SuppressWarnings( {"unchecked"})
public PersisterFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
    final Object customImpl = configurationValues.get( IMPL_NAME );
    if ( customImpl == null ) {
        return new PersisterFactoryImpl();
    }

    if ( PersisterFactory.class.isInstance( customImpl ) ) {
        return (PersisterFactory) customImpl;
    }

    final Class<? extends PersisterFactory> customImplClass = Class.class.isInstance( customImpl )
            ? ( Class<? extends PersisterFactory> ) customImpl
            : locate( registry, customImpl.toString() );
    try {
        return customImplClass.newInstance();
    }
    catch (Exception e) {
        throw new ServiceException( "Could not initialize custom PersisterFactory impl [" + customImplClass.getName() + "]", e );
    }
}
项目:lams    文件:PersisterClassResolverInitiator.java   
@Override
@SuppressWarnings( {"unchecked"})
public PersisterClassResolver initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
    final Object customImpl = configurationValues.get( IMPL_NAME );
    if ( customImpl == null ) {
        return new StandardPersisterClassResolver();
    }

    if ( PersisterClassResolver.class.isInstance( customImpl ) ) {
        return (PersisterClassResolver) customImpl;
    }

    final Class<? extends PersisterClassResolver> customImplClass = Class.class.isInstance( customImpl )
            ? (Class<? extends PersisterClassResolver>) customImpl
            : locate( registry, customImpl.toString() );

    try {
        return customImplClass.newInstance();
    }
    catch (Exception e) {
        throw new ServiceException( "Could not initialize custom PersisterClassResolver impl [" + customImplClass.getName() + "]", 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    文件:SessionFactoryServiceRegistryImpl.java   
@SuppressWarnings( {"unchecked"})
public SessionFactoryServiceRegistryImpl(
        ServiceRegistryImplementor parent,
        SessionFactoryImplementor sessionFactory,
        Configuration configuration) {
    super( parent );

    this.sessionFactory = sessionFactory;
    this.configuration = configuration;
    this.metadata = null;

    // for now, just use the standard initiator list
    for ( SessionFactoryServiceInitiator initiator : StandardSessionFactoryServiceInitiators.LIST ) {
        // create the bindings up front to help identify to which registry services belong
        createServiceBinding( initiator );
    }
}
项目:lams    文件:SessionFactoryServiceRegistryImpl.java   
@SuppressWarnings( {"unchecked"})
public SessionFactoryServiceRegistryImpl(
        ServiceRegistryImplementor parent,
        SessionFactoryImplementor sessionFactory,
        MetadataImplementor metadata) {
    super( parent );

    this.sessionFactory = sessionFactory;
    this.configuration = null;
    this.metadata = metadata;

    // for now, just use the standard initiator list
    for ( SessionFactoryServiceInitiator initiator : StandardSessionFactoryServiceInitiators.LIST ) {
        // create the bindings up front to help identify to which registry services belong
        createServiceBinding( initiator );
    }
}
项目:lams    文件:AbstractServiceRegistryImpl.java   
@Override
public void deRegisterChild(ServiceRegistryImplementor child) {
    if ( childRegistries == null ) {
        throw new IllegalStateException( "No child ServiceRegistry registrations found" );
    }
    childRegistries.remove( child );
    if ( childRegistries.isEmpty() ) {
        if ( autoCloseRegistry ) {
            log.debug(
                    "Implicitly destroying ServiceRegistry on de-registration " +
                            "of all child ServiceRegistries"
            );
            destroy();
        }
        else {
            log.debug(
                    "Skipping implicitly destroying ServiceRegistry on de-registration " +
                            "of all child ServiceRegistries"
            );
        }
    }
}
项目:lams    文件:BootstrapServiceRegistryImpl.java   
@Override
public void deRegisterChild(ServiceRegistryImplementor child) {
    if ( childRegistries == null ) {
        throw new IllegalStateException( "No child ServiceRegistry registrations found" );
    }
    childRegistries.remove( child );
    if ( childRegistries.isEmpty() ) {
        if ( autoCloseRegistry ) {
            LOG.debug(
                    "Implicitly destroying Boot-strap registry on de-registration " +
                            "of all child ServiceRegistries"
            );
            destroy();
        }
        else {
            LOG.debug(
                    "Skipping implicitly destroying Boot-strap registry on de-registration " +
                            "of all child ServiceRegistries"
            );
        }
    }
}
项目:breeze.server.java    文件:HibernateMetadata.java   
/**
 * Extract the Configuration from the ServiceRegistry exposed by SessionFactoryImpl. Works in
 * Hibernate 4.3, but will probably break in a future version as they keep trying to make the
 * configuration harder to access (for some reason). Hopefully they will provide a interface to
 * get the full mapping data again.
 * 
 * @param sessionFactory
 */
Configuration getConfigurationFromRegistry(SessionFactory sessionFactory) {
    ServiceRegistryImplementor serviceRegistry = ((SessionFactoryImplementor) _sessionFactory).getServiceRegistry();

    SessionFactoryServiceRegistryImpl impl = (SessionFactoryServiceRegistryImpl) serviceRegistry;
    Configuration cfg = null;

    try {
        Field configurationField = SessionFactoryServiceRegistryImpl.class.getDeclaredField("configuration");
        configurationField.setAccessible(true);
        Object configurationObject = configurationField.get(impl);
        cfg = (Configuration) configurationObject;

    } catch (Exception e) {
        e.printStackTrace();
    }
    if (cfg == null) {
        throw new RuntimeException(
                "Unable to get the Configuration from the service registry.  Please provide the Configuration in the constructor.");
    }

    return cfg;
}
项目: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    文件:JtaPlatformResolverInitiator.java   
@Override
public JtaPlatformResolver initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
    final Object setting = configurationValues.get( AvailableSettings.JTA_PLATFORM_RESOLVER );
    final JtaPlatformResolver resolver = registry.getService( StrategySelector.class )
            .resolveStrategy( JtaPlatformResolver.class, setting );
    if ( resolver == null ) {
        log.debugf( "No JtaPlatformResolver was specified, using default [%s]", StandardJtaPlatformResolver.class.getName() );
        return StandardJtaPlatformResolver.INSTANCE;
    }
    return resolver;
}
项目:lams    文件:JtaPlatformInitiator.java   
@Override
@SuppressWarnings( {"unchecked"})
public JtaPlatform initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
    final Object setting = configurationValues.get( AvailableSettings.JTA_PLATFORM );
    final JtaPlatform platform = registry.getService( StrategySelector.class ).resolveStrategy( JtaPlatform.class, setting );
    if ( platform == null ) {
        LOG.debugf( "No JtaPlatform was specified, checking resolver" );
        return registry.getService( JtaPlatformResolver.class ).resolveJtaPlatform( configurationValues, registry );
    }
    return platform;
}
项目:lams    文件:TransactionFactoryInitiator.java   
@Override
@SuppressWarnings({"unchecked"})
public TransactionFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
    final Object strategy = configurationValues.get( AvailableSettings.TRANSACTION_STRATEGY );

    if ( strategy == null ) {
        LOG.usingDefaultTransactionStrategy();
        return new JdbcTransactionFactory();
    }

    return registry.getService( StrategySelector.class ).resolveStrategy( TransactionFactory.class, strategy );
}
项目:lams    文件:NativeQueryInterpreterInitiator.java   
@Override
public NativeQueryInterpreter initiateService(
        SessionFactoryImplementor sessionFactory,
        Configuration configuration,
        ServiceRegistryImplementor registry) {
    return NativeQueryInterpreterStandardImpl.INSTANCE;
}
项目:lams    文件:NativeQueryInterpreterInitiator.java   
@Override
public NativeQueryInterpreter initiateService(
        SessionFactoryImplementor sessionFactory,
        MetadataImplementor metadata,
        ServiceRegistryImplementor registry) {
    return NativeQueryInterpreterStandardImpl.INSTANCE;
}
项目:lams    文件:DriverManagerConnectionCreator.java   
public DriverManagerConnectionCreator(
        ServiceRegistryImplementor serviceRegistry,
        String url,
        Properties connectionProps,
        Boolean autocommit,
        Integer isolation) {
    super( serviceRegistry, url, connectionProps, autocommit, isolation );
}
项目:lams    文件:BasicConnectionCreator.java   
public BasicConnectionCreator(
        ServiceRegistryImplementor serviceRegistry,
        String url,
        Properties connectionProps,
        boolean autocommit,
        Integer isolation) {
    this.serviceRegistry = serviceRegistry;
    this.url = url;
    this.connectionProps = connectionProps;
    this.autoCommit = autocommit;
    this.isolation = isolation;
}
项目:lams    文件:DriverConnectionCreator.java   
public DriverConnectionCreator(
        Driver driver,
        ServiceRegistryImplementor serviceRegistry,
        String url,
        Properties connectionProps,
        Boolean autocommit,
        Integer isolation) {
    super( serviceRegistry, url, connectionProps, autocommit, isolation );
    this.driver = driver;
}
项目:lams    文件:DialectResolverInitiator.java   
@Override
public DialectResolver initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
    final DialectResolverSet resolver = new DialectResolverSet();

    applyCustomerResolvers( resolver, registry, configurationValues );
    resolver.addResolver(StandardDialectResolver.INSTANCE );

    return resolver;
}
项目:lams    文件:AbstractServiceRegistryImpl.java   
protected AbstractServiceRegistryImpl(
        ServiceRegistryImplementor parent,
        boolean autoCloseRegistry) {
    this.parent = parent;
    this.allowCrawling = ConfigurationHelper.getBoolean( ALLOW_CRAWLING, Environment.getProperties(), true );

    this.autoCloseRegistry = autoCloseRegistry;
    this.parent.registerChild( this );
}
项目:lams    文件:AbstractServiceRegistryImpl.java   
public AbstractServiceRegistryImpl(
        BootstrapServiceRegistry bootstrapServiceRegistry,
        boolean autoCloseRegistry) {
    if ( ! ServiceRegistryImplementor.class.isInstance( bootstrapServiceRegistry ) ) {
        throw new IllegalArgumentException( "ServiceRegistry parent needs to implement ServiceRegistryImplementor" );
    }
    this.parent = (ServiceRegistryImplementor) bootstrapServiceRegistry;
    this.allowCrawling = ConfigurationHelper.getBoolean( ALLOW_CRAWLING, Environment.getProperties(), true );

    this.autoCloseRegistry = autoCloseRegistry;
    this.parent.registerChild( this );
}
项目:lams    文件:AbstractServiceRegistryImpl.java   
@Override
public void registerChild(ServiceRegistryImplementor child) {
    if ( childRegistries == null ) {
        childRegistries = new HashSet<ServiceRegistryImplementor>();
    }
    if ( !childRegistries.add( child ) ) {
        log.warnf(
                "Child ServiceRegistry [%s] was already registered; this will end badly later...",
                child
        );
    }
}
项目:lams    文件:StatisticsInitiator.java   
@Override
public StatisticsImplementor initiateService(
        SessionFactoryImplementor sessionFactory,
        Configuration configuration,
        ServiceRegistryImplementor registry) {
    final Object configValue = configuration.getProperties().get( STATS_BUILDER );
    return initiateServiceInternal( sessionFactory, configValue, registry );
}
项目:lams    文件:StatisticsInitiator.java   
@Override
public StatisticsImplementor initiateService(
        SessionFactoryImplementor sessionFactory,
        MetadataImplementor metadata,
        ServiceRegistryImplementor registry) {
    ConfigurationService configurationService =  registry.getService( ConfigurationService.class );
    final Object configValue = configurationService.getSetting( STATS_BUILDER, null );
    return initiateServiceInternal( sessionFactory, configValue, registry );
}
项目:lams    文件:EventListenerServiceInitiator.java   
@Override
public EventListenerRegistry initiateService(
        SessionFactoryImplementor sessionFactory,
        Configuration configuration,
        ServiceRegistryImplementor registry) {
    return new EventListenerRegistryImpl();
}
项目:lams    文件:EventListenerServiceInitiator.java   
@Override
public EventListenerRegistry initiateService(
        SessionFactoryImplementor sessionFactory,
        MetadataImplementor metadata,
        ServiceRegistryImplementor registry) {
    return new EventListenerRegistryImpl();
}
项目:lams    文件:BootstrapServiceRegistryImpl.java   
@Override
public void registerChild(ServiceRegistryImplementor child) {
    if ( childRegistries == null ) {
        childRegistries = new HashSet<ServiceRegistryImplementor>();
    }
    if ( !childRegistries.add( child ) ) {
        LOG.warnf(
                "Child ServiceRegistry [%s] was already registered; this will end badly later...",
                child
        );
    }
}
项目:hibernate-ogm-ignite    文件:IgniteQueryParserServiceInitiator.java   
@Override
public QueryParserService initiateService(
        SessionFactoryImplementor sessionFactory,
        SessionFactoryOptions sessionFactoryOptions,
        ServiceRegistryImplementor registry) {
    return IgniteQueryParserService.INSTANCE;
}
项目:cutdb    文件:SchemaBasedMultiTenantConnectionProvider.java   
@Override
public void injectServices(ServiceRegistryImplementor serviceRegistry) {
    Map settings = serviceRegistry.getService(ConfigurationService.class).getSettings();
    DataSource dataSource = (DataSource) settings.get(Environment.DATASOURCE);
    datasourceConnectionProvider.setDataSource(dataSource);
    datasourceConnectionProvider.configure(settings);
    logger.debug("connection provider:{}", datasourceConnectionProvider);
}
项目:sdcct    文件:CacheRegionFactory.java   
@Override
@SuppressWarnings({ CompilerWarnings.RAWTYPES })
public CacheRegionFactory initiateService(Map configValues, ServiceRegistryImplementor serviceRegistry) {
    CacheRegionFactory service = super.initiateService(configValues, serviceRegistry);

    serviceRegistry.locateServiceBinding(RegionFactory.class).setService(service);

    return service;
}
项目:sdcct    文件:SdcctHsqlDialect.java   
@Override
@SuppressWarnings({ CompilerWarnings.RAWTYPES })
public SdcctHsqlDialectResolver initiateService(Map configValues, ServiceRegistryImplementor serviceRegistry) {
    serviceRegistry.locateServiceBinding(DialectResolver.class).setService(SdcctHsqlDialectResolver.INSTANCE);

    return SdcctHsqlDialectResolver.INSTANCE;
}
项目:jooby    文件:Hbm.java   
/**
 * Register an hibernate event listener. Listener will be created and injected by Guice.
 *
 * @param type Event type.
 * @param listenerType Listener type.
 * @return This module.
 */
@SuppressWarnings("unchecked")
public <T> Hbm onEvent(final EventType<T> type, final Class<? extends T> listenerType) {
  bindings.add(b -> {
    b.bind(listenerType).asEagerSingleton();
  });

  listeners.add((s, r) -> {
    ServiceRegistryImplementor serviceRegistry = s.getServiceRegistry();
    EventListenerRegistry service = serviceRegistry.getService(EventListenerRegistry.class);
    T listener = r.require(listenerType);
    service.appendListeners(type, listener);
  });
  return this;
}
项目:debop4j    文件:GridDatastoreConfigBase.java   
/**
 * hibernate {@link ServiceRegistryImplementor}로부터 해당 서비스를 로드합니다.
 *
 * @param serviceImpl 서비스 구현체의 타입
 * @return {@link ServiceRegistryImplementor}에 등록된 서비스
 */
protected final org.hibernate.service.Service getService(Class<? extends org.hibernate.service.Service> serviceImpl) {
    if (log.isDebugEnabled())
        log.debug("Service 를 로드합니다. serviceImpl=[{}]", serviceImpl.getName());

    SessionFactoryImplementor sessionFactory = getSessionFactoryImplementor();
    ServiceRegistryImplementor serviceRegistry = sessionFactory.getServiceRegistry();
    return serviceRegistry.getService(serviceImpl);
}
项目:hibernate-ogm-redis    文件:RedisDatastoreProvider.java   
@Override
public void injectServices(ServiceRegistryImplementor serviceRegistry) {
    this.serviceRegistry = serviceRegistry;
}
项目:lemon    文件:SessionFactoryWrapper.java   
public ServiceRegistryImplementor getServiceRegistry() {
    return sessionFactoryImplementor.getServiceRegistry();
}
项目:lams    文件:PersisterFactoryInitiator.java   
private Class<? extends PersisterFactory> locate(ServiceRegistryImplementor registry, String className) {
    return registry.getService( ClassLoaderService.class ).classForName( className );
}
项目:lams    文件:PersisterFactoryImpl.java   
@Override
public void injectServices(ServiceRegistryImplementor serviceRegistry) {
    this.serviceRegistry = serviceRegistry;
}
项目:lams    文件:PersisterClassResolverInitiator.java   
private Class<? extends PersisterClassResolver> locate(ServiceRegistryImplementor registry, String className) {
    return registry.getService( ClassLoaderService.class ).classForName( className );
}
项目:lams    文件:JmxServiceInitiator.java   
@Override
public JmxService initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
    return ConfigurationHelper.getBoolean( AvailableSettings.JMX_ENABLED, configurationValues, false )
            ? new JmxServiceImpl( configurationValues )
            : DisabledJmxServiceImpl.INSTANCE;
}
项目:lams    文件:AbstractJtaPlatform.java   
@Override
public void injectServices(ServiceRegistryImplementor serviceRegistry) {
    this.serviceRegistry = serviceRegistry;
}
项目:lams    文件:JndiServiceInitiator.java   
@Override
public JndiService initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
    return new JndiServiceImpl( configurationValues );
}