KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > aop > framework > adapter > AdvisorAdapterRegistrationManager


1 /*
2  * Copyright 2002-2005 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.aop.framework.adapter;
18
19 import org.springframework.beans.BeansException;
20 import org.springframework.beans.factory.config.BeanPostProcessor;
21
22 /**
23  * BeanPostProcessor implementation that "registers" instances of any
24  * non-default AdvisorAdapters with GlobalAdvisorAdapterRegistry.
25  *
26  * <p>The only requirement for it to work is that it needs to be defined
27  * in application context along with any arbitrary "non-native" Spring
28  * AdvisorAdapters that need to be "recognized" by Spring's AOP framework.
29  *
30  * @author Dmitriy Kopylenko
31  * @since 27.02.2004
32  * @see AdvisorAdapter
33  * @see AdvisorAdapterRegistry
34  * @see GlobalAdvisorAdapterRegistry
35  */

36 public class AdvisorAdapterRegistrationManager implements BeanPostProcessor {
37
38     private AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
39
40     /**
41      * Specify the AdvisorAdapterRegistry to use.
42      * Default is the global AdvisorAdapterRegistry.
43      * @see org.springframework.aop.framework.adapter.GlobalAdvisorAdapterRegistry
44      */

45     public void setAdvisorAdapterRegistry(AdvisorAdapterRegistry advisorAdapterRegistry) {
46         this.advisorAdapterRegistry = advisorAdapterRegistry;
47     }
48
49     public Object JavaDoc postProcessBeforeInitialization(Object JavaDoc bean, String JavaDoc beanName) throws BeansException {
50         return bean;
51     }
52
53     public Object JavaDoc postProcessAfterInitialization(Object JavaDoc bean, String JavaDoc beanName) throws BeansException {
54         if (bean instanceof AdvisorAdapter){
55             this.advisorAdapterRegistry.registerAdvisorAdapter((AdvisorAdapter) bean);
56         }
57         return bean;
58     }
59
60 }
61
Popular Tags