Top Description Fields Constructors Methods
org.aspectj.weaver.tools

public Class PointcutParser

extends Object
Class Inheritance
Known Direct Subclasses
org.aspectj.weaver.reflect.InternalUseOnlyPointcutParser
Imports
java.io.File, .IOException, .InputStream, java.net.URL, java.util.HashSet, .Properties, .Set, org.aspectj.bridge.IMessageHandler, .ISourceLocation, .SourceLocation, org.aspectj.weaver.BindingScope, .IHasPosition, .ISourceContext, .IntMap, .ResolvedType, .Shadow, .UnresolvedType, .WeakClassLoaderReference, .World, org.aspectj.weaver.internal.tools.PointcutExpressionImpl, .TypePatternMatcherImpl, org.aspectj.weaver.patterns.AndPointcut, .CflowPointcut, .FormalBinding, .IScope, .KindedPointcut, .NotPointcut, .OrPointcut, .ParserException, .PatternParser, .Pointcut, .SimpleScope, .ThisOrTargetAnnotationPointcut, .ThisOrTargetPointcut, .TypePattern, org.aspectj.weaver.reflect.PointcutParameterImpl, .ReflectionWorld

A PointcutParser can be used to build PointcutExpressions for a user-defined subset of AspectJ's pointcut language
Authors
Adrian Colyer, Andy Clement

Field Summary

Modifier and TypeField and Description
private WeakClassLoaderReference
private final Set<PointcutDesignatorHandler>
private final Set<PointcutPrimitive>
private ReflectionWorld

Constructor Summary

AccessConstructor and Description
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.
private
PointcutParser(Set<PointcutPrimitive>
a set of PointcutPrimitives this parser should support
supportedPointcutKinds
)

Create a pointcut parser that can parse pointcut expressions built from a user-defined subset of AspectJ's supported pointcut primitives.

Method Summary

Modifier and TypeMethod and Description
private IScope
buildResolutionScope(Class<?> inScope, PointcutParameter[] formalParameters)

private String
protected Pointcut
concretizePointcutExpression(Pointcut pc, Class<?> inScope, PointcutParameter[] formalParameters)

public PointcutParameter
createPointcutParameter(String name, Class<?> type)

Create a pointcut parameter of the given name and type.

public static Set<PointcutPrimitive>

Returns:

a Set containing every PointcutPrimitive except if, cflow, and cflowbelow (useful for passing to PointcutParser constructor).
getAllSupportedPointcutPrimitives
()

