org.codehaus.aspectwerkz.joinpoint.control
Class AbstractJoinPointController

java.lang.Object
  extended byorg.codehaus.aspectwerkz.joinpoint.control.AbstractJoinPointController
All Implemented Interfaces:
JoinPointController, java.io.Serializable
Direct Known Subclasses:
DefaultJoinPointController

public abstract class AbstractJoinPointController
extends java.lang.Object
implements JoinPointController

Abstract join point controller with convenience methods for managing advices.

Author:
Stefan Finkenzeller
See Also:
Serialized Form

Constructor Summary
AbstractJoinPointController()
           
 
Method Summary
 void addAdvice(java.lang.String adviceName, MethodJoinPoint jp, MethodPointcut pc)
          Adds an advice to a pointcut
 int clearAllRedundancies(MethodJoinPoint jp)
          Checks all advices of a joinpoint for redundancies.
 int clearRedundancy(MethodJoinPoint joinPoint, java.lang.String adviceName, boolean purge)
          Checks for redundant advices of a given type in a joinpoint and then removes all redundant advices.
abstract  JoinPointController deepCopy()
          Clones the controller
 boolean equals(java.lang.Object o)
          The overridden equals method.
static java.util.Iterator getAllAdvices(MethodJoinPoint joinPoint, boolean asSet)
          Returns all advices of the joinpoint.
 int hashCode()
          Overridden hashCode method.
abstract  java.lang.Object proceed(MethodJoinPoint jp)
          Proceeds in the execution model for the join point to the next logical pointcut/advice<
static void purgePointcuts(MethodJoinPoint joinPoint)
          Removes all empty pointcuts from the joinpoint.
 void removeAdvice(java.lang.String adviceName, MethodJoinPoint joinPoint, MethodPointcut pointcut)
          Removes an advice from a pointcut
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractJoinPointController

public AbstractJoinPointController()
Method Detail

addAdvice

public void addAdvice(java.lang.String adviceName,
                      MethodJoinPoint jp,
                      MethodPointcut pc)
Adds an advice to a pointcut

Parameters:
adviceName - name of the advice as defined in the metadata
jp - joinpoint the controller is handling
pc - pointcut, the advice needs to be appended. If null, current pointcut is used.

removeAdvice

public void removeAdvice(java.lang.String adviceName,
                         MethodJoinPoint joinPoint,
                         MethodPointcut pointcut)
Removes an advice from a pointcut

Parameters:
adviceName - name of the advice as defined in the metadata
joinPoint - joinpoint the controller is handling
pointcut - pointcut, the advice needs to be appended. If null, current pointcut is used.

getAllAdvices

public static java.util.Iterator getAllAdvices(MethodJoinPoint joinPoint,
                                               boolean asSet)
Returns all advices of the joinpoint. If asSet is true, returns result as a set, otherwise returns all advices in the order they are pointcut.

Parameters:
joinPoint - the joinpoint to inspect
asSet - flag, whether result is a set
Returns:
iterator containing all advices

purgePointcuts

public static void purgePointcuts(MethodJoinPoint joinPoint)
Removes all empty pointcuts from the joinpoint. Pointcuts can become empty after advices have been deleted by e.g. the use of removeAdvice(), so if the proceed() method of the controller implemented cannot handle empty pointcuts, the pointcuts need to be purged before proceed() is bein executed.

Parameters:
joinPoint - the joinpoint which pointcuts need to be purged

clearRedundancy

public int clearRedundancy(MethodJoinPoint joinPoint,
                           java.lang.String adviceName,
                           boolean purge)
Checks for redundant advices of a given type in a joinpoint and then removes all redundant advices.

Redundancy can be caused by the use of very global regexp's or the combination of advice definitions in java doclets and XML. After calling this method, only the first of a series of redundant advices will remain in the advice chain that gets executed by the controller.

Parameters:
joinPoint - the joinpoint where redundant advices need to be removed
adviceName - the name of the advice to check for redundancy (e.g. log)
purge - true, if empty pointcuts shall be removed after redundancies have been found

clearAllRedundancies

public int clearAllRedundancies(MethodJoinPoint jp)
Checks all advices of a joinpoint for redundancies. If advices are redundant, they are removed.

Parameters:
jp - the joinpoint where redundant advices need to be removed

proceed

public abstract java.lang.Object proceed(MethodJoinPoint jp)
                                  throws java.lang.Throwable
Proceeds in the execution model for the join point to the next logical pointcut/advice<

Joinpoint controller implementations need to implement the business logic for handling e.g. advice redundancy, advice dependency, advice compatibility or special exception handling here.

To implement this logic it can use the knowledge about the joinpoint, the current advice and pointcut.

Specified by:
proceed in interface JoinPointController
Parameters:
jp - The joinpoint using this controller
Returns:
The result of the invocation.
Throws:
java.lang.Throwable

deepCopy

public abstract JoinPointController deepCopy()
Clones the controller

Specified by:
deepCopy in interface JoinPointController
Returns:
Clone of this controller.

hashCode

public int hashCode()
Overridden hashCode method.

Returns:

equals

public boolean equals(java.lang.Object o)
The overridden equals method.

Parameters:
o - the other object
Returns:
boolean


Copyright (c) 2002-2004 The AspectWerkz Team. All Rights Reserved.