HHH-10056 - Separate settings for notions of (1) disabling EnversService and (2) auto-registering Envers listeners

(cherry picked from commit 73c46e298c)
This commit is contained in:
Steve Ebersole 2015-09-02 09:05:34 -05:00
parent 5eb5ab4920
commit 38b3ed1ae9
2 changed files with 12 additions and 10 deletions

View File

@ -34,13 +34,7 @@ public interface EnversService extends Service {
* The name of the configuration setting used to control whether the Envers integration
* is enabled. Default is true
*/
public static final String INTEGRATION_ENABLED = "hibernate.integration.envers.enabled";
/**
* The name of the legacy configuration setting used to control whether auto registration
* of envers listeners should happen or not. Default is true
*/
public static final String LEGACY_AUTO_REGISTER = "hibernate.listeners.envers.autoRegister";
String INTEGRATION_ENABLED = "hibernate.integration.envers.enabled";
/**
* Is the Envers integration enabled? This is generally used as a

View File

@ -50,6 +50,8 @@ import org.jboss.logging.Logger;
public class EnversServiceImpl implements EnversService, Configurable, Stoppable {
private static final Logger log = Logger.getLogger( EnversServiceImpl.class );
private static final String LEGACY_AUTO_REGISTER = "hibernate.listeners.envers.autoRegister";
private boolean integrationEnabled;
private boolean initialized;
@ -77,9 +79,15 @@ public class EnversServiceImpl implements EnversService, Configurable, Stoppable
@Override
public void configure(Map configurationValues) {
final boolean legacySetting = ConfigurationHelper.getBoolean( LEGACY_AUTO_REGISTER, configurationValues, true );
this.integrationEnabled = ConfigurationHelper.getBoolean( INTEGRATION_ENABLED, configurationValues, legacySetting );
if ( configurationValues.containsKey( LEGACY_AUTO_REGISTER ) ) {
log.debugf(
"Encountered deprecated Envers setting [%s]; use [%s] or [%s] instead",
LEGACY_AUTO_REGISTER,
INTEGRATION_ENABLED,
EnversIntegrator.AUTO_REGISTER
);
}
this.integrationEnabled = ConfigurationHelper.getBoolean( INTEGRATION_ENABLED, configurationValues, true );
log.infof( "Envers integration enabled? : %s", integrationEnabled );
}