📄 jahiapagetemplatecache.java
字号:
//// ____.// __/\ ______| |__/\. _______// __ .____| | \ | +----+ \// _______| /--| | | - \ _ | : - \_________// \\______: :---| : : | : | \________>// |__\---\_____________:______: :____|____:_____\// /_____|//// . . . i n j a h i a w e t r u s t . . .//package org.jahia.services.pages;import java.util.Hashtable;import java.util.Enumeration;import org.jahia.services.pages.JahiaPageDefinition;/** * This class is used by the JahiaPageBaseService class. It implements cache * storing page infos. * * @author Fulco Houkes * @version 1.0 */class JahiaPageTemplateCache{ private static JahiaPageTemplateCache mObject = null; private static Hashtable mCache = null; //------------------------------------------------------------------------- /** * constructor */ private JahiaPageTemplateCache () { mCache = new Hashtable (); } //------------------------------------------------------------------------- /** * Reset the cache, by removing all the pages from the cache */ public synchronized void reset () { mCache.clear(); } //------------------------------------------------------------------------- /** * returns an instance of the registry */ public static synchronized JahiaPageTemplateCache getInstance() { if (mObject == null) { mObject = new JahiaPageTemplateCache(); } return mObject; } //------------------------------------------------------------------------- /** * adds a page to the registry * * @param thePage the JahiaPage object to add * */ public synchronized void add (JahiaPageDefinition template) { mCache.put (new Integer (template.getID()), template); JahiaPageDefinition pageDef = (JahiaPageDefinition)mCache.get(new Integer(template.getID())); //System.out.println(" added template in cache " + pageDef.getName() ); } //------------------------------------------------------------------------- /** * removes a page from the registry * * @param pageID the page id to be removed * */ public synchronized void remove (int templateID) { mCache.remove (new Integer (templateID)); } //------------------------------------------------------------------------- /** * Return the page related to the specified ID. If the page is not present * in the registry, an attempt is made to extract if from the database * * @param pageID the page id * @return a JahiaPage object * */ public JahiaPageDefinition get (int templateID) { return (JahiaPageDefinition) mCache.get (new Integer (templateID)); } //------------------------------------------------------------------------- /** * Return the internal state of the cache * * @return Return a string containing all the pages ID present in the * cache. */ public String toString () { return "<not yet implemented .. any volunteer ?"; } //------------------------------------------------------------------------- /** * Return all the page IDs present in the cache. * * @return Return an enumeration holding all the page IDs present in the * cache. */ public Enumeration getTemplateIDs () { return mCache.keys(); } //------------------------------------------------------------------------- /** Return all the pages templates present in the cache. * * @return Return an Enumeration holding all the page templates. */ public Enumeration getTemplates () { return mCache.elements(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -