org.codehaus.aspectwerkz.definition
Class AspectWerkzDefinition

java.lang.Object
  extended byorg.codehaus.aspectwerkz.definition.AspectWerkzDefinition
All Implemented Interfaces:
java.io.Serializable

public class AspectWerkzDefinition
extends java.lang.Object
implements java.io.Serializable

Implements the AspectWerkz definition.

Author:
Jonas Bonér
See Also:
Serialized Form

Field Summary
static java.lang.String CALLER_SIDE_DELIMITER
           
static java.lang.String DEFAULT_DEFINITION_FILE_NAME
          The default name for the definition file.
static java.lang.String DEFINITION_FILE
          The path to the definition file.
static java.lang.String PER_CLASS
           
static java.lang.String PER_INSTANCE
           
static java.lang.String PER_JVM
           
static java.lang.String PER_THREAD
           
static java.lang.String SYSTEM_ASPECT
          The name of the system aspect.
static java.lang.String THROWS_DELIMITER
           
 
Constructor Summary
AspectWerkzDefinition()
          Creates a new instance, creates and sets the system aspect.
 
Method Summary
 void addAbstractAspect(AspectDefinition aspect)
          Adds an abstract aspect definition.
 void addAdvice(AdviceDefinition advice)
          Adds an advice definition.
 void addAdviceStack(AdviceStackDefinition adviceStackDef)
          Adds an advice stack definition.
 void addAspect(AspectDefinition aspect)
          Adds an aspect definition.
 void addAspectToUse(java.lang.String className)
          Adds a new aspect to use.
 void addIntroduction(IntroductionDefinition introduction)
          Adds a new introductions definition.
 void addTransformationScope(java.lang.String transformationScope)
          Adds a new transformation scope.
static void createCallerSidePattern(java.lang.String pattern, PointcutDefinition pointcutDef, java.lang.String packageName)
          Creates a caller side pattern and adds it to the pointcut definition.
static void createClassPattern(java.lang.String pattern, PointcutDefinition pointcutDef, java.lang.String packageName)
          Creates a class pattern and adds it to the pointcut definition.
static AspectWerkzDefinition createDefinition(org.dom4j.Document document)
          Creates, caches and returns new definition.
static void createFieldPattern(java.lang.String pattern, PointcutDefinition pointcutDef, java.lang.String packageName)
          Creates a field pattern and adds it to the pointcut definition.
static void createMethodPattern(java.lang.String pattern, PointcutDefinition pointcutDef, java.lang.String packageName)
          Creates a method pattern and adds it to the pointcut definition.
static void createThrowsPattern(java.lang.String pattern, PointcutDefinition pointcutDef, java.lang.String packageName)
          Creates a throws pattern and adds it to the pointcut definition.
 AspectDefinition getAbstractAspectDefinition(java.lang.String name)
          Returns a specific abstract aspect definition.
 java.util.Collection getAbstractAspectDefinitions()
          Returns a collection with the abstract aspect definitions registered.
 AdviceDefinition getAdviceDefinition(java.lang.String name)
          Returns a specific advice definition.
 java.util.Collection getAdviceDefinitions()
          Returns a collection with the advice definitions registered.
 java.lang.String getAdviceNameByAttribute(java.lang.String attribute)
          Finds the name of an advice by its attribute.
 AdviceStackDefinition getAdviceStackDefinition(java.lang.String adviceStackName)
          Finds an advice stack definition by its name.
 AspectDefinition getAspectDefinition(java.lang.String name)
          Returns a specific aspect definition.
 java.util.Collection getAspectDefinitions()
          Returns a collection with the aspect definitions registered.
 java.util.Set getAspectsToUse()
          Returns a set with the aspects to use.
 java.lang.String[] getAspectTargetClassNames()
          Returns the names of the target classes.
static AspectWerkzDefinition getDefinition(java.lang.String uuid)
          Loads the aspectwerkz definition from disk based on a specific UUID.
static AspectWerkzDefinition getDefinitionForTransformation()
          Loads the aspectwerkz definition from disk.
