Java 5 code style
This commit is contained in:
parent
460977263d
commit
92588cddc6
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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) {
|
private static void useClassProxyingIfNecessary(BeanDefinitionRegistry registry, Element sourceElement) {
|
||||||
if (sourceElement != null) {
|
if (sourceElement != null) {
|
||||||
boolean proxyTargetClass = Boolean.valueOf(
|
boolean proxyTargetClass = Boolean.valueOf(sourceElement.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE));
|
||||||
sourceElement.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE)).booleanValue();
|
|
||||||
if (proxyTargetClass) {
|
if (proxyTargetClass) {
|
||||||
AopConfigUtils.forceAutoProxyCreatorToUseClassProxying(registry);
|
AopConfigUtils.forceAutoProxyCreatorToUseClassProxying(registry);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@ import java.io.IOException;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -38,7 +40,7 @@ import org.springframework.aop.target.EmptyTargetSource;
|
||||||
import org.springframework.aop.target.SingletonTargetSource;
|
import org.springframework.aop.target.SingletonTargetSource;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for AOP proxy configuration managers.
|
* 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.
|
* Add all of the given advisors to this proxy configuration.
|
||||||
* @param advisors the advisors to register
|
* @param advisors the advisors to register
|
||||||
|
* @deprecated as of Spring 3.0, in favor of {@link #addAdvisors}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void addAllAdvisors(Advisor[] advisors) {
|
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<Advisor> advisors) {
|
||||||
if (isFrozen()) {
|
if (isFrozen()) {
|
||||||
throw new AopConfigException("Cannot add advisor: Configuration is frozen.");
|
throw new AopConfigException("Cannot add advisor: Configuration is frozen.");
|
||||||
}
|
}
|
||||||
if (!ObjectUtils.isEmpty(advisors)) {
|
if (!CollectionUtils.isEmpty(advisors)) {
|
||||||
for (Advisor advisor : advisors) {
|
for (Advisor advisor : advisors) {
|
||||||
if (advisor instanceof IntroductionAdvisor) {
|
if (advisor instanceof IntroductionAdvisor) {
|
||||||
validateIntroductionAdvisor((IntroductionAdvisor) advisor);
|
validateIntroductionAdvisor((IntroductionAdvisor) advisor);
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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".
|
* the controlling proxy configuration has been set to "true".
|
||||||
* @see ProxyConfig#setExposeProxy
|
* @see ProxyConfig#setExposeProxy
|
||||||
*/
|
*/
|
||||||
private static final ThreadLocal currentProxy = new NamedThreadLocal("Current AOP proxy");
|
private static final ThreadLocal<Object> currentProxy = new NamedThreadLocal<Object>("Current AOP proxy");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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
|
* @param proxiedInterfaces the interfaces to introspect
|
||||||
*/
|
*/
|
||||||
private void findDefinedEqualsAndHashCodeMethods(Class[] proxiedInterfaces) {
|
private void findDefinedEqualsAndHashCodeMethods(Class[] proxiedInterfaces) {
|
||||||
for (int i = 0; i < proxiedInterfaces.length; i++) {
|
for (Class proxiedInterface : proxiedInterfaces) {
|
||||||
Class proxiedInterface = proxiedInterfaces[i];
|
|
||||||
Method[] methods = proxiedInterface.getDeclaredMethods();
|
Method[] methods = proxiedInterface.getDeclaredMethods();
|
||||||
for (int j = 0; j < methods.length; j++) {
|
for (Method method : methods) {
|
||||||
Method method = methods[j];
|
|
||||||
if (AopUtils.isEqualsMethod(method)) {
|
if (AopUtils.isEqualsMethod(method)) {
|
||||||
this.equalsDefined = true;
|
this.equalsDefined = true;
|
||||||
}
|
}
|
||||||
|
@ -187,7 +185,7 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the interception chain for this method.
|
// Get the interception chain for this method.
|
||||||
List chain = this.advised.getInterceptorsAndDynamicInterceptionAdvice(method, targetClass);
|
List<Object> chain = this.advised.getInterceptorsAndDynamicInterceptionAdvice(method, targetClass);
|
||||||
|
|
||||||
// Check whether we have any advice. If we don't, we can fallback on direct
|
// 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.
|
// reflective invocation of the target, and avoid creating a MethodInvocation.
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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());
|
protected final Log logger = LogFactory.getLog(getClass());
|
||||||
|
|
||||||
/** Default value is same as non-ordered */
|
/** Default value is same as non-ordered */
|
||||||
private int order = Integer.MAX_VALUE;
|
private int order = Ordered.LOWEST_PRECEDENCE;
|
||||||
|
|
||||||
/** Default is global AdvisorAdapterRegistry */
|
/** Default is global AdvisorAdapterRegistry */
|
||||||
private AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
|
private AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 {
|
public class ProxyCreationContext {
|
||||||
|
|
||||||
/** ThreadLocal holding the current proxied bean name during Advisor matching */
|
/** ThreadLocal holding the current proxied bean name during Advisor matching */
|
||||||
private static final ThreadLocal currentProxiedBeanName =
|
private static final ThreadLocal<String> currentProxiedBeanName =
|
||||||
new NamedThreadLocal("Name of currently proxied bean");
|
new NamedThreadLocal<String>("Name of currently proxied bean");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,7 +38,7 @@ public class ProxyCreationContext {
|
||||||
* @return the name of the bean, or <code>null</code> if none available
|
* @return the name of the bean, or <code>null</code> if none available
|
||||||
*/
|
*/
|
||||||
public static String getCurrentProxiedBeanName() {
|
public static String getCurrentProxiedBeanName() {
|
||||||
return (String) currentProxiedBeanName.get();
|
return currentProxiedBeanName.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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;
|
||||||
*
|
*
|
||||||
* <p>The default scope is "singleton", and the default is to <i>not</i> create
|
* <p>The default scope is "singleton", and the default is to <i>not</i> create
|
||||||
* scoped-proxies.
|
* scoped-proxies.
|
||||||
*
|
*
|
||||||
* @author Mark Fisher
|
* @author Mark Fisher
|
||||||
* @since 2.5
|
* @since 2.5
|
||||||
* @see ScopeMetadataResolver
|
* @see ScopeMetadataResolver
|
||||||
|
@ -37,36 +37,32 @@ public class ScopeMetadata {
|
||||||
private ScopedProxyMode scopedProxyMode = ScopedProxyMode.NO;
|
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.
|
* Set the name of the scope.
|
||||||
* @param scopeName said scope name
|
|
||||||
*/
|
*/
|
||||||
public void setScopeName(String scopeName) {
|
public void setScopeName(String scopeName) {
|
||||||
this.scopeName = scopeName;
|
this.scopeName = scopeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the proxy-mode to be applied to the scoped instance.
|
* Get the name of the scope.
|
||||||
* @return said scoped-proxy mode
|
|
||||||
*/
|
*/
|
||||||
public ScopedProxyMode getScopedProxyMode() {
|
public String getScopeName() {
|
||||||
return scopedProxyMode;
|
return this.scopeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the proxy-mode to be applied to the scoped instance.
|
* Set the proxy-mode to be applied to the scoped instance.
|
||||||
* @param scopedProxyMode said scoped-proxy mode
|
|
||||||
*/
|
*/
|
||||||
public void setScopedProxyMode(ScopedProxyMode scopedProxyMode) {
|
public void setScopedProxyMode(ScopedProxyMode scopedProxyMode) {
|
||||||
this.scopedProxyMode = scopedProxyMode;
|
this.scopedProxyMode = scopedProxyMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the proxy-mode to be applied to the scoped instance.
|
||||||
|
*/
|
||||||
|
public ScopedProxyMode getScopedProxyMode() {
|
||||||
|
return this.scopedProxyMode;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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
|
* @see ScopeMetadata
|
||||||
*/
|
*/
|
||||||
public enum ScopedProxyMode {
|
public enum ScopedProxyMode {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do not create a scoped proxy.
|
* Do not create a scoped proxy.
|
||||||
* <p>This proxy-mode is not typically useful when used with a
|
* <p>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.
|
* is to be used as a dependency.
|
||||||
*/
|
*/
|
||||||
NO,
|
NO,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a JDK dynamic proxy implementing <i>all</i> interfaces exposed by
|
* Create a JDK dynamic proxy implementing <i>all</i> interfaces exposed by
|
||||||
* the class of the target object.
|
* the class of the target object.
|
||||||
*/
|
*/
|
||||||
INTERFACES,
|
INTERFACES,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a class-based proxy (requires CGLIB).
|
* Create a class-based proxy (requires CGLIB).
|
||||||
*/
|
*/
|
||||||
TARGET_CLASS
|
TARGET_CLASS
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 {
|
public abstract class LocaleContextHolder {
|
||||||
|
|
||||||
private static final ThreadLocal localeContextHolder = new NamedThreadLocal("Locale context");
|
private static final ThreadLocal<LocaleContext> localeContextHolder =
|
||||||
|
new NamedThreadLocal<LocaleContext>("Locale context");
|
||||||
|
|
||||||
private static final ThreadLocal inheritableLocaleContextHolder =
|
private static final ThreadLocal<LocaleContext> inheritableLocaleContextHolder =
|
||||||
new NamedInheritableThreadLocal("Locale context");
|
new NamedInheritableThreadLocal<LocaleContext>("Locale context");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,9 +88,9 @@ public abstract class LocaleContextHolder {
|
||||||
* @return the current LocaleContext, or <code>null</code> if none
|
* @return the current LocaleContext, or <code>null</code> if none
|
||||||
*/
|
*/
|
||||||
public static LocaleContext getLocaleContext() {
|
public static LocaleContext getLocaleContext() {
|
||||||
LocaleContext localeContext = (LocaleContext) localeContextHolder.get();
|
LocaleContext localeContext = localeContextHolder.get();
|
||||||
if (localeContext == null) {
|
if (localeContext == null) {
|
||||||
localeContext = (LocaleContext) inheritableLocaleContextHolder.get();
|
localeContext = inheritableLocaleContextHolder.get();
|
||||||
}
|
}
|
||||||
return localeContext;
|
return localeContext;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 {
|
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||||
LoadTimeWeaver weaverToUse = this.loadTimeWeaver;
|
LoadTimeWeaver weaverToUse = this.loadTimeWeaver;
|
||||||
if (weaverToUse == null && InstrumentationLoadTimeWeaver.isInstrumentationAvailable()) {
|
if (weaverToUse == null) {
|
||||||
weaverToUse = new InstrumentationLoadTimeWeaver(this.beanClassLoader);
|
if (InstrumentationLoadTimeWeaver.isInstrumentationAvailable()) {
|
||||||
|
weaverToUse = new InstrumentationLoadTimeWeaver(this.beanClassLoader);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new IllegalStateException("No LoadTimeWeaver available");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
weaverToUse.addTransformer(new AspectJClassBypassingClassFileTransformer(
|
weaverToUse.addTransformer(new AspectJClassBypassingClassFileTransformer(
|
||||||
new ClassPreProcessorAgentAdapter()));
|
new ClassPreProcessorAgentAdapter()));
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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.
|
* to beans that implement the {@link LoadTimeWeaverAware} interface.
|
||||||
*
|
*
|
||||||
* <p>{@link org.springframework.context.ApplicationContext Application contexts}
|
* <p>{@link org.springframework.context.ApplicationContext Application contexts}
|
||||||
* will automatically register this with their underlying
|
* will automatically register this with their underlying {@link BeanFactory bean factory},
|
||||||
* {@link BeanFactory bean factory}, provided that a default
|
* provided that a default <code>LoadTimeWeaver</code> is actually available.
|
||||||
* <code>LoadTimeWeaver</code> is actually available.
|
|
||||||
*
|
*
|
||||||
* <p>Applications should not use this class directly.
|
* <p>Applications should not use this class directly.
|
||||||
*
|
*
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 String password;
|
||||||
|
|
||||||
private final ThreadLocal threadBoundCredentials = new NamedThreadLocal("Current JDBC user credentials");
|
private final ThreadLocal<JdbcUserCredentials> threadBoundCredentials =
|
||||||
|
new NamedThreadLocal<JdbcUserCredentials>("Current JDBC user credentials");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -126,7 +127,7 @@ public class UserCredentialsDataSourceAdapter extends DelegatingDataSource {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Connection getConnection() throws SQLException {
|
public Connection getConnection() throws SQLException {
|
||||||
JdbcUserCredentials threadCredentials = (JdbcUserCredentials) this.threadBoundCredentials.get();
|
JdbcUserCredentials threadCredentials = this.threadBoundCredentials.get();
|
||||||
if (threadCredentials != null) {
|
if (threadCredentials != null) {
|
||||||
return doGetConnection(threadCredentials.username, threadCredentials.password);
|
return doGetConnection(threadCredentials.username, threadCredentials.password);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 String password;
|
||||||
|
|
||||||
private final ThreadLocal threadBoundCredentials = new NamedThreadLocal("Current JMS user credentials");
|
private final ThreadLocal<JmsUserCredentials> threadBoundCredentials =
|
||||||
|
new NamedThreadLocal<JmsUserCredentials>("Current JMS user credentials");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -141,7 +142,7 @@ public class UserCredentialsConnectionFactoryAdapter
|
||||||
* @see #doCreateConnection
|
* @see #doCreateConnection
|
||||||
*/
|
*/
|
||||||
public final Connection createConnection() throws JMSException {
|
public final Connection createConnection() throws JMSException {
|
||||||
JmsUserCredentials threadCredentials = (JmsUserCredentials) this.threadBoundCredentials.get();
|
JmsUserCredentials threadCredentials = this.threadBoundCredentials.get();
|
||||||
if (threadCredentials != null) {
|
if (threadCredentials != null) {
|
||||||
return doCreateConnection(threadCredentials.username, threadCredentials.password);
|
return doCreateConnection(threadCredentials.username, threadCredentials.password);
|
||||||
}
|
}
|
||||||
|
@ -186,7 +187,7 @@ public class UserCredentialsConnectionFactoryAdapter
|
||||||
* @see #doCreateQueueConnection
|
* @see #doCreateQueueConnection
|
||||||
*/
|
*/
|
||||||
public final QueueConnection createQueueConnection() throws JMSException {
|
public final QueueConnection createQueueConnection() throws JMSException {
|
||||||
JmsUserCredentials threadCredentials = (JmsUserCredentials) this.threadBoundCredentials.get();
|
JmsUserCredentials threadCredentials = this.threadBoundCredentials.get();
|
||||||
if (threadCredentials != null) {
|
if (threadCredentials != null) {
|
||||||
return doCreateQueueConnection(threadCredentials.username, threadCredentials.password);
|
return doCreateQueueConnection(threadCredentials.username, threadCredentials.password);
|
||||||
}
|
}
|
||||||
|
@ -235,7 +236,7 @@ public class UserCredentialsConnectionFactoryAdapter
|
||||||
* @see #doCreateTopicConnection
|
* @see #doCreateTopicConnection
|
||||||
*/
|
*/
|
||||||
public final TopicConnection createTopicConnection() throws JMSException {
|
public final TopicConnection createTopicConnection() throws JMSException {
|
||||||
JmsUserCredentials threadCredentials = (JmsUserCredentials) this.threadBoundCredentials.get();
|
JmsUserCredentials threadCredentials = this.threadBoundCredentials.get();
|
||||||
if (threadCredentials != null) {
|
if (threadCredentials != null) {
|
||||||
return doCreateTopicConnection(threadCredentials.username, threadCredentials.password);
|
return doCreateTopicConnection(threadCredentials.username, threadCredentials.password);
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ import org.springframework.util.ObjectUtils;
|
||||||
*/
|
*/
|
||||||
public class SqlMapClientFactoryBean implements FactoryBean<SqlMapClient>, InitializingBean {
|
public class SqlMapClientFactoryBean implements FactoryBean<SqlMapClient>, InitializingBean {
|
||||||
|
|
||||||
private static final ThreadLocal configTimeLobHandlerHolder = new ThreadLocal();
|
private static final ThreadLocal<LobHandler> configTimeLobHandlerHolder = new ThreadLocal<LobHandler>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the LobHandler for the currently configured iBATIS SqlMapClient,
|
* Return the LobHandler for the currently configured iBATIS SqlMapClient,
|
||||||
|
@ -83,7 +83,7 @@ public class SqlMapClientFactoryBean implements FactoryBean<SqlMapClient>, Initi
|
||||||
* @see org.springframework.orm.ibatis.support.BlobSerializableTypeHandler
|
* @see org.springframework.orm.ibatis.support.BlobSerializableTypeHandler
|
||||||
*/
|
*/
|
||||||
public static LobHandler getConfigTimeLobHandler() {
|
public static LobHandler getConfigTimeLobHandler() {
|
||||||
return (LobHandler) configTimeLobHandlerHolder.get();
|
return configTimeLobHandlerHolder.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 java.lang.annotation.Annotation;
|
||||||
|
|
||||||
import org.springframework.aop.framework.Advised;
|
import org.springframework.aop.framework.Advised;
|
||||||
|
import org.springframework.aop.framework.AopInfrastructureBean;
|
||||||
import org.springframework.aop.framework.ProxyConfig;
|
import org.springframework.aop.framework.ProxyConfig;
|
||||||
import org.springframework.aop.framework.ProxyFactory;
|
import org.springframework.aop.framework.ProxyFactory;
|
||||||
import org.springframework.aop.support.AopUtils;
|
import org.springframework.aop.support.AopUtils;
|
||||||
|
@ -74,7 +75,7 @@ public class PersistenceExceptionTranslationPostProcessor extends ProxyConfig
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the 'repository' annotation type.
|
* 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.
|
||||||
* <p>This setter property exists so that developers can provide their own
|
* <p>This setter property exists so that developers can provide their own
|
||||||
* (non-Spring-specific) annotation type to indicate that a class has a
|
* (non-Spring-specific) annotation type to indicate that a class has a
|
||||||
* repository role.
|
* repository role.
|
||||||
|
@ -110,10 +111,14 @@ public class PersistenceExceptionTranslationPostProcessor extends ProxyConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||||
Class<?> targetClass =
|
if (bean instanceof AopInfrastructureBean) {
|
||||||
(bean instanceof Advised ? ((Advised) bean).getTargetSource().getTargetClass() : bean.getClass());
|
// Ignore AOP infrastructure such as scoped proxies.
|
||||||
|
return bean;
|
||||||
|
}
|
||||||
|
|
||||||
|
Class targetClass = AopUtils.getTargetClass(bean);
|
||||||
if (targetClass == null) {
|
if (targetClass == null) {
|
||||||
// Can't do much here
|
// Can't do much here.
|
||||||
return bean;
|
return bean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 ConnectionSpec connectionSpec;
|
||||||
|
|
||||||
private final ThreadLocal threadBoundSpec = new NamedThreadLocal("Current CCI ConnectionSpec");
|
private final ThreadLocal<ConnectionSpec> threadBoundSpec =
|
||||||
|
new NamedThreadLocal<ConnectionSpec>("Current CCI ConnectionSpec");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,7 +108,7 @@ public class ConnectionSpecConnectionFactoryAdapter extends DelegatingConnection
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final Connection getConnection() throws ResourceException {
|
public final Connection getConnection() throws ResourceException {
|
||||||
ConnectionSpec threadSpec = (ConnectionSpec) this.threadBoundSpec.get();
|
ConnectionSpec threadSpec = this.threadBoundSpec.get();
|
||||||
if (threadSpec != null) {
|
if (threadSpec != null) {
|
||||||
return doGetConnection(threadSpec);
|
return doGetConnection(threadSpec);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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);
|
beanFactory.registerResolvableDependency(BootstrapContext.class, this.bootstrapContext);
|
||||||
|
|
||||||
// JCA WorkManager resolved lazily - may not be available.
|
// JCA WorkManager resolved lazily - may not be available.
|
||||||
beanFactory.registerResolvableDependency(WorkManager.class, new ObjectFactory() {
|
beanFactory.registerResolvableDependency(WorkManager.class, new ObjectFactory<WorkManager>() {
|
||||||
public Object getObject() {
|
public WorkManager getObject() {
|
||||||
return bootstrapContext.getWorkManager();
|
return bootstrapContext.getWorkManager();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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
|
* (e.g. before and after advice) if the aspect involves more than a
|
||||||
* single method (as will be the case for around advice).
|
* single method (as will be the case for around advice).
|
||||||
*/
|
*/
|
||||||
private static final ThreadLocal transactionInfoHolder =
|
private static final ThreadLocal<TransactionInfo> transactionInfoHolder =
|
||||||
new NamedThreadLocal("Current aspect-driven transaction");
|
new NamedThreadLocal<TransactionInfo>("Current aspect-driven transaction");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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_SESSION, new SessionScope(false));
|
||||||
beanFactory.registerScope(WebApplicationContext.SCOPE_GLOBAL_SESSION, new SessionScope(true));
|
beanFactory.registerScope(WebApplicationContext.SCOPE_GLOBAL_SESSION, new SessionScope(true));
|
||||||
|
|
||||||
beanFactory.registerResolvableDependency(PortletRequest.class, new ObjectFactory() {
|
beanFactory.registerResolvableDependency(PortletRequest.class, new ObjectFactory<PortletRequest>() {
|
||||||
public Object getObject() {
|
public PortletRequest getObject() {
|
||||||
RequestAttributes requestAttr = RequestContextHolder.currentRequestAttributes();
|
RequestAttributes requestAttr = RequestContextHolder.currentRequestAttributes();
|
||||||
if (!(requestAttr instanceof PortletRequestAttributes)) {
|
if (!(requestAttr instanceof PortletRequestAttributes)) {
|
||||||
throw new IllegalStateException("Current request is not a portlet request");
|
throw new IllegalStateException("Current request is not a portlet request");
|
||||||
|
@ -120,8 +120,8 @@ public abstract class PortletApplicationContextUtils {
|
||||||
return ((PortletRequestAttributes) requestAttr).getRequest();
|
return ((PortletRequestAttributes) requestAttr).getRequest();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
beanFactory.registerResolvableDependency(PortletSession.class, new ObjectFactory() {
|
beanFactory.registerResolvableDependency(PortletSession.class, new ObjectFactory<PortletSession>() {
|
||||||
public Object getObject() {
|
public PortletSession getObject() {
|
||||||
RequestAttributes requestAttr = RequestContextHolder.currentRequestAttributes();
|
RequestAttributes requestAttr = RequestContextHolder.currentRequestAttributes();
|
||||||
if (!(requestAttr instanceof PortletRequestAttributes)) {
|
if (!(requestAttr instanceof PortletRequestAttributes)) {
|
||||||
throw new IllegalStateException("Current request is not a portlet request");
|
throw new IllegalStateException("Current request is not a portlet request");
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 =
|
private static final boolean jsfPresent =
|
||||||
ClassUtils.isPresent("javax.faces.context.FacesContext", RequestContextHolder.class.getClassLoader());
|
ClassUtils.isPresent("javax.faces.context.FacesContext", RequestContextHolder.class.getClassLoader());
|
||||||
|
|
||||||
private static final ThreadLocal<RequestAttributes> requestAttributesHolder = new NamedThreadLocal<RequestAttributes>("Request attributes");
|
private static final ThreadLocal<RequestAttributes> requestAttributesHolder =
|
||||||
|
new NamedThreadLocal<RequestAttributes>("Request attributes");
|
||||||
|
|
||||||
private static final ThreadLocal<RequestAttributes> inheritableRequestAttributesHolder =
|
private static final ThreadLocal<RequestAttributes> inheritableRequestAttributesHolder =
|
||||||
new NamedInheritableThreadLocal<RequestAttributes>("Request context");
|
new NamedInheritableThreadLocal<RequestAttributes>("Request context");
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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_SESSION, new SessionScope(false));
|
||||||
beanFactory.registerScope(WebApplicationContext.SCOPE_GLOBAL_SESSION, new SessionScope(true));
|
beanFactory.registerScope(WebApplicationContext.SCOPE_GLOBAL_SESSION, new SessionScope(true));
|
||||||
|
|
||||||
beanFactory.registerResolvableDependency(ServletRequest.class, new ObjectFactory() {
|
beanFactory.registerResolvableDependency(ServletRequest.class, new ObjectFactory<ServletRequest>() {
|
||||||
public Object getObject() {
|
public ServletRequest getObject() {
|
||||||
RequestAttributes requestAttr = RequestContextHolder.currentRequestAttributes();
|
RequestAttributes requestAttr = RequestContextHolder.currentRequestAttributes();
|
||||||
if (!(requestAttr instanceof ServletRequestAttributes)) {
|
if (!(requestAttr instanceof ServletRequestAttributes)) {
|
||||||
throw new IllegalStateException("Current request is not a servlet request");
|
throw new IllegalStateException("Current request is not a servlet request");
|
||||||
|
@ -133,8 +133,8 @@ public abstract class WebApplicationContextUtils {
|
||||||
return ((ServletRequestAttributes) requestAttr).getRequest();
|
return ((ServletRequestAttributes) requestAttr).getRequest();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
beanFactory.registerResolvableDependency(HttpSession.class, new ObjectFactory() {
|
beanFactory.registerResolvableDependency(HttpSession.class, new ObjectFactory<HttpSession>() {
|
||||||
public Object getObject() {
|
public HttpSession getObject() {
|
||||||
RequestAttributes requestAttr = RequestContextHolder.currentRequestAttributes();
|
RequestAttributes requestAttr = RequestContextHolder.currentRequestAttributes();
|
||||||
if (!(requestAttr instanceof ServletRequestAttributes)) {
|
if (!(requestAttr instanceof ServletRequestAttributes)) {
|
||||||
throw new IllegalStateException("Current request is not a servlet request");
|
throw new IllegalStateException("Current request is not a servlet request");
|
||||||
|
|
Loading…
Reference in New Issue