01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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.aopalliance.intercept.MethodInterceptor;
20:
21: import org.springframework.aop.Advisor;
22:
23: /**
24: * Interface for registries of Advisor adapters.
25: *
26: * <p><i>This is an SPI interface, not to be implemented by any Spring user.</i>
27: *
28: * @author Rod Johnson
29: * @author Rob Harrop
30: */
31: public interface AdvisorAdapterRegistry {
32:
33: /**
34: * Return an Advisor wrapping the given advice.
35: * <p>Should by default at least support
36: * {@link org.aopalliance.intercept.MethodInterceptor},
37: * {@link org.springframework.aop.MethodBeforeAdvice},
38: * {@link org.springframework.aop.AfterReturningAdvice},
39: * {@link org.springframework.aop.ThrowsAdvice}.
40: * @param advice object that should be an advice
41: * @return an Advisor wrapping the given advice. Never returns <code>null</code>.
42: * If the advice parameter is an Advisor, return it.
43: * @throws UnknownAdviceTypeException if no registered advisor adapter
44: * can wrap the supposed advice
45: */
46: Advisor wrap(Object advice) throws UnknownAdviceTypeException;
47:
48: /**
49: * Return an array of AOP Alliance MethodInterceptors to allow use of the
50: * given Advisor in an interception-based framework.
51: * <p>Don't worry about the pointcut associated with the Advisor,
52: * if it's a PointcutAdvisor: just return an interceptor.
53: * @param advisor Advisor to find an interceptor for
54: * @return an array of MethodInterceptors to expose this Advisor's behavior
55: * @throws UnknownAdviceTypeException if the Advisor type is
56: * not understood by any registered AdvisorAdapter.
57: */
58: MethodInterceptor[] getInterceptors(Advisor advisor)
59: throws UnknownAdviceTypeException;
60:
61: /**
62: * Register the given AdvisorAdapter. Note that it is not necessary to register
63: * adapters for an AOP Alliance Interceptors or Spring Advices: these must be
64: * automatically recognized by an AdvisorAdapterRegistry implementation.
65: * @param adapter AdvisorAdapter that understands a particular Advisor
66: * or Advice types
67: */
68: void registerAdvisorAdapter(AdvisorAdapter adapter);
69:
70: }
|