static java.io.InputStream getDefinitionInputStream()
          Returns an input stream to the definition if found on classpath.
 IntroductionDefinition getIntroductionDefinition(java.lang.String introductionName)
          Returns a specific introduction definition.
 java.util.Collection getIntroductionDefinitions()
          Returns a collection with the introduction definitions registered.
 java.lang.String getIntroductionImplName(java.lang.String introductionName)
          Returns the name of the implementation for an introduction.
 int getIntroductionIndex(java.lang.String introductionName)
          Returns the index for a specific introduction.
 gnu.trove.TObjectIntHashMap getIntroductionIndexes()
          Returns the indexes for the introductions.
 java.lang.String getIntroductionInterfaceName(java.lang.String introductionName)
          Returns the name of the interface for an introduction.
 java.lang.String getIntroductionNameByAttribute(java.lang.String attribute)
          Finds the name of an introduction by its attribute.
 java.util.List getIntroductionNames(java.lang.String className)
          Returns the names of the introductions for a certain class.
 java.lang.String getJoinPointController(ClassMetaData classMetaData, MethodMetaData methodMetaData)
          Returns the class name for the join point controller, if there is a match.
 java.util.Set getTransformationScopes()
          Returns the transformation scopes.
 java.lang.String getUuid()
          Returns the UUID for the definition.
 boolean hasAdvice(java.lang.String name)
          Checks if there exists an advice with the name specified.
 boolean hasCallerSidePointcut(ClassMetaData classMetaData)
          Checks if a class should care about advising caller side method invocations.
 boolean hasGetFieldPointcut(ClassMetaData classMetaData)
          Checks if a class has a GetFieldPointcut.
 boolean hasGetFieldPointcut(ClassMetaData classMetaData, FieldMetaData fieldMetaData)
          Checks if a class and field has a GetFieldPointcut.
 boolean hasIntroduction(java.lang.String name)
          Checks if there exists an introduction with the name specified.
 boolean hasIntroductions(java.lang.String className)
          Checks if a class has an Introduction.
 boolean hasMethodPointcut(ClassMetaData classMetaData)
          Checks if a method has a MethodPointcut.
 boolean hasMethodPointcut(ClassMetaData classMetaData, MethodMetaData methodMetaData)
          Checks if a method has a MethodPointcut.
 boolean hasSetFieldPointcut(ClassMetaData classMetaData)
          Checks if a class has a SetFieldPointcut.
 boolean hasSetFieldPointcut(ClassMetaData classMetaData, FieldMetaData fieldMetaData)
          Checks if a class and field has a SetFieldPointcut.
 boolean hasThrowsPointcut(ClassMetaData classMetaData)
          Checks if a class and method has a ThrowsPointcut.
 boolean hasThrowsPointcut(ClassMetaData classMetaData, MethodMetaData methodMetaData)
          Checks if a class and method has a ThrowsPointcut.
 boolean inTransformationScope(java.lang.String className)
          Checks if a class has an Aspect.
 boolean isCallerSideMethod(ClassMetaData classMetaData, MethodMetaData methodMetaData)
          Checks if a method is a defined as a caller side method.
static AspectWerkzDefinition loadDefaultDefinitionAsFile(boolean isDirty)
          Returns the definition.
static AspectWerkzDefinition loadDefinitionAsDocument(org.dom4j.Document document)
          Returns the definition.
static AspectWerkzDefinition loadDefinitionAsFile(java.lang.String definitionFile)
          Returns the definition.
static AspectWerkzDefinition loadDefinitionAsFile(java.lang.String definitionFile, boolean isDirty)
          Returns the definition.
static AspectWerkzDefinition loadDefinitionAsResource()
          Loads a definition from disk.
static AspectWerkzDefinition loadDefinitionAsStream(java.io.InputStream stream)
          Returns the definition.
 void setUuid(java.lang.String uuid)
          Sets the UUID for the definition.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PER_JVM

public static final java.lang.String PER_JVM
See Also:
Constant Field Values

PER_CLASS

public static final java.lang.String PER_CLASS
See Also:
Constant Field Values

PER_INSTANCE

public static final java.lang.String PER_INSTANCE
See Also:
Constant Field Values

PER_THREAD

public static final java.lang.String PER_THREAD
See Also:
Constant Field Values

THROWS_DELIMITER

public static final java.lang.String THROWS_DELIMITER
See Also:
Constant Field Values

CALLER_SIDE_DELIMITER

public static final java.lang.String CALLER_SIDE_DELIMITER
See Also:
Constant Field Values

DEFINITION_FILE

public static final java.lang.String DEFINITION_FILE
The path to the definition file.


DEFAULT_DEFINITION_FILE_NAME

