From 03190950d1150e1833a5d6f5a83b00394958d454 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 10 Feb 2011 22:19:10 +0000 Subject: [PATCH] polishing --- .../cache/annotation/Cacheable.java | 16 +++++++--------- .../concurrent/ConcurrentTaskScheduler.java | 6 +++--- .../concurrent/ThreadPoolTaskScheduler.java | 6 +++--- .../scheduling/config/package-info.java | 9 +++++++++ .../scheduling/support/TaskUtils.java | 8 +++----- .../core/env/AbstractEnvironment.java | 11 +++++------ .../core/env/DefaultEnvironment.java | 9 ++++----- .../core/env/PropertyResolver.java | 4 +--- .../org/springframework/util/ErrorHandler.java | 5 ++++- .../context/support/DefaultWebEnvironment.java | 16 ++++++++-------- 10 files changed, 47 insertions(+), 43 deletions(-) create mode 100644 org.springframework.context/src/main/java/org/springframework/scheduling/config/package-info.java diff --git a/org.springframework.context/src/main/java/org/springframework/cache/annotation/Cacheable.java b/org.springframework.context/src/main/java/org/springframework/cache/annotation/Cacheable.java index eea045111b3..a76f5815f1e 100644 --- a/org.springframework.context/src/main/java/org/springframework/cache/annotation/Cacheable.java +++ b/org.springframework.context/src/main/java/org/springframework/cache/annotation/Cacheable.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2011 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,7 +30,7 @@ import java.lang.annotation.Target; * * @author Costin Leau */ -@Target( { ElementType.METHOD, ElementType.TYPE }) +@Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Inherited @Documented @@ -38,23 +38,21 @@ public @interface Cacheable { /** * Name of the caches in which the update takes place. - *

- * May be used to determine the target cache (or caches), matching the + *

May be used to determine the target cache (or caches), matching the * qualifier value (or the bean name(s)) of (a) specific bean definition. */ String[] value(); /** * Spring Expression Language (SpEL) attribute for computing the key dynamically. - *

- * Default is "" meaning all method parameters are considered as a key. + *

Default is "", meaning all method parameters are considered as a key. */ String key() default ""; /** * Spring Expression Language (SpEL) attribute used for conditioning the method caching. - *

- * Default is "" meaning the method is always cached. + *

Default is "", meaning the method is always cached. */ String condition() default ""; -} \ No newline at end of file + +} diff --git a/org.springframework.context/src/main/java/org/springframework/scheduling/concurrent/ConcurrentTaskScheduler.java b/org.springframework.context/src/main/java/org/springframework/scheduling/concurrent/ConcurrentTaskScheduler.java index bde333356fa..da79d35ade5 100644 --- a/org.springframework.context/src/main/java/org/springframework/scheduling/concurrent/ConcurrentTaskScheduler.java +++ b/org.springframework.context/src/main/java/org/springframework/scheduling/concurrent/ConcurrentTaskScheduler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2011 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. @@ -118,8 +118,8 @@ public class ConcurrentTaskScheduler extends ConcurrentTaskExecutor implements T public ScheduledFuture schedule(Runnable task, Trigger trigger) { try { - ErrorHandler errorHandler = this.errorHandler != null ? - this.errorHandler : TaskUtils.getDefaultErrorHandler(true); + ErrorHandler errorHandler = + (this.errorHandler != null ? this.errorHandler : TaskUtils.getDefaultErrorHandler(true)); return new ReschedulingRunnable(task, trigger, this.scheduledExecutor, errorHandler).schedule(); } catch (RejectedExecutionException ex) { diff --git a/org.springframework.context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolTaskScheduler.java b/org.springframework.context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolTaskScheduler.java index ba49d36e779..fa42583444b 100644 --- a/org.springframework.context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolTaskScheduler.java +++ b/org.springframework.context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolTaskScheduler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2011 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. @@ -159,8 +159,8 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport public ScheduledFuture schedule(Runnable task, Trigger trigger) { ScheduledExecutorService executor = getScheduledExecutor(); try { - ErrorHandler errorHandler = this.errorHandler != null ? - this.errorHandler : TaskUtils.getDefaultErrorHandler(true); + ErrorHandler errorHandler = + (this.errorHandler != null ? this.errorHandler : TaskUtils.getDefaultErrorHandler(true)); return new ReschedulingRunnable(task, trigger, executor, errorHandler).schedule(); } catch (RejectedExecutionException ex) { diff --git a/org.springframework.context/src/main/java/org/springframework/scheduling/config/package-info.java b/org.springframework.context/src/main/java/org/springframework/scheduling/config/package-info.java new file mode 100644 index 00000000000..2ae10a2301f --- /dev/null +++ b/org.springframework.context/src/main/java/org/springframework/scheduling/config/package-info.java @@ -0,0 +1,9 @@ + +/** + * + * Support package for declarative scheduling configuration, + * with XML schema being the primary configuration format. + * + */ +package org.springframework.scheduling.config; + diff --git a/org.springframework.context/src/main/java/org/springframework/scheduling/support/TaskUtils.java b/org.springframework.context/src/main/java/org/springframework/scheduling/support/TaskUtils.java index e7b3d7595b4..2d0dcdbed6a 100644 --- a/org.springframework.context/src/main/java/org/springframework/scheduling/support/TaskUtils.java +++ b/org.springframework.context/src/main/java/org/springframework/scheduling/support/TaskUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2011 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,8 +26,8 @@ import org.springframework.util.ReflectionUtils; /** * Utility methods for decorating tasks with error handling. - *

- * NOTE: This class is intended for internal use by Spring's scheduler + * + *

NOTE: This class is intended for internal use by Spring's scheduler * implementations. It is only public so that it may be accessed from * implementations within other packages. It is not intended for general * use and may change in the future. @@ -95,7 +95,6 @@ public abstract class TaskUtils { logger.error("Unexpected error occurred in scheduled task.", t); } } - } @@ -109,7 +108,6 @@ public abstract class TaskUtils { super.handleError(t); ReflectionUtils.rethrowRuntimeException(t); } - } } diff --git a/org.springframework.core/src/main/java/org/springframework/core/env/AbstractEnvironment.java b/org.springframework.core/src/main/java/org/springframework/core/env/AbstractEnvironment.java index caf36d7f206..cf5143fed07 100644 --- a/org.springframework.core/src/main/java/org/springframework/core/env/AbstractEnvironment.java +++ b/org.springframework.core/src/main/java/org/springframework/core/env/AbstractEnvironment.java @@ -16,10 +16,7 @@ package org.springframework.core.env; -import static java.lang.String.format; -import static org.springframework.util.StringUtils.commaDelimitedListToSet; -import static org.springframework.util.StringUtils.trimAllWhitespace; - +import static java.lang.String.*; import java.security.AccessControlException; import java.util.Arrays; import java.util.LinkedHashSet; @@ -28,9 +25,11 @@ import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.core.convert.ConversionService; import org.springframework.util.Assert; import org.springframework.util.StringUtils; +import static org.springframework.util.StringUtils.*; /** * Abstract base class for {@link Environment} implementations. @@ -67,7 +66,7 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment { //--------------------------------------------------------------------- public String[] getActiveProfiles() { - return this.doGetActiveProfiles().toArray(new String[]{}); + return StringUtils.toStringArray(doGetActiveProfiles()); } protected Set doGetActiveProfiles() { @@ -86,7 +85,7 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment { } public String[] getDefaultProfiles() { - return this.doGetDefaultProfiles().toArray(new String[]{}); + return StringUtils.toStringArray(doGetDefaultProfiles()); } protected Set doGetDefaultProfiles() { diff --git a/org.springframework.core/src/main/java/org/springframework/core/env/DefaultEnvironment.java b/org.springframework.core/src/main/java/org/springframework/core/env/DefaultEnvironment.java index b7c665edfc7..c5e066ad970 100644 --- a/org.springframework.core/src/main/java/org/springframework/core/env/DefaultEnvironment.java +++ b/org.springframework.core/src/main/java/org/springframework/core/env/DefaultEnvironment.java @@ -87,16 +87,15 @@ public class DefaultEnvironment extends AbstractEnvironment { /** * Create a new {@code Environment} populated with property sources in the following order: *

- * *

Properties present in {@value #SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME} will * take precedence over those in {@value #SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME}. */ public DefaultEnvironment() { - this.getPropertySources().addFirst(new MapPropertySource(SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, this.getSystemEnvironment())); - this.getPropertySources().addFirst(new MapPropertySource(SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME, this.getSystemProperties())); + getPropertySources().addFirst(new MapPropertySource(SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, getSystemEnvironment())); + getPropertySources().addFirst(new MapPropertySource(SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME, getSystemProperties())); } } diff --git a/org.springframework.core/src/main/java/org/springframework/core/env/PropertyResolver.java b/org.springframework.core/src/main/java/org/springframework/core/env/PropertyResolver.java index e0e948f88b7..cf3fc60b340 100644 --- a/org.springframework.core/src/main/java/org/springframework/core/env/PropertyResolver.java +++ b/org.springframework.core/src/main/java/org/springframework/core/env/PropertyResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2011 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. @@ -16,8 +16,6 @@ package org.springframework.core.env; - - /** * Interface for resolving properties against any underlying source. * diff --git a/org.springframework.core/src/main/java/org/springframework/util/ErrorHandler.java b/org.springframework.core/src/main/java/org/springframework/util/ErrorHandler.java index 82c57f26f58..10e9daf0d0d 100644 --- a/org.springframework.core/src/main/java/org/springframework/util/ErrorHandler.java +++ b/org.springframework.core/src/main/java/org/springframework/util/ErrorHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2011 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. @@ -27,6 +27,9 @@ package org.springframework.util; */ public interface ErrorHandler { + /** + * Handle the given error, possibly rethrowing it as a fatal exception + */ void handleError(Throwable t); } diff --git a/org.springframework.web/src/main/java/org/springframework/web/context/support/DefaultWebEnvironment.java b/org.springframework.web/src/main/java/org/springframework/web/context/support/DefaultWebEnvironment.java index 48835b6adcf..a30a56f4aa0 100644 --- a/org.springframework.web/src/main/java/org/springframework/web/context/support/DefaultWebEnvironment.java +++ b/org.springframework.web/src/main/java/org/springframework/web/context/support/DefaultWebEnvironment.java @@ -56,9 +56,9 @@ public class DefaultWebEnvironment extends DefaultEnvironment { * Create a new {@code Environment} populated with the property sources contributed by * superclasses as well as: *

*

Properties present in {@value #SERVLET_CONFIG_PROPERTY_SOURCE_NAME} will * take precedence over those in {@value #SERVLET_CONTEXT_PROPERTY_SOURCE_NAME}. @@ -67,7 +67,6 @@ public class DefaultWebEnvironment extends DefaultEnvironment { *

The {@code Servlet}-related property sources are added as stubs for now, and will be * {@linkplain WebApplicationContextUtils#initServletPropertySources fully initialized} * once the actual {@link ServletConfig} and {@link ServletContext} objects are available. - * *

If the {@link JndiPropertySource#JNDI_PROPERTY_SOURCE_ENABLED_FLAG "jndiPropertySourceEnabled"} * property is present in any of the default property sources, a {@link JndiPropertySource} will * be added as well, with precedence lower than servlet property sources, but higher than system @@ -80,12 +79,13 @@ public class DefaultWebEnvironment extends DefaultEnvironment { * @see WebApplicationContextUtils#initServletPropertySources */ public DefaultWebEnvironment() { - this.getPropertySources().addFirst(new StubPropertySource(SERVLET_CONTEXT_PROPERTY_SOURCE_NAME)); - this.getPropertySources().addFirst(new StubPropertySource(SERVLET_CONFIG_PROPERTY_SOURCE_NAME)); + getPropertySources().addFirst(new StubPropertySource(SERVLET_CONTEXT_PROPERTY_SOURCE_NAME)); + getPropertySources().addFirst(new StubPropertySource(SERVLET_CONFIG_PROPERTY_SOURCE_NAME)); Boolean jndiPropertySourceEnabled = this.getProperty(JndiPropertySource.JNDI_PROPERTY_SOURCE_ENABLED_FLAG, boolean.class); - if (jndiPropertySourceEnabled != null && jndiPropertySourceEnabled != false) { - this.getPropertySources().addAfter(SERVLET_CONTEXT_PROPERTY_SOURCE_NAME, new JndiPropertySource()); + if (jndiPropertySourceEnabled != null && jndiPropertySourceEnabled) { + getPropertySources().addAfter(SERVLET_CONTEXT_PROPERTY_SOURCE_NAME, new JndiPropertySource()); } } + }