FileDocCategorySizeDatePackage
BaseContext.javaAPI DocJBoss 4.2.14426Fri Jul 13 20:53:58 BST 2007org.jboss.ejb3

BaseContext

public abstract class BaseContext extends Object implements BeanContext
Comment
author
Bill Burke
version
$Revision: 61173 $

Fields Summary
protected static Logger
log
protected Container
container
protected Object
bean
protected org.jboss.security.RealmMapping
rm
protected org.jboss.aop.metadata.SimpleMetaData
metadata
protected javax.ejb.EJBContext
ejbContext
protected HashMap
interceptorInstances
Constructors Summary
public BaseContext()

   
    
   
   
Methods Summary
public voidbindEJBContext()

      try 
      {
         Util.rebind(container.getEnc(), "EJBContext", getEJBContext());
      }
      catch (javax.naming.NamingException e)
      {
         e.printStackTrace();
         throw new RuntimeException(e);
      }
   
public ContainergetContainer()

      return container;
   
public javax.ejb.EJBContextgetEJBContext()

      if (ejbContext == null)
      {
         BaseSessionContext bsc = new BaseSessionContext();
         bsc.setContainer(getContainer());
         bsc.setBaseContext(this);
         ejbContext = bsc;
      }
      return ejbContext;
   
public java.lang.ObjectgetId()

      return null;
   
public java.lang.ObjectgetInstance()

      return bean;
   
public java.lang.Object[]getInterceptorInstances(org.jboss.ejb3.interceptor.InterceptorInfo[] interceptorInfos)

      Object[] interceptors = new Object[interceptorInfos.length];
      int i = 0;
      for (InterceptorInfo info : interceptorInfos)
      {
         interceptors[i++] = interceptorInstances.get(info.getClazz());
      }
      return interceptors;
   
public java.lang.ObjectgetInvokedMethodKey()

      return container;
   
public org.jboss.aop.metadata.SimpleMetaDatagetMetaData()

      if (metadata == null) metadata = new SimpleMetaData();
      return metadata;
   
public voidinitialiseInterceptorInstances()

      HashSet<InterceptorInfo> interceptors = ((EJBContainer)container).getApplicableInterceptors();
      if (interceptors != null && interceptors.size() > 0 && interceptorInstances == null)
      {
         HashMap<Class,InterceptorInjector> interceptorInjectors = ((EJBContainer)container).getInterceptorInjectors();
         interceptorInstances = new HashMap<Class, Object>();
         for (InterceptorInfo info : interceptors)
         {
            try
            {
               Object instance = info.getClazz().newInstance();
               interceptorInstances.put(info.getClazz(), instance);
               interceptorInjectors.get(info.getClazz()).inject(this, instance);
            }
            catch (Exception e)
            {
               log.warn("Interceptors must have a public noargs constructor: " + info.getClazz().getName());
            }
         }
      }
   
public voidsetContainer(Container container)

      this.container = container;
      bindEJBContext();
   
public voidsetInstance(java.lang.Object instance)

      bean = instance;