/*
 * 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 message-driven 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.2.2.3 $</tt>
 */
public class MessageDrivenBean extends EnterpriseBean
{
   private static final Logger log = Logger.getLogger(MessageDrivenBean.class);

   public static final String BEAN = "Bean";

   public static final String CONTAINER = "Container";

   // ejb-jar.xml
   private String acknowledgeMode;

   private String transactionType;

   private MessageDrivenDestination messageDrivenDestination;

   public MessageDrivenDestination getMessageDrivenDestination()
   {
      return messageDrivenDestination;
   }

   public void setMessageDrivenDestination(MessageDrivenDestination messageDrivenDestination)
   {
      this.messageDrivenDestination = messageDrivenDestination;
   }

   public String getAcknowledgeMode()
   {
      return acknowledgeMode;
   }

   public void setAcknowledgeMode(String acknowledgeMode)
   {
      this.acknowledgeMode = acknowledgeMode;
   }

   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("acknowledgeMode=").append(acknowledgeMode);
      sb.append(']');
      return sb.toString();
   }
}
