提交 2b371a7c 编写于 作者: C Chris Beams

Deprecate TransactionProxyFactoryBean

上级 c85ebd9a
/* /*
* 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"); * 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.
...@@ -37,12 +37,13 @@ import org.springframework.util.ClassUtils; ...@@ -37,12 +37,13 @@ import org.springframework.util.ClassUtils;
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 2.0 * @since 2.0
*/ */
@SuppressWarnings("serial")
public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig
implements FactoryBean<Object>, BeanClassLoaderAware, InitializingBean { implements FactoryBean<Object>, BeanClassLoaderAware, InitializingBean {
private Object target; private Object target;
private Class[] proxyInterfaces; private Class<?>[] proxyInterfaces;
private Object[] preInterceptors; private Object[] preInterceptors;
...@@ -77,7 +78,7 @@ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig ...@@ -77,7 +78,7 @@ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig
* out which interfaces need proxying by analyzing the target, * out which interfaces need proxying by analyzing the target,
* proxying all the interfaces that the target object implements. * proxying all the interfaces that the target object implements.
*/ */
public void setProxyInterfaces(Class[] proxyInterfaces) { public void setProxyInterfaces(Class<?>[] proxyInterfaces) {
this.proxyInterfaces = proxyInterfaces; this.proxyInterfaces = proxyInterfaces;
} }
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
package org.springframework.cache.interceptor; package org.springframework.cache.interceptor;
import org.springframework.aop.Pointcut;
import org.springframework.aop.framework.AbstractSingletonProxyFactoryBean; import org.springframework.aop.framework.AbstractSingletonProxyFactoryBean;
/** /**
...@@ -26,17 +25,17 @@ import org.springframework.aop.framework.AbstractSingletonProxyFactoryBean; ...@@ -26,17 +25,17 @@ import org.springframework.aop.framework.AbstractSingletonProxyFactoryBean;
* with a separate {@link CachingInterceptor} definition. * with a separate {@link CachingInterceptor} definition.
* *
* <p>This class is intended to cover the <i>typical</i> case of declarative * <p>This class is intended to cover the <i>typical</i> case of declarative
* transaction demarcation: namely, wrapping a singleton target object with a * caching: namely, wrapping a singleton target object with a caching proxy,
* caching proxy, proxying all the interfaces that the target implements. * proxying all the interfaces that the target implements.
* *
* @author Costin Leau * @author Costin Leau
* @see org.springframework.aop.framework.ProxyFactoryBean * @see org.springframework.aop.framework.ProxyFactoryBean
* @see CachingInterceptor * @see CachingInterceptor
*/ */
@SuppressWarnings("serial")
public class CacheProxyFactoryBean extends AbstractSingletonProxyFactoryBean { public class CacheProxyFactoryBean extends AbstractSingletonProxyFactoryBean {
private final CacheInterceptor cachingInterceptor = new CacheInterceptor(); private final CacheInterceptor cachingInterceptor = new CacheInterceptor();
private Pointcut pointcut;
@Override @Override
protected Object createMainInterceptor() { protected Object createMainInterceptor() {
......
/* /*
* 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"); * 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.
...@@ -17,10 +17,8 @@ ...@@ -17,10 +17,8 @@
package org.springframework.context.support; package org.springframework.context.support;
import org.springframework.aop.framework.AbstractSingletonProxyFactoryBean; import org.springframework.aop.framework.AbstractSingletonProxyFactoryBean;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.FactoryBean;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class TestProxyFactoryBean extends AbstractSingletonProxyFactoryBean implements BeanFactoryAware { public class TestProxyFactoryBean extends AbstractSingletonProxyFactoryBean implements BeanFactoryAware {
......
/* /*
* 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"); * 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.
...@@ -33,9 +33,18 @@ import org.springframework.transaction.PlatformTransactionManager; ...@@ -33,9 +33,18 @@ import org.springframework.transaction.PlatformTransactionManager;
* {@link org.springframework.aop.framework.ProxyFactoryBean} * {@link org.springframework.aop.framework.ProxyFactoryBean}
* with a separate {@link TransactionInterceptor} definition. * with a separate {@link TransactionInterceptor} definition.
* *
* <p>This class is intended to cover the <i>typical</i> case of declarative * <p><strong>HISTORICAL NOTE:</strong>This class was originally intended to cover the
* typical case of declarative
* transaction demarcation: namely, wrapping a singleton target object with a * 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 <a href="http://bit.ly/qUwvwz">
* declarative transaction management</a> section of the Spring reference documentation to
* understand the modern options for managing transactions in Spring applications.
* <strong>While this class has been deprecated starting with Spring 3.1, its use remains
* valid and supported</strong>. The deprecation serves as a strong reminder to users that
* simpler and superior approaches are available. What follows is the original
* (pre-deprecation) documentation.
* *
* <p>There are three main properties that need to be specified: * <p>There are three main properties that need to be specified:
* <ul> * <ul>
...@@ -71,36 +80,44 @@ import org.springframework.transaction.PlatformTransactionManager; ...@@ -71,36 +80,44 @@ import org.springframework.transaction.PlatformTransactionManager;
* This reduces the per-bean definition effort to a minimum. * This reduces the per-bean definition effort to a minimum.
* *
* <pre code="class"> * <pre code="class">
* &lt;bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" * {@code
* abstract="true"&gt; * <bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
* &lt;property name="transactionManager" ref="transactionManager"/&gt; * abstract="true">
* &lt;property name="transactionAttributes"&gt; * <property name="transactionManager" ref="transactionManager"/>
* &lt;props&gt; * <property name="transactionAttributes">
* &lt;prop key="insert*"&gt;PROPAGATION_REQUIRED&lt;/prop&gt; * <props>
* &lt;prop key="update*"&gt;PROPAGATION_REQUIRED&lt;/prop&gt; * <prop key="insert*">PROPAGATION_REQUIRED</prop>
* &lt;prop key="*"&gt;PROPAGATION_REQUIRED,readOnly&lt;/prop&gt; * <prop key="update*">PROPAGATION_REQUIRED</prop>
* &lt;/props&gt; * <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
* &lt;/property&gt; * </props>
* &lt;/bean&gt; * </property>
* </bean>
* *
* &lt;bean id="myProxy" parent="baseTransactionProxy"&gt; * <bean id="myProxy" parent="baseTransactionProxy">
* &lt;property name="target" ref="myTarget"/&gt; * <property name="target" ref="myTarget"/>
* &lt;/bean&gt; * </bean>
* *
* &lt;bean id="yourProxy" parent="baseTransactionProxy"&gt; * <bean id="yourProxy" parent="baseTransactionProxy">
* &lt;property name="target" ref="yourTarget"/&gt; * <property name="target" ref="yourTarget"/>
* &lt;/bean&gt;</pre> * </bean>}</pre>
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @author Dmitriy Kopylenko * @author Dmitriy Kopylenko
* @author Rod Johnson * @author Rod Johnson
* @author Chris Beams
* @since 21.08.2003 * @since 21.08.2003
* @see #setTransactionManager * @see #setTransactionManager
* @see #setTarget * @see #setTarget
* @see #setTransactionAttributes * @see #setTransactionAttributes
* @see TransactionInterceptor * @see TransactionInterceptor
* @see org.springframework.aop.framework.ProxyFactoryBean * @see org.springframework.aop.framework.ProxyFactoryBean
* @deprecated as of Spring 3.1 in favor of the {@code tx:} XML namespace as well as the
* {@link org.springframework.transaction.annotation.Transactional @Transactional} and
* {@link org.springframework.transaction.annotation.EnableTransactionManagement @EnableTransactionManagement}
* annotations
*/ */
@Deprecated
@SuppressWarnings("serial")
public class TransactionProxyFactoryBean extends AbstractSingletonProxyFactoryBean public class TransactionProxyFactoryBean extends AbstractSingletonProxyFactoryBean
implements BeanFactoryAware { implements BeanFactoryAware {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册