⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 opencms.java

📁 内容管理
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/*
* File   : $Source: /usr/local/cvs/opencms/src/com/opencms/core/Attic/OpenCms.java,v $
* Date   : $Date: 2004/01/06 12:45:53 $
* Version: $Revision: 1.124.2.1 $
*
* This library is part of OpenCms -
* the Open Source Content Mananagement System
*
* Copyright (C) 2001  The OpenCms Group
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* For further information about OpenCms, please see the
* OpenCms Website: http://www.opencms.org
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

package com.opencms.core;

import com.opencms.boot.CmsBase;
import com.opencms.boot.I_CmsLogChannels;
import com.opencms.core.exceptions.CmsCheckResourceException;
import com.opencms.file.CmsFile;
import com.opencms.file.CmsFolder;
import com.opencms.file.CmsObject;
import com.opencms.file.CmsRbManager;
import com.opencms.file.CmsStaticExport;
import com.opencms.flex.CmsJspLoader;
import com.opencms.flex.util.CmsResourceTranslator;
import com.opencms.flex.util.CmsUUID;
import com.opencms.launcher.CmsLauncherManager;
import com.opencms.launcher.I_CmsLauncher;
import com.opencms.template.cache.CmsElementCache;
import com.opencms.util.Utils;
import com.opencms.workplace.I_CmsWpConstants;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import source.org.apache.java.util.Configurations;

/**
 * This class is the main class of the OpenCms system,
 * think of it as the "operating system" of OpenCms.<p>
 *  
 * Any request to an OpenCms resource will be processed by this class first.
 * The class will try to map the request to a VFS (Virtual File System) resource,
 * i.e. an URI. If the resource is found, it will be read anf forwarded to
 * to a launcher, which is performs the output of the requested resource.<p>
 *
 * The OpenCms class is independent of access module to the OpenCms 
 * (e.g. Servlet, Command Shell), therefore this class is <b>not</b> responsible 
 * for user authentification. This is done by the access module to the OpenCms.<p>
 *
 * There will be only one instance of the OpenCms object created for
 * any accessing class. This means that in the default configuration, where 
 * OpenCms is accessed through a servlet, there will be only one instance of 
 * this class running at a time.
 * 
 * @see com.opencms.core.A_OpenCms
 * @see com.opencms.core.OpenCmsHttpServlet
 * @see com.opencms.file.CmsObject
 * 
 * @author Michael Emmerich
 * @author Alexander Lucas
 * @author Alexander Kandzior (a.kandzior@alkacon.com)
 * 
 * @version $Revision: 1.124.2.1 $ $Date: 2004/01/06 12:45:53 $
 */
public class OpenCms extends A_OpenCms implements I_CmsConstants, I_CmsLogChannels {

    /**
     * The default mimetype
     */
    private static final String C_DEFAULT_MIMETYPE = "text/html";

    /**
     * The cron scheduler to schedule the cronjobs
     */
    private CmsCronScheduler m_scheduler;

    /**
     * The cron table to use with the scheduler
     */
    private CmsCronTable m_table;

    /**
     * Reference to the OpenCms launcer manager
     */
    private CmsLauncherManager m_launcherManager;

    /**
     * Hashtable with all available Mimetypes.
     */
    private Hashtable m_mt = new Hashtable();

    /**
     * Indicates, if the session-failover should be enabled or not
     */
    private boolean m_sessionFailover = false;

    /**
     * Indicates, if the streaming should be enabled by the configurations.
     */
    private boolean m_streaming = true;

    /**
     * The name of the class used to validate a new password
     */
    private static String c_passwordValidatingClass = "";

    /**
     * Indicates, if the element cache should be enabled by the configurations
     */
    private boolean m_enableElementCache = true;

    /**
     * Reference to the CmsElementCache object containing locators for all
     * URIs and elements in cache
     */
    private static CmsElementCache c_elementCache = null;

    /**
     * The object to store the  properties from the opencms.property file for the
     * static export
     */
    private static CmsStaticExportProperties c_exportProperties = new CmsStaticExportProperties();

    /**
     * In this hashtable the dependencies for all variants in the elementcache
     * are stored. The keys are Strings with resourceNames like "/siteX/cos/ContentClass/news4"
     * and the value is a Vector with strings (The elementvariants that depend on the keys)
     * like "ElementClass|ElementTemplate|VariantCacheKey"
     */
    private static Hashtable c_variantDeps = null;
    
    /**
     * Directory translator, used to translate all access to resources
     */
    private static CmsResourceTranslator m_directoryTranslator = null;

