Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

ch.ethz.prose.crosscut
Class MethodCut  view MethodCut download MethodCut.java

java.lang.Object
  extended bych.ethz.prose.engine.JoinPointListener
      extended bych.ethz.prose.crosscut.Crosscut
          extended bych.ethz.prose.crosscut.AbstractCrosscut
              extended bych.ethz.prose.crosscut.MethodCut
All Implemented Interfaces:
ch.ethz.prose.Insertable, java.io.Serializable
Direct Known Subclasses:
AllLocationsTest.AllLocationsExample, FunctionalCrosscutTest.FunctionalCrosscutExample

public abstract class MethodCut
extends AbstractCrosscut
implements java.io.Serializable

Class MethodCut represents a crosscut. Such a crosscut defines a pattern (for matching specific join-points) and a method to be executed. Users must subclass MethodCut. There are two main modalities for subclassing:

The tipical way (normal user)

Define exactly one method (e.g., METHOD_ARGS(Bar thisO,Baz param1)). This method is both the advice action to be executed and it defines a pattern. Thus, just entries and exits of invocations of the form Bar.*(Baz) will be considered join-points of this crosscut.

This crosscut defines a crosscut for all entry- and exit- points of the matched methods.

Use poointCutter to further restrict the number of points were advices are executed.

Version:
$Revision: 1.2 $

Field Summary
(package private)  MethodCutSignaturePattern adviceSignature
           
(package private)  boolean isInitialized
          If you have more than one method in this class, determining the name of the advice method will use the value of this method.
(package private)  MethodCutSpecializer mcutSpecializer
           
(package private)  java.lang.String toStringSignature
           
 
Fields inherited from class ch.ethz.prose.crosscut.AbstractCrosscut
requestFactory
 
Constructor Summary
protected MethodCut()
          We want people to subclass this class.
 
Method Summary
protected  CrosscutRequest doCreateRequest(java.lang.Class theClass)
          Retrieve those methods belonging to theClass which have the same signature as the advice methods.
 ch.ethz.prose.filter.PointCutter equivalentSpecializer()
           
private  void initState()
           
 void insertionAction(boolean beforeInsertion)
          Upon insertion, the a default (abstract) crosscuts tries to figure out where it is running.
protected  boolean isPotentialCrosscutClass(java.lang.Class crtCls)
          Return true only if This crosscut redefines the methodAdvice method, OR if this crosscut defines an advice, and the corresponding UserDefinedMCSignature matches the target class crtCls.
 void joinPointAction(ch.ethz.jvmai.MethodEntryJoinPoint ev)
          Create an action to execute the advice which matched the method in which the location of jpe resides.
 void joinPointAction(ch.ethz.jvmai.MethodExitJoinPoint ev)
          Create an action to execute the advice which matched the method in which the location of jpe resides.
 void METHOD_ARGS()
          Override the value of this variable if you want to change the name of the method wildcards.
private  void methodAdvice(ch.ethz.jvmai.JoinPoint joinPoint)
          If 'methodAdvice' has been redefined, then we will deal with a 'DefaultMcutSignature'.
protected  java.lang.Class[] potentialCrosscutClasses()
          Return all potential classes to which this crosscut applies: To all loaded classes, apply the isPotentialCrosscutClass selector.
 java.lang.String toString()
          Convert this Object to a human-readable String.
 
Methods inherited from class ch.ethz.prose.crosscut.AbstractCrosscut
associateToGroup, createRequest, createRequest, getOwner, getPriority, getSpecializer, joinPointAction, joinPointAction, joinPointAction, joinPointAction, joinPointReached, joinPointReached, joinPointReached, joinPointReached, joinPointReached, joinPointReached, NOT, pointCutter, setOwner, thisJoinPoint, withdrawalAction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

isInitialized

transient boolean isInitialized
If you have more than one method in this class, determining the name of the advice method will use the value of this method. This variable should then be initialized with the name of the method you want to call as advice method.


mcutSpecializer

transient MethodCutSpecializer mcutSpecializer

adviceSignature

transient MethodCutSignaturePattern adviceSignature

toStringSignature

java.lang.String toStringSignature
Constructor Detail

MethodCut

protected MethodCut()
             throws MissingInformationException
We want people to subclass this class. Create a MethodCut object.

Method Detail

METHOD_ARGS

public void METHOD_ARGS()
Override the value of this variable if you want to change the name of the method wildcards. Currently, a method-name mathcing everything should have the name METHOD_ARGS


initState

private void initState()
                throws MissingInformationException

insertionAction

public void insertionAction(boolean beforeInsertion)
Description copied from class: AbstractCrosscut
Upon insertion, the a default (abstract) crosscuts tries to figure out where it is running. It then initializes the infoInterface and aspectInterface variables.

Specified by:
insertionAction in interface ch.ethz.prose.Insertable
Overrides:
insertionAction in class AbstractCrosscut

potentialCrosscutClasses

protected java.lang.Class[] potentialCrosscutClasses()
                                              throws MissingInformationException
Return all potential classes to which this crosscut applies: To all loaded classes, apply the isPotentialCrosscutClass selector.

Overrides:
potentialCrosscutClasses in class AbstractCrosscut

isPotentialCrosscutClass

protected boolean isPotentialCrosscutClass(java.lang.Class crtCls)
                                    throws MissingInformationException
Return true only if
  1. This crosscut redefines the methodAdvice method, OR
  2. if this crosscut defines an advice, and the corresponding UserDefinedMCSignature matches the target class crtCls.

Overrides:
isPotentialCrosscutClass in class AbstractCrosscut

doCreateRequest

protected CrosscutRequest doCreateRequest(java.lang.Class theClass)
Retrieve those methods belonging to theClass which have the same signature as the advice methods. Use the UserDefinedMCSignature object (adviceSignature) to determine which methods defined in class theClass match the pattern. (if wildcards are present, they use them to match more methods in theClass)

Return a list of JoinPointRequest objects corresponding to all locations of the matched methods.

This implementation will return just Method-Entry and -Exit locations..

Specified by:
doCreateRequest in class AbstractCrosscut

joinPointAction

public void joinPointAction(ch.ethz.jvmai.MethodEntryJoinPoint ev)
                     throws java.lang.IllegalAccessException,
                            java.lang.reflect.InvocationTargetException
Create an action to execute the advice which matched the method in which the location of jpe resides.

Overrides:
joinPointAction in class AbstractCrosscut

joinPointAction

public void joinPointAction(ch.ethz.jvmai.MethodExitJoinPoint ev)
                     throws java.lang.IllegalAccessException,
                            java.lang.reflect.InvocationTargetException
Create an action to execute the advice which matched the method in which the location of jpe resides.

Overrides:
joinPointAction in class AbstractCrosscut

methodAdvice

private void methodAdvice(ch.ethz.jvmai.JoinPoint joinPoint)
                   throws java.lang.reflect.InvocationTargetException,
                          java.lang.IllegalAccessException
If 'methodAdvice' has been redefined, then we will deal with a 'DefaultMcutSignature'. But in THAT case, this method will be never executed.


equivalentSpecializer

public ch.ethz.prose.filter.PointCutter equivalentSpecializer()

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).

Overrides:
toString in class AbstractCrosscut