org.springframework.jee.intercept
Class InterceptionMetadata

java.lang.Object
  extended by org.springframework.jee.inject.Jsr250Metadata
      extended by org.springframework.jee.intercept.InterceptionMetadata
All Implemented Interfaces:
Jsr250MetadataI, InterceptionMetadataI
Direct Known Subclasses:
EjbMetadata, EjbProxyMetadata, TransactionalMetadata

public class InterceptionMetadata
extends Jsr250Metadata
implements InterceptionMetadataI

Class representing metadata for a component that may have interceptors as per the JEE (EJB 3.0) interception specification. Attached to a Spring singleton definition.

Author:
Rod Johnson

Nested Class Summary
static class InterceptionMetadata.InterceptorExclusion
          Class representing the exclusion of class or default interceptors from a particular method
 
Field Summary
 
Fields inherited from class org.springframework.jee.inject.Jsr250Metadata
KEY
 
Constructor Summary
InterceptionMetadata(DeploymentUnitMetadataI dum, String name, Class<?> componentClass)
           
 
Method Summary
protected  int addAspectJAdvisors(Advised advised, Object bean)
           
 void addBeanControlInterfaceMethod(Method method)
           
 void addBusinessInterface(Class<?> businessInterface)
          Add a business interface for the singleton.
protected  void addComponentContractInterceptors(ProxyFactory pf, Object target, Map<Class,Object> interceptorInstancesForClass)
          Add interceptors that apply the component contract--such as EJB transaction behaviour.
protected  void addJeeInterceptors(Advised advised, List<InterceptorMetadataI> interceptorMetadata, Map<Class,Object> interceptorInstancesForClass, boolean isInterceptorOrder)
          Parses the interceptor metadata list, creates Spring pointcut advisors based on it and adds it to the given advised object.
protected  void addJeeInterceptors(Advised advised, Object bean, Map<Class,Object> interceptorInstancesForClass)
          Add EJB3 style interceptors to this singleton instance
protected  void addSelfInterceptor(Advised advised, Object bean)
          Add an interceptor definition for the singleton/bean itself.
protected  int addSpringAopAdvisors(Advised pf, Object bean)
           
protected  void addSuperInterceptors(Advised advised, Object baseInterceptorInstance, List<Method> superAroundInvokeMethods, JeeInterceptorPointcutAdvisor baseInterceptorPointcutAdvisor)
           
 Object createProxyIfNecessary(Object target)
          Use Spring AOP to create a proxy invoking the JEE-style interceptors and any Spring-style interceptors.
 Object createProxyIfNecessary(Object target, Map<Class,Object> interceptorInstancesForClass)
          Use Spring AOP to create a proxy invoking the JEE-style interceptors and any Spring-style interceptors.
protected  void customizeProxyConfig(ProxyFactory pf)
          Perform optional customization of ProxyFactory before use
 List<Class<?>> findBusinessInterfacesFromClassOrAnnotation(Class<?> clazz)
           
 Class getBeanControlInterface()
           
 Set<Method> getBeanControlInterfaceMethods()
           
 List<Class<?>> getBusinessInterfaces()
           
 Map<Object,InterceptionMetadata.InterceptorExclusion> getExclusion()
           
 List<InterceptorMetadataI> getInterceptorMetadata()
          Return the interceptors that apply to the given component.
 List<InterceptorMetadataI> getInterceptorOrder(Object object)
           
 void invokeLifecycleMethods(Object bean, LifecycleEvent le)
          Override superclass method to invoke all interceptors in the chain if they listen to this method
protected  void invokePostConstructAndRegisterShutdownHook(Object instance)
           
protected  boolean isExcludedAsBusinessInterfaceOnAutodetect(Class<?> potentialBusinessInterface)
          Subclasses can override this to exclude further business interfaces
 void registerInterceptorMetadata(InterceptorMetadataI im)
          Add interceptor metadata.
 void registerInterceptorOrder(InterceptorMetadataI im, Object object)
           
 void registerSelfInterceptorMethod(Method selfInterceptorMethod)
          Set the self interceptor method for this component
 void setBeanControlInterface(Class beanControlInterface)
           
 void setBeanControlInterfaceMethods(Set<Method> beanControlInterfaceMethods)
           
 void setComponentContext(ApplicationContext componentContext, BeanDefinitionRegistry bdr)
          Set the application context for the superclass and for the inner interceptorMetadata.
 void setExcludeClassInterceptors(Object methodOrClass)
           
 void setExcludeDefaultInterceptors(Object methodOrClass)
           
 
