org.jboss.aop.advice
Class AdviceBinding

java.lang.Object
  extended by org.jboss.aop.advice.AdviceBinding

public class AdviceBinding
extends Object

Binds a pointcut expression to one ore more advices/interceptors.

Version:
$Revision: 77480 $
Author:
Bill Burke
See Also:
AspectManager.addBinding(AdviceBinding), AspectManager.removeBinding(String)

Field Summary
protected  Map<Advisor,Boolean> advisors
          Contains all the client advisors, mapped to a boolean value.
protected  ASTCFlowExpression cflow
          A control flow restriction (in its AST form).
protected  String cflowString
          A control flow restriction (in its string form).
protected  InterceptorFactory[] interceptorFactories
          The factories responsible for creating the bound interceptor instances.
protected  String name
          Name that identifies this binding in its domain.
protected  Pointcut pointcut
          Identifies when the advices/interceptors contained in this binding should be invoked.
 
Constructor Summary
AdviceBinding()
           
AdviceBinding(String name, Pointcut p, ASTCFlowExpression cflow, String cflowString, InterceptorFactory[] factories)
          Constructor to be used internally.
AdviceBinding(String pointcutExpression, String cflow)
          This constructor is used for creation of advice bindings programmatically on dynamic AOP operations.
AdviceBinding(String name, String pointcutExpression, String cflow)
          This constructor is used for creation of advice bindings programmatically on dynamic AOP operations.
 
Method Summary
 void addAdvisor(Advisor advisor)
          Adds an advisor as a client of this binding.
 void addInterceptor(Class<?> clazz)
          Adds an interceptor to the chain.
 void addInterceptorFactory(InterceptorFactory factory)
          Adds an interceptor to the chain.
 void clearAdvisors()
          Clears the list of the client advisors.
 boolean equals(Object obj)
          Compares this binding with obj for equality.
 ArrayList<Advisor> getAdvisors()
          Returns the list of the client advisors.
 ASTCFlowExpression getCFlow()
          Returns the cflow condition in the form an AST parser.
 String getCFlowString()
          Returns the cflow condition.
 InterceptorFactory[] getInterceptorFactories()
          Returns the interceptor factory chain.
 String getName()
          Returns the name of this binding.
 Pointcut getPointcut()
          Returns the pointcut that determines when the bound interceptor chain should be invoked.
 boolean hasAdvisors()
          Indicates whether there are any advisors using this binding for interception.
 int hashCode()
           
 void setCFlowExpression(String cflow)
          Defines a control-flow restriction to this binding.
 void setName(String name)
          Defines the name of this binding.
 void setPointcutExpression(String pointcutExpression)
          Defines the pointcut expression to be used by this binding.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected String name
Name that identifies this binding in its domain.


pointcut

protected Pointcut pointcut
Identifies when the advices/interceptors contained in this binding should be invoked.


cflow

protected ASTCFlowExpression cflow
A control flow restriction (in its AST form). Can be null.


cflowString

protected String cflowString
A control flow restriction (in its string form). Can be null


advisors

protected Map<Advisor,Boolean> advisors
Contains all the client advisors, mapped to a boolean value.


interceptorFactories

protected InterceptorFactory[] interceptorFactories
The factories responsible for creating the bound interceptor instances.

Constructor Detail

AdviceBinding

public AdviceBinding()

AdviceBinding

public AdviceBinding(String name,
                     Pointcut p,
                     ASTCFlowExpression cflow,
                     String cflowString,
                     InterceptorFactory[] factories)
              throws ParseException
Constructor to be used internally.

Parameters:
name - identifies this definition in its domain
p - pointcut expression. Only the joinpoints that satisfy this expression will be intercepted by the bound interceptors.
cflow - a control flow condition in the form of an AST parser
cflowString - a control flow expression
factories - creates the objects that will perform interception on the matched joinpoints
Throws:
ParseException - when cflowString is not null and contains a syntax error

AdviceBinding

public AdviceBinding(String pointcutExpression,
                     String cflow)
              throws ParseException
This constructor is used for creation of advice bindings programmatically on dynamic AOP operations.

The name of the advice will be generated automatically.

Bound interceptors will be invoked only on the joinpoints that are matched by pointcutExpression, and that satisfy cflow if it is not null.

Parameters:
pointcutExpression - pointcut expression. Only the joinpoints that satisfy this expression will be intercepted by the bound interceptors.
cflow - a control flow expression. Can be null if no such condition is necessary. Notice that using control flow conditions requires runtime checks and may impact your system performance. Always prefer to use pointcut expressions of the form call(...) AND within(...) or call(...) AND withincode(...) instead, whenever applicable.
Throws:
ParseException - when cflow is not null and contains a syntax error

