站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 2.0.5 API 文档英文版

PersistenceExceptionTranslationInterceptor (Spring Framework API 2.0) - Spring Framework 2.0.5 API 文档英文版

The Spring Framework

org.springframework.dao.support
Class PersistenceExceptionTranslationInterceptor

java.lang.Object
  extended by org.springframework.dao.support.PersistenceExceptionTranslationInterceptor
All Implemented Interfaces:
Advice, Interceptor, MethodInterceptor, BeanFactoryAware, InitializingBean

public class PersistenceExceptionTranslationInterceptor
extends Object
implements MethodInterceptor, BeanFactoryAware, InitializingBean

AOP Alliance MethodInterceptor that provides persistence exception translation based on a given PersistenceExceptionTranslator.

Delegates to the given PersistenceExceptionTranslator to translate a RuntimeException thrown into Spring's DataAccessException hierarchy (if appropriate). If the RuntimeException in question is declared on the target method, it is always propagated as-is (with no translation applied).

Since:
2.0
Author:
Rod Johnson, Juergen Hoeller
See Also:
PersistenceExceptionTranslator

Constructor Summary
PersistenceExceptionTranslationInterceptor()
          Create a new PersistenceExceptionTranslationInterceptor.
PersistenceExceptionTranslationInterceptor(ListableBeanFactory beanFactory)
          Create a new PersistenceExceptionTranslationInterceptor, autodetecting PersistenceExceptionTranslators in the given BeanFactory.
PersistenceExceptionTranslationInterceptor(PersistenceExceptionTranslator persistenceExceptionTranslator)
          Create a new PersistenceExceptionTranslationInterceptor for the given PersistenceExceptionTranslator.
 
Method Summary
 void afterPropertiesSet()
          Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
protected  PersistenceExceptionTranslator detectPersistenceExceptionTranslators(ListableBeanFactory beanFactory)
          Detect all PersistenceExceptionTranslators in the given BeanFactory.
 Object invoke(MethodInvocation mi)
           
 void setBeanFactory(BeanFactory beanFactory)
          Callback that supplies the owning factory to a bean instance.
 void setPersistenceExceptionTranslator(PersistenceExceptionTranslator pet)
          Specify the PersistenceExceptionTranslator to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistenceExceptionTranslationInterceptor

public PersistenceExceptionTranslationInterceptor()
Create a new PersistenceExceptionTranslationInterceptor. Needs to be configured with a PersistenceExceptionTranslator afterwards.

See Also:
setPersistenceExceptionTranslator(org.springframework.dao.support.PersistenceExceptionTranslator)

PersistenceExceptionTranslationInterceptor

public PersistenceExceptionTranslationInterceptor(PersistenceExceptionTranslator persistenceExceptionTranslator)
Create a new PersistenceExceptionTranslationInterceptor for the given PersistenceExceptionTranslator.

Parameters:
persistenceExceptionTranslator - the PersistenceExceptionTranslator to use

PersistenceExceptionTranslationInterceptor

public PersistenceExceptionTranslationInterceptor(ListableBeanFactory beanFactory)
Create a new PersistenceExceptionTranslationInterceptor, autodetecting PersistenceExceptionTranslators in the given BeanFactory.

Parameters:
beanFactory - the ListableBeanFactory to obtaining all PersistenceExceptionTranslators from
Method Detail

setPersistenceExceptionTranslator

public void setPersistenceExceptionTranslator(PersistenceExceptionTranslator pet)
Specify the PersistenceExceptionTranslator to use.

Default is to autodetect all PersistenceExceptionTranslators in the containing BeanFactory, using them in a chain.

See Also:
detectPersistenceExceptionTranslators(org.springframework.beans.factory.ListableBeanFactory)

setBeanFactory

public void setBeanFactory(BeanFactory beanFactory)
                    throws BeansException
Description copied from interface: BeanFactoryAware
Callback that supplies the owning factory to a bean instance.

Invoked after the population of normal bean properties but before an initialization callback such as InitializingBean.afterPropertiesSet() or a custom init-method.

Specified by:
setBeanFactory in interface BeanFactoryAware
Parameters:
beanFactory - owning BeanFactory (never null). The bean can immediately call methods on the factory.
Throws:
BeansException - in case of initialization errors
See Also:
BeanInitializationException

afterPropertiesSet

public void afterPropertiesSet()
Description copied from interface: InitializingBean
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).

This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.

Specified by:
afterPropertiesSet in interface InitializingBean

detectPersistenceExceptionTranslators

protected PersistenceExceptionTranslator detectPersistenceExceptionTranslators(ListableBeanFactory beanFactory)
Detect all PersistenceExceptionTranslators in the given BeanFactory.

Parameters:
beanFactory - the ListableBeanFactory to obtaining all PersistenceExceptionTranslators from
Returns:
a chained PersistenceExceptionTranslator, combining all PersistenceExceptionTranslators found in the factory
See Also:
ChainedPersistenceExceptionTranslator

invoke

public Object invoke(MethodInvocation mi)
              throws Throwable
Specified by:
invoke in interface MethodInterceptor
Throws:
Throwable

The Spring Framework

Copyright © 2002-2007 The Spring Framework.