ar.com.allium.rules.core.listener.AlliumRuleListener.java Source code

Java tutorial

Introduction

Here is the source code for ar.com.allium.rules.core.listener.AlliumRuleListener.java

Source

package ar.com.allium.rules.core.listener;

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

import org.apache.log4j.Logger;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import ar.com.allium.rules.core.service.LoadAlliumRules;

/**
 * Copyright 2014 Joel del Valle <joelmarcosdelvalle@gmail.com>
 * 
 * This file is part of allium-rules, project of allium-projects.
 * 
 * allium-rules is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * allium-rules 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 General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * allium-rules. If not, see <http://www.gnu.org/licenses/>.
 * 
 * 
 * @author joel.delvalle
 * 
 *         listener to load rules and set of rules
 * 
 */
public final class AlliumRuleListener implements ServletContextListener {

    private static Logger log = Logger.getLogger(AlliumRuleListener.class);

    public void contextDestroyed(ServletContextEvent servletContextEvent) {

    }

    public void contextInitialized(ServletContextEvent servletContextEvent) {
        log.debug("start initialize alliumRules");

        ServletContext ctx = servletContextEvent.getServletContext();
        WebApplicationContext springContext = WebApplicationContextUtils.getWebApplicationContext(ctx);

        LoadAlliumRules loadAlliumRules = new LoadAlliumRules(springContext);

        loadAlliumRules.loadAlliumRules();

        log.debug("end initialize alliumRules");
    }

}