HHH-8211 - Checkstyle and FindBugs fix-ups

This commit is contained in:
Steve Ebersole 2013-05-09 19:51:10 -05:00
parent 6fe63e035c
commit 8e3770235b
16 changed files with 133 additions and 346 deletions

View File

@ -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();

View File

@ -36,11 +36,11 @@ public class ParameterBindImpl<T> implements ParameterBind<T> {
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;
}

View File

@ -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 );

View File

@ -51,6 +51,16 @@ public class ProcedureCallMementoImpl implements ProcedureCallMemento {
private final Map<String,Object> 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,

View File

@ -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 )

View File

@ -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<String> copy(Set<String> 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<String,Object> copy(Map<String, Object> 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 ) {

View File

@ -0,0 +1,4 @@
/**
* Defines the internal support for implementing stored procedure calling.
*/
package org.hibernate.procedure.internal;

View File

@ -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();

View File

@ -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
* <p/>
* 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
* <p/>
* 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
* <p/>
* NOTE : No-op in this case
*/
@Override
public void notifyCacheRemoved(String cacheName) {

View File

@ -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<String, Map<String, Object>> getRegionCacheAttributes() {
final Map<String, Map<String, Object>> result = new HashMap<String, Map<String, Object>>();
@ -294,9 +233,6 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
return result;
}
/**
* {@inheritDoc}
*/
@Override
public Map<String, Object> getRegionCacheAttributes(String regionName) {
final Map<String, Object> result = new HashMap<String, Object>();
@ -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<String, int[]> getRegionCacheSamples() {
final Map<String, int[]> rv = new HashMap<String, int[]>();
@ -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<String> rv = new ArrayList<String>();
@ -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};

View File

@ -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<EntityStats> 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()] );
}

View File

@ -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<CompositeData> result = new ArrayList<CompositeData>();
@ -279,11 +190,6 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
return td;
}
/**
* {@inheritDoc}
*
* @see HibernateStats#getCollectionStats()
*/
@Override
public TabularData getCollectionStats() {
final List<CompositeData> result = new ArrayList<CompositeData>();
@ -300,11 +206,6 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
return td;
}
/**
* {@inheritDoc}
*
* @see HibernateStats#getQueryStats()
*/
@Override
public TabularData getQueryStats() {
final List<CompositeData> result = new ArrayList<CompositeData>();
@ -318,9 +219,6 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
return td;
}
/**
* {@inheritDoc}
*/
@Override
public TabularData getCacheRegionStats() {
final List<CompositeData> list = new ArrayList<CompositeData>();
@ -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};

View File

@ -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;

View File

@ -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;

View File

@ -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<QueryStats> countList = new ArrayList( tabularData.size() );
for ( Object o : tabularData.values() ) {

View File

@ -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 <tt>null</tt>
* @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 <tt>true</tt> 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 {