Example usage for org.springframework.web.servlet HandlerExecutionChain HandlerExecutionChain

List of usage examples for org.springframework.web.servlet HandlerExecutionChain HandlerExecutionChain

Introduction

In this page you can find the example usage for org.springframework.web.servlet HandlerExecutionChain HandlerExecutionChain.

Prototype

public HandlerExecutionChain(Object handler, @Nullable HandlerInterceptor... interceptors) 

Source Link

Document

Create a new HandlerExecutionChain.

Usage

From source file:org.withinsea.izayoi.adapter.springmvc.SpringIzayoiDispatcherFilter.java

@Override
protected HandlerExecutionChain getHandler(HttpServletRequest request, boolean cache) throws Exception {
    HandlerExecutionChain mappedHandler = super.getHandler(request, cache);
    if (mappedHandler == null || mappedHandler.getHandler() == null) {
        return mappedHandler;
    } else {// w w w .ja  v  a 2 s .  c o m
        HandlerInterceptor[] originalInterceptors = mappedHandler.getInterceptors();
        HandlerInterceptor[] interceptors = new HandlerInterceptor[originalInterceptors.length + 1];
        interceptors[0] = izayoiInterceptor;
        System.arraycopy(originalInterceptors, 0, interceptors, 1, originalInterceptors.length);
        return new HandlerExecutionChain(mappedHandler.getHandler(), interceptors);
    }
}

From source file:org.broadleafcommerce.openadmin.security.CompatibleGWTSecuredHandler.java

@Override
protected Object getHandlerInternal(HttpServletRequest request) throws Exception {
    Object handlerWrapper;/*from w  w w .  j  a  v a2 s  .  c  o  m*/
    if ("true".equalsIgnoreCase(useJRebelCompatibilityMode)) {
        handlerWrapper = getMyHandlerInternal(request);
    } else {
        handlerWrapper = super.getHandlerInternal(request);
    }
    if (handlerWrapper instanceof HandlerExecutionChain) {
        final Object handler = ((HandlerExecutionChain) handlerWrapper).getHandler();
        if (handler instanceof GWTRPCServiceExporter) {
            final DefaultConverters defaultConverters = new DefaultConverters();
            final Transmorph transmorph = new Transmorph(this.getClass().getClassLoader(), defaultConverters);

            BeanToBeanMapping beanToBeanMapping = null;
            beanToBeanMapping = new BeanToBeanMapping(CompatibleGWTSecuredRPCServiceExporter.class,
                    GWTRPCServiceExporter.class);
            defaultConverters.getBeanToBean().addBeanToBeanMapping(beanToBeanMapping);

            beanToBeanMapping = new BeanToBeanMapping(GWTRPCServiceExporter.class,
                    CompatibleGWTSecuredRPCServiceExporter.class);
            defaultConverters.getBeanToBean().addBeanToBeanMapping(beanToBeanMapping);

            final CompatibleGWTSecuredRPCServiceExporter wrapper = transmorph.convert(handler,
                    CompatibleGWTSecuredRPCServiceExporter.class);
            wrapper.afterPropertiesSet();

            return new HandlerExecutionChain(wrapper,
                    ((HandlerExecutionChain) handlerWrapper).getInterceptors());
        }
    }
    return handlerWrapper;
}

From source file:org.springframework.web.servlet.handler.AbstractHandlerMapping.java

/**
 * Look up a handler for the given request, falling back to the default
 * handler if no specific one is found.//  w ww .  j  a v a  2  s. co  m
 * @param request current HTTP request
 * @return the looked up handler instance, or the default handler
 * @see #getHandlerInternal
 */
public final HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception {
    Object handler = getHandlerInternal(request);
    if (handler == null) {
        handler = this.defaultHandler;
    }
    if (handler == null) {
        return null;
    }
    // bean name of resolved handler?
    if (handler instanceof String) {
        String handlerName = (String) handler;
        handler = getApplicationContext().getBean(handlerName);
    }
    return new HandlerExecutionChain(handler, this.interceptors);
}