org.jboss.aop.advice
Class GeneratedAdvisorInterceptor

java.lang.Object
  extended by org.jboss.aop.advice.GeneratedAdvisorInterceptor
All Implemented Interfaces:
Interceptor

public class GeneratedAdvisorInterceptor
extends Object
implements Interceptor

Special interceptor wrapping the interceptor factory, so that generated advisors have all the information they need about the contained advices for generating the invocation methods. If we are invoked upon dymamically we use vanilla invocations, i.e. the generated invocation code does not step in, so we generate the interceptor class as and when needed in our invoke() method. Old skool class advisors do not use this class

Version:
$Revision: 78996 $
Author:
Kabir Khan

Constructor Summary
GeneratedAdvisorInterceptor(InterceptorFactory factory, GeneratedClassAdvisor advisor, Joinpoint joinpoint)
           
GeneratedAdvisorInterceptor(InterceptorFactory factory, GeneratedClassAdvisor advisor, Joinpoint joinpoint, String cflowString, ASTCFlowExpression cflowExpr)
           
 
Method Summary
 Interceptor create(Advisor advisor, Joinpoint joinpoint)
           
 boolean equals(Object obj)
           
 String getAdviceName()
           
 String getAdviceString()
           
 AspectDefinition getAspect()
           
 Object getAspect(Advisor advisor, Joinpoint joinpoint)
          Used to obtain aspects from the generated code at runtime for joinpoints/aspects requiring an instance advisor
 Object getAspect(Advisor advisor, Joinpoint joinpoint, boolean forCodeGeneration)
          Also used as a convenience method to create aspect instances for the JoinPointGenerator in order to figure out what the class of the aspect should be when making the call from the generated joinpoint class.
 String getAspectClassName()
           
 ASTCFlowExpression getCflowExpression()
           
 String getCFlowString()
           
 InterceptorFactory getDelegate()
           
 String getName()
          Returns the name of this interceptor.
 Object getPerInstanceAspect(Advisor advisor, Joinpoint joinpoint, InstanceAdvisor ia)
          Used to obtain aspects from the generated code at runtime for joinpoints/aspects requiring an instance advisor
 String getRegisteredName()
           
 Scope getScope()
           
 AdviceType getType()
           
 Object invoke(Invocation invocation)
          The single advice contained in the Interceptor.
 boolean isAspectFactory()
           
 boolean isInterceptor()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeneratedAdvisorInterceptor

public GeneratedAdvisorInterceptor(InterceptorFactory factory,
                                   GeneratedClassAdvisor advisor,
                                   Joinpoint joinpoint,
                                   String cflowString,
                                   ASTCFlowExpression cflowExpr)

GeneratedAdvisorInterceptor

public GeneratedAdvisorInterceptor(InterceptorFactory factory,
                                   GeneratedClassAdvisor advisor,
                                   Joinpoint joinpoint)
Method Detail

create

public Interceptor create(Advisor advisor,
                          Joinpoint joinpoint)

getAspect

public Object getAspect(Advisor advisor,
                        Joinpoint joinpoint)
Used to obtain aspects from the generated code at runtime for joinpoints/aspects requiring an instance advisor


getAspect

public Object getAspect(Advisor advisor,
                        Joinpoint joinpoint,
                        boolean forCodeGeneration)
Also used as a convenience method to create aspect instances for the JoinPointGenerator in order to figure out what the class of the aspect should be when making the call from the generated joinpoint class. PER_INSTANCE or PER_JOINPOINT (for non-static fields) aspects cannot be created "properly" until at runtime, since that requires access to the instance advisor. If forCodeGeneration is true we create a temporary InstanceAdvisor to avoid NPEs in case we are calling an AspectFactory needing access to the instance advisor


getPerInstanceAspect

public Object getPerInstanceAspect(Advisor advisor,
                                   Joinpoint joinpoint,
                                   InstanceAdvisor ia)
Used to obtain aspects from the generated code at runtime for joinpoints/aspects requiring an instance advisor


isAspectFactory

public boolean isAspectFactory()

getDelegate

public InterceptorFactory getDelegate()

getAspect

public AspectDefinition getAspect()

getName

public String getName()
Description copied from interface: Interceptor
Returns the name of this interceptor. This name is unique inside the domain.

Specified by:
getName in interface Interceptor
Returns:
name the name that identifies this interceptor in its domain

getAspectClassName

public String getAspectClassName()

getType

public AdviceType getType()

isInterceptor

public boolean isInterceptor()

getAdviceName

public String getAdviceName()

getScope

public Scope getScope()

getRegisteredName

public String getRegisteredName()

getCflowExpression

public ASTCFlowExpression getCflowExpression()

getCFlowString

public String getCFlowString()

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

invoke

public Object invoke(Invocation invocation)
              throws Throwable
Description copied from interface: Interceptor
The single advice contained in the Interceptor.
To call the next interceptor or advice in the chain, this method must call invocation.invokeNext() method (if there are not elements left to be called in the chain, this method invokes the joinpoint itself). Not doing so means halting the execution of the interceptor chain and, hence, avoiding the execution of the joinpoint. This should be done only when the interceptor must replace the joinpoint execution.

Specified by:
invoke in interface Interceptor
Parameters:
invocation - represents the joinpoint to be intercepted
Returns:
the result value. This value will be returned to the previous interceptor/advice as a result of Invocation.invokeNext(). In case this is the first interceptor in the chain, this value will replace the joinpoint return value in the basis system.
Throws:
Throwable - may throw any exceptions declared by the joinpoint itself. If this exception is not declared and is not a runtime exception, it will be encapsulated in a RuntimeException before being thrown to the basis system.

getAdviceString

public String getAdviceString()


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