From d628025f1356c663a0ecf951c6f57c31ca9a43eb Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 2 Apr 2014 21:28:42 +0200 Subject: [PATCH] Polishing Issue: SPR-11262 --- .../quartz/LocalTaskExecutorThreadPool.java | 4 ++-- .../scheduling/quartz/SchedulerAccessor.java | 6 ------ .../quartz/SimpleTriggerFactoryBean.java | 2 +- ...AllEncompassingFormHttpMessageConverter.java | 3 ++- .../web/client/RestTemplate.java | 1 + .../AnnotationDrivenBeanDefinitionParser.java | 14 ++++++-------- .../annotation/WebMvcConfigurationSupport.java | 17 +++++++++-------- .../view/json/MappingJackson2JsonView.java | 4 ++-- 8 files changed, 23 insertions(+), 28 deletions(-) diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/LocalTaskExecutorThreadPool.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/LocalTaskExecutorThreadPool.java index ec3ccac53fd..03117880b40 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/LocalTaskExecutorThreadPool.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/LocalTaskExecutorThreadPool.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. @@ -87,7 +87,7 @@ public class LocalTaskExecutorThreadPool implements ThreadPool { @Override public int blockForAvailableThreads() { - // The present implementation always returns 1, making Quartz (1.6) + // The present implementation always returns 1, making Quartz // always schedule any tasks that it feels like scheduling. // This could be made smarter for specific TaskExecutors, // for example calling {@code getMaximumPoolSize() - getActiveCount()} diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerAccessor.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerAccessor.java index a86a4b054a7..e993a74e31b 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerAccessor.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerAccessor.java @@ -151,8 +151,6 @@ public abstract class SchedulerAccessor implements ResourceLoaderAware { * in combination with the Trigger. * @see #setTriggers * @see org.quartz.JobDetail - * @see JobDetailBean - * @see JobDetailAwareTrigger */ public void setJobDetails(JobDetail... jobDetails) { // Use modifiable ArrayList here, to allow for further adding of @@ -180,15 +178,11 @@ public abstract class SchedulerAccessor implements ResourceLoaderAware { * "jobDetails" property of this FactoryBean. * @see #setJobDetails * @see org.quartz.JobDetail - * @see JobDetailAwareTrigger - * @see CronTriggerBean - * @see SimpleTriggerBean */ public void setTriggers(Trigger... triggers) { this.triggers = Arrays.asList(triggers); } - /** * Specify Quartz SchedulerListeners to be registered with the Scheduler. */ diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleTriggerFactoryBean.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleTriggerFactoryBean.java index 2215ac7e667..53399b821e9 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleTriggerFactoryBean.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleTriggerFactoryBean.java @@ -245,7 +245,7 @@ public class SimpleTriggerFactoryBean implements FactoryBean, Bea sti.setRepeatCount(this.repeatCount); sti.setPriority(this.priority); sti.setMisfireInstruction(this.misfireInstruction); - cti.setDescription(this.description); + sti.setDescription(this.description); this.simpleTrigger = sti; */ diff --git a/spring-web/src/main/java/org/springframework/http/converter/support/AllEncompassingFormHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/support/AllEncompassingFormHttpMessageConverter.java index ec1173d73fc..819104f8f11 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/support/AllEncompassingFormHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/support/AllEncompassingFormHttpMessageConverter.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. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.http.converter.support; import javax.xml.transform.Source; diff --git a/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java b/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java index 0411c4791cb..a71d11dda63 100644 --- a/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java +++ b/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java @@ -157,6 +157,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat this.messageConverters.add(new ResourceHttpMessageConverter()); this.messageConverters.add(new SourceHttpMessageConverter()); this.messageConverters.add(new AllEncompassingFormHttpMessageConverter()); + if (romePresent) { this.messageConverters.add(new AtomFeedHttpMessageConverter()); this.messageConverters.add(new RssChannelHttpMessageConverter()); 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 ebab71b9238..80dcf322bf4 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 @@ -133,6 +133,9 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { private static final boolean javaxValidationPresent = ClassUtils.isPresent( "javax.validation.Validator", AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); + private static boolean romePresent = + ClassUtils.isPresent("com.sun.syndication.feed.WireFeed", AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); + private static final boolean jaxb2Present = ClassUtils.isPresent("javax.xml.bind.Binder", AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); @@ -144,9 +147,6 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { ClassUtils.isPresent("org.codehaus.jackson.map.ObjectMapper", AnnotationDrivenBeanDefinitionParser.class.getClassLoader()) && ClassUtils.isPresent("org.codehaus.jackson.JsonGenerator", AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); - private static boolean romePresent = - ClassUtils.isPresent("com.sun.syndication.feed.WireFeed", AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); - @Override public BeanDefinition parse(Element element, ParserContext parserContext) { @@ -338,7 +338,6 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { } private void configurePathMatchingProperties(RootBeanDefinition handlerMappingDef, Element element) { - Element pathMatchingElement = DomUtils.getChildElementByTagName(element, "path-matching"); if(pathMatchingElement != null) { if (pathMatchingElement.hasAttribute("suffix-pattern")) { @@ -370,12 +369,12 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { props.put("atom", MediaType.APPLICATION_ATOM_XML_VALUE); props.put("rss", "application/rss+xml"); } - if (jackson2Present || jacksonPresent) { - props.put("json", MediaType.APPLICATION_JSON_VALUE); - } if (jaxb2Present) { props.put("xml", MediaType.APPLICATION_XML_VALUE); } + if (jackson2Present || jacksonPresent) { + props.put("json", MediaType.APPLICATION_JSON_VALUE); + } return props; } @@ -485,7 +484,6 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { if (jaxb2Present) { messageConverters.add(createConverterDefinition(Jaxb2RootElementHttpMessageConverter.class, source)); } - if (jackson2Present) { messageConverters.add(createConverterDefinition(MappingJackson2HttpMessageConverter.class, source)); } 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 706babc0d01..190495aaa1b 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 @@ -20,7 +20,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.xml.transform.Source; @@ -143,6 +142,9 @@ import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolv */ public class WebMvcConfigurationSupport implements ApplicationContextAware, ServletContextAware { + private static boolean romePresent = + ClassUtils.isPresent("com.sun.syndication.feed.WireFeed", WebMvcConfigurationSupport.class.getClassLoader()); + private static final boolean jaxb2Present = ClassUtils.isPresent("javax.xml.bind.Binder", WebMvcConfigurationSupport.class.getClassLoader()); @@ -154,8 +156,6 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv ClassUtils.isPresent("org.codehaus.jackson.map.ObjectMapper", WebMvcConfigurationSupport.class.getClassLoader()) && ClassUtils.isPresent("org.codehaus.jackson.JsonGenerator", WebMvcConfigurationSupport.class.getClassLoader()); - private static boolean romePresent = - ClassUtils.isPresent("com.sun.syndication.feed.WireFeed", WebMvcConfigurationSupport.class.getClassLoader()); private ServletContext servletContext; @@ -225,9 +225,9 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv InterceptorRegistry registry = new InterceptorRegistry(); addInterceptors(registry); registry.addInterceptor(new ConversionServiceExposingInterceptor(mvcConversionService())); - interceptors = registry.getInterceptors(); + this.interceptors = registry.getInterceptors(); } - return interceptors.toArray(); + return this.interceptors.toArray(); } /** @@ -264,12 +264,12 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv map.put("atom", MediaType.APPLICATION_ATOM_XML); map.put("rss", MediaType.valueOf("application/rss+xml")); } - if (jackson2Present || jacksonPresent) { - map.put("json", MediaType.APPLICATION_JSON); - } if (jaxb2Present) { map.put("xml", MediaType.APPLICATION_XML); } + if (jackson2Present || jacksonPresent) { + map.put("json", MediaType.APPLICATION_JSON); + } return map; } @@ -552,6 +552,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv messageConverters.add(new ResourceHttpMessageConverter()); messageConverters.add(new SourceHttpMessageConverter()); messageConverters.add(new AllEncompassingFormHttpMessageConverter()); + if (romePresent) { messageConverters.add(new AtomFeedHttpMessageConverter()); messageConverters.add(new RssChannelHttpMessageConverter()); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.java index 93c9e10698a..a744e4a73c7 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.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. @@ -209,7 +209,7 @@ public class MappingJackson2JsonView extends AbstractView { /** * Set whether to serialize models containing a single attribute as a map or whether to * extract the single value from the model and serialize it directly. - *

The effect of setting this flag is similar to using {@code MappingJacksonHttpMessageConverter} + *

The effect of setting this flag is similar to using {@code MappingJackson2HttpMessageConverter} * with an {@code @ResponseBody} request-handling method. *

Default is {@code false}. */