org.hibernate.service.spi.SessionFactoryServiceRegistry Java Examples
The following examples show how to use
org.hibernate.service.spi.SessionFactoryServiceRegistry.
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: ReactiveIntegrator.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 6 votes |
private void attachEventContextManagingListenersIfRequired(SessionFactoryServiceRegistry serviceRegistry) { if ( ReactiveModeCheck.isReactiveRegistry( serviceRegistry ) ) { CoreLogging.messageLogger(ReactiveIntegrator.class).info("HRX000001: Hibernate Reactive Preview"); EventListenerRegistry eventListenerRegistry = serviceRegistry.getService( EventListenerRegistry.class ); eventListenerRegistry.addDuplicationStrategy( ReplacementDuplicationStrategy.INSTANCE ); eventListenerRegistry.getEventListenerGroup( EventType.AUTO_FLUSH ).appendListener( new DefaultReactiveAutoFlushEventListener() ); eventListenerRegistry.getEventListenerGroup( EventType.FLUSH ).appendListener( new DefaultReactiveFlushEventListener() ); eventListenerRegistry.getEventListenerGroup( EventType.FLUSH_ENTITY ).appendListener( new DefaultReactiveFlushEntityEventListener() ); eventListenerRegistry.getEventListenerGroup( EventType.PERSIST ).appendListener( new DefaultReactivePersistEventListener() ); eventListenerRegistry.getEventListenerGroup( EventType.PERSIST_ONFLUSH ).appendListener( new DefaultReactivePersistOnFlushEventListener() ); eventListenerRegistry.getEventListenerGroup( EventType.MERGE ).appendListener( new DefaultReactiveMergeEventListener() ); eventListenerRegistry.getEventListenerGroup( EventType.DELETE ).appendListener( new DefaultReactiveDeleteEventListener() ); eventListenerRegistry.getEventListenerGroup( EventType.REFRESH ).appendListener( new DefaultReactiveRefreshEventListener() ); eventListenerRegistry.getEventListenerGroup( EventType.LOCK ).appendListener( new DefaultReactiveLockEventListener() ); eventListenerRegistry.getEventListenerGroup( EventType.LOAD ).appendListener( new DefaultReactiveLoadEventListener() ); eventListenerRegistry.getEventListenerGroup( EventType.INIT_COLLECTION ).appendListener( new DefaultReactiveInitializeCollectionEventListener() ); } }
Example #2
Source File: ClassImportIntegrator.java From hibernate-types with Apache License 2.0 | 6 votes |
/** * Register the provided classes by their simple name or relative package and class name. * * @param metadata metadata * @param sessionFactory Hibernate session factory * @param serviceRegistry Hibernate service registry */ @Override public void integrate( Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { for(Class classImport : classImportList) { String key; if(excludedPath != null) { key = classImport.getName().replace(excludedPath, ""); } else { key = classImport.getSimpleName(); } metadata.getImports().put( key, classImport.getName() ); } }
Example #3
Source File: ClassImportIntegrator.java From hibernate-types with Apache License 2.0 | 6 votes |
/** * Register the provided classes by their simple name or relative package and class name. * * @param metadata metadata * @param sessionFactory Hibernate session factory * @param serviceRegistry Hibernate service registry */ @Override public void integrate( Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { for(Class classImport : classImportList) { String key; if(excludedPath != null) { key = classImport.getName().replace(excludedPath, ""); } else { key = classImport.getSimpleName(); } metadata.getImports().put( key, classImport.getName() ); } }
Example #4
Source File: SessionFactoryImpl.java From lams with GNU General Public License v2.0 | 5 votes |
private void applyCfgXmlValues(LoadedConfig aggregatedConfig, SessionFactoryServiceRegistry serviceRegistry) { final JaccService jaccService = serviceRegistry.getService( JaccService.class ); if ( jaccService.getContextId() != null ) { final JaccPermissionDeclarations permissions = aggregatedConfig.getJaccPermissions( jaccService.getContextId() ); if ( permissions != null ) { for ( GrantedPermission grantedPermission : permissions.getPermissionDeclarations() ) { jaccService.addPermission( grantedPermission ); } } } if ( aggregatedConfig.getEventListenerMap() != null ) { final ClassLoaderService cls = serviceRegistry.getService( ClassLoaderService.class ); final EventListenerRegistry eventListenerRegistry = serviceRegistry.getService( EventListenerRegistry.class ); for ( Map.Entry<EventType, Set<String>> entry : aggregatedConfig.getEventListenerMap().entrySet() ) { final EventListenerGroup group = eventListenerRegistry.getEventListenerGroup( entry.getKey() ); for ( String listenerClassName : entry.getValue() ) { try { group.appendListener( cls.classForName( listenerClassName ).newInstance() ); } catch (Exception e) { throw new ConfigurationException( "Unable to instantiate event listener class : " + listenerClassName, e ); } } } } }
Example #5
Source File: OptimisticLockingChildUpdatesRootVersionTest.java From high-performance-java-persistence with Apache License 2.0 | 5 votes |
@Override public void integrate( Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { final EventListenerRegistry eventListenerRegistry = serviceRegistry.getService( EventListenerRegistry.class ); eventListenerRegistry.appendListeners(EventType.PERSIST, RootAwareInsertEventListener.INSTANCE); eventListenerRegistry.appendListeners(EventType.FLUSH_ENTITY, RootAwareUpdateAndDeleteEventListener.INSTANCE); }
Example #6
Source File: OptimisticLockingBidirectionalChildUpdatesRootVersionTest.java From high-performance-java-persistence with Apache License 2.0 | 5 votes |
@Override public void integrate( Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { final EventListenerRegistry eventListenerRegistry = serviceRegistry.getService( EventListenerRegistry.class ); eventListenerRegistry.appendListeners( EventType.PERSIST, RootAwareInsertEventListener.INSTANCE); eventListenerRegistry.appendListeners( EventType.FLUSH_ENTITY, RootAwareUpdateAndDeleteEventListener.INSTANCE); }
Example #7
Source File: EntityReplicationTest.java From high-performance-java-persistence with Apache License 2.0 | 5 votes |
@Override public void integrate( Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { final EventListenerRegistry eventListenerRegistry = serviceRegistry.getService(EventListenerRegistry.class); eventListenerRegistry.appendListeners(EventType.POST_INSERT, ReplicationInsertEventListener.INSTANCE); eventListenerRegistry.appendListeners(EventType.POST_UPDATE, ReplicationUpdateEventListener.INSTANCE); eventListenerRegistry.appendListeners(EventType.PRE_DELETE, ReplicationDeleteEventListener.INSTANCE); }
Example #8
Source File: CollectionCacheInvalidator.java From lams with GNU General Public License v2.0 | 5 votes |
private void integrate(SessionFactoryServiceRegistry serviceRegistry, SessionFactoryImplementor sessionFactory) { if ( !sessionFactory.getSessionFactoryOptions().isAutoEvictCollectionCache() ) { // feature is disabled return; } if ( !sessionFactory.getSessionFactoryOptions().isSecondLevelCacheEnabled() ) { // Nothing to do, if caching is disabled return; } EventListenerRegistry eventListenerRegistry = serviceRegistry.getService( EventListenerRegistry.class ); eventListenerRegistry.appendListeners( EventType.POST_INSERT, this ); eventListenerRegistry.appendListeners( EventType.POST_DELETE, this ); eventListenerRegistry.appendListeners( EventType.POST_UPDATE, this ); }
Example #9
Source File: EventListenerIntegrator.java From high-performance-java-persistence with Apache License 2.0 | 5 votes |
@Override public void integrate( Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { final EventListenerRegistry eventListenerRegistry = serviceRegistry.getService(EventListenerRegistry.class); eventListenerRegistry.appendListeners( EventType.POST_LOAD, AuditLogPostLoadEventListener.INSTANCE ); }
Example #10
Source File: JaccIntegrator.java From lams with GNU General Public License v2.0 | 5 votes |
private void doIntegration( Map properties, JaccPermissionDeclarations permissionDeclarations, SessionFactoryServiceRegistry serviceRegistry) { boolean isSecurityEnabled = properties.containsKey( AvailableSettings.JACC_ENABLED ); if ( ! isSecurityEnabled ) { log.debug( "Skipping JACC integration as it was not enabled" ); return; } final String contextId = (String) properties.get( AvailableSettings.JACC_CONTEXT_ID ); if ( contextId == null ) { throw new IntegrationException( "JACC context id must be specified" ); } final JaccService jaccService = serviceRegistry.getService( JaccService.class ); if ( jaccService == null ) { throw new IntegrationException( "JaccService was not set up" ); } if ( permissionDeclarations != null ) { for ( GrantedPermission declaration : permissionDeclarations.getPermissionDeclarations() ) { jaccService.addPermission( declaration ); } } final EventListenerRegistry eventListenerRegistry = serviceRegistry.getService( EventListenerRegistry.class ); eventListenerRegistry.addDuplicationStrategy( DUPLICATION_STRATEGY ); eventListenerRegistry.prependListeners( EventType.PRE_DELETE, new JaccPreDeleteEventListener() ); eventListenerRegistry.prependListeners( EventType.PRE_INSERT, new JaccPreInsertEventListener() ); eventListenerRegistry.prependListeners( EventType.PRE_UPDATE, new JaccPreUpdateEventListener() ); eventListenerRegistry.prependListeners( EventType.PRE_LOAD, new JaccPreLoadEventListener() ); }
Example #11
Source File: JaccIntegrator.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void integrate( Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { doIntegration( serviceRegistry.getService( ConfigurationService.class ).getSettings(), // pass no permissions here, because atm actually injecting the // permissions into the JaccService is handled on SessionFactoryImpl via // the org.hibernate.boot.cfgxml.spi.CfgXmlAccessService null, serviceRegistry ); }
Example #12
Source File: SessionFactoryServiceRegistryFactoryImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public SessionFactoryServiceRegistry buildServiceRegistry( SessionFactoryImplementor sessionFactory, BootstrapContext bootstrapContext, SessionFactoryOptions options) { final ClassLoaderService cls = options.getServiceRegistry().getService( ClassLoaderService.class ); final SessionFactoryServiceRegistryBuilderImpl builder = new SessionFactoryServiceRegistryBuilderImpl( theBasicServiceRegistry ); for ( SessionFactoryServiceContributor contributor : cls.loadJavaServices( SessionFactoryServiceContributor.class ) ) { contributor.contribute( builder ); } return builder.buildSessionFactoryServiceRegistry( sessionFactory, bootstrapContext, options ); }
Example #13
Source File: SessionFactoryServiceRegistryBuilderImpl.java From lams with GNU General Public License v2.0 | 5 votes |
public SessionFactoryServiceRegistry buildSessionFactoryServiceRegistry( SessionFactoryImplementor sessionFactory, BootstrapContext bootstrapContext, SessionFactoryOptions options) { return new SessionFactoryServiceRegistryImpl( parent, initiators, providedServices, sessionFactory, bootstrapContext, options ); }
Example #14
Source File: MetadataExtractorIntegrator.java From high-performance-java-persistence with Apache License 2.0 | 5 votes |
@Override public void integrate( Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { this.database = metadata.getDatabase(); this.metadata = metadata; }
Example #15
Source File: AbstractUserTypeHibernateIntegrator.java From jadira with Apache License 2.0 | 5 votes |
public void integrate(Configuration configuration, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { try { ConfigurationHelper.setCurrentSessionFactory(sessionFactory); String isEnabled = configuration.getProperty(REGISTER_USERTYPES_KEY); String javaZone = configuration.getProperty(DEFAULT_JAVAZONE_KEY); String databaseZone = configuration.getProperty(DEFAULT_DATABASEZONE_KEY); String seed = configuration.getProperty(DEFAULT_SEED_KEY); String currencyCode = configuration.getProperty(DEFAULT_CURRENCYCODE_KEY); String jdbc42Apis = configuration.getProperty(JDBC42_API_KEY); configureDefaultProperties(sessionFactory, javaZone, databaseZone, seed, currencyCode, jdbc42Apis); if (isEnabled != null && Boolean.valueOf(isEnabled)) { autoRegisterUsertypes(configuration); } final boolean use42Api = use42Api(configuration.getProperty(JDBC42_API_KEY), sessionFactory); ConfigurationHelper.setUse42Api(sessionFactory, use42Api); // doIntegrate(configuration, sessionFactory, serviceRegistry); } finally { ConfigurationHelper.setCurrentSessionFactory(null); } }
Example #16
Source File: ReactiveIntegrator.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void integrate( Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { attachEventContextManagingListenersIfRequired( serviceRegistry ); }
Example #17
Source File: ReactiveIntegrator.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void disintegrate( SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { }
Example #18
Source File: MetadataExtractorIntegrator.java From high-performance-java-persistence with Apache License 2.0 | 4 votes |
@Override public void disintegrate( SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { }
Example #19
Source File: EventListenerIntegrator.java From high-performance-java-persistence with Apache License 2.0 | 4 votes |
@Override public void disintegrate( SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { }
Example #20
Source File: TestIntegrator.java From hibernate-demos with Apache License 2.0 | 4 votes |
@Override public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { System.out.println("Integrator#integrate"); }
Example #21
Source File: EntityReplicationTest.java From high-performance-java-persistence with Apache License 2.0 | 4 votes |
@Override public void disintegrate( SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { }
Example #22
Source File: TestIntegrator.java From hibernate-demos with Apache License 2.0 | 4 votes |
@Override public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { System.out.println("Integrator#disintegrate"); }
Example #23
Source File: TestIntegrator.java From hibernate-demos with Apache License 2.0 | 4 votes |
@Override public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { System.out.println("Integrator#integrate"); }
Example #24
Source File: TestIntegrator.java From hibernate-demos with Apache License 2.0 | 4 votes |
@Override public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { System.out.println("Integrator#disintegrate"); }
Example #25
Source File: OptimisticLockingBidirectionalChildUpdatesRootVersionTest.java From high-performance-java-persistence with Apache License 2.0 | 4 votes |
@Override public void disintegrate( SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { }
Example #26
Source File: AbstractUserTypeHibernateIntegrator.java From jadira with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { ConfigurationHelper.configureDefaultProperties(sessionFactory, null); }
Example #27
Source File: EventListenerIntegrator.java From gorm-hibernate5 with Apache License 2.0 | 4 votes |
public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { // nothing to do }
Example #28
Source File: ClassImportIntegrator.java From hibernate-types with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public void disintegrate( SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {}
Example #29
Source File: ClassImportIntegrator.java From hibernate-types with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public void disintegrate( SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {}
Example #30
Source File: CollectionCacheInvalidator.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { }