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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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
|
* @author Costin Leau
|
||||||
*/
|
*/
|
||||||
@Target( { ElementType.METHOD, ElementType.TYPE })
|
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Inherited
|
@Inherited
|
||||||
@Documented
|
@Documented
|
||||||
|
|
@ -38,23 +38,21 @@ public @interface Cacheable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the caches in which the update takes place.
|
* Name of the caches in which the update takes place.
|
||||||
* <p>
|
* <p>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.
|
* qualifier value (or the bean name(s)) of (a) specific bean definition.
|
||||||
*/
|
*/
|
||||||
String[] value();
|
String[] value();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring Expression Language (SpEL) attribute for computing the key dynamically.
|
* Spring Expression Language (SpEL) attribute for computing the key dynamically.
|
||||||
* <p/>
|
* <p>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 "";
|
String key() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring Expression Language (SpEL) attribute used for conditioning the method caching.
|
* Spring Expression Language (SpEL) attribute used for conditioning the method caching.
|
||||||
* <p/>
|
* <p>Default is "", meaning the method is always cached.
|
||||||
* Default is "" meaning the method is always cached.
|
|
||||||
*/
|
*/
|
||||||
String condition() default "";
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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) {
|
public ScheduledFuture schedule(Runnable task, Trigger trigger) {
|
||||||
try {
|
try {
|
||||||
ErrorHandler errorHandler = this.errorHandler != null ?
|
ErrorHandler errorHandler =
|
||||||
this.errorHandler : TaskUtils.getDefaultErrorHandler(true);
|
(this.errorHandler != null ? this.errorHandler : TaskUtils.getDefaultErrorHandler(true));
|
||||||
return new ReschedulingRunnable(task, trigger, this.scheduledExecutor, errorHandler).schedule();
|
return new ReschedulingRunnable(task, trigger, this.scheduledExecutor, errorHandler).schedule();
|
||||||
}
|
}
|
||||||
catch (RejectedExecutionException ex) {
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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) {
|
public ScheduledFuture schedule(Runnable task, Trigger trigger) {
|
||||||
ScheduledExecutorService executor = getScheduledExecutor();
|
ScheduledExecutorService executor = getScheduledExecutor();
|
||||||
try {
|
try {
|
||||||
ErrorHandler errorHandler = this.errorHandler != null ?
|
ErrorHandler errorHandler =
|
||||||
this.errorHandler : TaskUtils.getDefaultErrorHandler(true);
|
(this.errorHandler != null ? this.errorHandler : TaskUtils.getDefaultErrorHandler(true));
|
||||||
return new ReschedulingRunnable(task, trigger, executor, errorHandler).schedule();
|
return new ReschedulingRunnable(task, trigger, executor, errorHandler).schedule();
|
||||||
}
|
}
|
||||||
catch (RejectedExecutionException ex) {
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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.
|
* 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. It is only public so that it may be accessed from
|
||||||
* implementations within other packages. It is <i>not</i> intended for general
|
* implementations within other packages. It is <i>not</i> intended for general
|
||||||
* use and may change in the future.
|
* use and may change in the future.
|
||||||
|
|
@ -95,7 +95,6 @@ public abstract class TaskUtils {
|
||||||
logger.error("Unexpected error occurred in scheduled task.", t);
|
logger.error("Unexpected error occurred in scheduled task.", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -109,7 +108,6 @@ public abstract class TaskUtils {
|
||||||
super.handleError(t);
|
super.handleError(t);
|
||||||
ReflectionUtils.rethrowRuntimeException(t);
|
ReflectionUtils.rethrowRuntimeException(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,7 @@
|
||||||
|
|
||||||
package org.springframework.core.env;
|
package org.springframework.core.env;
|
||||||
|
|
||||||
import static java.lang.String.format;
|
import static java.lang.String.*;
|
||||||
import static org.springframework.util.StringUtils.commaDelimitedListToSet;
|
|
||||||
import static org.springframework.util.StringUtils.trimAllWhitespace;
|
|
||||||
|
|
||||||
import java.security.AccessControlException;
|
import java.security.AccessControlException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
|
|
@ -28,9 +25,11 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import org.springframework.core.convert.ConversionService;
|
import org.springframework.core.convert.ConversionService;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
import static org.springframework.util.StringUtils.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract base class for {@link Environment} implementations.
|
* Abstract base class for {@link Environment} implementations.
|
||||||
|
|
@ -67,7 +66,7 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
public String[] getActiveProfiles() {
|
public String[] getActiveProfiles() {
|
||||||
return this.doGetActiveProfiles().toArray(new String[]{});
|
return StringUtils.toStringArray(doGetActiveProfiles());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Set<String> doGetActiveProfiles() {
|
protected Set<String> doGetActiveProfiles() {
|
||||||
|
|
@ -86,7 +85,7 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getDefaultProfiles() {
|
public String[] getDefaultProfiles() {
|
||||||
return this.doGetDefaultProfiles().toArray(new String[]{});
|
return StringUtils.toStringArray(doGetDefaultProfiles());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Set<String> 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:
|
* Create a new {@code Environment} populated with property sources in the following order:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{@value #SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME}
|
* <li>{@value #SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME}
|
||||||
* <li>{@value #SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME}
|
* <li>{@value #SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME}
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
|
||||||
* <p>Properties present in {@value #SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME} will
|
* <p>Properties present in {@value #SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME} will
|
||||||
* take precedence over those in {@value #SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME}.
|
* take precedence over those in {@value #SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME}.
|
||||||
*/
|
*/
|
||||||
public DefaultEnvironment() {
|
public DefaultEnvironment() {
|
||||||
this.getPropertySources().addFirst(new MapPropertySource(SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, this.getSystemEnvironment()));
|
getPropertySources().addFirst(new MapPropertySource(SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, getSystemEnvironment()));
|
||||||
this.getPropertySources().addFirst(new MapPropertySource(SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME, this.getSystemProperties()));
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -16,8 +16,6 @@
|
||||||
|
|
||||||
package org.springframework.core.env;
|
package org.springframework.core.env;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for resolving properties against any underlying source.
|
* 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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 {
|
public interface ErrorHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the given error, possibly rethrowing it as a fatal exception
|
||||||
|
*/
|
||||||
void handleError(Throwable t);
|
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
|
* Create a new {@code Environment} populated with the property sources contributed by
|
||||||
* superclasses as well as:
|
* superclasses as well as:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{@value #SERVLET_CONFIG_PROPERTY_SOURCE_NAME}
|
* <li>{@value #SERVLET_CONFIG_PROPERTY_SOURCE_NAME}
|
||||||
* <li>{@value #SERVLET_CONTEXT_PROPERTY_SOURCE_NAME}
|
* <li>{@value #SERVLET_CONTEXT_PROPERTY_SOURCE_NAME}
|
||||||
* <li>(optionally) {@link JndiPropertySource#JNDI_PROPERTY_SOURCE_NAME "jndiPropertySource"}
|
* <li>(optionally) {@link JndiPropertySource#JNDI_PROPERTY_SOURCE_NAME "jndiPropertySource"}
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>Properties present in {@value #SERVLET_CONFIG_PROPERTY_SOURCE_NAME} will
|
* <p>Properties present in {@value #SERVLET_CONFIG_PROPERTY_SOURCE_NAME} will
|
||||||
* take precedence over those in {@value #SERVLET_CONTEXT_PROPERTY_SOURCE_NAME}.
|
* 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
|
* <p>The {@code Servlet}-related property sources are added as stubs for now, and will be
|
||||||
* {@linkplain WebApplicationContextUtils#initServletPropertySources fully initialized}
|
* {@linkplain WebApplicationContextUtils#initServletPropertySources fully initialized}
|
||||||
* once the actual {@link ServletConfig} and {@link ServletContext} objects are available.
|
* once the actual {@link ServletConfig} and {@link ServletContext} objects are available.
|
||||||
*
|
|
||||||
* <p>If the {@link JndiPropertySource#JNDI_PROPERTY_SOURCE_ENABLED_FLAG "jndiPropertySourceEnabled"}
|
* <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
|
* 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
|
* 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
|
* @see WebApplicationContextUtils#initServletPropertySources
|
||||||
*/
|
*/
|
||||||
public DefaultWebEnvironment() {
|
public DefaultWebEnvironment() {
|
||||||
this.getPropertySources().addFirst(new StubPropertySource(SERVLET_CONTEXT_PROPERTY_SOURCE_NAME));
|
getPropertySources().addFirst(new StubPropertySource(SERVLET_CONTEXT_PROPERTY_SOURCE_NAME));
|
||||||
this.getPropertySources().addFirst(new StubPropertySource(SERVLET_CONFIG_PROPERTY_SOURCE_NAME));
|
getPropertySources().addFirst(new StubPropertySource(SERVLET_CONFIG_PROPERTY_SOURCE_NAME));
|
||||||
|
|
||||||
Boolean jndiPropertySourceEnabled = this.getProperty(JndiPropertySource.JNDI_PROPERTY_SOURCE_ENABLED_FLAG, boolean.class);
|
Boolean jndiPropertySourceEnabled = this.getProperty(JndiPropertySource.JNDI_PROPERTY_SOURCE_ENABLED_FLAG, boolean.class);
|
||||||
if (jndiPropertySourceEnabled != null && jndiPropertySourceEnabled != false) {
|
if (jndiPropertySourceEnabled != null && jndiPropertySourceEnabled) {
|
||||||
this.getPropertySources().addAfter(SERVLET_CONTEXT_PROPERTY_SOURCE_NAME, new JndiPropertySource());
|
getPropertySources().addAfter(SERVLET_CONTEXT_PROPERTY_SOURCE_NAME, new JndiPropertySource());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue