org.springframework.web.context.request.WebRequestInterceptor Java Examples

The following examples show how to use org.springframework.web.context.request.WebRequestInterceptor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InterceptorRegistry.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Adds the provided {@link WebRequestInterceptor}.
 * @param interceptor the interceptor to add
 * @return An {@link InterceptorRegistration} that allows you optionally configure the
 * registered interceptor further for example adding URL patterns it should apply to.
 */
public InterceptorRegistration addWebRequestInterceptor(WebRequestInterceptor interceptor) {
	WebRequestHandlerInterceptorAdapter adapted = new WebRequestHandlerInterceptorAdapter(interceptor);
	InterceptorRegistration registration = new InterceptorRegistration(adapted);
	registrations.add(registration);
	return registration;
}
 
Example #2
Source File: AbstractHandlerMapping.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Adapt the given interceptor object to the HandlerInterceptor interface.
 * <p>Supported interceptor types are HandlerInterceptor and WebRequestInterceptor.
 * Each given WebRequestInterceptor will be wrapped in a WebRequestHandlerInterceptorAdapter.
 * Can be overridden in subclasses.
 * @param interceptor the specified interceptor object
 * @return the interceptor wrapped as HandlerInterceptor
 * @see #setApplyWebRequestInterceptorsToRenderPhaseOnly
 * @see org.springframework.web.portlet.HandlerInterceptor
 * @see org.springframework.web.context.request.WebRequestInterceptor
 * @see WebRequestHandlerInterceptorAdapter
 */
protected HandlerInterceptor adaptInterceptor(Object interceptor) {
	if (interceptor instanceof HandlerInterceptor) {
		return (HandlerInterceptor) interceptor;
	}
	else if (interceptor instanceof WebRequestInterceptor) {
		return new WebRequestHandlerInterceptorAdapter(
				(WebRequestInterceptor) interceptor, this.applyWebRequestInterceptorsToRenderPhaseOnly);
	}
	else {
		throw new IllegalArgumentException("Interceptor type not supported: " + interceptor.getClass().getName());
	}
}
 
Example #3
Source File: InterceptorRegistry.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds the provided {@link WebRequestInterceptor}.
 * @param interceptor the interceptor to add
 * @return An {@link InterceptorRegistration} that allows you optionally configure the
 * registered interceptor further for example adding URL patterns it should apply to.
 */
public InterceptorRegistration addWebRequestInterceptor(WebRequestInterceptor interceptor) {
	WebRequestHandlerInterceptorAdapter adapted = new WebRequestHandlerInterceptorAdapter(interceptor);
	InterceptorRegistration registration = new InterceptorRegistration(adapted);
	this.registrations.add(registration);
	return registration;
}
 
Example #4
Source File: InterceptorRegistry.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Adds the provided {@link WebRequestInterceptor}.
 * @param interceptor the interceptor to add
 * @return an {@link InterceptorRegistration} that allows you optionally configure the
 * registered interceptor further for example adding URL patterns it should apply to.
 */
public InterceptorRegistration addWebRequestInterceptor(WebRequestInterceptor interceptor) {
	WebRequestHandlerInterceptorAdapter adapted = new WebRequestHandlerInterceptorAdapter(interceptor);
	InterceptorRegistration registration = new InterceptorRegistration(adapted);
	this.registrations.add(registration);
	return registration;
}
 
Example #5
Source File: InterceptorRegistry.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Adds the provided {@link WebRequestInterceptor}.
 * @param interceptor the interceptor to add
 * @return an {@link InterceptorRegistration} that allows you optionally configure the
 * registered interceptor further for example adding URL patterns it should apply to.
 */
public InterceptorRegistration addWebRequestInterceptor(WebRequestInterceptor interceptor) {
	WebRequestHandlerInterceptorAdapter adapted = new WebRequestHandlerInterceptorAdapter(interceptor);
	InterceptorRegistration registration = new InterceptorRegistration(adapted);
	this.registrations.add(registration);
	return registration;
}
 
