org.springframework.jee.intercept
Class InterceptionMetadata

java.lang.Object
  extended by org.springframework.jee.inject.Jsr250Metadata
      extended by org.springframework.jee.intercept.InterceptionMetadata
Direct Known Subclasses:
EjbMetadata, TransactionalMetadata

public class InterceptionMetadata
extends Jsr250Metadata

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(DeploymentUnitMetadata dum, java.lang.String name, java.lang.Class<?> componentClass)
           
 
Method Summary
protected  int addAspectJAdvisors(org.springframework.aop.framework.Advised advised, java.lang.Object bean)
           
 void addBusinessInterface(java.lang.Class<?> businessInterface)
          Add a business interface for the singleton.
protected  void addComponentContractInterceptors(org.springframework.aop.framework.ProxyFactory pf)
          Add interceptors that apply the component contract--such as EJB transaction behaviour.
protected  void addJeeInterceptors(org.springframework.aop.framework.Advised advised, java.util.List<InterceptorMetadata> interceptorMetadata, java.util.Map<java.lang.Class,java.lang.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(org.springframework.aop.framework.Advised advised, java.lang.Object bean, java.util.Map<java.lang.Class,java.lang.Object> interceptorInstancesForClass)
          Add EJB3 style interceptors to this singleton instance
protected  void addSelfInterceptor(org.springframework.aop.framework.Advised advised, java.lang.Object bean)
          Add an interceptor definition for the singleton/bean itself.
protected  int addSpringAopAdvisors(org.springframework.aop.framework.Advised pf, java.lang.Object bean)
           
protected  void addSuperInterceptors(org.springframework.aop.framework.Advised advised, java.lang.Object baseInterceptorInstance, JeeInterceptorPointcutAdvisor baseInterceptorPointcutAdvisor)
           
 java.lang.Object createProxyIfNecessary(java.lang.Object target)
          Use Spring AOP to create a proxy invoking the JEE-style interceptors and any Spring-style interceptors.
 java.lang.Object createProxyIfNecessary(java.lang.Object target, java.util.Map<java.lang.Class,java.lang.Object> interceptorInstancesForClass)
          Use Spring AOP to create a proxy invoking the JEE-style interceptors and any Spring-style interceptors.
protected  void customizeProxyConfig(org.springframework.aop.framework.ProxyFactory pf)
          Perform optional customization of ProxyFactory before use
protected  java.util.List<java.lang.reflect.Method> findSuperAroundInvokes(java.lang.Class clazz)
           
 java.util.List<java.lang.Class<?>> getBusinessInterfaces()
           
 java.util.Map<java.lang.reflect.Method,InterceptionMetadata.InterceptorExclusion> getExclusion()
           
 java.util.List<InterceptorMetadata> getInterceptorMetadata()
          Return the interceptors that apply to the given component.
 java.util.List<InterceptorMetadata> getInterceptorOrder(java.lang.Object object)
           
 void invokeLifecycleMethods(java.lang.Object bean, LifecycleEvent le)
          Override superclass method to invoke all interceptors in the chain if they listen to this method
protected  void invokePostConstructAndRegisterShutdownHook(java.lang.Object instance)
           
protected  boolean isExcludedAsBusinessInterfaceOnAutodetect(java.lang.Class<?> potentialBusinessInterface)
          Subclasses can override this to exclude further business interfaces
 void registerInterceptorMetadata(InterceptorMetadata im)
          Add interceptor metadata.
 void registerInterceptorOrder(InterceptorMetadata im, java.lang.Object object)
           
 void setComponentContext(org.springframework.context.ApplicationContext componentContext, org.springframework.beans.factory.support.BeanDefinitionRegistry bdr)
          Set the application context for the superclass and for the inner interceptorMetadata.
 void setExcludeClassInterceptors(java.lang.reflect.Method method)
           
 void setExcludeDefaultInterceptors(java.lang.reflect.Method method)
           
 void setSelfInterceptorMethod(java.lang.reflect.Method selfInterceptorMethod)
          Set the self interceptor method for this component
 
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
 

Constructor Detail

InterceptionMetadata

public InterceptionMetadata(DeploymentUnitMetadata dum,
                            java.lang.String name,
                            java.lang.Class<?> componentClass)
Method Detail

setComponentContext

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

Overrides:
setComponentContext in class Jsr250Metadata

invokePostConstructAndRegisterShutdownHook

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

setSelfInterceptorMethod

public void setSelfInterceptorMethod(java.lang.reflect.Method selfInterceptorMethod)
Set the self interceptor method for this component

Parameters:
selfInterceptorMethod - the self interceptor method for this component

addBusinessInterface

public void addBusinessInterface(java.lang.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

Parameters:
businessInterface - business interface to add

setExcludeClassInterceptors

public void setExcludeClassInterceptors(java.lang.reflect.Method method)

setExcludeDefaultInterceptors

public void setExcludeDefaultInterceptors(java.lang.reflect.Method method)

registerInterceptorMetadata

public void registerInterceptorMetadata(InterceptorMetadata 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.

Parameters:
im - interceptor
matchingMethod - method to match on

getInterceptorMetadata

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

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(InterceptorMetadata im,
                                     java.lang.Object object)

getInterceptorOrder

public java.util.List<InterceptorMetadata> getInterceptorOrder(java.lang.Object object)

getBusinessInterfaces

public java.util.List<java.lang.Class<?>> getBusinessInterfaces()

isExcludedAsBusinessInterfaceOnAutodetect

protected boolean isExcludedAsBusinessInterfaceOnAutodetect(java.lang.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 java.lang.Object createProxyIfNecessary(java.lang.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.

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 java.lang.Object createProxyIfNecessary(java.lang.Object target,
                                               java.util.Map<java.lang.Class,java.lang.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.

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(org.springframework.aop.framework.ProxyFactory pf)
Add interceptors that apply the component contract--such as EJB transaction behaviour.

Parameters:
pf - ProxyFactory used to create proxy

customizeProxyConfig

protected void customizeProxyConfig(org.springframework.aop.framework.ProxyFactory pf)
Perform optional customization of ProxyFactory before use

Parameters:
pf -

invokeLifecycleMethods

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

Overrides:
invokeLifecycleMethods in class Jsr250Metadata
Parameters:
singleton - normally a proxy
le - lifecycle event

addJeeInterceptors

protected void addJeeInterceptors(org.springframework.aop.framework.Advised advised,
                                  java.lang.Object bean,
                                  java.util.Map<java.lang.Class,java.lang.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(org.springframework.aop.framework.Advised advised,
                                  java.util.List<InterceptorMetadata> interceptorMetadata,
                                  java.util.Map<java.lang.Class,java.lang.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(org.springframework.aop.framework.Advised advised,
                                    java.lang.Object baseInterceptorInstance,
                                    JeeInterceptorPointcutAdvisor baseInterceptorPointcutAdvisor)

findSuperAroundInvokes

protected java.util.List<java.lang.reflect.Method> findSuperAroundInvokes(java.lang.Class clazz)

addSelfInterceptor

protected void addSelfInterceptor(org.springframework.aop.framework.Advised advised,
                                  java.lang.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(org.springframework.aop.framework.Advised pf,
                                   java.lang.Object bean)

addAspectJAdvisors

protected int addAspectJAdvisors(org.springframework.aop.framework.Advised advised,
                                 java.lang.Object bean)

getExclusion

public java.util.Map<java.lang.reflect.Method,InterceptionMetadata.InterceptorExclusion> getExclusion()
Returns:
the exclusion


Copyright 2006 Interface21. All Rights Reserved.