User: pra     
  Date: 01/08/24 02:56:23

  Modified:    src/main/org/jboss/metadata Tag: Branch_2_4
                        MessageDrivenMetaData.java
  Log:
  Merged in the setRollbackOnly bugfix for MDB, also added the log4j.jar into client, 
because JMS clients need that in classpath
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.7.4.1   +144 -126  jboss/src/main/org/jboss/metadata/MessageDrivenMetaData.java
  
  Index: MessageDrivenMetaData.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/metadata/MessageDrivenMetaData.java,v
  retrieving revision 1.7
  retrieving revision 1.7.4.1
  diff -u -r1.7 -r1.7.4.1
  --- MessageDrivenMetaData.java        2001/06/10 07:46:16     1.7
  +++ MessageDrivenMetaData.java        2001/08/24 09:56:23     1.7.4.1
  @@ -22,143 +22,161 @@
   ' *   @author <a href="mailto:[EMAIL PROTECTED]";>Sebastien Alborini</a>
    *   @author Peter Antman ([EMAIL PROTECTED])
   
  - *   @version $Revision: 1.7 $
  + *   @version $Revision: 1.7.4.1 $
    */
   public class MessageDrivenMetaData extends BeanMetaData {
  -    // Constants -----------------------------------------------------
  -    public static final int AUTO_ACKNOWLEDGE_MODE = Session.AUTO_ACKNOWLEDGE;
  -    public static final int DUPS_OK_ACKNOWLEDGE_MODE = Session.DUPS_OK_ACKNOWLEDGE;
  -    public static final int CLIENT_ACKNOWLEDGE_MODE = Session.CLIENT_ACKNOWLEDGE;
  -    public static final byte DURABLE_SUBSCRIPTION = 0;
  -    public static final byte NON_DURABLE_SUBSCRIPTION = 1;
  -    
  -    // Attributes ----------------------------------------------------
  -    private boolean containerManagedTx;
  -    private int acknowledgeMode = AUTO_ACKNOWLEDGE_MODE;
  -    private String destinationType;
  -    private byte subscriptionDurability = NON_DURABLE_SUBSCRIPTION;
  -    private String messageSelector = null;
  -    private String destinationJndiName;
  -    private String user = null;
  -    private String passwd = null;
  -    private String clientId = null;
  -
  -    // Static --------------------------------------------------------
  -    
  -    // Constructors --------------------------------------------------
  -    public MessageDrivenMetaData(ApplicationMetaData app) {
  -     super(app, BeanMetaData.MDB_TYPE);
  -     }
  +   // Constants -----------------------------------------------------
  +   public static final int AUTO_ACKNOWLEDGE_MODE = Session.AUTO_ACKNOWLEDGE;
  +   public static final int DUPS_OK_ACKNOWLEDGE_MODE = Session.DUPS_OK_ACKNOWLEDGE;
  +   public static final int CLIENT_ACKNOWLEDGE_MODE = Session.CLIENT_ACKNOWLEDGE;
  +   public static final byte DURABLE_SUBSCRIPTION = 0;
  +   public static final byte NON_DURABLE_SUBSCRIPTION = 1;
  +   public static final byte TX_UNSET = 9;
  +    
  +   // Attributes ----------------------------------------------------
  +   private boolean containerManagedTx;
  +   private int acknowledgeMode = AUTO_ACKNOWLEDGE_MODE;
  +   private String destinationType;
  +   private byte subscriptionDurability = NON_DURABLE_SUBSCRIPTION;
  +   private String messageSelector = null;
  +   private String destinationJndiName;
  +   private String user = null;
  +   private String passwd = null;
  +   private String clientId = null;
  +   private byte methodTransactionType= TX_UNSET;
  +
  +   // Static --------------------------------------------------------
  +    
  +   // Constructors --------------------------------------------------
  +   public MessageDrivenMetaData(ApplicationMetaData app) {
  +      super(app, BeanMetaData.MDB_TYPE);
  +   }
        
  -    // Public --------------------------------------------------------
  -    public boolean isContainerManagedTx() { return containerManagedTx; }
  -    public boolean isBeanManagedTx() { return !containerManagedTx; }
  -    /**
  -     * returns MessageDrivenMetaData.AUTO_ACKNOWLADGE_MODE or
  -     * MessageDrivenMetaData.DUPS_OK_AKNOWLEDGE_MODE
  -     */
  -    public int getAcknowledgeMode() {return acknowledgeMode;}
  -    public String getDestinationType() { return destinationType;}
  -    public String getMessageSelector() { return messageSelector;}
  -    public String getDestinationJndiName(){return destinationJndiName;}
  -    public String getUser() { return user;}
  -    public String getPasswd() {return passwd;}
  -    public String getClientId() {return clientId;}
  -    /**
  -     * returns MessageDrivenMetaData.DURABLE_SUBSCRIPTION or 
  -     * MessageDrivenMetaData.NON_DURABLE_SUBSCRIPTION
  -     */
  -    public byte getSubscriptionDurability() {return subscriptionDurability;}
  +   // Public --------------------------------------------------------
  +   public boolean isContainerManagedTx() { return containerManagedTx; }
  +   public boolean isBeanManagedTx() { return !containerManagedTx; }
  +
  +   /**
  +    * returns MessageDrivenMetaData.AUTO_ACKNOWLADGE_MODE or
  +    * MessageDrivenMetaData.DUPS_OK_AKNOWLEDGE_MODE, or 
MessageDrivenMetaData.CLIENT_ACKNOWLEDGE_MODE
  +    *
  +    */
  +   public int getAcknowledgeMode() {
  +      // My interpretation of the EJB and JMS spec leads
  +      // me to that CLIENT_ACK is the only possible
  +      // solution. A transaction is per session in JMS, and
  +      // it is not possible to get access to the transaction.
  +      // According to the JMS spec it is possible to 
  +      // multithread handling of messages (but not session),
  +      // but there is NO transaction support for this.
  +      // I,e, we can not use the JMS transaction for
  +      // message ack: hence we must use manual ack.
  +      
  +      // But for NOT_SUPPORTED this is not true here we 
  +      // should have AUTO_ACKNOWLEDGE_MODE
  +      
  +      // This is not true for now. For JBossMQ we relly 
  +      // completely on transaction handling. For JBossMQ, the
  +      // ackmode is actually not relevant. We keep it here
  +      // anyway, if we find that this is needed for other
  +      // JMS provider, or is not good.
  +      if ( getMethodTransactionType() == TX_REQUIRED)
  +      return  CLIENT_ACKNOWLEDGE_MODE;
  +      else 
  +      return acknowledgeMode;
  +   }
  +
  +   public String getDestinationType() { return destinationType;}
  +   public String getMessageSelector() { return messageSelector;}
  +   public String getDestinationJndiName(){return destinationJndiName;}
  +   public String getUser() { return user;}
  +   public String getPasswd() {return passwd;}
  +   public String getClientId() {return clientId;}
  +   public byte getMethodTransactionType() {
  +      if (methodTransactionType == TX_UNSET) {
  +      if (isContainerManagedTx()) {
  +         //
  +         // Here we should have a way of looking up wich message class
  +         // the MessageDriven bean implements, by doing this we might
  +         // be able to use other MOM systems, aka XmlBlaser. TODO!
  +         // The MessageDrivenContainer needs this too!!
  +         //
  +         if(super.getMethodTransactionType("onMessage", new Class[] {}, true) == 
MetaData.TX_REQUIRED) {
  +            methodTransactionType = TX_REQUIRED;
  +         } else {
  +            methodTransactionType = TX_NOT_SUPPORTED;
  +         }
  +      } else {
  +         methodTransactionType = TX_UNKNOWN;
  +      }
  +      }
  +      return methodTransactionType;
  +   }
  +
  +   public byte getMethodTransactionType(String methodName, Class[] params, boolean 
remote) {
  +      // An MDB may only ever have on method
  +      return getMethodTransactionType();
  +   }
  +   /**
  +    * returns MessageDrivenMetaData.DURABLE_SUBSCRIPTION or 
  +    * MessageDrivenMetaData.NON_DURABLE_SUBSCRIPTION
  +    */
  +   public byte getSubscriptionDurability() {return subscriptionDurability;}
       
  -    public String getDefaultConfigurationName() {
  -     return jdk13Enabled() ? ConfigurationMetaData.MESSAGE_DRIVEN_13 : 
ConfigurationMetaData.MESSAGE_DRIVEN_12;
  +   public String getDefaultConfigurationName() {
  +      return jdk13Enabled() ? ConfigurationMetaData.MESSAGE_DRIVEN_13 : 
ConfigurationMetaData.MESSAGE_DRIVEN_12;
   
  -    }
  +   }
        
  -     public void importEjbJarXml(Element element) throws DeploymentException {
  -             super.importEjbJarXml(element);
  +   public void importEjbJarXml(Element element) throws DeploymentException {
  +      super.importEjbJarXml(element);
                
  -             messageSelector = getElementContent(getOptionalChild(element, 
"message-selector"));
  +      messageSelector = getElementContent(getOptionalChild(element, 
"message-selector"));
   
  -             // set 
  -             Element destination = getUniqueChild(element, 
"message-driven-destination");
  -             destinationType = getElementContent(getUniqueChild(destination
  -, "destination-type"));
  +      // set 
  +      Element destination = getUniqueChild(element, "message-driven-destination");
  +      destinationType = getElementContent(getUniqueChild(destination
  +                                                      , "destination-type"));
                 
  -             if (destinationType.equals("javax.jms.Topic")) {
  -                     String subscr = getElementContent(getUniqueChild(destination, 
"subscription-durability"));
  -                     // Should we do sanity check??
  -                     if (subscr.equals("Durable"))
  -                         subscriptionDurability = DURABLE_SUBSCRIPTION;
  -                     else
  -                         subscriptionDurability = NON_DURABLE_SUBSCRIPTION;//Default
  -             }
  -             /* Skipp check of dest type, for flexibility
  -             } else if (destinationType.equals("javax.jms.Queue")) {
  -                     //Noop
  -             } else {
  -                     throw new DeploymentException("session type should be 
'Stateful' or 'Stateless'");
  -             }
  -             */
  -             // set the transaction type
  -             String transactionType = getElementContent(getUniqueChild(element, 
"transaction-type"));
  -             if (transactionType.equals("Bean")) {
  -                     containerManagedTx = false;
  -                     String ack = getElementContent(getUniqueChild(element, 
"acknowledge-mode"));
  -                     if ( ack.equals("Auto-acknowledge") || 
ack.equals("AUTO_ACKNOWLEDGE"))
  -                         acknowledgeMode = AUTO_ACKNOWLEDGE_MODE;
  -                     else
  -                         acknowledgeMode = DUPS_OK_ACKNOWLEDGE_MODE;
  -                     // else defaults to AUTO
  -             } else if (transactionType.equals("Container")) {
  -                     containerManagedTx = true;
  -                     /* My interpretation of the EJB and JMS spec leads
  -                        me to that CLIENT_ACK is the only possible
  -                        solution. A transaction is per session in JMS, and
  -                        it is not possible to get access to the transaction.
  -                        According to the JMS spec it is possible to 
  -                        multithread handling of messages (but not session),
  -                        but there is NO transaction support for this.
  -                        I,e, we can not use the JMS transaction for
  -                        message ack: hence we must use manual ack.
  -
  -                        But for NOT_SUPPORTED this is not true here we 
  -                        should have AUTO_ACKNOWLEDGE_MODE
  -
  -                        This is not true for now. For JBossMQ we relly 
  -                        completely on transaction handling. For JBossMQ, the
  -                        ackmode is actually not relevant. We keep it here
  -                        anyway, if we find that this is needed for other
  -                        JMS provider, or is not good.
  -                        
  -                     */
  -
  -                     /*
  -                      * Here we should have a way of looking up wich message class
  -                      * the MessageDriven bean implements, by doing this we might
  -                      * be able to use other MOM systems, aka XmlBlaser. TODO!
  -                      * The MessageDrivenContainer needs this too!!
  -                      */
  -                     if(getMethodTransactionType("onMessage", new Class[] {}, true) 
== MetaData.TX_REQUIRED)
  -                         acknowledgeMode = CLIENT_ACKNOWLEDGE_MODE;
  -             } else {
  -                 throw new DeploymentException("transaction type should be 'Bean' 
or 'Container'");
  -             }
  -     }
  -    public void importJbossXml(Element element) throws DeploymentException {
  +      if (destinationType.equals("javax.jms.Topic")) {
  +      String subscr = getElementContent(getUniqueChild(destination, 
"subscription-durability"));
  +      // Should we do sanity check??
  +      if (subscr.equals("Durable"))
  +         subscriptionDurability = DURABLE_SUBSCRIPTION;
  +      else
  +         subscriptionDurability = NON_DURABLE_SUBSCRIPTION;//Default
  +      }
  +
  +      // set the transaction type
  +      String transactionType = getElementContent(getUniqueChild(element, 
"transaction-type"));
  +      if (transactionType.equals("Bean")) {
  +      containerManagedTx = false;
  +      String ack = getElementContent(getUniqueChild(element, "acknowledge-mode"));
  +      if ( ack.equals("Auto-acknowledge") || ack.equals("AUTO_ACKNOWLEDGE"))
  +         acknowledgeMode = AUTO_ACKNOWLEDGE_MODE;
  +      else
  +         acknowledgeMode = DUPS_OK_ACKNOWLEDGE_MODE;
  +      // else defaults to AUTO
  +      } else if (transactionType.equals("Container")) {
  +      containerManagedTx = true;
  +      } else {
  +      throw new DeploymentException("transaction type should be 'Bean' or 
'Container'");
  +      }
  +   }
  +   public void importJbossXml(Element element) throws DeploymentException {
        
  -     super.importJbossXml(element);
  -     // set the jndi name, (optional)                
  -     destinationJndiName = getElementContent(getUniqueChild(element, 
"destination-jndi-name"));
  -     user = getElementContent(getOptionalChild(element,"mdb-user"));
  -     passwd = getElementContent(getOptionalChild(element,"mdb-passwd"));
  -     clientId = getElementContent(getOptionalChild(element,"mdb-client-id"));
  -    }        
  -    // Package protected ---------------------------------------------
  +      super.importJbossXml(element);
  +      // set the jndi name, (optional)               
  +      destinationJndiName = getElementContent(getUniqueChild(element, 
"destination-jndi-name"));
  +      user = getElementContent(getOptionalChild(element,"mdb-user"));
  +      passwd = getElementContent(getOptionalChild(element,"mdb-passwd"));
  +      clientId = getElementContent(getOptionalChild(element,"mdb-client-id"));
  +   } 
  +   // Package protected ---------------------------------------------
       
  -    // Protected -----------------------------------------------------
  +   // Protected -----------------------------------------------------
       
  -    // Private -------------------------------------------------------
  +   // Private -------------------------------------------------------
       
  -    // Inner classes -------------------------------------------------
  +   // Inner classes -------------------------------------------------
   }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to