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

📄 cmssysteminfo.java

📁 cms是开源的框架
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        if (m_packagesRfsPath == null) {
            m_packagesRfsPath = getAbsoluteRfsPathRelativeToWebInf(CmsSystemInfo.FOLDER_PACKAGES);
        }
        return m_packagesRfsPath;
    }

    /**
     * Returns the time this OpenCms instance is running in miliseconds.<p>
     * 
     * @return the time this OpenCms instance is running in miliseconds
     */
    public long getRuntime() {

        return System.currentTimeMillis() - m_startupTime;
    }

    /**
     * Returns the OpenCms server name, e.g. "OpenCmsServer".<p>
     * 
     * The server name is set in <code>opencms.properties</code>.
     * It is not related to any DNS name the server might also have.
     * The server name is usefull e.g. in a cluster to distinguish different servers,
     * or if you compare logfiles from multiple servers.<p>
     * 
     * @return the OpenCms server name
     */
    public String getServerName() {

        return m_serverName;
    }

    /**
     * Returns the OpenCms servlet path, e.g. "/opencms".<p> 
     * 
     * <i>From the Java Servlet Sepcecification v2.4:</i><br>
     * <b>Servlet Path:</b> The path section that directly corresponds to the mapping
     * which activated this request. This path starts with a?/? character except in the
     * case where the request is matched with the ?/*? pattern, in which case it is the
     * empty string.<p>
     * 
     * @return the OpenCms servlet path
     * @see #getContextPath()
     * @see #getWebApplicationName()
     * @see #getOpenCmsContext()
     */
    public String getServletPath() {

        return m_servletPath;
    }

    /**
     * Returns the time this OpenCms instance was started in miliseconds.<p>
     *
     * @return the time this OpenCms instance was started in miliseconds
     */
    public long getStartupTime() {

        return m_startupTime;
    }

    /**
     * Returns the identifier "OpenCms/" plus the OpenCms version number.<p>
     * 
     * This information is used for example to identify OpenCms in http response headers.<p>
     *
     * @return the identifier "OpenCms/" plus the OpenCms version number
     */
    public String getVersion() {

        return m_version;
    }

    /**
     * Returns the maximum number of versions that are kept per file in the VFS version history.<p>
     * 
     * If the version history is disabled, this setting has no effect.<p>
     * 
     * @return the maximum number of versions that are kept per file
     * @see #isVersionHistoryEnabled()
     */
    public int getVersionHistoryMaxCount() {

        return m_versionHistoryMaxCount;
    }

    /**
     * Returns the version name (that is the version number) of this OpenCms system.<p>
     *
     * @return the version name (that is the version number) of this OpenCms system
     */
    public String getVersionName() {

        return m_versionNumber;
    }

    /** 
     * Returns the OpenCms web application name, e.g. "opencms" or "ROOT" (no leading or trainling "/").<p> 
     * 
     * The web application name is stored for informational purposes only.
     * If you want to construct an URI, use either {@link #getContextPath()} and 
     * {@link #getServletPath()}, or for links to the OpenCms VFS use {@link  #getOpenCmsContext()}.<p>
     * 
     * @return the OpenCms web application name
     * @see #getContextPath()
     * @see #getServletPath()
     * @see #getOpenCmsContext()
     */
    public String getWebApplicationName() {

        return m_webApplicationName;
    }

    /**
     * Returns the OpenCms web application folder in the servlet container.<p>
     * 
     * @return the OpenCms web application folder in the servlet container
     */
    public String getWebApplicationRfsPath() {

        return m_webApplicationRfsPath;
    }

    /** 
     * Returns the OpenCms web application "WEB-INF" directory path.<p>
     *
     * @return the OpenCms web application "WEB-INF" directory path
     */
    public String getWebInfRfsPath() {

        return m_webInfRfsPath;
    }

    /**
     * Returns if the VFS version history is enabled.<p> 
     * 
     * @return if the VFS version history is enabled
     */
    public boolean isVersionHistoryEnabled() {

        return m_versionHistoryEnabled;
    }

    /**
     * Returns if versions in the VFS version history should be kept 
     * after a resource is deleted.<p>
     * 
     * @return if versions in the VFS version history should be kept
     */
    public boolean keepVersionHistory() {

        // TODO: make configurable
        return true;
    }

    /**
     * Sets the project in which timestamps for the content notification are read.<p>
     * 
     * @param notificationProject the project in which timestamps for the content notification are read
     */
    public void setNotificationProject(String notificationProject) {

        m_notificationProject = notificationProject;
    }

    /**
     * Sets the duration after which responsibles will be notified about out-dated content (in days).<p>
     * 
     * @param notificationTime the duration after which responsibles will be notified about out-dated content
     */
    public void setNotificationTime(int notificationTime) {

        m_notificationTime = notificationTime;
    }

    /**
     * VFS version history settings are set here.<p>
     * 
     * @param historyEnabled if true the history is enabled
     * @param historyMaxCount the maximum number of versions that are kept per VFS resource
     */
    public void setVersionHistorySettings(boolean historyEnabled, int historyMaxCount) {

        m_versionHistoryEnabled = historyEnabled;
        m_versionHistoryMaxCount = historyMaxCount;
    }

    /** 
     * Sets the OpenCms web application "WEB-INF" directory path (in the "real" file system).<p>
     * 
     * @param webInfRfsPath the OpenCms web application "WEB-INF" path in the "real" file system) to set
     * @param servletMapping the OpenCms servlet mapping  (e.g. "/opencms/*")
     * @param webApplicationContext the name/path of the OpenCms web application context (optional, will be calculated form the path if null)
     * @param defaultWebApplication the default web application name (usually "ROOT")
     */
    protected void init(
        String webInfRfsPath,
        String servletMapping,
        String webApplicationContext,
        String defaultWebApplication) {

        // init base path
        webInfRfsPath = webInfRfsPath.replace('\\', '/');
        if (!webInfRfsPath.endsWith("/")) {
            webInfRfsPath = webInfRfsPath + "/";
        }
        m_webInfRfsPath = CmsFileUtil.normalizePath(webInfRfsPath);

        // set the servlet paths
        if (!servletMapping.startsWith("/")) {
            servletMapping = "/" + servletMapping;
        }
        if (servletMapping.endsWith("/*")) {
            // usually a mapping must be in the form "/opencms/*", cut off all slashes
            servletMapping = servletMapping.substring(0, servletMapping.length() - 2);
        }
        m_servletPath = servletMapping;

        // set the default web application name
        if (defaultWebApplication.endsWith("/")) {
            defaultWebApplication = defaultWebApplication.substring(0, defaultWebApplication.length() - 1);
        }
        if (defaultWebApplication.startsWith("/")) {
            defaultWebApplication = defaultWebApplication.substring(1);
        }
        m_defaultWebApplicationName = defaultWebApplication;

        // set the web application name
        File path = new File(m_webInfRfsPath);
        m_webApplicationName = path.getParentFile().getName();

        String contextPath;
        if (webApplicationContext == null) {
            // default: use web application context calculated form RFS path (fine with Tomcat)
            contextPath = m_webApplicationName;
        } else {
            // optional: web application context was set in web.xml, required for certain 
            // runtime environments (e.g. Jboss) that do not use the same RFS and context path
            contextPath = webApplicationContext;
        }

        // set the context path
        if (contextPath.equals(getDefaultWebApplicationName())) {
            m_contextPath = "";
        } else {
            m_contextPath = "/" + contextPath;
        }

        // this fixes an issue with context names in Jboss
        if (m_contextPath.endsWith(".war")) {
            m_contextPath = m_contextPath.substring(0, m_contextPath.length() - 4);
        }

        // set the OpenCms context
        m_openCmsContext = m_contextPath + m_servletPath;

        // set the web application path
        m_webApplicationRfsPath = path.getParentFile().getAbsolutePath();
        if (!m_webApplicationRfsPath.endsWith(File.separator)) {
            m_webApplicationRfsPath += File.separator;
        }
    }

    /**
     * Sets the default encoding, called after the properties have been read.<p>
     *  
     * @param encoding the default encoding to set
     */
    protected void setDefaultEncoding(String encoding) {

        m_defaultEncoding = encoding.intern();
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.LOG_SET_DEFAULT_ENCODING_1, m_defaultEncoding));
        }
    }

    /**
     * Sets the HTTP authentication settings.<p>
     *
     * @param httpAuthenticationSettings the HTTP authentication settings to set
     */
    protected void setHttpAuthenticationSettings(CmsHttpAuthenticationSettings httpAuthenticationSettings) {

        m_httpAuthenticationSettings = httpAuthenticationSettings;
    }

    /**
     * Sets the settings for the internal OpenCms email service.<p>
     * 
     * @param mailSettings the settings for the internal OpenCms email service to set
     */
    protected void setMailSettings(CmsMailSettings mailSettings) {

        m_mailSettings = mailSettings;
    }

    /**
     * Sets the server name.<p>
     * 
     * The server name is set in <code>opencms.properties</code>.
     * It is not related to any DNS name the server might also have.
     * The server name is usefull e.g. in a cluster to distinguish different servers,
     * or if you compare logfiles from multiple servers.<p>
     *  
     * @param serverName the server name to set
     */
    protected void setServerName(String serverName) {

        m_serverName = serverName;
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.LOG_SET_SERVERNAME_1, m_serverName));
        }
    }

    /**
     * Initializes the version for this OpenCms, will be called by 
     * CmsHttpServlet or CmsShell upon system startup.<p>
     */
    private void initVersion() {

        // init version information with static defaults
        m_versionNumber = DEFAULT_VERSION_NUMBER;
        // set OpenCms version identifier with default values
        m_version = "OpenCms/" + m_versionNumber;
        // read the version-informations from properties
        Properties props = new Properties();
        try {
            props.load(this.getClass().getClassLoader().getResourceAsStream("org/opencms/main/version.properties"));
        } catch (Throwable t) {
            // ignore this exception - no properties found
            return;
        }
        m_versionNumber = props.getProperty("version.number", DEFAULT_VERSION_NUMBER);
        // set OpenCms version identifier with propery values
        m_version = "OpenCms/" + m_versionNumber;
    }
}

⌨️ 快捷键说明

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