org.jboss.ejb3.interceptors.container
Class AbstractContainer<T,C extends AbstractContainer<T,C>>

java.lang.Object
  extended by org.jboss.ejb3.interceptors.annotation.AnnotationAdvisorSupport
      extended by org.jboss.ejb3.interceptors.container.AbstractContainer<T,C>
All Implemented Interfaces:
AnnotationAdvisor
Direct Known Subclasses:
AbstractDirectContainer, ProxyContainer

public abstract class AbstractContainer<T,C extends AbstractContainer<T,C>>
extends AnnotationAdvisorSupport
implements AnnotationAdvisor

The base of all containers. Provides functions to allow for object construction and invocation with interception. Note that it's up to the actual implementation to expose any methods.


Field Summary
protected  java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,org.jboss.aop.advice.Interceptor[]> lifecycleCallbackInterceptors
          Maintains a array of interceptors applicable to this bean context for each of the lifecycle callbacks
 
Constructor Summary
protected AbstractContainer()
          For a completely customized startup.
protected AbstractContainer(java.lang.String name, org.jboss.aop.Domain domain, java.lang.Class<? extends T> beanClass)
           
protected AbstractContainer(java.lang.String name, java.lang.String domainName, java.lang.Class<? extends T> beanClass)
           
 
Method Summary
protected  BeanContext<T> construct(java.lang.reflect.Constructor<? extends T> constructor, java.lang.Object... initargs)
           
protected  ManagedObjectAdvisor<T,C> createAdvisor(java.lang.String name, org.jboss.aop.Domain domain, java.lang.Class<? extends T> beanClass, org.jboss.aop.annotation.AnnotationRepository annotations)
           
protected  void createAndSetAdvisor(java.lang.String name, org.jboss.aop.Domain domain, java.lang.Class<? extends T> beanClass, org.jboss.aop.annotation.AnnotationRepository annotations)
           
protected  java.lang.Object createInterceptor(java.lang.Class<?> interceptorClass)
           
protected  void destroy(BeanContext<T> bean)
           
protected  ManagedObjectAdvisor<T,C> getAdvisor()
           
protected  java.lang.Class<? extends T> getBeanClass()
           
static
<C extends AbstractContainer<?,?>>
C
getContainer(org.jboss.aop.Advisor advisor)
           
protected static org.jboss.aop.Domain getDomain(java.lang.String domainName)
           
 InterceptorRegistry getInterceptorRegistry()
           
protected  org.jboss.aop.advice.Interceptor[] getLifecycleInterceptors(java.lang.Class<? extends java.lang.annotation.Annotation> lifecycleCallbackAnnotation)
          Returns the interceptor instances (which is a combination of our internal AOP interceptors and bean developer defined Interceptors), corresponding to the lifecycleCallbackAnnotation.
protected  void initializeAdvisor(java.lang.String name, org.jboss.aop.Domain domain, java.lang.Class<? extends T> beanClass)
          Finalize construction of the abstract container by setting the advisor.
protected  void initializeAdvisor(java.lang.String name, org.jboss.aop.Domain domain, java.lang.Class<? extends T> beanClass, org.jboss.aop.annotation.AnnotationRepository annotations)
           
protected  java.lang.Object invoke(BeanContext<T> target, java.lang.reflect.Method method, java.lang.Object[] arguments)
          Call a method upon a target object with all interceptors in place.
protected
<R> R
invoke(BeanContext<T> target, java.lang.String methodName, java.lang.Object... args)
          A convenient, but unchecked and slow method to call a method upon a target.
 void invokeCallback(BeanContext<?> beanContext, java.lang.Class<? extends java.lang.annotation.Annotation> callbackAnnotationClass)
          Invokes the lifecycle callback(s) represented by the callbackAnnotationClass through (cached) AOP interceptor chain.
 void setBeanContextFactoryClass(java.lang.Class<? extends BeanContextFactory<T,C>> beanContextFactoryClass)
           
 
Methods inherited from class org.jboss.ejb3.interceptors.annotation.AnnotationAdvisorSupport
getAnnotation, getAnnotation, getAnnotation, isAnnotationPresent, isAnnotationPresent, isAnnotationPresent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.ejb3.interceptors.annotation.AnnotationAdvisor
getAnnotation, getAnnotation, getAnnotation, isAnnotationPresent, isAnnotationPresent, isAnnotationPresent
 

Field Detail

lifecycleCallbackInterceptors

protected java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,org.jboss.aop.advice.Interceptor[]> lifecycleCallbackInterceptors
Maintains a array of interceptors applicable to this bean context for each of the lifecycle callbacks

Constructor Detail

AbstractContainer

protected AbstractContainer()
For a completely customized startup. Note that before construction ends advisor must be set!


AbstractContainer