Example #6
Source File: WebRequestHandlerInterceptorAdapter.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * Create a new WebRequestHandlerInterceptorAdapter for the given WebRequestInterceptor.
 * @param requestInterceptor the WebRequestInterceptor to wrap
 */
public WebRequestHandlerInterceptorAdapter(WebRequestInterceptor requestInterceptor) {
	Assert.notNull(requestInterceptor, "WebRequestInterceptor must not be null");
	this.requestInterceptor = requestInterceptor;
}
 
Example #7
Source File: WebRequestHandlerInterceptorAdapter.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create a new WebRequestHandlerInterceptorAdapter for the given WebRequestInterceptor.
 * @param requestInterceptor the WebRequestInterceptor to wrap
 */
public WebRequestHandlerInterceptorAdapter(WebRequestInterceptor requestInterceptor) {
	Assert.notNull(requestInterceptor, "WebRequestInterceptor must not be null");
	this.requestInterceptor = requestInterceptor;
}
 
Example #8
Source File: WebRequestHandlerInterceptorAdapter.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Create a new WebRequestHandlerInterceptorAdapter for the given WebRequestInterceptor.
 * @param requestInterceptor the WebRequestInterceptor to wrap
 */
public WebRequestHandlerInterceptorAdapter(WebRequestInterceptor requestInterceptor) {
	Assert.notNull(requestInterceptor, "WebRequestInterceptor must not be null");
	this.requestInterceptor = requestInterceptor;
}
 
Example #9
Source File: WebRequestHandlerInterceptorAdapter.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
/**
 * Create a new WebRequestHandlerInterceptorAdapter for the given WebRequestInterceptor.
 * @param requestInterceptor the WebRequestInterceptor to wrap
 */
public WebRequestHandlerInterceptorAdapter(WebRequestInterceptor requestInterceptor) {
	Assert.notNull(requestInterceptor, "WebRequestInterceptor must not be null");
	this.requestInterceptor = requestInterceptor;
}
 
Example #10
Source File: AbstractHandlerMapping.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Adapt the given interceptor object to the {@link HandlerInterceptor} interface.
 * <p>By default, the supported interceptor types are {@link HandlerInterceptor}
 * and {@link WebRequestInterceptor}. Each given {@link WebRequestInterceptor}
 * will be wrapped in a {@link WebRequestHandlerInterceptorAdapter}.
 * Can be overridden in subclasses.
 * @param interceptor the specified interceptor object
 * @return the interceptor wrapped as HandlerInterceptor
 * @see org.springframework.web.servlet.HandlerInterceptor
 * @see org.springframework.web.context.request.WebRequestInterceptor
 * @see WebRequestHandlerInterceptorAdapter
 */
protected HandlerInterceptor adaptInterceptor(Object interceptor) {
	if (interceptor instanceof HandlerInterceptor) {
		return (HandlerInterceptor) interceptor;
	}
	else if (interceptor instanceof WebRequestInterceptor) {
		return new WebRequestHandlerInterceptorAdapter((WebRequestInterceptor) interceptor);
	}
	else {
		throw new IllegalArgumentException("Interceptor type not supported: " + interceptor.getClass().getName());
	}
}
 
Example #11
Source File: AbstractHandlerMapping.java    From spring-analysis-note with MIT License 3 votes vote down vote up
/**
 * Adapt the given interceptor object to the {@link HandlerInterceptor} interface.
 * <p>By default, the supported interceptor types are {@link HandlerInterceptor}
 * and {@link WebRequestInterceptor}. Each given {@link WebRequestInterceptor}
 * will be wrapped in a {@link WebRequestHandlerInterceptorAdapter}.
 * Can be overridden in subclasses.
 * @param interceptor the specified interceptor object
 * @return the interceptor wrapped as HandlerInterceptor
 * @see org.springframework.web.servlet.HandlerInterceptor
 * @see org.springframework.web.context.request.WebRequestInterceptor
 * @see WebRequestHandlerInterceptorAdapter
 */
