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

import javax.annotation.security.PermitAll;
import javax.ejb.Remote;
import javax.ejb.Stateful;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.transaction.TransactionManager;
import org.jboss.annotation.JndiInject;
import org.jboss.logging.Logger;

/**
 * @version <tt>$Revision: 1.5.2.3 $</tt>
 * @author <a href="mailto:bdecoste@jboss.com">William DeCoste</a>
 */
@Stateful(name="Foo1")
@Remote(Foo.class)
public class FooBean1 implements Foo, java.io.Serializable
{
   private static final Logger log = Logger.getLogger(FooBean1.class);
   
   private boolean transactionExisted = false;
   
   private TransactionManager tm;
   
   @JndiInject(jndiName = "java:/TransactionManager")
   public void setTransactionManager(TransactionManager tm)
   {
      this.tm = tm;
   }
   
   @PermitAll
   @TransactionAttribute(TransactionAttributeType.REQUIRED)
   public void bar() throws Exception
   {
      transactionExisted = (tm.getTransaction() != null);
   }
   
   @PermitAll
   public boolean transactionExisted()
   {
      return transactionExisted;
   }
}