org.mockejb.interceptor
Class AspectSystemImpl

java.lang.Object
  extended byorg.mockejb.interceptor.AspectSystemImpl
All Implemented Interfaces:
AspectSystem

public class AspectSystemImpl
extends java.lang.Object
implements AspectSystem

Provides the implementation of the AspectSystem by adding aspects to the list and providing access to this list. Note that all "add" method first check if the same aspect is already in the list. If it is, the aspect is removed from the list and then added again. This is to prevent having the same aspect in the list multiple times. Aspect's "equals" method is used to compare aspects/interceptors, so it is the aspect providers must have this method implemented.

Author:
Alexander Ananiev

Constructor Summary
AspectSystemImpl()
           
 
Method Summary
 void add(Aspect aspect)
          Adds the given aspect to the end of the global list of aspects.
 void add(Pointcut pointcut, Interceptor interceptor)
          Creates the new aspect and adds it to the end of the list of aspects.
 void addFirst(Aspect aspect)
          Inserts the given aspect in the beginning of the list of aspects.
 void addFirst(Pointcut pointcut, Interceptor interceptor)
          Creates the new aspect from the given pointcut and the interceptor and inserts it in the beginning of the list of aspects.
 void clear()
          Clears the list of aspects for this AspectSystem
 java.util.List findInterceptors(java.lang.reflect.Method proxyMethod, java.lang.reflect.Method targetMethod)
          Identifiesaspects whose pointcut matches the given source method or target method.
 java.util.List getAspectList()
          Returns the list of aspects to the client.
protected  void removeIfExists(Aspect aspect)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AspectSystemImpl

public AspectSystemImpl()
Method Detail

add

public void add(Aspect aspect)
Description copied from interface: AspectSystem
Adds the given aspect to the end of the global list of aspects.

Specified by:
add in interface AspectSystem
Parameters:
aspect - aspect to add
See Also:
AspectSystem.add(org.mockejb.interceptor.Aspect)

addFirst

public void addFirst(Aspect aspect)
Description copied from interface: AspectSystem
Inserts the given aspect in the beginning of the list of aspects. If you want an interceptor for a given pointcut to be called before other interceptors for the same pointcut, you can use this method.

Specified by:
addFirst in interface AspectSystem
Parameters:
aspect - aspect to add
See Also:
AspectSystem.addFirst(org.mockejb.interceptor.Aspect)

add

public void add(Pointcut pointcut,
                Interceptor interceptor)
Description copied from interface: AspectSystem
Creates the new aspect and adds it to the end of the list of aspects.

Specified by:
add in interface AspectSystem
Parameters:
pointcut - pointcut of the aspect
interceptor - interceptor of the aspect
See Also:
AspectSystem.add(org.mockejb.interceptor.Pointcut, org.mockejb.interceptor.Interceptor)

addFirst

public void addFirst(Pointcut pointcut,
                     Interceptor interceptor)
Description copied from interface: AspectSystem
Creates the new aspect from the given pointcut and the interceptor and inserts it in the beginning of the list of aspects. If you want an interceptor for a given pointcut to be called before other interceptors for the same pointcut, you can use this method.

Specified by:
addFirst in interface AspectSystem
Parameters:
pointcut - pointcut of the aspect
interceptor - interceptor of the aspect
See Also:
AspectSystem.addFirst(org.mockejb.interceptor.Pointcut, org.mockejb.interceptor.Interceptor)

removeIfExists

protected void removeIfExists(Aspect aspect)

getAspectList

public java.util.List getAspectList()
Description copied from interface: AspectSystem
Returns the list of aspects to the client. Clients can manipulate the list.

Specified by:
getAspectList in interface AspectSystem
Returns:
the list of aspects
See Also:
AspectSystem.getAspectList()

clear

public void clear()
Clears the list of aspects for this AspectSystem

Specified by:
clear in interface AspectSystem

findInterceptors

public java.util.List findInterceptors(java.lang.reflect.Method proxyMethod,
                                       java.lang.reflect.Method targetMethod)
Description copied from interface: AspectSystem
Identifiesaspects whose pointcut matches the given source method or target method. Returns the list of the interceptors for the matching pointcuts.

Specified by:
findInterceptors in interface AspectSystem
Parameters:
proxyMethod - method invoked by the client on the proxy (interface method)
targetMethod - target method which will be called as the result of the proxy method
Returns:
list of the interceptors for the matching pointcuts
See Also:
AspectSystem.findInterceptors(java.lang.reflect.Method, java.lang.reflect.Method)