public static final java.lang.String DEFAULT_DEFINITION_FILE_NAME
The default name for the definition file.

See Also:
Constant Field Values

SYSTEM_ASPECT

public static final java.lang.String SYSTEM_ASPECT
The name of the system aspect.

See Also:
Constant Field Values
Constructor Detail

AspectWerkzDefinition

public AspectWerkzDefinition()
Creates a new instance, creates and sets the system aspect.

Method Detail

createDefinition

public static AspectWerkzDefinition createDefinition(org.dom4j.Document document)
Creates, caches and returns new definition. Loads the definition in the file specified.

Parameters:
document - the DOM document containing the definition
Returns:
the aspectwerkz definition

getDefinitionForTransformation

public static AspectWerkzDefinition getDefinitionForTransformation()
Loads the aspectwerkz definition from disk. Used by the transformers. Grabs the first one it finds (should only by one in the transformations process).

Returns:
the aspectwerkz definition

getDefinition

public static AspectWerkzDefinition getDefinition(java.lang.String uuid)
Loads the aspectwerkz definition from disk based on a specific UUID. Only loads from the disk if the timestamp for the latest parsing is older than the timestamp for the weave model.

Parameters:
uuid - the uuid for the weave model to load (null is allowed if only XML definition is used)
Returns:
the aspectwerkz definition

loadDefinitionAsResource

public static AspectWerkzDefinition loadDefinitionAsResource()
Loads a definition from disk. Only loads a new model from disk if it has changed.

Returns:
the definition

loadDefaultDefinitionAsFile

public static AspectWerkzDefinition loadDefaultDefinitionAsFile(boolean isDirty)
Returns the definition.

If the file name is not specified as a parameter to the JVM it tries to locate a file named 'aspectwerkz.xml' on the classpath.

Parameters:
isDirty - flag to mark the the defintion as updated or not
Returns:
the definition

loadDefinitionAsFile

public static AspectWerkzDefinition loadDefinitionAsFile(java.lang.String definitionFile)
Returns the definition.

Parameters:
definitionFile - the definition file
Returns:
the definition

loadDefinitionAsFile

public static AspectWerkzDefinition loadDefinitionAsFile(java.lang.String definitionFile,
                                                         boolean isDirty)
Returns the definition.

Parameters:
definitionFile - the definition file
isDirty - flag to mark the the defintion as updated or not
Returns:
the definition

loadDefinitionAsStream

public static AspectWerkzDefinition loadDefinitionAsStream(java.io.InputStream stream)
Returns the definition.

Parameters:
stream - the stream containing the definition file
Returns:
the definition

loadDefinitionAsDocument

public static AspectWerkzDefinition loadDefinitionAsDocument(org.dom4j.Document document)
Returns the definition.

Parameters:
document - the DOM document containing the definition file
Returns:
the definition

getDefinitionInputStream

public static java.io.InputStream getDefinitionInputStream()
Returns an input stream to the definition if found on classpath.

Returns:
the input stream to the definition

createClassPattern

public static void createClassPattern(java.lang.String pattern,
                                      PointcutDefinition pointcutDef,
                                      java.lang.String packageName)
Creates a class pattern and adds it to the pointcut definition.

Parameters:
pattern - the pattern
pointcutDef - the pointcut definition
packageName - the name of the package

createMethodPattern

public static void createMethodPattern(java.lang.String pattern,
                                       PointcutDefinition pointcutDef,
                                       java.lang.String packageName)
Creates a method pattern and adds it to the pointcut definition.

Parameters:
pattern - the pattern
pointcutDef - the pointcut definition
packageName - the name of the package

createFieldPattern

public static void createFieldPattern(java.lang.String pattern,
                                      PointcutDefinition pointcutDef,
                                      java.lang.String packageName)
Creates a field pattern and adds it to the pointcut definition.

Parameters:
pattern - the pattern
pointcutDef - the pointcut definition
packageName - the name of the package

createThrowsPattern

public static void createThrowsPattern(java.lang.String pattern,
                                       PointcutDefinition pointcutDef,
                                       java.lang.String packageName)
Creates a throws pattern and adds it to the pointcut definition.

Parameters:
pattern - the pattern
pointcutDef - the pointcut definition
packageName - the name of the package

createCallerSidePattern

public static void createCallerSidePattern(java.lang.String pattern,
                                           PointcutDefinition pointcutDef,
                                           java.lang.String packageName)
