org.vulpe.controller.struts.VulpeStrutsStartupExtend.java Source code

Java tutorial

Introduction

Here is the source code for org.vulpe.controller.struts.VulpeStrutsStartupExtend.java

Source

/**
 * Vulpe Framework - Quick and Smart ;)
 * Copyright (C) 2011 Active Thread
 *
 * Este programa  software livre; voc pode redistribu-lo e/ou
 * modific-lo sob os termos da Licena Pblica Geral GNU, conforme
 * publicada pela Free Software Foundation; tanto a verso 2 da
 * Licena como (a seu critrio) qualquer verso mais nova.
 *
 * Este programa  distribudo na expectativa de ser til, mas SEM
 * QUALQUER GARANTIA; sem mesmo a garantia implcita de
 * COMERCIALIZAO ou de ADEQUAO A QUALQUER PROPSITO EM
 * PARTICULAR. Consulte a Licena Pblica Geral GNU para obter mais
 * detalhes.
 *
 * Voc deve ter recebido uma cpia da Licena Pblica Geral GNU
 * junto com este programa; se no, escreva para a Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 */
/**
 * Vulpe Framework - Quick and Smart ;)
 * Copyright (C) 2011 Active Thread
 *
 * This program 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 2
 * of the License, or (at your option) any later version.
 *
 * This program 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 this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package org.vulpe.controller.struts;

import java.math.BigDecimal;
import java.util.Date;

import javax.servlet.ServletContextEvent;

import org.apache.commons.beanutils.ConvertUtils;
import org.springframework.stereotype.Component;
import org.vulpe.commons.VulpeConstants.Context;
import org.vulpe.commons.helper.VulpeConfigHelper;
import org.vulpe.controller.listener.VulpeStartupExtend;
import org.vulpe.controller.struts.commons.beans.converter.BigDecimalConverter;
import org.vulpe.controller.struts.commons.beans.converter.DateConverter;
import org.vulpe.controller.struts.commons.beans.converter.DecimalConverter;
import org.vulpe.controller.struts.commons.beans.converter.EnumConverter;
import org.vulpe.controller.struts.commons.beans.converter.SqlDateConverter;

import com.opensymphony.xwork2.util.LocalizedTextUtil;

/**
 * Class to manager startup with struts of application.
 *
 * @author <a href="mailto:felipe@vulpe.org">Geraldo Felipe</a>
 */
@Component(Context.FW_STARTUP_EXTEND)
public class VulpeStrutsStartupExtend implements VulpeStartupExtend {

    @Override
    public void contextInitialized(final ServletContextEvent event) {
        // configuration bundle
        LocalizedTextUtil.addDefaultResourceBundle(VulpeConfigHelper.getI18nManager());

        // register converters to struts
        ConvertUtils.register(new DateConverter(), Date.class);
        ConvertUtils.register(new SqlDateConverter(), java.sql.Date.class);
        ConvertUtils.register(new BigDecimalConverter(), BigDecimal.class);
        ConvertUtils.register(new DecimalConverter(), Double.class);
        ConvertUtils.register(new EnumConverter(), Enum.class);
    }

    @Override
    public void contextDestroyed(ServletContextEvent event) {

    }

}