📄 jahiacachefactory.java
字号:
//// ____.// __/\ ______| |__/\. _______// __ .____| | \ | +----+ \// _______| /--| | | - \ _ | : - \_________// \\______: :---| : : | : | \________>// |__\---\_____________:______: :____|____:_____\// /_____|//// . . . i n j a h i a w e t r u s t . . .////// JahiaCache Factory// DJ 06.01.2001+//// createJahiaCache (ID, JahiaCacheIO)//package org.jahia.services.cache;import java.util.*; // Vectorimport org.jahia.utils.*; // JahiaConsoleimport org.jahia.data.fields.*; // JahiaFieldimport org.jahia.data.cache.*; // JahiaCache, JahiaCacheIOimport org.jahia.services.*; // ServicesRegistryimport org.jahia.exceptions.*; // JahiaException/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: Jahia Inc.</p> * @author David Jilli * @todo FIXME we should really only store an common interface in here !! */public class JahiaCacheFactory { private static JahiaCacheFactory m_instance = null; // containing every JahiaCache's created /** * @associates JahiaCache */ private Hashtable allCaches = new Hashtable(); /*** * constructor */ private JahiaCacheFactory() { JahiaConsole.println( "CacheFactory", "***** Starting Cache Factory *****" ); } // end constructor /*** * getInstance */ public static synchronized JahiaCacheFactory getInstance() { if (m_instance == null) { m_instance = new JahiaCacheFactory(); } return m_instance; } // end getInstance /** * Creates a new JahiaCache object * * @return the jahia cache */ public JahiaCache createJahiaCache(String cacheName, String cachedesc, JahiaCacheIO cacheIO, int maxCachedObjects) { // a cache with similar name already exists! if (allCaches.get(cacheName)!=null) { JahiaConsole.println ("JahiaCacheFactory", "Huston, I think we have a problem : the cache "+cacheName+" is already defined!"); } JahiaCache jCache = new JahiaCache(cacheName, cachedesc, cacheIO, maxCachedObjects); allCaches.put (cacheName, jCache); // adds the cache to the hashtable return jCache; } /** * Creates a new JahiaSimpleCache object * * @return the jahia cache */ public JahiaSimpleCache createJahiaSimpleCache(String cacheName, String cachedesc, int maxCachedObjects) { // a cache with similar name already exists! if (allCaches.get(cacheName)!=null) { JahiaConsole.println ("JahiaCacheFactory", "Huston, I think we have a problem : the cache "+cacheName+" is already defined!"); } JahiaSimpleCache jCache = new JahiaSimpleCache(cacheName, cachedesc, maxCachedObjects); allCaches.put (cacheName, jCache); // adds the cache to the hashtable return jCache; } /** * Returns a specific cache * @param cacheName name of the cache to retrieve from the factory. * @return Object returns an object because we store two different types * of object : JahiaCache or JahiaSimpleCache. * @todo FIXME we should really only store an common interface in here !! */ public Object getCache(String cacheName) { return allCaches.get(cacheName); } /** * Returns an enumeration of all the cache names * @return an enumeration of String objects that contain the cache names. */ public Enumeration getNames() { return allCaches.keys(); }} // end JahiaCacheFactory
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -