mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-12 22:24:47 +00:00
HHH-8211 - Checkstyle and FindBugs fix-ups
This commit is contained in:
parent
f841c2ab3b
commit
6fe63e035c
@ -56,20 +56,15 @@ public class EhcacheHibernateMBeanRegistrationImpl
|
|||||||
EhcacheHibernateMBeanRegistrationImpl.class.getName()
|
EhcacheHibernateMBeanRegistrationImpl.class.getName()
|
||||||
);
|
);
|
||||||
private static final int MAX_MBEAN_REGISTRATION_RETRIES = 50;
|
private static final int MAX_MBEAN_REGISTRATION_RETRIES = 50;
|
||||||
private String cacheManagerClusterUUID;
|
|
||||||
private String registeredCacheManagerName;
|
|
||||||
private Status status = Status.STATUS_UNINITIALISED;
|
private Status status = Status.STATUS_UNINITIALISED;
|
||||||
private volatile EhcacheHibernate ehcacheHibernate;
|
private volatile EhcacheHibernate ehcacheHibernate;
|
||||||
private volatile ObjectName cacheManagerObjectName;
|
private volatile ObjectName cacheManagerObjectName;
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void registerMBeanForCacheManager(final CacheManager manager, final Properties properties)
|
public synchronized void registerMBeanForCacheManager(final CacheManager manager, final Properties properties)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
final String sessionFactoryName = properties.getProperty( Environment.SESSION_FACTORY_NAME );
|
final String sessionFactoryName = properties.getProperty( Environment.SESSION_FACTORY_NAME );
|
||||||
String name = null;
|
final String name;
|
||||||
if ( sessionFactoryName == null ) {
|
if ( sessionFactoryName == null ) {
|
||||||
name = manager.getName();
|
name = manager.getName();
|
||||||
}
|
}
|
||||||
@ -82,11 +77,12 @@ public synchronized void registerMBeanForCacheManager(final CacheManager manager
|
|||||||
private void registerBean(String name, CacheManager manager) throws Exception {
|
private void registerBean(String name, CacheManager manager) throws Exception {
|
||||||
ehcacheHibernate = new EhcacheHibernate( manager );
|
ehcacheHibernate = new EhcacheHibernate( manager );
|
||||||
int tries = 0;
|
int tries = 0;
|
||||||
boolean success = false;
|
boolean success;
|
||||||
Exception exception = null;
|
Exception exception = null;
|
||||||
cacheManagerClusterUUID = manager.getClusterUUID();
|
final String cacheManagerClusterUUID = manager.getClusterUUID();
|
||||||
|
String registeredCacheManagerName;
|
||||||
do {
|
do {
|
||||||
this.registeredCacheManagerName = name;
|
registeredCacheManagerName = name;
|
||||||
if ( tries != 0 ) {
|
if ( tries != 0 ) {
|
||||||
registeredCacheManagerName += "_" + tries;
|
registeredCacheManagerName += "_" + tries;
|
||||||
}
|
}
|
||||||
@ -121,9 +117,6 @@ private MBeanServer getMBeanServer() {
|
|||||||
return ManagementFactory.getPlatformMBeanServer();
|
return ManagementFactory.getPlatformMBeanServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void enableHibernateStatisticsSupport(SessionFactory sessionFactory) {
|
public void enableHibernateStatisticsSupport(SessionFactory sessionFactory) {
|
||||||
ehcacheHibernate.enableHibernateStatistics( sessionFactory );
|
ehcacheHibernate.enableHibernateStatistics( sessionFactory );
|
||||||
|
@ -69,11 +69,10 @@ public static String mbeanSafe(String s) {
|
|||||||
*/
|
*/
|
||||||
public static ObjectName getCacheManagerObjectName(String cacheManagerClusterUUID, String name)
|
public static ObjectName getCacheManagerObjectName(String cacheManagerClusterUUID, String name)
|
||||||
throws MalformedObjectNameException {
|
throws MalformedObjectNameException {
|
||||||
final ObjectName objectName = new ObjectName(
|
return new ObjectName(
|
||||||
GROUP_ID + ":type=" + EHCACHE_HIBERNATE_TYPE + ",name=" + mbeanSafe( name )
|
GROUP_ID + ":type=" + EHCACHE_HIBERNATE_TYPE
|
||||||
+ getBeanNameSuffix( cacheManagerClusterUUID )
|
+ ",name=" + mbeanSafe( name ) + getBeanNameSuffix( cacheManagerClusterUUID )
|
||||||
);
|
);
|
||||||
return objectName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getBeanNameSuffix(String cacheManagerClusterUUID) {
|
private static String getBeanNameSuffix(String cacheManagerClusterUUID) {
|
||||||
|
@ -130,7 +130,6 @@ public void run() {
|
|||||||
);
|
);
|
||||||
this.cancel();
|
this.cancel();
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ehcacheHibernateMBeanRegistration.enableHibernateStatisticsSupport( sessionFactory );
|
ehcacheHibernateMBeanRegistration.enableHibernateStatisticsSupport( sessionFactory );
|
||||||
@ -152,9 +151,8 @@ private SessionFactory locateSessionFactory() {
|
|||||||
if ( map == null ) {
|
if ( map == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final Iterator values = map.values().iterator();
|
for ( Object o : map.values() ) {
|
||||||
while ( values.hasNext() ) {
|
final SessionFactory sessionFactory = (SessionFactory) o;
|
||||||
final SessionFactory sessionFactory = (SessionFactory) values.next();
|
|
||||||
final Class sessionFactoryType = sessionFactory.getClass();
|
final Class sessionFactoryType = sessionFactory.getClass();
|
||||||
final Field propertiesField = getField( sessionFactoryType, "properties" );
|
final Field propertiesField = getField( sessionFactoryType, "properties" );
|
||||||
if ( propertiesField != null ) {
|
if ( propertiesField != null ) {
|
||||||
|
@ -324,8 +324,8 @@ public static TabularData newTabularDataInstance() {
|
|||||||
*/
|
*/
|
||||||
public static QueryStats[] fromTabularData(final TabularData tabularData) {
|
public static QueryStats[] fromTabularData(final TabularData tabularData) {
|
||||||
final List<QueryStats> countList = new ArrayList( tabularData.size() );
|
final List<QueryStats> countList = new ArrayList( tabularData.size() );
|
||||||
for ( final Iterator pos = tabularData.values().iterator(); pos.hasNext(); ) {
|
for ( Object o : tabularData.values() ) {
|
||||||
countList.add( new QueryStats( (CompositeData) pos.next() ) );
|
countList.add( new QueryStats( (CompositeData) o ) );
|
||||||
}
|
}
|
||||||
return countList.toArray( new QueryStats[countList.size()] );
|
return countList.toArray( new QueryStats[countList.size()] );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user