org.aspectj.weaver.tools
Class PointcutParser

java.lang.Object
  extended by org.aspectj.weaver.tools.PointcutParser
Direct Known Subclasses:
InternalUseOnlyPointcutParser

public class PointcutParser
extends java.lang.Object

A PointcutParser can be used to build PointcutExpressions for a user-defined subset of AspectJ's pointcut language


Constructor Summary
protected PointcutParser()
          Create a pointcut parser that can parse the full AspectJ pointcut language with the following exceptions: The if, cflow, and cflowbelow pointcut designators are not supported Pointcut expressions must be self-contained :- they cannot contain references to other named pointcuts The pointcut expression must be anonymous with no formals allowed.
 
Method Summary
protected  Pointcut concretizePointcutExpression(Pointcut pc, java.lang.Class inScope, PointcutParameter[] formalParameters)
           
 PointcutParameter createPointcutParameter(java.lang.String name, java.lang.Class type)
          Create a pointcut parameter of the given name and type.
static java.util.Set<PointcutPrimitive> getAllSupportedPointcutPrimitives()
           
static PointcutParser getPointcutParserSupportingAllPrimitivesAndUsingContextClassloaderForResolution()
          Returns a pointcut parser that can parse the full AspectJ pointcut language with the following exceptions: The if, cflow, and cflowbelow pointcut designators are not supported Pointcut expressions must be self-contained :- they cannot contain references to other named pointcuts The pointcut expression must be anonymous with no formals allowed.
static PointcutParser getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(java.lang.ClassLoader classLoader)
          Returns a pointcut parser that can parse the full AspectJ pointcut language with the following exceptions: The if, cflow, and cflowbelow pointcut designators are not supported Pointcut expressions must be self-contained :- they cannot contain references to other named pointcuts The pointcut expression must be anonymous with no formals allowed.
static PointcutParser getPointcutParserSupportingSpecifiedPrimitivesAndUsingContextClassloaderForResolution(java.util.Set supportedPointcutKinds)
          Returns a pointcut parser that can parse pointcut expressions built from a user-defined subset of AspectJ's supported pointcut primitives.
static PointcutParser getPointcutParserSupportingSpecifiedPrimitivesAndUsingSpecifiedClassLoaderForResolution(java.util.Set supportedPointcutKinds, java.lang.ClassLoader classLoader)
          Returns a pointcut parser that can parse pointcut expressions built from a user-defined subset of AspectJ's supported pointcut primitives.
 PointcutExpression parsePointcutExpression(java.lang.String expression)
          Parse the given pointcut expression.
 PointcutExpression parsePointcutExpression(java.lang.String expression, java.lang.Class inScope, PointcutParameter[] formalParameters)
          Parse the given pointcut expression.
 TypePatternMatcher parseTypePattern(java.lang.String typePattern)
          Parse the given aspectj type pattern, and return a matcher that can be used to match types using it.
 void registerPointcutDesignatorHandler(PointcutDesignatorHandler designatorHandler)
          Register a new pointcut designator handler with this parser.
protected  Pointcut resolvePointcutExpression(java.lang.String expression, java.lang.Class inScope, PointcutParameter[] formalParameters)
           
protected  void setClassLoader(java.lang.ClassLoader aLoader)
          Set the classloader that this parser should use for type resolution.
 void setLintProperties(java.util.Properties properties)
          Set the lint properties for this parser from the given properties set.
 void setLintProperties(java.lang.String resourcePath)
          Set the lint properties for this parser from the given resource on the classpath.
protected  void setWorld(ReflectionWorld aWorld)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PointcutParser

protected PointcutParser()
Create a pointcut parser that can parse the full AspectJ pointcut language with the following exceptions:

Method Detail

getAllSupportedPointcutPrimitives

public static java.util.Set<PointcutPrimitive> getAllSupportedPointcutPrimitives()
Returns:
a Set containing every PointcutPrimitive except if, cflow, and cflowbelow (useful for passing to PointcutParser constructor).

getPointcutParserSupportingAllPrimitivesAndUsingContextClassloaderForResolution

public static PointcutParser getPointcutParserSupportingAllPrimitivesAndUsingContextClassloaderForResolution()
Returns a pointcut parser that can parse the full AspectJ pointcut language with the following exceptions:

When resolving types in pointcut expressions, the context classloader is used to find types.


getPointcutParserSupportingSpecifiedPrimitivesAndUsingContextClassloaderForResolution

public static PointcutParser getPointcutParserSupportingSpecifiedPrimitivesAndUsingContextClassloaderForResolution(java.util.Set supportedPointcutKinds)
Returns a pointcut parser that can parse pointcut expressions built from a user-defined subset of AspectJ's supported pointcut primitives. The following restrictions apply:

