/*
 * JBoss, the OpenSource J2EE webOS
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package org.jboss.ejb3.mdb;

import java.util.Hashtable;
import javax.ejb.TimerService;
import javax.management.ObjectName;
import javax.naming.InitialContext;
import javax.naming.Context;
import org.jboss.aop.AspectManager;
import org.jboss.ejb3.Container;
import org.jboss.ejb3.EjbLinkResolver;
import org.jboss.ejb3.Pool;
import org.jboss.ejb3.entity.ManagedEntityManagerFactory;
import org.jboss.ejb3.security.JaccHelper;
import org.jboss.system.ServiceMBeanSupport;

/**
 * Comment
 *
 * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
 * @version $Revision: 1.6.2.4 $
 */
public class ConsumerManager extends ServiceMBeanSupport implements ConsumerManagerMBean, Container
{
   protected ConsumerContainer container;
   protected String jaccContextId;

   public ConsumerManager(ClassLoader cl, String beanClassName, String ejbName, AspectManager manager, String jaccContextId, Hashtable ctxProperties)
   {
      container = new ConsumerContainer(ejbName, manager, cl, beanClassName, ctxProperties);
      this.jaccContextId = jaccContextId;
   }

   public Context getEnc()
   {
      return container.getEnc();
   }

   public InitialContext getInitialContext()
   {
      return container.getInitialContext();
   }

   public Hashtable getInitialContextProperties()
   {
      return container.getInitialContextProperties();
   }

   public Container getInstance()
   {
      return container;
   }

   public EjbLinkResolver getEjbLinkResolver()
   {
      return container.getEjbLinkResolver();
   }

   public void setEjbLinkResolver(EjbLinkResolver ejbLinkResolver)
   {
      container.setEjbLinkResolver(ejbLinkResolver);
   }

   public ManagedEntityManagerFactory getManagedEntityManagerFactory()
   {
      return container.getManagedEntityManagerFactory();
   }

   public void setManagedEntityManagerFactory(ManagedEntityManagerFactory factory)
   {
      container.setManagedEntityManagerFactory(factory);
   }

   public void createService() throws Exception
   {
      container.create();
      JaccHelper.configureContainer(jaccContextId, container);
   }

   public void startService() throws Exception
   {
      container.start();
   }

   public void stopService() throws Exception
   {
      container.stop();
   }

   public void destroyService() throws Exception
   {
      container.destroy();
   }

   public Class getBeanClass()
   {
      return container.getBeanClass();
   }

   public String getEjbName()
   {
      return container.getEjbName();
   }

   public ObjectName getObjectName()
   {
      return container.getObjectName();
   }

   public TimerService getTimerService()
   {
      return container.getTimerService();
   }

   public Pool getPool()
   {
      return container.getPool();
   }

   public void invokePostConstruct(Object bean)
   {
      container.invokePostConstruct(bean);
   }

   public void invokePreDestroy(Object bean)
   {
      container.invokePreDestroy(bean);
   }

   public void invokePostActivate(Object bean)
   {
      container.invokePostActivate(bean);
   }

   public void invokePrePassivate(Object bean)
   {
      container.invokePrePassivate(bean);
   }

   public void invokeInit(Object bean)
   {
      container.invokeInit(bean);
   }

   public void invokeInit(Object bean, Class[] initParameterTypes, Object[] initParameterValues)
   {
      container.invokeInit(bean, initParameterTypes, initParameterValues);
   }

   public Object construct()
   {
      return container.construct();
   }

}
