All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.itcb.common.web.vaadin.config.ItcbVaadinApplicationConfig Maven / Gradle / Ivy

Go to download

This module is the common portlet module. It defines the base on which the developements can be done by extending view, edit or help mode.

The newest version!
package net.sf.itcb.common.web.vaadin.config;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.portlet.PortletMode;

import org.springframework.beans.factory.annotation.Required;

import net.sf.itcb.common.web.portal.PortalAdapterProvider;
import net.sf.itcb.common.web.vaadin.ItcbVaadinApplication;
import net.sf.itcb.common.web.vaadin.interceptor.request.ItcbRequestInterceptor;
import net.sf.itcb.common.web.vaadin.interceptor.request.ItcbRequestInterceptor.ItcbRequestInterceptorExceptionListener;
import net.sf.itcb.common.web.vaadin.page.PageMappingProcessor;

import com.vaadin.Application;

/**
 * Itcb Vaadin application configuration that should be injected by Spring bean.
* It allows to declare all pageMappingProcessors used by the application depending on the mode, * how to adapt context to the portal or servlet mode and how to manage the init request and other requests.
* @author Pierre Le Roux * @since 0.5.0 */ public class ItcbVaadinApplicationConfig { private List requestInterceptors; private List requestInterceptorsExceptionListener; private List initRequestInterceptors; private List initRequestInterceptorsExceptionListener; private PortalAdapterProvider portalAdapterProvider; private Map mapPageMappingProcessor; /** * Set the portalAdapterProvider in order to have access to portal functionalities * @param portalAdapterProvider */ @Required public void setPortalAdapterProvider(PortalAdapterProvider portalAdapterProvider) { this.portalAdapterProvider = portalAdapterProvider; } public PortalAdapterProvider getPortalAdapterProvider() { return portalAdapterProvider; } /** * Map of : *
    *
  • key reference (used in request parameter itcbmode in servlet context or {@link PortletMode} in portlet request
  • *
  • spring bean name for the pageMappingProcessor to load.
  • *
* It allows to declare all pageMappingProcessors used by the application depending on the mode. * In order to be compliant with either servlet and portlet contexts, those modes have to declared : *
    *
  • view
  • *
  • edit
  • *
  • help
  • *
* For servlet contexts others pageMappingProcessor can be declared.
* Warning : pageMappingProcessor and pages declarations must be done using scope="prototype" * @param mapPageMappingProcessor map of String, String. {@link PageMappingProcessor} objects will be loaded at init or when user changes mode. Loading is done by {@link ItcbVaadinApplication} */ @Required public void setMapPageMappingProcessor( Map mapPageMappingProcessor) { this.mapPageMappingProcessor = mapPageMappingProcessor; } public Map getMapPageMappingProcessor() { return mapPageMappingProcessor; } public List getItcbInitRequestInterceptors() { return initRequestInterceptors; } /** * Interceptors that have to be called at application init. * It allows to deal with request at init which is not possible with vaadin {@link Application#init()} method. * @param itcbInitRequestInterceptors list of interceptors */ public void setItcbInitRequestInterceptors( List itcbInitRequestInterceptors) { this.initRequestInterceptors = itcbInitRequestInterceptors; this.initRequestInterceptorsExceptionListener = new ArrayList(); for (ItcbRequestInterceptor itcbRequestInterceptor : itcbInitRequestInterceptors) { if(itcbRequestInterceptor instanceof ItcbRequestInterceptor.ItcbRequestInterceptorExceptionListener) { initRequestInterceptorsExceptionListener.add((ItcbRequestInterceptorExceptionListener)itcbRequestInterceptor); } } } /** * * @return */ public List getItcbRequestInterceptors() { return requestInterceptors; } /** * Interceptors that have to be called at each request * @param itcbRequestInterceptors list of interceptors */ public void setItcbRequestInterceptors(List itcbRequestInterceptors) { this.requestInterceptors = itcbRequestInterceptors; this.requestInterceptorsExceptionListener = new ArrayList(); for (ItcbRequestInterceptor itcbRequestInterceptor : itcbRequestInterceptors) { if(itcbRequestInterceptor instanceof ItcbRequestInterceptor.ItcbRequestInterceptorExceptionListener) { requestInterceptorsExceptionListener.add((ItcbRequestInterceptorExceptionListener)itcbRequestInterceptor); } } } /** * Interceptors which are listening exceptions in Vaadin terminal errors * @return list of interceptors injected by Spring in requestInterceptors parameter which are ItcbRequestInterceptorExceptionListener */ public List getRequestInterceptorsExceptionListener() { return requestInterceptorsExceptionListener; } /** * Interceptors which are listening exceptions in initialization of the application * @return list of interceptors injected by Spring in initRequestInterceptors parameter which are ItcbRequestInterceptorExceptionListener */ public List getInitRequestInterceptorsExceptionListener() { return initRequestInterceptorsExceptionListener; } }