package com.zuoxiaolong.listener;

/*
 * Copyright 2002-2015 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

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

import org.apache.log4j.Logger;

import com.zuoxiaolong.config.Configuration;
import com.zuoxiaolong.generator.Generators;
import com.zuoxiaolong.search.LuceneHelper;
import com.zuoxiaolong.thread.BaiduPushTask;
import com.zuoxiaolong.thread.DirtyWordsFlushTask;
import com.zuoxiaolong.thread.Executor;
import com.zuoxiaolong.thread.FetchTask;

/**
 * @author 左潇龙
 * @since 5/7/2015 3:33 PM
 */
public class ConfigurationListener implements ServletContextListener {
	
	private static final Logger logger = Logger.getLogger(ConfigurationListener.class);

    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
    	if (logger.isInfoEnabled()) {
			logger.info("will begin init configuration...");
		}
        Configuration.init(servletContextEvent.getServletContext());
        if (logger.isInfoEnabled()) {
			logger.info("init configuration success...");
		}
        if (logger.isInfoEnabled()) {
            logger.info("starting DirtyWordsFlush thread...");
        }
        Executor.executeTask(new DirtyWordsFlushTask());
        if (logger.isInfoEnabled()) {
            logger.info("DirtyWordsFlush thread has been started...");
        }
        if (logger.isInfoEnabled()) {
            logger.info("starting fetch and generate thread...");
        }
        Executor.executeTask(new FetchTask());
        if (logger.isInfoEnabled()) {
            logger.info("fetch and generate thread has been started...");
        }
        if (Configuration.isProductEnv()) {
            if (logger.isInfoEnabled()) {
                logger.info("starting baidu push thread...");
            }
            Executor.executeTask(new BaiduPushTask());
            if (logger.isInfoEnabled()) {
                logger.info("baidu push thread has been started...");
            }
        }
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
    }

}

@@ -661,254 +661,44 @@
 ort 
-javax.servlet.ServletContextEvent;%0Aimport javax.servlet.ServletContextListener;%0A%0Aimport org.apache.log4j.Logger;%0A%0Aimport com.zuoxiaolong.config.Configuration;%0Aimport com.zuoxiaolong.generator.Generators;%0Aimport com.zuoxiaolong.search.LuceneHelper
+com.zuoxiaolong.config.Configuration
 ;%0Aim
@@ -871,16 +871,136 @@
 tchTask;
+%0Aimport org.apache.log4j.Logger;%0A%0Aimport javax.servlet.ServletContextEvent;%0Aimport javax.servlet.ServletContextListener;
 %0A%0A/**%0A *
@@ -1824,32 +1824,80 @@
 ..%22);%0A        %7D%0A
+        if (Configuration.isProductEnv()) %7B%0A    
         if (logg
@@ -1910,32 +1910,36 @@
 nfoEnabled()) %7B%0A
+    
             logg
@@ -1988,34 +1988,42 @@
 d...%22);%0A        
+   
+ 
 %7D%0A
+    
         Executor
@@ -2053,32 +2053,36 @@
 ask());%0A        
+  
+  
 if (logger.isInf
@@ -2087,32 +2087,36 @@
 nfoEnabled()) %7B%0A
+    
             logg
@@ -2185,53 +2185,13 @@
     
-%7D%0A
     
-    if (Configuration.isProductEnv()) %7B
+%7D
 %0A   

add new comments.