com.acc.filter.SessionAttributesFilter.java Source code

Java tutorial

Introduction

Here is the source code for com.acc.filter.SessionAttributesFilter.java

Source

/*
 * [y] hybris Platform
 *
 * Copyright (c) 2000-2013 hybris AG
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of hybris
 * ("Confidential Information"). You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the
 * license agreement you entered into with hybris.
 * 
 *  
 */
package com.acc.filter;

import de.hybris.platform.core.model.c2l.CurrencyModel;
import de.hybris.platform.core.model.c2l.LanguageModel;
import com.acc.context.ContextInformationLoader;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.web.filter.OncePerRequestFilter;

/**
 * Filter sets session context basing on request parameters:<br>
 * <ul>
 * <li><b>lang</b> - set current {@link LanguageModel}</li>
 * <li><b>curr</b> - set current {@link CurrencyModel}</li>
 * </ul>
 * 
 * @author KKW
 * 
 */
public class SessionAttributesFilter extends OncePerRequestFilter {
    private final static Logger LOG = Logger.getLogger(SessionAttributesFilter.class);

    private ContextInformationLoader contextInformationLoader;

    @Override
    protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response,
            final FilterChain filterChain) throws ServletException, IOException {

        getContextInformationLoader().setLanguageFromRequest(request);
        getContextInformationLoader().setCurrencyFromRequest(request);
        filterChain.doFilter(request, response);
    }

    public ContextInformationLoader getContextInformationLoader() {
        return contextInformationLoader;
    }

    @Required
    public void setContextInformationLoader(final ContextInformationLoader contextInformationLoader) {
        this.contextInformationLoader = contextInformationLoader;
    }
}