Creates a caller side pattern and adds it to the pointcut definition.

Parameters:
pattern - the pattern
pointcutDef - the pointcut definition
packageName - the name of the package

setUuid

public void setUuid(java.lang.String uuid)
Sets the UUID for the definition.

Parameters:
uuid - the UUID

getUuid

public java.lang.String getUuid()
Returns the UUID for the definition.

Returns:
the UUID

getTransformationScopes

public java.util.Set getTransformationScopes()
Returns the transformation scopes.

Returns:
the transformation scopes

getAbstractAspectDefinitions

public java.util.Collection getAbstractAspectDefinitions()
Returns a collection with the abstract aspect definitions registered.

Returns:
the abstract aspect definitions

getAspectDefinitions

public java.util.Collection getAspectDefinitions()
Returns a collection with the aspect definitions registered.

Returns:
the aspect definitions

getIntroductionDefinitions

public java.util.Collection getIntroductionDefinitions()
Returns a collection with the introduction definitions registered.

Returns:
the introduction definitions

getAdviceDefinitions

public java.util.Collection getAdviceDefinitions()
Returns a collection with the advice definitions registered.

Returns:
the advice definitions

getAdviceStackDefinition

public AdviceStackDefinition getAdviceStackDefinition(java.lang.String adviceStackName)
Finds an advice stack definition by its name.

Parameters:
adviceStackName - the advice stack name
Returns:
the definition

getAbstractAspectDefinition

public AspectDefinition getAbstractAspectDefinition(java.lang.String name)
Returns a specific abstract aspect definition.

Parameters:
name - the name of the abstract aspect definition
Returns:
the abstract aspect definition

getAspectDefinition

public AspectDefinition getAspectDefinition(java.lang.String name)
Returns a specific aspect definition.

Parameters:
name - the name of the aspect definition
Returns:
the aspect definition

getAspectTargetClassNames

public java.lang.String[] getAspectTargetClassNames()
Returns the names of the target classes.

Returns:
the names of the target classes

getAdviceDefinition

public AdviceDefinition getAdviceDefinition(java.lang.String name)
Returns a specific advice definition.

Parameters:
name - the name of the advice definition
Returns:
the advice definition

getAdviceNameByAttribute

public java.lang.String getAdviceNameByAttribute(java.lang.String attribute)
Finds the name of an advice by its attribute.

Parameters:
attribute - the attribute
Returns:
the name of the advice

getIntroductionNameByAttribute

public java.lang.String getIntroductionNameByAttribute(java.lang.String attribute)
Finds the name of an introduction by its attribute.

Parameters:
attribute - the attribute
Returns:
the name of the introduction

getIntroductionInterfaceName

public java.lang.String getIntroductionInterfaceName(java.lang.String introductionName)
Returns the name of the interface for an introduction.

Parameters:
introductionName - the name of the introduction
Returns:
the name of the interface

getIntroductionImplName

public java.lang.String getIntroductionImplName(java.lang.String introductionName)
Returns the name of the implementation for an introduction.

Parameters:
introductionName - the name of the introduction
Returns:
the name of the interface

getIntroductionDefinition

public IntroductionDefinition getIntroductionDefinition(java.lang.String introductionName)
Returns a specific introduction definition.

Parameters:
introductionName - the name of the introduction
Returns:
the introduction definition

getIntroductionIndex

public int getIntroductionIndex(java.lang.String introductionName)
Returns the index for a specific introduction.

Parameters:
introductionName - the name of the introduction
Returns:
the index

getIntroductionIndexes

public gnu.trove.TObjectIntHashMap getIntroductionIndexes()
Returns the indexes for the introductions.

Returns:
the indexes

getJoinPointController

public java.lang.String getJoinPointController(ClassMetaData classMetaData,
                                               MethodMetaData methodMetaData)
Returns the class name for the join point controller, if there is a match.

Parameters:
classMetaData - the class meta-data
methodMetaData - the method meta-data
Returns:
the controller class name

getAspectsToUse

public java.util.Set getAspectsToUse()
Returns a set with the aspects to use.

Returns:
the aspects to use

addAspectToUse

public void addAspectToUse(java.lang.String className)
Adds a new aspect to use.

Parameters:
className - the class name of the aspect

addTransformationScope

public void addTransformationScope(java.lang.String transformationScope)
Adds a new transformation scope.

Parameters:
transformationScope - the new scope

addAbstractAspect

