KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opencms > workplace > CmsCheckMem


1 /*
2 * File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/workplace/CmsCheckMem.java,v $
3 * Date : $Date: 2005/05/31 15:51:19 $
4 * Version: $Revision: 1.2 $
5 *
6 * This library is part of OpenCms -
7 * the Open Source Content Mananagement System
8 *
9 * Copyright (C) 2001 The OpenCms Group
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * For further information about OpenCms, please see the
22 * OpenCms Website: http://www.opencms.org
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 */

28
29
30 package com.opencms.workplace;
31
32 import org.opencms.file.CmsObject;
33 import org.opencms.main.CmsException;
34 import org.opencms.main.CmsLog;
35
36 import com.opencms.template.CmsXmlTemplateFile;
37
38 import java.util.Hashtable JavaDoc;
39
40 /**
41  * Template class for displaying OpenCms workplace task head screens.
42  * <P>
43  *
44  * @author Andreas Schouten
45  * @version $Revision: 1.2 $ $Date: 2005/05/31 15:51:19 $
46  * @see com.opencms.workplace.CmsXmlWpTemplateFile
47  *
48  * @deprecated Will not be supported past the OpenCms 6 release.
49  */

50
51 public class CmsCheckMem extends CmsWorkplaceDefault {
52     
53     /**
54      * Gets the content of a defined section in a given template file and its subtemplates
55      * with the given parameters.
56      *
57      * @see #getContent(CmsObject, String, String, Hashtable, String)
58      * @param cms CmsObject Object for accessing system resources.
59      * @param templateFile Filename of the template file.
60      * @param elementName Element name of this template in our parent template.
61      * @param parameters Hashtable with all template class parameters.
62      * @param templateSelector template section that should be processed.
63      */

64     
65     public byte[] getContent(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName,
66             Hashtable JavaDoc parameters, String JavaDoc templateSelector) throws CmsException {
67         if(CmsLog.getLog(this).isDebugEnabled() && C_DEBUG) {
68             CmsLog.getLog(this).debug("Getting content of element " + ((elementName==null)?"<root>":elementName));
69             CmsLog.getLog(this).debug("Template file is: " + templateFile);
70             CmsLog.getLog(this).debug("Selected template section is: " + ((templateSelector==null)?"<default>":templateSelector));
71         }
72         CmsXmlTemplateFile xmlTemplateDocument = getOwnTemplateFile(cms, templateFile,
73                 elementName, parameters, templateSelector);
74         xmlTemplateDocument.setData("mem", getMem());
75         
76         // Now load the template file and start the processing
77
return startProcessing(cms, xmlTemplateDocument, elementName, parameters,
78                 templateSelector);
79     }
80     
81     /**
82      * Creates a Textstring, containing all, free and used memeory.
83      * @return String with memory information.
84      */

85     
86     private String JavaDoc getMem() {
87         long total = Runtime.getRuntime().totalMemory() / 1024;
88         long free = Runtime.getRuntime().freeMemory() / 1024;
89         return ("OpenCms Avail. Mem:" + total + "k, Free Mem:" + free + "k, Used Mem:"
90                 + (total - free) + "k");
91     }
92     
93     /**
94      * Indicates if the results of this class are cacheable.
95      *
96      * @param cms CmsObject Object for accessing system resources
97      * @param templateFile Filename of the template file
98      * @param elementName Element name of this template in our parent template.
99      * @param parameters Hashtable with all template class parameters.
100      * @param templateSelector template section that should be processed.
101      * @return <EM>true</EM> if cacheable, <EM>false</EM> otherwise.
102      */

103     
104     public boolean isCacheable(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName,
105             Hashtable JavaDoc parameters, String JavaDoc templateSelector) {
106         return false;
107     }
108 }
109
Popular Tags