From 2b371a7c9abf8b711031f01ff555cb2344a8b833 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 26 Jul 2011 22:29:04 +0000 Subject: [PATCH] Deprecate TransactionProxyFactoryBean --- .../AbstractSingletonProxyFactoryBean.java | 7 ++- .../interceptor/CacheProxyFactoryBean.java | 7 +-- .../context/support/TestProxyFactoryBean.java | 4 +- .../TransactionProxyFactoryBean.java | 57 ++++++++++++------- 4 files changed, 45 insertions(+), 30 deletions(-) diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/framework/AbstractSingletonProxyFactoryBean.java b/org.springframework.aop/src/main/java/org/springframework/aop/framework/AbstractSingletonProxyFactoryBean.java index a58c86584cc..6a113fad149 100644 --- a/org.springframework.aop/src/main/java/org/springframework/aop/framework/AbstractSingletonProxyFactoryBean.java +++ b/org.springframework.aop/src/main/java/org/springframework/aop/framework/AbstractSingletonProxyFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2011 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. @@ -37,12 +37,13 @@ import org.springframework.util.ClassUtils; * @author Juergen Hoeller * @since 2.0 */ +@SuppressWarnings("serial") public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig implements FactoryBean, BeanClassLoaderAware, InitializingBean { private Object target; - private Class[] proxyInterfaces; + private Class[] proxyInterfaces; private Object[] preInterceptors; @@ -77,7 +78,7 @@ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig * out which interfaces need proxying by analyzing the target, * proxying all the interfaces that the target object implements. */ - public void setProxyInterfaces(Class[] proxyInterfaces) { + public void setProxyInterfaces(Class[] proxyInterfaces) { this.proxyInterfaces = proxyInterfaces; } diff --git a/org.springframework.context/src/main/java/org/springframework/cache/interceptor/CacheProxyFactoryBean.java b/org.springframework.context/src/main/java/org/springframework/cache/interceptor/CacheProxyFactoryBean.java index 5e9bbd0d26d..5c558b4d89f 100644 --- a/org.springframework.context/src/main/java/org/springframework/cache/interceptor/CacheProxyFactoryBean.java +++ b/org.springframework.context/src/main/java/org/springframework/cache/interceptor/CacheProxyFactoryBean.java @@ -16,7 +16,6 @@ package org.springframework.cache.interceptor; -import org.springframework.aop.Pointcut; import org.springframework.aop.framework.AbstractSingletonProxyFactoryBean; /** @@ -26,17 +25,17 @@ import org.springframework.aop.framework.AbstractSingletonProxyFactoryBean; * with a separate {@link CachingInterceptor} definition. * *

This class is intended to cover the typical case of declarative - * transaction demarcation: namely, wrapping a singleton target object with a - * caching proxy, proxying all the interfaces that the target implements. + * caching: namely, wrapping a singleton target object with a caching proxy, + * proxying all the interfaces that the target implements. * * @author Costin Leau * @see org.springframework.aop.framework.ProxyFactoryBean * @see CachingInterceptor */ +@SuppressWarnings("serial") public class CacheProxyFactoryBean extends AbstractSingletonProxyFactoryBean { private final CacheInterceptor cachingInterceptor = new CacheInterceptor(); - private Pointcut pointcut; @Override protected Object createMainInterceptor() { diff --git a/org.springframework.context/src/test/java/org/springframework/context/support/TestProxyFactoryBean.java b/org.springframework.context/src/test/java/org/springframework/context/support/TestProxyFactoryBean.java index 07467873b5a..71c11ec4e36 100644 --- a/org.springframework.context/src/test/java/org/springframework/context/support/TestProxyFactoryBean.java +++ b/org.springframework.context/src/test/java/org/springframework/context/support/TestProxyFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2011 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,10 +17,8 @@ package org.springframework.context.support; import org.springframework.aop.framework.AbstractSingletonProxyFactoryBean; -import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.beans.factory.FactoryBean; @SuppressWarnings("serial") public class TestProxyFactoryBean extends AbstractSingletonProxyFactoryBean implements BeanFactoryAware { diff --git a/org.springframework.transaction/src/main/java/org/springframework/transaction/interceptor/TransactionProxyFactoryBean.java b/org.springframework.transaction/src/main/java/org/springframework/transaction/interceptor/TransactionProxyFactoryBean.java index 762b5122694..20d5cdec886 100644 --- a/org.springframework.transaction/src/main/java/org/springframework/transaction/interceptor/TransactionProxyFactoryBean.java +++ b/org.springframework.transaction/src/main/java/org/springframework/transaction/interceptor/TransactionProxyFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2011 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. @@ -33,9 +33,18 @@ import org.springframework.transaction.PlatformTransactionManager; * {@link org.springframework.aop.framework.ProxyFactoryBean} * with a separate {@link TransactionInterceptor} definition. * - *

This class is intended to cover the typical case of declarative + *

HISTORICAL NOTE:This class was originally intended to cover the + * typical case of declarative * transaction demarcation: namely, wrapping a singleton target object with a - * transactional proxy, proxying all the interfaces that the target implements. + * transactional proxy, proxying all the interfaces that the target implements. However, + * in Spring versions 2.0 and beyond, the functionality provided here is superseded + * by the more convenient {@code tx:} XML namespace. See the + * declarative transaction management section of the Spring reference documentation to + * understand the modern options for managing transactions in Spring applications. + * While this class has been deprecated starting with Spring 3.1, its use remains + * valid and supported. The deprecation serves as a strong reminder to users that + * simpler and superior approaches are available. What follows is the original + * (pre-deprecation) documentation. * *

There are three main properties that need to be specified: *