diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparator.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparator.java index 20b34371a8..8177fc9828 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparator.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparator.java @@ -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; * *

Given two pieces of advice, {@code a} and {@code b}: *

* *

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 { private static final int HIGHER_PRECEDENCE = -1; + private static final int SAME_PRECEDENCE = 0; + private static final int LOWER_PRECEDENCE = 1; + private final Comparator advisorComparator; diff --git a/spring-context/src/main/java/org/springframework/context/annotation/Configuration.java b/spring-context/src/main/java/org/springframework/context/annotation/Configuration.java index 6789a6c49d..4b81239af9 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/Configuration.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/Configuration.java @@ -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; * *

Constraints when authoring {@code @Configuration} classes

* * * @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. - * *

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 */ diff --git a/spring-core/src/main/java/org/springframework/util/ClassUtils.java b/spring-core/src/main/java/org/springframework/util/ClassUtils.java index 282c020ca8..f0c9e28ce9 100644 --- a/spring-core/src/main/java/org/springframework/util/ClassUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ClassUtils.java @@ -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); } /** diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelExpression.java b/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelExpression.java index 4be3506bc0..237e79d595 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelExpression.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelExpression.java @@ -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() { diff --git a/spring-jms/src/main/java/org/springframework/jms/connection/DelegatingConnectionFactory.java b/spring-jms/src/main/java/org/springframework/jms/connection/DelegatingConnectionFactory.java index 85a1a589de..0b81da699f 100644 --- a/spring-jms/src/main/java/org/springframework/jms/connection/DelegatingConnectionFactory.java +++ b/spring-jms/src/main/java/org/springframework/jms/connection/DelegatingConnectionFactory.java @@ -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. *

Default is "false", simply closing Connections. * @see ConnectionFactoryUtils#releaseConnection diff --git a/spring-jms/src/test/java/org/springframework/jms/core/JmsTemplateTests.java b/spring-jms/src/test/java/org/springframework/jms/core/JmsTemplateTests.java index 2a5dbf95e1..d754324e4d 100644 --- a/spring-jms/src/test/java/org/springframework/jms/core/JmsTemplateTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/core/JmsTemplateTests.java @@ -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"); diff --git a/spring-jms/src/test/java/org/springframework/jms/core/JmsTemplateTransactedTests.java b/spring-jms/src/test/java/org/springframework/jms/core/JmsTemplateTransactedTests.java index 27da72ac8d..eb2d0cc87c 100644 --- a/spring-jms/src/test/java/org/springframework/jms/core/JmsTemplateTransactedTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/core/JmsTemplateTransactedTests.java @@ -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 diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/DestinationPatternsMessageCondition.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/DestinationPatternsMessageCondition.java index c1d5b87f1c..919aa70e62 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/DestinationPatternsMessageCondition.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/DestinationPatternsMessageCondition.java @@ -38,8 +38,7 @@ import org.springframework.util.StringUtils; * @author Rossen Stoyanchev * @since 4.0 */ -public final class DestinationPatternsMessageCondition - extends AbstractMessageCondition { +public class DestinationPatternsMessageCondition extends AbstractMessageCondition { public static final String LOOKUP_DESTINATION_HEADER = "lookupDestination"; @@ -68,12 +67,13 @@ public final class DestinationPatternsMessageCondition } private DestinationPatternsMessageCondition(Collection 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 asList(String... patterns) { - return patterns != null ? Arrays.asList(patterns) : Collections.emptyList(); + return (patterns != null ? Arrays.asList(patterns) : Collections.emptyList()); } private static Set prependLeadingSlash(Collection patterns, PathMatcher pathMatcher) { @@ -93,6 +93,7 @@ public final class DestinationPatternsMessageCondition return result; } + public Set 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: *

*/ @Override diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java index d40b6e4a40..259b8ca024 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java @@ -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. - *

- * {@link #clientInboundChannel()} and {@link #clientOutboundChannel()} deliver messages - * to and from remote clients to several message handlers such as + * + *

{@link #clientInboundChannel()} and {@link #clientOutboundChannel()} deliver + * messages to and from remote clients to several message handlers such as *

* 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. - *

- * Sub-classes are responsible for the part of the configuration that feed messages + * + *

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 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: + *

In order, this method tries to get a Validator instance: *

*/ 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) { } - }; + } } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/support/ImmutableMessageChannelInterceptor.java b/spring-messaging/src/main/java/org/springframework/messaging/support/ImmutableMessageChannelInterceptor.java index c2921857fd..02b21bd267 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/support/ImmutableMessageChannelInterceptor.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/support/ImmutableMessageChannelInterceptor.java @@ -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); diff --git a/spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/LocalSessionFactoryBuilder.java b/spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/LocalSessionFactoryBuilder.java index 944ea4a80a..dcbfbdb51c 100644 --- a/spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/LocalSessionFactoryBuilder.java +++ b/spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/LocalSessionFactoryBuilder.java @@ -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; diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/JpaDialect.java b/spring-orm/src/main/java/org/springframework/orm/jpa/JpaDialect.java index 11529655b6..51382cfd73 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/JpaDialect.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/JpaDialect.java @@ -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. * - *