When resolving types in pointcut expressions, the context classloader is used to find types.

Parameters:
supportedPointcutKinds - a set of PointcutPrimitives this parser should support
Throws:
java.lang.UnsupportedOperationException - if the set contains if, cflow, or cflow below

getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution

public static PointcutParser getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(java.lang.ClassLoader classLoader)
Returns a pointcut parser that can parse the full AspectJ pointcut language with the following exceptions:

When resolving types in pointcut expressions, the given classloader is used to find types.


getPointcutParserSupportingSpecifiedPrimitivesAndUsingSpecifiedClassLoaderForResolution

public static PointcutParser getPointcutParserSupportingSpecifiedPrimitivesAndUsingSpecifiedClassLoaderForResolution(java.util.Set supportedPointcutKinds,
                                                                                                                     java.lang.ClassLoader classLoader)
Returns a pointcut parser that can parse pointcut expressions built from a user-defined subset of AspectJ's supported pointcut primitives. The following restrictions apply:

When resolving types in pointcut expressions, the given classloader is used to find types.

Parameters:
supportedPointcutKinds - a set of PointcutPrimitives this parser should support
Throws:
java.lang.UnsupportedOperationException - if the set contains if, cflow, or cflow below

setWorld

protected void setWorld(ReflectionWorld aWorld)

setClassLoader

protected void setClassLoader(java.lang.ClassLoader aLoader)
Set the classloader that this parser should use for type resolution.

Parameters:
aLoader -

setLintProperties

public void setLintProperties(java.lang.String resourcePath)
                       throws java.io.IOException
Set the lint properties for this parser from the given resource on the classpath.

Parameters:
resourcePath - path to a file containing aspectj lint properties
Throws:
java.io.IOException

setLintProperties

public void setLintProperties(java.util.Properties properties)
Set the lint properties for this parser from the given properties set.

Parameters:
properties -

registerPointcutDesignatorHandler

public void registerPointcutDesignatorHandler(PointcutDesignatorHandler designatorHandler)
Register a new pointcut designator handler with this parser. This provides an extension mechansim for the integration of domain-specific pointcut designators with the AspectJ pointcut language.

Parameters:
designatorHandler -

createPointcutParameter

public PointcutParameter createPointcutParameter(java.lang.String name,
                                                 java.lang.Class type)
Create a pointcut parameter of the given name and type.

Parameters:
name -
type -
Returns:

parsePointcutExpression

public PointcutExpression parsePointcutExpression(java.lang.String expression)
                                           throws UnsupportedPointcutPrimitiveException,
                                                  java.lang.IllegalArgumentException
Parse the given pointcut expression. A global scope is assumed for resolving any type references, and the pointcut must contain no formals (variables to be bound).

Throws:
UnsupportedPointcutPrimitiveException - if the parser encounters a primitive pointcut expression of a kind not supported by this PointcutParser.
java.lang.IllegalArgumentException - if the expression is not a well-formed pointcut expression

parsePointcutExpression

public PointcutExpression parsePointcutExpression(java.lang.String expression,
                                                  java.lang.Class inScope,
                                                  PointcutParameter[] formalParameters)
                                           throws UnsupportedPointcutPrimitiveException,
                                                  java.lang.IllegalArgumentException
Parse the given pointcut expression. The pointcut is resolved as if it had been declared inside the inScope class (this allows the pointcut to contain unqualified references to other pointcuts declared in the same type for example). The pointcut may contain zero or more formal parameters to be bound at matched join points.

Throws:
UnsupportedPointcutPrimitiveException - if the parser encounters a primitive pointcut expression of a kind not supported by this PointcutParser.
java.lang.IllegalArgumentException - if the expression is not a well-formed pointcut expression

resolvePointcutExpression

protected Pointcut resolvePointcutExpression(java.lang.String expression,
                                             java.lang.Class inScope,
                                             PointcutParameter[] formalParameters)

concretizePointcutExpression

protected Pointcut concretizePointcutExpression(Pointcut pc,
                                                java.lang.Class inScope,
                                                PointcutParameter[] formalParameters)

parseTypePattern

public TypePatternMatcher parseTypePattern(java.lang.String typePattern)
                                    throws java.lang.IllegalArgumentException
Parse the given aspectj type pattern, and return a matcher that can be used to match types using it.

Parameters:
typePattern - an aspectj type pattern
Returns:
a type pattern matcher that matches using the given pattern
Throws:
java.lang.IllegalArgumentException - if the type pattern cannot be successfully parsed.