public void addAbstractAspect(AspectDefinition aspect)
Adds an abstract aspect definition.

Parameters:
aspect - a new abstract aspect definition

addAspect

public void addAspect(AspectDefinition aspect)
Adds an aspect definition.

Parameters:
aspect - a new aspect definition

addAdviceStack

public void addAdviceStack(AdviceStackDefinition adviceStackDef)
Adds an advice stack definition.

Parameters:
adviceStackDef - the advice stack definition

addAdvice

public void addAdvice(AdviceDefinition advice)
Adds an advice definition.

Parameters:
advice - the advice definition

addIntroduction

public void addIntroduction(IntroductionDefinition introduction)
Adds a new introductions definition.

Parameters:
introduction - the introduction definition

hasAdvice

public boolean hasAdvice(java.lang.String name)
Checks if there exists an advice with the name specified.

Parameters:
name - the name of the advice
Returns:
boolean

hasIntroduction

public boolean hasIntroduction(java.lang.String name)
Checks if there exists an introduction with the name specified.

Parameters:
name - the name of the introduction
Returns:
boolean

inTransformationScope

public boolean inTransformationScope(java.lang.String className)
Checks if a class has an Aspect.

Parameters:
className - the name or the class
Returns:
boolean

hasIntroductions

public boolean hasIntroductions(java.lang.String className)
Checks if a class has an Introduction.

Parameters:
className - the name or the class
Returns:
boolean

hasMethodPointcut

public boolean hasMethodPointcut(ClassMetaData classMetaData)
Checks if a method has a MethodPointcut. Only checks for a class match to allow early filtering.

Parameters:
classMetaData - the class meta-data
Returns:
boolean

hasMethodPointcut

public boolean hasMethodPointcut(ClassMetaData classMetaData,
                                 MethodMetaData methodMetaData)
Checks if a method has a MethodPointcut.

Parameters:
classMetaData - the class meta-data
methodMetaData - the method meta-data
Returns:
boolean

hasGetFieldPointcut

public boolean hasGetFieldPointcut(ClassMetaData classMetaData)
Checks if a class has a GetFieldPointcut. Only checks for a class match to allow early filtering.

Parameters:
classMetaData - the class meta-data
Returns:
boolean

hasGetFieldPointcut

public boolean hasGetFieldPointcut(ClassMetaData classMetaData,
                                   FieldMetaData fieldMetaData)
Checks if a class and field has a GetFieldPointcut.

Parameters:
classMetaData - the class meta-data
fieldMetaData - the name or the field
Returns:
boolean

hasSetFieldPointcut

public boolean hasSetFieldPointcut(ClassMetaData classMetaData)
Checks if a class has a SetFieldPointcut. Only checks for a class match to allow early filtering.

Parameters:
classMetaData - the class meta-data
Returns:
boolean

hasSetFieldPointcut

public boolean hasSetFieldPointcut(ClassMetaData classMetaData,
                                   FieldMetaData fieldMetaData)
Checks if a class and field has a SetFieldPointcut.

Parameters:
classMetaData - the class meta-data
fieldMetaData - the name or the field
Returns:
boolean

hasThrowsPointcut

public boolean hasThrowsPointcut(ClassMetaData classMetaData)
Checks if a class and method has a ThrowsPointcut. Only checks for a class match to allow early filtering.

Parameters:
classMetaData - the class meta-data
Returns:
boolean

hasThrowsPointcut

public boolean hasThrowsPointcut(ClassMetaData classMetaData,
                                 MethodMetaData methodMetaData)
Checks if a class and method has a ThrowsPointcut.

Parameters:
classMetaData - the class meta-data
methodMetaData - the name or the method
Returns:
boolean

hasCallerSidePointcut

public boolean hasCallerSidePointcut(ClassMetaData classMetaData)
Checks if a class should care about advising caller side method invocations.

Parameters:
classMetaData - the class meta-data
Returns:
boolean

isCallerSideMethod

public boolean isCallerSideMethod(ClassMetaData classMetaData,
                                  MethodMetaData methodMetaData)
Checks if a method is a defined as a caller side method.

Parameters:
classMetaData - the class meta-data
methodMetaData - the name or the method
Returns:
boolean

getIntroductionNames

public java.util.List getIntroductionNames(java.lang.String className)
Returns the names of the introductions for a certain class.

Parameters:
className - the name of the class
Returns:
the names


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