HHH-14847 - Deprecate JMX support

This commit is contained in:
Steve Ebersole 2021-09-27 12:12:53 -05:00 committed by Sanne Grinovero
parent ba9c3201eb
commit ff4db00aec
6 changed files with 85 additions and 10 deletions

View File

@ -1903,13 +1903,6 @@ public interface AvailableSettings extends org.hibernate.jpa.AvailableSettings {
*/ */
String HBM2DDL_DEFAULT_CONSTRAINT_MODE = "hibernate.hbm2ddl.default_constraint_mode"; String HBM2DDL_DEFAULT_CONSTRAINT_MODE = "hibernate.hbm2ddl.default_constraint_mode";
String JMX_ENABLED = "hibernate.jmx.enabled";
String JMX_PLATFORM_SERVER = "hibernate.jmx.usePlatformServer";
String JMX_AGENT_ID = "hibernate.jmx.agentId";
String JMX_DOMAIN_NAME = "hibernate.jmx.defaultDomain";
String JMX_SF_NAME = "hibernate.jmx.sessionFactoryName";
String JMX_DEFAULT_OBJ_NAME_DOMAIN = "org.hibernate.core";
/** /**
* Setting to identify a {@link org.hibernate.CustomEntityDirtinessStrategy} to use. May point to * Setting to identify a {@link org.hibernate.CustomEntityDirtinessStrategy} to use. May point to
* either a class name or instance. * either a class name or instance.
@ -2471,4 +2464,42 @@ public interface AvailableSettings extends org.hibernate.jpa.AvailableSettings {
*/ */
@Deprecated @Deprecated
String JACC_ENABLED = "hibernate.jacc.enabled"; String JACC_ENABLED = "hibernate.jacc.enabled";
/**
* @deprecated Scheduled for removal in 6.0; see https://hibernate.atlassian.net/browse/HHH-14847
* and https://hibernate.atlassian.net/browse/HHH-14846
*/
@Deprecated
String JMX_ENABLED = "hibernate.jmx.enabled";
/**
* @deprecated Scheduled for removal in 6.0; see https://hibernate.atlassian.net/browse/HHH-14847
* and https://hibernate.atlassian.net/browse/HHH-14846
*/
@Deprecated
String JMX_PLATFORM_SERVER = "hibernate.jmx.usePlatformServer";
/**
* @deprecated Scheduled for removal in 6.0; see https://hibernate.atlassian.net/browse/HHH-14847
* and https://hibernate.atlassian.net/browse/HHH-14846
*/
@Deprecated
String JMX_AGENT_ID = "hibernate.jmx.agentId";
/**
* @deprecated Scheduled for removal in 6.0; see https://hibernate.atlassian.net/browse/HHH-14847
* and https://hibernate.atlassian.net/browse/HHH-14846
*/
@Deprecated
String JMX_DOMAIN_NAME = "hibernate.jmx.defaultDomain";
/**
* @deprecated Scheduled for removal in 6.0; see https://hibernate.atlassian.net/browse/HHH-14847
* and https://hibernate.atlassian.net/browse/HHH-14846
*/
@Deprecated
String JMX_SF_NAME = "hibernate.jmx.sessionFactoryName";
/**
* @deprecated Scheduled for removal in 6.0; see https://hibernate.atlassian.net/browse/HHH-14847
* and https://hibernate.atlassian.net/browse/HHH-14846
*/
@Deprecated
String JMX_DEFAULT_OBJ_NAME_DOMAIN = "org.hibernate.core";
} }

View File

@ -273,4 +273,28 @@ public interface DeprecationLogger extends BasicLogger {
value = "JACC settings encountered in hibernate `cfg.xml` file. JACC integration is deprecated and will be removed in version 6.0" value = "JACC settings encountered in hibernate `cfg.xml` file. JACC integration is deprecated and will be removed in version 6.0"
) )
void deprecatedJaccCfgXmlSettings(); void deprecatedJaccCfgXmlSettings();
@LogMessage(level = WARN)
@Message(
id = 90000028,
value = "Manageable service was registered with JMX support (`%s`). JMX support is scheduled for removal in 6.0"
)
void deprecatedJmxManageableServiceRegistration(String jmxEnabledSetting);
@LogMessage(level = WARN)
@Message(
id = 90000029,
value = "JMX support has been enabled via `%s`. This feature is scheduled for removal in 6.0"
)
void deprecatedJmxSupport(String jmxEnabledSetting);
@LogMessage(level = WARN)
@Message(
id = 90000030,
value = "MBean was registered with JMX support (`%s`). JMX support is scheduled for removal in 6.0"
)
void deprecatedJmxBeanRegistration(String name);
} }

