From 8e3770235b852024b6ff0ac7ff764b291d76fa61 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Thu, 9 May 2013 19:51:10 -0500 Subject: [PATCH] HHH-8211 - Checkstyle and FindBugs fix-ups --- .../c3p0/internal/C3P0ConnectionProvider.java | 3 +- .../procedure/internal/ParameterBindImpl.java | 4 +- .../procedure/internal/ProcedureCallImpl.java | 2 +- .../internal/ProcedureCallMementoImpl.java | 10 + .../internal/ProcedureResultImpl.java | 8 +- .../hibernate/procedure/internal/Util.java | 82 ++++++- .../procedure/internal/package-info.java | 4 + .../management/impl/AbstractEmitterBean.java | 1 + ...EhcacheHibernateMBeanRegistrationImpl.java | 20 +- .../management/impl/EhcacheStatsImpl.java | 200 +----------------- .../ehcache/management/impl/EntityStats.java | 17 +- .../management/impl/HibernateStatsImpl.java | 111 +--------- .../management/impl/NullHibernateStats.java | 1 + .../impl/ProviderMBeanRegistrationHelper.java | 1 - .../ehcache/management/impl/QueryStats.java | 7 +- .../access/TransactionalAccessDelegate.java | 8 +- 16 files changed, 133 insertions(+), 346 deletions(-) create mode 100644 hibernate-core/src/main/java/org/hibernate/procedure/internal/package-info.java diff --git a/hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/C3P0ConnectionProvider.java b/hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/C3P0ConnectionProvider.java index 207461b1c5..27ef421bd7 100644 --- a/hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/C3P0ConnectionProvider.java +++ b/hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/C3P0ConnectionProvider.java @@ -168,7 +168,7 @@ public class C3P0ConnectionProvider } final String key = (String) o; if ( key.startsWith( "hibernate.c3p0." ) ) { - String newKey = key.substring( 15 ); + final String newKey = key.substring( 15 ); if ( props.containsKey( newKey ) ) { warnPropertyConflict( key, newKey ); } @@ -267,6 +267,7 @@ public class C3P0ConnectionProvider * * @deprecated Use {@link #stop} instead */ + @SuppressWarnings("UnusedDeclaration") @Deprecated public void close() { stop(); diff --git a/hibernate-core/src/main/java/org/hibernate/procedure/internal/ParameterBindImpl.java b/hibernate-core/src/main/java/org/hibernate/procedure/internal/ParameterBindImpl.java index 505bca94f4..80d2b3b621 100644 --- a/hibernate-core/src/main/java/org/hibernate/procedure/internal/ParameterBindImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/procedure/internal/ParameterBindImpl.java @@ -36,11 +36,11 @@ public class ParameterBindImpl implements ParameterBind { private final T value; private final TemporalType explicitTemporalType; - public ParameterBindImpl(T value) { + ParameterBindImpl(T value) { this( value, null ); } - public ParameterBindImpl(T value, TemporalType explicitTemporalType) { + ParameterBindImpl(T value, TemporalType explicitTemporalType) { this.value = value; this.explicitTemporalType = explicitTemporalType; } diff --git a/hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureCallImpl.java b/hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureCallImpl.java index 0c878894d2..f6235b8aea 100644 --- a/hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureCallImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureCallImpl.java @@ -484,7 +484,7 @@ public class ProcedureCallImpl extends AbstractBasicQueryContractImpl implements @Override public QueryParameters buildQueryParametersObject() { - QueryParameters qp = super.buildQueryParametersObject(); + final QueryParameters qp = super.buildQueryParametersObject(); // both of these are for documentation purposes, they are actually handled directly... qp.setAutoDiscoverScalarTypes( true ); qp.setCallable( true ); diff --git a/hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureCallMementoImpl.java b/hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureCallMementoImpl.java index 7af100283e..456198a494 100644 --- a/hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureCallMementoImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureCallMementoImpl.java @@ -51,6 +51,16 @@ public class ProcedureCallMementoImpl implements ProcedureCallMemento { private final Map hintsMap; + /** + * Constructs a ProcedureCallImpl + * + * @param procedureName The name of the procedure to be called + * @param queryReturns The result mappings + * @param parameterStrategy Are parameters named or positional? + * @param parameterDeclarations The parameters registrations + * @param synchronizedQuerySpaces Any query spaces to synchronize on execution + * @param hintsMap Map of JPA query hints + */ public ProcedureCallMementoImpl( String procedureName, NativeSQLQueryReturn[] queryReturns, diff --git a/hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureResultImpl.java b/hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureResultImpl.java index 6b52b3f895..d618e3d6c6 100644 --- a/hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureResultImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureResultImpl.java @@ -35,6 +35,8 @@ import org.hibernate.result.Return; import org.hibernate.result.internal.ResultImpl; /** + * Implementation of ProcedureResult. Defines centralized access to all of the results of a procedure call. + * * @author Steve Ebersole */ public class ProcedureResultImpl extends ResultImpl implements ProcedureResult { @@ -42,7 +44,7 @@ public class ProcedureResultImpl extends ResultImpl implements ProcedureResult { private final CallableStatement callableStatement; private final ParameterRegistrationImplementor[] refCursorParameters; - private int refCursorParamIndex = 0; + private int refCursorParamIndex; ProcedureResultImpl(ProcedureCallImpl procedureCall, CallableStatement callableStatement) { super( procedureCall, callableStatement ); @@ -80,9 +82,9 @@ public class ProcedureResultImpl extends ResultImpl implements ProcedureResult { @Override protected Return buildExtendedReturn(CurrentReturnDescriptor returnDescriptor) { this.refCursorParamIndex++; + final int refCursorParamIndex = ( (ProcedureCurrentReturnDescriptor) returnDescriptor ).refCursorParamIndex; + final ParameterRegistrationImplementor refCursorParam = refCursorParameters[refCursorParamIndex]; ResultSet resultSet; - int refCursorParamIndex = ( (ProcedureCurrentReturnDescriptor) returnDescriptor ).refCursorParamIndex; - ParameterRegistrationImplementor refCursorParam = refCursorParameters[refCursorParamIndex]; if ( refCursorParam.getName() != null ) { resultSet = procedureCall.getSession().getFactory().getServiceRegistry() .getService( RefCursorSupport.class ) diff --git a/hibernate-core/src/main/java/org/hibernate/procedure/internal/Util.java b/hibernate-core/src/main/java/org/hibernate/procedure/internal/Util.java index 36e6ffe66f..bae270906f 100644 --- a/hibernate-core/src/main/java/org/hibernate/procedure/internal/Util.java +++ b/hibernate-core/src/main/java/org/hibernate/procedure/internal/Util.java @@ -23,7 +23,6 @@ */ package org.hibernate.procedure.internal; -import java.util.Collections; import java.util.Map; import java.util.Set; @@ -38,6 +37,8 @@ import org.hibernate.loader.custom.sql.SQLQueryReturnProcessor; import org.hibernate.persister.entity.EntityPersister; /** + * Utilities used to implement procedure call support. + * * @author Steve Ebersole */ public class Util { @@ -51,7 +52,7 @@ public class Util { * * @return The copy */ - static NativeSQLQueryReturn[] copy(NativeSQLQueryReturn[] queryReturns) { + public static NativeSQLQueryReturn[] copy(NativeSQLQueryReturn[] queryReturns) { if ( queryReturns == null ) { return new NativeSQLQueryReturn[0]; } @@ -61,21 +62,69 @@ public class Util { return copy; } + /** + * Make a (shallow) copy of query spaces to be synchronized + * + * @param synchronizedQuerySpaces The query spaces + * + * @return The copy + */ public static Set copy(Set synchronizedQuerySpaces) { return CollectionHelper.makeCopy( synchronizedQuerySpaces ); } + /** + * Make a (shallow) copy of the JPA query hints map + * + * @param hints The JPA query hints to copy + * + * @return The copy + */ public static Map copy(Map hints) { return CollectionHelper.makeCopy( hints ); } + /** + * Context for resolving result-set-mapping definitions + */ public static interface ResultSetMappingResolutionContext { + /** + * Access to the SessionFactory + * + * @return SessionFactory + */ public SessionFactoryImplementor getSessionFactory(); + + /** + * Locate a ResultSetMappingDefinition by name + * + * @param name The name of the ResultSetMappingDefinition to locate + * + * @return The ResultSetMappingDefinition + */ public ResultSetMappingDefinition findResultSetMapping(String name); + + /** + * Callback to add query returns indicated by the result set mapping(s) + * + * @param queryReturns The query returns + */ public void addQueryReturns(NativeSQLQueryReturn... queryReturns); - public void addQuerySpaces(String... spaces); + + /** + * Callback to add query spaces indicated by the result set mapping(s) + * + * @param querySpaces The query spaces + */ + public void addQuerySpaces(String... querySpaces); } + /** + * Resolve the given result set mapping names + * + * @param context The context for the resolution. See {@link ResultSetMappingResolutionContext} + * @param resultSetMappingNames The names of the result-set-mappings to resolve + */ public static void resolveResultSetMappings(ResultSetMappingResolutionContext context, String... resultSetMappingNames) { for ( String resultSetMappingName : resultSetMappingNames ) { final ResultSetMappingDefinition mapping = context.findResultSetMapping( resultSetMappingName ); @@ -92,12 +141,37 @@ public class Util { } } + /** + * Context for resolving result-class definitions + */ public static interface ResultClassesResolutionContext { + /** + * Access to the SessionFactory + * + * @return SessionFactory + */ public SessionFactoryImplementor getSessionFactory(); + /** + * Callback to add query returns indicated by the result set mapping(s) + * + * @param queryReturns The query returns + */ public void addQueryReturns(NativeSQLQueryReturn... queryReturns); - public void addQuerySpaces(String... spaces); + + /** + * Callback to add query spaces indicated by the result set mapping(s) + * + * @param querySpaces The query spaces + */ + public void addQuerySpaces(String... querySpaces); } + /** + * Resolve the given result classes + * + * @param context The context for the resolution. See {@link ResultSetMappingResolutionContext} + * @param resultClasses The Classes to which the results should be mapped + */ public static void resolveResultClasses(ResultClassesResolutionContext context, Class... resultClasses) { int i = 1; for ( Class resultClass : resultClasses ) { diff --git a/hibernate-core/src/main/java/org/hibernate/procedure/internal/package-info.java b/hibernate-core/src/main/java/org/hibernate/procedure/internal/package-info.java new file mode 100644 index 0000000000..66aff73343 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/procedure/internal/package-info.java @@ -0,0 +1,4 @@ +/** + * Defines the internal support for implementing stored procedure calling. + */ +package org.hibernate.procedure.internal; diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/AbstractEmitterBean.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/AbstractEmitterBean.java index d3e4245abe..12d3c448a5 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/AbstractEmitterBean.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/AbstractEmitterBean.java @@ -103,6 +103,7 @@ public abstract class AbstractEmitterBean extends StandardMBean implements Notif /** * Dispose of this SampledCacheManager and clean up held resources */ + @SuppressWarnings("UnusedDeclaration") public final void dispose() { doDispose(); removeAllNotificationListeners(); diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheHibernateMBeanRegistrationImpl.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheHibernateMBeanRegistrationImpl.java index 8b39cd7b27..980cdb7ad7 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheHibernateMBeanRegistrationImpl.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheHibernateMBeanRegistrationImpl.java @@ -122,9 +122,6 @@ public class EhcacheHibernateMBeanRegistrationImpl ehcacheHibernate.enableHibernateStatistics( sessionFactory ); } - /** - * {@inheritDoc} - */ @Override public synchronized void dispose() throws CacheException { if ( status == Status.STATUS_SHUTDOWN ) { @@ -145,19 +142,15 @@ public class EhcacheHibernateMBeanRegistrationImpl status = Status.STATUS_SHUTDOWN; } - /** - * {@inheritDoc} - */ @Override public synchronized Status getStatus() { return status; } /** - * * {@inheritDoc} - * - * No-op in this case + *

+ * NOTE : No-op in this case */ @Override public void init() throws CacheException { @@ -165,10 +158,9 @@ public class EhcacheHibernateMBeanRegistrationImpl } /** - * * {@inheritDoc} - * - * No-op in this case + *

+ * NOTE : No-op in this case */ @Override public void notifyCacheAdded(String cacheName) { @@ -177,8 +169,8 @@ public class EhcacheHibernateMBeanRegistrationImpl /** * {@inheritDoc} - * - * No-op in this case + *

+ * NOTE : No-op in this case */ @Override public void notifyCacheRemoved(String cacheName) { diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheStatsImpl.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheStatsImpl.java index 36d9f4c123..c81d78c274 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheStatsImpl.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheStatsImpl.java @@ -72,42 +72,27 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat this.cacheManager = manager; } - /** - * {@inheritDoc} - */ @Override public boolean isStatisticsEnabled() { return false; } - /** - * {@inheritDoc} - */ @Override public void clearStats() { sampledCacheManager.clearStatistics(); statsSince = System.currentTimeMillis(); } - /** - * {@inheritDoc} - */ @Override public void disableStats() { setStatisticsEnabled( false ); } - /** - * {@inheritDoc} - */ @Override public void enableStats() { setStatisticsEnabled( true ); } - /** - * {@inheritDoc} - */ @Override public void flushRegionCache(String region) { final Cache cache = this.cacheManager.getCache( region ); @@ -116,9 +101,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat } } - /** - * {@inheritDoc} - */ @Override public void flushRegionCaches() { for ( String name : cacheManager.getCacheNames() ) { @@ -127,28 +109,18 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat cache.flush(); } } - } - /** - * {@inheritDoc} - */ @Override public String generateActiveConfigDeclaration() { return this.cacheManager.getActiveConfigurationText(); } - /** - * {@inheritDoc} - */ @Override public String generateActiveConfigDeclaration(String region) { return this.cacheManager.getActiveConfigurationText( region ); } - /** - * {@inheritDoc} - */ @Override public long getCacheHitCount() { long count = 0; @@ -161,9 +133,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat return count; } - /** - * {@inheritDoc} - */ @Override public double getCacheHitRate() { final long now = System.currentTimeMillis(); @@ -171,9 +140,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat return getCacheHitCount() / deltaSecs; } - /** - * {@inheritDoc} - */ @Override public long getCacheHitSample() { long count = 0; @@ -186,9 +152,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat return count; } - /** - * {@inheritDoc} - */ @Override public long getCacheMissCount() { long count = 0; @@ -201,9 +164,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat return count; } - /** - * {@inheritDoc} - */ @Override public double getCacheMissRate() { final long now = System.currentTimeMillis(); @@ -211,9 +171,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat return getCacheMissCount() / deltaSecs; } - /** - * {@inheritDoc} - */ @Override public long getCacheMissSample() { long count = 0; @@ -226,9 +183,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat return count; } - /** - * {@inheritDoc} - */ @Override public long getCachePutCount() { long count = 0; @@ -241,9 +195,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat return count; } - /** - * {@inheritDoc} - */ @Override public double getCachePutRate() { final long now = System.currentTimeMillis(); @@ -251,9 +202,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat return getCachePutCount() / deltaSecs; } - /** - * {@inheritDoc} - */ @Override public long getCachePutSample() { long count = 0; @@ -266,25 +214,16 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat return count; } - /** - * {@inheritDoc} - */ @Override public String getOriginalConfigDeclaration() { return this.cacheManager.getOriginalConfigurationText(); } - /** - * {@inheritDoc} - */ @Override public String getOriginalConfigDeclaration(String region) { return this.cacheManager.getOriginalConfigurationText( region ); } - /** - * {@inheritDoc} - */ @Override public Map> getRegionCacheAttributes() { final Map> result = new HashMap>(); @@ -294,9 +233,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat return result; } - /** - * {@inheritDoc} - */ @Override public Map getRegionCacheAttributes(String regionName) { final Map result = new HashMap(); @@ -311,9 +247,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat return result; } - /** - * {@inheritDoc} - */ @Override public int getRegionCacheMaxTTISeconds(String region) { final Cache cache = cacheManager.getCache( region ); @@ -325,9 +258,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat } } - /** - * {@inheritDoc} - */ @Override public int getRegionCacheMaxTTLSeconds(String region) { final Cache cache = cacheManager.getCache( region ); @@ -339,9 +269,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat } } - /** - * {@inheritDoc} - */ @Override public int getRegionCacheOrphanEvictionPeriod(String region) { final Cache cache = this.cacheManager.getCache( region ); @@ -353,9 +280,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat } } - /** - * {@inheritDoc} - */ @Override public Map getRegionCacheSamples() { final Map rv = new HashMap(); @@ -375,9 +299,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat return rv; } - /** - * {@inheritDoc} - */ @Override public int getRegionCacheTargetMaxInMemoryCount(String region) { final Cache cache = cacheManager.getCache( region ); @@ -389,9 +310,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat } } - /** - * {@inheritDoc} - */ @Override public int getRegionCacheTargetMaxTotalCount(String region) { final Cache cache = cacheManager.getCache( region ); @@ -403,9 +321,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat } } - /** - * {@inheritDoc} - */ @Override public String[] getTerracottaHibernateCacheRegionNames() { final ArrayList rv = new ArrayList(); @@ -417,26 +332,15 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat } } } - return rv.toArray( new String[] {} ); + return rv.toArray( new String[ rv.size() ] ); } - /** - * {@inheritDoc} - */ @Override public boolean isRegionCacheEnabled(String region) { final Cache cache = this.cacheManager.getCache( region ); - if ( cache != null ) { - return !cache.isDisabled(); - } - else { - return false; - } + return cache != null && !cache.isDisabled(); } - /** - * {@inheritDoc} - */ @Override public void setRegionCacheEnabled(String region, boolean enabled) { final Cache cache = this.cacheManager.getCache( region ); @@ -446,9 +350,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat sendNotification( CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region ); } - /** - * {@inheritDoc} - */ @Override public boolean isRegionCachesEnabled() { for ( String name : this.cacheManager.getCacheNames() ) { @@ -462,10 +363,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat return true; } - /** - * {@inheritDoc} - * @see EhcacheStats#setRegionCachesEnabled(boolean) - */ @Override public void setRegionCachesEnabled(final boolean flag) { for ( String name : this.cacheManager.getCacheNames() ) { @@ -477,51 +374,26 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat sendNotification( CACHE_ENABLED, flag ); } - /** - * {@inheritDoc} - */ @Override public boolean isRegionCacheLoggingEnabled(String region) { final Cache cache = this.cacheManager.getCache( region ); - if ( cache != null ) { - return cache.getCacheConfiguration().getLogging(); - } - else { - return false; - } + return cache != null && cache.getCacheConfiguration().getLogging(); } - /** - * {@inheritDoc} - */ @Override public boolean isRegionCacheOrphanEvictionEnabled(String region) { final Cache cache = this.cacheManager.getCache( region ); - if ( cache != null && cache.isTerracottaClustered() ) { - return cache.getCacheConfiguration().getTerracottaConfiguration().getOrphanEviction(); - } - else { - return false; - } + return cache != null && cache.isTerracottaClustered() && cache.getCacheConfiguration() + .getTerracottaConfiguration() + .getOrphanEviction(); } - /** - * {@inheritDoc} - */ @Override public boolean isTerracottaHibernateCache(String region) { final Cache cache = cacheManager.getCache( region ); - if ( cache != null ) { - return cache.getCacheConfiguration().isTerracottaClustered(); - } - else { - return false; - } + return cache != null && cache.getCacheConfiguration().isTerracottaClustered(); } - /** - * {@inheritDoc} - */ @Override public void setRegionCacheLoggingEnabled(String region, boolean loggingEnabled) { final Cache cache = this.cacheManager.getCache( region ); @@ -531,9 +403,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat } } - /** - * {@inheritDoc} - */ @Override public void setRegionCacheMaxTTISeconds(String region, int maxTTISeconds) { final Cache cache = this.cacheManager.getCache( region ); @@ -543,9 +412,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat } } - /** - * {@inheritDoc} - */ @Override public void setRegionCacheMaxTTLSeconds(String region, int maxTTLSeconds) { final Cache cache = this.cacheManager.getCache( region ); @@ -555,9 +421,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat } } - /** - * {@inheritDoc} - */ @Override public void setRegionCacheTargetMaxInMemoryCount(String region, int targetMaxInMemoryCount) { final Cache cache = this.cacheManager.getCache( region ); @@ -567,9 +430,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat } } - /** - * {@inheritDoc} - */ @Override public void setRegionCacheTargetMaxTotalCount(String region, int targetMaxTotalCount) { final Cache cache = this.cacheManager.getCache( region ); @@ -579,11 +439,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat } } - /** - * {@inheritDoc} - * - * @see EhcacheStats#getNumberOfElementsInMemory(java.lang.String) - */ @Override public int getNumberOfElementsInMemory(String region) { final Cache cache = this.cacheManager.getCache( region ); @@ -595,11 +450,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat } } - /** - * {@inheritDoc} - * - * @see EhcacheStats#getNumberOfElementsOffHeap(java.lang.String) - */ @Override public int getNumberOfElementsOffHeap(String region) { final Cache cache = this.cacheManager.getCache( region ); @@ -611,11 +461,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat } } - /** - * {@inheritDoc} - * - * @see EhcacheStats#getNumberOfElementsOnDisk(java.lang.String) - */ @Override public int getNumberOfElementsOnDisk(String region) { final Cache cache = this.cacheManager.getCache( region ); @@ -627,9 +472,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat } } - /** - * {@inheritDoc} - */ @Override public void setStatisticsEnabled(boolean flag) { for ( String cacheName : cacheManager.getCacheNames() ) { @@ -644,9 +486,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat sendNotification( CACHE_STATISTICS_ENABLED, flag ); } - /** - * {@inheritDoc} - */ @Override public long getMaxGetTimeMillis() { long rv = 0; @@ -659,9 +498,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat return rv; } - /** - * {@inheritDoc} - */ @Override public long getMinGetTimeMillis() { long rv = 0; @@ -674,11 +510,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat return rv; } - /** - * {@inheritDoc} - * - * @see EhcacheStats#getMaxGetTimeMillis(java.lang.String) - */ @Override public long getMaxGetTimeMillis(String cacheName) { final Cache cache = cacheManager.getCache( cacheName ); @@ -690,11 +521,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat } } - /** - * {@inheritDoc} - * - * @see EhcacheStats#getMinGetTimeMillis(java.lang.String) - */ @Override public long getMinGetTimeMillis(String cacheName) { final Cache cache = cacheManager.getCache( cacheName ); @@ -706,11 +532,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat } } - /** - * {@inheritDoc} - * - * @see EhcacheStats#getAverageGetTimeMillis(java.lang.String) - */ @Override public float getAverageGetTimeMillis(String region) { final Cache cache = this.cacheManager.getCache( region ); @@ -722,18 +543,11 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat } } - /** - * {@inheritDoc} - */ @Override protected void doDispose() { // no-op } - /** - * {@inheritDoc} - * @see AbstractEmitterBean#getNotificationInfo() - */ @Override public MBeanNotificationInfo[] getNotificationInfo() { return new MBeanNotificationInfo[] {NOTIFICATION_INFO}; diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EntityStats.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EntityStats.java index 19faf860c1..4322b01007 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EntityStats.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EntityStats.java @@ -34,7 +34,6 @@ import javax.management.openmbean.TabularDataSupport; import javax.management.openmbean.TabularType; import java.io.Serializable; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.hibernate.stat.EntityStatistics; @@ -154,6 +153,7 @@ public class EntityStats implements Serializable { * Constructor from compositeDate * @param cData CompositeData of the stats */ + @SuppressWarnings("UnusedAssignment") public EntityStats(final CompositeData cData) { int i = 0; name = (String) cData.get( ITEM_NAMES[i++] ); @@ -166,15 +166,6 @@ public class EntityStats implements Serializable { optimisticFailureCount = (Long) cData.get( ITEM_NAMES[i++] ); } - private static int safeParseInt(String s) { - try { - return Integer.parseInt( s ); - } - catch (Exception e) { - return -1; - } - } - /** * Adds the counters of this instance up with the ones passed in * @param stats the stats to add to this one @@ -210,6 +201,7 @@ public class EntityStats implements Serializable { * The short name of the entity those stats are about * @return the shortName of the entity */ + @SuppressWarnings("UnusedDeclaration") public String getShortName() { return shortName; } @@ -293,10 +285,11 @@ public class EntityStats implements Serializable { * @param tabularData the tabularData with the {@link CompositeData} of stats to extract * @return all entityStats as an array */ + @SuppressWarnings({"unchecked", "UnusedDeclaration"}) public static EntityStats[] fromTabularData(final TabularData tabularData) { final List countList = new ArrayList( tabularData.size() ); - for ( final Iterator pos = tabularData.values().iterator(); pos.hasNext(); ) { - countList.add( new EntityStats( (CompositeData) pos.next() ) ); + for ( Object o : tabularData.values() ) { + countList.add( new EntityStats( (CompositeData) o ) ); } return countList.toArray( new EntityStats[countList.size()] ); } diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/HibernateStatsImpl.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/HibernateStatsImpl.java index 35bc4e0ea2..434be5a9e0 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/HibernateStatsImpl.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/HibernateStatsImpl.java @@ -75,52 +75,27 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate return sessionFactory.getStatistics(); } - /** - * {@inheritDoc} - * - * @see HibernateStats#clearStats() - */ @Override public void clearStats() { getStatistics().clear(); sendNotification( CACHE_STATISTICS_RESET ); } - /** - * {@inheritDoc} - * - * @see HibernateStats#disableStats() - */ @Override public void disableStats() { setStatisticsEnabled( false ); } - /** - * {@inheritDoc} - * - * @see HibernateStats#enableStats() - */ @Override public void enableStats() { setStatisticsEnabled( true ); } - /** - * {@inheritDoc} - * - * @see HibernateStats#getCloseStatementCount() - */ @Override public long getCloseStatementCount() { return getStatistics().getCloseStatementCount(); } - /** - * {@inheritDoc} - * - * @see HibernateStats#getConnectCount() - */ @Override public long getConnectCount() { return getStatistics().getConnectCount(); @@ -133,55 +108,31 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate * @deprecated DO NOT USE, WILL ONLY THROW AT YOU! */ @Deprecated + @SuppressWarnings("UnusedDeclaration") public long getDBSQLExecutionSample() { throw new UnsupportedOperationException( "Use getQueryExecutionCount() instead" ); } - /** - * {@inheritDoc} - * - * @see HibernateStats#getFlushCount() - */ @Override public long getFlushCount() { return getStatistics().getFlushCount(); } - /** - * {@inheritDoc} - * - * @see HibernateStats#getOptimisticFailureCount() - */ @Override public long getOptimisticFailureCount() { return getStatistics().getOptimisticFailureCount(); } - /** - * {@inheritDoc} - * - * @see HibernateStats#getPrepareStatementCount() - */ @Override public long getPrepareStatementCount() { return getStatistics().getPrepareStatementCount(); } - /** - * {@inheritDoc} - * - * @see HibernateStats#getQueryExecutionCount() - */ @Override public long getQueryExecutionCount() { return getStatistics().getQueryExecutionCount(); } - /** - * {@inheritDoc} - * - * @see HibernateStats#getQueryExecutionRate() - */ @Override public double getQueryExecutionRate() { final long startTime = getStatistics().getStartTime(); @@ -190,82 +141,42 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate return getQueryExecutionCount() / deltaSecs; } - /** - * {@inheritDoc} - * - * @see HibernateStats#getQueryExecutionSample() - */ @Override public long getQueryExecutionSample() { throw new UnsupportedOperationException( "TODO: need to impl. rates for query execution" ); } - /** - * {@inheritDoc} - * - * @see HibernateStats#getSessionCloseCount() - */ @Override public long getSessionCloseCount() { return getStatistics().getSessionCloseCount(); } - /** - * {@inheritDoc} - * - * @see HibernateStats#getSessionOpenCount() - */ @Override public long getSessionOpenCount() { return getStatistics().getSessionOpenCount(); } - /** - * {@inheritDoc} - * - * @see HibernateStats#getSuccessfulTransactionCount() - */ @Override public long getSuccessfulTransactionCount() { return getStatistics().getSuccessfulTransactionCount(); } - /** - * {@inheritDoc} - * - * @see HibernateStats#getTransactionCount() - */ @Override public long getTransactionCount() { return getStatistics().getTransactionCount(); } - /** - * {@inheritDoc} - * - * @see HibernateStats#isStatisticsEnabled() - */ @Override public boolean isStatisticsEnabled() { return getStatistics().isStatisticsEnabled(); } - /** - * {@inheritDoc} - * - * @see HibernateStats#setStatisticsEnabled(boolean) - */ @Override public void setStatisticsEnabled(boolean flag) { getStatistics().setStatisticsEnabled( flag ); sendNotification( CACHE_STATISTICS_ENABLED, flag ); } - /** - * {@inheritDoc} - * - * @see HibernateStats#getEntityStats() - */ @Override public TabularData getEntityStats() { final List result = new ArrayList(); @@ -279,11 +190,6 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate return td; } - /** - * {@inheritDoc} - * - * @see HibernateStats#getCollectionStats() - */ @Override public TabularData getCollectionStats() { final List result = new ArrayList(); @@ -300,11 +206,6 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate return td; } - /** - * {@inheritDoc} - * - * @see HibernateStats#getQueryStats() - */ @Override public TabularData getQueryStats() { final List result = new ArrayList(); @@ -318,9 +219,6 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate return td; } - /** - * {@inheritDoc} - */ @Override public TabularData getCacheRegionStats() { final List list = new ArrayList(); @@ -337,18 +235,11 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate return td; } - /** - * {@inheritDoc} - */ @Override protected void doDispose() { // no-op } - /** - * {@inheritDoc} - * @see AbstractEmitterBean#getNotificationInfo() - */ @Override public MBeanNotificationInfo[] getNotificationInfo() { return new MBeanNotificationInfo[] {NOTIFICATION_INFO}; diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/NullHibernateStats.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/NullHibernateStats.java index 56c66c0e90..eafe92b3b4 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/NullHibernateStats.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/NullHibernateStats.java @@ -124,6 +124,7 @@ public final class NullHibernateStats implements HibernateStats { * Not supported right now * @return 0 always */ + @SuppressWarnings("UnusedDeclaration") public long getDBSQLExecutionSample() { // no-op return 0; diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/ProviderMBeanRegistrationHelper.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/ProviderMBeanRegistrationHelper.java index 7bfa2d7856..fb5c1d90a7 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/ProviderMBeanRegistrationHelper.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/ProviderMBeanRegistrationHelper.java @@ -24,7 +24,6 @@ package org.hibernate.cache.ehcache.management.impl; import java.lang.reflect.Field; -import java.util.Iterator; import java.util.Map; import java.util.Properties; import java.util.TimerTask; diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/QueryStats.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/QueryStats.java index 5be104df11..ab2f203d23 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/QueryStats.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/QueryStats.java @@ -34,7 +34,6 @@ import javax.management.openmbean.TabularDataSupport; import javax.management.openmbean.TabularType; import java.io.Serializable; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.hibernate.stat.QueryStatistics; @@ -175,6 +174,7 @@ public class QueryStats implements Serializable { * Constructor * @param cData CompositeDate to construct an instance from */ + @SuppressWarnings("UnusedAssignment") public QueryStats(final CompositeData cData) { int i = 0; query = (String) cData.get( ITEM_NAMES[i++] ); @@ -203,9 +203,6 @@ public class QueryStats implements Serializable { executionMinTime += stats.getExecutionMinTime(); } - /** - * {@inheritDoc} - */ @Override public String toString() { return "query=" + query + ", cacheHitCount=" + cacheHitCount + ", cacheMissCount=" + cacheMissCount @@ -218,6 +215,7 @@ public class QueryStats implements Serializable { * Accessor to the queryString * @return the query string */ + @SuppressWarnings("UnusedDeclaration") public String getQuery() { return query; } @@ -322,6 +320,7 @@ public class QueryStats implements Serializable { * @param tabularData the tabularData with the {@link CompositeData} of stats to extract * @return all queryStats as an array */ + @SuppressWarnings({"unchecked", "UnusedDeclaration"}) public static QueryStats[] fromTabularData(final TabularData tabularData) { final List countList = new ArrayList( tabularData.size() ); for ( Object o : tabularData.values() ) { diff --git a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/access/TransactionalAccessDelegate.java b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/access/TransactionalAccessDelegate.java index 8069383837..dfb7c24a1c 100755 --- a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/access/TransactionalAccessDelegate.java +++ b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/access/TransactionalAccessDelegate.java @@ -58,6 +58,7 @@ public class TransactionalAccessDelegate { * @param region to control access to * @param validator put from load validator */ + @SuppressWarnings("unchecked") public TransactionalAccessDelegate(BaseRegion region, PutFromLoadValidator validator) { this.region = region; this.cache = region.getCache(); @@ -73,6 +74,7 @@ public class TransactionalAccessDelegate { * @return the cached object or null * @throws CacheException if the cache retrieval failed */ + @SuppressWarnings("UnusedParameters") public Object get(Object key, long txTimestamp) throws CacheException { if ( !region.checkValid() ) { return null; @@ -109,6 +111,7 @@ public class TransactionalAccessDelegate { * @return true if the object was successfully cached * @throws CacheException if storing the object failed */ + @SuppressWarnings("UnusedParameters") public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride) throws CacheException { if ( !region.checkValid() ) { @@ -154,6 +157,7 @@ public class TransactionalAccessDelegate { * @return Were the contents of the cache actual changed by this operation? * @throws CacheException if the insert fails */ + @SuppressWarnings("UnusedParameters") public boolean insert(Object key, Object value, Object version) throws CacheException { if ( !region.checkValid() ) { return false; @@ -174,6 +178,7 @@ public class TransactionalAccessDelegate { * @return Whether the contents of the cache actual changed by this operation * @throws CacheException if the update fails */ + @SuppressWarnings("UnusedParameters") public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) throws CacheException { // We update whether or not the region is valid. Other nodes @@ -241,7 +246,8 @@ public class TransactionalAccessDelegate { } final Transaction tx = region.suspend(); try { - region.invalidateRegion(); // Invalidate the local region and then go remote + // Invalidate the local region and then go remote + region.invalidateRegion(); Caches.broadcastEvictAll( cache ); } finally {