|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2010 the original author or authors. |
| 2 | + * Copyright 2002-2011 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
35 | 35 | import org.springframework.util.ClassUtils;
|
36 | 36 |
|
37 | 37 | /**
|
38 |
| - * Bean post-processor that automatically applies persistence exception |
39 |
| - * translation to any bean that carries the |
40 |
| - * {@link org.springframework.stereotype.Repository} annotation, |
41 |
| - * adding a corresponding {@link PersistenceExceptionTranslationAdvisor} |
42 |
| - * to the exposed proxy (either an existing AOP proxy or a newly generated |
43 |
| - * proxy that implements all of the target's interfaces). |
| 38 | + * Bean post-processor that automatically applies persistence exception translation to any |
| 39 | + * bean marked with Spring's @{@link org.springframework.stereotype.Repository Repository} |
| 40 | + * annotation, adding a corresponding {@link PersistenceExceptionTranslationAdvisor} to |
| 41 | + * the exposed proxy (either an existing AOP proxy or a newly generated proxy that |
| 42 | + * implements all of the target's interfaces). |
44 | 43 | *
|
45 | 44 | * <p>Translates native resource exceptions to Spring's
|
46 |
| - * {@link org.springframework.dao.DataAccessException} hierarchy. |
| 45 | + * {@link org.springframework.dao.DataAccessException DataAccessException} hierarchy. |
47 | 46 | * Autodetects beans that implement the
|
48 |
| - * {@link org.springframework.dao.support.PersistenceExceptionTranslator} |
49 |
| - * interface, which are subsequently asked to translate candidate exceptions. |
| 47 | + * {@link org.springframework.dao.support.PersistenceExceptionTranslator |
| 48 | + * PersistenceExceptionTranslator} interface, which are subsequently asked to translate |
| 49 | + * candidate exceptions. |
50 | 50 | *
|
51 |
| - * <p>All of Spring's applicable resource factories implement the |
52 |
| - * <code>PersistenceExceptionTranslator</code> interface out of the box. |
53 |
| - * As a consequence, all that is usually needed to enable automatic exception |
54 |
| - * translation is marking all affected beans (such as DAOs) with the |
55 |
| - * <code>Repository</code> annotation, along with defining this post-processor |
56 |
| - * as bean in the application context. |
| 51 | +
|
| 52 | + * <p>All of Spring's applicable resource factories (e.g. {@link |
| 53 | + * org.springframework.orm.hibernate3.LocalSessionFactoryBean LocalSessionFactoryBean}, |
| 54 | + * {@link org.springframework.orm.jpa.LocalEntityManagerFactoryBean |
| 55 | + * LocalEntityManagerFactoryBean}) implement the {@code PersistenceExceptionTranslator} |
| 56 | + * interface out of the box. As a consequence, all that is usually needed to enable |
| 57 | + * automatic exception translation is marking all affected beans (such as Repositories or |
| 58 | + * DAOs) with the {@code @Repository} annotation, along with defining this post-processor |
| 59 | + * as a bean in the application context. |
57 | 60 | *
|
58 | 61 | * @author Rod Johnson
|
59 | 62 | * @author Juergen Hoeller
|
@@ -82,7 +85,7 @@ public class PersistenceExceptionTranslationPostProcessor extends ProxyConfig
|
82 | 85 | * @param repositoryAnnotationType the desired annotation type
|
83 | 86 | */
|
84 | 87 | public void setRepositoryAnnotationType(Class<? extends Annotation> repositoryAnnotationType) {
|
85 |
| - Assert.notNull(repositoryAnnotationType, "'requiredAnnotationType' must not be null"); |
| 88 | + Assert.notNull(repositoryAnnotationType, "'repositoryAnnotationType' must not be null"); |
86 | 89 | this.repositoryAnnotationType = repositoryAnnotationType;
|
87 | 90 | }
|
88 | 91 |
|
@@ -115,7 +118,7 @@ public Object postProcessAfterInitialization(Object bean, String beanName) {
|
115 | 118 | // Ignore AOP infrastructure such as scoped proxies.
|
116 | 119 | return bean;
|
117 | 120 | }
|
118 |
| - Class targetClass = AopUtils.getTargetClass(bean); |
| 121 | + Class<?> targetClass = AopUtils.getTargetClass(bean); |
119 | 122 | if (AopUtils.canApply(this.persistenceExceptionTranslationAdvisor, targetClass)) {
|
120 | 123 | if (bean instanceof Advised) {
|
121 | 124 | ((Advised) bean).addAdvisor(this.persistenceExceptionTranslationAdvisor);
|
|
0 commit comments