org.hibernate.service.Service Java Examples
The following examples show how to use
org.hibernate.service.Service.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpannerServiceContributor.java From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void contribute(StandardServiceRegistryBuilder serviceRegistryBuilder) { serviceRegistryBuilder // The custom Hibernate schema management tool for Spanner. .addInitiator(new StandardServiceInitiator() { @Override public Service initiateService(Map configurationValues, ServiceRegistryImplementor registry) { return SCHEMA_MANAGEMENT_TOOL; } @Override public Class getServiceInitiated() { return SchemaManagementTool.class; } }) // The user agent JDBC connection property to identify the library. .applySetting("hibernate.connection.userAgent", HIBERNATE_API_CLIENT_LIB_TOKEN) // Create a unique index for a table if it does not already exist when in UPDATE mode. .applySetting( "hibernate.schema_update.unique_constraint_strategy", UniqueConstraintSchemaUpdateStrategy.RECREATE_QUIETLY) // Allows entities to be used with InheritanceType.JOINED in Spanner. .applySetting("hibernate.hql.bulk_id_strategy", InlineIdsOrClauseBulkIdStrategy.INSTANCE); }
Example #2
Source File: AbstractServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 6 votes |
private <R extends Service> R initializeService(ServiceBinding<R> serviceBinding) { if ( log.isTraceEnabled() ) { log.tracev( "Initializing service [role={0}]", serviceBinding.getServiceRole().getName() ); } // PHASE 1 : create service R service = createService( serviceBinding ); if ( service == null ) { return null; } // PHASE 2 : inject service (***potentially recursive***) serviceBinding.getLifecycleOwner().injectDependencies( serviceBinding ); // PHASE 3 : configure service serviceBinding.getLifecycleOwner().configureService( serviceBinding ); // PHASE 4 : Start service serviceBinding.getLifecycleOwner().startService( serviceBinding ); return service; }
Example #3
Source File: AbstractServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 5 votes |
protected <R extends Service> void createServiceBinding(ProvidedService<R> providedService) { ServiceBinding<R> binding = locateServiceBinding( providedService.getServiceRole(), false ); if ( binding == null ) { binding = new ServiceBinding<R>( this, providedService.getServiceRole(), providedService.getService() ); serviceBindingMap.put( providedService.getServiceRole(), binding ); } registerService( binding, providedService.getService() ); }
Example #4
Source File: BootstrapServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public <R extends Service> void stopService(ServiceBinding<R> binding) { final Service service = binding.getService(); if ( Stoppable.class.isInstance( service ) ) { try { ( (Stoppable) service ).stop(); } catch ( Exception e ) { LOG.unableToStopService( service.getClass(), e.toString() ); } } }
Example #5
Source File: AbstractServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public <R extends Service> R getService(Class<R> serviceRole) { // TODO: should an exception be thrown if active == false??? R service = serviceRole.cast( initializedServiceByRole.get( serviceRole ) ); if ( service != null ) { return service; } //Any service initialization needs synchronization synchronized ( this ) { // Check again after having acquired the lock: service = serviceRole.cast( initializedServiceByRole.get( serviceRole ) ); if ( service != null ) { return service; } final ServiceBinding<R> serviceBinding = locateServiceBinding( serviceRole ); if ( serviceBinding == null ) { throw new UnknownServiceException( serviceRole ); } service = serviceBinding.getService(); if ( service == null ) { service = initializeService( serviceBinding ); } if ( service != null ) { // add the service only after it is completely initialized initializedServiceByRole.put( serviceRole, service ); } return service; } }
Example #6
Source File: BootstrapServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@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; }
Example #7
Source File: JmxServiceImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void registerService(Manageable service, Class<? extends Service> serviceRole) { if ( OptionallyManageable.class.isInstance( service ) ) { for ( Manageable realManageable : ( (OptionallyManageable) service ).getRealManageables() ) { registerService( realManageable,serviceRole ); } return; } final String domain = service.getManagementDomain() == null ? AvailableSettings.JMX_DEFAULT_OBJ_NAME_DOMAIN : service.getManagementDomain(); final String serviceType = service.getManagementServiceType() == null ? service.getClass().getName() : service.getManagementServiceType(); try { final ObjectName objectName = new ObjectName( String.format( OBJ_NAME_TEMPLATE, domain, sessionFactoryName, serviceRole.getName(), serviceType ) ); registerMBean( objectName, service.getManagementBean() ); } catch ( MalformedObjectNameException e ) { throw new HibernateException( "Unable to generate service IbjectName", e ); } }
Example #8
Source File: AbstractServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public <R extends Service> void injectDependencies(ServiceBinding<R> serviceBinding) { final R service = serviceBinding.getService(); applyInjections( service ); if ( ServiceRegistryAwareService.class.isInstance( service ) ) { ( (ServiceRegistryAwareService) service ).injectServices( this ); } }
Example #9
Source File: AbstractServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public <R extends Service> void stopService(ServiceBinding<R> binding) { final Service service = binding.getService(); if ( Stoppable.class.isInstance( service ) ) { try { ( (Stoppable) service ).stop(); } catch ( Exception e ) { log.unableToStopService( service.getClass(), e.toString() ); } } }
Example #10
Source File: AbstractServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override @SuppressWarnings({ "unchecked" }) public <R extends Service> void startService(ServiceBinding<R> serviceBinding) { if ( Startable.class.isInstance( serviceBinding.getService() ) ) { ( (Startable) serviceBinding.getService() ).start(); } if ( Manageable.class.isInstance( serviceBinding.getService() ) ) { getService( JmxService.class ).registerService( (Manageable) serviceBinding.getService(), serviceBinding.getServiceRole() ); } }
Example #11
Source File: AbstractServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings({ "unchecked" }) private <T extends Service> void processInjection(T service, Method injectionMethod, InjectService injectService) { if ( injectionMethod.getParameterTypes() == null || injectionMethod.getParameterCount() != 1 ) { throw new ServiceDependencyException( "Encountered @InjectService on method with unexpected number of parameters" ); } Class dependentServiceRole = injectService.serviceRole(); if ( dependentServiceRole == null || dependentServiceRole.equals( Void.class ) ) { dependentServiceRole = injectionMethod.getParameterTypes()[0]; } // todo : because of the use of proxies, this is no longer returning null here... final Service dependantService = getService( dependentServiceRole ); if ( dependantService == null ) { if ( injectService.required() ) { throw new ServiceDependencyException( "Dependency [" + dependentServiceRole + "] declared by service [" + service + "] not found" ); } } else { try { injectionMethod.invoke( service, dependantService ); } catch ( Exception e ) { throw new ServiceDependencyException( "Cannot inject dependency service", e ); } } }
Example #12
Source File: AbstractServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 5 votes |
private <R extends Service> void applyInjections(R service) { try { for ( Method method : service.getClass().getMethods() ) { InjectService injectService = method.getAnnotation( InjectService.class ); if ( injectService == null ) { continue; } processInjection( service, method, injectService ); } } catch (NullPointerException e) { log.error( "NPE injecting service deps : " + service.getClass().getName() ); } }
Example #13
Source File: BootstrapServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public <R extends Service> R getService(Class<R> serviceRole) { final ServiceBinding<R> binding = locateServiceBinding( serviceRole ); return binding == null ? null : binding.getService(); }
Example #14
Source File: AbstractServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override @SuppressWarnings({ "unchecked" }) public <R extends Service> ServiceBinding<R> locateServiceBinding(Class<R> serviceRole) { return locateServiceBinding( serviceRole, true ); }
Example #15
Source File: AbstractServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings({ "unchecked" }) protected <R extends Service> ServiceBinding<R> locateServiceBinding(Class<R> serviceRole, boolean checkParent) { ServiceBinding<R> serviceBinding = serviceBindingMap.get( serviceRole ); if ( serviceBinding == null && checkParent && parent != null ) { // look in parent serviceBinding = parent.locateServiceBinding( serviceRole ); } if ( serviceBinding != null ) { return serviceBinding; } if ( !allowCrawling ) { return null; } // look for a previously resolved alternate registration final Class alternative = roleXref.get( serviceRole ); if ( alternative != null ) { return serviceBindingMap.get( alternative ); } // perform a crawl looking for an alternate registration for ( ServiceBinding binding : serviceBindingMap.values() ) { if ( serviceRole.isAssignableFrom( binding.getServiceRole() ) ) { // we found an alternate... log.alternateServiceRole( serviceRole.getName(), binding.getServiceRole().getName() ); registerAlternate( serviceRole, binding.getServiceRole() ); return binding; } if ( binding.getService() != null && serviceRole.isInstance( binding.getService() ) ) { // we found an alternate... log.alternateServiceRole( serviceRole.getName(), binding.getServiceRole().getName() ); registerAlternate( serviceRole, binding.getServiceRole() ); return binding; } } return null; }
Example #16
Source File: AbstractServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
protected <R extends Service> void registerService(ServiceBinding<R> serviceBinding, R service) { serviceBinding.setService( service ); synchronized ( serviceBindingList ) { serviceBindingList.add( serviceBinding ); } }
Example #17
Source File: AbstractServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings({ "unchecked" }) protected <R extends Service> void createServiceBinding(ServiceInitiator<R> initiator) { final ServiceBinding serviceBinding = new ServiceBinding( this, initiator ); serviceBindingMap.put( initiator.getServiceInitiated(), serviceBinding ); }
Example #18
Source File: BootstrapServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public <R extends Service> R initiateService(ServiceInitiator<R> serviceInitiator) { throw new ServiceException( "Boot-strap registry should only contain provided services" ); }
Example #19
Source File: BootstrapServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public <R extends Service> void configureService(ServiceBinding<R> binding) { throw new ServiceException( "Boot-strap registry should only contain provided services" ); }
Example #20
Source File: BootstrapServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public <R extends Service> void injectDependencies(ServiceBinding<R> binding) { throw new ServiceException( "Boot-strap registry should only contain provided services" ); }
Example #21
Source File: BootstrapServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public <R extends Service> void startService(ServiceBinding<R> binding) { throw new ServiceException( "Boot-strap registry should only contain provided services" ); }
Example #22
Source File: StandardServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public <R extends Service> R initiateService(ServiceInitiator<R> serviceInitiator) { // todo : add check/error for unexpected initiator types? return ( (StandardServiceInitiator<R>) serviceInitiator ).initiateService( configurationValues, this ); }
Example #23
Source File: StandardServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public <R extends Service> void configureService(ServiceBinding<R> serviceBinding) { if ( Configurable.class.isInstance( serviceBinding.getService() ) ) { ( (Configurable) serviceBinding.getService() ).configure( configurationValues ); } }
Example #24
Source File: TestingRegistryRule.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 4 votes |
@Override public <R extends Service> ServiceBinding<R> locateServiceBinding(Class<R> serviceRole) { return null; }
Example #25
Source File: SessionFactoryServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public <R extends Service> void configureService(ServiceBinding<R> serviceBinding) { if ( Configurable.class.isInstance( serviceBinding.getService() ) ) { ( (Configurable) serviceBinding.getService() ).configure( getService( ConfigurationService.class ).getSettings() ); } }
Example #26
Source File: SessionFactoryServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public <R extends Service> R initiateService(ServiceInitiator<R> serviceInitiator) { SessionFactoryServiceInitiator<R> sessionFactoryServiceInitiator = (SessionFactoryServiceInitiator<R>) serviceInitiator; return sessionFactoryServiceInitiator.initiateService( this ); }
Example #27
Source File: SessionFactoryServiceRegistryBuilder.java From lams with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings( {"unchecked"}) SessionFactoryServiceRegistryBuilder addService(Class serviceRole, Service service);
Example #28
Source File: TestingRegistryRule.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 4 votes |
@Override @SuppressWarnings("unchecked") public <R extends Service> R getService(Class<R> serviceRole) { if ( serviceRole == VertxInstance.class ) { return (R) vertxService; } else if ( serviceRole == JdbcEnvironment.class ) { return (R) new JdbcEnvironment() { @Override public Dialect getDialect() { return new MySQL8Dialect(); } @Override public ExtractedDatabaseMetaData getExtractedDatabaseMetaData() { return null; } @Override public Identifier getCurrentCatalog() { return null; } @Override public Identifier getCurrentSchema() { return null; } @Override public QualifiedObjectNameFormatter getQualifiedObjectNameFormatter() { return null; } @Override public IdentifierHelper getIdentifierHelper() { return null; } @Override public NameQualifierSupport getNameQualifierSupport() { return null; } @Override public SqlExceptionHelper getSqlExceptionHelper() { return null; } @Override public LobCreatorBuilder getLobCreatorBuilder() { return null; } @Override public TypeInfo getTypeInfoForJdbcCode(int jdbcTypeCode) { return null; } }; } else { throw new IllegalArgumentException( "This is a mock service - need to explicitly handle any service we might need during testing" ); } }
Example #29
Source File: RecordableBootstrap.java From quarkus with Apache License 2.0 | 4 votes |
/** * @return the list of services to get from the service registry and turn into provided services */ public List<Class<? extends Service>> getPostBuildProvidedServices() { return postBuildProvidedServices; }
Example #30
Source File: Substitute_JmxServiceImpl.java From quarkus with Apache License 2.0 | 4 votes |
@Override public void registerService(Manageable service, Class<? extends Service> serviceRole) { // no-op }