CacheManager.java

Index Score
net.sf.ehcache
ehcache

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
JAVA0126JAVA0126 Method declares unchecked exception in throws
DOC_COMMENTNumber of javadoc comment lines
SIZESize of the file in bytes
JAVA0143JAVA0143 Synchronized method
COMMENTSComment lines
DECL_COMMENTSComments in declarations
RETURNSNumber of return points from functions
BLOCKSNumber of blocks
LINESNumber of lines in the source file
INTERFACE_COMPLEXITYInterface complexity
EXITSProcedure exits
CYCLOMATICCyclomatic complexity
COMPARISONSNumber of comparison operators
FUNCTIONSNumber of function declarations
OPERATORSNumber of operators
JAVA0115JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
LOCLines of code
PROGRAM_LENGTHHalstead program length
ELOCEffective lines of code
LOGICAL_LINESNumber of statements
JAVA0041JAVA0041 Nested synchronized block
UNIQUE_OPERANDSNumber of unique operands
OPERANDSNumber of operands
PROGRAM_VOCABHalstead program vocabulary
JAVA0034JAVA0034 Missing braces in if statement
JAVA0075JAVA0075 Method parameter hides field
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0144JAVA0144 Line exceeds maximum M characters
JAVA0254JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0270JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
PARAMSNumber of formal parameter declarations
JAVA0117JAVA0117 Missing javadoc: method 'method'
JAVA0177JAVA0177 Variable declaration missing initializer
NEST_DEPTHMaximum nesting depth
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
UNIQUE_OPERATORSNumber of unique operators
LOOPSNumber of loops
JAVA0100JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0145JAVA0145 Tab character used in source file
/** * Copyright 2003-2008 Luck Consulting Pty Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package net.sf.ehcache; import net.sf.ehcache.config.Configuration; import net.sf.ehcache.config.ConfigurationFactory; import net.sf.ehcache.config.ConfigurationHelper; import net.sf.ehcache.config.DiskStoreConfiguration; import net.sf.ehcache.distribution.CacheManagerPeerListener; import net.sf.ehcache.distribution.CacheManagerPeerProvider; import net.sf.ehcache.event.CacheManagerEventListener; import net.sf.ehcache.event.CacheManagerEventListenerRegistry; import net.sf.ehcache.store.DiskStore; import net.sf.ehcache.util.PropertyUtil; import net.sf.ehcache.jcache.JCache; import java.io.File; import java.io.InputStream; import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.logging.Logger; import java.util.logging.Level; /** * A container for {@link Ehcache}s that maintain all aspects of their lifecycle. * <p/> * CacheManager may be either be a singleton if created with factory methods, or multiple instances may exist, * in which case resources required by each must be unique. * <p/> * A CacheManager holds references to Cache, Ehcache, and JCache objects and manages their creation and lifecycle. * * @author Greg Luck * @version $Id: CacheManager.java 744 2008-08-16 20:10:49Z gregluck $ */ public class CacheManager { /** * Keeps track of all known CacheManagers. Used to check on conflicts. * CacheManagers should remove themselves from this list during shut down. */ public static final List ALL_CACHE_MANAGERS = Collections.synchronizedList(new ArrayList()); /** * System property to enable creation of a shutdown hook for CacheManager. */ public static final String ENABLE_SHUTDOWN_HOOK_PROPERTY = "net.sf.ehcache.enableShutdownHook"; private static final Logger LOG = Logger.getLogger(CacheManager.class.getName()); /** * The Singleton Instance. */ private static CacheManager singleton; /** * Ehcaches managed by this manager. */ protected final Map ehcaches = new HashMap(); /** * Caches managed by this manager. A Cache is also an Ehcache. * For central managment the cache is also in the ehcaches map. */ protected final Map caches = new HashMap(); /** * JCaches managed by this manager. For each JCache there is a backing ehcache stored in the ehcaches map. */ protected final Map jCaches = new HashMap(); /** * Default cache cache. */ private Ehcache defaultCache; /** * The path for the directory in which disk caches are created. */ private String diskStorePath; /** * A name for this CacheManager to distinguish it from others. */ private String name; private Status status; private CacheManagerPeerProvider cacheManagerPeerProvider; private CacheManagerPeerListener cacheManagerPeerListener; private CacheManagerEventListenerRegistry cacheManagerEventListenerRegistry = new CacheManagerEventListenerRegistry(); /** * The shutdown hook thread for CacheManager. This ensures that the CacheManager and Caches are left in a * consistent state on a CTRL-C or kill. * <p/> * This thread must be unregistered as a shutdown hook, when the CacheManager is disposed. * Otherwise the CacheManager is not GC-able. * <p/> * Of course kill -9 or abrupt termination will not run the shutdown hook. In this case, various * sanity checks are made at start up. */ private Thread shutdownHook; /** * An constructor for CacheManager, which takes a configuration object, rather than one created by parsing * an ehcache.xml file. This constructor gives complete control over the creation of the CacheManager. * <p/> * Care should be taken to ensure that, if multiple CacheManages are created, they do now overwrite each others * disk store files, as would happend if two were created which used the same diskStore path. * <p/> * This method does not act as a singleton. Callers must maintain their own reference to it. * <p/> * Note that if one of the {@link #create()} methods are called, a new singleton instance will be created, * separate from any instances created in this method. * * @param configuration * @throws CacheException */ public CacheManager(Configuration configuration) throws CacheException { status = Status.STATUS_UNINITIALISED; init(configuration, null, null, null); } /** * An ordinary constructor for CacheManager. * This method does not act as a singleton. Callers must maintain a reference to it. * Note that if one of the {@link #create()} methods are called, a new singleton will be created, * separate from any instances created in this method. * * @param configurationFileName an xml configuration file available through a file name. The configuration * {@link File} is created * using new <code>File(configurationFileName)</code> * @throws CacheException * @see #create(String) */ public CacheManager(String configurationFileName) throws CacheException { status = Status.STATUS_UNINITIALISED; init(null, configurationFileName, null, null); } /** * An ordinary constructor for CacheManager. * This method does not act as a singleton. Callers must maintain a reference to it. * Note that if one of the {@link #create()} methods are called, a new singleton will be created, * separate from any instances created in this method. * <p/> * This method can be used to specify a configuration resource in the classpath other * than the default of \"/ehcache.xml\": * <pre> * URL url = this.getClass().getResource("/ehcache-2.xml"); * </pre> * Note that {@link Class#getResource} will look for resources in the same package unless a leading "/" * is used, in which case it will look in the root of the classpath. * <p/> * You can also load a resource using other class loaders. e.g. {@link Thread#getContextClassLoader()} * * @param configurationURL an xml configuration available through a URL. * @throws CacheException * @see #create(java.net.URL) * @since 1.2 */ public CacheManager(URL configurationURL) throws CacheException { status = Status.STATUS_UNINITIALISED; init(null, null, configurationURL, null); } /** * An ordinary constructor for CacheManager. * This method does not act as a singleton. Callers must maintain a reference to it. * Note that if one of the {@link #create()} methods are called, a new singleton will be created, * separate from any instances created in this method. * * @param configurationInputStream an xml configuration file available through an inputstream * @throws CacheException * @see #create(java.io.InputStream) */ public CacheManager(InputStream configurationInputStream) throws CacheException { status = Status.STATUS_UNINITIALISED; init(null, null, null, configurationInputStream); } /** * Constructor. * * @throws CacheException */ public CacheManager() throws CacheException { //default config will be done status = Status.STATUS_UNINITIALISED; init(null, null, null, null); } private void init(Configuration configuration, String configurationFileName, URL configurationURL, InputStream configurationInputStream) { Configuration localConfiguration = configuration; if (configuration == null) { localConfiguration = parseConfiguration(configurationFileName, configurationURL, configurationInputStream); } else { localConfiguration.setSource("Programmatically configured."); } ConfigurationHelper configurationHelper = new ConfigurationHelper(this, localConfiguration); configure(configurationHelper); status = Status.STATUS_ALIVE; if (cacheManagerPeerProvider != null) { cacheManagerPeerProvider.init(); } cacheManagerEventListenerRegistry.init(); addShutdownHookIfRequired(); //do this last addConfiguredCaches(configurationHelper); } /** * Loads configuration, either from the supplied {@link ConfigurationHelper} or by creating a new Configuration instance * from the configuration file referred to by file, inputstream or URL. * <p/> * Should only be called once. * * @param configurationFileName the file name to parse, or null * @param configurationURL the URL to pass, or null * @param configurationInputStream, the InputStream to parse, or null * @return the loaded configuration * @throws CacheException if the configuration cannot be parsed */ private synchronized Configuration parseConfiguration(String configurationFileName, URL configurationURL, InputStream configurationInputStream) throws CacheException { reinitialisationCheck(); Configuration configuration; String configurationSource; if (configurationFileName != null) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Configuring CacheManager from " + configurationFileName); } configuration = ConfigurationFactory.parseConfiguration(new File(configurationFileName)); configurationSource = "file located at " + configurationFileName; } else if (configurationURL != null) { configuration = ConfigurationFactory.parseConfiguration(configurationURL); configurationSource = "URL of " + configurationURL; } else if (configurationInputStream != null) { configuration = ConfigurationFactory.parseConfiguration(configurationInputStream); configurationSource = "InputStream " + configurationInputStream; } else { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Configuring ehcache from classpath."); } configuration = ConfigurationFactory.parseConfiguration(); configurationSource = "classpath"; } configuration.setSource(configurationSource); return configuration; } private void configure(ConfigurationHelper configurationHelper) { diskStorePath = configurationHelper.getDiskStorePath(); int cachesRequiringDiskStores = configurationHelper.numberOfCachesThatOverflowToDisk().intValue() + configurationHelper.numberOfCachesThatAreDiskPersistent().intValue(); if (diskStorePath == null && cachesRequiringDiskStores > 0) { diskStorePath = DiskStoreConfiguration.getDefaultPath(); LOG.warning("One or more caches require a DiskStore but there is no diskStore element configured." + " Using the default disk store path of " + DiskStoreConfiguration.getDefaultPath() + ". Please explicitly configure the diskStore element in ehcache.xml."); } detectAndFixDiskStorePathConflict(configurationHelper); cacheManagerEventListenerRegistry.registerListener(configurationHelper.createCacheManagerEventListener()); cacheManagerPeerListener = configurationHelper.createCachePeerListener(); cacheManagerEventListenerRegistry.registerListener(cacheManagerPeerListener); detectAndFixCacheManagerPeerListenerConflict(configurationHelper); ALL_CACHE_MANAGERS.add(this); cacheManagerPeerProvider = configurationHelper.createCachePeerProvider(); defaultCache = configurationHelper.createDefaultCache(); } private void detectAndFixDiskStorePathConflict(ConfigurationHelper configurationHelper) { if (diskStorePath == null) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("No disk store path defined. Skipping disk store path conflict test."); } return; } for (int i = 0; i < ALL_CACHE_MANAGERS.size(); i++) { CacheManager cacheManager = (CacheManager) ALL_CACHE_MANAGERS.get(i); if (diskStorePath.equals(cacheManager.diskStorePath)) { String newDiskStorePath = diskStorePath + File.separator + DiskStore.generateUniqueDirectory(); LOG.warning("Creating a new instance of CacheManager using the diskStorePath \"" + diskStorePath + "\" which is already used" + " by an existing CacheManager.\nThe source of the configuration was " + configurationHelper.getConfigurationBean().getConfigurationSource() + ".\n" + "The diskStore path for this CacheManager will be set to " + newDiskStorePath + ".\nTo avoid this" + " warning consider using the CacheManager factory methods to create a singleton CacheManager " + "or specifying a separate ehcache configuration (ehcache.xml) for each CacheManager instance."); diskStorePath = newDiskStorePath; break; } } } private void detectAndFixCacheManagerPeerListenerConflict(ConfigurationHelper configurationHelper) { if (cacheManagerPeerListener == null) { return; } String uniqueResourceIdentifier = cacheManagerPeerListener.getUniqueResourceIdentifier(); for (int i = 0; i < ALL_CACHE_MANAGERS.size(); i++) { CacheManager cacheManager = (CacheManager) ALL_CACHE_MANAGERS.get(i); CacheManagerPeerListener otherCacheManagerPeerListener = cacheManager.cacheManagerPeerListener; if (otherCacheManagerPeerListener == null) { continue; } String otherUniqueResourceIdentifier = otherCacheManagerPeerListener.getUniqueResourceIdentifier(); if (uniqueResourceIdentifier.equals(otherUniqueResourceIdentifier)) { LOG.warning("Creating a new instance of CacheManager with a CacheManagerPeerListener which " + "has a conflict on a resource that must be unique.\n" + "The resource is " + uniqueResourceIdentifier + ".\n" + "Attempting automatic resolution. The source of the configuration was " + configurationHelper.getConfigurationBean().getConfigurationSource() + ".\n" + "To avoid this warning consider using the CacheManager factory methods to create a " + "singleton CacheManager " + "or specifying a separate ehcache configuration (ehcache.xml) for each CacheManager instance."); cacheManagerPeerListener.attemptResolutionOfUniqueResourceConflict(); break; } } } private void addConfiguredCaches(ConfigurationHelper configurationHelper) { Set unitialisedCaches = configurationHelper.createCaches(); for (Iterator iterator = unitialisedCaches.iterator(); iterator.hasNext();) { Ehcache unitialisedCache = (Ehcache) iterator.next(); addCacheNoCheck(unitialisedCache); } } private void reinitialisationCheck() throws IllegalStateException { if (defaultCache != null || diskStorePath != null || ehcaches.size() != 0 || status.equals(Status.STATUS_SHUTDOWN)) { throw new IllegalStateException("Attempt to reinitialise the CacheManager"); } } /** * A factory method to create a singleton CacheManager with default config, or return it if it exists. * <p/> * The configuration will be read, {@link Ehcache}s created and required stores initialized. * When the {@link CacheManager} is no longer required, call shutdown to free resources. * * @return the singleton CacheManager * @throws CacheException if the CacheManager cannot be created */ public static CacheManager create() throws CacheException { synchronized (CacheManager.class) { if (singleton == null) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Creating new CacheManager with default config"); } singleton = new CacheManager(); } else { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Attempting to create an existing singleton. Existing singleton returned."); } } return singleton; } } /** * A factory method to create a singleton CacheManager with default config, or return it if it exists. * <p/> * This has the same effect as {@link CacheManager#create} * <p/> * Same as {@link #create()} * * @return the singleton CacheManager * @throws CacheException if the CacheManager cannot be created */ public static CacheManager getInstance() throws CacheException { return CacheManager.create(); } /** * A factory method to create a singleton CacheManager with a specified configuration. * * @param configurationFileName an xml file compliant with the ehcache.xsd schema * <p/> * The configuration will be read, {@link Ehcache}s created and required stores initialized. * When the {@link CacheManager} is no longer required, call shutdown to free resources. */ public static CacheManager create(String configurationFileName) throws CacheException { synchronized (CacheManager.class) { if (singleton == null) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Creating new CacheManager with config file: " + configurationFileName); } singleton = new CacheManager(configurationFileName); } return singleton; } } /** * A factory method to create a singleton CacheManager from an URL. * <p/> * This method can be used to specify a configuration resource in the classpath other * than the default of \"/ehcache.xml\": * This method can be used to specify a configuration resource in the classpath other * than the default of \"/ehcache.xml\": * <pre> * URL url = this.getClass().getResource("/ehcache-2.xml"); * </pre> * Note that {@link Class#getResource} will look for resources in the same package unless a leading "/" * is used, in which case it will look in the root of the classpath. * <p/> * You can also load a resource using other class loaders. e.g. {@link Thread#getContextClassLoader()} * * @param configurationFileURL an URL to an xml file compliant with the ehcache.xsd schema * <p/> * The configuration will be read, {@link Ehcache}s created and required stores initialized. * When the {@link CacheManager} is no longer required, call shutdown to free resources. */ public static CacheManager create(URL configurationFileURL) throws CacheException { synchronized (CacheManager.class) { if (singleton == null) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Creating new CacheManager with config URL: " + configurationFileURL); } singleton = new CacheManager(configurationFileURL); } return singleton; } } /** * A factory method to create a singleton CacheManager from a java.io.InputStream. * <p/> * This method makes it possible to use an inputstream for configuration. * Note: it is the clients responsibility to close the inputstream. * <p/> * * @param inputStream InputStream of xml compliant with the ehcache.xsd schema * <p/> * The configuration will be read, {@link Ehcache}s created and required stores initialized. * When the {@link CacheManager} is no longer required, call shutdown to free resources. */ public static CacheManager create(InputStream inputStream) throws CacheException { synchronized (CacheManager.class) { if (singleton == null) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Creating new CacheManager with InputStream"); } singleton = new CacheManager(inputStream); } return singleton; } } /** * Returns a concrete implementation of Cache, it it is available in the CacheManager. * Consider using getEhcache(String name) instead, which will return decorated caches that are registered. * <p/> * If a decorated ehcache is registered in CacheManager, an undecorated Cache with the same name will also exist. * * @return a Cache, if an object of that type exists by that name, else null * @throws IllegalStateException if the cache is not {@link Status#STATUS_ALIVE} * @see #getEhcache(String) */ public synchronized Cache getCache(String name) throws IllegalStateException, ClassCastException { checkStatus(); return (Cache) caches.get(name); } /** * Gets an Ehcache * <p/> * * @return a Cache, if an object of type Cache exists by that name, else null * @throws IllegalStateException if the cache is not {@link Status#STATUS_ALIVE} */ public synchronized Ehcache getEhcache(String name) throws IllegalStateException { checkStatus(); return (Ehcache) ehcaches.get(name); } /** * Gets a draft JSR107 spec JCache. * <p/> * If a JCache does not exist for the name, but an ehcache does, a new JCache will be created dynamically and added * to the list of JCaches managed by this CacheManager. * Warning: JCache will change as the specification changes, so no guarantee of backward compatibility is made for this method. * * @return a JSR 107 Cache, if an object of that type exists by that name, else null * @throws IllegalStateException if the cache is not {@link Status#STATUS_ALIVE} */ public synchronized JCache getJCache(String name) throws IllegalStateException { checkStatus(); if (jCaches.get(name) != null) { return (JCache) jCaches.get(name); } else if (ehcaches.get(name) != null) { jCaches.put(name, new JCache((Ehcache) ehcaches.get(name), null)); } return (JCache) jCaches.get(name); } /** * Some caches might be persistent, so we want to add a shutdown hook if that is the * case, so that the data and index can be written to disk. */ private void addShutdownHookIfRequired() { String shutdownHookProperty = System.getProperty(ENABLE_SHUTDOWN_HOOK_PROPERTY); boolean enabled = PropertyUtil.parseBoolean(shutdownHookProperty); if (!enabled) { return; } else { LOG.info("The CacheManager shutdown hook is enabled because " + ENABLE_SHUTDOWN_HOOK_PROPERTY + " is set to true."); Thread localShutdownHook = new Thread() { public void run() { synchronized (this) { if (status.equals(Status.STATUS_ALIVE)) { // clear shutdown hook reference to prevent // removeShutdownHook to remove it during shutdown shutdownHook = null; if (LOG.isLoggable(Level.INFO)) { LOG.info("VM shutting down with the CacheManager still active. Calling shutdown."); } shutdown(); } } } }; Runtime.getRuntime().addShutdownHook(localShutdownHook); shutdownHook = localShutdownHook; } } /** * Remove the shutdown hook to prevent leaving orphaned CacheManagers around. This * is called by {@link #shutdown()}} AFTER the status has been set to shutdown. */ private void removeShutdownHook() { if (shutdownHook != null) { // remove shutdown hook try { Runtime.getRuntime().removeShutdownHook(shutdownHook); } catch (IllegalStateException e) { //This will be thrown if the VM is shutting down. In this case //we do not need to worry about leaving references to CacheManagers lying //around and the call is ok to fail. if (LOG.isLoggable(Level.FINE)) { LOG.log(Level.FINE, "IllegalStateException due to attempt to remove a shutdown" + "hook while the VM is actually shutting down.", e); } } shutdownHook = null; } } /** * Adds a {@link Ehcache} based on the defaultCache with the given name. * <p/> * Memory and Disk stores will be configured for it and it will be added * to the map of caches. * <p/> * Also notifies the CacheManagerEventListener after the cache was initialised and added. * <p/> * It will be created with the defaultCache attributes specified in ehcache.xml * * @param cacheName the name for the cache * @throws ObjectExistsException if the cache already exists * @throws CacheException if there was an error creating the cache. */ public synchronized void addCache(String cacheName) throws IllegalStateException, ObjectExistsException, CacheException { checkStatus(); //NPE guard if (cacheName == null || cacheName.length() == 0) { return; } if (ehcaches.get(cacheName) != null) { throw new ObjectExistsException("Cache " + cacheName + " already exists"); } Ehcache cache = null; try { cache = (Ehcache) defaultCache.clone(); } catch (CloneNotSupportedException e) { throw new CacheException("Failure adding cache. Initial cause was " + e.getMessage(), e); } if (cache != null) { cache.setName(cacheName); } addCache(cache); } /** * Adds a {@link Cache} to the CacheManager. * <p/> * Memory and Disk stores will be configured for it and it will be added to the map of caches. * Also notifies the CacheManagerEventListener after the cache was initialised and added. * * @param cache * @throws IllegalStateException if the cache is not {@link Status#STATUS_UNINITIALISED} before this method is called. * @throws ObjectExistsException if the cache already exists in the CacheManager * @throws CacheException if there was an error adding the cache to the CacheManager */ public synchronized void addCache(Cache cache) throws IllegalStateException, ObjectExistsException, CacheException { checkStatus(); if (cache == null) { return; } addCache((Ehcache) cache); caches.put(cache.getName(), cache); } /** * Adds a {@link Cache} to the CacheManager. * <p/> * Memory and Disk stores will be configured for it and it will be added to the map of caches. * Also notifies the CacheManagerEventListener after the cache was initialised and added. * * @param jCache * @throws IllegalStateException if the cache is not {@link Status#STATUS_UNINITIALISED} before this method is called. * @throws ObjectExistsException if the cache already exists in the CacheManager * @throws CacheException if there was an error adding the cache to the CacheManager */ public synchronized void addCache(JCache jCache) throws IllegalStateException, ObjectExistsException, CacheException { checkStatus(); if (jCache == null) { return; } Ehcache backingCache = jCache.getBackingCache(); addCache(backingCache); jCaches.put(backingCache.getName(), jCache); } /** * Adds an {@link Ehcache} to the CacheManager. * <p/> * Memory and Disk stores will be configured for it and it will be added to the map of caches. * Also notifies the CacheManagerEventListener after the cache was initialised and added. * * @param cache * @throws IllegalStateException if the cache is not {@link Status#STATUS_UNINITIALISED} before this method is called. * @throws ObjectExistsException if the cache already exists in the CacheManager * @throws CacheException if there was an error adding the cache to the CacheManager */ public synchronized void addCache(Ehcache cache) throws IllegalStateException, ObjectExistsException, CacheException { checkStatus(); if (cache == null) { return; } addCacheNoCheck(cache); } private synchronized void addCacheNoCheck(Ehcache cache) throws IllegalStateException, ObjectExistsException, CacheException { if (ehcaches.get(cache.getName()) != null) { throw new ObjectExistsException("Cache " + cache.getName() + " already exists"); } cache.setCacheManager(this); cache.setDiskStorePath(diskStorePath); cache.initialise(); try { cache.bootstrap(); } catch (CacheException e) { LOG.log(Level.WARNING, "Cache " + cache.getName() + "requested bootstrap but a CacheException occured. " + e.getMessage(), e); } ehcaches.put(cache.getName(), cache); if (cache instanceof Cache) { caches.put(cache.getName(), cache); } //Don't notify initial config. The init method of each listener should take care of this. if (status.equals(Status.STATUS_ALIVE)) { cacheManagerEventListenerRegistry.notifyCacheAdded(cache.getName()); } } /** * Checks whether a cache of type ehcache exists. * <p/> * * @param cacheName the cache name to check for * @return true if it exists * @throws IllegalStateException if the cache is not {@link Status#STATUS_ALIVE} */ public synchronized boolean cacheExists(String cacheName) throws IllegalStateException { checkStatus(); return (ehcaches.get(cacheName) != null); } /** * Removes all caches using {@link #removeCache} for each cache. */ public synchronized void removalAll() { String[] cacheNames = getCacheNames(); for (int i = 0; i < cacheNames.length; i++) { String cacheName = cacheNames[i]; removeCache(cacheName); } } /** * Remove a cache from the CacheManager. The cache is disposed of. * * @param cacheName the cache name * @throws IllegalStateException if the cache is not {@link Status#STATUS_ALIVE} */ public synchronized void removeCache(String cacheName) throws IllegalStateException { checkStatus(); //NPE guard if (cacheName == null || cacheName.length() == 0) { return; } Ehcache cache = (Ehcache) ehcaches.remove(cacheName); if (cache != null && cache.getStatus().equals(Status.STATUS_ALIVE)) { cache.dispose(); cacheManagerEventListenerRegistry.notifyCacheRemoved(cache.getName()); } jCaches.remove(cacheName); caches.remove(cacheName); } /** * Shuts down the CacheManager. * <p/> * If the shutdown occurs on the singleton, then the singleton is removed, so that if a singleton access method * is called, a new singleton will be created. * <p/> * By default there is no shutdown hook (ehcache-1.3-beta2 and higher). * <p/> * Set the system property net.sf.ehcache.enableShutdownHook=true to turn it on. */ public void shutdown() { synchronized (CacheManager.class) { if (status.equals(Status.STATUS_SHUTDOWN)) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("CacheManager already shutdown"); } return; } if (cacheManagerPeerProvider != null) { cacheManagerPeerProvider.dispose(); } cacheManagerEventListenerRegistry.dispose(); synchronized (CacheManager.class) { ALL_CACHE_MANAGERS.remove(this); Collection cacheSet = ehcaches.values(); for (Iterator iterator = cacheSet.iterator(); iterator.hasNext();) { Ehcache cache = (Ehcache) iterator.next(); if (cache != null) { cache.dispose(); } } defaultCache.dispose(); status = Status.STATUS_SHUTDOWN; //only delete singleton if the singleton is shutting down. if (this == singleton) { singleton = null; } removeShutdownHook(); } } } /** * Returns a list of the current cache names. * * @return an array of {@link String}s * @throws IllegalStateException if the cache is not {@link Status#STATUS_ALIVE} */ public synchronized String[] getCacheNames() throws IllegalStateException { checkStatus(); String[] list = new String[ehcaches.size()]; return (String[]) ehcaches.keySet().toArray(list); } private void checkStatus() { if (!(status.equals(Status.STATUS_ALIVE))) { throw new IllegalStateException("The CacheManager is not alive."); } } /** * Gets the status attribute of the Ehcache * * @return The status value from the Status enum class */ public Status getStatus() { return status; } /** * Clears the contents of all caches in the CacheManager, but without * removing any caches. * <p/> * This method is not synchronized. It only guarantees to clear those elements in a cache * at the time that the {@link Ehcache#removeAll()} mehod on each cache is called. */ public void clearAll() throws CacheException { String[] cacheNames = getCacheNames(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Clearing all caches"); } for (int i = 0; i < cacheNames.length; i++) { String cacheName = cacheNames[i]; Ehcache cache = getEhcache(cacheName); cache.removeAll(); } } /** * Gets the <code>CacheManagerPeerProvider</code> * For distributed caches, the peer provider finds other cache managers and their caches in the same cluster * * @return the provider, or null if one does not exist */ public CacheManagerPeerProvider getCachePeerProvider() { return cacheManagerPeerProvider; } /** * When CacheManage is configured as part of a cluster, a CacheManagerPeerListener will * be registered in it. Use this to access the individual cache listeners * * @return the listener, or null if one does not exist */ public CacheManagerPeerListener getCachePeerListener() { return cacheManagerPeerListener; } /** * Returns the composite listener. A notification sent to this listener will notify all registered * listeners. * * @return null if none * @see "getCacheManagerEventListenerRegistry" */ public CacheManagerEventListener getCacheManagerEventListener() { return cacheManagerEventListenerRegistry; } /** * Same as getCacheManagerEventListenerRegistry().registerListener(cacheManagerEventListener); * Left for backward compatiblity * * @param cacheManagerEventListener the listener to set. * @see "getCacheManagerEventListenerRegistry" * @deprecated Use getCacheManagerEventListenerRegistry instead */ public void setCacheManagerEventListener(CacheManagerEventListener cacheManagerEventListener) { getCacheManagerEventListenerRegistry().registerListener(cacheManagerEventListener); } /** * Gets the CacheManagerEventListenerRegistry. Add and remove listeners here. */ public CacheManagerEventListenerRegistry getCacheManagerEventListenerRegistry() { return cacheManagerEventListenerRegistry; } /** * Gets the CacheManagerPeerProvider, which can be useful for programmatically adding peers. Adding peers * will only be useful if the peer providers are manually provided rather than automatically discovered, otherwise * they will go stale. * * @return the CacheManagerPeerProvider, or null if there is not one. */ public CacheManagerPeerProvider getCacheManagerPeerProvider() { return cacheManagerPeerProvider; } /** * Replaces in the map of Caches managed by this CacheManager an Ehcache with a decorated version of the same * Ehcache. CacheManager can operate fully with a decorated Ehcache. * <p/> * Ehcache Decorators can be used to obtain different behaviour from an Ehcache in a very flexible way. Some examples in * ehcache are: * <ol> * <li>{@link net.sf.ehcache.constructs.blocking.BlockingCache} - A cache that blocks other threads from getting a null element until the first thread * has placed a value in it. * <li>{@link net.sf.ehcache.constructs.blocking.SelfPopulatingCache} - A BlockingCache that has the additional * property of knowing how to load its own entries. * </ol> * Many other kinds are possible. * <p/> * It is generally required that a decorated cache, once constructed, is made available to other execution threads. * The simplest way of doing this is to substitute the original cache for the decorated one here. * <p/> * Note that any overwritten Ehcache methods will take on new behaviours without casting. Casting is only required * for new methods that the decorator introduces. * For more information see the well known Gang of Four Decorator pattern. * * @param ehcache * @param decoratedCache An implementation of Ehcache that wraps the original cache. * @throws CacheException if the two caches do not equal each other. */ public synchronized void replaceCacheWithDecoratedCache(Ehcache ehcache, Ehcache decoratedCache) throws CacheException { if (!ehcache.equals(decoratedCache)) { throw new CacheException("Cannot replace " + decoratedCache.getName() + " It does not equal the incumbent cache."); } else { String cacheName = ehcache.getName(); ehcaches.remove(cacheName); caches.remove(cacheName); ehcaches.put(decoratedCache.getName(), decoratedCache); if (decoratedCache instanceof Cache) { caches.put(decoratedCache.getName(), decoratedCache); } } } /** * Replaces in the map of Caches managed by this CacheManager an Ehcache with a JCache decorated version of the <i>same</i> (see Ehcache equals method) * Ehcache, in a single synchronized method. * <p/> * Warning: JCache will change as the specification changes, so no guarantee of backward compatibility is made for this method. * * @param ehcache * @param jCache A JCache that wraps the original cache. * @throws CacheException */ public synchronized void replaceEhcacheWithJCache(Ehcache ehcache, JCache jCache) throws CacheException { if (!ehcache.getName().equals(jCache.getBackingCache().getName())) { throw new CacheException("Cannot replace ehcache with a JCache where the backing cache has a different name"); } Ehcache backingCache = jCache.getBackingCache(); if (!ehcache.equals(backingCache)) { throw new CacheException("Cannot replace " + backingCache.getName() + " It does not equal the incumbent cache."); } else { jCaches.put(backingCache.getName(), jCache); } } /** * Gets the name of the CacheManager. This is useful for distinguishing multiple CacheManagers * * @return the name, or the output of toString() if it is not set. * @see #toString() which uses either the name or Object.toString() */ public String getName() { if (name != null) { return name; } else { return super.toString(); } } /** * Sets the name of the CacheManager. This is useful for distinguishing multiple CacheManagers * in a monitoring situation. * * @param name a name with characters legal in a JMX ObjectName */ public void setName(String name) { this.name = name; } /** * @return either the name of this CacheManager, or if unset, Object.toString() */ public String toString() { return getName(); } /** * Returns the disk store path. This may be null if no caches need a DiskStore and none was configured. * The path cannot be changed after creation of the CacheManager. All caches take the disk store path * from this value. * @return the disk store path. */ public String getDiskStorePath() { return diskStorePath; } }

The table below shows all metrics for CacheManager.java.

MetricValueDescription
BLOCKS128.00Number of blocks
BLOCK_COMMENT 0.00Number of block comment lines
COMMENTS431.00Comment lines
COMMENT_DENSITY 1.13Comment density
COMPARISONS77.00Number of comparison operators
CYCLOMATIC118.00Cyclomatic complexity
DECL_COMMENTS51.00Comments in declarations
DOC_COMMENT419.00Number of javadoc comment lines
ELOC383.00Effective lines of code
EXEC_COMMENTS 9.00Comments in executable code
EXITS91.00Procedure exits
FUNCTIONS48.00Number of function declarations
HALSTEAD_DIFFICULTY75.43Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY138.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 0.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 1.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 0.00JAVA0007 Should not declare public field
JAVA0008 0.00JAVA0008 Empty catch block
JAVA0009 0.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 0.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 0.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 0.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 0.00JAVA0030 Private field not used
JAVA0031 0.00JAVA0031 Case statement not properly closed
JAVA0032 0.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA0034 0.00JAVA0034 Missing braces in if statement
JAVA0035 0.00JAVA0035 Missing braces in for statement
JAVA0036 0.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 0.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 1.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 0.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 1.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 0.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 0.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 0.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 0.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 3.00JAVA0075 Method parameter hides field
JAVA0076 0.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 1.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 0.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 0.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 0.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 1.00JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0101 0.00JAVA0101 Unnecessary modifier for field in interface
JAVA0102 0.00JAVA0102 Last statement in finalize() not super.finalize()
JAVA0103 0.00JAVA0103 Explicit call to finalize()
JAVA0104 0.00JAVA0104 finalize() only calls super.finalize()
JAVA0105 0.00JAVA0105 Duplicate import declaration
JAVA0106 0.00JAVA0106 Unnecessary import from current package
JAVA0108 4.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 4.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 0.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 0.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 0.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 6.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 0.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 0.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 0.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA012637.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 0.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 1.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 1.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 0.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA014315.00JAVA0143 Synchronized method
JAVA0144 3.00JAVA0144 Line exceeds maximum M characters
JAVA0145 0.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 0.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 0.00JAVA0160 Method does not throw specified exception
JAVA0161 0.00JAVA0161 Conditional wait() not in loop
JAVA0163 0.00JAVA0163 Empty statement
JAVA0165 0.00JAVA0165 Conflicting return statement in finally block
JAVA0166 0.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 0.00JAVA0173 Unused method parameter
JAVA0174 0.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 2.00JAVA0177 Variable declaration missing initializer
JAVA0179 0.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 0.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 0.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 0.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 2.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 0.00JAVA0256 Assignment of external collection/array to field
JAVA0257 0.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 0.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 0.00JAVA0259 Return of collection/array field
JAVA0260 0.00JAVA0260 Use 'enum' instead of Enumerated Type pattern
JAVA0261 0.00JAVA0261 Use specialized Enum collection types
JAVA0262 0.00JAVA0262 Use of char in integer context
JAVA0263 0.00JAVA0263 Long literal ends with 'l' instead of 'L'
JAVA0264 0.00JAVA0264 Integer math in long context - check for overflow
JAVA0265 0.00JAVA0265 Use of Throwable.printStackTrace()
JAVA0266 0.00JAVA0266 Use of System.out
JAVA0267 0.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 2.00JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0271 0.00JAVA0271 Minimize use of on-demand (.*) static imports
JAVA0272 0.00JAVA0272 Thread.run() called
JAVA0273 0.00JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0274 0.00JAVA0274 Serializable class has a synchronized readObject()
JAVA0275 0.00JAVA0275 Serializable class has a synchronized writeObject() and no other synchronized methods
JAVA0276 0.00JAVA0276 Unnecessary use of String constructor
JAVA0277 0.00JAVA0277 Iterator.next() implementation does not throw NoSuchElementException
JAVA0278 0.00JAVA0278 Unnecessary use of Boolean constructor
JAVA0279 0.00JAVA0279 Serialization method readObject or readObjectNoData calls an overridable method
JAVA0280 0.00JAVA0280 IllegalMonitorStateException caught
JAVA0281 0.00JAVA0281 Iterator.next() not called in loop
JAVA0282 0.00JAVA0282 Call to Iterator.next() in loop which does not test Iterator.hasNext()
JAVA0283 0.00JAVA0283 Control variable not updated in loop body
JAVA0284 0.00JAVA0284 Explicit garbage collection
JAVA0285 0.00JAVA0285 Dereference of potentially null variable
JAVA0286 0.00JAVA0286 Dereference of null variable
JAVA0287 0.00JAVA0287 Unnecessary null check
JAVA0288 0.00JAVA0288 Inconsistent null check
LINES1031.00Number of lines in the source file
LINE_COMMENT12.00Number of line comments
LOC499.00Lines of code
LOGICAL_LINES238.00Number of statements
LOOPS 6.00Number of loops
NEST_DEPTH 6.00Maximum nesting depth
OPERANDS1056.00Number of operands
OPERATORS2106.00Number of operators
PARAMS34.00Number of formal parameter declarations
PROGRAM_LENGTH3162.00Halstead program length
PROGRAM_VOCAB368.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS104.00Number of return points from functions
SIZE42868.00Size of the file in bytes
UNIQUE_OPERANDS322.00Number of unique operands
UNIQUE_OPERATORS46.00Number of unique operators
WHITESPACE101.00Number of whitespace lines