polishing
This commit is contained in:
parent
6bfead259e
commit
03190950d1
|
|
@ -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.
|
||||
* <p>
|
||||
* May be used to determine the target cache (or caches), matching the
|
||||
* <p>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.
|
||||
* <p/>
|
||||
* Default is "" meaning all method parameters are considered as a key.
|
||||
* <p>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.
|
||||
* <p/>
|
||||
* Default is "" meaning the method is always cached.
|
||||
* <p>Default is "", meaning the method is always cached.
|
||||
*/
|
||||
String condition() default "";
|
||||
|
||||
}
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
/**
|
||||
*
|
||||
* Support package for declarative scheduling configuration,
|
||||
* with XML schema being the primary configuration format.
|
||||
*
|
||||
*/
|
||||
package org.springframework.scheduling.config;
|
||||
|
||||
|
|
@ -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.
|
||||
* <p>
|
||||
* <b>NOTE:</b> This class is intended for internal use by Spring's scheduler
|
||||
*
|
||||
* <p><b>NOTE:</b> 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 <i>not</i> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<String> 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<String> doGetDefaultProfiles() {
|
||||
|
|
|
|||
|
|
@ -87,16 +87,15 @@ public class DefaultEnvironment extends AbstractEnvironment {
|
|||
/**
|
||||
* Create a new {@code Environment} populated with property sources in the following order:
|
||||
* <ul>
|
||||
* <li>{@value #SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME}
|
||||
* <li>{@value #SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME}
|
||||
* <li>{@value #SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME}
|
||||
* <li>{@value #SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME}
|
||||
* </ul>
|
||||
*
|
||||
* <p>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()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
* <ul>
|
||||
* <li>{@value #SERVLET_CONFIG_PROPERTY_SOURCE_NAME}
|
||||
* <li>{@value #SERVLET_CONTEXT_PROPERTY_SOURCE_NAME}
|
||||
* <li>(optionally) {@link JndiPropertySource#JNDI_PROPERTY_SOURCE_NAME "jndiPropertySource"}
|
||||
* <li>{@value #SERVLET_CONFIG_PROPERTY_SOURCE_NAME}
|
||||
* <li>{@value #SERVLET_CONTEXT_PROPERTY_SOURCE_NAME}
|
||||
* <li>(optionally) {@link JndiPropertySource#JNDI_PROPERTY_SOURCE_NAME "jndiPropertySource"}
|
||||
* </ul>
|
||||
* <p>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 {
|
|||
* <p>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.
|
||||
*
|
||||
* <p>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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue