Source Code‎ > ‎src‎ > ‎in.co.sunrays.proj1‎ > ‎action‎ > ‎

FrontController.java

package in.co.sunrays.proj1.action;
 
import java.util.Map;
 
import org.apache.log4j.Logger;
 
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
 
/**
 * FrontController Class. Performs Command Line Pattern task for all Action
 * classes.
 * 
 * @author SUNRAYS Technologies
 * @version 1.0
 * @Copyright (c) SUNRAYS Technologies
 */
public class FrontController extends AbstractInterceptor {
 
    /**
     * Logger
     */
    private static Logger log = Logger.getLogger(FrontController.class);
 
    /**
     * Destroy FrontController
     */
    @Override
    public void destroy() {
        log.debug("LoginInterceptor.destroy()");
    }
 
    /**
     * Initialize FrontController
     */
    @Override
    public void init() {
        log.debug("LoginInterceptor.init()");
    }
 
    /**
     * Performs FrontController Task
     */
    @Override
    public String intercept(ActionInvocation actionInvocation) throws Exception {
        ActionSupport actionSupport = (ActionSupport) actionInvocation
                .getAction();
        Map session = actionInvocation.getInvocationContext().getSession();
        if (session.get("user") == null) {
            actionSupport
                    .addActionError("Oops! Your session has been expired. Please re-Login.");
            return "Logout";
        }
        String val = actionInvocation.invoke();
        // Post Processing
        return val;
    }
 
}
Comments