/** * Make sure we have a cache manager. This should have happened in the init method. * * @throws CacheException if the configuration cannot be loaded */ protected synchronized void ensureCacheManager() throws CacheException { if ( cacheMgr == null || !cacheMgr.isInitialized() ) { cacheMgr = CompositeCacheManager.getInstance(); } }
@Override public void shutdown() { if (manager.isInitialized()) { LOGGER.debug("Shutting down JCS cache service..."); manager.shutDown(); } }
/** * This will persist the keys on shutdown. * <p> * @see java.lang.Thread#run() */ @SuppressWarnings("synthetic-access") @Override public void run() { if ( isInitialized() ) { log.info( "Shutdown hook activated. Shutdown was not called. Shutting down JCS." ); shutDown(); } } }
/** * Shut down the cache manager and set the instance to null */ public static void shutdown() { synchronized ( JCS.class ) { if ( cacheMgr != null && cacheMgr.isInitialized()) { cacheMgr.shutDown(); } cacheMgr = null; } }
/** * This will persist the keys on shutdown. * <p> * @see java.lang.Thread#run() */ @SuppressWarnings("synthetic-access") @Override public void run() { if ( isInitialized() ) { log.info( "Shutdown hook activated. Shutdown was not called. Shutting down JCS." ); shutDown(); } } }
/** * Get a CacheHub instance which is not configured. If an instance already exists, it will be * returned. *<p> * @return CompositeCacheManager */ public static synchronized CompositeCacheManager getUnconfiguredInstance() { if ( instance == null ) { if ( log.isInfoEnabled() ) { log.info( "Instance is null, returning unconfigured instance" ); } instance = createInstance(); } if (!instance.isInitialized()) { instance.initialize(); } instance.clients.incrementAndGet(); return instance; }
/** * Get a CacheHub instance which is not configured. If an instance already exists, it will be * returned. *<p> * @return CompositeCacheManager */ public static synchronized CompositeCacheManager getUnconfiguredInstance() { if ( instance == null ) { if ( log.isInfoEnabled() ) { log.info( "Instance is null, returning unconfigured instance" ); } instance = createInstance(); } if (!instance.isInitialized()) { instance.initialize(); } instance.incrementClients(); return instance; }
/** * Initializes the cache manager using the props file for the given name. * <p> * @param propsFilename * @return CompositeCacheManager configured from the give propsFileName * @throws CacheException if the configuration cannot be loaded */ public static synchronized CompositeCacheManager getInstance( String propsFilename ) throws CacheException { if ( instance == null ) { if ( log.isInfoEnabled() ) { log.info( "Instance is null, creating with config [" + propsFilename + "]" ); } instance = createInstance(); } if (!instance.isInitialized()) { instance.initialize(); } if (!instance.isConfigured()) { instance.configure( propsFilename ); } instance.clients.incrementAndGet(); return instance; }
/** * Initializes the cache manager using the props file for the given name. * <p> * @param propsFilename * @return CompositeCacheManager configured from the give propsFileName * @throws CacheException if the configuration cannot be loaded */ public static synchronized CompositeCacheManager getInstance( String propsFilename ) throws CacheException { if ( instance == null ) { if ( log.isInfoEnabled() ) { log.info( "Instance is null, creating with config [" + propsFilename + "]" ); } instance = createInstance(); } if (!instance.isInitialized()) { instance.initialize(); } if (!instance.isConfigured()) { instance.configure( propsFilename ); } instance.incrementClients(); return instance; }
/** * Helper method which checks to make sure the cacheMgr class field is set, and if not requests * an instance from CacheManagerFactory. * * @throws CacheException if the configuration cannot be loaded */ private static CompositeCacheManager getCacheManager() throws CacheException { synchronized ( JCS.class ) { if ( cacheMgr == null || !cacheMgr.isInitialized()) { if ( configProps != null ) { cacheMgr = CompositeCacheManager.getUnconfiguredInstance(); cacheMgr.configure( configProps ); } else if ( configFilename != null ) { cacheMgr = CompositeCacheManager.getUnconfiguredInstance(); cacheMgr.configure( configFilename ); } else { cacheMgr = CompositeCacheManager.getInstance(); } } return cacheMgr; } }
/** * Helper method which checks to make sure the cacheMgr class field is set, and if not requests * an instance from CacheManagerFactory. * * @throws CacheException if the configuration cannot be loaded */ private static CompositeCacheManager getCacheManager() throws CacheException { synchronized ( JCS.class ) { if ( cacheMgr == null || !cacheMgr.isInitialized()) { if ( configProps != null ) { cacheMgr = CompositeCacheManager.getUnconfiguredInstance(); cacheMgr.configure( configProps ); } else if ( configFilename != null ) { cacheMgr = CompositeCacheManager.getUnconfiguredInstance(); cacheMgr.configure( configFilename ); } else { cacheMgr = CompositeCacheManager.getInstance(); } } return cacheMgr; } }