下面列出了怎么用org.hibernate.integrator.spi.IntegratorService的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* 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 )
);
}
/**
* 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
);
}
@SuppressWarnings("deprecation")
private void applyServiceContributingIntegrators() {
for ( Integrator integrator : bootstrapServiceRegistry.getService( IntegratorService.class )
.getIntegrators() ) {
if (integrator instanceof ServiceContributingIntegrator) {
((ServiceContributingIntegrator) integrator).prepareServices( this );
}
}
}
@SuppressWarnings("deprecation")
private void applyServiceContributingIntegrators() {
for ( Integrator integrator : bootstrapServiceRegistry.getService( IntegratorService.class )
.getIntegrators() ) {
if ( org.hibernate.integrator.spi.ServiceContributingIntegrator.class.isInstance( integrator ) ) {
org.hibernate.integrator.spi.ServiceContributingIntegrator.class.cast( integrator ).prepareServices(
this );
}
}
}
@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;
}
private Metadata getMetadataInternal() {
Metadata metadata = null;
ServiceRegistry bootstrapServiceRegistry = ((SessionFactoryImplementor) sessionFactory).getServiceRegistry().getParentServiceRegistry();
Iterable<Integrator> integrators = bootstrapServiceRegistry.getService(IntegratorService.class).getIntegrators();
for (Integrator integrator : integrators) {
if (integrator instanceof MetadataIntegrator) {
metadata = ((MetadataIntegrator) integrator).getMetadata();
}
}
return metadata;
}
/**
* Constructs a BootstrapServiceRegistryImpl.
*
* Do not use directly generally speaking. Use {@link org.hibernate.boot.registry.BootstrapServiceRegistryBuilder}
* instead.
*
* @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(
ClassLoaderService classLoaderService,
StrategySelector strategySelector,
IntegratorService integratorService) {
this( true, classLoaderService, strategySelector, integratorService );
}