diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/config/AopNamespaceUtils.java b/org.springframework.aop/src/main/java/org/springframework/aop/config/AopNamespaceUtils.java index da69bed31f..c00659027b 100644 --- a/org.springframework.aop/src/main/java/org/springframework/aop/config/AopNamespaceUtils.java +++ b/org.springframework.aop/src/main/java/org/springframework/aop/config/AopNamespaceUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 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. @@ -98,8 +98,7 @@ public abstract class AopNamespaceUtils { private static void useClassProxyingIfNecessary(BeanDefinitionRegistry registry, Element sourceElement) { if (sourceElement != null) { - boolean proxyTargetClass = Boolean.valueOf( - sourceElement.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE)).booleanValue(); + boolean proxyTargetClass = Boolean.valueOf(sourceElement.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE)); if (proxyTargetClass) { AopConfigUtils.forceAutoProxyCreatorToUseClassProxying(registry); } diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java b/org.springframework.aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java index 49bbbd041f..f5015a2c81 100644 --- a/org.springframework.aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java +++ b/org.springframework.aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java @@ -20,6 +20,8 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -38,7 +40,7 @@ import org.springframework.aop.target.EmptyTargetSource; import org.springframework.aop.target.SingletonTargetSource; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; -import org.springframework.util.ObjectUtils; +import org.springframework.util.CollectionUtils; /** * Base class for AOP proxy configuration managers. @@ -309,12 +311,30 @@ public class AdvisedSupport extends ProxyConfig implements Advised { /** * Add all of the given advisors to this proxy configuration. * @param advisors the advisors to register + * @deprecated as of Spring 3.0, in favor of {@link #addAdvisors} */ + @Deprecated public void addAllAdvisors(Advisor[] advisors) { + addAdvisors(Arrays.asList(advisors)); + } + + /** + * Add all of the given advisors to this proxy configuration. + * @param advisors the advisors to register + */ + public void addAdvisors(Advisor... advisors) { + addAdvisors(Arrays.asList(advisors)); + } + + /** + * Add all of the given advisors to this proxy configuration. + * @param advisors the advisors to register + */ + public void addAdvisors(Collection advisors) { if (isFrozen()) { throw new AopConfigException("Cannot add advisor: Configuration is frozen."); } - if (!ObjectUtils.isEmpty(advisors)) { + if (!CollectionUtils.isEmpty(advisors)) { for (Advisor advisor : advisors) { if (advisor instanceof IntroductionAdvisor) { validateIntroductionAdvisor((IntroductionAdvisor) advisor); diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/framework/AopContext.java b/org.springframework.aop/src/main/java/org/springframework/aop/framework/AopContext.java index c5e62ae36c..00317a97d8 100644 --- a/org.springframework.aop/src/main/java/org/springframework/aop/framework/AopContext.java +++ b/org.springframework.aop/src/main/java/org/springframework/aop/framework/AopContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 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. @@ -46,7 +46,7 @@ public abstract class AopContext { * the controlling proxy configuration has been set to "true". * @see ProxyConfig#setExposeProxy */ - private static final ThreadLocal currentProxy = new NamedThreadLocal("Current AOP proxy"); + private static final ThreadLocal currentProxy = new NamedThreadLocal("Current AOP proxy"); /** diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java b/org.springframework.aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java index 6eccb8d83a..a4a10f4df5 100644 --- a/org.springframework.aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java +++ b/org.springframework.aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 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. @@ -123,11 +123,9 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa * @param proxiedInterfaces the interfaces to introspect */ private void findDefinedEqualsAndHashCodeMethods(Class[] proxiedInterfaces) { - for (int i = 0; i < proxiedInterfaces.length; i++) { - Class proxiedInterface = proxiedInterfaces[i]; + for (Class proxiedInterface : proxiedInterfaces) { Method[] methods = proxiedInterface.getDeclaredMethods(); - for (int j = 0; j < methods.length; j++) { - Method method = methods[j]; + for (Method method : methods) { if (AopUtils.isEqualsMethod(method)) { this.equalsDefined = true; } @@ -187,7 +185,7 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa } // Get the interception chain for this method. - List chain = this.advised.getInterceptorsAndDynamicInterceptionAdvice(method, targetClass); + List chain = this.advised.getInterceptorsAndDynamicInterceptionAdvice(method, targetClass); // Check whether we have any advice. If we don't, we can fallback on direct // reflective invocation of the target, and avoid creating a MethodInvocation. diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java b/org.springframework.aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java index 1e92646292..7959b53b02 100644 --- a/org.springframework.aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java +++ b/org.springframework.aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 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. @@ -112,7 +112,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig protected final Log logger = LogFactory.getLog(getClass()); /** Default value is same as non-ordered */ - private int order = Integer.MAX_VALUE; + private int order = Ordered.LOWEST_PRECEDENCE; /** Default is global AdvisorAdapterRegistry */ private AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance(); diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/framework/autoproxy/ProxyCreationContext.java b/org.springframework.aop/src/main/java/org/springframework/aop/framework/autoproxy/ProxyCreationContext.java index 3a7d6d73e0..58aefc2b30 100644 --- a/org.springframework.aop/src/main/java/org/springframework/aop/framework/autoproxy/ProxyCreationContext.java +++ b/org.springframework.aop/src/main/java/org/springframework/aop/framework/autoproxy/ProxyCreationContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,8 +29,8 @@ import org.springframework.core.NamedThreadLocal; public class ProxyCreationContext { /** ThreadLocal holding the current proxied bean name during Advisor matching */ - private static final ThreadLocal currentProxiedBeanName = - new NamedThreadLocal("Name of currently proxied bean"); + private static final ThreadLocal currentProxiedBeanName = + new NamedThreadLocal("Name of currently proxied bean"); /** @@ -38,7 +38,7 @@ public class ProxyCreationContext { * @return the name of the bean, or null if none available */ public static String getCurrentProxiedBeanName() { - return (String) currentProxiedBeanName.get(); + return currentProxiedBeanName.get(); } /** diff --git a/org.springframework.context/src/main/java/org/springframework/context/annotation/ScopeMetadata.java b/org.springframework.context/src/main/java/org/springframework/context/annotation/ScopeMetadata.java index 65e8ed0c20..fac3724524 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/annotation/ScopeMetadata.java +++ b/org.springframework.context/src/main/java/org/springframework/context/annotation/ScopeMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 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,7 @@ import org.springframework.beans.factory.config.BeanDefinition; * *

The default scope is "singleton", and the default is to not create * scoped-proxies. - * + * * @author Mark Fisher * @since 2.5 * @see ScopeMetadataResolver @@ -37,36 +37,32 @@ public class ScopeMetadata { private ScopedProxyMode scopedProxyMode = ScopedProxyMode.NO; - /** - * Get the name of the scope. - * @return said scope name - */ - public String getScopeName() { - return scopeName; - } - /** * Set the name of the scope. - * @param scopeName said scope name */ public void setScopeName(String scopeName) { this.scopeName = scopeName; } /** - * Get the proxy-mode to be applied to the scoped instance. - * @return said scoped-proxy mode + * Get the name of the scope. */ - public ScopedProxyMode getScopedProxyMode() { - return scopedProxyMode; + public String getScopeName() { + return this.scopeName; } /** * Set the proxy-mode to be applied to the scoped instance. - * @param scopedProxyMode said scoped-proxy mode */ public void setScopedProxyMode(ScopedProxyMode scopedProxyMode) { this.scopedProxyMode = scopedProxyMode; } - + + /** + * Get the proxy-mode to be applied to the scoped instance. + */ + public ScopedProxyMode getScopedProxyMode() { + return this.scopedProxyMode; + } + } diff --git a/org.springframework.context/src/main/java/org/springframework/context/annotation/ScopedProxyMode.java b/org.springframework.context/src/main/java/org/springframework/context/annotation/ScopedProxyMode.java index 771026eb47..cc873d7570 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/annotation/ScopedProxyMode.java +++ b/org.springframework.context/src/main/java/org/springframework/context/annotation/ScopedProxyMode.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ package org.springframework.context.annotation; * @see ScopeMetadata */ public enum ScopedProxyMode { - + /** * Do not create a scoped proxy. *

This proxy-mode is not typically useful when used with a @@ -37,16 +37,16 @@ public enum ScopedProxyMode { * is to be used as a dependency. */ NO, - + /** * Create a JDK dynamic proxy implementing all interfaces exposed by * the class of the target object. */ INTERFACES, - + /** * Create a class-based proxy (requires CGLIB). */ TARGET_CLASS - + } diff --git a/org.springframework.context/src/main/java/org/springframework/context/i18n/LocaleContextHolder.java b/org.springframework.context/src/main/java/org/springframework/context/i18n/LocaleContextHolder.java index 2b244f0332..f57e9b60d1 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/i18n/LocaleContextHolder.java +++ b/org.springframework.context/src/main/java/org/springframework/context/i18n/LocaleContextHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 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. @@ -40,10 +40,11 @@ import org.springframework.core.NamedThreadLocal; */ public abstract class LocaleContextHolder { - private static final ThreadLocal localeContextHolder = new NamedThreadLocal("Locale context"); + private static final ThreadLocal localeContextHolder = + new NamedThreadLocal("Locale context"); - private static final ThreadLocal inheritableLocaleContextHolder = - new NamedInheritableThreadLocal("Locale context"); + private static final ThreadLocal inheritableLocaleContextHolder = + new NamedInheritableThreadLocal("Locale context"); /** @@ -87,9 +88,9 @@ public abstract class LocaleContextHolder { * @return the current LocaleContext, or null if none */ public static LocaleContext getLocaleContext() { - LocaleContext localeContext = (LocaleContext) localeContextHolder.get(); + LocaleContext localeContext = localeContextHolder.get(); if (localeContext == null) { - localeContext = (LocaleContext) inheritableLocaleContextHolder.get(); + localeContext = inheritableLocaleContextHolder.get(); } return localeContext; } diff --git a/org.springframework.context/src/main/java/org/springframework/context/weaving/AspectJWeavingEnabler.java b/org.springframework.context/src/main/java/org/springframework/context/weaving/AspectJWeavingEnabler.java index b302988bf5..03c51c57fe 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/weaving/AspectJWeavingEnabler.java +++ b/org.springframework.context/src/main/java/org/springframework/context/weaving/AspectJWeavingEnabler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 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. @@ -63,8 +63,13 @@ public class AspectJWeavingEnabler public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { LoadTimeWeaver weaverToUse = this.loadTimeWeaver; - if (weaverToUse == null && InstrumentationLoadTimeWeaver.isInstrumentationAvailable()) { - weaverToUse = new InstrumentationLoadTimeWeaver(this.beanClassLoader); + if (weaverToUse == null) { + if (InstrumentationLoadTimeWeaver.isInstrumentationAvailable()) { + weaverToUse = new InstrumentationLoadTimeWeaver(this.beanClassLoader); + } + else { + throw new IllegalStateException("No LoadTimeWeaver available"); + } } weaverToUse.addTransformer(new AspectJClassBypassingClassFileTransformer( new ClassPreProcessorAgentAdapter())); diff --git a/org.springframework.context/src/main/java/org/springframework/context/weaving/LoadTimeWeaverAwareProcessor.java b/org.springframework.context/src/main/java/org/springframework/context/weaving/LoadTimeWeaverAwareProcessor.java index 081339c6cb..93a112d9b8 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/weaving/LoadTimeWeaverAwareProcessor.java +++ b/org.springframework.context/src/main/java/org/springframework/context/weaving/LoadTimeWeaverAwareProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 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. @@ -30,9 +30,8 @@ import org.springframework.util.Assert; * to beans that implement the {@link LoadTimeWeaverAware} interface. * *

{@link org.springframework.context.ApplicationContext Application contexts} - * will automatically register this with their underlying - * {@link BeanFactory bean factory}, provided that a default - * LoadTimeWeaver is actually available. + * will automatically register this with their underlying {@link BeanFactory bean factory}, + * provided that a default LoadTimeWeaver is actually available. * *

Applications should not use this class directly. * diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/UserCredentialsDataSourceAdapter.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/UserCredentialsDataSourceAdapter.java index c45f0be10e..629b5a4953 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/UserCredentialsDataSourceAdapter.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/UserCredentialsDataSourceAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 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. @@ -65,7 +65,8 @@ public class UserCredentialsDataSourceAdapter extends DelegatingDataSource { private String password; - private final ThreadLocal threadBoundCredentials = new NamedThreadLocal("Current JDBC user credentials"); + private final ThreadLocal threadBoundCredentials = + new NamedThreadLocal("Current JDBC user credentials"); /** @@ -126,7 +127,7 @@ public class UserCredentialsDataSourceAdapter extends DelegatingDataSource { */ @Override public Connection getConnection() throws SQLException { - JdbcUserCredentials threadCredentials = (JdbcUserCredentials) this.threadBoundCredentials.get(); + JdbcUserCredentials threadCredentials = this.threadBoundCredentials.get(); if (threadCredentials != null) { return doGetConnection(threadCredentials.username, threadCredentials.password); } diff --git a/org.springframework.jms/src/main/java/org/springframework/jms/connection/UserCredentialsConnectionFactoryAdapter.java b/org.springframework.jms/src/main/java/org/springframework/jms/connection/UserCredentialsConnectionFactoryAdapter.java index ed65ef65da..b8c2905efd 100644 --- a/org.springframework.jms/src/main/java/org/springframework/jms/connection/UserCredentialsConnectionFactoryAdapter.java +++ b/org.springframework.jms/src/main/java/org/springframework/jms/connection/UserCredentialsConnectionFactoryAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 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. @@ -76,7 +76,8 @@ public class UserCredentialsConnectionFactoryAdapter private String password; - private final ThreadLocal threadBoundCredentials = new NamedThreadLocal("Current JMS user credentials"); + private final ThreadLocal threadBoundCredentials = + new NamedThreadLocal("Current JMS user credentials"); /** @@ -141,7 +142,7 @@ public class UserCredentialsConnectionFactoryAdapter * @see #doCreateConnection */ public final Connection createConnection() throws JMSException { - JmsUserCredentials threadCredentials = (JmsUserCredentials) this.threadBoundCredentials.get(); + JmsUserCredentials threadCredentials = this.threadBoundCredentials.get(); if (threadCredentials != null) { return doCreateConnection(threadCredentials.username, threadCredentials.password); } @@ -186,7 +187,7 @@ public class UserCredentialsConnectionFactoryAdapter * @see #doCreateQueueConnection */ public final QueueConnection createQueueConnection() throws JMSException { - JmsUserCredentials threadCredentials = (JmsUserCredentials) this.threadBoundCredentials.get(); + JmsUserCredentials threadCredentials = this.threadBoundCredentials.get(); if (threadCredentials != null) { return doCreateQueueConnection(threadCredentials.username, threadCredentials.password); } @@ -235,7 +236,7 @@ public class UserCredentialsConnectionFactoryAdapter * @see #doCreateTopicConnection */ public final TopicConnection createTopicConnection() throws JMSException { - JmsUserCredentials threadCredentials = (JmsUserCredentials) this.threadBoundCredentials.get(); + JmsUserCredentials threadCredentials = this.threadBoundCredentials.get(); if (threadCredentials != null) { return doCreateTopicConnection(threadCredentials.username, threadCredentials.password); } diff --git a/org.springframework.orm/src/main/java/org/springframework/orm/ibatis/SqlMapClientFactoryBean.java b/org.springframework.orm/src/main/java/org/springframework/orm/ibatis/SqlMapClientFactoryBean.java index b3b9e706a7..dd3437d3a4 100644 --- a/org.springframework.orm/src/main/java/org/springframework/orm/ibatis/SqlMapClientFactoryBean.java +++ b/org.springframework.orm/src/main/java/org/springframework/orm/ibatis/SqlMapClientFactoryBean.java @@ -69,7 +69,7 @@ import org.springframework.util.ObjectUtils; */ public class SqlMapClientFactoryBean implements FactoryBean, InitializingBean { - private static final ThreadLocal configTimeLobHandlerHolder = new ThreadLocal(); + private static final ThreadLocal configTimeLobHandlerHolder = new ThreadLocal(); /** * Return the LobHandler for the currently configured iBATIS SqlMapClient, @@ -83,7 +83,7 @@ public class SqlMapClientFactoryBean implements FactoryBean, Initi * @see org.springframework.orm.ibatis.support.BlobSerializableTypeHandler */ public static LobHandler getConfigTimeLobHandler() { - return (LobHandler) configTimeLobHandlerHolder.get(); + return configTimeLobHandlerHolder.get(); } diff --git a/org.springframework.transaction/src/main/java/org/springframework/dao/annotation/PersistenceExceptionTranslationPostProcessor.java b/org.springframework.transaction/src/main/java/org/springframework/dao/annotation/PersistenceExceptionTranslationPostProcessor.java index d832a386a1..46b0d689c2 100644 --- a/org.springframework.transaction/src/main/java/org/springframework/dao/annotation/PersistenceExceptionTranslationPostProcessor.java +++ b/org.springframework.transaction/src/main/java/org/springframework/dao/annotation/PersistenceExceptionTranslationPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ package org.springframework.dao.annotation; import java.lang.annotation.Annotation; import org.springframework.aop.framework.Advised; +import org.springframework.aop.framework.AopInfrastructureBean; import org.springframework.aop.framework.ProxyConfig; import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.support.AopUtils; @@ -74,7 +75,7 @@ public class PersistenceExceptionTranslationPostProcessor extends ProxyConfig /** * Set the 'repository' annotation type. - * The default required annotation type is the {@link Repository} annotation. + * The default repository annotation type is the {@link Repository} annotation. *

This setter property exists so that developers can provide their own * (non-Spring-specific) annotation type to indicate that a class has a * repository role. @@ -110,10 +111,14 @@ public class PersistenceExceptionTranslationPostProcessor extends ProxyConfig } public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { - Class targetClass = - (bean instanceof Advised ? ((Advised) bean).getTargetSource().getTargetClass() : bean.getClass()); + if (bean instanceof AopInfrastructureBean) { + // Ignore AOP infrastructure such as scoped proxies. + return bean; + } + + Class targetClass = AopUtils.getTargetClass(bean); if (targetClass == null) { - // Can't do much here + // Can't do much here. return bean; } diff --git a/org.springframework.transaction/src/main/java/org/springframework/jca/cci/connection/ConnectionSpecConnectionFactoryAdapter.java b/org.springframework.transaction/src/main/java/org/springframework/jca/cci/connection/ConnectionSpecConnectionFactoryAdapter.java index 5df976c1ea..c2ab35369c 100644 --- a/org.springframework.transaction/src/main/java/org/springframework/jca/cci/connection/ConnectionSpecConnectionFactoryAdapter.java +++ b/org.springframework.transaction/src/main/java/org/springframework/jca/cci/connection/ConnectionSpecConnectionFactoryAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 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. @@ -66,7 +66,8 @@ public class ConnectionSpecConnectionFactoryAdapter extends DelegatingConnection private ConnectionSpec connectionSpec; - private final ThreadLocal threadBoundSpec = new NamedThreadLocal("Current CCI ConnectionSpec"); + private final ThreadLocal threadBoundSpec = + new NamedThreadLocal("Current CCI ConnectionSpec"); /** @@ -107,7 +108,7 @@ public class ConnectionSpecConnectionFactoryAdapter extends DelegatingConnection */ @Override public final Connection getConnection() throws ResourceException { - ConnectionSpec threadSpec = (ConnectionSpec) this.threadBoundSpec.get(); + ConnectionSpec threadSpec = this.threadBoundSpec.get(); if (threadSpec != null) { return doGetConnection(threadSpec); } diff --git a/org.springframework.transaction/src/main/java/org/springframework/jca/context/ResourceAdapterApplicationContext.java b/org.springframework.transaction/src/main/java/org/springframework/jca/context/ResourceAdapterApplicationContext.java index d6cead7e38..72303b4c32 100644 --- a/org.springframework.transaction/src/main/java/org/springframework/jca/context/ResourceAdapterApplicationContext.java +++ b/org.springframework.transaction/src/main/java/org/springframework/jca/context/ResourceAdapterApplicationContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 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. @@ -59,8 +59,8 @@ public class ResourceAdapterApplicationContext extends GenericApplicationContext beanFactory.registerResolvableDependency(BootstrapContext.class, this.bootstrapContext); // JCA WorkManager resolved lazily - may not be available. - beanFactory.registerResolvableDependency(WorkManager.class, new ObjectFactory() { - public Object getObject() { + beanFactory.registerResolvableDependency(WorkManager.class, new ObjectFactory() { + public WorkManager getObject() { return bootstrapContext.getWorkManager(); } }); diff --git a/org.springframework.transaction/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java b/org.springframework.transaction/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java index 3e66374532..a455ee7b1b 100644 --- a/org.springframework.transaction/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java +++ b/org.springframework.transaction/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 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. @@ -72,8 +72,8 @@ public abstract class TransactionAspectSupport implements InitializingBean { * (e.g. before and after advice) if the aspect involves more than a * single method (as will be the case for around advice). */ - private static final ThreadLocal transactionInfoHolder = - new NamedThreadLocal("Current aspect-driven transaction"); + private static final ThreadLocal transactionInfoHolder = + new NamedThreadLocal("Current aspect-driven transaction"); /** diff --git a/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/context/PortletApplicationContextUtils.java b/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/context/PortletApplicationContextUtils.java index 6d4da7e077..e4c5286329 100644 --- a/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/context/PortletApplicationContextUtils.java +++ b/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/context/PortletApplicationContextUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 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. @@ -111,8 +111,8 @@ public abstract class PortletApplicationContextUtils { beanFactory.registerScope(WebApplicationContext.SCOPE_SESSION, new SessionScope(false)); beanFactory.registerScope(WebApplicationContext.SCOPE_GLOBAL_SESSION, new SessionScope(true)); - beanFactory.registerResolvableDependency(PortletRequest.class, new ObjectFactory() { - public Object getObject() { + beanFactory.registerResolvableDependency(PortletRequest.class, new ObjectFactory() { + public PortletRequest getObject() { RequestAttributes requestAttr = RequestContextHolder.currentRequestAttributes(); if (!(requestAttr instanceof PortletRequestAttributes)) { throw new IllegalStateException("Current request is not a portlet request"); @@ -120,8 +120,8 @@ public abstract class PortletApplicationContextUtils { return ((PortletRequestAttributes) requestAttr).getRequest(); } }); - beanFactory.registerResolvableDependency(PortletSession.class, new ObjectFactory() { - public Object getObject() { + beanFactory.registerResolvableDependency(PortletSession.class, new ObjectFactory() { + public PortletSession getObject() { RequestAttributes requestAttr = RequestContextHolder.currentRequestAttributes(); if (!(requestAttr instanceof PortletRequestAttributes)) { throw new IllegalStateException("Current request is not a portlet request"); diff --git a/org.springframework.web/src/main/java/org/springframework/web/context/request/RequestContextHolder.java b/org.springframework.web/src/main/java/org/springframework/web/context/request/RequestContextHolder.java index e805882e6b..6e980cafd4 100644 --- a/org.springframework.web/src/main/java/org/springframework/web/context/request/RequestContextHolder.java +++ b/org.springframework.web/src/main/java/org/springframework/web/context/request/RequestContextHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 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. @@ -46,7 +46,8 @@ public abstract class RequestContextHolder { private static final boolean jsfPresent = ClassUtils.isPresent("javax.faces.context.FacesContext", RequestContextHolder.class.getClassLoader()); - private static final ThreadLocal requestAttributesHolder = new NamedThreadLocal("Request attributes"); + private static final ThreadLocal requestAttributesHolder = + new NamedThreadLocal("Request attributes"); private static final ThreadLocal inheritableRequestAttributesHolder = new NamedInheritableThreadLocal("Request context"); diff --git a/org.springframework.web/src/main/java/org/springframework/web/context/support/WebApplicationContextUtils.java b/org.springframework.web/src/main/java/org/springframework/web/context/support/WebApplicationContextUtils.java index e9290e6dae..282dea7a2b 100644 --- a/org.springframework.web/src/main/java/org/springframework/web/context/support/WebApplicationContextUtils.java +++ b/org.springframework.web/src/main/java/org/springframework/web/context/support/WebApplicationContextUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 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. @@ -124,8 +124,8 @@ public abstract class WebApplicationContextUtils { beanFactory.registerScope(WebApplicationContext.SCOPE_SESSION, new SessionScope(false)); beanFactory.registerScope(WebApplicationContext.SCOPE_GLOBAL_SESSION, new SessionScope(true)); - beanFactory.registerResolvableDependency(ServletRequest.class, new ObjectFactory() { - public Object getObject() { + beanFactory.registerResolvableDependency(ServletRequest.class, new ObjectFactory() { + public ServletRequest getObject() { RequestAttributes requestAttr = RequestContextHolder.currentRequestAttributes(); if (!(requestAttr instanceof ServletRequestAttributes)) { throw new IllegalStateException("Current request is not a servlet request"); @@ -133,8 +133,8 @@ public abstract class WebApplicationContextUtils { return ((ServletRequestAttributes) requestAttr).getRequest(); } }); - beanFactory.registerResolvableDependency(HttpSession.class, new ObjectFactory() { - public Object getObject() { + beanFactory.registerResolvableDependency(HttpSession.class, new ObjectFactory() { + public HttpSession getObject() { RequestAttributes requestAttr = RequestContextHolder.currentRequestAttributes(); if (!(requestAttr instanceof ServletRequestAttributes)) { throw new IllegalStateException("Current request is not a servlet request");