public 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.
public static PointcutParser
getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(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.
public static PointcutParser
getPointcutParserSupportingSpecifiedPrimitivesAndUsingContextClassloaderForResolution(Set<PointcutPrimitive>
a set of PointcutPrimitives this parser should support
supportedPointcutKinds
)

Returns a pointcut parser that can parse pointcut expressions built from a user-defined subset of AspectJ's supported pointcut primitives.

public static PointcutParser
getPointcutParserSupportingSpecifiedPrimitivesAndUsingSpecifiedClassLoaderForResolution(Set<PointcutPrimitive>
a set of PointcutPrimitives this parser should support
supportedPointcutKinds
,
ClassLoader classLoader)

Returns a pointcut parser that can parse pointcut expressions built from a user-defined subset of AspectJ's supported pointcut primitives.

pack-priv Set<PointcutPrimitive>
private World
public PointcutExpression
parsePointcutExpression(String expression)

Parse the given pointcut expression.

public PointcutExpression
parsePointcutExpression(String expression, Class<?> inScope, PointcutParameter[] formalParameters)

Parse the given pointcut expression.

public TypePatternMatcher

Returns:

a type pattern matcher that matches using the given pattern
parseTypePattern
(String
an aspectj type pattern
typePattern
)

Parse the given aspectj type pattern, and return a matcher that can be used to match types using it.

public void
registerPointcutDesignatorHandler(PointcutDesignatorHandler designatorHandler)

Register a new pointcut designator handler with this parser.

protected Pointcut
resolvePointcutExpression(String expression, Class<?> inScope, PointcutParameter[] formalParameters)

protected void
setClassLoader(ClassLoader aLoader)

Set the classloader that this parser should use for type resolution.

protected void
setClassLoader(ClassLoader aLoader, boolean
if true then two PointcutParsers operating using the same classloader will share a ReflectionWorld
shareWorlds
)

Set the classloader that this parser should use for type resolution.

pack-priv IMessageHandler
public void
setLintProperties(String
path to a file containing aspectj lint properties
resourcePath
)

Set the lint properties for this parser from the given resource on the classpath.

public void
setLintProperties(Properties properties)

Set the lint properties for this parser from the given properties set.

protected void
private UnresolvedType
private void
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

classLoaderReferenceback to summary
private WeakClassLoaderReference classLoaderReference
pointcutDesignatorsback to summary
private final Set<PointcutDesignatorHandler> pointcutDesignators
supportedPrimitivesback to summary
private final Set<PointcutPrimitive> supportedPrimitives
worldback to summary
private ReflectionWorld world

Constructor Detail

PointcutParserback to 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.
PointcutParserback to summary
private PointcutParser(Set<PointcutPrimitive> supportedPointcutKinds)

Create a pointcut parser that can parse pointcut expressions built from a user-defined subset of AspectJ's supported pointcut primitives. The following restrictions apply:

  • 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.
Parameters
supportedPointcutKinds:Set<PointcutPrimitive>

a set of PointcutPrimitives this parser should support

Exceptions
UnsupportedOperationException:
if the set contains if, cflow, or cflow below

Method Detail

buildResolutionScopeback to summary
private IScope buildResolutionScope(Class<?> inScope, PointcutParameter[] formalParameters)
buildUserMessageFromParserExceptionback to summary
private String buildUserMessageFromParserException(String pc, ParserException ex)
concretizePointcutExpressionback to summary
protected Pointcut concretizePointcutExpression(Pointcut pc, Class<?> inScope, PointcutParameter[] formalParameters)
createPointcutParameterback to summary
public PointcutParameter createPointcutParameter(String name, Class<?> type)

Create a pointcut parameter of the given name and type.

getAllSupportedPointcutPrimitivesback to summary
public static Set<PointcutPrimitive> getAllSupportedPointcutPrimitives()
Returns:Set<PointcutPrimitive>

a Set containing every PointcutPrimitive except if, cflow, and cflowbelow (useful for passing to PointcutParser constructor).

getPointcutParserSupportingAllPrimitivesAndUsingContextClassloaderForResolutionback to summary
public 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.

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

getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolutionback to summary
public static PointcutParser getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(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.

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

getPointcutParserSupportingSpecifiedPrimitivesAndUsingContextClassloaderForResolutionback to summary
public static PointcutParser getPointcutParserSupportingSpecifiedPrimitivesAndUsingContextClassloaderForResolution(Set<PointcutPrimitive> 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:

  • 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.

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

Parameters
supportedPointcutKinds:Set<PointcutPrimitive>

a set of PointcutPrimitives this parser should support

Exceptions
UnsupportedOperationException:
if the set contains if, cflow, or cflow below
getPointcutParserSupportingSpecifiedPrimitivesAndUsingSpecifiedClassLoaderForResolutionback to summary
public static PointcutParser getPointcutParserSupportingSpecifiedPrimitivesAndUsingSpecifiedClassLoaderForResolution(Set<PointcutPrimitive> supportedPointcutKinds, 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:

  • 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.

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

Parameters
supportedPointcutKinds:Set<PointcutPrimitive>

a set of PointcutPrimitives this parser should support

Exceptions
UnsupportedOperationException:
if the set contains if, cflow, or cflow below
getSupportedPrimitivesback to summary
pack-priv Set<PointcutPrimitive> getSupportedPrimitives()
getWorldback to summary
private World getWorld()
parsePointcutExpressionback to summary
public PointcutExpression parsePointcutExpression(String expression) throws UnsupportedPointcutPrimitiveException, 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).

Exceptions
UnsupportedPointcutPrimitiveException:
if the parser encounters a primitive pointcut expression of a kind not supported by this PointcutParser.
IllegalArgumentException:
if the expression is not a well-formed pointcut expression
parsePointcutExpressionback to summary
public PointcutExpression parsePointcutExpression(String expression, Class<?> inScope, PointcutParameter[] formalParameters) throws UnsupportedPointcutPrimitiveException, 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.

Exceptions
UnsupportedPointcutPrimitiveException:
if the parser encounters a primitive pointcut expression of a kind not supported by this PointcutParser.
IllegalArgumentException:
if the expression is not a well-formed pointcut expression
parseTypePatternback to summary
public TypePatternMatcher parseTypePattern(String typePattern) throws IllegalArgumentException

Parse the given aspectj type pattern, and return a matcher that can be used to match types using it.

Parameters
typePattern:String

an aspectj type pattern

Returns:TypePatternMatcher

a type pattern matcher that matches using the given pattern

Exceptions
IllegalArgumentException:
if the type pattern cannot be successfully parsed.
registerPointcutDesignatorHandlerback to summary
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.

resolvePointcutExpressionback to summary
protected Pointcut resolvePointcutExpression(String expression, Class<?> inScope, PointcutParameter[] formalParameters)
setClassLoaderback to summary
protected void setClassLoader(ClassLoader aLoader)

Set the classloader that this parser should use for type resolution.

setClassLoaderback to summary
protected void setClassLoader(ClassLoader aLoader, boolean shareWorlds)

Set the classloader that this parser should use for type resolution.

Parameters
shareWorlds:boolean

if true then two PointcutParsers operating using the same classloader will share a ReflectionWorld

setCustomMessageHandlerback to summary
pack-priv IMessageHandler setCustomMessageHandler(IMessageHandler aHandler)
setLintPropertiesback to summary
public void setLintProperties(String resourcePath) throws IOException

Set the lint properties for this parser from the given resource on the classpath.

Parameters
resourcePath:String

path to a file containing aspectj lint properties

setLintPropertiesback to summary
public void setLintProperties(Properties properties)

Set the lint properties for this parser from the given properties set.

setWorldback to summary
protected void setWorld(ReflectionWorld aWorld)
toUnresolvedTypeback to summary
private UnresolvedType toUnresolvedType(Class<?> clazz)
validateAgainstSupportedPrimitivesback to summary
private void validateAgainstSupportedPrimitives(Pointcut pc, String expression)
validateKindedPointcutback to summary
private void validateKindedPointcut(KindedPointcut pc, String expression)