Also allows for the provision of value-added methods for portable yet - * more capable EntityManager and EntityManagerFactory subinterfaces offered - * by Spring. - * - *

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. + *

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 diff --git a/spring-test/src/main/java/org/springframework/test/annotation/DirtiesContext.java b/spring-test/src/main/java/org/springframework/test/annotation/DirtiesContext.java index 564f582edf..a7f035097a 100644 --- a/spring-test/src/main/java/org/springframework/test/annotation/DirtiesContext.java +++ b/spring-test/src/main/java/org/springframework/test/annotation/DirtiesContext.java @@ -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 dirty and should be closed: * *

* *

Use this annotation if a test has modified the context — for example, diff --git a/spring-test/src/main/java/org/springframework/test/context/junit4/AbstractJUnit4SpringContextTests.java b/spring-test/src/main/java/org/springframework/test/context/junit4/AbstractJUnit4SpringContextTests.java index 9c5f0aefb4..6524b65db4 100644 --- a/spring-test/src/main/java/org/springframework/test/context/junit4/AbstractJUnit4SpringContextTests.java +++ b/spring-test/src/main/java/org/springframework/test/context/junit4/AbstractJUnit4SpringContextTests.java @@ -49,9 +49,9 @@ import org.springframework.test.context.web.ServletTestExecutionListener; * TestExecutionListeners} are configured by default: * *

* *

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 { /** diff --git a/spring-test/src/main/java/org/springframework/test/context/junit4/AbstractTransactionalJUnit4SpringContextTests.java b/spring-test/src/main/java/org/springframework/test/context/junit4/AbstractTransactionalJUnit4SpringContextTests.java index 5b55e3384c..6299311b13 100644 --- a/spring-test/src/main/java/org/springframework/test/context/junit4/AbstractTransactionalJUnit4SpringContextTests.java +++ b/spring-test/src/main/java/org/springframework/test/context/junit4/AbstractTransactionalJUnit4SpringContextTests.java @@ -53,11 +53,11 @@ import org.springframework.transaction.annotation.Transactional; * TestExecutionListeners} are configured by default: * *

* *

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 { diff --git a/spring-test/src/main/java/org/springframework/test/context/testng/AbstractTestNGSpringContextTests.java b/spring-test/src/main/java/org/springframework/test/context/testng/AbstractTestNGSpringContextTests.java index 32b4b52ff4..9becd20bd0 100644 --- a/spring-test/src/main/java/org/springframework/test/context/testng/AbstractTestNGSpringContextTests.java +++ b/spring-test/src/main/java/org/springframework/test/context/testng/AbstractTestNGSpringContextTests.java @@ -63,9 +63,9 @@ import org.springframework.test.context.web.ServletTestExecutionListener; * TestExecutionListeners} are configured by default: * *

* * @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 */ diff --git a/spring-test/src/main/java/org/springframework/test/context/testng/AbstractTransactionalTestNGSpringContextTests.java b/spring-test/src/main/java/org/springframework/test/context/testng/AbstractTransactionalTestNGSpringContextTests.java index ccaf0547d1..45c9e7186c 100644 --- a/spring-test/src/main/java/org/springframework/test/context/testng/AbstractTransactionalTestNGSpringContextTests.java +++ b/spring-test/src/main/java/org/springframework/test/context/testng/AbstractTransactionalTestNGSpringContextTests.java @@ -52,11 +52,11 @@ import org.springframework.transaction.annotation.Transactional; * TestExecutionListeners} are configured by default: * * * * @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 { diff --git a/spring-web/src/main/java/org/springframework/web/util/Log4jWebConfigurer.java b/spring-web/src/main/java/org/springframework/web/util/Log4jWebConfigurer.java index 4861703930..5fe7a6ae09 100644 --- a/spring-web/src/main/java/org/springframework/web/util/Log4jWebConfigurer.java +++ b/spring-web/src/main/java/org/springframework/web/util/Log4jWebConfigurer.java @@ -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); } diff --git a/spring-webmvc-portlet/src/main/java/org/springframework/web/portlet/HandlerInterceptor.java b/spring-webmvc-portlet/src/main/java/org/springframework/web/portlet/HandlerInterceptor.java index d0c0a311f0..af442a75d5 100644 --- a/spring-webmvc-portlet/src/main/java/org/springframework/web/portlet/HandlerInterceptor.java +++ b/spring-webmvc-portlet/src/main/java/org/springframework/web/portlet/HandlerInterceptor.java @@ -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; * *