AdviceBinding

public AdviceBinding(String name,
                     String pointcutExpression,
                     String cflow)
              throws ParseException
This constructor is used for creation of advice bindings programmatically on dynamic AOP operations. Call this constructor when you want to define the binding's name.

Bound interceptors will be invoked only on the joinpoints that are matched by pointcutExpression, and that satisfy cflow if it is not null.

Parameters:
name - identifies this binding in its domain.
pointcutExpression - pointcut expression. Only the joinpoints that satisfy this expression can be intercepted by the bound interceptors.
cflow - a control flow expression. Can be null if no such condition is necessary. Notice that using control flow conditions requires runtime checks and may impact your system performance. Always prefer to use pointcut expressions of the form call(...) AND within(...) or call(...) AND withincode(...) instead, whenever applicable.
Throws:
ParseException - when cflow is not null and contains a syntax error
Method Detail

setCFlowExpression

public void setCFlowExpression(String cflow)
                        throws ParseException
Defines a control-flow restriction to this binding.
Bound interceptors will not be invoked when this restriction is not satisfied.
Notice that using control flow conditions requires runtime checks and may impact your system performance. Always prefer to use pointcut expressions of the form call(...) AND within(...) or call(...) AND withincode(...) instead, whenever applicable.

Parameters:
cflow - a control flow expression.
Throws:
ParseException - when cflow is not null and contains a syntax error

setPointcutExpression

public void setPointcutExpression(String pointcutExpression)
                           throws ParseException
Defines the pointcut expression to be used by this binding.
Bound interceptors will be invoked only on the joinpoints that are matched by this expression, and that satisfy the cflow condition if there is one.

Parameters:
pointcutExpression - pointcut expression. Only the joinpoints that satisfy this expression can be intercepted by the bound interceptors.
Throws:
ParseException - when cflow is not null and contains a syntax error

addInterceptorFactory

public void addInterceptorFactory(InterceptorFactory factory)
Adds an interceptor to the chain.

Parameters:
factory - creates the interceptor instances that will be invoked during interception

addInterceptor

public void addInterceptor(Class<?> clazz)
Adds an interceptor to the chain.

Parameters:
clazz - the actual class that implements Interceptor. This class must provide a default constructor so it can be created. A GenericInterceptorFactory will be used to create the interceptor instances.
See Also:
GenericInterceptorFactory

getName

public String getName()
Returns the name of this binding. This name is unique inside the domain.

Returns:
name the name that identifies this binding in its domain

getInterceptorFactories

public InterceptorFactory[] getInterceptorFactories()
Returns the interceptor factory chain.

For internal use only.

Returns:
an array containing the interceptor factory chain. This chain will be used to create an equivalent chain (same order) of interceptor instances. The generated interceptor chain is the one that will be used on interception. This chain must not be edited this chain.
See Also:
addInterceptor(Class), addInterceptorFactory(InterceptorFactory)

setName

public void setName(String name)
Defines the name of this binding. This name must be unique inside the domain.

Parameters:
name - the name that identifies this binding in its domain

getPointcut

public Pointcut getPointcut()
Returns the pointcut that determines when the bound interceptor chain should be invoked.

For internal use only.

Returns:
the pointcut object

getCFlow

public ASTCFlowExpression getCFlow()
Returns the cflow condition in the form an AST parser.

For internal use only.

Returns:
the cflow condition that must be satisfied by joinpoints in order for the bound interceptors to be invoked

getCFlowString

public String getCFlowString()
Returns the cflow condition.

Returns:
the cflow condition expression that must be satisfied by joinpoints in order for the bound interceptors to be invoked

addAdvisor

public void addAdvisor(Advisor advisor)
Adds an advisor as a client of this binding.

For internal use only.

Parameters:
advisor - manages one or more joinpoints that are matched by the bound pointcut.

hasAdvisors

public boolean hasAdvisors()
Indicates whether there are any advisors using this binding for interception.

Returns:
true if and only if there are one or more advisors that use this binding for interception

getAdvisors

public ArrayList<Advisor> getAdvisors()
Returns the list of the client advisors.

For internal use only.

Returns:
the list of the advisors that use this binding for interception

clearAdvisors

public void clearAdvisors()
Clears the list of the client advisors.

For internal use only.


equals

public boolean equals(Object obj)
Compares this binding with obj for equality.

Overrides:
equals in class Object
Parameters:
obj - the object to be compared with this binding for equality
Returns:
true if and only if obj is a binding with a name that is equal to the name of this binding.

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2008 JBoss, a division of Red Hat, Inc.. All Rights Reserved.