Skip to content

Commit

Permalink
HHH-14847 - Deprecate JMX support
Browse files Browse the repository at this point in the history
  • Loading branch information
sebersole authored and Sanne committed Sep 28, 2021
1 parent 4c235a4 commit 251e1fb
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 10 deletions.
Expand Up @@ -1488,13 +1488,6 @@ public interface AvailableSettings extends org.hibernate.jpa.AvailableSettings {
*/
String HBM2DDL_HALT_ON_ERROR = "hibernate.hbm2ddl.halt_on_error";

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.
Expand Down Expand Up @@ -2000,4 +1993,41 @@ 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";

}
Expand Up @@ -273,4 +273,27 @@ void connectionProviderClassDeprecated(
)
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);

}
Expand Up @@ -19,6 +19,7 @@
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;
Expand Down Expand Up @@ -107,6 +108,12 @@ public void stop() {

@Override
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 ) ) {
for ( Manageable realManageable : ( (OptionallyManageable) service ).getRealManageables() ) {
registerService( realManageable,serviceRole );
Expand Down Expand Up @@ -139,6 +146,8 @@ public void registerService(Manageable service, Class<? extends Service> service

@Override
public void registerMBean(ObjectName objectName, Object mBean) {
DeprecationLogger.DEPRECATION_LOGGER.deprecatedJmxBeanRegistration( mBean.getClass().getName() );

MBeanServer mBeanServer = findServer();
if ( mBeanServer == null ) {
if ( startedServer ) {
Expand Down
Expand Up @@ -10,6 +10,7 @@

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;
Expand All @@ -29,8 +30,10 @@ public Class<JmxService> getServiceInitiated() {

@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;
}
}
Expand Up @@ -15,7 +15,11 @@
* 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.
Expand Down
Expand Up @@ -10,7 +10,11 @@
* 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
Expand Down

0 comments on commit 251e1fb

Please sign in to comment.