Nullability fine-tuning around declaration inconsistencies
Issue: SPR-15720 Issue: SPR-15792
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -56,6 +56,7 @@ public class ConcurrentMapCacheManager implements CacheManager, BeanClassLoaderA
|
||||
|
||||
private boolean storeByValue = false;
|
||||
|
||||
@Nullable
|
||||
private SerializationDelegate serialization;
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public abstract class AbstractCacheInvoker {
|
||||
}
|
||||
|
||||
protected AbstractCacheInvoker(CacheErrorHandler errorHandler) {
|
||||
setErrorHandler(errorHandler);
|
||||
this.errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -36,6 +36,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public abstract class AbstractCacheResolver implements CacheResolver, InitializingBean {
|
||||
|
||||
@Nullable
|
||||
private CacheManager cacheManager;
|
||||
|
||||
|
||||
@@ -55,15 +56,16 @@ public abstract class AbstractCacheResolver implements CacheResolver, Initializi
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@link CacheManager} that this instance use.
|
||||
* Return the {@link CacheManager} that this instance uses.
|
||||
*/
|
||||
public CacheManager getCacheManager() {
|
||||
Assert.state(this.cacheManager != null, "No CacheManager set");
|
||||
return this.cacheManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(this.cacheManager, "CacheManager must not be null");
|
||||
Assert.notNull(this.cacheManager, "CacheManager is required");
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +78,7 @@ public abstract class AbstractCacheResolver implements CacheResolver, Initializi
|
||||
else {
|
||||
Collection<Cache> result = new ArrayList<>();
|
||||
for (String cacheName : cacheNames) {
|
||||
Cache cache = this.cacheManager.getCache(cacheName);
|
||||
Cache cache = getCacheManager().getCache(cacheName);
|
||||
if (cache == null) {
|
||||
throw new IllegalArgumentException("Cannot find cache named '" +
|
||||
cacheName + "' for " + context.getOperation());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -19,6 +19,7 @@ package org.springframework.cache.interceptor;
|
||||
import org.springframework.aop.ClassFilter;
|
||||
import org.springframework.aop.Pointcut;
|
||||
import org.springframework.aop.support.AbstractBeanFactoryPointcutAdvisor;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Advisor driven by a {@link CacheOperationSource}, used to include a
|
||||
@@ -30,6 +31,7 @@ import org.springframework.aop.support.AbstractBeanFactoryPointcutAdvisor;
|
||||
@SuppressWarnings("serial")
|
||||
public class BeanFactoryCacheOperationSourceAdvisor extends AbstractBeanFactoryPointcutAdvisor {
|
||||
|
||||
@Nullable
|
||||
private CacheOperationSource cacheOperationSource;
|
||||
|
||||
private final CacheOperationSourcePointcut pointcut = new CacheOperationSourcePointcut() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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,6 +16,8 @@
|
||||
|
||||
package org.springframework.cache.interceptor;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Class describing a cache 'put' operation.
|
||||
*
|
||||
@@ -26,6 +28,7 @@ package org.springframework.cache.interceptor;
|
||||
*/
|
||||
public class CachePutOperation extends CacheOperation {
|
||||
|
||||
@Nullable
|
||||
private final String unless;
|
||||
|
||||
|
||||
@@ -38,6 +41,7 @@ public class CachePutOperation extends CacheOperation {
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public String getUnless() {
|
||||
return this.unless;
|
||||
}
|
||||
@@ -48,6 +52,7 @@ public class CachePutOperation extends CacheOperation {
|
||||
*/
|
||||
public static class Builder extends CacheOperation.Builder {
|
||||
|
||||
@Nullable
|
||||
private String unless;
|
||||
|
||||
public void setUnless(String unless) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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,6 +16,8 @@
|
||||
|
||||
package org.springframework.cache.interceptor;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Class describing a cache 'cacheable' operation.
|
||||
*
|
||||
@@ -26,6 +28,7 @@ package org.springframework.cache.interceptor;
|
||||
*/
|
||||
public class CacheableOperation extends CacheOperation {
|
||||
|
||||
@Nullable
|
||||
private final String unless;
|
||||
|
||||
private final boolean sync;
|
||||
@@ -41,6 +44,7 @@ public class CacheableOperation extends CacheOperation {
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public String getUnless() {
|
||||
return this.unless;
|
||||
}
|
||||
@@ -55,6 +59,7 @@ public class CacheableOperation extends CacheOperation {
|
||||
*/
|
||||
public static class Builder extends CacheOperation.Builder {
|
||||
|
||||
@Nullable
|
||||
private String unless;
|
||||
|
||||
private boolean sync;
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
package org.springframework.cache.interceptor;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A {@link CacheResolver} that forces the resolution to a configurable
|
||||
@@ -32,6 +32,7 @@ import org.springframework.cache.CacheManager;
|
||||
*/
|
||||
public class NamedCacheResolver extends AbstractCacheResolver {
|
||||
|
||||
@Nullable
|
||||
private Collection<String> cacheNames;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.cache.interceptor;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A simple {@link CacheErrorHandler} that does not handle the
|
||||
@@ -33,7 +34,7 @@ public class SimpleCacheErrorHandler implements CacheErrorHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCachePutError(RuntimeException exception, Cache cache, Object key, Object value) {
|
||||
public void handleCachePutError(RuntimeException exception, Cache cache, Object key, @Nullable Object value) {
|
||||
throw exception;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.cache.support;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
|
||||
@@ -29,7 +30,7 @@ import org.springframework.cache.Cache;
|
||||
*/
|
||||
public class SimpleCacheManager extends AbstractCacheManager {
|
||||
|
||||
private Collection<? extends Cache> caches;
|
||||
private Collection<? extends Cache> caches = Collections.emptySet();
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -53,6 +53,7 @@ final class ConfigurationClass {
|
||||
|
||||
private final Resource resource;
|
||||
|
||||
@Nullable
|
||||
private String beanName;
|
||||
|
||||
private final Set<ConfigurationClass> importedBy = new LinkedHashSet<>(1);
|
||||
@@ -75,7 +76,7 @@ final class ConfigurationClass {
|
||||
* @see ConfigurationClass#ConfigurationClass(Class, ConfigurationClass)
|
||||
*/
|
||||
public ConfigurationClass(MetadataReader metadataReader, String beanName) {
|
||||
Assert.hasText(beanName, "Bean name must not be null");
|
||||
Assert.notNull(beanName, "Bean name must not be null");
|
||||
this.metadata = metadataReader.getAnnotationMetadata();
|
||||
this.resource = metadataReader.getResource();
|
||||
this.beanName = beanName;
|
||||
@@ -102,7 +103,7 @@ final class ConfigurationClass {
|
||||
* @see ConfigurationClass#ConfigurationClass(Class, ConfigurationClass)
|
||||
*/
|
||||
public ConfigurationClass(Class<?> clazz, String beanName) {
|
||||
Assert.hasText(beanName, "Bean name must not be null");
|
||||
Assert.notNull(beanName, "Bean name must not be null");
|
||||
this.metadata = new StandardAnnotationMetadata(clazz, true);
|
||||
this.resource = new DescriptiveResource(clazz.getName());
|
||||
this.beanName = beanName;
|
||||
@@ -113,7 +114,7 @@ final class ConfigurationClass {
|
||||
* using the {@link Import} annotation or automatically processed as a nested
|
||||
* configuration class (if imported is {@code true}).
|
||||
* @param clazz the underlying {@link Class} to represent
|
||||
* @param importedBy the configuration class importing this one or {@code null}
|
||||
* @param importedBy the configuration class importing this one (or {@code null})
|
||||
* @since 3.1.1
|
||||
*/
|
||||
public ConfigurationClass(Class<?> clazz, @Nullable ConfigurationClass importedBy) {
|
||||
@@ -129,7 +130,7 @@ final class ConfigurationClass {
|
||||
* @see ConfigurationClass#ConfigurationClass(Class, ConfigurationClass)
|
||||
*/
|
||||
public ConfigurationClass(AnnotationMetadata metadata, String beanName) {
|
||||
Assert.hasText(beanName, "Bean name must not be null");
|
||||
Assert.notNull(beanName, "Bean name must not be null");
|
||||
this.metadata = metadata;
|
||||
this.resource = new DescriptiveResource(metadata.getClassName());
|
||||
this.beanName = beanName;
|
||||
@@ -152,6 +153,7 @@ final class ConfigurationClass {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getBeanName() {
|
||||
return this.beanName;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import org.springframework.aop.framework.autoproxy.AutoProxyUtils;
|
||||
import org.springframework.aop.scope.ScopedObject;
|
||||
import org.springframework.aop.scope.ScopedProxyUtils;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanInitializationException;
|
||||
import org.springframework.beans.factory.SmartInitializingSingleton;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -41,6 +40,7 @@ import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.MethodIntrospector;
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@@ -56,6 +56,7 @@ public class EventListenerMethodProcessor implements SmartInitializingSingleton,
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
@Nullable
|
||||
private ConfigurableApplicationContext applicationContext;
|
||||
|
||||
private final EventExpressionEvaluator evaluator = new EventExpressionEvaluator();
|
||||
@@ -64,21 +65,28 @@ public class EventListenerMethodProcessor implements SmartInitializingSingleton,
|
||||
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
Assert.isTrue(applicationContext instanceof ConfigurableApplicationContext,
|
||||
"ApplicationContext does not implement ConfigurableApplicationContext");
|
||||
this.applicationContext = (ConfigurableApplicationContext) applicationContext;
|
||||
}
|
||||
|
||||
private ConfigurableApplicationContext getApplicationContext() {
|
||||
Assert.state(this.applicationContext != null, "No ApplicationContext set");
|
||||
return this.applicationContext;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void afterSingletonsInstantiated() {
|
||||
List<EventListenerFactory> factories = getEventListenerFactories();
|
||||
String[] beanNames = this.applicationContext.getBeanNamesForType(Object.class);
|
||||
ConfigurableApplicationContext context = getApplicationContext();
|
||||
String[] beanNames = context.getBeanNamesForType(Object.class);
|
||||
for (String beanName : beanNames) {
|
||||
if (!ScopedProxyUtils.isScopedTarget(beanName)) {
|
||||
Class<?> type = null;
|
||||
try {
|
||||
type = AutoProxyUtils.determineTargetClass(this.applicationContext.getBeanFactory(), beanName);
|
||||
type = AutoProxyUtils.determineTargetClass(context.getBeanFactory(), beanName);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
// An unresolvable bean type, probably from a lazy bean - let's ignore it.
|
||||
@@ -90,8 +98,7 @@ public class EventListenerMethodProcessor implements SmartInitializingSingleton,
|
||||
if (ScopedObject.class.isAssignableFrom(type)) {
|
||||
try {
|
||||
Class<?> targetClass = AutoProxyUtils.determineTargetClass(
|
||||
this.applicationContext.getBeanFactory(),
|
||||
ScopedProxyUtils.getTargetBeanName(beanName));
|
||||
context.getBeanFactory(), ScopedProxyUtils.getTargetBeanName(beanName));
|
||||
if (targetClass != null) {
|
||||
type = targetClass;
|
||||
}
|
||||
@@ -121,7 +128,7 @@ public class EventListenerMethodProcessor implements SmartInitializingSingleton,
|
||||
* {@link EventListener} annotated methods.
|
||||
*/
|
||||
protected List<EventListenerFactory> getEventListenerFactories() {
|
||||
Map<String, EventListenerFactory> beans = this.applicationContext.getBeansOfType(EventListenerFactory.class);
|
||||
Map<String, EventListenerFactory> beans = getApplicationContext().getBeansOfType(EventListenerFactory.class);
|
||||
List<EventListenerFactory> allFactories = new ArrayList<>(beans.values());
|
||||
AnnotationAwareOrderComparator.sort(allFactories);
|
||||
return allFactories;
|
||||
@@ -152,18 +159,17 @@ public class EventListenerMethodProcessor implements SmartInitializingSingleton,
|
||||
}
|
||||
else {
|
||||
// Non-empty set of methods
|
||||
ConfigurableApplicationContext context = getApplicationContext();
|
||||
for (Method method : annotatedMethods.keySet()) {
|
||||
for (EventListenerFactory factory : factories) {
|
||||
if (factory.supportsMethod(method)) {
|
||||
Method methodToUse = AopUtils.selectInvocableMethod(
|
||||
method, this.applicationContext.getType(beanName));
|
||||
Method methodToUse = AopUtils.selectInvocableMethod(method, context.getType(beanName));
|
||||
ApplicationListener<?> applicationListener =
|
||||
factory.createApplicationListener(beanName, targetType, methodToUse);
|
||||
if (applicationListener instanceof ApplicationListenerMethodAdapter) {
|
||||
((ApplicationListenerMethodAdapter) applicationListener)
|
||||
.init(this.applicationContext, this.evaluator);
|
||||
((ApplicationListenerMethodAdapter) applicationListener).init(context, this.evaluator);
|
||||
}
|
||||
this.applicationContext.addApplicationListener(applicationListener);
|
||||
context.addApplicationListener(applicationListener);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.springframework.beans.factory.support.MergedBeanDefinitionPostProcess
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ApplicationEventMulticaster;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
@@ -47,7 +46,6 @@ class ApplicationListenerDetector implements DestructionAwareBeanPostProcessor,
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ApplicationListenerDetector.class);
|
||||
|
||||
@Nullable
|
||||
private transient final AbstractApplicationContext applicationContext;
|
||||
|
||||
private transient final Map<String, Boolean> singletonNames = new ConcurrentHashMap<>(256);
|
||||
@@ -60,9 +58,7 @@ class ApplicationListenerDetector implements DestructionAwareBeanPostProcessor,
|
||||
|
||||
@Override
|
||||
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) {
|
||||
if (this.applicationContext != null) {
|
||||
this.singletonNames.put(beanName, beanDefinition.isSingleton());
|
||||
}
|
||||
this.singletonNames.put(beanName, beanDefinition.isSingleton());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,7 +68,7 @@ class ApplicationListenerDetector implements DestructionAwareBeanPostProcessor,
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) {
|
||||
if (this.applicationContext != null && bean instanceof ApplicationListener) {
|
||||
if (bean instanceof ApplicationListener) {
|
||||
// potentially not detected as a listener by getBeanNamesForType retrieval
|
||||
Boolean flag = this.singletonNames.get(beanName);
|
||||
if (Boolean.TRUE.equals(flag)) {
|
||||
@@ -95,7 +91,7 @@ class ApplicationListenerDetector implements DestructionAwareBeanPostProcessor,
|
||||
|
||||
@Override
|
||||
public void postProcessBeforeDestruction(Object bean, String beanName) {
|
||||
if (this.applicationContext != null && bean instanceof ApplicationListener) {
|
||||
if (bean instanceof ApplicationListener) {
|
||||
ApplicationEventMulticaster multicaster = this.applicationContext.getApplicationEventMulticaster();
|
||||
multicaster.removeApplicationListener((ApplicationListener<?>) bean);
|
||||
multicaster.removeApplicationListenerBean(beanName);
|
||||
|
||||
@@ -51,6 +51,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class ClassPathXmlApplicationContext extends AbstractXmlApplicationContext {
|
||||
|
||||
@Nullable
|
||||
private Resource[] configResources;
|
||||
|
||||
|
||||
@@ -203,6 +204,7 @@ public class ClassPathXmlApplicationContext extends AbstractXmlApplicationContex
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Resource[] getConfigResources() {
|
||||
return this.configResources;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -24,6 +24,7 @@ import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.support.ConversionServiceFactory;
|
||||
import org.springframework.core.convert.support.DefaultConversionService;
|
||||
import org.springframework.core.convert.support.GenericConversionService;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A factory providing convenient access to a ConversionService configured with
|
||||
@@ -49,8 +50,10 @@ import org.springframework.core.convert.support.GenericConversionService;
|
||||
*/
|
||||
public class ConversionServiceFactoryBean implements FactoryBean<ConversionService>, InitializingBean {
|
||||
|
||||
@Nullable
|
||||
private Set<?> converters;
|
||||
|
||||
@Nullable
|
||||
private GenericConversionService conversionService;
|
||||
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ import org.springframework.context.Lifecycle;
|
||||
import org.springframework.context.LifecycleProcessor;
|
||||
import org.springframework.context.Phased;
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Default implementation of the {@link LifecycleProcessor} strategy.
|
||||
@@ -55,6 +57,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
|
||||
|
||||
private volatile boolean running;
|
||||
|
||||
@Nullable
|
||||
private volatile ConfigurableListableBeanFactory beanFactory;
|
||||
|
||||
|
||||
@@ -76,6 +79,12 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
|
||||
this.beanFactory = (ConfigurableListableBeanFactory) beanFactory;
|
||||
}
|
||||
|
||||
private ConfigurableListableBeanFactory getBeanFactory() {
|
||||
ConfigurableListableBeanFactory beanFactory = this.beanFactory;
|
||||
Assert.state(beanFactory != null, "No BeanFactory available");
|
||||
return beanFactory;
|
||||
}
|
||||
|
||||
|
||||
// Lifecycle implementation
|
||||
|
||||
@@ -161,7 +170,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
|
||||
private void doStart(Map<String, ? extends Lifecycle> lifecycleBeans, String beanName, boolean autoStartupOnly) {
|
||||
Lifecycle bean = lifecycleBeans.remove(beanName);
|
||||
if (bean != null && !this.equals(bean)) {
|
||||
String[] dependenciesForBean = this.beanFactory.getDependenciesForBean(beanName);
|
||||
String[] dependenciesForBean = getBeanFactory().getDependenciesForBean(beanName);
|
||||
for (String dependency : dependenciesForBean) {
|
||||
doStart(lifecycleBeans, dependency, autoStartupOnly);
|
||||
}
|
||||
@@ -215,7 +224,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
|
||||
|
||||
Lifecycle bean = lifecycleBeans.remove(beanName);
|
||||
if (bean != null) {
|
||||
String[] dependentBeans = this.beanFactory.getDependentBeans(beanName);
|
||||
String[] dependentBeans = getBeanFactory().getDependentBeans(beanName);
|
||||
for (String dependentBean : dependentBeans) {
|
||||
doStop(lifecycleBeans, dependentBean, latch, countDownBeanNames);
|
||||
}
|
||||
@@ -266,16 +275,17 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
|
||||
* @return the Map of applicable beans, with bean names as keys and bean instances as values
|
||||
*/
|
||||
protected Map<String, Lifecycle> getLifecycleBeans() {
|
||||
ConfigurableListableBeanFactory beanFactory = getBeanFactory();
|
||||
Map<String, Lifecycle> beans = new LinkedHashMap<>();
|
||||
String[] beanNames = this.beanFactory.getBeanNamesForType(Lifecycle.class, false, false);
|
||||
String[] beanNames = getBeanFactory().getBeanNamesForType(Lifecycle.class, false, false);
|
||||
for (String beanName : beanNames) {
|
||||
String beanNameToRegister = BeanFactoryUtils.transformedBeanName(beanName);
|
||||
boolean isFactoryBean = this.beanFactory.isFactoryBean(beanNameToRegister);
|
||||
boolean isFactoryBean = getBeanFactory().isFactoryBean(beanNameToRegister);
|
||||
String beanNameToCheck = (isFactoryBean ? BeanFactory.FACTORY_BEAN_PREFIX + beanName : beanName);
|
||||
if ((this.beanFactory.containsSingleton(beanNameToRegister) &&
|
||||
if ((getBeanFactory().containsSingleton(beanNameToRegister) &&
|
||||
(!isFactoryBean || matchesBeanType(Lifecycle.class, beanNameToCheck))) ||
|
||||
matchesBeanType(SmartLifecycle.class, beanNameToCheck)) {
|
||||
Lifecycle bean = this.beanFactory.getBean(beanNameToCheck, Lifecycle.class);
|
||||
Lifecycle bean = getBeanFactory().getBean(beanNameToCheck, Lifecycle.class);
|
||||
if (bean != this) {
|
||||
beans.put(beanNameToRegister, bean);
|
||||
}
|
||||
@@ -285,7 +295,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
|
||||
}
|
||||
|
||||
private boolean matchesBeanType(Class<?> targetType, String beanName) {
|
||||
Class<?> beanType = this.beanFactory.getType(beanName);
|
||||
Class<?> beanType = getBeanFactory().getType(beanName);
|
||||
return (beanType != null && targetType.isAssignableFrom(beanType));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -47,8 +47,10 @@ public class AspectJWeavingEnabler
|
||||
public static final String ASPECTJ_AOP_XML_RESOURCE = "META-INF/aop.xml";
|
||||
|
||||
|
||||
@Nullable
|
||||
private ClassLoader beanClassLoader;
|
||||
|
||||
@Nullable
|
||||
private LoadTimeWeaver loadTimeWeaver;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -20,6 +20,7 @@ import org.joda.time.format.DateTimeFormatter;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* {@link FactoryBean} that creates a Joda-Time {@link DateTimeFormatter}.
|
||||
@@ -36,6 +37,7 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
public class DateTimeFormatterFactoryBean extends DateTimeFormatterFactory
|
||||
implements FactoryBean<DateTimeFormatter>, InitializingBean {
|
||||
|
||||
@Nullable
|
||||
private DateTimeFormatter dateTimeFormatter;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -20,6 +20,7 @@ import java.time.format.DateTimeFormatter;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* {@link FactoryBean} that creates a JSR-310 {@link java.time.format.DateTimeFormatter}.
|
||||
@@ -36,6 +37,7 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
public class DateTimeFormatterFactoryBean extends DateTimeFormatterFactory
|
||||
implements FactoryBean<DateTimeFormatter>, InitializingBean {
|
||||
|
||||
@Nullable
|
||||
private DateTimeFormatter dateTimeFormatter;
|
||||
|
||||
|
||||
|
||||
@@ -432,7 +432,8 @@ public class MetadataMBeanInfoAssembler extends AbstractReflectiveMBeanInfoAssem
|
||||
* @param setter the Object value associated with the set method
|
||||
* @return the appropriate Object to use as the value for the descriptor
|
||||
*/
|
||||
private Object resolveObjectDescriptor(@Nullable Object getter, Object setter) {
|
||||
@Nullable
|
||||
private Object resolveObjectDescriptor(@Nullable Object getter, @Nullable Object setter) {
|
||||
return (getter != null ? getter : setter);
|
||||
}
|
||||
|
||||
@@ -446,7 +447,8 @@ public class MetadataMBeanInfoAssembler extends AbstractReflectiveMBeanInfoAssem
|
||||
* @param setter the String value associated with the set method
|
||||
* @return the appropriate String to use as the value for the descriptor
|
||||
*/
|
||||
private String resolveStringDescriptor(String getter, String setter) {
|
||||
@Nullable
|
||||
private String resolveStringDescriptor(@Nullable String getter, @Nullable String setter) {
|
||||
return (StringUtils.hasLength(getter) ? getter : setter);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
* Copyright 2002-2017 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,6 +16,8 @@
|
||||
|
||||
package org.springframework.jmx.export.metadata;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Metadata that indicates to expose a given bean property as JMX attribute.
|
||||
* Only valid when used on a JavaBean getter or setter.
|
||||
@@ -30,8 +32,10 @@ public class ManagedAttribute extends AbstractJmxAttribute {
|
||||
public static final ManagedAttribute EMPTY = new ManagedAttribute();
|
||||
|
||||
|
||||
@Nullable
|
||||
private Object defaultValue;
|
||||
|
||||
@Nullable
|
||||
private String persistPolicy;
|
||||
|
||||
private int persistPeriod = -1;
|
||||
@@ -40,21 +44,23 @@ public class ManagedAttribute extends AbstractJmxAttribute {
|
||||
/**
|
||||
* Set the default value of this attribute.
|
||||
*/
|
||||
public void setDefaultValue(Object defaultValue) {
|
||||
public void setDefaultValue(@Nullable Object defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default value of this attribute.
|
||||
*/
|
||||
@Nullable
|
||||
public Object getDefaultValue() {
|
||||
return this.defaultValue;
|
||||
}
|
||||
|
||||
public void setPersistPolicy(String persistPolicy) {
|
||||
public void setPersistPolicy(@Nullable String persistPolicy) {
|
||||
this.persistPolicy = persistPolicy;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPersistPolicy() {
|
||||
return this.persistPolicy;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.jmx.export.metadata;
|
||||
|
||||
import org.springframework.jmx.support.MetricType;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -30,29 +31,34 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class ManagedMetric extends AbstractJmxAttribute {
|
||||
|
||||
@Nullable
|
||||
private String category;
|
||||
|
||||
@Nullable
|
||||
private String displayName;
|
||||
|
||||
private MetricType metricType = MetricType.GAUGE;
|
||||
|
||||
private int persistPeriod = -1;
|
||||
|
||||
@Nullable
|
||||
private String persistPolicy;
|
||||
|
||||
@Nullable
|
||||
private String unit;
|
||||
|
||||
|
||||
/**
|
||||
* The category of this metric (ex. throughput, performance, utilization).
|
||||
*/
|
||||
public void setCategory(String category) {
|
||||
public void setCategory(@Nullable String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
/**
|
||||
* The category of this metric (ex. throughput, performance, utilization).
|
||||
*/
|
||||
@Nullable
|
||||
public String getCategory() {
|
||||
return this.category;
|
||||
}
|
||||
@@ -60,13 +66,14 @@ public class ManagedMetric extends AbstractJmxAttribute {
|
||||
/**
|
||||
* A display name for this metric.
|
||||
*/
|
||||
public void setDisplayName(String displayName) {
|
||||
public void setDisplayName(@Nullable String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* A display name for this metric.
|
||||
*/
|
||||
@Nullable
|
||||
public String getDisplayName() {
|
||||
return this.displayName;
|
||||
}
|
||||
@@ -103,13 +110,14 @@ public class ManagedMetric extends AbstractJmxAttribute {
|
||||
/**
|
||||
* The persist policy for this metric.
|
||||
*/
|
||||
public void setPersistPolicy(String persistPolicy) {
|
||||
public void setPersistPolicy(@Nullable String persistPolicy) {
|
||||
this.persistPolicy = persistPolicy;
|
||||
}
|
||||
|
||||
/**
|
||||
* The persist policy for this metric.
|
||||
*/
|
||||
@Nullable
|
||||
public String getPersistPolicy() {
|
||||
return this.persistPolicy;
|
||||
}
|
||||
@@ -117,13 +125,14 @@ public class ManagedMetric extends AbstractJmxAttribute {
|
||||
/**
|
||||
* The expected unit of measurement values.
|
||||
*/
|
||||
public void setUnit(String unit) {
|
||||
public void setUnit(@Nullable String unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* The expected unit of measurement values.
|
||||
*/
|
||||
@Nullable
|
||||
public String getUnit() {
|
||||
return this.unit;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 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,6 +16,8 @@
|
||||
|
||||
package org.springframework.jmx.export.metadata;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Metadata indicating that instances of an annotated class
|
||||
* are to be registered with a JMX server.
|
||||
@@ -29,31 +31,37 @@ package org.springframework.jmx.export.metadata;
|
||||
*/
|
||||
public class ManagedResource extends AbstractJmxAttribute {
|
||||
|
||||
@Nullable
|
||||
private String objectName;
|
||||
|
||||
private boolean log = false;
|
||||
|
||||
@Nullable
|
||||
private String logFile;
|
||||
|
||||
@Nullable
|
||||
private String persistPolicy;
|
||||
|
||||
private int persistPeriod = -1;
|
||||
|
||||
@Nullable
|
||||
private String persistName;
|
||||
|
||||
@Nullable
|
||||
private String persistLocation;
|
||||
|
||||
|
||||
/**
|
||||
* Set the JMX ObjectName of this managed resource.
|
||||
*/
|
||||
public void setObjectName(String objectName) {
|
||||
public void setObjectName(@Nullable String objectName) {
|
||||
this.objectName = objectName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the JMX ObjectName of this managed resource.
|
||||
*/
|
||||
@Nullable
|
||||
public String getObjectName() {
|
||||
return this.objectName;
|
||||
}
|
||||
@@ -66,18 +74,20 @@ public class ManagedResource extends AbstractJmxAttribute {
|
||||
return this.log;
|
||||
}
|
||||
|
||||
public void setLogFile(String logFile) {
|
||||
public void setLogFile(@Nullable String logFile) {
|
||||
this.logFile = logFile;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getLogFile() {
|
||||
return this.logFile;
|
||||
}
|
||||
|
||||
public void setPersistPolicy(String persistPolicy) {
|
||||
public void setPersistPolicy(@Nullable String persistPolicy) {
|
||||
this.persistPolicy = persistPolicy;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPersistPolicy() {
|
||||
return this.persistPolicy;
|
||||
}
|
||||
@@ -90,18 +100,20 @@ public class ManagedResource extends AbstractJmxAttribute {
|
||||
return this.persistPeriod;
|
||||
}
|
||||
|
||||
public void setPersistName(String persistName) {
|
||||
public void setPersistName(@Nullable String persistName) {
|
||||
this.persistName = persistName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPersistName() {
|
||||
return this.persistName;
|
||||
}
|
||||
|
||||
public void setPersistLocation(String persistLocation) {
|
||||
public void setPersistLocation(@Nullable String persistLocation) {
|
||||
this.persistLocation = persistLocation;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPersistLocation() {
|
||||
return this.persistLocation;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 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,9 +29,9 @@ import javax.naming.NamingException;
|
||||
@SuppressWarnings("serial")
|
||||
public class TypeMismatchNamingException extends NamingException {
|
||||
|
||||
private Class<?> requiredType;
|
||||
private final Class<?> requiredType;
|
||||
|
||||
private Class<?> actualType;
|
||||
private final Class<?> actualType;
|
||||
|
||||
|
||||
/**
|
||||
@@ -48,14 +48,6 @@ public class TypeMismatchNamingException extends NamingException {
|
||||
this.actualType = actualType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new TypeMismatchNamingException.
|
||||
* @param explanation the explanation text
|
||||
*/
|
||||
public TypeMismatchNamingException(String explanation) {
|
||||
super(explanation);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the required type for the lookup, if available.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -20,6 +20,7 @@ import java.io.Serializable;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Encapsulates a remote invocation result, holding a result value or an exception.
|
||||
@@ -53,7 +54,7 @@ public class RemoteInvocationResult implements Serializable {
|
||||
* @param value the result value returned by a successful invocation
|
||||
* of the target method
|
||||
*/
|
||||
public RemoteInvocationResult(Object value) {
|
||||
public RemoteInvocationResult(@Nullable Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@@ -62,7 +63,7 @@ public class RemoteInvocationResult implements Serializable {
|
||||
* @param exception the exception thrown by an unsuccessful invocation
|
||||
* of the target method
|
||||
*/
|
||||
public RemoteInvocationResult(Throwable exception) {
|
||||
public RemoteInvocationResult(@Nullable Throwable exception) {
|
||||
this.exception = exception;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -88,17 +88,19 @@ public class ConcurrentTaskExecutor implements AsyncListenableTaskExecutor, Sche
|
||||
* @see java.util.concurrent.Executors#newSingleThreadExecutor()
|
||||
*/
|
||||
public ConcurrentTaskExecutor() {
|
||||
setConcurrentExecutor(null);
|
||||
this.concurrentExecutor = Executors.newSingleThreadExecutor();
|
||||
this.adaptedExecutor = new TaskExecutorAdapter(this.concurrentExecutor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ConcurrentTaskExecutor, using the given {@link java.util.concurrent.Executor}.
|
||||
* <p>Autodetects a JSR-236 {@link javax.enterprise.concurrent.ManagedExecutorService}
|
||||
* in order to expose {@link javax.enterprise.concurrent.ManagedTask} adapters for it.
|
||||
* @param concurrentExecutor the {@link java.util.concurrent.Executor} to delegate to
|
||||
* @param executor the {@link java.util.concurrent.Executor} to delegate to
|
||||
*/
|
||||
public ConcurrentTaskExecutor(Executor concurrentExecutor) {
|
||||
setConcurrentExecutor(concurrentExecutor);
|
||||
public ConcurrentTaskExecutor(@Nullable Executor executor) {
|
||||
this.concurrentExecutor = (executor != null ? executor : Executors.newSingleThreadExecutor());
|
||||
this.adaptedExecutor = getAdaptedExecutor(this.concurrentExecutor);
|
||||
}
|
||||
|
||||
|
||||
@@ -107,20 +109,9 @@ public class ConcurrentTaskExecutor implements AsyncListenableTaskExecutor, Sche
|
||||
* <p>Autodetects a JSR-236 {@link javax.enterprise.concurrent.ManagedExecutorService}
|
||||
* in order to expose {@link javax.enterprise.concurrent.ManagedTask} adapters for it.
|
||||
*/
|
||||
public final void setConcurrentExecutor(@Nullable Executor concurrentExecutor) {
|
||||
if (concurrentExecutor != null) {
|
||||
this.concurrentExecutor = concurrentExecutor;
|
||||
if (managedExecutorServiceClass != null && managedExecutorServiceClass.isInstance(concurrentExecutor)) {
|
||||
this.adaptedExecutor = new ManagedTaskExecutorAdapter(concurrentExecutor);
|
||||
}
|
||||
else {
|
||||
this.adaptedExecutor = new TaskExecutorAdapter(concurrentExecutor);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.concurrentExecutor = Executors.newSingleThreadExecutor();
|
||||
this.adaptedExecutor = new TaskExecutorAdapter(this.concurrentExecutor);
|
||||
}
|
||||
public final void setConcurrentExecutor(@Nullable Executor executor) {
|
||||
this.concurrentExecutor = (executor != null ? executor : Executors.newSingleThreadExecutor());
|
||||
this.adaptedExecutor = getAdaptedExecutor(this.concurrentExecutor);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,6 +175,14 @@ public class ConcurrentTaskExecutor implements AsyncListenableTaskExecutor, Sche
|
||||
}
|
||||
|
||||
|
||||
private static TaskExecutorAdapter getAdaptedExecutor(Executor concurrentExecutor) {
|
||||
if (managedExecutorServiceClass != null && managedExecutorServiceClass.isInstance(concurrentExecutor)) {
|
||||
return new ManagedTaskExecutorAdapter(concurrentExecutor);
|
||||
}
|
||||
return new TaskExecutorAdapter(concurrentExecutor);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TaskExecutorAdapter subclass that wraps all provided Runnables and Callables
|
||||
* with a JSR-236 ManagedTask, exposing a long-running hint based on
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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,6 +22,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A Spring {@link FactoryBean} that builds and exposes a preconfigured {@link ForkJoinPool}.
|
||||
@@ -43,12 +44,14 @@ public class ForkJoinPoolFactoryBean implements FactoryBean<ForkJoinPool>, Initi
|
||||
|
||||
private ForkJoinPool.ForkJoinWorkerThreadFactory threadFactory = ForkJoinPool.defaultForkJoinWorkerThreadFactory;
|
||||
|
||||
@Nullable
|
||||
private Thread.UncaughtExceptionHandler uncaughtExceptionHandler;
|
||||
|
||||
private boolean asyncMode = false;
|
||||
|
||||
private int awaitTerminationSeconds = 0;
|
||||
|
||||
@Nullable
|
||||
private ForkJoinPool forkJoinPool;
|
||||
|
||||
|
||||
@@ -148,16 +151,18 @@ public class ForkJoinPoolFactoryBean implements FactoryBean<ForkJoinPool>, Initi
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
// Ignored for the common pool.
|
||||
this.forkJoinPool.shutdown();
|
||||
if (this.forkJoinPool != null) {
|
||||
// Ignored for the common pool.
|
||||
this.forkJoinPool.shutdown();
|
||||
|
||||
// Wait for all tasks to terminate - works for the common pool as well.
|
||||
if (this.awaitTerminationSeconds > 0) {
|
||||
try {
|
||||
this.forkJoinPool.awaitTermination(this.awaitTerminationSeconds, TimeUnit.SECONDS);
|
||||
}
|
||||
catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
// Wait for all tasks to terminate - works for the common pool as well.
|
||||
if (this.awaitTerminationSeconds > 0) {
|
||||
try {
|
||||
this.forkJoinPool.awaitTermination(this.awaitTerminationSeconds, TimeUnit.SECONDS);
|
||||
}
|
||||
catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.scheduling.concurrent;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* JavaBean that describes a scheduled executor task, consisting of the
|
||||
@@ -40,6 +41,7 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
public class ScheduledExecutorTask {
|
||||
|
||||
@Nullable
|
||||
private Runnable runnable;
|
||||
|
||||
private long delay = 0;
|
||||
@@ -107,6 +109,7 @@ public class ScheduledExecutorTask {
|
||||
* Return the Runnable to schedule as executor task.
|
||||
*/
|
||||
public Runnable getRunnable() {
|
||||
Assert.state(this.runnable != null, "No Runnable set");
|
||||
return this.runnable;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -18,6 +18,7 @@ package org.springframework.scheduling.support;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.scheduling.TriggerContext;
|
||||
|
||||
/**
|
||||
@@ -28,10 +29,13 @@ import org.springframework.scheduling.TriggerContext;
|
||||
*/
|
||||
public class SimpleTriggerContext implements TriggerContext {
|
||||
|
||||
@Nullable
|
||||
private volatile Date lastScheduledExecutionTime;
|
||||
|
||||
@Nullable
|
||||
private volatile Date lastActualExecutionTime;
|
||||
|
||||
@Nullable
|
||||
private volatile Date lastCompletionTime;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -28,6 +28,7 @@ import org.springframework.lang.Nullable;
|
||||
@SuppressWarnings("serial")
|
||||
public class ScriptCompilationException extends NestedRuntimeException {
|
||||
|
||||
@Nullable
|
||||
private ScriptSource scriptSource;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -38,6 +38,7 @@ import org.springframework.scripting.ScriptSource;
|
||||
*/
|
||||
public class BshScriptEvaluator implements ScriptEvaluator, BeanClassLoaderAware {
|
||||
|
||||
@Nullable
|
||||
private ClassLoader classLoader;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -49,19 +49,19 @@ public class ExtendedModelMap extends ModelMap implements Model {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExtendedModelMap addAllAttributes(Collection<?> attributeValues) {
|
||||
public ExtendedModelMap addAllAttributes(@Nullable Collection<?> attributeValues) {
|
||||
super.addAllAttributes(attributeValues);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExtendedModelMap addAllAttributes(Map<String, ?> attributes) {
|
||||
public ExtendedModelMap addAllAttributes(@Nullable Map<String, ?> attributes) {
|
||||
super.addAllAttributes(attributes);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExtendedModelMap mergeAttributes(Map<String, ?> attributes) {
|
||||
public ExtendedModelMap mergeAttributes(@Nullable Map<String, ?> attributes) {
|
||||
super.mergeAttributes(attributes);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ public class MethodValidationPostProcessor extends AbstractBeanFactoryAwareAdvis
|
||||
|
||||
private Class<? extends Annotation> validatedAnnotationType = Validated.class;
|
||||
|
||||
@Nullable
|
||||
private Validator validator;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user