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

📄 appinitcontextlistener.java

📁 本平台是以web2.0为基本的标准
💻 JAVA
字号:
package com.afuer.chat;

import java.io.File;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * This <code>ContextListener</code> is to perform application initialization.
 */
public class AppInitContextListener implements ServletContextListener {
    private static Log log = LogFactory.getLog(ChatConfig.class);

    public void contextInitialized(ServletContextEvent event) {
        try {
            ServletContext context = event.getServletContext();

            ChatConfig.init(context.getRealPath("WEB-INF/elchat.properties"));
            ChatConfig config = ChatConfig.getInstance();

            EmotIcon.init(context.getRealPath("WEB-INF/emoticon.properties"));
            Command.init(context.getRealPath("WEB-INF/command.properties"));

            String persistFile = config.getMessagePath() + config.getId().replaceAll("[\\s|\\.\\/]", "_")
                    + "_messages.xml";
            if (!new File(config.getMessagePath()).exists()) {
                persistFile = context.getRealPath("WEB-INF/messages.xml");
            }
            Chat.init(persistFile);
        }
        catch (Exception ex) {
            ex.printStackTrace();
            log.fatal("Exception in AppInitContextListener", ex);
        }
    }

    public void contextDestroyed(ServletContextEvent event) {
        ;
    }

}

⌨️ 快捷键说明

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