@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(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); } }
protected CibetPostDeleteEventListener(AuditConfiguration enversConfiguration) { super(enversConfiguration); }
protected CibetPostUpdateEventListener(AuditConfiguration enversConfiguration) { super(enversConfiguration); }
public CibetPostInsertEventListener(AuditConfiguration enversConfiguration) { super(enversConfiguration); log.info("register CibetPostInsertEventListener"); }
protected CibetPreCollectionUpdateEventListener(AuditConfiguration enversConfiguration) { super(enversConfiguration); }
protected CibetPreCollectionRemoveEventListener(AuditConfiguration enversConfiguration) { super(enversConfiguration); }
protected CibetPostCollectionRecreateEventListener(AuditConfiguration enversConfiguration) { super(enversConfiguration); }
/** * Instantiates a {@link CustomEnversPostDeleteEventListenerImpl} from the * specified parameters. * * @param enversConfiguration the envers configuration */ public CustomEnversPostDeleteEventListenerImpl( AuditConfiguration enversConfiguration) { super(enversConfiguration); }
/** * Instantiates a {@link EmptyEnversPostInsertEventListenerImpl} from the * specified parameters. * * @param enversConfiguration the envers configuration */ public EmptyEnversPostInsertEventListenerImpl( AuditConfiguration enversConfiguration) { super(enversConfiguration); }