protected HandlerInterceptor adaptInterceptor(Object interceptor) {
	if (interceptor instanceof HandlerInterceptor) {
		return (HandlerInterceptor) interceptor;
	}
	else if (interceptor instanceof WebRequestInterceptor) {
		return new WebRequestHandlerInterceptorAdapter((WebRequestInterceptor) interceptor);
	}
	else {
		throw new IllegalArgumentException("Interceptor type not supported: " + interceptor.getClass().getName());
	}
}
 
Example #12
Source File: AbstractHandlerMapping.java    From spring4-understanding with Apache License 2.0 3 votes vote down vote up
/**
 * Adapt the given interceptor object to the {@link HandlerInterceptor} interface.
 * <p>By default, the supported interceptor types are {@link HandlerInterceptor}
 * and {@link WebRequestInterceptor}. Each given {@link WebRequestInterceptor}
 * will be wrapped in a {@link WebRequestHandlerInterceptorAdapter}.
 * Can be overridden in subclasses.
 * @param interceptor the specified interceptor object
 * @return the interceptor wrapped as HandlerInterceptor
 * @see org.springframework.web.servlet.HandlerInterceptor
 * @see org.springframework.web.context.request.WebRequestInterceptor
 * @see WebRequestHandlerInterceptorAdapter
 */
protected HandlerInterceptor adaptInterceptor(Object interceptor) {
	if (interceptor instanceof HandlerInterceptor) {
		return (HandlerInterceptor) interceptor;
	}
	else if (interceptor instanceof WebRequestInterceptor) {
		return new WebRequestHandlerInterceptorAdapter((WebRequestInterceptor) interceptor);
	}
	else {
		throw new IllegalArgumentException("Interceptor type not supported: " + interceptor.getClass().getName());
	}
}
 
Example #13
Source File: AbstractHandlerMapping.java    From java-technology-stack with MIT License 3 votes vote down vote up
/**
 * Adapt the given interceptor object to the {@link HandlerInterceptor} interface.
 * <p>By default, the supported interceptor types are {@link HandlerInterceptor}
 * and {@link WebRequestInterceptor}. Each given {@link WebRequestInterceptor}
 * will be wrapped in a {@link WebRequestHandlerInterceptorAdapter}.
 * Can be overridden in subclasses.
 * @param interceptor the specified interceptor object
 * @return the interceptor wrapped as HandlerInterceptor
 * @see org.springframework.web.servlet.HandlerInterceptor
 * @see org.springframework.web.context.request.WebRequestInterceptor
 * @see WebRequestHandlerInterceptorAdapter
 */
protected HandlerInterceptor adaptInterceptor(Object interceptor) {
	if (interceptor instanceof HandlerInterceptor) {
		return (HandlerInterceptor) interceptor;
	}
	else if (interceptor instanceof WebRequestInterceptor) {
		return new WebRequestHandlerInterceptorAdapter((WebRequestInterceptor) interceptor);
	}
	else {
		throw new IllegalArgumentException("Interceptor type not supported: " + interceptor.getClass().getName());
	}
}
 
Example #14
Source File: MappedInterceptor.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new MappedInterceptor instance.
 * @param includePatterns the path patterns to map with a {@code null} value matching to all paths
 * @param interceptor the WebRequestInterceptor instance to map to the given patterns
 */
public MappedInterceptor(String[] includePatterns, WebRequestInterceptor interceptor) {
	this(includePatterns, null, interceptor);
}
 
Example #15
Source File: MappedInterceptor.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a new MappedInterceptor instance.
 * @param includePatterns the path patterns to map with a {@code null} value matching to all paths
 * @param interceptor the WebRequestInterceptor instance to map to the given patterns
 */
public MappedInterceptor(String[] includePatterns, WebRequestInterceptor interceptor) {
	this(includePatterns, null, interceptor);
}
 
