/**
* High Availability Service (HA) for JOnAS
*
* Copyright (C) 2007,2008 Bull S.A.S.
* Copyright (C) 2006 Distributed Systems Lab.
* Universidad Politecnica de Madrid (Spain)
* Contact: http://lsd.ls.fi.upm.es/lsd
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* --------------------------------------------------------------------------
*
* --------------------------------------------------------------------------
*/

package org.ow2.jonas.lib.ejb21.ha.interceptors.jrmp;

import org.objectweb.util.monolog.api.BasicLevel;
import org.objectweb.util.monolog.api.Logger;
import org.ow2.carol.rmi.jrmp.interceptor.api.JInitInfo;
import org.ow2.carol.rmi.jrmp.interceptor.spi.JInitializer;
import org.ow2.jonas.lib.util.Log;

/**
 * This class initializes the interception mechanism with jrmp.
 * @author Francisco Perez-Sorrosal (fpsorrosal@no-spam@fi.upm.es)
 * @author Alberto Paz-Jimenez (apaz@no-spam@fi.upm.es)
 */
public class HAInterceptorInitializer implements JInitializer {

    /**
     * Logger for traces
     */
    private static Logger cmilogger = Log.getLogger("org.ow2.jonas.lib.ejb21.ha.interceptors.jrmp");

    /**
     * Initializes the HA client and server side interceptors
     */
    public void pre_init(final JInitInfo info) {
        try {
            info.add_client_request_interceptor(new HAClientInterceptor());
            info.add_server_request_interceptor(new HAServerInterceptor());
        } catch (Exception e) {
            cmilogger.log(BasicLevel.ERROR,
                    "Error while adding the request interceptors", e);
        }
    }

    public void post_init(final JInitInfo info) {
    }

}
