public ClassLoaderAccessImpl(ClassLoader tempClassLoader, ServiceRegistry serviceRegistry) { this( tempClassLoader, serviceRegistry.getService( ClassLoaderService.class ) ); }
/** * Retrieve a service by role. If service is not found, but a {@link org.hibernate.service.spi.ServiceInitiator} is * registered for this service role, the service will be initialized and returned. * <p/> * NOTE: We cannot return {@code <R extends Service<T>>} here because the service might come from the parent... * * @param serviceRole The service role * @param <R> The service role type * * @return The requested service . * * @throws UnknownServiceException Indicates the service was not known. * @throws NullServiceException Indicates the service was null. */ default <R extends Service> R requireService(Class<R> serviceRole) { final R service = getService( serviceRole ); if ( service == null ) { throw new NullServiceException( serviceRole ); } return service; }
@Override public void prepareServices(ServiceRegistryBuilder serviceRegistryBuilder) { serviceRegistryBuilder.addInitiator(LifecycleAwareJDBCServicesInitiator.INSTANCE); }
@Override @SuppressWarnings({"unchecked"}) public <T> T unwrap(Class<T> unwrapType) { if ( ConnectionProvider.class.equals( unwrapType ) || ProxoolConnectionProvider.class.isAssignableFrom( unwrapType ) ) { return (T) this; } else { throw new UnknownUnwrapTypeException( unwrapType ); } }
private static SessionFactory sessionFactory; private static ServiceRegistry serviceRegistry; public static SessionFactory createSessionFactory() { Configuration configuration = new Configuration(); configuration.configure(); ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings( configuration.getProperties()). buildServiceRegistry(); sessionFactory = configuration.buildSessionFactory(serviceRegistry); return sessionFactory; }
public JdbcConnectionAccessImpl(ServiceRegistry serviceRegistry) { this( serviceRegistry.getService( ConnectionProvider.class ) ); }
@Override @SuppressWarnings({ "unchecked" }) public <T> T unwrap(Class<T> unwrapType) { if ( isUnwrappableAs( unwrapType ) ) { return (T) this; } else { throw new UnknownUnwrapTypeException( unwrapType ); } }
public XmlMappingBinderAccess(ServiceRegistry serviceRegistry) { this.classLoaderService = serviceRegistry.getService( ClassLoaderService.class ); // NOTE : The boolean here indicates whether or not to perform validation as we load XML documents. // Should we expose this setting? Disabling would speed up JAXP and JAXB at runtime, but potentially // at the cost of less obvious errors when a document is not valid. this.mappingBinder = new MappingBinder( serviceRegistry.getService( ClassLoaderService.class ), true ); }
protected StrategySelector strategySelectorService() { if ( strategySelectorService == null ) { if ( serviceRegistry == null ) { throw new HibernateException( "ServiceRegistry not yet injected; PropertyAccessStrategyResolver not ready for use." ); } strategySelectorService = serviceRegistry.getService( StrategySelector.class ); } return strategySelectorService; }
private void resolveLegacyLimitHandlerBehavior(ServiceRegistry serviceRegistry) { // HHH-11194 // Temporary solution to set whether legacy limit handler behavior should be used. final ConfigurationService configurationService = serviceRegistry.getService( ConfigurationService.class ); legacyLimitHandlerBehavior = configurationService.getSetting( AvailableSettings.USE_LEGACY_LIMIT_HANDLERS, StandardConverters.BOOLEAN, false ); }
private static PropertyAccessStrategy getAccessStrategy(Class<?> cls, ServiceRegistry serviceRegistry, String accessorType) { return serviceRegistry.getService( PropertyAccessStrategyResolver.class ) .resolvePropertyAccessStrategy( cls, accessorType, null ); }
protected JndiService jndiService() { return serviceRegistry().getService( JndiService.class ); }
private ManagedBean<? extends RevisionListener> resolveRevisionListenerBean( Class<? extends RevisionListener> listenerClass, ServiceRegistry serviceRegistry) { if ( !listenerClass.equals( RevisionListener.class ) ) { return serviceRegistry.getService( ManagedBeanRegistry.class ).getBean( listenerClass ); } return null; } }
public SchemaCreatorImpl(ServiceRegistry serviceRegistry, SchemaFilter schemaFilter) { SchemaManagementTool smt = serviceRegistry.getService( SchemaManagementTool.class ); if ( smt == null || !HibernateSchemaManagementTool.class.isInstance( smt ) ) { smt = new HibernateSchemaManagementTool(); ( (HibernateSchemaManagementTool) smt ).injectServices( (ServiceRegistryImplementor) serviceRegistry ); } this.tool = (HibernateSchemaManagementTool) smt; this.schemaFilter = schemaFilter; }
public JdbcContextDelayedDropImpl(ServiceRegistry serviceRegistry) { this.serviceRegistry = serviceRegistry; this.jdbcServices = serviceRegistry.getService( JdbcServices.class ); this.jdbcConnectionAccess = jdbcServices.getBootstrapJdbcConnectionAccess(); if ( jdbcConnectionAccess == null ) { // todo : log or error? throw new SchemaManagementException( "Could not build JDBC Connection context to drop schema on SessionFactory close" ); } }
@Override protected String expectedIndexName() { if ( this.serviceRegistry.getService( JdbcServices.class ).getDialect() instanceof AbstractHANADialect ) { return "IDXinnacp0woeltj5l0k4vgabf8k"; // Non-ASCII, non-alphanumeric identifiers are quoted on HANA } else { return "IDXpm66tdjkgtsca5x2uwux487t5"; } } }
@Override protected String expectedForeignKeyName() { if ( this.serviceRegistry.getService( JdbcServices.class ).getDialect() instanceof AbstractHANADialect ) { return "FKe1lr9dd16cmmon53r7m736yev"; // Non-ASCII, non-alphanumeric identifiers are quoted on HANA } else { return "FKgvrnki5fwp3qo0hfp1bu1jj0q"; } }
@Override protected String expectedUniqueKeyName() { if ( this.serviceRegistry.getService( JdbcServices.class ).getDialect() instanceof AbstractHANADialect ) { return "UKinnacp0woeltj5l0k4vgabf8k"; // Non-ASCII, non-alphanumeric identifiers are quoted on HANA } else { return "UKpm66tdjkgtsca5x2uwux487t5"; } }
@Override public Map getConfigurationValues() { return serviceRegistry.getService( ConfigurationService.class ).getSettings(); }
private SchemaDropper getSchemaDropper() { return serviceRegistry.getService( SchemaManagementTool.class ).getSchemaDropper( null ); }