org.jboss.aop.advice
Interface AspectFactory

All Known Implementing Classes:
AspectFactoryDelegator, AspectFactoryWithClassLoaderSupport, GenericAspectFactory

public interface AspectFactory

Creates aspect instances.

This interface must be implemented by all aspect factories. Declare aspect factories instead of the real aspect class when you want:

This interface provides different methods. However, only the one(s) correspondent to the Scope of the aspect will be called. Hence, when writing an aspect factory whose scope is known (and is not intended to change), the implemention of the other methods can be empty. However, we advise throwing a runtime exception from those methods instead of simply returning null, to alert for unpredicted scenarios in case the Scope value is not the expected.

Version:
$Revision: 73173 $
Author:
Bill Burke

Method Summary
 Object createPerClass(Advisor advisor)
          Creates an aspect with scope value Scope.PER_CLASS.
 Object createPerInstance(Advisor advisor, InstanceAdvisor instanceAdvisor)
          Creates an aspect with scope value Scope.PER_INSTANCE.
 Object createPerJoinpoint(Advisor advisor, InstanceAdvisor instanceAdvisor, Joinpoint jp)
          Creates an aspect with scope value or Scope.PER_JOINPOINT.
 Object createPerJoinpoint(Advisor advisor, Joinpoint jp)
          Creates an aspect with scope value Scope.PER_CLASS_JOINPOINT or Scope.PER_JOINPOINT.
 Object createPerVM()
          Creates an aspect with scope value Scope.PER_VM.
 String getName()
          The name that identifies the aspect in its domain.
 

Method Detail

createPerVM

Object createPerVM()
Creates an aspect with scope value Scope.PER_VM.

Returns:
the single aspect instance that will be invoked for all applicable joinpoints during Java VM execution. If null, the aspect represented by this factory is ignored, resulting in no interception.

createPerClass

Object createPerClass(Advisor advisor)
Creates an aspect with scope value Scope.PER_CLASS.

Parameters:
advisor - manages all the interceptions that should occur during execution of a specific class
Returns:
the aspect instance that will be invoked for all applicable joinpoints contained in the class managed by advisor. If null, the aspect represented by this factory is ignored, resulting in no interception of the joinpoints contained in the referred class.
See Also:
Advisor.getClazz()

createPerInstance

Object createPerInstance(Advisor advisor,
                         InstanceAdvisor instanceAdvisor)
Creates an aspect with scope value Scope.PER_INSTANCE.

Parameters:
advisor - manages all the interceptions that should occur during execution of a specific class
instanceAdvisor - manages all the interceptions that should occur during execution of a specific instance. The instance it manages is an object of the class managed by advisor
Returns:
the aspect instance that will be invoked for all applicable joinpoints contained in the instance managed by instanceAdvisor. If null, the aspect represented by this factory is ignored, resulting in no interception of the joinpoints contained in the referred instance.
See Also:
Advisor.getClazz(), InstanceAdvisor.getInstance()

createPerJoinpoint

Object createPerJoinpoint(Advisor advisor,
                          Joinpoint jp)
Creates an aspect with scope value Scope.PER_CLASS_JOINPOINT or Scope.PER_JOINPOINT.
In case the scope value is PER_CLASS_JOINPOINT, this method will always be invoked to create the aspect instance. On the other hand, if the scope value is PER_JOINPOINT, this method is called only if the joinpoint to be intercepted is in a static context (like a static method, a static field access, or a constructor execution).

Parameters:
advisor - manages all the interceptions that should occur during execution of a specific class
jp - the joinpoint to be intercepted by the created instance. This joinpoint is contained in the class managed by advisor
Returns:
the aspect instance that will be invoked only to intercept jp. If null, the aspect represented by this factory is ignored, resulting in no interception of jp.
See Also:
Advisor.getClazz(), Joinpoint

createPerJoinpoint

Object createPerJoinpoint(Advisor advisor,
                          InstanceAdvisor instanceAdvisor,
                          Joinpoint jp)
Creates an aspect with scope value or Scope.PER_JOINPOINT.
This method is called only if the joinpoint to be intercepted is not in a static context (like a non-static method, for example).

Parameters:
advisor - manages all the interceptions that should occur during execution of a specific class
instanceAdvisor - manages all the interceptions that should occur during execution of a specific instance. The instance it manages is an object of the class managed by advisor
jp - the joinpoint to be intercepted by the created instance. This joinpoint is contained in the class managed by advisor
Returns:
the aspect instance that will be invoked only to intercept jp when it happens on the instance managed by instanceAdvisor. If null, the aspect represented by this factory is ignored, resulting in no interception of jp when it is executed in the context of the referred instance.
See Also:
Advisor.getClazz(), InstanceAdvisor.getInstance(), Joinpoint

getName

String getName()
The name that identifies the aspect in its domain. Typically, the name is the name of the class.

Returns:
the name that identifies the aspect in its domain.
See Also:
Domain


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