Spring Framework

org.springframework.aop.interceptor
Class ExposeBeanNameAdvisors

java.lang.Object
  extended by org.springframework.aop.interceptor.ExposeBeanNameAdvisors

public abstract class ExposeBeanNameAdvisors
extends java.lang.Object

Convenient methods for creating advisors that may be used when autoproxying beans created with the Spring IoC container, binding the bean name to the current invocation. May support a bean() pointcut designator with AspectJ.

Typically used in Spring auto-proxying, where the bean name is known at proxy creation time.

Since:
2.0
Author:
Rod Johnson, Juergen Hoeller
See Also:
NamedBean

Constructor Summary
ExposeBeanNameAdvisors()
           
 
Method Summary
static Advisor createAdvisorIntroducingNamedBean(java.lang.String beanName)
          Create a new advisor that will expose the given bean name, introducing the NamedBean interface to make the bean name accessible without forcing the target object to be aware of this Spring IoC concept.
static Advisor createAdvisorWithoutIntroduction(java.lang.String beanName)
          Create a new advisor that will expose the given bean name, with no introduction
static java.lang.String getBeanName()
          Find the bean name for the current invocation.
static java.lang.String getBeanName(org.aopalliance.intercept.MethodInvocation mi)
          Find the bean name for the given invocation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExposeBeanNameAdvisors

public ExposeBeanNameAdvisors()
Method Detail

getBeanName

public static java.lang.String getBeanName()
                                    throws java.lang.IllegalStateException
Find the bean name for the current invocation. Assumes that an ExposeBeanNameAdvisor has been included in the interceptor chain, and that the invocation is exposed with ExposeInvocationInterceptor.

Returns:
the bean name (never null)
Throws:
java.lang.IllegalStateException - if the bean name has not been exposed

getBeanName

public static java.lang.String getBeanName(org.aopalliance.intercept.MethodInvocation mi)
                                    throws java.lang.IllegalStateException
Find the bean name for the given invocation. Assumes that an ExposeBeanNameAdvisor has been included in the interceptor chain.

Parameters:
mi - MethodInvocation that should contain the bean name as an attribute
Returns:
the bean name (never null)
Throws:
java.lang.IllegalStateException - if the bean name has not been exposed

createAdvisorWithoutIntroduction

public static Advisor createAdvisorWithoutIntroduction(java.lang.String beanName)
Create a new advisor that will expose the given bean name, with no introduction

Parameters:
beanName - bean name to expose

createAdvisorIntroducingNamedBean

public static Advisor createAdvisorIntroducingNamedBean(java.lang.String beanName)
Create a new advisor that will expose the given bean name, introducing the NamedBean interface to make the bean name accessible without forcing the target object to be aware of this Spring IoC concept.

Parameters:
beanName - the bean name to expose

Spring Framework