Polishing

This commit is contained in:
Juergen Hoeller
2015-05-11 18:05:09 +02:00
parent 0cd7fed050
commit ce4e795f09
17 changed files with 133 additions and 115 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 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,7 +17,7 @@
package org.springframework.cache;
/**
* Interface that defines the common cache operations.
* Interface that defines common cache operations.
*
* <b>Note:</b> Due to the generic use of caching, it is recommended that
* implementations allow storage of <tt>null</tt> values (for example to
@@ -68,8 +68,8 @@ public interface Cache {
* the cache contains no mapping for this key
* @throws IllegalStateException if a cache entry has been found
* but failed to match the specified type
* @see #get(Object)
* @since 4.0
* @see #get(Object)
*/
<T> T get(Object key, Class<T> type);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 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.
@@ -162,13 +162,12 @@ public @interface EnableCaching {
* Indicate whether subclass-based (CGLIB) proxies are to be created as opposed
* to standard Java interface-based proxies. The default is {@code false}. <strong>
* Applicable only if {@link #mode()} is set to {@link AdviceMode#PROXY}</strong>.
*
* <p>Note that setting this attribute to {@code true} will affect <em>all</em>
* Spring-managed beans requiring proxying, not just those marked with
* {@code @Cacheable}. For example, other beans marked with Spring's
* {@code @Transactional} annotation will be upgraded to subclass proxying at the same
* time. This approach has no negative impact in practice unless one is explicitly
* expecting one type of proxy vs another, e.g. in tests.
* Spring-managed beans requiring proxying, not just those marked with {@code @Cacheable}.
* For example, other beans marked with Spring's {@code @Transactional} annotation will
* be upgraded to subclass proxying at the same time. This approach has no negative
* impact in practice unless one is explicitly expecting one type of proxy vs another,
* e.g. in tests.
*/
boolean proxyTargetClass() default false;
@@ -185,4 +184,5 @@ public @interface EnableCaching {
* The default is {@link Ordered#LOWEST_PRECEDENCE}.
*/
int order() default Ordered.LOWEST_PRECEDENCE;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 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,7 +24,6 @@ import groovy.lang.MetaClass;
import groovy.lang.Script;
import org.codehaus.groovy.control.CompilationFailedException;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
@@ -102,7 +101,7 @@ public class GroovyScriptFactory implements ScriptFactory, BeanFactoryAware, Bea
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
public void setBeanFactory(BeanFactory beanFactory) {
if (beanFactory instanceof ConfigurableListableBeanFactory) {
((ConfigurableListableBeanFactory) beanFactory).ignoreDependencyType(MetaClass.class);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 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.
@@ -94,7 +94,7 @@ import org.springframework.util.StringUtils;
* &lt;property name="message" value="Hello World!"/&gt;
* &lt;/bean&gt;
*
* &lt;bean id="groovyMessenger" class="org.springframework.scripting.bsh.GroovyScriptFactory"&gt;
* &lt;bean id="groovyMessenger" class="org.springframework.scripting.groovy.GroovyScriptFactory"&gt;
* &lt;constructor-arg value="classpath:mypackage/Messenger.groovy"/&gt;
* &lt;property name="message" value="Hello World!"/&gt;
* &lt;/bean&gt;</pre>
@@ -346,17 +346,16 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
* @param scriptedObjectBeanName the name of the internal scripted object bean
*/
protected void prepareScriptBeans(BeanDefinition bd, String scriptFactoryBeanName, String scriptedObjectBeanName) {
// Avoid recreation of the script bean definition in case of a prototype.
synchronized (this.scriptBeanFactory) {
if (!this.scriptBeanFactory.containsBeanDefinition(scriptedObjectBeanName)) {
this.scriptBeanFactory.registerBeanDefinition(scriptFactoryBeanName,
createScriptFactoryBeanDefinition(bd));
ScriptFactory scriptFactory = this.scriptBeanFactory
.getBean(scriptFactoryBeanName, ScriptFactory.class);
ScriptSource scriptSource = getScriptSource(scriptFactoryBeanName,
scriptFactory.getScriptSourceLocator());
this.scriptBeanFactory.registerBeanDefinition(
scriptFactoryBeanName, createScriptFactoryBeanDefinition(bd));
ScriptFactory scriptFactory =
this.scriptBeanFactory.getBean(scriptFactoryBeanName, ScriptFactory.class);
ScriptSource scriptSource =
getScriptSource(scriptFactoryBeanName, scriptFactory.getScriptSourceLocator());
Class<?>[] interfaces = scriptFactory.getScriptInterfaces();
Class<?>[] scriptedInterfaces = interfaces;
@@ -365,8 +364,8 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
scriptedInterfaces = ObjectUtils.addObjectToArray(interfaces, configInterface);
}
BeanDefinition objectBd = createScriptedObjectBeanDefinition(bd, scriptFactoryBeanName, scriptSource,
scriptedInterfaces);
BeanDefinition objectBd = createScriptedObjectBeanDefinition(
bd, scriptFactoryBeanName, scriptSource, scriptedInterfaces);
long refreshCheckDelay = resolveRefreshCheckDelay(bd);
if (refreshCheckDelay >= 0) {
objectBd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
@@ -569,7 +568,7 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
proxyFactory.setInterfaces(interfaces);
if (proxyTargetClass) {
classLoader = null; // force use of Class.getClassLoader()
proxyFactory.setProxyTargetClass(proxyTargetClass);
proxyFactory.setProxyTargetClass(true);
}
DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(ts);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 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.
@@ -667,27 +667,27 @@ public class InjectAnnotationAutowireContextTests {
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Qualifier
public static @interface TestQualifier {
public @interface TestQualifier {
}
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Qualifier
public static @interface TestQualifierWithDefaultValue {
public @interface TestQualifierWithDefaultValue {
public abstract String value() default "default";
String value() default "default";
}
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Qualifier
public static @interface TestQualifierWithMultipleAttributes {
public @interface TestQualifierWithMultipleAttributes {
public abstract String value() default "default";
String value() default "default";
public abstract int number();
int number();
}
}