diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java b/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java index 0e66765190..49bc50d2df 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java @@ -1903,13 +1903,6 @@ public interface AvailableSettings extends org.hibernate.jpa.AvailableSettings { */ 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 * either a class name or instance. @@ -2471,4 +2464,42 @@ public interface AvailableSettings extends org.hibernate.jpa.AvailableSettings { */ @Deprecated 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"; + } diff --git a/hibernate-core/src/main/java/org/hibernate/internal/log/DeprecationLogger.java b/hibernate-core/src/main/java/org/hibernate/internal/log/DeprecationLogger.java index c08ec09024..9ecfe081bf 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/log/DeprecationLogger.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/log/DeprecationLogger.java @@ -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" ) 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); + } diff --git a/hibernate-core/src/main/java/org/hibernate/jmx/internal/JmxServiceImpl.java b/hibernate-core/src/main/java/org/hibernate/jmx/internal/JmxServiceImpl.java index e63ef9a63c..b155409eec 100644 --- a/hibernate-core/src/main/java/org/hibernate/jmx/internal/JmxServiceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/jmx/internal/JmxServiceImpl.java @@ -19,6 +19,7 @@ import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Environment; import org.hibernate.internal.CoreLogging; import org.hibernate.internal.CoreMessageLogger; +import org.hibernate.internal.log.DeprecationLogger; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.jmx.spi.JmxService; import org.hibernate.service.Service; @@ -119,6 +120,12 @@ public class JmxServiceImpl implements JmxService, Stoppable { @Override public void registerService(Manageable service, Class serviceRole) { + if ( service == null ) { + return; + } + + DeprecationLogger.DEPRECATION_LOGGER.deprecatedJmxManageableServiceRegistration( service.getClass().getName() ); + if ( OptionallyManageable.class.isInstance( service ) ) { for ( Manageable realManageable : ( (OptionallyManageable) service ).getRealManageables() ) { registerService( realManageable,serviceRole ); @@ -151,6 +158,8 @@ public class JmxServiceImpl implements JmxService, Stoppable { @Override public void registerMBean(ObjectName objectName, Object mBean) { + DeprecationLogger.DEPRECATION_LOGGER.deprecatedJmxBeanRegistration( mBean.getClass().getName() ); + MBeanServer mBeanServer = findServer(); if ( mBeanServer == null ) { if ( startedServer ) { diff --git a/hibernate-core/src/main/java/org/hibernate/jmx/internal/JmxServiceInitiator.java b/hibernate-core/src/main/java/org/hibernate/jmx/internal/JmxServiceInitiator.java index 6c16036854..b8c371bb47 100644 --- a/hibernate-core/src/main/java/org/hibernate/jmx/internal/JmxServiceInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/jmx/internal/JmxServiceInitiator.java @@ -10,6 +10,7 @@ import java.util.Map; import org.hibernate.boot.registry.StandardServiceInitiator; import org.hibernate.cfg.AvailableSettings; +import org.hibernate.internal.log.DeprecationLogger; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.jmx.spi.JmxService; import org.hibernate.service.spi.ServiceRegistryImplementor; @@ -29,8 +30,10 @@ public class JmxServiceInitiator implements StandardServiceInitiator @Override public JmxService initiateService(Map configurationValues, ServiceRegistryImplementor registry) { - return ConfigurationHelper.getBoolean( AvailableSettings.JMX_ENABLED, configurationValues, false ) - ? new JmxServiceImpl( configurationValues ) - : DisabledJmxServiceImpl.INSTANCE; + if ( ConfigurationHelper.getBoolean( AvailableSettings.JMX_ENABLED, configurationValues, false ) ) { + DeprecationLogger.DEPRECATION_LOGGER.deprecatedJmxSupport( AvailableSettings.JMX_ENABLED ); + return new JmxServiceImpl( configurationValues ); + } + return DisabledJmxServiceImpl.INSTANCE; } } diff --git a/hibernate-core/src/main/java/org/hibernate/jmx/spi/JmxService.java b/hibernate-core/src/main/java/org/hibernate/jmx/spi/JmxService.java index 5050696583..94e3383c3d 100644 --- a/hibernate-core/src/main/java/org/hibernate/jmx/spi/JmxService.java +++ b/hibernate-core/src/main/java/org/hibernate/jmx/spi/JmxService.java @@ -15,7 +15,11 @@ import org.hibernate.service.spi.Manageable; * Service providing simplified access to JMX related features needed by Hibernate. * * @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 { /** * Handles registration of a manageable service. diff --git a/hibernate-core/src/main/java/org/hibernate/service/spi/Manageable.java b/hibernate-core/src/main/java/org/hibernate/service/spi/Manageable.java index afc47301bc..16fdda7e93 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/spi/Manageable.java +++ b/hibernate-core/src/main/java/org/hibernate/service/spi/Manageable.java @@ -10,7 +10,11 @@ package org.hibernate.service.spi; * Optional {@link org.hibernate.service.Service} contract for services which can be managed in JMX * * @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 { /** * Get the domain name to be used in registering the management bean. May be {@code null} to indicate Hibernate's