    /**
     * Filename translator, used only for the creation of new files
     */
    private static CmsResourceTranslator m_fileTranslator = null;
    
    /**
     * List of default file names (for directories, e.g, "index.html")
     */
    private static String[] m_defaultFilenames = null;

    /**
     * Flag to indicate if the startup classes have already been initialized
     */
    private boolean m_isInitialized = false;
    
   /**
    * Member variable to store instances to modify resources
    */
   private List m_checkFile = new ArrayList();
    
    /**
     * Constructor to create a new OpenCms object.<p>
     * 
     * It reads the configurations from the <code>opencms.properties</code>
     * file in the <code>config/</code> subdirectory. With the information 
     * from this file is inits a ResourceBroker (Database access module),
     * various caching systems and other options.<p>
     * 
     * This will only be done once per accessing class.
     *
     * @param conf The configurations from the <code>opencms.properties</code> file.
     */
    public OpenCms(Configurations conf) throws Exception {        
        // Save the configuration
        setConfiguration(conf);

        // this will initialize the encoding with some default from the A_OpenCms
        String defaultEncoding = getDefaultEncoding();
        // check the opencms.properties for a different setting
        defaultEncoding = conf.getString("defaultContentEncoding", defaultEncoding);
        if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". OpenCms encoding     : " + defaultEncoding);
        String systemEncoding = null;
        try {
            systemEncoding = System.getProperty("file.encoding");
        } catch (SecurityException se) {
            // security manager is active, but we will try other options before giving up
        }
        if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". System file.encoding : " + systemEncoding);
        if (! defaultEncoding.equals(systemEncoding)) { 
            String msg = "OpenCms startup failure: System file.encoding '" + systemEncoding + 
                "' not equal to OpenCms encoding '" + defaultEncoding + "'";
            if(C_LOGGING && isLogging(C_OPENCMS_CRITICAL)) log(C_OPENCMS_CRITICAL, ". Critical init error/1: " + msg);
            throw new Exception(msg);                 
        }
        try {
            // check if the found encoding is supported 
            // this will work with Java 1.4+ only
            if (!java.nio.charset.Charset.isSupported(defaultEncoding)) {
                defaultEncoding = getDefaultEncoding();
            }
        } catch (Throwable t) {
            // will be thrown in Java < 1.4 (NoSuchMethodException etc.)
            // in Java < 1.4 there is no easy way to check if encoding is supported,
            // so you must make sure your setting in "opencms.properties" is correct.             
        }        
        setDefaultEncoding(defaultEncoding);
        if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Encoding set to      : " + defaultEncoding);
        
        // Read server ethernet address (MAC) and init UUID generator
        String ethernetAddress = conf.getString("server.ethernet.address", CmsUUID.getDummyEthernetAddress());
        if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Ethernet address used: " + ethernetAddress);
        CmsUUID.init(ethernetAddress);
        
        // invoke the ResourceBroker via the initalizer
        try {
            if(C_LOGGING && isLogging(C_OPENCMS_INIT)) {
                String jdkinfo = System.getProperty("java.vm.name") + " ";
                jdkinfo += System.getProperty("java.vm.version") + " ";
                jdkinfo += System.getProperty("java.vm.info") + " ";
                jdkinfo += System.getProperty("java.vm.vendor") + " ";
                log(C_OPENCMS_INIT, ". Java VM in use       : " + jdkinfo);
                String osinfo = System.getProperty("os.name") + " ";
                osinfo += System.getProperty("os.version") + " ";
                osinfo += System.getProperty("os.arch") + " ";
                log(C_OPENCMS_INIT, ". Operating sytem      : " + osinfo);
            }
            m_sessionFailover = conf.getBoolean("sessionfailover.enabled", false);
        } catch(Exception e) {
            if(C_LOGGING && isLogging(C_OPENCMS_CRITICAL)) log(C_OPENCMS_CRITICAL, ". Critical init error/2: " + e.getMessage());
            // any exception here is fatal and will cause a stop in processing
            throw e;
        }
        
        try {           
            // init the rb via the manager with the configuration
            // and init the cms-object with the rb.
            m_resourceBroker = CmsRbManager.init(conf);
        } catch(Exception e) {
            if(C_LOGGING && isLogging(C_OPENCMS_CRITICAL)) log(C_OPENCMS_CRITICAL, ". Critical init error/3: " + e.getMessage());
            // any exception here is fatal and will cause a stop in processing

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -