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

import javax.ejb.TransactionManagementType;
import org.jboss.logging.Logger;

/**
 * Represents a Session EJB element of the ejb-jar.xml deployment descriptor for
 * the 1.4 schema
 *
 * @author <a href="mailto:bdecoste@jboss.com">William DeCoste</a>
 * @version <tt>$Revision: 1.7.2.3 $</tt>
 */
public class SessionEnterpriseBean extends EnterpriseBean
{
   private static final Logger log = Logger
           .getLogger(SessionEnterpriseBean.class);

   public static final String STATELESS = "Stateless";

   public static final String STATEFUL = "Stateful";

   public static final String BEAN = "Bean";

   public static final String CONTAINER = "Container";

   // ejb-jar.xml
   private String sessionType = STATELESS;

   private String transactionType = CONTAINER;

   public boolean isStateless()
   {
      return sessionType.equals(STATELESS);
   }

   public boolean isStateful()
   {
      return sessionType.equals(STATEFUL);
   }

   public String getSessionType()
   {
      return sessionType;
   }

   public void setSessionType(String sessionType)
   {
      this.sessionType = sessionType;
   }

   public String getTransactionType()
   {
      return transactionType;
   }

   public void setTransactionType(String transactionType)
   {
      if (transactionType.equals(BEAN))
         tmType = TransactionManagementType.BEAN;
      else if (transactionType.equals(CONTAINER))
         tmType = TransactionManagementType.CONTAINER;
      this.transactionType = transactionType;
   }

   public String toString()
   {
      StringBuffer sb = new StringBuffer(100);
      sb.append('[');
      sb.append(super.toString());
      sb.append(",");
      sb.append("sessionType=").append(sessionType);
      sb.append(']');
      return sb.toString();
   }
}
