001: /*
002: * File : $Source: /usr/local/cvs/opencms/src/org/opencms/file/types/CmsResourceTypePointer.java,v $
003: * Date : $Date: 2008-02-27 12:05:46 $
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.CmsPointerLoader;
036: import org.opencms.main.OpenCms;
037:
038: /**
039: * Resource type descriptor for the type "pointer".<p>
040: *
041: * @author Alexander Kandzior
042: *
043: * @version $Revision: 1.15 $
044: *
045: * @since 6.0.0
046: */
047: public class CmsResourceTypePointer extends A_CmsResourceType {
048:
049: /** The type id of this resource type. */
050: private static final int RESOURCE_TYPE_ID = 5;
051:
052: /** The name of this resource type. */
053: private static final String RESOURCE_TYPE_NAME = "pointer";
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 CmsResourceTypePointer() {
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: * @see org.opencms.file.types.I_CmsResourceType#getLoaderId()
093: */
094: public int getLoaderId() {
095:
096: return CmsPointerLoader.RESOURCE_LOADER_ID;
097: }
098:
099: /**
100: * @see org.opencms.file.types.A_CmsResourceType#initConfiguration(java.lang.String, java.lang.String, String)
101: */
102: public void initConfiguration(String name, String id,
103: String className) throws CmsConfigurationException {
104:
105: if ((OpenCms.getRunLevel() > OpenCms.RUNLEVEL_2_INITIALIZING)
106: && m_staticFrozen) {
107: // configuration already frozen
108: throw new CmsConfigurationException(Messages.get()
109: .container(Messages.ERR_CONFIG_FROZEN_3,
110: this .getClass().getName(),
111: getStaticTypeName(),
112: new Integer(getStaticTypeId())));
113: }
114:
115: if (!RESOURCE_TYPE_NAME.equals(name)) {
116: // default resource type MUST have default name
117: throw new CmsConfigurationException(Messages.get()
118: .container(
119: Messages.ERR_INVALID_RESTYPE_CONFIG_NAME_3,
120: this .getClass().getName(),
121: RESOURCE_TYPE_NAME, name));
122: }
123:
124: // freeze the configuration
125: m_staticFrozen = true;
126:
127: super .initConfiguration(RESOURCE_TYPE_NAME, id, className);
128: // set static members with values from the configuration
129: m_staticTypeId = m_typeId;
130: }
131: }
|