Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,15 +29,13 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* <p>Given two pieces of advice, {@code a} and {@code b}:
|
||||
* <ul>
|
||||
* <li>if {@code a} and {@code b} are defined in different
|
||||
* aspects, then the advice in the aspect with the lowest order
|
||||
* value has the highest precedence</li>
|
||||
* <li>if {@code a} and {@code b} are defined in the same
|
||||
* aspect, then if one of {@code a} or {@code b} is a form of
|
||||
* after advice, then the advice declared last in the aspect has the
|
||||
* highest precedence. If neither {@code a} nor {@code b} is a
|
||||
* form of after advice, then the advice declared first in the aspect has
|
||||
* the highest precedence.</li>
|
||||
* <li>if {@code a} and {@code b} are defined in different aspects, then the advice
|
||||
* in the aspect with the lowest order value has the highest precedence</li>
|
||||
* <li>if {@code a} and {@code b} are defined in the same aspect, then if one of
|
||||
* {@code a} or {@code b} is a form of after advice, then the advice declared last
|
||||
* in the aspect has the highest precedence. If neither {@code a} nor {@code b} is
|
||||
* a form of after advice, then the advice declared first in the aspect has the
|
||||
* highest precedence.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>Important: Note that unlike a normal comparator a return of 0 means
|
||||
@@ -51,9 +49,12 @@ import org.springframework.util.Assert;
|
||||
class AspectJPrecedenceComparator implements Comparator<Advisor> {
|
||||
|
||||
private static final int HIGHER_PRECEDENCE = -1;
|
||||
|
||||
private static final int SAME_PRECEDENCE = 0;
|
||||
|
||||
private static final int LOWER_PRECEDENCE = 1;
|
||||
|
||||
|
||||
private final Comparator<? super Advisor> advisorComparator;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -305,11 +305,11 @@ import org.springframework.stereotype.Component;
|
||||
*
|
||||
* <h2>Constraints when authoring {@code @Configuration} classes</h2>
|
||||
* <ul>
|
||||
* <li>@Configuration classes must be non-final
|
||||
* <li>@Configuration classes must be non-local (may not be declared within a method)
|
||||
* <li>@Configuration classes must have a default/no-arg constructor and may not
|
||||
* use {@link Autowired @Autowired} constructor parameters. Any nested configuration classes
|
||||
* must be {@code static}
|
||||
* <li>@Configuration classes must be non-final
|
||||
* <li>@Configuration classes must be non-local (may not be declared within a method)
|
||||
* <li>@Configuration classes must have a default/no-arg constructor and may not use
|
||||
* {@link Autowired @Autowired} constructor parameters. Any nested configuration classes
|
||||
* must be {@code static}.
|
||||
* </ul>
|
||||
*
|
||||
* @author Rod Johnson
|
||||
@@ -337,12 +337,10 @@ public @interface Configuration {
|
||||
* Explicitly specify the name of the Spring bean definition associated
|
||||
* with this Configuration class. If left unspecified (the common case),
|
||||
* a bean name will be automatically generated.
|
||||
*
|
||||
* <p>The custom name applies only if the Configuration class is picked up via
|
||||
* component scanning or supplied directly to a {@link AnnotationConfigApplicationContext}.
|
||||
* If the Configuration class is registered as a traditional XML bean definition,
|
||||
* the name/id of the bean element will take precedence.
|
||||
*
|
||||
* @return the specified bean name, if any
|
||||
* @see org.springframework.beans.factory.support.DefaultBeanNameGenerator
|
||||
*/
|
||||
|
||||
@@ -58,6 +58,9 @@ public abstract class ClassUtils {
|
||||
/** The package separator character '.' */
|
||||
private static final char PACKAGE_SEPARATOR = '.';
|
||||
|
||||
/** The path separator character '/' */
|
||||
private static final char PATH_SEPARATOR = '/';
|
||||
|
||||
/** The inner class separator character '$' */
|
||||
private static final char INNER_CLASS_SEPARATOR = '$';
|
||||
|
||||
@@ -246,14 +249,15 @@ public abstract class ClassUtils {
|
||||
return (clToUse != null ? clToUse.loadClass(name) : Class.forName(name));
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
int lastDotIndex = name.lastIndexOf('.');
|
||||
int lastDotIndex = name.lastIndexOf(PACKAGE_SEPARATOR);
|
||||
if (lastDotIndex != -1) {
|
||||
String innerClassName = name.substring(0, lastDotIndex) + '$' + name.substring(lastDotIndex + 1);
|
||||
String innerClassName =
|
||||
name.substring(0, lastDotIndex) + INNER_CLASS_SEPARATOR + name.substring(lastDotIndex + 1);
|
||||
try {
|
||||
return (clToUse != null ? clToUse.loadClass(innerClassName) : Class.forName(innerClassName));
|
||||
}
|
||||
catch (ClassNotFoundException ex2) {
|
||||
// swallow - let original exception get through
|
||||
// Swallow - let original exception get through
|
||||
}
|
||||
}
|
||||
throw ex;
|
||||
@@ -424,7 +428,7 @@ public abstract class ClassUtils {
|
||||
*/
|
||||
public static String getShortNameAsProperty(Class<?> clazz) {
|
||||
String shortName = ClassUtils.getShortName(clazz);
|
||||
int dotIndex = shortName.lastIndexOf('.');
|
||||
int dotIndex = shortName.lastIndexOf(PACKAGE_SEPARATOR);
|
||||
shortName = (dotIndex != -1 ? shortName.substring(dotIndex + 1) : shortName);
|
||||
return Introspector.decapitalize(shortName);
|
||||
}
|
||||
@@ -943,7 +947,7 @@ public abstract class ClassUtils {
|
||||
*/
|
||||
public static String convertResourcePathToClassName(String resourcePath) {
|
||||
Assert.notNull(resourcePath, "Resource path must not be null");
|
||||
return resourcePath.replace('/', '.');
|
||||
return resourcePath.replace(PATH_SEPARATOR, PACKAGE_SEPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -953,7 +957,7 @@ public abstract class ClassUtils {
|
||||
*/
|
||||
public static String convertClassNameToResourcePath(String className) {
|
||||
Assert.notNull(className, "Class name must not be null");
|
||||
return className.replace('.', '/');
|
||||
return className.replace(PACKAGE_SEPARATOR, PATH_SEPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -966,7 +970,7 @@ public abstract class ClassUtils {
|
||||
* loading a resource file that is in the same package as a class file,
|
||||
* although {@link org.springframework.core.io.ClassPathResource} is usually
|
||||
* even more convenient.
|
||||
* @param clazz the Class whose package will be used as the base
|
||||
* @param clazz the Class whose package will be used as the base
|
||||
* @param resourceName the resource name to append. A leading slash is optional.
|
||||
* @return the built-up resource path
|
||||
* @see ClassLoader#getResource
|
||||
@@ -999,12 +1003,12 @@ public abstract class ClassUtils {
|
||||
return "";
|
||||
}
|
||||
String className = clazz.getName();
|
||||
int packageEndIndex = className.lastIndexOf('.');
|
||||
int packageEndIndex = className.lastIndexOf(PACKAGE_SEPARATOR);
|
||||
if (packageEndIndex == -1) {
|
||||
return "";
|
||||
}
|
||||
String packageName = className.substring(0, packageEndIndex);
|
||||
return packageName.replace('.', '/');
|
||||
return packageName.replace(PACKAGE_SEPARATOR, PATH_SEPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,7 +57,7 @@ public class SpelExpression implements Expression {
|
||||
|
||||
private final SpelParserConfiguration configuration;
|
||||
|
||||
// the default context is used if no override is supplied by the user
|
||||
// The default context is used if no override is supplied by the user
|
||||
private EvaluationContext evaluationContext;
|
||||
|
||||
// Holds the compiled form of the expression (if it has been compiled)
|
||||
@@ -220,12 +220,11 @@ public class SpelExpression implements Expression {
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext context) throws EvaluationException {
|
||||
Assert.notNull(context, "The EvaluationContext is required");
|
||||
Assert.notNull(context, "EvaluationContext is required");
|
||||
if (compiledAst!= null) {
|
||||
try {
|
||||
TypedValue contextRoot = context == null ? null : context.getRootObject();
|
||||
Object result = this.compiledAst.getValue(contextRoot==null?null:contextRoot.getValue(),context);
|
||||
return result;
|
||||
return this.compiledAst.getValue(contextRoot != null ? contextRoot.getValue() : null, context);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
// If running in mixed mode, revert to interpreted
|
||||
@@ -247,7 +246,7 @@ public class SpelExpression implements Expression {
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext context, Object rootObject) throws EvaluationException {
|
||||
Assert.notNull(context, "The EvaluationContext is required");
|
||||
Assert.notNull(context, "EvaluationContext is required");
|
||||
if (this.compiledAst != null) {
|
||||
try {
|
||||
return this.compiledAst.getValue(rootObject,context);
|
||||
@@ -345,16 +344,16 @@ public class SpelExpression implements Expression {
|
||||
|
||||
@Override
|
||||
public Class<?> getValueType(EvaluationContext context) throws EvaluationException {
|
||||
Assert.notNull(context, "The EvaluationContext is required");
|
||||
ExpressionState eState = new ExpressionState(context, this.configuration);
|
||||
TypeDescriptor typeDescriptor = this.ast.getValueInternal(eState).getTypeDescriptor();
|
||||
Assert.notNull(context, "EvaluationContext is required");
|
||||
ExpressionState expressionState = new ExpressionState(context, this.configuration);
|
||||
TypeDescriptor typeDescriptor = this.ast.getValueInternal(expressionState).getTypeDescriptor();
|
||||
return (typeDescriptor != null ? typeDescriptor.getType() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getValueType(EvaluationContext context, Object rootObject) throws EvaluationException {
|
||||
ExpressionState eState = new ExpressionState(context, toTypedValue(rootObject), this.configuration);
|
||||
TypeDescriptor typeDescriptor = this.ast.getValueInternal(eState).getTypeDescriptor();
|
||||
ExpressionState expressionState = new ExpressionState(context, toTypedValue(rootObject), this.configuration);
|
||||
TypeDescriptor typeDescriptor = this.ast.getValueInternal(expressionState).getTypeDescriptor();
|
||||
return (typeDescriptor != null ? typeDescriptor.getType() : null);
|
||||
}
|
||||
|
||||
@@ -365,22 +364,23 @@ public class SpelExpression implements Expression {
|
||||
|
||||
@Override
|
||||
public TypeDescriptor getValueTypeDescriptor(Object rootObject) throws EvaluationException {
|
||||
ExpressionState eState = new ExpressionState(getEvaluationContext(), toTypedValue(rootObject), this.configuration);
|
||||
return this.ast.getValueInternal(eState).getTypeDescriptor();
|
||||
ExpressionState expressionState =
|
||||
new ExpressionState(getEvaluationContext(), toTypedValue(rootObject), this.configuration);
|
||||
return this.ast.getValueInternal(expressionState).getTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context) throws EvaluationException {
|
||||
Assert.notNull(context, "The EvaluationContext is required");
|
||||
ExpressionState eState = new ExpressionState(context, this.configuration);
|
||||
return this.ast.getValueInternal(eState).getTypeDescriptor();
|
||||
Assert.notNull(context, "EvaluationContext is required");
|
||||
ExpressionState expressionState = new ExpressionState(context, this.configuration);
|
||||
return this.ast.getValueInternal(expressionState).getTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context, Object rootObject) throws EvaluationException {
|
||||
Assert.notNull(context, "The EvaluationContext is required");
|
||||
ExpressionState eState = new ExpressionState(context, toTypedValue(rootObject), this.configuration);
|
||||
return this.ast.getValueInternal(eState).getTypeDescriptor();
|
||||
Assert.notNull(context, "EvaluationContext is required");
|
||||
ExpressionState expressionState = new ExpressionState(context, toTypedValue(rootObject), this.configuration);
|
||||
return this.ast.getValueInternal(expressionState).getTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -390,7 +390,7 @@ public class SpelExpression implements Expression {
|
||||
|
||||
@Override
|
||||
public boolean isWritable(EvaluationContext context) throws EvaluationException {
|
||||
Assert.notNull(context, "The EvaluationContext is required");
|
||||
Assert.notNull(context, "EvaluationContext is required");
|
||||
return this.ast.isWritable(new ExpressionState(context, this.configuration));
|
||||
}
|
||||
|
||||
@@ -401,13 +401,13 @@ public class SpelExpression implements Expression {
|
||||
|
||||
@Override
|
||||
public boolean isWritable(EvaluationContext context, Object rootObject) throws EvaluationException {
|
||||
Assert.notNull(context, "The EvaluationContext is required");
|
||||
Assert.notNull(context, "EvaluationContext is required");
|
||||
return this.ast.isWritable(new ExpressionState(context, toTypedValue(rootObject), this.configuration));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(EvaluationContext context, Object value) throws EvaluationException {
|
||||
Assert.notNull(context, "The EvaluationContext is required");
|
||||
Assert.notNull(context, "EvaluationContext is required");
|
||||
this.ast.setValue(new ExpressionState(context, this.configuration), value);
|
||||
}
|
||||
|
||||
@@ -418,15 +418,14 @@ public class SpelExpression implements Expression {
|
||||
|
||||
@Override
|
||||
public void setValue(EvaluationContext context, Object rootObject, Object value) throws EvaluationException {
|
||||
Assert.notNull(context, "The EvaluationContext is required");
|
||||
Assert.notNull(context, "EvaluationContext is required");
|
||||
this.ast.setValue(new ExpressionState(context, toTypedValue(rootObject), this.configuration), value);
|
||||
}
|
||||
|
||||
|
||||
// impl only
|
||||
|
||||
/**
|
||||
* Compile the expression if it has been evaluated more than the threshold number of times to trigger compilation.
|
||||
* Compile the expression if it has been evaluated more than the threshold number
|
||||
* of times to trigger compilation.
|
||||
* @param expressionState the expression state used to determine compilation mode
|
||||
*/
|
||||
private void checkCompile(ExpressionState expressionState) {
|
||||
@@ -486,16 +485,16 @@ public class SpelExpression implements Expression {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return return the Abstract Syntax Tree for the expression
|
||||
* Return the Abstract Syntax Tree for the expression.
|
||||
*/
|
||||
public SpelNode getAST() {
|
||||
return this.ast;
|
||||
}
|
||||
|
||||
/**
|
||||
* Produce a string representation of the Abstract Syntax Tree for the expression, this should ideally look like the
|
||||
* input expression, but properly formatted since any unnecessary whitespace will have been discarded during the
|
||||
* parse of the expression.
|
||||
* Produce a string representation of the Abstract Syntax Tree for the expression.
|
||||
* This should ideally look like the input expression, but properly formatted since any
|
||||
* unnecessary whitespace will have been discarded during the parse of the expression.
|
||||
* @return the string representation of the AST
|
||||
*/
|
||||
public String toStringAST() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -76,7 +76,7 @@ public class DelegatingConnectionFactory
|
||||
/**
|
||||
* Indicate whether Connections obtained from the target factory are supposed
|
||||
* to be stopped before closed ("true") or simply closed ("false").
|
||||
* The latter may be necessary for some connection pools that simply return
|
||||
* An extra stop call may be necessary for some connection pools that simply return
|
||||
* released connections to the pool, not stopping them while they sit in the pool.
|
||||
* <p>Default is "false", simply closing Connections.
|
||||
* @see ConnectionFactoryUtils#releaseConnection
|
||||
|
||||
@@ -72,13 +72,19 @@ import static org.mockito.BDDMockito.*;
|
||||
public class JmsTemplateTests {
|
||||
|
||||
private Context jndiContext;
|
||||
|
||||
private ConnectionFactory connectionFactory;
|
||||
|
||||
protected Connection connection;
|
||||
|
||||
private Session session;
|
||||
|
||||
private Destination queue;
|
||||
|
||||
private int deliveryMode = DeliveryMode.PERSISTENT;
|
||||
|
||||
private int priority = 9;
|
||||
|
||||
private int timeToLive = 10000;
|
||||
|
||||
|
||||
@@ -94,8 +100,7 @@ public class JmsTemplateTests {
|
||||
queue = mock(Queue.class);
|
||||
|
||||
given(connectionFactory.createConnection()).willReturn(connection);
|
||||
given(connection.createSession(useTransactedTemplate(),
|
||||
Session.AUTO_ACKNOWLEDGE)).willReturn(session);
|
||||
given(connection.createSession(useTransactedTemplate(), Session.AUTO_ACKNOWLEDGE)).willReturn(session);
|
||||
given(session.getTransacted()).willReturn(useTransactedSession());
|
||||
given(jndiContext.lookup("testDestination")).willReturn(queue);
|
||||
}
|
||||
@@ -126,6 +131,7 @@ public class JmsTemplateTests {
|
||||
return session;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testExceptionStackTrace() {
|
||||
JMSException jmsEx = new JMSException("could not connect");
|
||||
|
||||
@@ -30,12 +30,12 @@ public class JmsTemplateTransactedTests extends JmsTemplateTests {
|
||||
|
||||
private Session localSession;
|
||||
|
||||
|
||||
@Override
|
||||
public void setupMocks() throws Exception {
|
||||
super.setupMocks();
|
||||
this.localSession = mock(Session.class);
|
||||
given(this.connection.createSession(false,
|
||||
Session.AUTO_ACKNOWLEDGE)).willReturn(this.localSession);
|
||||
given(this.connection.createSession(false, Session.AUTO_ACKNOWLEDGE)).willReturn(this.localSession);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,8 +38,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.0
|
||||
*/
|
||||
public final class DestinationPatternsMessageCondition
|
||||
extends AbstractMessageCondition<DestinationPatternsMessageCondition> {
|
||||
public class DestinationPatternsMessageCondition extends AbstractMessageCondition<DestinationPatternsMessageCondition> {
|
||||
|
||||
public static final String LOOKUP_DESTINATION_HEADER = "lookupDestination";
|
||||
|
||||
@@ -68,12 +67,13 @@ public final class DestinationPatternsMessageCondition
|
||||
}
|
||||
|
||||
private DestinationPatternsMessageCondition(Collection<String> patterns, PathMatcher pathMatcher) {
|
||||
this.pathMatcher = (pathMatcher != null) ? pathMatcher : new AntPathMatcher();
|
||||
this.pathMatcher = (pathMatcher != null ? pathMatcher : new AntPathMatcher());
|
||||
this.patterns = Collections.unmodifiableSet(prependLeadingSlash(patterns, this.pathMatcher));
|
||||
}
|
||||
|
||||
|
||||
private static List<String> asList(String... patterns) {
|
||||
return patterns != null ? Arrays.asList(patterns) : Collections.<String>emptyList();
|
||||
return (patterns != null ? Arrays.asList(patterns) : Collections.<String>emptyList());
|
||||
}
|
||||
|
||||
private static Set<String> prependLeadingSlash(Collection<String> patterns, PathMatcher pathMatcher) {
|
||||
@@ -93,6 +93,7 @@ public final class DestinationPatternsMessageCondition
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public Set<String> getPatterns() {
|
||||
return this.patterns;
|
||||
}
|
||||
@@ -107,14 +108,15 @@ public final class DestinationPatternsMessageCondition
|
||||
return " || ";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a new instance with URL patterns from the current instance ("this") and
|
||||
* the "other" instance as follows:
|
||||
* <ul>
|
||||
* <li>If there are patterns in both instances, combine the patterns in "this" with
|
||||
* the patterns in "other" using {@link org.springframework.util.PathMatcher#combine(String, String)}.
|
||||
* <li>If only one instance has patterns, use them.
|
||||
* <li>If neither instance has patterns, use an empty String (i.e. "").
|
||||
* <li>If there are patterns in both instances, combine the patterns in "this" with
|
||||
* the patterns in "other" using {@link org.springframework.util.PathMatcher#combine(String, String)}.
|
||||
* <li>If only one instance has patterns, use them.
|
||||
* <li>If neither instance has patterns, use an empty String (i.e. "").
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanInitializationException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
@@ -56,20 +55,20 @@ import org.springframework.validation.Validator;
|
||||
/**
|
||||
* Provides essential configuration for handling messages with simple messaging
|
||||
* protocols such as STOMP.
|
||||
* <p>
|
||||
* {@link #clientInboundChannel()} and {@link #clientOutboundChannel()} deliver messages
|
||||
* to and from remote clients to several message handlers such as
|
||||
*
|
||||
* <p>{@link #clientInboundChannel()} and {@link #clientOutboundChannel()} deliver
|
||||
* messages to and from remote clients to several message handlers such as
|
||||
* <ul>
|
||||
* <li>{@link #simpAnnotationMethodMessageHandler()}</li>
|
||||
* <li>{@link #simpleBrokerMessageHandler()}</li>
|
||||
* <li>{@link #stompBrokerRelayMessageHandler()}</li>
|
||||
* <li>{@link #userDestinationMessageHandler()}</li>
|
||||
* <li>{@link #simpAnnotationMethodMessageHandler()}</li>
|
||||
* <li>{@link #simpleBrokerMessageHandler()}</li>
|
||||
* <li>{@link #stompBrokerRelayMessageHandler()}</li>
|
||||
* <li>{@link #userDestinationMessageHandler()}</li>
|
||||
* </ul>
|
||||
* while {@link #brokerChannel()} delivers messages from within the application to the
|
||||
* the respective message handlers. {@link #brokerMessagingTemplate()} can be injected
|
||||
* into any application component to send messages.
|
||||
* <p>
|
||||
* Sub-classes are responsible for the part of the configuration that feed messages
|
||||
*
|
||||
* <p>Subclasses are responsible for the part of the configuration that feed messages
|
||||
* to and from the client inbound/outbound channels (e.g. STOMP over WebSocket).
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -78,10 +77,11 @@ import org.springframework.validation.Validator;
|
||||
*/
|
||||
public abstract class AbstractMessageBrokerConfiguration implements ApplicationContextAware {
|
||||
|
||||
private static final String MVC_VALIDATOR_NAME = "mvcValidator";
|
||||
|
||||
private static final boolean jackson2Present= ClassUtils.isPresent(
|
||||
"com.fasterxml.jackson.databind.ObjectMapper", AbstractMessageBrokerConfiguration.class.getClassLoader());
|
||||
|
||||
private static final String MVC_VALIDATOR_NAME = "mvcValidator";
|
||||
|
||||
private ChannelRegistration clientInboundChannelRegistration;
|
||||
|
||||
@@ -99,6 +99,16 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
public ApplicationContext getApplicationContext() {
|
||||
return this.applicationContext;
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public AbstractSubscribableChannel clientInboundChannel() {
|
||||
ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(clientInboundChannelExecutor());
|
||||
@@ -125,7 +135,6 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC
|
||||
return this.clientInboundChannelRegistration;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A hook for sub-classes to customize the message channel for inbound messages
|
||||
* from WebSocket clients.
|
||||
@@ -133,7 +142,6 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC
|
||||
protected void configureClientInboundChannel(ChannelRegistration registration) {
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public AbstractSubscribableChannel clientOutboundChannel() {
|
||||
ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(clientOutboundChannelExecutor());
|
||||
@@ -248,13 +256,13 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC
|
||||
@Bean
|
||||
public AbstractBrokerMessageHandler simpleBrokerMessageHandler() {
|
||||
SimpleBrokerMessageHandler handler = getBrokerRegistry().getSimpleBroker(brokerChannel());
|
||||
return (handler != null) ? handler : new NoOpBrokerMessageHandler();
|
||||
return (handler != null ? handler : new NoOpBrokerMessageHandler());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AbstractBrokerMessageHandler stompBrokerRelayMessageHandler() {
|
||||
AbstractBrokerMessageHandler handler = getBrokerRegistry().getStompBrokerRelay(brokerChannel());
|
||||
return (handler != null) ? handler : new NoOpBrokerMessageHandler();
|
||||
return (handler != null ? handler : new NoOpBrokerMessageHandler());
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -294,9 +302,8 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC
|
||||
/**
|
||||
* Override this method to add custom message converters.
|
||||
* @param messageConverters the list to add converters to, initially empty
|
||||
*
|
||||
* @return {@code true} if default message converters should be added to list,
|
||||
* {@code false} if no more converters should be added.
|
||||
* {@code false} if no more converters should be added.
|
||||
*/
|
||||
protected boolean configureMessageConverters(List<MessageConverter> messageConverters) {
|
||||
return true;
|
||||
@@ -317,25 +324,17 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC
|
||||
return new DefaultUserSessionRegistry();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
public ApplicationContext getApplicationContext() {
|
||||
return applicationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@link org.springframework.validation.Validator}s instance for validating
|
||||
* {@code @Payload} method arguments.
|
||||
* In order, this method tries to get a Validator instance:
|
||||
* <p>In order, this method tries to get a Validator instance:
|
||||
* <ul>
|
||||
* <li>delegating to getValidator() first</li>
|
||||
* <li>if none returned, getting an existing instance with its well-known name "mvcValidator", created by an MVC configuration</li>
|
||||
* <li>if none returned, checking the classpath for the presence of a JSR-303 implementation before creating a
|
||||
* {@code OptionalValidatorFactoryBean}</li>
|
||||
* <li>returning a no-op Validator instance</li>
|
||||
* <li>delegating to getValidator() first</li>
|
||||
* <li>if none returned, getting an existing instance with its well-known name "mvcValidator",
|
||||
* created by an MVC configuration</li>
|
||||
* <li>if none returned, checking the classpath for the presence of a JSR-303 implementation
|
||||
* before creating a {@code OptionalValidatorFactoryBean}</li>
|
||||
* <li>returning a no-op Validator instance</li>
|
||||
* </ul>
|
||||
*/
|
||||
protected Validator simpValidator() {
|
||||
@@ -350,11 +349,8 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC
|
||||
String className = "org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean";
|
||||
clazz = ClassUtils.forName(className, AbstractMessageBrokerConfiguration.class.getClassLoader());
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
throw new BeanInitializationException("Could not find default validator", e);
|
||||
}
|
||||
catch (LinkageError e) {
|
||||
throw new BeanInitializationException("Could not find default validator", e);
|
||||
catch (Throwable ex) {
|
||||
throw new BeanInitializationException("Could not find default validator class", ex);
|
||||
}
|
||||
validator = (Validator) BeanUtils.instantiate(clazz);
|
||||
}
|
||||
@@ -403,6 +399,6 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC
|
||||
@Override
|
||||
protected void handleMessageInternal(Message<?> message) {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.springframework.messaging.MessageChannel;
|
||||
*/
|
||||
public class ImmutableMessageChannelInterceptor extends ChannelInterceptorAdapter {
|
||||
|
||||
|
||||
@Override
|
||||
public Message<?> preSend(Message<?> message, MessageChannel channel) {
|
||||
MessageHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, MessageHeaderAccessor.class);
|
||||
|
||||
@@ -260,7 +260,7 @@ public class LocalSessionFactoryBuilder extends Configuration {
|
||||
* @see #scanPackages
|
||||
*/
|
||||
public LocalSessionFactoryBuilder addPackages(String... annotatedPackages) {
|
||||
for (String annotatedPackage :annotatedPackages) {
|
||||
for (String annotatedPackage : annotatedPackages) {
|
||||
addPackage(annotatedPackage);
|
||||
}
|
||||
return this;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,19 +26,15 @@ import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionException;
|
||||
|
||||
/**
|
||||
* SPI strategy that encapsulates certain functionality that standard JPA 2.0
|
||||
* does not offer, such as access to the underlying JDBC Connection. This
|
||||
* strategy is mainly intended for standalone usage of a JPA provider; most
|
||||
* of its functionality is not relevant when running with JTA transactions.
|
||||
* SPI strategy that encapsulates certain functionality that standard JPA 2.0 does
|
||||
* not offer, such as access to the underlying JDBC Connection. This strategy is
|
||||
* mainly intended for standalone usage of a JPA provider; most of its functionality
|
||||
* is not relevant when running with JTA transactions.
|
||||
*
|
||||
* <p>Also allows for the provision of value-added methods for portable yet
|
||||
* more capable EntityManager and EntityManagerFactory subinterfaces offered
|
||||
* by Spring.
|
||||
*
|
||||
* <p>In general, it is recommended to derive from DefaultJpaDialect instead of
|
||||
* implementing this interface directly. This allows for inheriting common
|
||||
* behavior (present and future) from DefaultJpaDialect, only overriding
|
||||
* specific hooks to plug in concrete vendor-specific behavior.
|
||||
* <p>In general, it is recommended to derive from {@link DefaultJpaDialect} instead
|
||||
* of implementing this interface directly. This allows for inheriting common behavior
|
||||
* (present and future) from DefaultJpaDialect, only overriding specific hooks to
|
||||
* plug in concrete vendor-specific behavior.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Rod Johnson
|
||||
@@ -141,9 +137,8 @@ public interface JpaDialect extends PersistenceExceptionTranslator {
|
||||
* an implementation should use a special handle that references that other object.
|
||||
* @param entityManager the current JPA EntityManager
|
||||
* @param readOnly whether the Connection is only needed for read-only purposes
|
||||
* @return a handle for the JDBC Connection, to be passed into
|
||||
* {@code releaseJdbcConnection}, or {@code null}
|
||||
* if no JDBC Connection can be retrieved
|
||||
* @return a handle for the Connection, to be passed into {@code releaseJdbcConnection},
|
||||
* or {@code null} if no JDBC Connection can be retrieved
|
||||
* @throws javax.persistence.PersistenceException if thrown by JPA methods
|
||||
* @throws java.sql.SQLException if thrown by JDBC methods
|
||||
* @see #releaseJdbcConnection
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,12 +29,12 @@ import java.lang.annotation.Target;
|
||||
* associated with a test is <em>dirty</em> and should be closed:
|
||||
*
|
||||
* <ul>
|
||||
* <li>after the current test, when declared at the method level</li>
|
||||
* <li>after each test method in the current test class, when declared at the
|
||||
* class level with class mode set to {@link ClassMode#AFTER_EACH_TEST_METHOD
|
||||
* AFTER_EACH_TEST_METHOD}</li>
|
||||
* <li>after the current test class, when declared at the class level with class
|
||||
* mode set to {@link ClassMode#AFTER_CLASS AFTER_CLASS}</li>
|
||||
* <li>after the current test, when declared at the method level</li>
|
||||
* <li>after each test method in the current test class, when declared at the
|
||||
* class level with class mode set to {@link ClassMode#AFTER_EACH_TEST_METHOD
|
||||
* AFTER_EACH_TEST_METHOD}</li>
|
||||
* <li>after the current test class, when declared at the class level with class
|
||||
* mode set to {@link ClassMode#AFTER_CLASS AFTER_CLASS}</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>Use this annotation if a test has modified the context — for example,
|
||||
|
||||
@@ -49,9 +49,9 @@ import org.springframework.test.context.web.ServletTestExecutionListener;
|
||||
* TestExecutionListeners} are configured by default:
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@link org.springframework.test.context.web.ServletTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.support.DependencyInjectionTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.support.DirtiesContextTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.web.ServletTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.support.DependencyInjectionTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.support.DirtiesContextTestExecutionListener}
|
||||
* </ul>
|
||||
*
|
||||
* <p>Note: this class serves only as a convenience for extension. If you do not
|
||||
@@ -76,8 +76,8 @@ import org.springframework.test.context.web.ServletTestExecutionListener;
|
||||
* @see org.springframework.test.context.testng.AbstractTestNGSpringContextTests
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@TestExecutionListeners({ ServletTestExecutionListener.class, DependencyInjectionTestExecutionListener.class,
|
||||
DirtiesContextTestExecutionListener.class })
|
||||
@TestExecutionListeners({ServletTestExecutionListener.class, DependencyInjectionTestExecutionListener.class,
|
||||
DirtiesContextTestExecutionListener.class})
|
||||
public abstract class AbstractJUnit4SpringContextTests implements ApplicationContextAware {
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,11 +53,11 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* TestExecutionListeners} are configured by default:
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@link org.springframework.test.context.web.ServletTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.support.DependencyInjectionTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.support.DirtiesContextTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.transaction.TransactionalTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.web.ServletTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.support.DependencyInjectionTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.support.DirtiesContextTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.transaction.TransactionalTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener}
|
||||
* </ul>
|
||||
*
|
||||
* <p>Note: this class serves only as a convenience for extension. If you do not
|
||||
@@ -86,7 +86,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @see org.springframework.test.jdbc.JdbcTestUtils
|
||||
* @see org.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests
|
||||
*/
|
||||
@TestExecutionListeners({ TransactionalTestExecutionListener.class, SqlScriptsTestExecutionListener.class })
|
||||
@TestExecutionListeners({TransactionalTestExecutionListener.class, SqlScriptsTestExecutionListener.class})
|
||||
@Transactional
|
||||
public abstract class AbstractTransactionalJUnit4SpringContextTests extends AbstractJUnit4SpringContextTests {
|
||||
|
||||
|
||||
@@ -63,9 +63,9 @@ import org.springframework.test.context.web.ServletTestExecutionListener;
|
||||
* TestExecutionListeners} are configured by default:
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@link org.springframework.test.context.web.ServletTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.support.DependencyInjectionTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.support.DirtiesContextTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.web.ServletTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.support.DependencyInjectionTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.support.DirtiesContextTestExecutionListener}
|
||||
* </ul>
|
||||
*
|
||||
* @author Sam Brannen
|
||||
@@ -81,8 +81,8 @@ import org.springframework.test.context.web.ServletTestExecutionListener;
|
||||
* @see AbstractTransactionalTestNGSpringContextTests
|
||||
* @see org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests
|
||||
*/
|
||||
@TestExecutionListeners({ ServletTestExecutionListener.class, DependencyInjectionTestExecutionListener.class,
|
||||
DirtiesContextTestExecutionListener.class })
|
||||
@TestExecutionListeners({ServletTestExecutionListener.class, DependencyInjectionTestExecutionListener.class,
|
||||
DirtiesContextTestExecutionListener.class})
|
||||
public abstract class AbstractTestNGSpringContextTests implements IHookable, ApplicationContextAware {
|
||||
|
||||
/** Logger available to subclasses */
|
||||
|
||||
@@ -52,11 +52,11 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* TestExecutionListeners} are configured by default:
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@link org.springframework.test.context.web.ServletTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.support.DependencyInjectionTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.support.DirtiesContextTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.transaction.TransactionalTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.web.ServletTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.support.DependencyInjectionTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.support.DirtiesContextTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.transaction.TransactionalTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener}
|
||||
* </ul>
|
||||
*
|
||||
* @author Sam Brannen
|
||||
@@ -75,7 +75,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @see org.springframework.test.jdbc.JdbcTestUtils
|
||||
* @see org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests
|
||||
*/
|
||||
@TestExecutionListeners({ TransactionalTestExecutionListener.class, SqlScriptsTestExecutionListener.class })
|
||||
@TestExecutionListeners({TransactionalTestExecutionListener.class, SqlScriptsTestExecutionListener.class})
|
||||
@Transactional
|
||||
public abstract class AbstractTransactionalTestNGSpringContextTests extends AbstractTestNGSpringContextTests {
|
||||
|
||||
|
||||
@@ -127,8 +127,7 @@ public abstract class Log4jWebConfigurer {
|
||||
|
||||
// Leave a URL (e.g. "classpath:" or "file:") as-is.
|
||||
if (!ResourceUtils.isUrl(location)) {
|
||||
// Consider a plain file path as relative to the web
|
||||
// application root directory.
|
||||
// Consider a plain file path as relative to the web application root directory.
|
||||
location = WebUtils.getRealPath(servletContext, location);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -74,36 +74,32 @@ import javax.portlet.ResourceResponse;
|
||||
*
|
||||
* <p><b>Action Request:</b><p>
|
||||
* <ol>
|
||||
* <li>{@code DispatcherPortlet} maps the action request to a particular handler
|
||||
* and assembles a handler execution chain consisting of the handler that
|
||||
* is to be invoked and all of the {@code HandlerInterceptor}
|
||||
* instances that apply to the request.</li>
|
||||
* <li>{@link HandlerInterceptor#preHandleAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse, Object) preHandleAction(..)}
|
||||
* is called; if the invocation of this method returns {@code true} then
|
||||
* this workflow continues</li>
|
||||
* <li>The target handler handles the action request (via
|
||||
* {@link HandlerAdapter#handleAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse, Object) HandlerAdapter.handleAction(..)})</li>
|
||||
* <li>{@link HandlerInterceptor#afterActionCompletion(javax.portlet.ActionRequest, javax.portlet.ActionResponse, Object, Exception) afterActionCompletion(..)}
|
||||
* is called</li>
|
||||
* <li>{@code DispatcherPortlet} maps the action request to a particular handler and
|
||||
* assembles a handler execution chain consisting of the handler that is to be invoked
|
||||
* and all of the {@code HandlerInterceptor} instances that apply to the request.</li>
|
||||
* <li>{@link HandlerInterceptor#preHandleAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse, Object) preHandleAction(..)}
|
||||
* is called; if the invocation of this method returns {@code true} then this workflow continues.</li>
|
||||
* <li>The target handler handles the action request (via
|
||||
* {@link HandlerAdapter#handleAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse, Object) HandlerAdapter.handleAction(..)}).</li>
|
||||
* <li>{@link HandlerInterceptor#afterActionCompletion(javax.portlet.ActionRequest, javax.portlet.ActionResponse, Object, Exception) afterActionCompletion(..)}
|
||||
* is called.</li>
|
||||
* </ol>
|
||||
*
|
||||
* <p><b>Render Request:</b><p>
|
||||
* <ol>
|
||||
* <li>{@code DispatcherPortlet} maps the render request to a particular handler
|
||||
* and assembles a handler execution chain consisting of the handler that
|
||||
* is to be invoked and all of the {@code HandlerInterceptor}
|
||||
* instances that apply to the request.</li>
|
||||
* <li>{@link HandlerInterceptor#preHandleRender(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object) preHandleRender(..)}
|
||||
* is called; if the invocation of this method returns {@code true} then
|
||||
* this workflow continues</li>
|
||||
* <li>The target handler handles the render request (via
|
||||
* {@link HandlerAdapter#handleRender(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object) HandlerAdapter.handleRender(..)})</li>
|
||||
* <li>{@link HandlerInterceptor#postHandleRender(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object, ModelAndView) postHandleRender(..)}
|
||||
* is called</li>
|
||||
* <li>If the {@code HandlerAdapter} returned a {@code ModelAndView},
|
||||
* then {@code DispatcherPortlet} renders the view accordingly
|
||||
* <li>{@link HandlerInterceptor#afterRenderCompletion(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object, Exception) afterRenderCompletion(..)}
|
||||
* is called</li>
|
||||
* <li>{@code DispatcherPortlet} maps the render request to a particular handler and
|
||||
* assembles a handler execution chain consisting of the handler that is to be invoked
|
||||
* and all of the {@code HandlerInterceptor} instances that apply to the request.</li>
|
||||
* <li>{@link HandlerInterceptor#preHandleRender(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object) preHandleRender(..)}
|
||||
* is called; if the invocation of this method returns {@code true} then this workflow continues.</li>
|
||||
* <li>The target handler handles the render request (via
|
||||
* {@link HandlerAdapter#handleRender(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object) HandlerAdapter.handleRender(..)}).</li>
|
||||
* <li>{@link HandlerInterceptor#postHandleRender(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object, ModelAndView) postHandleRender(..)}
|
||||
* is called.</li>
|
||||
* <li>If the {@code HandlerAdapter} returned a {@code ModelAndView}, then
|
||||
* {@code DispatcherPortlet} renders the view accordingly.
|
||||
* <li>{@link HandlerInterceptor#afterRenderCompletion(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object, Exception) afterRenderCompletion(..)}
|
||||
* is called.</li>
|
||||
* </ol>
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
@@ -151,8 +147,7 @@ public interface HandlerInterceptor {
|
||||
* request execution may have failed even when this argument is {@code null})
|
||||
* @throws Exception in case of errors
|
||||
*/
|
||||
void afterActionCompletion(
|
||||
ActionRequest request, ActionResponse response, Object handler, Exception ex)
|
||||
void afterActionCompletion(ActionRequest request, ActionResponse response, Object handler, Exception ex)
|
||||
throws Exception;
|
||||
|
||||
/**
|
||||
@@ -191,8 +186,7 @@ public interface HandlerInterceptor {
|
||||
* (can also be {@code null})
|
||||
* @throws Exception in case of errors
|
||||
*/
|
||||
void postHandleRender(
|
||||
RenderRequest request, RenderResponse response, Object handler, ModelAndView modelAndView)
|
||||
void postHandleRender(RenderRequest request, RenderResponse response, Object handler, ModelAndView modelAndView)
|
||||
throws Exception;
|
||||
|
||||
/**
|
||||
@@ -208,8 +202,7 @@ public interface HandlerInterceptor {
|
||||
* @param ex exception thrown on handler execution, if any
|
||||
* @throws Exception in case of errors
|
||||
*/
|
||||
void afterRenderCompletion(
|
||||
RenderRequest request, RenderResponse response, Object handler, Exception ex)
|
||||
void afterRenderCompletion(RenderRequest request, RenderResponse response, Object handler, Exception ex)
|
||||
throws Exception;
|
||||
|
||||
/**
|
||||
@@ -248,8 +241,7 @@ public interface HandlerInterceptor {
|
||||
* (can also be {@code null})
|
||||
* @throws Exception in case of errors
|
||||
*/
|
||||
void postHandleResource(
|
||||
ResourceRequest request, ResourceResponse response, Object handler, ModelAndView modelAndView)
|
||||
void postHandleResource(ResourceRequest request, ResourceResponse response, Object handler, ModelAndView modelAndView)
|
||||
throws Exception;
|
||||
|
||||
/**
|
||||
@@ -265,11 +257,9 @@ public interface HandlerInterceptor {
|
||||
* @param ex exception thrown on handler execution, if any
|
||||
* @throws Exception in case of errors
|
||||
*/
|
||||
void afterResourceCompletion(
|
||||
ResourceRequest request, ResourceResponse response, Object handler, Exception ex)
|
||||
void afterResourceCompletion(ResourceRequest request, ResourceResponse response, Object handler, Exception ex)
|
||||
throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* Intercept the execution of a handler in the action phase.
|
||||
* <p>Called after a HandlerMapping determines an appropriate handler object
|
||||
@@ -305,8 +295,7 @@ public interface HandlerInterceptor {
|
||||
* request execution may have failed even when this argument is {@code null})
|
||||
* @throws Exception in case of errors
|
||||
*/
|
||||
void afterEventCompletion(
|
||||
EventRequest request, EventResponse response, Object handler, Exception ex)
|
||||
void afterEventCompletion(EventRequest request, EventResponse response, Object handler, Exception ex)
|
||||
throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,69 +41,69 @@ import org.springframework.web.portlet.util.PortletUtils;
|
||||
* <p><b><a name="workflow">Workflow
|
||||
* (<a href="Controller.html#workflow">and that defined by interface</a>):</b><br>
|
||||
* <ol>
|
||||
* <li>If this is an action request, {@link #handleActionRequest handleActionRequest}
|
||||
* will be called by the DispatcherPortlet once to perform the action defined by this
|
||||
* controller.</li>
|
||||
* <li>If a session is required, try to get it (PortletException if not found).</li>
|
||||
* <li>Call method {@link #handleActionRequestInternal handleActionRequestInternal},
|
||||
* (optionally synchronizing around the call on the PortletSession),
|
||||
* which should be overridden by extending classes to provide actual functionality to
|
||||
* perform the desired action of the controller. This will be executed only once.</li>
|
||||
* <li>For a straight render request, or the render phase of an action request (assuming the
|
||||
* same controller is called for the render phase -- see tip below),
|
||||
* {@link #handleRenderRequest handleRenderRequest} will be called by the DispatcherPortlet
|
||||
* repeatedly to render the display defined by this controller.</li>
|
||||
* <li>If a session is required, try to get it (PortletException if none found).</li>
|
||||
* <li>It will control caching as defined by the cacheSeconds property.</li>
|
||||
* <li>Call method {@link #handleRenderRequestInternal handleRenderRequestInternal},
|
||||
* (optionally synchronizing around the call on the PortletSession),
|
||||
* which should be overridden by extending classes to provide actual functionality to
|
||||
* return {@link org.springframework.web.portlet.ModelAndView ModelAndView} objects.
|
||||
* This will be executed repeatedly as the portal updates the current displayed page.</li>
|
||||
* <li>If this is an action request, {@link #handleActionRequest handleActionRequest}
|
||||
* will be called by the DispatcherPortlet once to perform the action defined by this
|
||||
* controller.</li>
|
||||
* <li>If a session is required, try to get it (PortletException if not found).</li>
|
||||
* <li>Call method {@link #handleActionRequestInternal handleActionRequestInternal},
|
||||
* (optionally synchronizing around the call on the PortletSession),
|
||||
* which should be overridden by extending classes to provide actual functionality to
|
||||
* perform the desired action of the controller. This will be executed only once.</li>
|
||||
* <li>For a straight render request, or the render phase of an action request (assuming the
|
||||
* same controller is called for the render phase -- see tip below),
|
||||
* {@link #handleRenderRequest handleRenderRequest} will be called by the DispatcherPortlet
|
||||
* repeatedly to render the display defined by this controller.</li>
|
||||
* <li>If a session is required, try to get it (PortletException if none found).</li>
|
||||
* <li>It will control caching as defined by the cacheSeconds property.</li>
|
||||
* <li>Call method {@link #handleRenderRequestInternal handleRenderRequestInternal},
|
||||
* (optionally synchronizing around the call on the PortletSession),
|
||||
* which should be overridden by extending classes to provide actual functionality to
|
||||
* return {@link org.springframework.web.portlet.ModelAndView ModelAndView} objects.
|
||||
* This will be executed repeatedly as the portal updates the current displayed page.</li>
|
||||
* </ol>
|
||||
*
|
||||
* <p><b><a name="config">Exposed configuration properties</a>
|
||||
* (<a href="Controller.html#config">and those defined by interface</a>):</b><br>
|
||||
* <table border="1">
|
||||
* <tr>
|
||||
* <td><b>name</b></th>
|
||||
* <td><b>default</b></td>
|
||||
* <td><b>description</b></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>requireSession</td>
|
||||
* <td>false</td>
|
||||
* <td>whether a session should be required for requests to be able to
|
||||
* be handled by this controller. This ensures, derived controller
|
||||
* can - without fear of Nullpointers - call request.getSession() to
|
||||
* retrieve a session. If no session can be found while processing
|
||||
* the request, a PortletException will be thrown</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>synchronizeOnSession</td>
|
||||
* <td>false</td>
|
||||
* <td>whether the calls to {@code handleRenderRequestInternal} and
|
||||
* {@code handleRenderRequestInternal} should be
|
||||
* synchronized around the PortletSession, to serialize invocations
|
||||
* from the same client. No effect if there is no PortletSession.
|
||||
* </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>cacheSeconds</td>
|
||||
* <td>-1</td>
|
||||
* <td>indicates the amount of seconds to specify caching is allowed in
|
||||
* the render response generatedby this request. 0 (zero) will indicate
|
||||
* no caching is allowed at all, -1 (the default) will not override the
|
||||
* portlet configuration and any positive number will cause the render
|
||||
* response to declare the amount indicated as seconds to cache the content</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>renderWhenMinimized</td>
|
||||
* <td>false</td>
|
||||
* <td>whether should be rendered when the portlet is in a minimized state --
|
||||
* will return null for the ModelandView when the portlet is minimized
|
||||
* and this is false</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>name</b></th>
|
||||
* <td><b>default</b></td>
|
||||
* <td><b>description</b></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>requireSession</td>
|
||||
* <td>false</td>
|
||||
* <td>whether a session should be required for requests to be able to
|
||||
* be handled by this controller. This ensures, derived controller
|
||||
* can - without fear of Nullpointers - call request.getSession() to
|
||||
* retrieve a session. If no session can be found while processing
|
||||
* the request, a PortletException will be thrown</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>synchronizeOnSession</td>
|
||||
* <td>false</td>
|
||||
* <td>whether the calls to {@code handleRenderRequestInternal} and
|
||||
* {@code handleRenderRequestInternal} should be synchronized around
|
||||
* the PortletSession, to serialize invocations from the same client.
|
||||
* No effect if there is no PortletSession.
|
||||
* </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>cacheSeconds</td>
|
||||
* <td>-1</td>
|
||||
* <td>indicates the amount of seconds to specify caching is allowed in
|
||||
* the render response generatedby this request. 0 (zero) will indicate
|
||||
* no caching is allowed at all, -1 (the default) will not override the
|
||||
* portlet configuration and any positive number will cause the render
|
||||
* response to declare the amount indicated as seconds to cache the content</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>renderWhenMinimized</td>
|
||||
* <td>false</td>
|
||||
* <td>whether should be rendered when the portlet is in a minimized state --
|
||||
* will return null for the ModelandView when the portlet is minimized
|
||||
* and this is false</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* <p><b>TIP:</b> The controller mapping will be run twice by the PortletDispatcher for
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,42 +22,37 @@ import javax.portlet.RenderResponse;
|
||||
import org.springframework.web.portlet.ModelAndView;
|
||||
|
||||
/**
|
||||
* <p>Trivial controller that always returns a named view. The view
|
||||
* can be configured using an exposed configuration property. This
|
||||
* controller offers an alternative to sending a request straight to a view
|
||||
* such as a JSP. The advantage here is that the client is not exposed to
|
||||
* the concrete view technology but rather just to the controller URL;
|
||||
* the concrete view will be determined by the ViewResolver.</p>
|
||||
* Trivial controller that always returns a named view. The view can be configured
|
||||
* using an exposed configuration property. This controller offers an alternative
|
||||
* to sending a request straight to a view such as a JSP. The advantage here is
|
||||
* that the client is not exposed to the concrete view technology but rather just
|
||||
* to the controller URL; the concrete view will be determined by the ViewResolver.
|
||||
*
|
||||
* <p><b><a name="workflow">Workflow
|
||||
* (<a href="AbstractController.html#workflow">and that defined by superclass</a>):</b><br>
|
||||
* (<a href="AbstractController.html#workflow">and that defined by superclass</a>):</b>
|
||||
* <ol>
|
||||
* <li>Render request is received by the controller</li>
|
||||
* <li>call to {@link #handleRenderRequestInternal handleRenderRequestInternal} which
|
||||
* just returns the view, named by the configuration property
|
||||
* {@code viewName}. Nothing more, nothing less</li>
|
||||
* <li>Render request is received by the controller</li>
|
||||
* <li>call to {@link #handleRenderRequestInternal handleRenderRequestInternal} which
|
||||
* just returns the view, named by the configuration property {@code viewName}.</li>
|
||||
* </ol>
|
||||
* </p>
|
||||
*
|
||||
* <p>This controller does not handle action requests.</p>
|
||||
* <p>This controller does not handle action requests.
|
||||
*
|
||||
* <p><b><a name="config">Exposed configuration properties</a>
|
||||
* (<a href="AbstractController.html#config">and those defined by superclass</a>):</b><br>
|
||||
* (<a href="AbstractController.html#config">and those defined by superclass</a>):</b>
|
||||
* <table border="1">
|
||||
* <tr>
|
||||
* <td><b>name</b></td>
|
||||
* <td><b>default</b></td>
|
||||
* <td><b>description</b></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>viewName</td>
|
||||
* <td><i>null</i></td>
|
||||
* <td>the name of the view the viewResolver will use to forward to
|
||||
* (if this property is not set, an exception will be thrown during
|
||||
* initialization)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>name</b></td>
|
||||
* <td><b>default</b></td>
|
||||
* <td><b>description</b></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>viewName</td>
|
||||
* <td><i>null</i></td>
|
||||
* <td>the name of the view the viewResolver will use to forward to (if this property
|
||||
* is not set, an exception will be thrown during initialization)</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
* </p>
|
||||
*
|
||||
* @author John A. Lewis
|
||||
* @since 2.0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -108,8 +108,7 @@ public interface HandlerInterceptor {
|
||||
* (can also be {@code null})
|
||||
* @throws Exception in case of errors
|
||||
*/
|
||||
void postHandle(
|
||||
HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)
|
||||
void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)
|
||||
throws Exception;
|
||||
|
||||
/**
|
||||
@@ -128,8 +127,7 @@ public interface HandlerInterceptor {
|
||||
* @param ex exception thrown on handler execution, if any
|
||||
* @throws Exception in case of errors
|
||||
*/
|
||||
void afterCompletion(
|
||||
HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
|
||||
void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
|
||||
throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -84,10 +84,10 @@ import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolv
|
||||
*
|
||||
* <p>This class registers the following {@link HandlerMapping}s:</p>
|
||||
* <ul>
|
||||
* <li>{@link RequestMappingHandlerMapping}
|
||||
* ordered at 0 for mapping requests to annotated controller methods.
|
||||
* <li>{@link BeanNameUrlHandlerMapping}
|
||||
* ordered at 2 to map URL paths to controller bean names.
|
||||
* <li>{@link RequestMappingHandlerMapping}
|
||||
* ordered at 0 for mapping requests to annotated controller methods.
|
||||
* <li>{@link BeanNameUrlHandlerMapping}
|
||||
* ordered at 2 to map URL paths to controller bean names.
|
||||
* </ul>
|
||||
*
|
||||
* <p><strong>Note:</strong> Additional HandlerMappings may be registered
|
||||
@@ -96,30 +96,30 @@ import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolv
|
||||
*
|
||||
* <p>This class registers the following {@link HandlerAdapter}s:
|
||||
* <ul>
|
||||
* <li>{@link RequestMappingHandlerAdapter}
|
||||
* for processing requests with annotated controller methods.
|
||||
* <li>{@link HttpRequestHandlerAdapter}
|
||||
* for processing requests with {@link HttpRequestHandler}s.
|
||||
* <li>{@link SimpleControllerHandlerAdapter}
|
||||
* for processing requests with interface-based {@link Controller}s.
|
||||
* <li>{@link RequestMappingHandlerAdapter}
|
||||
* for processing requests with annotated controller methods.
|
||||
* <li>{@link HttpRequestHandlerAdapter}
|
||||
* for processing requests with {@link HttpRequestHandler}s.
|
||||
* <li>{@link SimpleControllerHandlerAdapter}
|
||||
* for processing requests with interface-based {@link Controller}s.
|
||||
* </ul>
|
||||
*
|
||||
* <p>This class registers the following {@link HandlerExceptionResolver}s:
|
||||
* <ul>
|
||||
* <li>{@link ExceptionHandlerExceptionResolver} for handling exceptions
|
||||
* through @{@link ExceptionHandler} methods.
|
||||
* <li>{@link ResponseStatusExceptionResolver} for exceptions annotated
|
||||
* with @{@link ResponseStatus}.
|
||||
* <li>{@link DefaultHandlerExceptionResolver} for resolving known Spring
|
||||
* exception types
|
||||
* <li>{@link ExceptionHandlerExceptionResolver} for handling exceptions
|
||||
* through @{@link ExceptionHandler} methods.
|
||||
* <li>{@link ResponseStatusExceptionResolver} for exceptions annotated
|
||||
* with @{@link ResponseStatus}.
|
||||
* <li>{@link DefaultHandlerExceptionResolver} for resolving known Spring
|
||||
* exception types
|
||||
* </ul>
|
||||
*
|
||||
* <p>This class registers an {@link org.springframework.util.AntPathMatcher}
|
||||
* and a {@link org.springframework.web.util.UrlPathHelper} to be used by:
|
||||
* <ul>
|
||||
* <li>the {@link RequestMappingHandlerMapping},
|
||||
* <li>the {@link HandlerMapping} for ViewControllers
|
||||
* <li>and the {@link HandlerMapping} for serving resources
|
||||
* <li>the {@link RequestMappingHandlerMapping},
|
||||
* <li>the {@link HandlerMapping} for ViewControllers
|
||||
* <li>and the {@link HandlerMapping} for serving resources
|
||||
* </ul>
|
||||
* Note that those beans can be configured by using the {@code path-matching} MVC namespace element.
|
||||
*
|
||||
@@ -127,12 +127,12 @@ import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolv
|
||||
* {@link ExceptionHandlerExceptionResolver} are configured with instances of
|
||||
* the following by default:
|
||||
* <ul>
|
||||
* <li>A {@link ContentNegotiationManager}
|
||||
* <li>A {@link DefaultFormattingConversionService}
|
||||
* <li>A {@link org.springframework.validation.beanvalidation.LocalValidatorFactoryBean}
|
||||
* if a JSR-303 implementation is available on the classpath
|
||||
* <li>A range of {@link HttpMessageConverter}s depending on what 3rd party
|
||||
* libraries are available on the classpath.
|
||||
* <li>A {@link ContentNegotiationManager}
|
||||
* <li>A {@link DefaultFormattingConversionService}
|
||||
* <li>A {@link org.springframework.validation.beanvalidation.LocalValidatorFactoryBean}
|
||||
* if a JSR-303 implementation is available on the classpath
|
||||
* <li>A range of {@link HttpMessageConverter}s depending on what 3rd party
|
||||
* libraries are available on the classpath.
|
||||
* </ul>
|
||||
*
|
||||
* @author Keith Donald
|
||||
@@ -576,10 +576,12 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
||||
if (StringUtils.hasText("bean")) {
|
||||
reference = new RuntimeBeanReference(refElement.getAttribute("bean"),false);
|
||||
list.add(reference);
|
||||
}else if (StringUtils.hasText("parent")){
|
||||
}
|
||||
else if (StringUtils.hasText("parent")){
|
||||
reference = new RuntimeBeanReference(refElement.getAttribute("parent"),true);
|
||||
list.add(reference);
|
||||
}else{
|
||||
}
|
||||
else {
|
||||
parserContext.getReaderContext().error("'bean' or 'parent' attribute is required for <ref> element",
|
||||
parserContext.extractSource(parentElement));
|
||||
}
|
||||
|
||||
@@ -22,11 +22,12 @@ import org.springframework.web.util.UrlPathHelper;
|
||||
/**
|
||||
* Helps with configuring HandlerMappings path matching options such as trailing slash match,
|
||||
* suffix registration, path matcher and path helper.
|
||||
* Configured path matcher and path helper instances are shared for:
|
||||
*
|
||||
* <p>Configured path matcher and path helper instances are shared for:
|
||||
* <ul>
|
||||
* <li>RequestMappings</li>
|
||||
* <li>ViewControllerMappings</li>
|
||||
* <li>ResourcesMappings</li>
|
||||
* <li>RequestMappings</li>
|
||||
* <li>ViewControllerMappings</li>
|
||||
* <li>ResourcesMappings</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Brian Clozel
|
||||
|
||||
@@ -102,45 +102,45 @@ import org.springframework.web.util.UrlPathHelper;
|
||||
*
|
||||
* <p>This class registers the following {@link HandlerMapping}s:</p>
|
||||
* <ul>
|
||||
* <li>{@link RequestMappingHandlerMapping}
|
||||
* ordered at 0 for mapping requests to annotated controller methods.
|
||||
* <li>{@link HandlerMapping}
|
||||
* ordered at 1 to map URL paths directly to view names.
|
||||
* <li>{@link BeanNameUrlHandlerMapping}
|
||||
* ordered at 2 to map URL paths to controller bean names.
|
||||
* <li>{@link HandlerMapping}
|
||||
* ordered at {@code Integer.MAX_VALUE-1} to serve static resource requests.
|
||||
* <li>{@link HandlerMapping}
|
||||
* ordered at {@code Integer.MAX_VALUE} to forward requests to the default servlet.
|
||||
* <li>{@link RequestMappingHandlerMapping}
|
||||
* ordered at 0 for mapping requests to annotated controller methods.
|
||||
* <li>{@link HandlerMapping}
|
||||
* ordered at 1 to map URL paths directly to view names.
|
||||
* <li>{@link BeanNameUrlHandlerMapping}
|
||||
* ordered at 2 to map URL paths to controller bean names.
|
||||
* <li>{@link HandlerMapping}
|
||||
* ordered at {@code Integer.MAX_VALUE-1} to serve static resource requests.
|
||||
* <li>{@link HandlerMapping}
|
||||
* ordered at {@code Integer.MAX_VALUE} to forward requests to the default servlet.
|
||||
* </ul>
|
||||
*
|
||||
* <p>Registers these {@link HandlerAdapter}s:
|
||||
* <ul>
|
||||
* <li>{@link RequestMappingHandlerAdapter}
|
||||
* for processing requests with annotated controller methods.
|
||||
* <li>{@link HttpRequestHandlerAdapter}
|
||||
* for processing requests with {@link HttpRequestHandler}s.
|
||||
* <li>{@link SimpleControllerHandlerAdapter}
|
||||
* for processing requests with interface-based {@link Controller}s.
|
||||
* <li>{@link RequestMappingHandlerAdapter}
|
||||
* for processing requests with annotated controller methods.
|
||||
* <li>{@link HttpRequestHandlerAdapter}
|
||||
* for processing requests with {@link HttpRequestHandler}s.
|
||||
* <li>{@link SimpleControllerHandlerAdapter}
|
||||
* for processing requests with interface-based {@link Controller}s.
|
||||
* </ul>
|
||||
*
|
||||
* <p>Registers a {@link HandlerExceptionResolverComposite} with this chain of
|
||||
* exception resolvers:
|
||||
* <ul>
|
||||
* <li>{@link ExceptionHandlerExceptionResolver} for handling exceptions
|
||||
* through @{@link ExceptionHandler} methods.
|
||||
* <li>{@link ResponseStatusExceptionResolver} for exceptions annotated
|
||||
* with @{@link ResponseStatus}.
|
||||
* <li>{@link DefaultHandlerExceptionResolver} for resolving known Spring
|
||||
* exception types
|
||||
* <li>{@link ExceptionHandlerExceptionResolver} for handling exceptions
|
||||
* through @{@link ExceptionHandler} methods.
|
||||
* <li>{@link ResponseStatusExceptionResolver} for exceptions annotated
|
||||
* with @{@link ResponseStatus}.
|
||||
* <li>{@link DefaultHandlerExceptionResolver} for resolving known Spring
|
||||
* exception types
|
||||
* </ul>
|
||||
*
|
||||
* <p>Registers an {@link AntPathMatcher} and a {@link UrlPathHelper}
|
||||
* to be used by:
|
||||
* <ul>
|
||||
* <li>the {@link RequestMappingHandlerMapping},
|
||||
* <li>the {@link HandlerMapping} for ViewControllers
|
||||
* <li>and the {@link HandlerMapping} for serving resources
|
||||
* <li>the {@link RequestMappingHandlerMapping},
|
||||
* <li>the {@link HandlerMapping} for ViewControllers
|
||||
* <li>and the {@link HandlerMapping} for serving resources
|
||||
* </ul>
|
||||
* Note that those beans can be configured with a {@link PathMatchConfigurer}.
|
||||
*
|
||||
@@ -148,12 +148,12 @@ import org.springframework.web.util.UrlPathHelper;
|
||||
* {@link ExceptionHandlerExceptionResolver} are configured with default
|
||||
* instances of the following by default:
|
||||
* <ul>
|
||||
* <li>A {@link ContentNegotiationManager}
|
||||
* <li>A {@link DefaultFormattingConversionService}
|
||||
* <li>A {@link org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean}
|
||||
* if a JSR-303 implementation is available on the classpath
|
||||
* <li>A range of {@link HttpMessageConverter}s depending on the 3rd party
|
||||
* libraries available on the classpath.
|
||||
* <li>a {@link ContentNegotiationManager}
|
||||
* <li>a {@link DefaultFormattingConversionService}
|
||||
* <li>a {@link org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean}
|
||||
* if a JSR-303 implementation is available on the classpath
|
||||
* <li>a range of {@link HttpMessageConverter}s depending on the third-party
|
||||
* libraries available on the classpath.
|
||||
* </ul>
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -439,9 +439,9 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
|
||||
* through annotated controller methods. Consider overriding one of these
|
||||
* other more fine-grained methods:
|
||||
* <ul>
|
||||
* <li>{@link #addArgumentResolvers} for adding custom argument resolvers.
|
||||
* <li>{@link #addReturnValueHandlers} for adding custom return value handlers.
|
||||
* <li>{@link #configureMessageConverters} for adding custom message converters.
|
||||
* <li>{@link #addArgumentResolvers} for adding custom argument resolvers.
|
||||
* <li>{@link #addReturnValueHandlers} for adding custom return value handlers.
|
||||
* <li>{@link #configureMessageConverters} for adding custom message converters.
|
||||
* </ul>
|
||||
*/
|
||||
@Bean
|
||||
@@ -763,17 +763,16 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
|
||||
* A method available to subclasses for adding default {@link HandlerExceptionResolver}s.
|
||||
* <p>Adds the following exception resolvers:
|
||||
* <ul>
|
||||
* <li>{@link ExceptionHandlerExceptionResolver}
|
||||
* for handling exceptions through @{@link ExceptionHandler} methods.
|
||||
* <li>{@link ResponseStatusExceptionResolver}
|
||||
* for exceptions annotated with @{@link ResponseStatus}.
|
||||
* <li>{@link DefaultHandlerExceptionResolver}
|
||||
* for resolving known Spring exception types
|
||||
* <li>{@link ExceptionHandlerExceptionResolver}
|
||||
* for handling exceptions through @{@link ExceptionHandler} methods.
|
||||
* <li>{@link ResponseStatusExceptionResolver}
|
||||
* for exceptions annotated with @{@link ResponseStatus}.
|
||||
* <li>{@link DefaultHandlerExceptionResolver}
|
||||
* for resolving known Spring exception types
|
||||
* </ul>
|
||||
*/
|
||||
protected final void addDefaultHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) {
|
||||
ExceptionHandlerExceptionResolver exceptionHandlerExceptionResolver = new ExceptionHandlerExceptionResolver();
|
||||
exceptionHandlerExceptionResolver.setApplicationContext(this.applicationContext);
|
||||
exceptionHandlerExceptionResolver.setContentNegotiationManager(mvcContentNegotiationManager());
|
||||
exceptionHandlerExceptionResolver.setMessageConverters(getMessageConverters());
|
||||
if (jackson2Present) {
|
||||
@@ -781,14 +780,15 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
|
||||
interceptors.add(new JsonViewResponseBodyAdvice());
|
||||
exceptionHandlerExceptionResolver.setResponseBodyAdvice(interceptors);
|
||||
}
|
||||
exceptionHandlerExceptionResolver.setApplicationContext(this.applicationContext);
|
||||
exceptionHandlerExceptionResolver.afterPropertiesSet();
|
||||
exceptionResolvers.add(exceptionHandlerExceptionResolver);
|
||||
|
||||
ResponseStatusExceptionResolver responseStatusExceptionResolver = new ResponseStatusExceptionResolver();
|
||||
responseStatusExceptionResolver.setMessageSource(this.applicationContext);
|
||||
|
||||
exceptionResolvers.add(exceptionHandlerExceptionResolver);
|
||||
exceptionResolvers.add(responseStatusExceptionResolver);
|
||||
exceptionResolvers.add(new DefaultHandlerExceptionResolver());
|
||||
|
||||
exceptionHandlerExceptionResolver.afterPropertiesSet();
|
||||
exceptionResolvers.add(new DefaultHandlerExceptionResolver());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -84,9 +84,9 @@ public interface WebMvcConfigurer {
|
||||
* suffix registration, path matcher and path helper.
|
||||
* Configured path matcher and path helper instances are shared for:
|
||||
* <ul>
|
||||
* <li>RequestMappings</li>
|
||||
* <li>ViewControllerMappings</li>
|
||||
* <li>ResourcesMappings</li>
|
||||
* <li>RequestMappings</li>
|
||||
* <li>ViewControllerMappings</li>
|
||||
* <li>ResourcesMappings</li>
|
||||
* </ul>
|
||||
* @since 4.0.3
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,72 +25,64 @@ import org.springframework.web.servlet.support.WebContentGenerator;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
|
||||
/**
|
||||
* <p>Convenient superclass for controller implementations, using the Template
|
||||
* Method design pattern.</p>
|
||||
*
|
||||
* <p>As stated in the {@link Controller Controller}
|
||||
* interface, a lot of functionality is already provided by certain abstract
|
||||
* base controllers. The AbstractController is one of the most important
|
||||
* abstract base controller providing basic features such as the generation
|
||||
* of caching headers and the enabling or disabling of
|
||||
* supported methods (GET/POST).</p>
|
||||
* <p>Convenient superclass for controller implementations, using the Template Method
|
||||
* design pattern.
|
||||
*
|
||||
* <p><b><a name="workflow">Workflow
|
||||
* (<a href="Controller.html#workflow">and that defined by interface</a>):</b><br>
|
||||
* <ol>
|
||||
* <li>{@link #handleRequest(HttpServletRequest, HttpServletResponse) handleRequest()}
|
||||
* will be called by the DispatcherServlet</li>
|
||||
* <li>Inspection of supported methods (ServletException if request method
|
||||
* is not support)</li>
|
||||
* <li>If session is required, try to get it (ServletException if not found)</li>
|
||||
* <li>Set caching headers if needed according to the cacheSeconds property</li>
|
||||
* <li>Call abstract method {@link #handleRequestInternal(HttpServletRequest, HttpServletResponse) handleRequestInternal()}
|
||||
* (optionally synchronizing around the call on the HttpSession),
|
||||
* which should be implemented by extending classes to provide actual
|
||||
* functionality to return {@link org.springframework.web.servlet.ModelAndView ModelAndView} objects.</li>
|
||||
* <li>{@link #handleRequest(HttpServletRequest, HttpServletResponse) handleRequest()}
|
||||
* will be called by the DispatcherServlet</li>
|
||||
* <li>Inspection of supported methods (ServletException if request method
|
||||
* is not support)</li>
|
||||
* <li>If session is required, try to get it (ServletException if not found)</li>
|
||||
* <li>Set caching headers if needed according to the cacheSeconds property</li>
|
||||
* <li>Call abstract method {@link #handleRequestInternal(HttpServletRequest, HttpServletResponse) handleRequestInternal()}
|
||||
* (optionally synchronizing around the call on the HttpSession),
|
||||
* which should be implemented by extending classes to provide actual
|
||||
* functionality to return {@link org.springframework.web.servlet.ModelAndView ModelAndView} objects.</li>
|
||||
* </ol>
|
||||
* </p>
|
||||
*
|
||||
* <p><b><a name="config">Exposed configuration properties</a>
|
||||
* (<a href="Controller.html#config">and those defined by interface</a>):</b><br>
|
||||
* <table border="1">
|
||||
* <tr>
|
||||
* <td><b>name</b></th>
|
||||
* <td><b>default</b></td>
|
||||
* <td><b>description</b></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>supportedMethods</td>
|
||||
* <td>GET,POST</td>
|
||||
* <td>comma-separated (CSV) list of methods supported by this controller,
|
||||
* such as GET, POST and PUT</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>requireSession</td>
|
||||
* <td>false</td>
|
||||
* <td>whether a session should be required for requests to be able to
|
||||
* be handled by this controller. This ensures that derived controller
|
||||
* can - without fear of null pointers - call request.getSession() to
|
||||
* retrieve a session. If no session can be found while processing
|
||||
* the request, a ServletException will be thrown</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>cacheSeconds</td>
|
||||
* <td>-1</td>
|
||||
* <td>indicates the amount of seconds to include in the cache header
|
||||
* for the response following on this request. 0 (zero) will include
|
||||
* headers for no caching at all, -1 (the default) will not generate
|
||||
* <i>any headers</i> and any positive number will generate headers
|
||||
* that state the amount indicated as seconds to cache the content</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>synchronizeOnSession</td>
|
||||
* <td>false</td>
|
||||
* <td>whether the call to {@code handleRequestInternal} should be
|
||||
* synchronized around the HttpSession, to serialize invocations
|
||||
* from the same client. No effect if there is no HttpSession.
|
||||
* </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>name</b></th>
|
||||
* <td><b>default</b></td>
|
||||
* <td><b>description</b></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>supportedMethods</td>
|
||||
* <td>GET,POST</td>
|
||||
* <td>comma-separated (CSV) list of methods supported by this controller,
|
||||
* such as GET, POST and PUT</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>requireSession</td>
|
||||
* <td>false</td>
|
||||
* <td>whether a session should be required for requests to be able to
|
||||
* be handled by this controller. This ensures that derived controller
|
||||
* can - without fear of null pointers - call request.getSession() to
|
||||
* retrieve a session. If no session can be found while processing
|
||||
* the request, a ServletException will be thrown</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>cacheSeconds</td>
|
||||
* <td>-1</td>
|
||||
* <td>indicates the amount of seconds to include in the cache header
|
||||
* for the response following on this request. 0 (zero) will include
|
||||
* headers for no caching at all, -1 (the default) will not generate
|
||||
* <i>any headers</i> and any positive number will generate headers
|
||||
* that state the amount indicated as seconds to cache the content</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>synchronizeOnSession</td>
|
||||
* <td>false</td>
|
||||
* <td>whether the call to {@code handleRequestInternal} should be
|
||||
* synchronized around the HttpSession, to serialize invocations
|
||||
* from the same client. No effect if there is no HttpSession.
|
||||
* </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* @author Rod Johnson
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,13 +30,12 @@ import org.springframework.web.servlet.HandlerMapping;
|
||||
* <p>Can optionally prepend a {@link #setPrefix prefix} and/or append a
|
||||
* {@link #setSuffix suffix} to build the viewname from the URL filename.
|
||||
*
|
||||
* <p>Find below some examples:
|
||||
*
|
||||
* <p>Find some examples below:
|
||||
* <ol>
|
||||
* <li>{@code "/index" -> "index"}</li>
|
||||
* <li>{@code "/index.html" -> "index"}</li>
|
||||
* <li>{@code "/index.html"} + prefix {@code "pre_"} and suffix {@code "_suf" -> "pre_index_suf"}</li>
|
||||
* <li>{@code "/products/view.html" -> "products/view"}</li>
|
||||
* <li>{@code "/index" -> "index"}</li>
|
||||
* <li>{@code "/index.html" -> "index"}</li>
|
||||
* <li>{@code "/index.html"} + prefix {@code "pre_"} and suffix {@code "_suf" -> "pre_index_suf"}</li>
|
||||
* <li>{@code "/products/view.html" -> "products/view"}</li>
|
||||
* </ol>
|
||||
*
|
||||
* <p>Thanks to David Barri for suggesting prefix/suffix support!
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.servlet.resource;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
@@ -11,10 +27,11 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Abstract base class for {@link VersionStrategy} implementations.
|
||||
* Supports versions as:
|
||||
*
|
||||
* <p>Supports versions as:
|
||||
* <ul>
|
||||
* <li>prefix in the request path, like "version/static/myresource.js"
|
||||
* <li>file name suffix in the request path, like "static/myresource-version.js"
|
||||
* <li>prefix in the request path, like "version/static/myresource.js"
|
||||
* <li>file name suffix in the request path, like "static/myresource-version.js"
|
||||
* </ul>
|
||||
*
|
||||
* <p>Note: This base class does <i>not</i> provide support for generating the
|
||||
@@ -32,7 +49,7 @@ public abstract class AbstractVersionStrategy implements VersionStrategy {
|
||||
|
||||
|
||||
protected AbstractVersionStrategy(VersionPathStrategy pathStrategy) {
|
||||
Assert.notNull(pathStrategy, "'pathStrategy' is required");
|
||||
Assert.notNull(pathStrategy, "VersionPathStrategy is required");
|
||||
this.pathStrategy = pathStrategy;
|
||||
}
|
||||
|
||||
@@ -66,9 +83,8 @@ public abstract class AbstractVersionStrategy implements VersionStrategy {
|
||||
|
||||
private final String prefix;
|
||||
|
||||
|
||||
public PrefixVersionPathStrategy(String version) {
|
||||
Assert.hasText(version, "'version' is required and must not be empty");
|
||||
Assert.hasText(version, "'version' must not be empty");
|
||||
this.prefix = version;
|
||||
}
|
||||
|
||||
@@ -86,9 +102,9 @@ public abstract class AbstractVersionStrategy implements VersionStrategy {
|
||||
public String addVersion(String path, String version) {
|
||||
return (this.prefix.endsWith("/") || path.startsWith("/") ? this.prefix + path : this.prefix + "/" + path);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* File name-based {@code VersionPathStrategy},
|
||||
* e.g. {@code "path/foo-{version}.css"}.
|
||||
@@ -97,7 +113,6 @@ public abstract class AbstractVersionStrategy implements VersionStrategy {
|
||||
|
||||
private static final Pattern pattern = Pattern.compile("-(\\S*)\\.");
|
||||
|
||||
|
||||
@Override
|
||||
public String extractVersion(String requestPath) {
|
||||
Matcher matcher = pattern.matcher(requestPath);
|
||||
|
||||
@@ -40,22 +40,21 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* <p>This transformer:
|
||||
* <ul>
|
||||
* <li>modifies links to match the public URL paths that should be exposed to clients, using
|
||||
* configured {@code ResourceResolver} strategies
|
||||
* <li>appends a comment in the manifest, containing a Hash (e.g. "# Hash: 9de0f09ed7caf84e885f1f0f11c7e326"),
|
||||
* thus changing the content of the manifest in order to trigger an appcache reload in the browser.
|
||||
* <li>modifies links to match the public URL paths that should be exposed to clients,
|
||||
* using configured {@code ResourceResolver} strategies
|
||||
* <li>appends a comment in the manifest, containing a Hash (e.g. "# Hash: 9de0f09ed7caf84e885f1f0f11c7e326"),
|
||||
* thus changing the content of the manifest in order to trigger an appcache reload in the browser.
|
||||
* </ul>
|
||||
*
|
||||
* All files that have the ".manifest" file extension, or the extension given in the constructor, will be transformed
|
||||
* by this class.
|
||||
* All files that have the ".manifest" file extension, or the extension given in the constructor,
|
||||
* will be transformed by this class.
|
||||
*
|
||||
* <p>This hash is computed using the content of the appcache manifest and the content of the linked resources; so
|
||||
* changing a resource linked in the manifest or the manifest itself should invalidate the browser cache.
|
||||
* <p>This hash is computed using the content of the appcache manifest and the content of the linked resources;
|
||||
* so changing a resource linked in the manifest or the manifest itself should invalidate the browser cache.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/offline.html#offline">HTML5 offline
|
||||
* applications spec</a>
|
||||
* @since 4.1
|
||||
* @see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/offline.html#offline">HTML5 offline applications spec</a>
|
||||
*/
|
||||
public class AppCacheManifestTransformer extends ResourceTransformerSupport {
|
||||
|
||||
@@ -65,6 +64,7 @@ public class AppCacheManifestTransformer extends ResourceTransformerSupport {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(AppCacheManifestTransformer.class);
|
||||
|
||||
|
||||
private final Map<String, SectionTransformer> sectionTransformers = new HashMap<String, SectionTransformer>();
|
||||
|
||||
private final String fileExtension;
|
||||
@@ -93,7 +93,9 @@ public class AppCacheManifestTransformer extends ResourceTransformerSupport {
|
||||
|
||||
|
||||
@Override
|
||||
public Resource transform(HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain) throws IOException {
|
||||
public Resource transform(HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain)
|
||||
throws IOException {
|
||||
|
||||
resource = transformerChain.transform(request, resource);
|
||||
|
||||
String filename = resource.getFilename();
|
||||
@@ -128,7 +130,8 @@ public class AppCacheManifestTransformer extends ResourceTransformerSupport {
|
||||
hashBuilder.appendString(line);
|
||||
}
|
||||
else {
|
||||
contentWriter.write(currentTransformer.transform(line, hashBuilder, resource, transformerChain, request) + "\n");
|
||||
contentWriter.write(
|
||||
currentTransformer.transform(line, hashBuilder, resource, transformerChain, request) + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -275,7 +275,7 @@ public class TransportHandlingSockJsService extends AbstractSockJsService implem
|
||||
|
||||
@Override
|
||||
protected boolean validateRequest(String serverId, String sessionId, String transport) {
|
||||
if (!this.getAllowedOrigins().contains("*") && !TransportType.fromValue(transport).supportsOrigin()) {
|
||||
if (!getAllowedOrigins().contains("*") && !TransportType.fromValue(transport).supportsOrigin()) {
|
||||
logger.error("Origin check has been enabled, but this transport does not support it");
|
||||
return false;
|
||||
}
|
||||
@@ -298,7 +298,6 @@ public class TransportHandlingSockJsService extends AbstractSockJsService implem
|
||||
}
|
||||
|
||||
private void scheduleSessionTask() {
|
||||
|
||||
synchronized (this.sessions) {
|
||||
if (this.sessionCleanupTask != null) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user