diff --git a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/JtaTransactionAspectsTests.java b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/JtaTransactionAspectsTests.java index a4eea3e1e61..4c7b5fcfa7f 100644 --- a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/JtaTransactionAspectsTests.java +++ b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/JtaTransactionAspectsTests.java @@ -17,7 +17,6 @@ package org.springframework.transaction.aspectj; import java.io.IOException; - import javax.transaction.Transactional; import org.junit.Before; @@ -132,6 +131,7 @@ public class JtaTransactionAspectsTests { } + protected static class JtaAnnotationProtectedAnnotatedMember { public void doSomething() { @@ -143,6 +143,7 @@ public class JtaTransactionAspectsTests { } } + protected static class JtaAnnotationPrivateAnnotatedMember { public void doSomething() { @@ -154,6 +155,7 @@ public class JtaTransactionAspectsTests { } } + @Configuration protected static class Config { @@ -168,7 +170,6 @@ public class JtaTransactionAspectsTests { aspect.setTransactionManager(transactionManager()); return aspect; } - } } diff --git a/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java b/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java index 855ef022fdf..2a6c53e0876 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java @@ -22,6 +22,7 @@ import java.lang.reflect.Array; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.lang.reflect.UndeclaredThrowableException; import java.security.AccessControlContext; import java.security.AccessController; import java.security.PrivilegedAction; @@ -1179,7 +1180,12 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra throw new TypeMismatchException(propertyChangeEvent, pd.getPropertyType(), ex.getTargetException()); } else { - throw new MethodInvocationException(propertyChangeEvent, ex.getTargetException()); + Throwable cause = ex.getTargetException(); + if (cause instanceof UndeclaredThrowableException) { + // May happen e.g. with Groovy-generated methods + cause = cause.getCause(); + } + throw new MethodInvocationException(propertyChangeEvent, cause); } } catch (Exception ex) { diff --git a/spring-context/src/main/java/org/springframework/cache/annotation/EnableCaching.java b/spring-context/src/main/java/org/springframework/cache/annotation/EnableCaching.java index 5be29849429..5086c1a1df4 100644 --- a/spring-context/src/main/java/org/springframework/cache/annotation/EnableCaching.java +++ b/spring-context/src/main/java/org/springframework/cache/annotation/EnableCaching.java @@ -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}. * Applicable only if {@link #mode()} is set to {@link AdviceMode#PROXY}. - * *
Note that setting this attribute to {@code true} will affect all - * 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; + } diff --git a/spring-context/src/main/java/org/springframework/scripting/groovy/GroovyScriptFactory.java b/spring-context/src/main/java/org/springframework/scripting/groovy/GroovyScriptFactory.java index fdaa876c080..b13527543c2 100644 --- a/spring-context/src/main/java/org/springframework/scripting/groovy/GroovyScriptFactory.java +++ b/spring-context/src/main/java/org/springframework/scripting/groovy/GroovyScriptFactory.java @@ -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); } diff --git a/spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java b/spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java index 01e3c206923..156e322e025 100644 --- a/spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java +++ b/spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java @@ -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; * <property name="message" value="Hello World!"/> * </bean> * - * <bean id="groovyMessenger" class="org.springframework.scripting.bsh.GroovyScriptFactory"> + * <bean id="groovyMessenger" class="org.springframework.scripting.groovy.GroovyScriptFactory"> * <constructor-arg value="classpath:mypackage/Messenger.groovy"/> * <property name="message" value="Hello World!"/> * </bean> @@ -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);