@Override public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { EventListenerRegistry service = serviceRegistry.getService(org.hibernate.event.service.spi.EventListenerRegistry.class); StandardPBEStringEncryptor encrypt = new StandardPBEStringEncryptor(); encrypt.setPassword("test_password"); RenderedMessageEncryptEventListener encryptListener = new RenderedMessageEncryptEventListener(); encryptListener.setStringEncryptor(encrypt); RenderedMessageDecryptEventListener decryptListener = new RenderedMessageDecryptEventListener(); decryptListener.setStringEncryptor(encrypt); FullTextIndexEventListener fullTextListener = new FullTextIndexEventListener(); service.appendListeners(EventType.PRE_UPDATE, encryptListener); service.prependListeners(EventType.POST_UPDATE, decryptListener); service.appendListeners(EventType.PRE_INSERT, encryptListener); service.prependListeners(EventType.POST_INSERT, decryptListener); service.appendListeners(EventType.POST_LOAD, decryptListener); }
public void integrate(Configuration configuration, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { System.out.println("Integrating......"); //final AuditService auditService = serviceRegistry.getService(AuditService.class); final AuditService auditService = new AuditServiceImpl(); auditService.init(); if (!auditService.isInitialized()) { throw new InitializationException( "Audit4j hibernate integration can not be initialized.."); } // Register listeners.. final EventListenerRegistry listenerRegistry = serviceRegistry .getService(EventListenerRegistry.class); listenerRegistry.appendListeners(EventType.POST_INSERT, new AuditPostInsertEventListenerImpl(auditService)); listenerRegistry.appendListeners(EventType.POST_UPDATE, new AuditPostUpdateEventListenerImpl(auditService)); listenerRegistry.appendListeners(EventType.POST_DELETE, new AuditPostDeleteEventListenerImpl(auditService)); }
@Override public void integrate( Configuration configuration, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { doIntegration( configuration.getProperties(), configuration.getJaccPermissionDeclarations(), serviceRegistry ); }
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() ); }
@Override public void integrate( MetadataImplementor metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { doIntegration( sessionFactory.getProperties(), null, serviceRegistry ); }
private void integrate(SessionFactoryServiceRegistry serviceRegistry, SessionFactoryImplementor sessionFactory) { if ( !sessionFactory.getSettings().isAutoEvictCollectionCache() ) { // feature is disabled return; } if ( !sessionFactory.getSettings().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 ); }
@Override public void integrate(Configuration configuration, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { log.info("start CibetIntegrator"); final boolean autoRegister = ConfigurationHelper.getBoolean(AUTO_REGISTER, configuration.getProperties(), true); if (autoRegister) { log.debug("Skipping Cibet Envers listener auto registration"); return; } log.info("CibetIntegrator registers Cibet Envers listeners"); EventListenerRegistry listenerRegistry = serviceRegistry.getService(EventListenerRegistry.class); listenerRegistry.addDuplicationStrategy(EnversListenerDuplicationStrategy.INSTANCE); enversConfiguration = AuditConfiguration.getFor(configuration, serviceRegistry.getService(ClassLoaderService.class)); if (enversConfiguration.getEntCfg().hasAuditedEntities()) { listenerRegistry.appendListeners(EventType.POST_DELETE, new CibetPostDeleteEventListener(enversConfiguration)); listenerRegistry.appendListeners(EventType.POST_INSERT, new CibetPostInsertEventListener(enversConfiguration)); listenerRegistry.appendListeners(EventType.POST_UPDATE, new CibetPostUpdateEventListener(enversConfiguration)); listenerRegistry.appendListeners(EventType.POST_COLLECTION_RECREATE, new CibetPostCollectionRecreateEventListener(enversConfiguration)); listenerRegistry.appendListeners(EventType.PRE_COLLECTION_REMOVE, new CibetPreCollectionRemoveEventListener(enversConfiguration)); listenerRegistry.appendListeners(EventType.PRE_COLLECTION_UPDATE, new CibetPreCollectionUpdateEventListener(enversConfiguration)); } }
@Override public void integrate( Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry ) { final EventListenerRegistry registry = serviceRegistry.getService( EventListenerRegistry.class ); DeletedObjectPostDeleteEventListener listener = new DeletedObjectPostDeleteEventListener(); registry.appendListeners( EventType.POST_DELETE, listener ); }
@Override public void integrate(Configuration configuration, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { // Avoid custom behavior is autoregister is true try { if (!"true".equals(ConfigUtility.getConfigProperties() .getProperty("hibernate.listeners.envers.autoRegister"))) { super.integrate(configuration, sessionFactory, serviceRegistry); final AuditConfiguration enversConfiguration = AuditConfiguration.getFor(configuration, serviceRegistry.getService(ClassLoaderService.class)); EventListenerRegistry listenerRegistry = serviceRegistry.getService(EventListenerRegistry.class); listenerRegistry .addDuplicationStrategy(EnversListenerDuplicationStrategy.INSTANCE); if (enversConfiguration.getEntCfg().hasAuditedEntities()) { listenerRegistry.appendListeners(EventType.POST_INSERT, new EmptyEnversPostInsertEventListenerImpl(enversConfiguration)); listenerRegistry.appendListeners(EventType.POST_DELETE, new CustomEnversPostDeleteEventListenerImpl(enversConfiguration)); } } } catch (Exception e) { throw new RuntimeException(e); } }
@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); }
@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); }
@Override public void integrate( Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { this.database = metadata.getDatabase(); this.metadata = metadata; }
/** * Appends the {@link LifecyclePostLoadEventListener}. * <p> * {@inheritDoc} */ @Override public void integrate(Configuration configuration, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { serviceRegistry.getService(EventListenerRegistry.class) .getEventListenerGroup(EventType.POST_LOAD) .appendListener(postLoadListener); }
/** * Appends the {@link LifecyclePostLoadEventListener}. * <p> * {@inheritDoc} */ @Override public void integrate(MetadataImplementor metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { serviceRegistry.getService(EventListenerRegistry.class) .getEventListenerGroup(EventType.POST_LOAD) .appendListener(postLoadListener); }
/** * Do nothing. * <p> * {@inheritDoc} */ @Override public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { // Cannot un-register listener // serviceRegistry.getService(EventListenerRegistry.class) // .getEventListenerGroup(EventType.POST_LOAD) // .removeListener(postLoadListener); }
public void integrate( Configuration configuration, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { ConfigConventions configConventions = ConfigConventions.create(configuration); configConventions.validate(); MappingConventions mappingConventions = MappingConventions.create(configuration); mappingConventions.normalize(); mappingConventions.validate(); }
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); } }
@Override public void integrate( MetadataImplementor metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry ) { }
@Override public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { // nothing to do here afaik }
@Override public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { // nothing to do }
@Override public void integrate(Configuration configuration, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { integrate( serviceRegistry, sessionFactory ); }
@Override public void integrate(MetadataImplementor metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { integrate( serviceRegistry, sessionFactory ); }
@Override public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { }
@Override public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { }
@Override public void disintegrate(SessionFactoryImplementor arg0, SessionFactoryServiceRegistry arg1) { super.disintegrate(arg0, arg1); }
@Override public void integrate(MetadataImplementor arg0, SessionFactoryImplementor arg1, SessionFactoryServiceRegistry arg2) { if (enversConfiguration != null) { enversConfiguration.destroy(); } }
public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { // nothing to do }
@Override public void disintegrate( SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry ) { }
@Override public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { METADATA = metadata; }
@Override public void disintegrate( SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { }
public void disintegrate( SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { }
public void integrate( MetadataImplementor metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { }
@Override public void disintegrate(SessionFactoryImplementor sfi, SessionFactoryServiceRegistry sfsr) { }
@Override public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { System.out.println("Integrator#integrate"); }
@Override public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { System.out.println("Integrator#disintegrate"); }