Example #16
Source File: MappedInterceptor.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new MappedInterceptor instance.
 * @param includePatterns the path patterns to map with a {@code null} value matching to all paths
 * @param interceptor the WebRequestInterceptor instance to map to the given patterns
 */
public MappedInterceptor(String[] includePatterns, String[] excludePatterns, WebRequestInterceptor interceptor) {
	this(includePatterns, excludePatterns, new WebRequestHandlerInterceptorAdapter(interceptor));
}
 
Example #17
Source File: WebRequestHandlerInterceptorAdapter.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new WebRequestHandlerInterceptorAdapter for the given WebRequestInterceptor.
 * @param requestInterceptor the WebRequestInterceptor to wrap
 * @param renderPhaseOnly whether to apply to the render phase only ({@code true})
 * or to the action phase as well ({@code false})
 */
public WebRequestHandlerInterceptorAdapter(WebRequestInterceptor requestInterceptor, boolean renderPhaseOnly) {
	Assert.notNull(requestInterceptor, "WebRequestInterceptor must not be null");
	this.requestInterceptor = requestInterceptor;
	this.renderPhaseOnly = renderPhaseOnly;
}
 
Example #18
Source File: WebRequestHandlerInterceptorAdapter.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new WebRequestHandlerInterceptorAdapter for the given WebRequestInterceptor,
 * applying to the render phase only.
 * @param requestInterceptor the WebRequestInterceptor to wrap
 */
public WebRequestHandlerInterceptorAdapter(WebRequestInterceptor requestInterceptor) {
	this(requestInterceptor, true);
}
 
Example #19
Source File: MappedInterceptor.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a new MappedInterceptor instance.
 * @param includePatterns the path patterns to map with a {@code null} value matching to all paths
 * @param interceptor the WebRequestInterceptor instance to map to the given patterns
 */
public MappedInterceptor(String[] includePatterns, String[] excludePatterns, WebRequestInterceptor interceptor) {
	this(includePatterns, excludePatterns, new WebRequestHandlerInterceptorAdapter(interceptor));
}
 
Example #20
Source File: MappedInterceptor.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Create a new MappedInterceptor instance.
 * @param includePatterns the path patterns to map (empty for matching to all paths)
 * @param excludePatterns the path patterns to exclude (empty for no specific excludes)
 * @param interceptor the WebRequestInterceptor instance to map to the given patterns
 */
public MappedInterceptor(@Nullable String[] includePatterns, @Nullable String[] excludePatterns,
		WebRequestInterceptor interceptor) {

	this(includePatterns, excludePatterns, new WebRequestHandlerInterceptorAdapter(interceptor));
}
 
Example #21
Source File: MappedInterceptor.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Create a new MappedInterceptor instance.
 * @param includePatterns the path patterns to map (empty for matching to all paths)
 * @param interceptor the WebRequestInterceptor instance to map to the given patterns
 */
public MappedInterceptor(@Nullable String[] includePatterns, WebRequestInterceptor interceptor) {
	this(includePatterns, null, interceptor);
}
 
Example #22
Source File: MappedInterceptor.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Create a new MappedInterceptor instance.
 * @param includePatterns the path patterns to map (empty for matching to all paths)
 * @param excludePatterns the path patterns to exclude (empty for no specific excludes)
 * @param interceptor the WebRequestInterceptor instance to map to the given patterns
 */
public MappedInterceptor(@Nullable String[] includePatterns, @Nullable String[] excludePatterns,
		WebRequestInterceptor interceptor) {

	this(includePatterns, excludePatterns, new WebRequestHandlerInterceptorAdapter(interceptor));
}
 
Example #23
Source File: MappedInterceptor.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Create a new MappedInterceptor instance.
 * @param includePatterns the path patterns to map (empty for matching to all paths)
 * @param interceptor the WebRequestInterceptor instance to map to the given patterns
 */
public MappedInterceptor(@Nullable String[] includePatterns, WebRequestInterceptor interceptor) {
	this(includePatterns, null, interceptor);
}