Add @Override annotations to main sources

Issue: SPR-10130
This commit is contained in:
Chris Beams
2012-12-28 14:00:16 +01:00
parent 9c2046c3ee
commit 3b40ce76bf
1256 changed files with 5716 additions and 0 deletions

View File

@@ -50,6 +50,7 @@ public abstract class AbstractCachingConfiguration implements ImportAware {
@Autowired(required=false)
private Collection<CachingConfigurer> cachingConfigurers;
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
this.enableCaching = AnnotationAttributes.fromMap(
importMetadata.getAnnotationAttributes(EnableCaching.class.getName(), false));

View File

@@ -39,6 +39,7 @@ public class CachingConfigurationSelector extends AdviceModeImportSelector<Enabl
* @return {@link ProxyCachingConfiguration} or {@code AspectJCacheConfiguration} for
* {@code PROXY} and {@code ASPECTJ} values of {@link EnableCaching#mode()}, respectively
*/
@Override
public String[] selectImports(AdviceMode adviceMode) {
switch (adviceMode) {
case PROXY:

View File

@@ -40,6 +40,7 @@ import org.springframework.util.ObjectUtils;
@SuppressWarnings("serial")
public class SpringCacheAnnotationParser implements CacheAnnotationParser, Serializable {
@Override
public Collection<CacheOperation> parseCacheAnnotations(AnnotatedElement ae) {
Collection<CacheOperation> ops = null;

View File

@@ -83,10 +83,12 @@ public class ConcurrentMapCache implements Cache {
}
@Override
public String getName() {
return this.name;
}
@Override
public ConcurrentMap getNativeCache() {
return this.store;
}
@@ -95,19 +97,23 @@ public class ConcurrentMapCache implements Cache {
return this.allowNullValues;
}
@Override
public ValueWrapper get(Object key) {
Object value = this.store.get(key);
return (value != null ? new SimpleValueWrapper(fromStoreValue(value)) : null);
}
@Override
public void put(Object key, Object value) {
this.store.put(key, toStoreValue(value));
}
@Override
public void evict(Object key) {
this.store.remove(key);
}
@Override
public void clear() {
this.store.clear();
}

View File

@@ -74,26 +74,31 @@ public class ConcurrentMapCacheFactoryBean
this.allowNullValues = allowNullValues;
}
@Override
public void setBeanName(String beanName) {
if (!StringUtils.hasLength(this.name)) {
setName(beanName);
}
}
@Override
public void afterPropertiesSet() {
this.cache = (this.store != null ? new ConcurrentMapCache(this.name, this.store, this.allowNullValues) :
new ConcurrentMapCache(this.name, this.allowNullValues));
}
@Override
public ConcurrentMapCache getObject() {
return this.cache;
}
@Override
public Class<?> getObjectType() {
return ConcurrentMapCache.class;
}
@Override
public boolean isSingleton() {
return true;
}

View File

@@ -71,10 +71,12 @@ public class ConcurrentMapCacheManager implements CacheManager {
}
}
@Override
public Collection<String> getCacheNames() {
return Collections.unmodifiableSet(this.cacheMap.keySet());
}
@Override
public Cache getCache(String name) {
Cache cache = this.cacheMap.get(name);
if (cache == null && this.dynamic) {

View File

@@ -53,6 +53,7 @@ class AnnotationDrivenCacheBeanDefinitionParser implements BeanDefinitionParser
* {@link AopNamespaceUtils#registerAutoProxyCreatorIfNecessary
* register an AutoProxyCreator} with the container as necessary.
*/
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
String mode = element.getAttribute("mode");
if ("aspectj".equals(mode)) {

View File

@@ -51,6 +51,7 @@ public class CacheNamespaceHandler extends NamespaceHandlerSupport {
return def;
}
@Override
public void init() {
registerBeanDefinitionParser("annotation-driven", new AnnotationDrivenCacheBeanDefinitionParser());
registerBeanDefinitionParser("advice", new CacheAdviceParser());

View File

@@ -84,6 +84,7 @@ public abstract class AbstractFallbackCacheOperationSource implements CacheOpera
* @return {@link CacheOperation} for this method, or {@code null} if the method
* is not cacheable
*/
@Override
public Collection<CacheOperation> getCacheOperations(Method method, Class<?> targetClass) {
// First, see if we have a cached value.
Object cacheKey = getCacheKey(method, targetClass);

View File

@@ -57,6 +57,7 @@ public class BeanFactoryCacheOperationSourceAdvisor extends AbstractBeanFactoryP
this.pointcut.setClassFilter(classFilter);
}
@Override
public Pointcut getPointcut() {
return this.pointcut;
}

View File

@@ -128,6 +128,7 @@ public abstract class CacheAspectSupport implements InitializingBean {
return this.keyGenerator;
}
@Override
public void afterPropertiesSet() {
if (this.cacheManager == null) {
throw new IllegalStateException("'cacheManager' is required");

View File

@@ -49,10 +49,12 @@ public class CacheInterceptor extends CacheAspectSupport implements MethodInterc
}
}
@Override
public Object invoke(final MethodInvocation invocation) throws Throwable {
Method method = invocation.getMethod();
Invoker aopAllianceInvoker = new Invoker() {
@Override
public Object invoke() {
try {
return invocation.proceed();

View File

@@ -33,6 +33,7 @@ import org.springframework.util.ObjectUtils;
@SuppressWarnings("serial")
abstract class CacheOperationSourcePointcut extends StaticMethodMatcherPointcut implements Serializable {
@Override
public boolean matches(Method method, Class<?> targetClass) {
CacheOperationSource cas = getCacheOperationSource();
return (cas != null && !CollectionUtils.isEmpty(cas.getCacheOperations(method, targetClass)));

View File

@@ -52,6 +52,7 @@ public class CompositeCacheOperationSource implements CacheOperationSource, Seri
return this.cacheOperationSources;
}
@Override
public Collection<CacheOperation> getCacheOperations(Method method, Class<?> targetClass) {
Collection<CacheOperation> ops = null;

View File

@@ -36,6 +36,7 @@ public class DefaultKeyGenerator implements KeyGenerator {
public static final int NO_PARAM_KEY = 0;
public static final int NULL_PARAM_KEY = 53;
@Override
public Object generate(Object target, Method method, Object... params) {
if (params.length == 1) {
return (params[0] == null ? NULL_PARAM_KEY : params[0]);

View File

@@ -71,6 +71,7 @@ public class NameMatchCacheOperationSource implements CacheOperationSource, Seri
this.nameMap.put(methodName, ops);
}
@Override
public Collection<CacheOperation> getCacheOperations(Method method, Class<?> targetClass) {
// look for direct name match
String methodName = method.getName();

View File

@@ -43,6 +43,7 @@ public abstract class AbstractCacheManager implements CacheManager, Initializing
private Set<String> cacheNames = new LinkedHashSet<String>(16);
@Override
public void afterPropertiesSet() {
Collection<? extends Cache> caches = loadCaches();
Assert.notEmpty(caches, "loadCaches must not return an empty Collection");
@@ -71,10 +72,12 @@ public abstract class AbstractCacheManager implements CacheManager, Initializing
}
@Override
public Cache getCache(String name) {
return this.cacheMap.get(name);
}
@Override
public Collection<String> getCacheNames() {
return Collections.unmodifiableSet(this.cacheNames);
}

View File

@@ -59,6 +59,7 @@ public class CompositeCacheManager implements InitializingBean, CacheManager {
this.fallbackToNoOpCache = fallbackToNoOpCache;
}
@Override
public void afterPropertiesSet() {
if (this.fallbackToNoOpCache) {
this.cacheManagers.add(new NoOpCacheManager());
@@ -66,6 +67,7 @@ public class CompositeCacheManager implements InitializingBean, CacheManager {
}
@Override
public Cache getCache(String name) {
for (CacheManager cacheManager : this.cacheManagers) {
Cache cache = cacheManager.getCache(name);
@@ -76,6 +78,7 @@ public class CompositeCacheManager implements InitializingBean, CacheManager {
return null;
}
@Override
public Collection<String> getCacheNames() {
List<String> names = new ArrayList<String>();
for (CacheManager manager : this.cacheManagers) {

View File

@@ -48,6 +48,7 @@ public class NoOpCacheManager implements CacheManager {
* This implementation always returns a {@link Cache} implementation that will not store items.
* Additionally, the request cache will be remembered by the manager for consistency.
*/
@Override
public Cache getCache(String name) {
Cache cache = this.caches.get(name);
if (cache == null) {
@@ -63,6 +64,7 @@ public class NoOpCacheManager implements CacheManager {
/**
* This implementation returns the name of the caches previously requested.
*/
@Override
public Collection<String> getCacheNames() {
synchronized (this.cacheNames) {
return Collections.unmodifiableSet(this.cacheNames);
@@ -78,24 +80,30 @@ public class NoOpCacheManager implements CacheManager {
this.name = name;
}
@Override
public void clear() {
}
@Override
public void evict(Object key) {
}
@Override
public ValueWrapper get(Object key) {
return null;
}
@Override
public String getName() {
return this.name;
}
@Override
public Object getNativeCache() {
return null;
}
@Override
public void put(Object key, Object value) {
}
}

View File

@@ -42,6 +42,7 @@ public class SimpleValueWrapper implements ValueWrapper {
/**
* Simply returns the value as given at construction time.
*/
@Override
public Object get() {
return this.value;
}

View File

@@ -100,6 +100,7 @@ public interface ConfigurableApplicationContext extends ApplicationContext, Life
/**
* Return the Environment for this application context in configurable form.
*/
@Override
ConfigurableEnvironment getEnvironment();
/**
@@ -158,6 +159,7 @@ public interface ConfigurableApplicationContext extends ApplicationContext, Life
* <p>This method can be called multiple times without side effects: Subsequent
* {@code close} calls on an already closed context will be ignored.
*/
@Override
void close();
/**

View File

@@ -48,6 +48,7 @@ public class ContextBeanFactoryReference implements BeanFactoryReference {
}
@Override
public BeanFactory getFactory() {
if (this.applicationContext == null) {
throw new IllegalStateException(
@@ -56,6 +57,7 @@ public class ContextBeanFactoryReference implements BeanFactoryReference {
return this.applicationContext;
}
@Override
public void release() {
if (this.applicationContext != null) {
ApplicationContext savedCtx;

View File

@@ -57,6 +57,7 @@ public class ContextJndiBeanFactoryLocator extends JndiLocatorSupport implements
* will be created from the combined resources.
* @see #createBeanFactory
*/
@Override
public BeanFactoryReference useBeanFactory(String factoryKey) throws BeansException {
try {
String beanFactoryPath = lookup(factoryKey, String.class);

View File

@@ -65,6 +65,7 @@ public abstract class AdviceModeImportSelector<A extends Annotation> implements
* on the importing {@code @Configuration} class or if {@link #selectImports(AdviceMode)}
* returns {@code null}
*/
@Override
public final String[] selectImports(AnnotationMetadata importingClassMetadata) {
Class<?> annoType = GenericTypeResolver.resolveTypeArgument(this.getClass(), AdviceModeImportSelector.class);

View File

@@ -64,6 +64,7 @@ public class AnnotationBeanNameGenerator implements BeanNameGenerator {
private static final String COMPONENT_ANNOTATION_CLASSNAME = "org.springframework.stereotype.Component";
@Override
public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
if (definition instanceof AnnotatedBeanDefinition) {
String beanName = determineBeanNameFromAnnotation((AnnotatedBeanDefinition) definition);

View File

@@ -38,6 +38,7 @@ import org.springframework.beans.factory.xml.ParserContext;
*/
public class AnnotationConfigBeanDefinitionParser implements BeanDefinitionParser {
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
Object source = parserContext.extractSource(element);

View File

@@ -73,6 +73,7 @@ public class AnnotationScopeMetadataResolver implements ScopeMetadataResolver {
}
@Override
public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
ScopeMetadata metadata = new ScopeMetadata();
if (definition instanceof AnnotatedBeanDefinition) {

View File

@@ -39,6 +39,7 @@ class AspectJAutoProxyRegistrar implements ImportBeanDefinitionRegistrar {
* of the @{@link EnableAspectJAutoProxy#proxyTargetClass()} attribute on the importing
* {@code @Configuration} class.
*/
@Override
public void registerBeanDefinitions(
AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {

View File

@@ -56,6 +56,7 @@ public class AutoProxyRegistrar implements ImportBeanDefinitionRegistrar {
* {@code proxyTargetClass} attributes, the APC can be registered and configured all
* the same.
*/
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
boolean candidateFound = false;
Set<String> annoTypes = importingClassMetadata.getAnnotationTypes();

View File

@@ -117,6 +117,7 @@ public class ClassPathScanningCandidateComponentProvider implements EnvironmentC
* @see org.springframework.core.io.support.ResourcePatternResolver
* @see org.springframework.core.io.support.PathMatchingResourcePatternResolver
*/
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
this.metadataReaderFactory = new CachingMetadataReaderFactory(resourceLoader);
@@ -157,6 +158,7 @@ public class ClassPathScanningCandidateComponentProvider implements EnvironmentC
this.environment = environment;
}
@Override
public final Environment getEnvironment() {
return this.environment;
}

View File

@@ -269,6 +269,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
this.resourceFactory = resourceFactory;
}
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
Assert.notNull(beanFactory, "BeanFactory must not be null");
this.beanFactory = beanFactory;
@@ -287,14 +288,17 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
}
}
@Override
public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
return null;
}
@Override
public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException {
return true;
}
@Override
public PropertyValues postProcessPropertyValues(
PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException {

View File

@@ -75,6 +75,7 @@ public class ComponentScanBeanDefinitionParser implements BeanDefinitionParser {
private static final String FILTER_EXPRESSION_ATTRIBUTE = "expression";
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
String[] basePackages = StringUtils.tokenizeToStringArray(element.getAttribute(BASE_PACKAGE_ATTRIBUTE),
ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS);

View File

@@ -318,6 +318,7 @@ class ConfigurationClassBeanDefinitionReader {
this.annotationMetadata = original.annotationMetadata;
}
@Override
public AnnotationMetadata getMetadata() {
return this.annotationMetadata;
}

View File

@@ -56,6 +56,7 @@ class ConfigurationClassEnhancer {
DisposableBeanMethodInterceptor.class, NoOp.class };
private static final CallbackFilter CALLBACK_FILTER = new CallbackFilter() {
@Override
public int accept(Method candidateMethod) {
// Set up the callback filter to return the index of the BeanMethodInterceptor when
// handling a @Bean-annotated method; otherwise, return index of the NoOp callback.
@@ -168,6 +169,7 @@ class ConfigurationClassEnhancer {
this.beanName = beanName;
}
@Override
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
return beanFactory.getBean(beanName);
}
@@ -183,6 +185,7 @@ class ConfigurationClassEnhancer {
*/
private static class DisposableBeanMethodInterceptor implements MethodInterceptor {
@Override
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
Enhancer.registerStaticCallbacks(obj.getClass(), null);
// does the actual (non-CGLIB) superclass actually implement DisposableBean?
@@ -213,6 +216,7 @@ class ConfigurationClassEnhancer {
GetObjectMethodInterceptor.class, NoOp.class };
private static final CallbackFilter CALLBACK_FITLER = new CallbackFilter() {
@Override
public int accept(Method method) {
return method.getName().equals("getObject") ? 0 : 1;
}
@@ -234,6 +238,7 @@ class ConfigurationClassEnhancer {
* invoking the super implementation of the proxied method i.e., the actual
* {@code @Bean} method.
*/
@Override
public Object intercept(Object enhancedConfigInstance, Method beanMethod, Object[] beanMethodArgs,
MethodProxy cglibMethodProxy) throws Throwable {

View File

@@ -413,6 +413,7 @@ class ConfigurationClassParser {
this.imports.put(importedClass, importingClass);
}
@Override
public String getImportingClassFor(String importedClass) {
return this.imports.get(importedClass);
}
@@ -426,6 +427,7 @@ class ConfigurationClassParser {
public boolean contains(Object elem) {
ConfigurationClass configClass = (ConfigurationClass) elem;
Comparator<ConfigurationClass> comparator = new Comparator<ConfigurationClass>() {
@Override
public int compare(ConfigurationClass first, ConfigurationClass second) {
return first.getMetadata().getClassName().equals(second.getMetadata().getClassName()) ? 0 : 1;
}

View File

@@ -183,16 +183,19 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
this.importBeanNameGenerator = beanNameGenerator;
}
@Override
public void setEnvironment(Environment environment) {
Assert.notNull(environment, "Environment must not be null");
this.environment = environment;
}
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
Assert.notNull(resourceLoader, "ResourceLoader must not be null");
this.resourceLoader = resourceLoader;
}
@Override
public void setBeanClassLoader(ClassLoader beanClassLoader) {
this.beanClassLoader = beanClassLoader;
if (!this.setMetadataReaderFactoryCalled) {
@@ -204,6 +207,7 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
/**
* Derive further bean definitions from the configuration classes in the registry.
*/
@Override
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) {
RootBeanDefinition iabpp = new RootBeanDefinition(ImportAwareBeanPostProcessor.class);
iabpp.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
@@ -227,6 +231,7 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
* Prepare the Configuration classes for servicing bean requests at runtime
* by replacing them with CGLIB-enhanced subclasses.
*/
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
int factoryId = System.identityHashCode(beanFactory);
if (this.factoriesPostProcessed.contains(factoryId)) {
@@ -373,10 +378,12 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
private BeanFactory beanFactory;
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
this.beanFactory = beanFactory;
}
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof ImportAware) {
ImportRegistry importRegistry = this.beanFactory.getBean(IMPORT_REGISTRY_BEAN_NAME, ImportRegistry.class);
@@ -399,10 +406,12 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
@Override
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE;
}

View File

@@ -81,6 +81,7 @@ public class Jsr330ScopeMetadataResolver implements ScopeMetadataResolver {
}
@Override
public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
ScopeMetadata metadata = new ScopeMetadata();
metadata.setScopeName(BeanDefinition.SCOPE_PROTOTYPE);

View File

@@ -52,6 +52,7 @@ public class LoadTimeWeavingConfiguration implements ImportAware, BeanClassLoade
private ClassLoader beanClassLoader;
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
this.enableLTW = MetadataUtils.attributesFor(importMetadata, EnableLoadTimeWeaving.class);
Assert.notNull(this.enableLTW,
@@ -59,6 +60,7 @@ public class LoadTimeWeavingConfiguration implements ImportAware, BeanClassLoade
importMetadata.getClassName());
}
@Override
public void setBeanClassLoader(ClassLoader beanClassLoader) {
this.beanClassLoader = beanClassLoader;
}

View File

@@ -56,6 +56,7 @@ public class MBeanExportConfiguration implements ImportAware, BeanFactoryAware {
private BeanFactory beanFactory;
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
Map<String, Object> map = importMetadata.getAnnotationAttributes(EnableMBeanExport.class.getName());
this.attributes = AnnotationAttributes.fromMap(map);
@@ -63,6 +64,7 @@ public class MBeanExportConfiguration implements ImportAware, BeanFactoryAware {
"importing class " + importMetadata.getClassName());
}
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
this.beanFactory = beanFactory;
}

View File

@@ -61,6 +61,7 @@ public class ScannedGenericBeanDefinition extends GenericBeanDefinition implemen
}
@Override
public final AnnotationMetadata getMetadata() {
return this.metadata;
}

View File

@@ -30,6 +30,7 @@ import org.springframework.context.annotation.ComponentScanBeanDefinitionParser;
*/
public class ContextNamespaceHandler extends NamespaceHandlerSupport {
@Override
public void init() {
registerBeanDefinitionParser("property-placeholder", new PropertyPlaceholderBeanDefinitionParser());
registerBeanDefinitionParser("property-override", new PropertyOverrideBeanDefinitionParser());

View File

@@ -43,6 +43,7 @@ class SpringConfiguredBeanDefinitionParser implements BeanDefinitionParser {
"org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect";
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
if (!parserContext.getRegistry().containsBeanDefinition(BEAN_CONFIGURER_ASPECT_BEAN_NAME)) {
RootBeanDefinition def = new RootBeanDefinition();

View File

@@ -58,6 +58,7 @@ public abstract class AbstractApplicationEventMulticaster implements Application
private BeanFactory beanFactory;
@Override
public void addApplicationListener(ApplicationListener listener) {
synchronized (this.defaultRetriever) {
this.defaultRetriever.applicationListeners.add(listener);
@@ -65,6 +66,7 @@ public abstract class AbstractApplicationEventMulticaster implements Application
}
}
@Override
public void addApplicationListenerBean(String listenerBeanName) {
synchronized (this.defaultRetriever) {
this.defaultRetriever.applicationListenerBeans.add(listenerBeanName);
@@ -72,6 +74,7 @@ public abstract class AbstractApplicationEventMulticaster implements Application
}
}
@Override
public void removeApplicationListener(ApplicationListener listener) {
synchronized (this.defaultRetriever) {
this.defaultRetriever.applicationListeners.remove(listener);
@@ -79,6 +82,7 @@ public abstract class AbstractApplicationEventMulticaster implements Application
}
}
@Override
public void removeApplicationListenerBean(String listenerBeanName) {
synchronized (this.defaultRetriever) {
this.defaultRetriever.applicationListenerBeans.remove(listenerBeanName);
@@ -86,6 +90,7 @@ public abstract class AbstractApplicationEventMulticaster implements Application
}
}
@Override
public void removeAllListeners() {
synchronized (this.defaultRetriever) {
this.defaultRetriever.applicationListeners.clear();
@@ -94,6 +99,7 @@ public abstract class AbstractApplicationEventMulticaster implements Application
}
}
@Override
public final void setBeanFactory(BeanFactory beanFactory) {
this.beanFactory = beanFactory;
}

View File

@@ -77,10 +77,12 @@ public class EventPublicationInterceptor
}
}
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.applicationEventPublisher = applicationEventPublisher;
}
@Override
public void afterPropertiesSet() throws Exception {
if (this.applicationEventClassConstructor == null) {
throw new IllegalArgumentException("applicationEventClass is required");
@@ -88,6 +90,7 @@ public class EventPublicationInterceptor
}
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
Object retVal = invocation.proceed();

View File

@@ -46,11 +46,13 @@ public class GenericApplicationListenerAdapter implements SmartApplicationListen
}
@Override
@SuppressWarnings("unchecked")
public void onApplicationEvent(ApplicationEvent event) {
this.delegate.onApplicationEvent(event);
}
@Override
public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) {
Class typeArg = GenericTypeResolver.resolveTypeArgument(this.delegate.getClass(), ApplicationListener.class);
if (typeArg == null || typeArg.equals(ApplicationEvent.class)) {
@@ -62,10 +64,12 @@ public class GenericApplicationListenerAdapter implements SmartApplicationListen
return (typeArg == null || typeArg.isAssignableFrom(eventType));
}
@Override
public boolean supportsSourceType(Class<?> sourceType) {
return true;
}
@Override
public int getOrder() {
return (this.delegate instanceof Ordered ? ((Ordered) this.delegate).getOrder() : Ordered.LOWEST_PRECEDENCE);
}

View File

@@ -81,12 +81,14 @@ public class SimpleApplicationEventMulticaster extends AbstractApplicationEventM
}
@Override
@SuppressWarnings("unchecked")
public void multicastEvent(final ApplicationEvent event) {
for (final ApplicationListener listener : getApplicationListeners(event)) {
Executor executor = getTaskExecutor();
if (executor != null) {
executor.execute(new Runnable() {
@Override
@SuppressWarnings("unchecked")
public void run() {
listener.onApplicationEvent(event);

View File

@@ -63,20 +63,24 @@ public class SourceFilteringListener implements SmartApplicationListener {
}
@Override
public void onApplicationEvent(ApplicationEvent event) {
if (event.getSource() == this.source) {
onApplicationEventInternal(event);
}
}
@Override
public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) {
return (this.delegate == null || this.delegate.supportsEventType(eventType));
}
@Override
public boolean supportsSourceType(Class<?> sourceType) {
return sourceType.isInstance(this.source);
}
@Override
public int getOrder() {
return (this.delegate != null ? this.delegate.getOrder() : Ordered.LOWEST_PRECEDENCE);
}

View File

@@ -32,22 +32,27 @@ import org.springframework.expression.TypedValue;
*/
public class BeanExpressionContextAccessor implements PropertyAccessor {
@Override
public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException {
return ((BeanExpressionContext) target).containsObject(name);
}
@Override
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
return new TypedValue(((BeanExpressionContext) target).getObject(name));
}
@Override
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {
return false;
}
@Override
public void write(EvaluationContext context, Object target, String name, Object newValue) throws AccessException {
throw new AccessException("Beans in a BeanFactory are read-only");
}
@Override
public Class[] getSpecificTargetClasses() {
return new Class[] {BeanExpressionContext.class};
}

View File

@@ -32,22 +32,27 @@ import org.springframework.expression.TypedValue;
*/
public class BeanFactoryAccessor implements PropertyAccessor {
@Override
public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException {
return (((BeanFactory) target).containsBean(name));
}
@Override
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
return new TypedValue(((BeanFactory) target).getBean(name));
}
@Override
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {
return false;
}
@Override
public void write(EvaluationContext context, Object target, String name, Object newValue) throws AccessException {
throw new AccessException("Beans in a BeanFactory are read-only");
}
@Override
public Class[] getSpecificTargetClasses() {
return new Class[] {BeanFactory.class};
}

View File

@@ -39,6 +39,7 @@ public class BeanFactoryResolver implements BeanResolver {
this.beanFactory = beanFactory;
}
@Override
public Object resolve(EvaluationContext context, String beanName) throws AccessException {
try {
return this.beanFactory.getBean(beanName);

View File

@@ -31,6 +31,7 @@ import org.springframework.expression.TypedValue;
*/
public class EnvironmentAccessor implements PropertyAccessor {
@Override
public Class<?>[] getSpecificTargetClasses() {
return new Class[] { Environment.class };
}
@@ -39,6 +40,7 @@ public class EnvironmentAccessor implements PropertyAccessor {
* Can read any {@link Environment}, thus always returns true.
* @return true
*/
@Override
public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException {
return true;
}
@@ -47,6 +49,7 @@ public class EnvironmentAccessor implements PropertyAccessor {
* Access the given target object by resolving the given property name against the given target
* environment.
*/
@Override
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
return new TypedValue(((Environment)target).getProperty(name));
}
@@ -55,6 +58,7 @@ public class EnvironmentAccessor implements PropertyAccessor {
* Read only.
* @return false
*/
@Override
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {
return false;
}
@@ -62,6 +66,7 @@ public class EnvironmentAccessor implements PropertyAccessor {
/**
* Read only. No-op.
*/
@Override
public void write(EvaluationContext context, Object target, String name, Object newValue) throws AccessException {
}

View File

@@ -33,11 +33,13 @@ import org.springframework.expression.TypedValue;
*/
public class MapAccessor implements PropertyAccessor {
@Override
public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException {
Map map = (Map) target;
return map.containsKey(name);
}
@Override
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
Map map = (Map) target;
Object value = map.get(name);
@@ -47,16 +49,19 @@ public class MapAccessor implements PropertyAccessor {
return new TypedValue(value);
}
@Override
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {
return true;
}
@Override
@SuppressWarnings("unchecked")
public void write(EvaluationContext context, Object target, String name, Object newValue) throws AccessException {
Map map = (Map) target;
map.put(name, newValue);
}
@Override
public Class[] getSpecificTargetClasses() {
return new Class[] {Map.class};
}

View File

@@ -66,12 +66,15 @@ public class StandardBeanExpressionResolver implements BeanExpressionResolver {
new ConcurrentHashMap<BeanExpressionContext, StandardEvaluationContext>(8);
private final ParserContext beanExpressionParserContext = new ParserContext() {
@Override
public boolean isTemplate() {
return true;
}
@Override
public String getExpressionPrefix() {
return expressionPrefix;
}
@Override
public String getExpressionSuffix() {
return expressionSuffix;
}
@@ -109,6 +112,7 @@ public class StandardBeanExpressionResolver implements BeanExpressionResolver {
}
@Override
public Object evaluate(String value, BeanExpressionContext evalContext) throws BeansException {
if (!StringUtils.hasLength(value)) {
return value;

View File

@@ -42,6 +42,7 @@ public class SimpleLocaleContext implements LocaleContext {
this.locale = locale;
}
@Override
public Locale getLocale() {
return this.locale;
}

View File

@@ -240,14 +240,17 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
* of the context bean if the context is itself defined as a bean.
* @param id the unique id of the context
*/
@Override
public void setId(String id) {
this.id = id;
}
@Override
public String getId() {
return this.id;
}
@Override
public String getApplicationName() {
return "";
}
@@ -266,6 +269,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
* Return a friendly name for this context.
* @return a display name for this context (never {@code null})
*/
@Override
public String getDisplayName() {
return this.displayName;
}
@@ -274,6 +278,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
* Return the parent context, or {@code null} if there is no parent
* (that is, this context is the root of the context hierarchy).
*/
@Override
public ApplicationContext getParent() {
return this.parent;
}
@@ -283,6 +288,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
* <p>If {@code null}, a new environment will be initialized via
* {@link #createEnvironment()}.
*/
@Override
public ConfigurableEnvironment getEnvironment() {
if (this.environment == null) {
this.environment = createEnvironment();
@@ -298,6 +304,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
* should be performed <em>before</em> {@link #refresh()}.
* @see org.springframework.context.support.AbstractApplicationContext#createEnvironment
*/
@Override
public void setEnvironment(ConfigurableEnvironment environment) {
this.environment = environment;
}
@@ -307,6 +314,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
* if already available.
* @see #getBeanFactory()
*/
@Override
public AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws IllegalStateException {
return getBeanFactory();
}
@@ -314,6 +322,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
/**
* Return the timestamp (ms) when this context was first loaded.
*/
@Override
public long getStartupDate() {
return this.startupDate;
}
@@ -326,6 +335,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
* @param event the event to publish (may be application-specific or a
* standard framework event)
*/
@Override
public void publishEvent(ApplicationEvent event) {
Assert.notNull(event, "Event must not be null");
if (logger.isTraceEnabled()) {
@@ -394,6 +404,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
* its environment is an instance of {@link ConfigurableEnvironment}.
* @see ConfigurableEnvironment#merge(ConfigurableEnvironment)
*/
@Override
public void setParent(ApplicationContext parent) {
this.parent = parent;
if (parent != null) {
@@ -404,6 +415,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
}
}
@Override
public void addBeanFactoryPostProcessor(BeanFactoryPostProcessor beanFactoryPostProcessor) {
this.beanFactoryPostProcessors.add(beanFactoryPostProcessor);
}
@@ -417,6 +429,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
return this.beanFactoryPostProcessors;
}
@Override
public void addApplicationListener(ApplicationListener<?> listener) {
if (this.applicationEventMulticaster != null) {
this.applicationEventMulticaster.addApplicationListener(listener);
@@ -442,6 +455,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
return new StandardEnvironment();
}
@Override
public void refresh() throws BeansException, IllegalStateException {
synchronized (this.startupShutdownMonitor) {
// Prepare this context for refreshing.
@@ -971,6 +985,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
* @see #close()
* @see #doClose()
*/
@Override
public void registerShutdownHook() {
if (this.shutdownHook == null) {
// No shutdown hook registered yet.
@@ -994,6 +1009,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
* @see #close()
* @see org.springframework.beans.factory.access.SingletonBeanFactoryLocator
*/
@Override
public void destroy() {
close();
}
@@ -1005,6 +1021,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
* @see #doClose()
* @see #registerShutdownHook()
*/
@Override
public void close() {
synchronized (this.startupShutdownMonitor) {
doClose();
@@ -1102,6 +1119,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
// For subclasses: do nothing by default.
}
@Override
public boolean isActive() {
synchronized (this.activeMonitor) {
return this.active;
@@ -1113,42 +1131,52 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
// Implementation of BeanFactory interface
//---------------------------------------------------------------------
@Override
public Object getBean(String name) throws BeansException {
return getBeanFactory().getBean(name);
}
@Override
public <T> T getBean(String name, Class<T> requiredType) throws BeansException {
return getBeanFactory().getBean(name, requiredType);
}
@Override
public <T> T getBean(Class<T> requiredType) throws BeansException {
return getBeanFactory().getBean(requiredType);
}
@Override
public Object getBean(String name, Object... args) throws BeansException {
return getBeanFactory().getBean(name, args);
}
@Override
public boolean containsBean(String name) {
return getBeanFactory().containsBean(name);
}
@Override
public boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
return getBeanFactory().isSingleton(name);
}
@Override
public boolean isPrototype(String name) throws NoSuchBeanDefinitionException {
return getBeanFactory().isPrototype(name);
}
@Override
public boolean isTypeMatch(String name, Class<?> targetType) throws NoSuchBeanDefinitionException {
return getBeanFactory().isTypeMatch(name, targetType);
}
@Override
public Class<?> getType(String name) throws NoSuchBeanDefinitionException {
return getBeanFactory().getType(name);
}
@Override
public String[] getAliases(String name) {
return getBeanFactory().getAliases(name);
}
@@ -1158,42 +1186,51 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
// Implementation of ListableBeanFactory interface
//---------------------------------------------------------------------
@Override
public boolean containsBeanDefinition(String beanName) {
return getBeanFactory().containsBeanDefinition(beanName);
}
@Override
public int getBeanDefinitionCount() {
return getBeanFactory().getBeanDefinitionCount();
}
@Override
public String[] getBeanDefinitionNames() {
return getBeanFactory().getBeanDefinitionNames();
}
@Override
public String[] getBeanNamesForType(Class<?> type) {
return getBeanFactory().getBeanNamesForType(type);
}
@Override
public String[] getBeanNamesForType(Class<?> type, boolean includeNonSingletons, boolean allowEagerInit) {
return getBeanFactory().getBeanNamesForType(type, includeNonSingletons, allowEagerInit);
}
@Override
public <T> Map<String, T> getBeansOfType(Class<T> type) throws BeansException {
return getBeanFactory().getBeansOfType(type);
}
@Override
public <T> Map<String, T> getBeansOfType(Class<T> type, boolean includeNonSingletons, boolean allowEagerInit)
throws BeansException {
return getBeanFactory().getBeansOfType(type, includeNonSingletons, allowEagerInit);
}
@Override
public Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> annotationType)
throws BeansException {
return getBeanFactory().getBeansWithAnnotation(annotationType);
}
@Override
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType) {
return getBeanFactory().findAnnotationOnBean(beanName, annotationType);
}
@@ -1203,10 +1240,12 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
// Implementation of HierarchicalBeanFactory interface
//---------------------------------------------------------------------
@Override
public BeanFactory getParentBeanFactory() {
return getParent();
}
@Override
public boolean containsLocalBean(String name) {
return getBeanFactory().containsLocalBean(name);
}
@@ -1226,14 +1265,17 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
// Implementation of MessageSource interface
//---------------------------------------------------------------------
@Override
public String getMessage(String code, Object args[], String defaultMessage, Locale locale) {
return getMessageSource().getMessage(code, args, defaultMessage, locale);
}
@Override
public String getMessage(String code, Object args[], Locale locale) throws NoSuchMessageException {
return getMessageSource().getMessage(code, args, locale);
}
@Override
public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException {
return getMessageSource().getMessage(resolvable, locale);
}
@@ -1265,6 +1307,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
// Implementation of ResourcePatternResolver interface
//---------------------------------------------------------------------
@Override
public Resource[] getResources(String locationPattern) throws IOException {
return this.resourcePatternResolver.getResources(locationPattern);
}
@@ -1274,16 +1317,19 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
// Implementation of Lifecycle interface
//---------------------------------------------------------------------
@Override
public void start() {
getLifecycleProcessor().start();
publishEvent(new ContextStartedEvent(this));
}
@Override
public void stop() {
getLifecycleProcessor().stop();
publishEvent(new ContextStoppedEvent(this));
}
@Override
public boolean isRunning() {
return getLifecycleProcessor().isRunning();
}
@@ -1325,6 +1371,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
* @see #refreshBeanFactory()
* @see #closeBeanFactory()
*/
@Override
public abstract ConfigurableListableBeanFactory getBeanFactory() throws IllegalStateException;
@@ -1363,10 +1410,12 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
this.beanPostProcessorTargetCount = beanPostProcessorTargetCount;
}
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) {
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) {
if (bean != null && !(bean instanceof BeanPostProcessor) &&
this.beanFactory.getBeanPostProcessorCount() < this.beanPostProcessorTargetCount) {
@@ -1389,16 +1438,19 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
private final Map<String, Boolean> singletonNames = new ConcurrentHashMap<String, Boolean>(64);
@Override
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) {
if (beanDefinition.isSingleton()) {
this.singletonNames.put(beanName, Boolean.TRUE);
}
}
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) {
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) {
if (bean instanceof ApplicationListener) {
// potentially not detected as a listener by getBeanNamesForType retrieval

View File

@@ -67,10 +67,12 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
private boolean useCodeAsDefaultMessage = false;
@Override
public void setParentMessageSource(MessageSource parent) {
this.parentMessageSource = parent;
}
@Override
public MessageSource getParentMessageSource() {
return this.parentMessageSource;
}
@@ -109,6 +111,7 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
}
@Override
public final String getMessage(String code, Object[] args, String defaultMessage, Locale locale) {
String msg = getMessageInternal(code, args, locale);
if (msg != null) {
@@ -123,6 +126,7 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
return renderDefaultMessage(defaultMessage, args, locale);
}
@Override
public final String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException {
String msg = getMessageInternal(code, args, locale);
if (msg != null) {
@@ -135,6 +139,7 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
throw new NoSuchMessageException(code, locale);
}
@Override
public final String getMessage(MessageSourceResolvable resolvable, Locale locale)
throws NoSuchMessageException {

View File

@@ -133,6 +133,7 @@ public abstract class AbstractRefreshableConfigApplicationContext extends Abstra
* Sets the id of this context to the bean name by default,
* for cases where the context instance is itself defined as a bean.
*/
@Override
public void setBeanName(String name) {
if (!this.setIdCalled) {
super.setId(name);
@@ -144,6 +145,7 @@ public abstract class AbstractRefreshableConfigApplicationContext extends Abstra
* Triggers {@link #refresh()} if not refreshed in the concrete context's
* constructor already.
*/
@Override
public void afterPropertiesSet() {
if (!isActive()) {
refresh();

View File

@@ -70,6 +70,7 @@ class ApplicationContextAwareProcessor implements BeanPostProcessor {
}
@Override
public Object postProcessBeforeInitialization(final Object bean, String beanName) throws BeansException {
AccessControlContext acc = null;
@@ -82,6 +83,7 @@ class ApplicationContextAwareProcessor implements BeanPostProcessor {
if (acc != null) {
AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
public Object run() {
invokeAwareInterfaces(bean);
return null;
@@ -119,6 +121,7 @@ class ApplicationContextAwareProcessor implements BeanPostProcessor {
}
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) {
return bean;
}
@@ -132,6 +135,7 @@ class ApplicationContextAwareProcessor implements BeanPostProcessor {
this.beanFactory = beanFactory;
}
@Override
public String resolveStringValue(String strVal) {
return this.beanFactory.resolveEmbeddedValue(strVal);
}

View File

@@ -56,6 +56,7 @@ public abstract class ApplicationObjectSupport implements ApplicationContextAwar
private MessageSourceAccessor messageSourceAccessor;
@Override
public final void setApplicationContext(ApplicationContext context) throws BeansException {
if (context == null && !isContextRequired()) {
// Reset internal context state.

View File

@@ -63,6 +63,7 @@ class ContextTypeMatchClassLoader extends DecoratingClassLoader implements Smart
return new ContextOverridingClassLoader(getParent()).loadClass(name);
}
@Override
public boolean isClassReloadable(Class clazz) {
return (clazz.getClassLoader() instanceof ContextOverridingClassLoader);
}

View File

@@ -64,6 +64,7 @@ public class ConversionServiceFactoryBean implements FactoryBean<ConversionServi
this.converters = converters;
}
@Override
public void afterPropertiesSet() {
this.conversionService = createConversionService();
ConversionServiceFactory.registerConverters(this.converters, this.conversionService);
@@ -82,14 +83,17 @@ public class ConversionServiceFactoryBean implements FactoryBean<ConversionServi
// implementing FactoryBean
@Override
public ConversionService getObject() {
return this.conversionService;
}
@Override
public Class<? extends ConversionService> getObjectType() {
return GenericConversionService.class;
}
@Override
public boolean isSingleton() {
return true;
}

View File

@@ -68,6 +68,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
this.timeoutPerShutdownPhase = timeoutPerShutdownPhase;
}
@Override
public void setBeanFactory(BeanFactory beanFactory) {
Assert.isInstanceOf(ConfigurableListableBeanFactory.class, beanFactory);
this.beanFactory = (ConfigurableListableBeanFactory) beanFactory;
@@ -85,6 +86,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
* declared as a dependency of another bean will be started before
* the dependent bean regardless of the declared phase.
*/
@Override
public void start() {
startBeans(false);
this.running = true;
@@ -99,21 +101,25 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
* declared as dependent on another bean will be stopped before
* the dependency bean regardless of the declared phase.
*/
@Override
public void stop() {
stopBeans();
this.running = false;
}
@Override
public void onRefresh() {
startBeans(true);
this.running = true;
}
@Override
public void onClose() {
stopBeans();
this.running = false;
}
@Override
public boolean isRunning() {
return this.running;
}
@@ -221,6 +227,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
}
countDownBeanNames.add(beanName);
((SmartLifecycle) bean).stop(new Runnable() {
@Override
public void run() {
latch.countDown();
countDownBeanNames.remove(beanName);
@@ -389,6 +396,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
this.bean = bean;
}
@Override
public int compareTo(LifecycleGroupMember other) {
int thisOrder = getPhase(this.bean);
int otherOrder = getPhase(other.bean);

View File

@@ -96,6 +96,7 @@ public class DefaultMessageSourceResolvable implements MessageSourceResolvable,
}
@Override
public String[] getCodes() {
return this.codes;
}
@@ -108,10 +109,12 @@ public class DefaultMessageSourceResolvable implements MessageSourceResolvable,
return (this.codes != null && this.codes.length > 0) ? this.codes[this.codes.length - 1] : null;
}
@Override
public Object[] getArguments() {
return this.arguments;
}
@Override
public String getDefaultMessage() {
return this.defaultMessage;
}

View File

@@ -39,15 +39,18 @@ public class DelegatingMessageSource extends MessageSourceSupport implements Hie
private MessageSource parentMessageSource;
@Override
public void setParentMessageSource(MessageSource parent) {
this.parentMessageSource = parent;
}
@Override
public MessageSource getParentMessageSource() {
return this.parentMessageSource;
}
@Override
public String getMessage(String code, Object[] args, String defaultMessage, Locale locale) {
if (this.parentMessageSource != null) {
return this.parentMessageSource.getMessage(code, args, defaultMessage, locale);
@@ -57,6 +60,7 @@ public class DelegatingMessageSource extends MessageSourceSupport implements Hie
}
}
@Override
public String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException {
if (this.parentMessageSource != null) {
return this.parentMessageSource.getMessage(code, args, locale);
@@ -66,6 +70,7 @@ public class DelegatingMessageSource extends MessageSourceSupport implements Hie
}
}
@Override
public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException {
if (this.parentMessageSource != null) {
return this.parentMessageSource.getMessage(resolvable, locale);

View File

@@ -286,32 +286,39 @@ public class GenericApplicationContext extends AbstractApplicationContext implem
// Implementation of BeanDefinitionRegistry
//---------------------------------------------------------------------
@Override
public void registerBeanDefinition(String beanName, BeanDefinition beanDefinition)
throws BeanDefinitionStoreException {
this.beanFactory.registerBeanDefinition(beanName, beanDefinition);
}
@Override
public void removeBeanDefinition(String beanName) throws NoSuchBeanDefinitionException {
this.beanFactory.removeBeanDefinition(beanName);
}
@Override
public BeanDefinition getBeanDefinition(String beanName) throws NoSuchBeanDefinitionException {
return this.beanFactory.getBeanDefinition(beanName);
}
@Override
public boolean isBeanNameInUse(String beanName) {
return this.beanFactory.isBeanNameInUse(beanName);
}
@Override
public void registerAlias(String beanName, String alias) {
this.beanFactory.registerAlias(beanName, alias);
}
@Override
public void removeAlias(String alias) {
this.beanFactory.removeAlias(alias);
}
@Override
public boolean isAlias(String beanName) {
return this.beanFactory.isAlias(beanName);
}

View File

@@ -93,6 +93,7 @@ public class LiveBeansView implements LiveBeansViewMBean, ApplicationContextAwar
private ConfigurableApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) {
Assert.isTrue(applicationContext instanceof ConfigurableApplicationContext,
"ApplicationContext does not implement ConfigurableApplicationContext");
@@ -105,6 +106,7 @@ public class LiveBeansView implements LiveBeansViewMBean, ApplicationContextAwar
* finding all active ApplicationContexts through {@link #findApplicationContexts()},
* then delegating to {@link #generateJson(java.util.Set)}.
*/
@Override
public String getSnapshotAsJson() {
Set<ConfigurableApplicationContext> contexts;
if (this.applicationContext != null) {

View File

@@ -98,6 +98,7 @@ public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerS
* @see #setPropertySources
* @see #postProcessBeanFactory
*/
@Override
public void setEnvironment(Environment environment) {
this.environment = environment;
}
@@ -163,6 +164,7 @@ public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerS
propertyResolver.setValueSeparator(this.valueSeparator);
StringValueResolver valueResolver = new StringValueResolver() {
@Override
public String resolveStringValue(String strVal) {
String resolved = ignoreUnresolvablePlaceholders ?
propertyResolver.resolvePlaceholders(strVal) :

View File

@@ -250,6 +250,7 @@ public class ReloadableResourceBundleMessageSource extends AbstractMessageSource
* @see org.springframework.core.io.DefaultResourceLoader
* @see org.springframework.context.ResourceLoaderAware
*/
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
this.resourceLoader = (resourceLoader != null ? resourceLoader : new DefaultResourceLoader());
}

View File

@@ -223,6 +223,7 @@ public class ResourceBundleMessageSource extends AbstractMessageSource implement
return (this.bundleClassLoader != null ? this.bundleClassLoader : this.beanClassLoader);
}
@Override
public void setBeanClassLoader(ClassLoader classLoader) {
this.beanClassLoader = (classLoader != null ? classLoader : ClassUtils.getDefaultClassLoader());
}
@@ -431,6 +432,7 @@ public class ResourceBundleMessageSource extends AbstractMessageSource implement
try {
stream = AccessController.doPrivileged(
new PrivilegedExceptionAction<InputStream>() {
@Override
public InputStream run() throws IOException {
InputStream is = null;
if (reloadFlag) {

View File

@@ -55,6 +55,7 @@ public class SimpleThreadScope implements Scope {
}
};
@Override
public Object get(String name, ObjectFactory objectFactory) {
Map<String, Object> scope = threadScope.get();
Object object = scope.get(name);
@@ -65,20 +66,24 @@ public class SimpleThreadScope implements Scope {
return object;
}
@Override
public Object remove(String name) {
Map<String, Object> scope = threadScope.get();
return scope.remove(name);
}
@Override
public void registerDestructionCallback(String name, Runnable callback) {
logger.warn("SimpleThreadScope does not support descruction callbacks. " +
"Consider using a RequestScope in a Web environment.");
}
@Override
public Object resolveContextualObject(String key) {
return null;
}
@Override
public String getConversationId() {
return Thread.currentThread().getName();
}

View File

@@ -50,18 +50,22 @@ public class AspectJWeavingEnabler
public static final String ASPECTJ_AOP_XML_RESOURCE = "META-INF/aop.xml";
@Override
public void setBeanClassLoader(ClassLoader classLoader) {
this.beanClassLoader = classLoader;
}
@Override
public void setLoadTimeWeaver(LoadTimeWeaver loadTimeWeaver) {
this.loadTimeWeaver = loadTimeWeaver;
}
@Override
public int getOrder() {
return HIGHEST_PRECEDENCE;
}
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
enableAspectJWeaving(this.loadTimeWeaver, this.beanClassLoader);
}
@@ -95,6 +99,7 @@ public class AspectJWeavingEnabler
this.delegate = delegate;
}
@Override
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined,
ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {

View File

@@ -70,6 +70,7 @@ public class DefaultContextLoadTimeWeaver implements LoadTimeWeaver, BeanClassLo
setBeanClassLoader(beanClassLoader);
}
@Override
public void setBeanClassLoader(ClassLoader classLoader) {
LoadTimeWeaver serverSpecificLoadTimeWeaver = createServerSpecificLoadTimeWeaver(classLoader);
if (serverSpecificLoadTimeWeaver != null) {
@@ -130,6 +131,7 @@ public class DefaultContextLoadTimeWeaver implements LoadTimeWeaver, BeanClassLo
return null;
}
@Override
public void destroy() {
if (this.loadTimeWeaver instanceof InstrumentationLoadTimeWeaver) {
logger.info("Removing all registered transformers for class loader: " +
@@ -139,14 +141,17 @@ public class DefaultContextLoadTimeWeaver implements LoadTimeWeaver, BeanClassLo
}
@Override
public void addTransformer(ClassFileTransformer transformer) {
this.loadTimeWeaver.addTransformer(transformer);
}
@Override
public ClassLoader getInstrumentableClassLoader() {
return this.loadTimeWeaver.getInstrumentableClassLoader();
}
@Override
public ClassLoader getThrowawayClassLoader() {
return this.loadTimeWeaver.getThrowawayClassLoader();
}

View File

@@ -81,11 +81,13 @@ public class LoadTimeWeaverAwareProcessor implements BeanPostProcessor, BeanFact
}
@Override
public void setBeanFactory(BeanFactory beanFactory) {
this.beanFactory = beanFactory;
}
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof LoadTimeWeaverAware) {
LoadTimeWeaver ltw = this.loadTimeWeaver;
@@ -100,6 +102,7 @@ public class LoadTimeWeaverAwareProcessor implements BeanPostProcessor, BeanFact
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String name) {
return bean;
}

View File

@@ -183,6 +183,7 @@ public abstract class AbstractSlsbInvokerInterceptor extends JndiObjectLocator
* Prepares the thread context if necessar, and delegates to
* {@link #invokeInContext}.
*/
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
Context ctx = (this.exposeAccessContext ? getJndiTemplate().getContext() : null);
try {

View File

@@ -77,6 +77,7 @@ public class LocalStatelessSessionProxyFactoryBean extends LocalSlsbInvokerInter
return this.businessInterface;
}
@Override
public void setBeanClassLoader(ClassLoader classLoader) {
this.beanClassLoader = classLoader;
}
@@ -91,14 +92,17 @@ public class LocalStatelessSessionProxyFactoryBean extends LocalSlsbInvokerInter
}
@Override
public Object getObject() {
return this.proxy;
}
@Override
public Class<?> getObjectType() {
return this.businessInterface;
}
@Override
public boolean isSingleton() {
return true;
}

View File

@@ -171,6 +171,7 @@ public class SimpleRemoteSlsbInvokerInterceptor extends AbstractRemoteSlsbInvoke
/**
* Remove the cached session bean instance, if necessary.
*/
@Override
public void destroy() {
if (this.cacheSessionBean) {
synchronized (this.beanInstanceMonitor) {

View File

@@ -91,6 +91,7 @@ public class SimpleRemoteStatelessSessionProxyFactoryBean extends SimpleRemoteSl
return this.businessInterface;
}
@Override
public void setBeanClassLoader(ClassLoader classLoader) {
this.beanClassLoader = classLoader;
}
@@ -105,14 +106,17 @@ public class SimpleRemoteStatelessSessionProxyFactoryBean extends SimpleRemoteSl
}
@Override
public Object getObject() {
return this.proxy;
}
@Override
public Class<?> getObjectType() {
return this.businessInterface;
}
@Override
public boolean isSingleton() {
return true;
}

View File

@@ -27,6 +27,7 @@ import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
*/
public class JeeNamespaceHandler extends NamespaceHandlerSupport {
@Override
public void init() {
registerBeanDefinitionParser("jndi-lookup", new JndiLookupBeanDefinitionParser());
registerBeanDefinitionParser("local-slsb", new LocalStatelessSessionBeanDefinitionParser());

View File

@@ -187,6 +187,7 @@ public abstract class AbstractEnterpriseBean implements EnterpriseBean {
this.beanFactoryReference = beanFactoryReference;
}
@Override
public void released() {
this.beanFactoryReference.release();
}

View File

@@ -57,6 +57,7 @@ public abstract class AbstractMessageDrivenBean extends AbstractEnterpriseBean
* Required lifecycle method. Sets the MessageDriven context.
* @param messageDrivenContext MessageDrivenContext
*/
@Override
public void setMessageDrivenContext(MessageDrivenContext messageDrivenContext) {
this.messageDrivenContext = messageDrivenContext;
}

View File

@@ -42,6 +42,7 @@ public abstract class AbstractSessionBean extends AbstractEnterpriseBean impleme
* Set the session context for this EJB.
* <p><b>When overriding this method, be sure to invoke this form of it first.</b>
*/
@Override
public void setSessionContext(SessionContext sessionContext) {
this.sessionContext = sessionContext;
}
@@ -50,6 +51,7 @@ public abstract class AbstractSessionBean extends AbstractEnterpriseBean impleme
* Convenience method for subclasses, returning the EJB session context
* saved on initialization ({@link #setSessionContext}).
*/
@Override
public final SessionContext getSessionContext() {
return this.sessionContext;
}

View File

@@ -85,6 +85,7 @@ public abstract class AbstractStatelessSessionBean extends AbstractSessionBean {
* This method always throws an exception, as it should not be invoked by the EJB container.
* @see javax.ejb.SessionBean#ejbActivate()
*/
@Override
public void ejbActivate() throws EJBException {
throw new IllegalStateException("ejbActivate must not be invoked on a stateless session bean");
}
@@ -93,6 +94,7 @@ public abstract class AbstractStatelessSessionBean extends AbstractSessionBean {
* This method always throws an exception, as it should not be invoked by the EJB container.
* @see javax.ejb.SessionBean#ejbPassivate()
*/
@Override
public void ejbPassivate() throws EJBException {
throw new IllegalStateException("ejbPassivate must not be invoked on a stateless session bean");
}

View File

@@ -145,10 +145,12 @@ public class DateFormatter implements Formatter<Date> {
}
@Override
public String print(Date date, Locale locale) {
return getDateFormat(locale).format(date);
}
@Override
public Date parse(String text, Locale locale) throws ParseException {
return getDateFormat(locale).parse(text);
}

View File

@@ -43,6 +43,7 @@ public class DateFormatterRegistrar implements FormatterRegistrar {
private DateFormatter dateFormatter = new DateFormatter();
@Override
public void registerFormatters(FormatterRegistry registry) {
addDateConverters(registry);
registry.addFormatter(dateFormatter);
@@ -76,6 +77,7 @@ public class DateFormatterRegistrar implements FormatterRegistrar {
private static class DateToLongConverter implements Converter<Date, Long> {
@Override
public Long convert(Date source) {
return source.getTime();
}
@@ -83,6 +85,7 @@ public class DateFormatterRegistrar implements FormatterRegistrar {
private static class DateToCalendarConverter implements Converter<Date, Calendar> {
@Override
public Calendar convert(Date source) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(source);
@@ -92,6 +95,7 @@ public class DateFormatterRegistrar implements FormatterRegistrar {
private static class CalendarToDateConverter implements Converter<Calendar, Date> {
@Override
public Date convert(Calendar source) {
return source.getTime();
}
@@ -99,6 +103,7 @@ public class DateFormatterRegistrar implements FormatterRegistrar {
private static class CalendarToLongConverter implements Converter<Calendar, Long> {
@Override
public Long convert(Calendar source) {
return source.getTime().getTime();
}
@@ -106,6 +111,7 @@ public class DateFormatterRegistrar implements FormatterRegistrar {
private static class LongToDateConverter implements Converter<Long, Date> {
@Override
public Date convert(Long source) {
return new Date(source);
}
@@ -116,6 +122,7 @@ public class DateFormatterRegistrar implements FormatterRegistrar {
private DateToCalendarConverter dateToCalendarConverter = new DateToCalendarConverter();
@Override
public Calendar convert(Long source) {
return dateToCalendarConverter.convert(new Date(source));
}

View File

@@ -55,18 +55,22 @@ public class DateTimeFormatAnnotationFormatterFactory implements
private StringValueResolver embeddedValueResolver;
@Override
public void setEmbeddedValueResolver(StringValueResolver resolver) {
this.embeddedValueResolver = resolver;
}
@Override
public Set<Class<?>> getFieldTypes() {
return FIELD_TYPES;
}
@Override
public Printer<?> getPrinter(DateTimeFormat annotation, Class<?> fieldType) {
return getFormatter(annotation, fieldType);
}
@Override
public Parser<?> getParser(DateTimeFormat annotation, Class<?> fieldType) {
return getFormatter(annotation, fieldType);
}

View File

@@ -39,18 +39,22 @@ public class DateTimeFormatterFactoryBean extends DateTimeFormatterFactory
private DateTimeFormatter dateTimeFormatter;
@Override
public void afterPropertiesSet() {
this.dateTimeFormatter = createDateTimeFormatter();
}
@Override
public DateTimeFormatter getObject() {
return this.dateTimeFormatter;
}
@Override
public Class<?> getObjectType() {
return DateTimeFormatter.class;
}
@Override
public boolean isSingleton() {
return true;
}

View File

@@ -42,6 +42,7 @@ public final class DateTimeParser implements Parser<DateTime> {
this.formatter = formatter;
}
@Override
public DateTime parse(String text, Locale locale) throws ParseException {
return JodaTimeContextHolder.getFormatter(this.formatter, locale).parseDateTime(text);
}

View File

@@ -71,10 +71,12 @@ public class JodaDateTimeFormatAnnotationFormatterFactory
private StringValueResolver embeddedValueResolver;
@Override
public final Set<Class<?>> getFieldTypes() {
return FIELD_TYPES;
}
@Override
public void setEmbeddedValueResolver(StringValueResolver resolver) {
this.embeddedValueResolver = resolver;
}
@@ -83,6 +85,7 @@ public class JodaDateTimeFormatAnnotationFormatterFactory
return (this.embeddedValueResolver != null ? this.embeddedValueResolver.resolveStringValue(value) : value);
}
@Override
public Printer<?> getPrinter(DateTimeFormat annotation, Class<?> fieldType) {
DateTimeFormatter formatter = getFormatter(annotation, fieldType);
if (ReadableInstant.class.isAssignableFrom(fieldType)) {
@@ -99,6 +102,7 @@ public class JodaDateTimeFormatAnnotationFormatterFactory
return new MillisecondInstantPrinter(formatter);
}
@Override
public Parser<DateTime> getParser(DateTimeFormat annotation, Class<?> fieldType) {
return new DateTimeParser(getFormatter(annotation, fieldType));
}

View File

@@ -63,6 +63,7 @@ final class JodaTimeConverters {
* @see DateTimeParser
**/
private static class DateTimeToLocalDateConverter implements Converter<DateTime, LocalDate> {
@Override
public LocalDate convert(DateTime source) {
return source.toLocalDate();
}
@@ -73,6 +74,7 @@ final class JodaTimeConverters {
* @see DateTimeParser
*/
private static class DateTimeToLocalTimeConverter implements Converter<DateTime, LocalTime> {
@Override
public LocalTime convert(DateTime source) {
return source.toLocalTime();
}
@@ -83,6 +85,7 @@ final class JodaTimeConverters {
* @see DateTimeParser
*/
private static class DateTimeToLocalDateTimeConverter implements Converter<DateTime, LocalDateTime> {
@Override
public LocalDateTime convert(DateTime source) {
return source.toLocalDateTime();
}
@@ -93,6 +96,7 @@ final class JodaTimeConverters {
* @see DateTimeParser
*/
private static class DateTimeToDateMidnightConverter implements Converter<DateTime, DateMidnight> {
@Override
public DateMidnight convert(DateTime source) {
return source.toDateMidnight();
}
@@ -103,6 +107,7 @@ final class JodaTimeConverters {
* @see DateTimeParser
*/
private static class DateTimeToInstantConverter implements Converter<DateTime, Instant> {
@Override
public Instant convert(DateTime source) {
return source.toInstant();
}
@@ -113,6 +118,7 @@ final class JodaTimeConverters {
* @see DateTimeParser
*/
private static class DateTimeToMutableDateTimeConverter implements Converter<DateTime, MutableDateTime> {
@Override
public MutableDateTime convert(DateTime source) {
return source.toMutableDateTime();
}
@@ -123,6 +129,7 @@ final class JodaTimeConverters {
* @see DateTimeParser
*/
private static class DateTimeToDateConverter implements Converter<DateTime, Date> {
@Override
public Date convert(DateTime source) {
return source.toDate();
}
@@ -133,6 +140,7 @@ final class JodaTimeConverters {
* @see DateTimeParser
*/
private static class DateTimeToCalendarConverter implements Converter<DateTime, Calendar> {
@Override
public Calendar convert(DateTime source) {
return source.toGregorianCalendar();
}
@@ -143,6 +151,7 @@ final class JodaTimeConverters {
* @see DateTimeParser
*/
private static class DateTimeToLongConverter implements Converter<DateTime, Long> {
@Override
public Long convert(DateTime source) {
return source.getMillis();
}
@@ -154,6 +163,7 @@ final class JodaTimeConverters {
* @see JodaDateTimeFormatAnnotationFormatterFactory
*/
private static class CalendarToReadableInstantConverter implements Converter<Calendar, ReadableInstant> {
@Override
public ReadableInstant convert(Calendar source) {
return new DateTime(source);
}

View File

@@ -149,6 +149,7 @@ public class JodaTimeFormatterRegistrar implements FormatterRegistrar {
this.formatters.put(Type.DATE_TIME, formatter);
}
@Override
public void registerFormatters(FormatterRegistry registry) {
JodaTimeConverters.registerConverters(registry);

View File

@@ -40,6 +40,7 @@ public final class MillisecondInstantPrinter implements Printer<Long> {
this.formatter = formatter;
}
@Override
public String print(Long instant, Locale locale) {
return JodaTimeContextHolder.getFormatter(this.formatter, locale).print(instant);
}

View File

@@ -40,6 +40,7 @@ public final class ReadableInstantPrinter implements Printer<ReadableInstant> {
this.formatter = formatter;
}
@Override
public String print(ReadableInstant instant, Locale locale) {
return JodaTimeContextHolder.getFormatter(this.formatter, locale).print(instant);
}

View File

@@ -41,6 +41,7 @@ public final class ReadablePartialPrinter implements Printer<ReadablePartial> {
this.formatter = formatter;
}
@Override
public String print(ReadablePartial partial, Locale locale) {
return JodaTimeContextHolder.getFormatter(this.formatter, locale).print(partial);
}

View File

@@ -44,10 +44,12 @@ public abstract class AbstractNumberFormatter implements Formatter<Number> {
this.lenient = lenient;
}
@Override
public String print(Number number, Locale locale) {
return getNumberFormat(locale).format(number);
}
@Override
public Number parse(String text, Locale locale) throws ParseException {
NumberFormat format = getNumberFormat(locale);
ParsePosition position = new ParsePosition(0);

View File

@@ -75,6 +75,7 @@ public class CurrencyFormatter extends AbstractNumberFormatter {
}
@Override
public BigDecimal parse(String text, Locale locale) throws ParseException {
BigDecimal decimal = (BigDecimal) super.parse(text, locale);
if (decimal != null) {
@@ -88,6 +89,7 @@ public class CurrencyFormatter extends AbstractNumberFormatter {
return decimal;
}
@Override
protected NumberFormat getNumberFormat(Locale locale) {
DecimalFormat format = (DecimalFormat) NumberFormat.getCurrencyInstance(locale);
format.setParseBigDecimal(true);

View File

@@ -59,11 +59,13 @@ public class NumberFormatAnnotationFormatterFactory
this.fieldTypes = Collections.unmodifiableSet(rawFieldTypes);
}
@Override
public final Set<Class<?>> getFieldTypes() {
return this.fieldTypes;
}
@Override
public void setEmbeddedValueResolver(StringValueResolver resolver) {
this.embeddedValueResolver = resolver;
}
@@ -73,10 +75,12 @@ public class NumberFormatAnnotationFormatterFactory
}
@Override
public Printer<Number> getPrinter(NumberFormat annotation, Class<?> fieldType) {
return configureFormatterFrom(annotation);
}
@Override
public Parser<Number> getParser(NumberFormat annotation, Class<?> fieldType) {
return configureFormatterFrom(annotation);
}

View File

@@ -65,6 +65,7 @@ public class NumberFormatter extends AbstractNumberFormatter {
}
@Override
public NumberFormat getNumberFormat(Locale locale) {
NumberFormat format = NumberFormat.getInstance(locale);
if (!(format instanceof DecimalFormat)) {

View File

@@ -34,6 +34,7 @@ import java.util.Locale;
*/
public class PercentFormatter extends AbstractNumberFormatter {
@Override
protected NumberFormat getNumberFormat(Locale locale) {
NumberFormat format = NumberFormat.getPercentInstance(locale);
if (format instanceof DecimalFormat) {

View File

@@ -59,11 +59,13 @@ public class FormattingConversionService extends GenericConversionService
new ConcurrentHashMap<AnnotationConverterKey, GenericConverter>(64);
@Override
public void setEmbeddedValueResolver(StringValueResolver resolver) {
this.embeddedValueResolver = resolver;
}
@Override
public void addFormatter(Formatter<?> formatter) {
Class<?> fieldType = GenericTypeResolver.resolveTypeArgument(formatter.getClass(), Formatter.class);
if (fieldType == null) {
@@ -73,16 +75,19 @@ public class FormattingConversionService extends GenericConversionService
addFormatterForFieldType(fieldType, formatter);
}
@Override
public void addFormatterForFieldType(Class<?> fieldType, Formatter<?> formatter) {
addConverter(new PrinterConverter(fieldType, formatter, this));
addConverter(new ParserConverter(fieldType, formatter, this));
}
@Override
public void addFormatterForFieldType(Class<?> fieldType, Printer<?> printer, Parser<?> parser) {
addConverter(new PrinterConverter(fieldType, printer, this));
addConverter(new ParserConverter(fieldType, parser, this));
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void addFormatterForFieldAnnotation(AnnotationFormatterFactory annotationFormatterFactory) {
final Class<? extends Annotation> annotationType = (Class<? extends Annotation>)
@@ -120,10 +125,12 @@ public class FormattingConversionService extends GenericConversionService
this.conversionService = conversionService;
}
@Override
public Set<ConvertiblePair> getConvertibleTypes() {
return Collections.singleton(new ConvertiblePair(this.fieldType, String.class));
}
@Override
@SuppressWarnings("unchecked")
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
if (source == null) {
@@ -159,10 +166,12 @@ public class FormattingConversionService extends GenericConversionService
this.conversionService = conversionService;
}
@Override
public Set<ConvertiblePair> getConvertibleTypes() {
return Collections.singleton(new ConvertiblePair(String.class, this.fieldType));
}
@Override
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
String text = (String) source;
if (!StringUtils.hasText(text)) {
@@ -206,14 +215,17 @@ public class FormattingConversionService extends GenericConversionService
this.fieldType = fieldType;
}
@Override
public Set<ConvertiblePair> getConvertibleTypes() {
return Collections.singleton(new ConvertiblePair(fieldType, String.class));
}
@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
return sourceType.hasAnnotation(annotationType);
}
@Override
@SuppressWarnings("unchecked")
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
AnnotationConverterKey converterKey =
@@ -250,14 +262,17 @@ public class FormattingConversionService extends GenericConversionService
this.fieldType = fieldType;
}
@Override
public Set<ConvertiblePair> getConvertibleTypes() {
return Collections.singleton(new ConvertiblePair(String.class, fieldType));
}
@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
return targetType.hasAnnotation(annotationType);
}
@Override
@SuppressWarnings("unchecked")
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
AnnotationConverterKey converterKey =

View File

@@ -124,11 +124,13 @@ public class FormattingConversionServiceFactoryBean
this.registerDefaultFormatters = registerDefaultFormatters;
}
@Override
public void setEmbeddedValueResolver(StringValueResolver embeddedValueResolver) {
this.embeddedValueResolver = embeddedValueResolver;
}
@Override
public void afterPropertiesSet() {
this.conversionService = new DefaultFormattingConversionService(this.embeddedValueResolver, this.registerDefaultFormatters);
ConversionServiceFactory.registerConverters(this.converters, this.conversionService);
@@ -171,14 +173,17 @@ public class FormattingConversionServiceFactoryBean
}
@Override
public FormattingConversionService getObject() {
return this.conversionService;
}
@Override
public Class<? extends FormattingConversionService> getObjectType() {
return FormattingConversionService.class;
}
@Override
public boolean isSingleton() {
return true;
}

Some files were not shown because too many files have changed in this diff Show More