001: /*
002: * File : $Source: /usr/local/cvs/opencms/src/org/opencms/file/types/CmsResourceTypePlain.java,v $
003: * Date : $Date: 2008-02-27 12:05:45 $
004: * Version: $Revision: 1.15 $
005: *
006: * This library is part of OpenCms -
007: * the Open Source Content Management System
008: *
009: * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * For further information about Alkacon Software GmbH, please see the
022: * company website: http://www.alkacon.com
023: *
024: * For further information about OpenCms, please see the
025: * project website: http://www.opencms.org
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: package org.opencms.file.types;
033:
034: import org.opencms.configuration.CmsConfigurationException;
035: import org.opencms.loader.CmsDumpLoader;
036: import org.opencms.main.OpenCms;
037:
038: /**
039: * Resource type descriptor for the type "plain".<p>
040: *
041: * @author Alexander Kandzior
042: *
043: * @version $Revision: 1.15 $
044: *
045: * @since 6.0.0
046: */
047: public class CmsResourceTypePlain extends A_CmsResourceType {
048:
049: /** The type id of this resource type. */
050: private static final int RESOURCE_TYPE_ID = 1;
051:
052: /** The name of this resource type. */
053: private static final String RESOURCE_TYPE_NAME = "plain";
054:
055: /** Indicates that the static configuration of the resource type has been frozen. */
056: private static boolean m_staticFrozen;
057:
058: /** The static type id of this resource type. */
059: private static int m_staticTypeId;
060:
061: /**
062: * Default constructor, used to initialize member variables.<p>
063: */
064: public CmsResourceTypePlain() {
065:
066: super ();
067: m_typeId = RESOURCE_TYPE_ID;
068: m_typeName = RESOURCE_TYPE_NAME;
069: }
070:
071: /**
072: * Returns the static type id of this (default) resource type.<p>
073: *
074: * @return the static type id of this (default) resource type
075: */
076: public static int getStaticTypeId() {
077:
078: return m_staticTypeId;
079: }
080:
081: /**
082: * Returns the static type name of this (default) resource type.<p>
083: *
084: * @return the static type name of this (default) resource type
085: */
086: public static String getStaticTypeName() {
087:
088: return RESOURCE_TYPE_NAME;
089: }
090:
091: /**
092: * A plain resource might appear as a sub-element in a JSP,
093: * therefore it needs cache properties.<p>
094: *
095: * @see org.opencms.file.types.I_CmsResourceType#getCachePropertyDefault()
096: */
097: public String getCachePropertyDefault() {
098:
099: return "always;";
100: }
101:
102: /**
103: * @see org.opencms.file.types.I_CmsResourceType#getLoaderId()
104: */
105: public int getLoaderId() {
106:
107: return CmsDumpLoader.RESOURCE_LOADER_ID;
108: }
109:
110: /**
111: * @see org.opencms.file.types.A_CmsResourceType#initConfiguration(java.lang.String, java.lang.String, String)
112: */
113: public void initConfiguration(String name, String id,
114: String className) throws CmsConfigurationException {
115:
116: if ((OpenCms.getRunLevel() > OpenCms.RUNLEVEL_2_INITIALIZING)
117: && m_staticFrozen) {
118: // configuration already frozen
119: throw new CmsConfigurationException(Messages.get()
120: .container(Messages.ERR_CONFIG_FROZEN_3,
121: this .getClass().getName(),
122: getStaticTypeName(),
123: new Integer(getStaticTypeId())));
124: }
125:
126: if (!RESOURCE_TYPE_NAME.equals(name)) {
127: // default resource type MUST have default name
128: throw new CmsConfigurationException(Messages.get()
129: .container(
130: Messages.ERR_INVALID_RESTYPE_CONFIG_NAME_3,
131: this .getClass().getName(),
132: RESOURCE_TYPE_NAME, name));
133: }
134:
135: // freeze the configuration
136: m_staticFrozen = true;
137:
138: super .initConfiguration(RESOURCE_TYPE_NAME, id, className);
139: // set static members with values from the configuration
140: m_staticTypeId = m_typeId;
141: }
142: }
|