/*
 * Copyright 1999 by dreamBean Software,
 * All rights reserved.
 */
package org.jboss.ejb3.test.exception;

import javax.annotation.Resource;
import javax.ejb.Remote;
import javax.ejb.SessionContext;
import javax.ejb.Stateful;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.jboss.logging.Logger;

/**
 * @version <tt>$Revision: 1.3.2.4 $</tt>
 * @author <a href="mailto:bdecoste@jboss.com">William DeCoste</a>
 */
@Stateful
@TransactionManagement(TransactionManagementType.CONTAINER)
@Remote(Foo1.class)
public class FooBean1 implements Foo1, java.io.Serializable
{
   private static final Logger log = Logger.getLogger(FooBean1.class);
   
   private String status = "init";

   @Resource
   private SessionContext ctx;

   public void bar() throws FooException1
   {
      try
      {
         InitialContext jndiContext = new InitialContext();
         Foo2 foo2 = (Foo2) jndiContext.lookup(Foo2.class.getName());
         foo2.bar();
      } catch (NamingException e)
      {
         throw new FooException1(e.getMessage());
      } catch (FooException2 e)
      {
         status = "Caught FooException1";
         throw new FooException1(e.getMessage());
      } 
   }
   
   public String getStatus()
   {
      return status;
   }

}