protected AbstractContainer(java.lang.String name,
                            org.jboss.aop.Domain domain,
                            java.lang.Class<? extends T> beanClass)

AbstractContainer

protected AbstractContainer(java.lang.String name,
                            java.lang.String domainName,
                            java.lang.Class<? extends T> beanClass)
Method Detail

construct

protected BeanContext<T> construct(java.lang.reflect.Constructor<? extends T> constructor,
                                   java.lang.Object... initargs)

createInterceptor

protected java.lang.Object createInterceptor(java.lang.Class<?> interceptorClass)
                                      throws java.lang.InstantiationException,
                                             java.lang.IllegalAccessException
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException

destroy

protected void destroy(BeanContext<T> bean)

initializeAdvisor

protected void initializeAdvisor(java.lang.String name,
                                 org.jboss.aop.Domain domain,
                                 java.lang.Class<? extends T> beanClass)
Finalize construction of the abstract container by setting the advisor.

Parameters:
name - the name of the advisor
domain - the domain for the advisor
beanClass - the class being advised

initializeAdvisor

protected final void initializeAdvisor(java.lang.String name,
                                       org.jboss.aop.Domain domain,
                                       java.lang.Class<? extends T> beanClass,
                                       org.jboss.aop.annotation.AnnotationRepository annotations)

createAndSetAdvisor

protected final void createAndSetAdvisor(java.lang.String name,
                                         org.jboss.aop.Domain domain,
                                         java.lang.Class<? extends T> beanClass,
                                         org.jboss.aop.annotation.AnnotationRepository annotations)

createAdvisor

protected ManagedObjectAdvisor<T,C> createAdvisor(java.lang.String name,
                                                  org.jboss.aop.Domain domain,
                                                  java.lang.Class<? extends T> beanClass,
                                                  org.jboss.aop.annotation.AnnotationRepository annotations)

getAdvisor

protected final ManagedObjectAdvisor<T,C> getAdvisor()

getBeanClass

protected java.lang.Class<? extends T> getBeanClass()

getContainer

public static <C extends AbstractContainer<?,?>> C getContainer(org.jboss.aop.Advisor advisor)

getDomain

protected static final org.jboss.aop.Domain getDomain(java.lang.String domainName)

getInterceptorRegistry

public InterceptorRegistry getInterceptorRegistry()

invokeCallback

public void invokeCallback(BeanContext<?> beanContext,
                           java.lang.Class<? extends java.lang.annotation.Annotation> callbackAnnotationClass)
Invokes the lifecycle callback(s) represented by the callbackAnnotationClass through (cached) AOP interceptor chain. Internally, the AOP interceptor chain consists of the LifecycleCallback AOP stack interceptors, the javax.interceptor.Interceptor(s) and the lifecycle methods on the bean implementation class

Parameters:
beanContext - The bean context
callbackAnnotationClass - The lifecycle callback (ex: @PostConstruct, @PrePassivate etc...)
See Also:
for more details.

getLifecycleInterceptors

protected org.jboss.aop.advice.Interceptor[] getLifecycleInterceptors(java.lang.Class<? extends java.lang.annotation.Annotation> lifecycleCallbackAnnotation)
Returns the interceptor instances (which is a combination of our internal AOP interceptors and bean developer defined Interceptors), corresponding to the lifecycleCallbackAnnotation. Internally caches the interceptor instances corresponding to each of the lifecycle callbacks, for this bean context

Parameters:
lifecycleCallbackAnnotation - Lifecycle callback annotations like PrePassivate, PostActivate, PreDestroy, PostConstruct
Returns:
Returns an empty array if there are no interceptor instances associated with this bean context, for the lifecycleCallbackAnnotation. Else, returns the array of interceptors applicable to this bean context for the lifecycleCallbackAnnotation

invoke

protected java.lang.Object invoke(BeanContext<T> target,
                                  java.lang.reflect.Method method,
                                  java.lang.Object[] arguments)
                           throws java.lang.Throwable
Call a method upon a target object with all interceptors in place.

Parameters:
target - the target to invoke upon
method - the method to invoke
arguments - arguments to the method
Returns:
return value of the method
Throws:
java.lang.Throwable - if anything goes wrong

invoke

protected <R> R invoke(BeanContext<T> target,
                       java.lang.String methodName,
                       java.lang.Object... args)
            throws java.lang.Throwable
A convenient, but unchecked and slow method to call a method upon a target. (Slow method)

Type Parameters:
R - the return type
Parameters:
target - the target to invoke upon
methodName - the method name to invoke
args - the arguments to the method
Returns:
the return value
Throws:
java.lang.Throwable - if anything goes wrong

setBeanContextFactoryClass

public void setBeanContextFactoryClass(java.lang.Class<? extends BeanContextFactory<T,C>> beanContextFactoryClass)