org.springframework.aop.framework.adapter
Interface AdvisorAdapter
- All Known Implementing Classes:
- AfterReturningAdviceAdapter, BeforeAdviceAdapter, ThrowsAdviceAdapter
- public interface AdvisorAdapter
Interface allowing extension to the Spring AOP framework to allow
handling of new Advisors and Advice types.
Implementing objects can wrap Advice objects in an Advisor,
or convert an arbitrary Advisor type to InterceptionAroundAdvisor
for use in the Spring AOP framework.
Typically an implementation will understand an Advice type
and the matching AdvisorWrapper: e.g. MethodBeforeAdvice and BeforeAdvisor.
There is no need for most Spring users to implement this interface;
do so only if you need to introduce more Advisor or Advice types to
Spring.
- Author:
- Rod Johnson
- Version: $Id: AdvisorAdapter.java,v 1.2 2003/12/11 17:24:51 johnsonr Exp $
| Method Summary |
Interceptor | getInterceptor(Advisor advisor) Return an AOP Alliance Interceptor exposing the behaviour of
the given advice to an interception-based AOP framework. |
boolean | supportsAdvice(Object advice) Does this adapter understand this advice object?
Is it valid to invoke the wrap() method with the
given advice as an argument? |
boolean | supportsAdvisor(Advisor advisor) Does this adapter understand this Advisor? Is it valid to invoke
the getInterceptor() method with this advisor as an argument. |
Advisor | wrap(Object advice) Given the advice, return an Advisor wrapping it. |
getInterceptor
public Interceptor getInterceptor(Advisor advisor)
- Return an AOP Alliance Interceptor exposing the behaviour of
the given advice to an interception-based AOP framework.
Don't worry about any Pointcut contained in the Advisor;
the AOP framework will take care of checking the pointcut.
- Parameters:
- advisor - Advisor. the supportsAdvisor() method must have
returned true on this object
- Returns: an AOP Alliance interceptor for this Advisor. There's
no need to cache instances for efficiency, as the AOP framework
caches advice chains.
supportsAdvice
public boolean supportsAdvice(Object advice)
- Does this adapter understand this advice object?
Is it valid to invoke the wrap() method with the
given advice as an argument?
- Parameters:
- advice - Advice such as a BeforeAdvice. There is
no common interface for Advices, partly because Spring
implements the AOP Alliance interfaces.
- Returns: whether this adapter understands the given advice object
supportsAdvisor
public boolean supportsAdvisor(Advisor advisor)
- Does this adapter understand this Advisor? Is it valid to invoke
the getInterceptor() method with this advisor as an argument.
Most implementations will support only a single Advisor type,
and simply do an
instanceof test here.- Parameters:
- advisor - advisor to test
- Returns: whether it's valid to invoke the getInterceptor() method
on this object with the advisor as argument
wrap
public Advisor wrap(Object advice)
- Given the advice, return an Advisor wrapping it. If the
Advisor is a PointcutAdvisor, it should always match.
- Parameters:
- advice - the supportsAdvice() method must have returned
true on this object
- Returns: an Advisor wrapping this advice, that will apply
to all invocations.