Methods inherited from class org.springframework.jee.inject.Jsr250Metadata
addInjection, applyInjections, getBeanDefinition, getBeanDefinitionRegistry, getComponentClass, getComponentContext, getComponentName, getDeploymentUnitMetadata, getInjections, getLifecycleEventCallbackMethod, getUniqueInstanceOfType, inject, injectAndPostConstruct, invokeLifecycleMethod, invokeLifecycleMethod, refresh, registerLifecycleEventCallbackMethod, resolve, resolveByType, setBeanDefinition, setComponentContext, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.springframework.jee.interfaces.inject.Jsr250MetadataI
addInjection, getComponentClass, getComponentName, getDeploymentUnitMetadata, getInjections, getLifecycleEventCallbackMethod, inject, refresh, registerLifecycleEventCallbackMethod
 

Constructor Detail

InterceptionMetadata

public InterceptionMetadata(DeploymentUnitMetadataI dum,
                            String name,
                            Class<?> componentClass)
Method Detail

setComponentContext

public void setComponentContext(ApplicationContext componentContext,
                                BeanDefinitionRegistry bdr)
Set the application context for the superclass and for the inner interceptorMetadata.

Overrides:
setComponentContext in class Jsr250Metadata

invokePostConstructAndRegisterShutdownHook

protected void invokePostConstructAndRegisterShutdownHook(Object instance)
Overrides:
invokePostConstructAndRegisterShutdownHook in class Jsr250Metadata

registerSelfInterceptorMethod

public void registerSelfInterceptorMethod(Method selfInterceptorMethod)
Set the self interceptor method for this component

Specified by:
registerSelfInterceptorMethod in interface InterceptionMetadataI
Parameters:
selfInterceptorMethod - the self interceptor method for this component

setBeanControlInterface

public void setBeanControlInterface(Class beanControlInterface)
Specified by:
setBeanControlInterface in interface InterceptionMetadataI

getBeanControlInterface

public Class getBeanControlInterface()

setBeanControlInterfaceMethods

public void setBeanControlInterfaceMethods(Set<Method> beanControlInterfaceMethods)
Specified by:
setBeanControlInterfaceMethods in interface InterceptionMetadataI

addBeanControlInterfaceMethod

public void addBeanControlInterfaceMethod(Method method)

getBeanControlInterfaceMethods

public Set<Method> getBeanControlInterfaceMethods()

setExcludeClassInterceptors

public void setExcludeClassInterceptors(Object methodOrClass)
Specified by:
setExcludeClassInterceptors in interface InterceptionMetadataI

setExcludeDefaultInterceptors

public void setExcludeDefaultInterceptors(Object methodOrClass)
Specified by:
setExcludeDefaultInterceptors in interface InterceptionMetadataI

getExclusion

public Map<Object,InterceptionMetadata.InterceptorExclusion> getExclusion()
Returns:
the exclusion

registerInterceptorMetadata

public void registerInterceptorMetadata(InterceptorMetadataI im)
Add interceptor metadata. Whether it's a class or method level interceptor will be defined by whether the matchingMethod it returns is null. Following the EJB 3.0 specification, method level interceptors will be added after all class level interceptors.

Specified by:
registerInterceptorMetadata in interface InterceptionMetadataI
Parameters:
im - interceptor
matchingMethod - method to match on

getInterceptorMetadata

public List<InterceptorMetadataI> getInterceptorMetadata()
Return the interceptors that apply to the given component.

Specified by:
getInterceptorMetadata in interface InterceptionMetadataI
Returns:
a list of interceptors applying to the given component. This will be sorted, according to the spec, as with class interceptors followed by methodInterceptor, and finally any around invoke method denoting an interceptor on the component

registerInterceptorOrder

public void registerInterceptorOrder(InterceptorMetadataI im,
                                     Object object)
Specified by:
registerInterceptorOrder in interface InterceptionMetadataI

getInterceptorOrder

public List<InterceptorMetadataI> getInterceptorOrder(Object object)

addBusinessInterface

public void addBusinessInterface(Class<?> businessInterface)
Add a business interface for the singleton. If no business methods are added, default to using introspection to find all interfaces on the class

Specified by:
addBusinessInterface in interface InterceptionMetadataI
Parameters:
businessInterface - business interface to add

getBusinessInterfaces

public List<Class<?>> getBusinessInterfaces()