Action Request:

*

    - *
  1. {@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.
  2. - *
  3. {@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
  4. - *
  5. The target handler handles the action request (via - * {@link HandlerAdapter#handleAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse, Object) HandlerAdapter.handleAction(..)})
  6. - *
  7. {@link HandlerInterceptor#afterActionCompletion(javax.portlet.ActionRequest, javax.portlet.ActionResponse, Object, Exception) afterActionCompletion(..)} - * is called
  8. + *
  9. {@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.
  10. + *
  11. {@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.
  12. + *
  13. The target handler handles the action request (via + * {@link HandlerAdapter#handleAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse, Object) HandlerAdapter.handleAction(..)}).
  14. + *
  15. {@link HandlerInterceptor#afterActionCompletion(javax.portlet.ActionRequest, javax.portlet.ActionResponse, Object, Exception) afterActionCompletion(..)} + * is called.
  16. *
* *

Render Request:

*

    - *
  1. {@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.
  2. - *
  3. {@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
  4. - *
  5. The target handler handles the render request (via - * {@link HandlerAdapter#handleRender(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object) HandlerAdapter.handleRender(..)})
  6. - *
  7. {@link HandlerInterceptor#postHandleRender(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object, ModelAndView) postHandleRender(..)} - * is called
  8. - *
  9. If the {@code HandlerAdapter} returned a {@code ModelAndView}, - * then {@code DispatcherPortlet} renders the view accordingly - *
  10. {@link HandlerInterceptor#afterRenderCompletion(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object, Exception) afterRenderCompletion(..)} - * is called
  11. + *
  12. {@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.
  13. + *
  14. {@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.
  15. + *
  16. The target handler handles the render request (via + * {@link HandlerAdapter#handleRender(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object) HandlerAdapter.handleRender(..)}).
  17. + *
  18. {@link HandlerInterceptor#postHandleRender(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object, ModelAndView) postHandleRender(..)} + * is called.
  19. + *
  20. If the {@code HandlerAdapter} returned a {@code ModelAndView}, then + * {@code DispatcherPortlet} renders the view accordingly. + *
  21. {@link HandlerInterceptor#afterRenderCompletion(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object, Exception) afterRenderCompletion(..)} + * is called.
  22. *
* * @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. *

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; } diff --git a/spring-webmvc-portlet/src/main/java/org/springframework/web/portlet/mvc/AbstractController.java b/spring-webmvc-portlet/src/main/java/org/springframework/web/portlet/mvc/AbstractController.java index de00d6f077..cc703aee27 100644 --- a/spring-webmvc-portlet/src/main/java/org/springframework/web/portlet/mvc/AbstractController.java +++ b/spring-webmvc-portlet/src/main/java/org/springframework/web/portlet/mvc/AbstractController.java @@ -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; *

Workflow * (and that defined by interface):
*

    - *
  1. If this is an action request, {@link #handleActionRequest handleActionRequest} - * will be called by the DispatcherPortlet once to perform the action defined by this - * controller.
  2. - *
  3. If a session is required, try to get it (PortletException if not found).
  4. - *
  5. 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.
  6. - *
  7. 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.
  8. - *
  9. If a session is required, try to get it (PortletException if none found).
  10. - *
  11. It will control caching as defined by the cacheSeconds property.
  12. - *
  13. 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.
  14. + *
  15. If this is an action request, {@link #handleActionRequest handleActionRequest} + * will be called by the DispatcherPortlet once to perform the action defined by this + * controller.
  16. + *
  17. If a session is required, try to get it (PortletException if not found).
  18. + *
  19. 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.
  20. + *
  21. 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.
  22. + *
  23. If a session is required, try to get it (PortletException if none found).
  24. + *
  25. It will control caching as defined by the cacheSeconds property.
  26. + *
  27. 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.
  28. *
* *

Exposed configuration properties * (and those defined by interface):
* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * *
name - * defaultdescription
requireSessionfalsewhether 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
synchronizeOnSessionfalsewhether 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. - *
cacheSeconds-1indicates 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
renderWhenMinimizedfalsewhether 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
name + * defaultdescription
requireSessionfalsewhether 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
synchronizeOnSessionfalsewhether 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. + *
cacheSeconds-1indicates 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
renderWhenMinimizedfalsewhether 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
* *

TIP: The controller mapping will be run twice by the PortletDispatcher for diff --git a/spring-webmvc-portlet/src/main/java/org/springframework/web/portlet/mvc/ParameterizableViewController.java b/spring-webmvc-portlet/src/main/java/org/springframework/web/portlet/mvc/ParameterizableViewController.java index ab4818effa..7dc8640578 100644 --- a/spring-webmvc-portlet/src/main/java/org/springframework/web/portlet/mvc/ParameterizableViewController.java +++ b/spring-webmvc-portlet/src/main/java/org/springframework/web/portlet/mvc/ParameterizableViewController.java @@ -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; /** - *

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.

+ * 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. * *

Workflow - * (and that defined by superclass):
+ * (and that defined by superclass): *

    - *
  1. Render request is received by the controller
  2. - *
  3. call to {@link #handleRenderRequestInternal handleRenderRequestInternal} which - * just returns the view, named by the configuration property - * {@code viewName}. Nothing more, nothing less
  4. + *
  5. Render request is received by the controller
  6. + *
  7. call to {@link #handleRenderRequestInternal handleRenderRequestInternal} which + * just returns the view, named by the configuration property {@code viewName}.
  8. *
- *

* - *

This controller does not handle action requests.

+ *

This controller does not handle action requests. * *

Exposed configuration properties - * (and those defined by superclass):
+ * (and those defined by superclass): * - * - * - * - * - * - * - * - * - * - * + * + * + * + * + * + * + * + * + * + * *
namedefaultdescription
viewNamenullthe name of the view the viewResolver will use to forward to - * (if this property is not set, an exception will be thrown during - * initialization)
namedefaultdescription
viewNamenullthe name of the view the viewResolver will use to forward to (if this property + * is not set, an exception will be thrown during initialization)
- *

* * @author John A. Lewis * @since 2.0 diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerInterceptor.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerInterceptor.java index 3ed6dbf357..29c2721a6c 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerInterceptor.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerInterceptor.java @@ -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; } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java index dd10016099..9bafb340f9 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java @@ -84,10 +84,10 @@ import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolv * *

This class registers the following {@link HandlerMapping}s:

* * *

Note: Additional HandlerMappings may be registered @@ -96,30 +96,30 @@ import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolv * *

This class registers the following {@link HandlerAdapter}s: *

* *

This class registers the following {@link HandlerExceptionResolver}s: *

* *

This class registers an {@link org.springframework.util.AntPathMatcher} * and a {@link org.springframework.web.util.UrlPathHelper} to be used by: *

* 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: * * * @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 element", parserContext.extractSource(parentElement)); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/PathMatchConfigurer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/PathMatchConfigurer.java index dbede71a53..8203ea201c 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/PathMatchConfigurer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/PathMatchConfigurer.java @@ -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: + * + *

Configured path matcher and path helper instances are shared for: *

* * @author Brian Clozel diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java index 6886f6e00c..1aa538baac 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java @@ -102,45 +102,45 @@ import org.springframework.web.util.UrlPathHelper; * *

This class registers the following {@link HandlerMapping}s:

* * *

Registers these {@link HandlerAdapter}s: *

* *

Registers a {@link HandlerExceptionResolverComposite} with this chain of * exception resolvers: *

* *

Registers an {@link AntPathMatcher} and a {@link UrlPathHelper} * to be used by: *

* 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: * * * @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: * */ @Bean @@ -763,17 +763,16 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv * A method available to subclasses for adding default {@link HandlerExceptionResolver}s. *

Adds the following exception resolvers: *

*/ protected final void addDefaultHandlerExceptionResolvers(List 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()); } /** diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurer.java index 3c4c120104..68e8ebb8b3 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurer.java @@ -84,9 +84,9 @@ public interface WebMvcConfigurer { * suffix registration, path matcher and path helper. * Configured path matcher and path helper instances are shared for: * * @since 4.0.3 */ diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/AbstractController.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/AbstractController.java index ec2c81639b..772953ffee 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/AbstractController.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/AbstractController.java @@ -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; /** - *

Convenient superclass for controller implementations, using the Template - * Method design pattern.

- * - *

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).

+ *

Convenient superclass for controller implementations, using the Template Method + * design pattern. * *

Workflow * (and that defined by interface):
*

    - *
  1. {@link #handleRequest(HttpServletRequest, HttpServletResponse) handleRequest()} - * will be called by the DispatcherServlet
  2. - *
  3. Inspection of supported methods (ServletException if request method - * is not support)
  4. - *
  5. If session is required, try to get it (ServletException if not found)
  6. - *
  7. Set caching headers if needed according to the cacheSeconds property
  8. - *
  9. 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.
  10. + *
  11. {@link #handleRequest(HttpServletRequest, HttpServletResponse) handleRequest()} + * will be called by the DispatcherServlet
  12. + *
  13. Inspection of supported methods (ServletException if request method + * is not support)
  14. + *
  15. If session is required, try to get it (ServletException if not found)
  16. + *
  17. Set caching headers if needed according to the cacheSeconds property
  18. + *
  19. 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.
  20. *
- *

* *

Exposed configuration properties * (and those defined by interface):
* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * *
name - * defaultdescription
supportedMethodsGET,POSTcomma-separated (CSV) list of methods supported by this controller, - * such as GET, POST and PUT
requireSessionfalsewhether 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
cacheSeconds-1indicates 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 - * any headers and any positive number will generate headers - * that state the amount indicated as seconds to cache the content
synchronizeOnSessionfalsewhether 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. - *
name + * defaultdescription
supportedMethodsGET,POSTcomma-separated (CSV) list of methods supported by this controller, + * such as GET, POST and PUT
requireSessionfalsewhether 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
cacheSeconds-1indicates 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 + * any headers and any positive number will generate headers + * that state the amount indicated as seconds to cache the content
synchronizeOnSessionfalsewhether 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. + *
* * @author Rod Johnson diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/UrlFilenameViewController.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/UrlFilenameViewController.java index cdf0a54e91..d244bf543d 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/UrlFilenameViewController.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/UrlFilenameViewController.java @@ -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; *

Can optionally prepend a {@link #setPrefix prefix} and/or append a * {@link #setSuffix suffix} to build the viewname from the URL filename. * - *

Find below some examples: - * + *

Find some examples below: *

    - *
  1. {@code "/index" -> "index"}
  2. - *
  3. {@code "/index.html" -> "index"}
  4. - *
  5. {@code "/index.html"} + prefix {@code "pre_"} and suffix {@code "_suf" -> "pre_index_suf"}
  6. - *
  7. {@code "/products/view.html" -> "products/view"}
  8. + *
  9. {@code "/index" -> "index"}
  10. + *
  11. {@code "/index.html" -> "index"}
  12. + *
  13. {@code "/index.html"} + prefix {@code "pre_"} and suffix {@code "_suf" -> "pre_index_suf"}
  14. + *
  15. {@code "/products/view.html" -> "products/view"}
  16. *
* *

Thanks to David Barri for suggesting prefix/suffix support! diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AbstractVersionStrategy.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AbstractVersionStrategy.java index 17d72700e8..ebd4e73c57 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AbstractVersionStrategy.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AbstractVersionStrategy.java @@ -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: + * + *

Supports versions as: *

* *

Note: This base class does not 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); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java index cf86d40631..b4628118bf 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java @@ -40,22 +40,21 @@ import org.springframework.util.StringUtils; * *

This transformer: *

* - * 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. * - *

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. + *

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 HTML5 offline - * applications spec * @since 4.1 + * @see HTML5 offline applications spec */ 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 sectionTransformers = new HashMap(); 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"); } } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandlingSockJsService.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandlingSockJsService.java index 7037bedbf8..60ed1c0b45 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandlingSockJsService.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandlingSockJsService.java @@ -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;