View File

@ -19,6 +19,7 @@ import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.internal.CoreLogging; import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.log.DeprecationLogger;
import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.jmx.spi.JmxService; import org.hibernate.jmx.spi.JmxService;
import org.hibernate.service.Service; import org.hibernate.service.Service;
@ -119,6 +120,12 @@ public class JmxServiceImpl implements JmxService, Stoppable {
@Override @Override
public void registerService(Manageable service, Class<? extends Service> serviceRole) { public void registerService(Manageable service, Class<? extends Service> serviceRole) {
if ( service == null ) {
return;
}
DeprecationLogger.DEPRECATION_LOGGER.deprecatedJmxManageableServiceRegistration( service.getClass().getName() );
if ( OptionallyManageable.class.isInstance( service ) ) { if ( OptionallyManageable.class.isInstance( service ) ) {
for ( Manageable realManageable : ( (OptionallyManageable) service ).getRealManageables() ) { for ( Manageable realManageable : ( (OptionallyManageable) service ).getRealManageables() ) {
registerService( realManageable,serviceRole ); registerService( realManageable,serviceRole );
@ -151,6 +158,8 @@ public class JmxServiceImpl implements JmxService, Stoppable {
@Override @Override
public void registerMBean(ObjectName objectName, Object mBean) { public void registerMBean(ObjectName objectName, Object mBean) {
DeprecationLogger.DEPRECATION_LOGGER.deprecatedJmxBeanRegistration( mBean.getClass().getName() );
MBeanServer mBeanServer = findServer(); MBeanServer mBeanServer = findServer();
if ( mBeanServer == null ) { if ( mBeanServer == null ) {
if ( startedServer ) { if ( startedServer ) {

View File

@ -10,6 +10,7 @@ import java.util.Map;
import org.hibernate.boot.registry.StandardServiceInitiator; import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.internal.log.DeprecationLogger;
import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.jmx.spi.JmxService; import org.hibernate.jmx.spi.JmxService;
import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.service.spi.ServiceRegistryImplementor;
@ -29,8 +30,10 @@ public class JmxServiceInitiator implements StandardServiceInitiator<JmxService>
@Override @Override
public JmxService initiateService(Map configurationValues, ServiceRegistryImplementor registry) { public JmxService initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
return ConfigurationHelper.getBoolean( AvailableSettings.JMX_ENABLED, configurationValues, false ) if ( ConfigurationHelper.getBoolean( AvailableSettings.JMX_ENABLED, configurationValues, false ) ) {
? new JmxServiceImpl( configurationValues ) DeprecationLogger.DEPRECATION_LOGGER.deprecatedJmxSupport( AvailableSettings.JMX_ENABLED );
: DisabledJmxServiceImpl.INSTANCE; return new JmxServiceImpl( configurationValues );
}
return DisabledJmxServiceImpl.INSTANCE;
} }
} }

View File

@ -15,7 +15,11 @@ import org.hibernate.service.spi.Manageable;
* Service providing simplified access to JMX related features needed by Hibernate. * Service providing simplified access to JMX related features needed by Hibernate.
* *
* @author Steve Ebersole * @author Steve Ebersole
*
* @deprecated Scheduled for removal in 6.0; see https://hibernate.atlassian.net/browse/HHH-14847
* and https://hibernate.atlassian.net/browse/HHH-14846
*/ */
@Deprecated
public interface JmxService extends Service { public interface JmxService extends Service {
/** /**
* Handles registration of a manageable service. * Handles registration of a manageable service.

View File

@ -10,7 +10,11 @@ package org.hibernate.service.spi;
* Optional {@link org.hibernate.service.Service} contract for services which can be managed in JMX * Optional {@link org.hibernate.service.Service} contract for services which can be managed in JMX
* *
* @author Steve Ebersole * @author Steve Ebersole
*
* @deprecated Scheduled for removal in 6.0; see https://hibernate.atlassian.net/browse/HHH-14847
* and https://hibernate.atlassian.net/browse/HHH-14846
*/ */
@Deprecated
public interface Manageable { public interface Manageable {
/** /**
* Get the domain name to be used in registering the management bean. May be {@code null} to indicate Hibernate's * Get the domain name to be used in registering the management bean. May be {@code null} to indicate Hibernate's