findBusinessInterfacesFromClassOrAnnotation

public List<Class<?>> findBusinessInterfacesFromClassOrAnnotation(Class<?> clazz)
Specified by:
findBusinessInterfacesFromClassOrAnnotation in interface InterceptionMetadataI

isExcludedAsBusinessInterfaceOnAutodetect

protected boolean isExcludedAsBusinessInterfaceOnAutodetect(Class<?> potentialBusinessInterface)
Subclasses can override this to exclude further business interfaces

Parameters:
potentialBusinessInterface - candidate interface
Returns:
whether this class should be excluded from consideration as a business interface if autodetecting business interfaces

createProxyIfNecessary

public Object createProxyIfNecessary(Object target)
Use Spring AOP to create a proxy invoking the JEE-style interceptors and any Spring-style interceptors. Create new instances of the given interceptors.

Specified by:
createProxyIfNecessary in interface InterceptionMetadataI
Parameters:
instance - the singleton instance to wrap in a proxy
Returns:
a Spring AOP proxy-control interface allowing subsequent changes to the proxy, if the object was proxied at all

createProxyIfNecessary

public Object createProxyIfNecessary(Object target,
                                     Map<Class,Object> interceptorInstancesForClass)
Use Spring AOP to create a proxy invoking the JEE-style interceptors and any Spring-style interceptors. Allows the creation of a fresh proxy wrapping a given target singleton instance and set of interceptors: for example, in the case where we have passivated a SFSB and now need to create a new proxy given activated interceptors and target instance state.

Specified by:
createProxyIfNecessary in interface InterceptionMetadataI
Parameters:
instance - the singleton instance to wrap in a proxy
interceptorInstancesForClass - map from interceptor class to instance of JEE interceptors
Returns:
a Spring AOP proxy-control interface allowing subsequent changes to the proxy, if the object was proxied at all

addComponentContractInterceptors

protected void addComponentContractInterceptors(ProxyFactory pf,
                                                Object target,
                                                Map<Class,Object> interceptorInstancesForClass)
Add interceptors that apply the component contract--such as EJB transaction behaviour.

Parameters:
pf - ProxyFactory used to create proxy

customizeProxyConfig

protected void customizeProxyConfig(ProxyFactory pf)
Perform optional customization of ProxyFactory before use

Parameters:
pf -

invokeLifecycleMethods

public void invokeLifecycleMethods(Object bean,
                                   LifecycleEvent le)
Override superclass method to invoke all interceptors in the chain if they listen to this method

Specified by:
invokeLifecycleMethods in interface Jsr250MetadataI
Overrides:
invokeLifecycleMethods in class Jsr250Metadata
Parameters:
singleton - normally a proxy
le - lifecycle event

addJeeInterceptors

protected void addJeeInterceptors(Advised advised,
                                  Object bean,
                                  Map<Class,Object> interceptorInstancesForClass)
Add EJB3 style interceptors to this singleton instance

Parameters:
advised - Spring AOP proxy control interface
singleton - new JEE component instance being advised (intercepted)
interceptorInstancesForClass - map from interceptor class to interceptor instance. Used to ensure that we have only one instance of each interceptor class, as per Core Contract specification 11.7.

addJeeInterceptors

protected void addJeeInterceptors(Advised advised,
                                  List<InterceptorMetadataI> interceptorMetadata,
                                  Map<Class,Object> interceptorInstancesForClass,
                                  boolean isInterceptorOrder)
Parses the interceptor metadata list, creates Spring pointcut advisors based on it and adds it to the given advised object.

Parameters:
advised -
interceptorMetadata -
interceptorInstancesForClass -

addSuperInterceptors

protected void addSuperInterceptors(Advised advised,
                                    Object baseInterceptorInstance,
                                    List<Method> superAroundInvokeMethods,
                                    JeeInterceptorPointcutAdvisor baseInterceptorPointcutAdvisor)

addSelfInterceptor

protected void addSelfInterceptor(Advised advised,
                                  Object bean)
Add an interceptor definition for the singleton/bean itself.

Parameters:
advised - AOP proxy control interface
singleton - target instance that contains an around invoke method

addSpringAopAdvisors

protected int addSpringAopAdvisors(Advised pf,
                                   Object bean)

addAspectJAdvisors

protected int addAspectJAdvisors(Advised advised,
                                 Object bean)


Copyright © 2006-2008 SpringSource (formerly Interface21). All Rights Reserved.