commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jelly/jelly-tags/jms maven.xml project.xml project.properties .cvsignore
Date Tue, 07 Jan 2003 16:11:19 GMT
dion        2003/01/07 08:11:19

  Added:       jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms
                        ConnectionTag.java PropertyTag.java ReceiveTag.java
                        JMSTagLibrary.java package.html TextMessageTag.java
                        ConnectionContext.java MessageOperationTag.java
                        MapEntryTag.java DestinationTag.java
                        MapMessageTag.java StopwatchTag.java
                        ObjectMessageTag.java SendTag.java
                        SubscribeTag.java MessageTag.java ConsumerTag.java
                        OnMessageTag.java
               jelly/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms
                        sendMessage.jelly flushQueue.jelly sendMap.jelly
                        sendObject.jelly receiveMap.jelly
                        receiveObject.jelly sendText.jelly receive.jelly
               jelly/jelly-tags/jms maven.xml project.xml
                        project.properties .cvsignore
  Log:
  Move jms out of core
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/ConnectionTag.java
  
  Index: ConnectionTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/ConnectionTag.java,v 1.1 2003/01/07 16:11:00 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 16:11:00 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: ConnectionTag.java,v 1.1 2003/01/07 16:11:00 dion Exp $
   */
  package org.apache.commons.jelly.tags.jms;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.messenger.Messenger;
  import org.apache.commons.messenger.MessengerManager;
  
  /** Defines a JMS connection for use by other JMS tags.
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class ConnectionTag extends TagSupport implements ConnectionContext {
  
      /** The variable name to create */
      private String var;
          
      /** Stores the name of the map entry */
      private String name;
  
      /** The Messenger */
      private Messenger connection;
  
      // ConnectionContext interface
      //-------------------------------------------------------------------------                    
      public Messenger getConnection() {
          return connection;        
      }
      
      // Tag interface
      //-------------------------------------------------------------------------                    
      public void doTag(XMLOutput output) throws Exception {        
          connection = MessengerManager.get( name );
  
          if (connection == null) {        
              throw new JellyException( "Could not find a JMS connection called: " + name );
          }
  
          if ( var != null ) {
              context.setVariable( var, connection );
          }
          
          invokeBody(output);
      }
      
      // Properties
      //-------------------------------------------------------------------------                    
      
      /** Sets the name of the Messenger (JMS connection pool) to use
        */
      public void setName(String name) {
          this.name = name;
      }
      
      /** Sets the variable name to use for the exported Messenger (JMS connection pool)
        */
      public void setVar(String var) {
          this.var = var;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/PropertyTag.java
  
  Index: PropertyTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/PropertyTag.java,v 1.1 2003/01/07 16:11:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 16:11:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: PropertyTag.java,v 1.1 2003/01/07 16:11:01 dion Exp $
   */
  
  package org.apache.commons.jelly.tags.jms;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.MissingAttributeException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  /** Defines a property on an outer JMS Message tag
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class PropertyTag extends TagSupport {
  
      /** Stores the name of the property */
      private String name;
      
      /** Stores the value of the property */
      private Object value;
      
      
      // Tag interface
      //-------------------------------------------------------------------------                    
      public void doTag(XMLOutput output) throws Exception {
          if ( name == null ) {
              throw new MissingAttributeException("name");
          }
          MessageTag tag = (MessageTag) findAncestorWithClass( MessageTag.class );
          if ( tag == null ) {
              throw new JellyException("<jms:property> tag must be within a <jms:message> tag");
          }
          
          if ( value != null ) {
              tag.addProperty(name, value);
          }
          else {
              tag.addProperty(name, getBodyText());
          }
      }
  
      
      // Properties
      //-------------------------------------------------------------------------                    
      /** Sets the name of the JMS property
        */
      public void setName(String name) {
          this.name = name;
      }
      
      /** Sets the value of the JMS property. 
        * If no value is set then the body of the tag is used
        */
      public void setValue(Object value) {
          this.value = value;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/ReceiveTag.java
  
  Index: ReceiveTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/ReceiveTag.java,v 1.1 2003/01/07 16:11:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 16:11:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: ReceiveTag.java,v 1.1 2003/01/07 16:11:01 dion Exp $
   */
  package org.apache.commons.jelly.tags.jms;
  
  import javax.jms.Destination;
  import javax.jms.Message;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /** Receives a JMS message.
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class ReceiveTag extends MessageOperationTag {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(ReceiveTag.class);
  
      private String var;
      private long timeout = -1L;
      
      public ReceiveTag() {
      }
      
      // Tag interface
      //-------------------------------------------------------------------------                    
      public void doTag(XMLOutput output) throws Exception {
          // evaluate body as it may contain a <destination> tag
          invokeBody(output);
          
          Destination destination = getDestination();
          if ( destination == null ) {
              throw new JellyException( "No destination specified. Either specify a 'destination' attribute or use a nested <jms:destination> tag" );
          }
          Message message = null;
          if ( timeout > 0 ) {
              if ( log.isDebugEnabled() ) {
                  log.debug( "Receiving message on destination: " + destination + " with timeout: " + timeout );
              }
              
              message = getConnection().receive( destination, timeout );
          }
          else if ( timeout == 0 ) {
              if ( log.isDebugEnabled() ) {
                  log.debug( "Receiving message on destination: " + destination + " with No Wait" );
              }
              
              message = getConnection().receiveNoWait( destination );
          }
          else {
              if ( log.isDebugEnabled() ) {
                  log.debug( "Receiving message on destination: " + destination );
              }
              message = getConnection().receive( destination );
          }
          onMessage( message );
      }
      
      // Properties
      //-------------------------------------------------------------------------                                
      public String getVar() {
          return var;
      }
      
      /**
       * Sets the variable name to create for the received message, which will be null if no
       * message could be returned in the given time period.
       */
      public void setVar(String var) {
          this.var = var;
      }    
      
      public long getTimeout() {
          return timeout;
      }
  
      /**
       * Sets the timeout period in milliseconds to wait for a message. A value
       * of -1 will wait forever for a message.
       */    
      public void setTimeout(long timeout) {
          this.timeout = timeout;
      }
      
      // Implementation methods
      //-------------------------------------------------------------------------                            
      
      /** 
       * A strategy method which processes the incoming message, allowing derived classes
       * to implement different processing methods
       */
      protected void onMessage( Message message ) {
          if ( message != null ) {
              context.setVariable( var, message );
          }
          else {
              context.removeVariable( var );
          }
      }
  }    
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/JMSTagLibrary.java
  
  Index: JMSTagLibrary.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/JMSTagLibrary.java,v 1.1 2003/01/07 16:11:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 16:11:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: JMSTagLibrary.java,v 1.1 2003/01/07 16:11:01 dion Exp $
   */
  package org.apache.commons.jelly.tags.jms;
  
  import org.apache.commons.jelly.TagLibrary;
  
  /** Describes the Taglib. This class could be generated by XDoclet
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class JMSTagLibrary extends TagLibrary {
  
      public JMSTagLibrary() {
          registerTag("connection", ConnectionTag.class);
          registerTag("destination", DestinationTag.class);
          registerTag("mapEntry", MapEntryTag.class);
          registerTag("mapMessage", MapMessageTag.class);
          registerTag("message", MessageTag.class);
          registerTag("onMessage", OnMessageTag.class);
          registerTag("objectMessage", ObjectMessageTag.class);
          registerTag("property", PropertyTag.class);
          registerTag("receive", ReceiveTag.class);
          registerTag("send", SendTag.class);
          registerTag("stopwatch", StopwatchTag.class);
          registerTag("subscribe", SubscribeTag.class);
          registerTag("textMessage", TextMessageTag.class);
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/package.html
  
  Index: package.html
  ===================================================================
  <html>
  <head>
  </head>
  <body>
  
    <p>A tag library for working with JMS using the 
    <a href="http://jakarta.apache.org/commons/sandbox/messenger/">Messenger</a> project
    </p>
  </body>
  </html>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/TextMessageTag.java
  
  Index: TextMessageTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/TextMessageTag.java,v 1.1 2003/01/07 16:11:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 16:11:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: TextMessageTag.java,v 1.1 2003/01/07 16:11:01 dion Exp $
   */
  package org.apache.commons.jelly.tags.jms;
  
  import javax.jms.Message;
  
  /** Creates a JMS TextMessage
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class TextMessageTag extends MessageTag {
  
      private String text;
      
      public TextMessageTag() {
      }
      
      // Properties
      //-------------------------------------------------------------------------                                
      
      /**
       * Sets the body of the message, a String. If this value is not set or
       * the value is null then the content of the tag will be used instead.
       */
      public void setText(String text) {
          this.text = text;
      }
      
      
      // Implementation methods
      //-------------------------------------------------------------------------                            
      protected Message createMessage() throws Exception {
          String value = (text != null) ? text : getBodyText();
          return getConnection().createTextMessage(value);
      }    
  }    
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/ConnectionContext.java
  
  Index: ConnectionContext.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/ConnectionContext.java,v 1.1 2003/01/07 16:11:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 16:11:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: ConnectionContext.java,v 1.1 2003/01/07 16:11:01 dion Exp $
   */
  package org.apache.commons.jelly.tags.jms;
  
  import javax.jms.JMSException;
  
  import org.apache.commons.jelly.JellyException;
  
  import org.apache.commons.messenger.Messenger;
  
  /** Represents a context capable of providing a Messenger connection to use
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public interface ConnectionContext {
  
      public Messenger getConnection() throws JellyException, JMSException;
  }    
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/MessageOperationTag.java
  
  Index: MessageOperationTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/MessageOperationTag.java,v 1.1 2003/01/07 16:11:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 16:11:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: MessageOperationTag.java,v 1.1 2003/01/07 16:11:01 dion Exp $
   */
  package org.apache.commons.jelly.tags.jms;
  
  import javax.jms.Destination;
  import javax.jms.JMSException;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.messenger.Messenger;
  
  /** An abstract base class for JMS Message operation tags such as send, receive or call.
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public abstract class MessageOperationTag extends TagSupport implements ConnectionContext {
  
      /** The Messenger used to access the JMS connection */
      private Messenger connection;
      
      /** The Destination */
      private Destination destination;
  
      /** The String subject used to find a destination */
      private String subject;
      
      public MessageOperationTag() {
      }
      
      // Properties
      //-------------------------------------------------------------------------                                
      public Messenger getConnection() throws JellyException, JMSException {
          if ( connection == null ) {
              return findConnection();
          }
          return connection;
      }
      
      /**
       * Sets the Messenger (the JMS connection pool) that will be used to send the message
       */
      public void setConnection(Messenger connection) {
          this.connection = connection;
      }
      
      public Destination getDestination() throws JellyException, JMSException {
          if (destination == null) {
              // if we have a subject defined, lets use it to find the destination
              if (subject != null) {
                  destination = findDestination(subject);
              }
          }
          return destination;
      }
      
      /**
       * Sets the JMS Destination to be used by this tag
       */
      public void setDestination(Destination destination) {
          this.destination = destination;
      }
  
      /**
       * Sets the subject as a String which is used to create the 
       * JMS Destination to be used by this tag
       */
      public void setSubject(String subject) {
          this.subject = subject;
      }
  
      // Implementation methods
      //-------------------------------------------------------------------------                            
      
      /**
       * Strategy Method allowing derived classes to change this behaviour
       */
      protected Messenger findConnection() throws JellyException, JMSException {
          ConnectionContext messengerTag = (ConnectionContext) findAncestorWithClass( ConnectionContext.class );
          if ( messengerTag == null ) {
              throw new JellyException("This tag must be within a <jms:connection> tag or the 'connection' attribute should be specified");
          }
          return messengerTag.getConnection();
      }
  
      /**
       * Strategy Method allowing derived classes to change this behaviour
       */
      protected Destination findDestination(String subject) throws JellyException, JMSException {
          return getConnection().getDestination(subject);
      }
  }    
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/MapEntryTag.java
  
  Index: MapEntryTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/MapEntryTag.java,v 1.1 2003/01/07 16:11:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 16:11:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: MapEntryTag.java,v 1.1 2003/01/07 16:11:01 dion Exp $
   */
  package org.apache.commons.jelly.tags.jms;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.MissingAttributeException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  /** Adds a map entry to the outer Map Message tag
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class MapEntryTag extends TagSupport {
  
      /** Stores the name of the map entry */
      private String name;
      
      /** Stores the value of the map entry */
      private Object value;
      
      
      // Tag interface
      //-------------------------------------------------------------------------                    
      public void doTag(XMLOutput output) throws Exception {        
          if ( name == null ) {
              throw new MissingAttributeException("name");
          }
          MapMessageTag tag = (MapMessageTag) findAncestorWithClass( MapMessageTag.class );
          if ( tag == null ) {
              throw new JellyException("<jms:mapEntry> tag must be within a <jms:mapMessage> tag");
          }
          if (value != null) {
              tag.addEntry( name, value );
          }
          else {
              tag.addEntry( name, getBodyText() );
          }
      }
      
      // Properties
      //-------------------------------------------------------------------------                    
      /** Sets the name of the entry in the map message
        */
      public void setName(String name) {
          this.name = name;
      }
      
      /** Sets the value of the entry in the map message.
        * If no value is set then the body of the tag is used
        */
      public void setValue(Object value) {
          this.value = value;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/DestinationTag.java
  
  Index: DestinationTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/DestinationTag.java,v 1.1 2003/01/07 16:11:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 16:11:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: DestinationTag.java,v 1.1 2003/01/07 16:11:01 dion Exp $
   */
  package org.apache.commons.jelly.tags.jms;
  
  import javax.jms.Destination;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.messenger.Messenger;
  
  /** Creates a Destination object from a String name.
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class DestinationTag extends TagSupport {
  
      /** The variable name to create */
      private String var;
          
      /** Stores the name of the map entry */
      private String name;
          
      // Tag interface
      //-------------------------------------------------------------------------                    
      public void doTag(XMLOutput output) throws Exception {        
          ConnectionContext messengerTag = (ConnectionContext) findAncestorWithClass( ConnectionContext.class );
          if ( messengerTag == null ) {
              throw new JellyException("<jms:destination> tag must be within a <jms:connection> or <jms:send> or <jms:receive> tag");
          }
          Messenger messenger = messengerTag.getConnection();
          if (messenger == null) {
              throw new JellyException("No JMS Connection could be found!" );            
          }
          String subject = (name != null) ? name : getBodyText();
          Destination destination = messenger.getDestination( subject );
          if ( var != null ) {
              context.setVariable( var, destination );
          }
          else {
              MessageOperationTag tag = (MessageOperationTag) findAncestorWithClass( MessageOperationTag.class );
              if ( tag == null ) {
                  throw new JellyException("<jms:destination> tag must be within a <jms:send> or <jms:receive> tag or the 'var' attribute should be specified");
              }
              tag.setDestination( destination );
          }
      }
      
      
      // Properties
      //-------------------------------------------------------------------------                    
      
      /** Sets the name of the Destination
        */
      public void setName(String name) {
          this.name = name;
      }
      
      /** Sets the variable name to use for the Destination
        */
      public void setVar(String var) {
          this.var = var;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/MapMessageTag.java
  
  Index: MapMessageTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/MapMessageTag.java,v 1.1 2003/01/07 16:11:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 16:11:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: MapMessageTag.java,v 1.1 2003/01/07 16:11:01 dion Exp $
   */
  package org.apache.commons.jelly.tags.jms;
  
  import java.util.Iterator;
  import java.util.Map;
  
  import javax.jms.Message;
  import javax.jms.MapMessage;
  
  /** Creates a JMS MapMessage
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class MapMessageTag extends MessageTag {
  
      public MapMessageTag() {
      }
  
      public void addEntry(String name, Object value) throws Exception {
          MapMessage message = (MapMessage) getMessage();
          message.setObject(name, value);
      }
      
      // Properties
      //-------------------------------------------------------------------------                                
      
      /**
       * Sets the Map of entries to be used for this Map Message
       */
      public void setMap(Map map) throws Exception {
          MapMessage message = (MapMessage) getMessage();
          for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
              Map.Entry entry = (Map.Entry) iter.next();
              String name = entry.getKey().toString();
              Object value = entry.getValue();
              message.setObject(name, value);
          }
      }
      
      // Implementation methods
      //-------------------------------------------------------------------------                            
      protected Message createMessage() throws Exception {
          return getConnection().createMapMessage();
      }    
  }    
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/StopwatchTag.java
  
  Index: StopwatchTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/StopwatchTag.java,v 1.1 2003/01/07 16:11:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 16:11:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: StopwatchTag.java,v 1.1 2003/01/07 16:11:01 dion Exp $
   */
  package org.apache.commons.jelly.tags.jms;
  
  import javax.jms.MessageListener;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  import org.apache.commons.messenger.tool.StopWatchMessageListener;
  
  /** 
   * This tag can be used to measure the amount of time it takes to process JMS messages.
   * This tag can be wrapped around any custom JMS tag which consumes JMS messages.
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public class StopwatchTag extends MessageOperationTag implements ConsumerTag {
  
      /** the underlying MessageListener */
      private MessageListener messageListener;
          
      /** The Log to which logging calls will be made. */
      private Log log = LogFactory.getLog( StopwatchTag.class );
      
      /** the message group size */
      private int groupSize = 1000;
  
      public StopwatchTag() {
      }
      
      // Tag interface
      //-------------------------------------------------------------------------                    
      public void doTag(XMLOutput output) throws Exception {
  
          // evaluate body as it may contain child tags to register a MessageListener
          invokeBody(output);
          
          MessageListener listener = getMessageListener();
  
  		ConsumerTag tag = (ConsumerTag) findAncestorWithClass(ConsumerTag.class);
  		if (tag == null) {
  			throw new JellyException("This tag must be nested within a ConsumerTag like the subscribe tag");
  		}			
  
          // clear the listener for the next tag invocation, if caching is employed
          setMessageListener(null);
  
  		StopWatchMessageListener stopWatch = new StopWatchMessageListener(listener);
  		stopWatch.setGroupSize(groupSize);
  		stopWatch.setLog(log);
  
  		// perform the consumption
  		tag.setMessageListener(stopWatch);		
      }
      
      // Properties
      //-------------------------------------------------------------------------   
  
      /**
       * @return the number of messages in the group before the performance statistics are logged
       */
      public int getGroupSize() {
          return groupSize;
      }    
          
      /**
       * Sets the number of messages in the group before the performance statistics are logged
       */
      public void setGroupSize(int groupSize) {
          this.groupSize = groupSize;
      }    
      
      
      /**
       * @return the logger to which statistic messages will be sent
       */
      public Log getLog() {
          return log;
      }
      
      /**
       * Sets the logger to which statistic messages will be sent
       */
      public void setLog(Log log) {
          this.log = log;
      }
          
      /**
       * @return the MessageListener which this listener delegates to
       */
      public MessageListener getMessageListener() {
          return messageListener;    
      }
      
      /**
       * Sets the JMS messageListener used to consume JMS messages on the given destination
       */
      public void setMessageListener(MessageListener messageListener) {
          this.messageListener = messageListener;
      }
  
  }    
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/ObjectMessageTag.java
  
  Index: ObjectMessageTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/ObjectMessageTag.java,v 1.1 2003/01/07 16:11:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 16:11:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: ObjectMessageTag.java,v 1.1 2003/01/07 16:11:01 dion Exp $
   */
  package org.apache.commons.jelly.tags.jms;
  
  import java.io.Serializable;
  
  import javax.jms.Message;
  
  /** Creates a JMS ObjectMessage
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class ObjectMessageTag extends MessageTag {
  
      private Serializable object;
      
      public ObjectMessageTag() {
      }
      
      // Properties
      //-------------------------------------------------------------------------                                
      
      /**
       * Sets the body of the message, a serializable java object.
       * If this value is not set or the value is null then the content 
       * of the tag will be used instead.
       */
      public void setObject(Serializable object) {
          this.object = object;
      }
      
      // Implementation methods
      //-------------------------------------------------------------------------                            
      protected Message createMessage() throws Exception {
          Serializable value = (object != null) ? object : getBodyText();
          return getConnection().createObjectMessage(value);
      }    
  }    
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/SendTag.java
  
  Index: SendTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/SendTag.java,v 1.1 2003/01/07 16:11:03 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 16:11:03 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: SendTag.java,v 1.1 2003/01/07 16:11:03 dion Exp $
   */
  package org.apache.commons.jelly.tags.jms;
  
  import javax.jms.Destination;
  import javax.jms.Message;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.XMLOutput;
  
  /** Sends a JMS message to some destination.
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class SendTag extends MessageOperationTag {
  
      /** The JMS Message to be sent */
      private Message message;
      
      public SendTag() {
      }
          
      // Tag interface
      //-------------------------------------------------------------------------                    
      public void doTag(XMLOutput output) throws Exception {
          // evaluate body as it may contain a <destination> or message tag
          invokeBody(output);
          
          Message message = getMessage();
          if ( message == null ) {
              throw new JellyException( "No message specified. Either specify a 'message' attribute or use a nested <jms:message> tag" );
          }
          Destination destination = getDestination();
          if ( destination == null ) {
              throw new JellyException( "No destination specified. Either specify a 'destination' attribute or use a nested <jms:destination> tag" );
          }
          getConnection().send( destination, message );
      }
      
      // Properties
      //-------------------------------------------------------------------------                            
      public Message getMessage() {
          return message;
      }
  
      /**
       * Sets the JMS message to be sent 
       */    
      public void setMessage(Message message) {
          this.message = message;
      }
  }    
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/SubscribeTag.java
  
  Index: SubscribeTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/SubscribeTag.java,v 1.1 2003/01/07 16:11:03 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 16:11:03 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: SubscribeTag.java,v 1.1 2003/01/07 16:11:03 dion Exp $
   */
  package org.apache.commons.jelly.tags.jms;
  
  import javax.jms.Destination;
  import javax.jms.MessageListener;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /** 
   * Performs a subscription to some JMS connection to a destination maybe with a selector.
   * A JMS MessageListener can be specified, or a special child tag can explicitly set it on 
   * its parent (so a special tag could construct a MessageListener object and register it with this tag).
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public class SubscribeTag extends MessageOperationTag implements ConsumerTag {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(SubscribeTag.class);
  
      /** the JMS Selector for the subscription */
      private String selector;
      
      /** The JMS MessageListener used to create the subscription */
      private MessageListener messageListener;
      
      public SubscribeTag() {
      }
      
      // Tag interface
      //-------------------------------------------------------------------------                    
      public void doTag(XMLOutput output) throws Exception {
  
          // evaluate body as it may contain child tags to register a MessageListener
          invokeBody(output);
          
          MessageListener listener = getMessageListener();
          if (listener == null) {
              throw new JellyException( "No messageListener attribute is specified so could not subscribe" );
          }
  
          // clear the listener for the next tag invocation, if caching is employed
          setMessageListener(null);
  
          
          Destination destination = getDestination();
          if ( destination == null ) {
              throw new JellyException( "No destination specified. Either specify a 'destination' attribute or use a nested <jms:destination> tag" );
          }
          
          if ( log.isDebugEnabled() ) {
              log.debug( "About to consume to: " + destination + " with listener: " + listener );
          }
              
          log.info( "About to consume to: " + destination + " with listener: " + listener );
              
          if (selector == null ) {            
              getConnection().addListener( destination, listener );
          }
          else {
              getConnection().addListener( destination, selector, listener );
          }
      }
      
      // Properties
      //-------------------------------------------------------------------------   
      
      /**
       * Sets the optional JMS Message selector for the subscription
       */
      public void setSelector(String selector) {
          this.selector = selector;
      }                             
      
  
      /**
       * Returns the messageListener.
       * @return MessageListener
       */
      public MessageListener getMessageListener() {
          return messageListener;
      }
  
      
      /**
       * Sets the JMS messageListener used ot consume JMS messages on the given destination
       */
      public void setMessageListener(MessageListener messageListener) {
          this.messageListener = messageListener;
      }
  
  }    
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/MessageTag.java
  
  Index: MessageTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/MessageTag.java,v 1.1 2003/01/07 16:11:03 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 16:11:03 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: MessageTag.java,v 1.1 2003/01/07 16:11:03 dion Exp $
   */
  package org.apache.commons.jelly.tags.jms;
  
  import javax.jms.Destination;
  import javax.jms.Message;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.apache.commons.messenger.Messenger;
  
  /** A tag which creates a JMS message
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class MessageTag extends TagSupport {
  
      /** The name of the Message variable that is created */
      private String var;    
      
      /** The JMS Message created */
      private Message message;
      
      /** The Messenger used to access the JMS connection */
      private Messenger connection;
      
      public MessageTag() {
      }
      
      /** Adds a JMS property to the message */
      public void addProperty(String name, Object value) throws Exception {
          Message message = getMessage();
          message.setObjectProperty(name, value);
      }
      
      // Tag interface
      //-------------------------------------------------------------------------                    
      public void doTag(XMLOutput output) throws Exception {                
          if ( var == null ) {
              // expose message to parent message consumer
              SendTag tag = (SendTag) findAncestorWithClass( SendTag.class );
              if ( tag == null ) {
                  throw new JellyException("<jms:message> tags must either have the 'var' attribute specified or be used inside a <jms:send> tag");
              }
              tag.setMessage( getMessage() );            
          }
          else {
              context.setVariable( var, getMessage() );
          }        
      }
      
      // Properties
      //-------------------------------------------------------------------------                            
      
      /** Sets the name of the variable that the message will be exported to */
      public void setVar(String var) {
          this.var = var;        
      }
      
      public Messenger getConnection() throws Exception {
          if ( connection == null ) {
              return findConnection();
          }
          return connection;
      }
  
      /**
       * Sets the Messenger (the JMS connection pool) that will be used to send the message
       */
      public void setConnection(Messenger connection) {
          this.connection = connection;
      }
      
      public Message getMessage() throws Exception {
          if ( message == null ) {
              message = createMessage();
          }
          return message;
      }
      
  
      // JMS related properties
  
      /**
       * Sets the JMS Correlation ID to be used on the message 
       */    
      public void setCorrelationID(String correlationID) throws Exception {
          getMessage().setJMSCorrelationID(correlationID);
      }
      
      /**
       * Sets the reply-to destination to add to the message
       */
      public void setReplyTo(Destination destination) throws Exception {
          getMessage().setJMSReplyTo(destination);
      }
      
      /**
       * Sets the type name of the message
       */
      public void setType(String type) throws Exception {
          getMessage().setJMSType(type);
      }
      
      // Implementation methods
      //-------------------------------------------------------------------------                            
      protected Messenger findConnection() throws Exception {
          ConnectionContext messengerTag = (ConnectionContext) findAncestorWithClass( ConnectionContext.class );
          if ( messengerTag == null ) {
              throw new JellyException("This tag must be within a <jms:connection> tag or the 'connection' attribute should be specified");
          }
          return messengerTag.getConnection();
      }
      
      protected Message createMessage() throws Exception {
          return getConnection().createMessage();
      }    
  }    
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/ConsumerTag.java
  
  Index: ConsumerTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/ConsumerTag.java,v 1.1 2003/01/07 16:11:03 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 16:11:03 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: ConsumerTag.java,v 1.1 2003/01/07 16:11:03 dion Exp $
   */
  package org.apache.commons.jelly.tags.jms;
  
  import javax.jms.MessageListener;
  
  /** 
   * Represents an interface for a Tag which consumes JMS messages.
   * By default this is the &lt;subscribe&gt; tag but other tags could
   * implement this interface to enabled things like Message pipelining, 
   * transactional message consumer tags, stopwatch wrappers etc.
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public interface ConsumerTag {
  
      /**
       * Sets the JMS messageListener used to consume JMS messages
       */
      public void setMessageListener(MessageListener messageListener);
  
  }    
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/OnMessageTag.java
  
  Index: OnMessageTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/OnMessageTag.java,v 1.1 2003/01/07 16:11:03 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 16:11:03 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: OnMessageTag.java,v 1.1 2003/01/07 16:11:03 dion Exp $
   */
  package org.apache.commons.jelly.tags.jms;
  
  import javax.jms.Message;
  import javax.jms.MessageListener;
  
  import org.apache.commons.jelly.JellyContext;
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.Script;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /** 
   * This tag creates a JMS MessageListener which will invoke this
   * tag's body whenever a JMS Message is received. The JMS Message
   * will be available via a variable, which defaults to the 'message'
   * variable name, but can be overloaded by the var attribute.
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public class OnMessageTag extends TagSupport {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(OnMessageTag.class);
  
  	private String var = "message";
  	
      public OnMessageTag() {
      }
  
      // Tag interface
      //-------------------------------------------------------------------------                    
      public void doTag(XMLOutput output) throws Exception {
  		ConsumerTag tag = (ConsumerTag) findAncestorWithClass(ConsumerTag.class);
  		if (tag == null) {
  			throw new JellyException("This tag must be nested within a ConsumerTag like the subscribe tag");
  		}			
  
  
  		final JellyContext childContext = context.newJellyContext();
  		final Script script = getBody();
  		final XMLOutput childOutput = output; 
  		
  		MessageListener listener = new MessageListener() {
  			public void onMessage(Message message) {
  				childContext.setVariable(var, childContext);
  				try {
  					script.run(childContext, childOutput);
  				}
  				catch (Exception e) {
  					log.error("Caught exception processing message: " + message + ". Exception: " + e, e);
  				}
  			}
  		};
  
  		// perform the consumption
  		tag.setMessageListener(listener);		
      }
  
      
      // Properties
      //-------------------------------------------------------------------------                    
  
      /**
       * Sets the name of the variable used to make the JMS message available to this tags
       * body when a message is received.
       */
      public void setVar(String var) {
  		this.var = var;						
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms/sendMessage.jelly
  
  Index: sendMessage.jelly
  ===================================================================
  <?xml version="1.0"?>
  <jelly xmlns="jelly:core" xmlns:jms="jelly:jms">
  
  About to send a JMS message
  
  <jms:connection name="queue">
    <jms:send>
      <jms:destination name="myQueue"/>
      <jms:message type="Pizza" correlationID="9999">
        <jms:property name="a" value="topping"/>
        <jms:property name="b" value="${123+456}"/>
        <jms:property name="c">cheese x ${2+2}</jms:property>
      </jms:message>
    </jms:send>
  </jms:connection>
  
  Message sent!
  
  </jelly>
  
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms/flushQueue.jelly
  
  Index: flushQueue.jelly
  ===================================================================
  <?xml version="1.0"?>
  <jelly xmlns="jelly:core" xmlns:jms="jelly:jms">
  
  Flushing the input queue
  
  <jms:connection name="queue" var="conn">
    <forEach begin="1" end="1000">
      <jms:receive var="message" timeout="1">
        <jms:destination name="myQueue"/>
      </jms:receive>
      <if test="${message != null}">
  Found message: ${message}.
  	</if>
    </forEach>
    	
  </jms:connection>
  	
  </jelly>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms/sendMap.jelly
  
  Index: sendMap.jelly
  ===================================================================
  <?xml version="1.0"?>
  <jelly xmlns="jelly:core" xmlns:jms="jelly:jms">
  
  About to send a JMS map message
  
  <jms:connection name="queue">
    <jms:send>
      <jms:destination name="myQueue"/>
      <jms:mapMessage type="Order" correlationID="1234">
        <jms:mapEntry name="a" value="pizza"/>
        <jms:mapEntry name="b">cheese</jms:mapEntry>
        <jms:mapEntry name="c" value="${12 * 20}"/>
      </jms:mapMessage>
    </jms:send>
  
    <new className="java.util.HashMap" var="m"/>
    <set target="${m}" property="a" value="pizza"/>  
    <set target="${m}" property="b" value="1234"/>  
    <set target="${m}" property="c" value="${12+57}"/>  
  
  Sending map message with map: ${m}
    
    <jms:send>
      <jms:destination name="myQueue"/>
      <jms:mapMessage type="Order2" correlationID="23456" map="${m}"/>
    </jms:send>
    
  </jms:connection>
  
  </jelly>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms/sendObject.jelly
  
  Index: sendObject.jelly
  ===================================================================
  <?xml version="1.0"?>
  <jelly xmlns="jelly:core" xmlns:jms="jelly:jms">
  
  About to send a JMS Object message
  
  <new className="java.util.Date" var="d"/>
  
  <jms:connection name="queue">
    <jms:send>
      <jms:destination name="myQueue"/>
      <jms:objectMessage object="${d}" type="Date" correlationID="4321"/>
    </jms:send>
  </jms:connection>
  
  Message sent!
  
  </jelly>
  
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms/receiveMap.jelly
  
  Index: receiveMap.jelly
  ===================================================================
  <?xml version="1.0"?>
  <jelly xmlns="jelly:core" xmlns:jms="jelly:jms">
  
  Waiting until I receive a JMS message
  
  <jms:connection name="queue" var="conn">
    <jms:receive var="message">
      <jms:destination name="myQueue"/>
    </jms:receive>
  </jms:connection>
  
  Found message: ${message.JMSMessageID}.
  
  Map values are:
  <forEach items="${message.mapNames}" var="key">
    ${key} = ${message.getObject(key)}
  </forEach>
  	
  </jelly>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms/receiveObject.jelly
  
  Index: receiveObject.jelly
  ===================================================================
  <?xml version="1.0"?>
  <jelly xmlns="jelly:core" xmlns:jms="jelly:jms">
  
  Waiting until I receive a JMS message
  
  <jms:connection name="queue" var="conn">
    <jms:receive var="message">
      <jms:destination name="myQueue"/>
    </jms:receive>
  </jms:connection>
  
  Found message: ${message}
  The object body is: ${message.getObject()}
  	
  </jelly>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms/sendText.jelly
  
  Index: sendText.jelly
  ===================================================================
  <?xml version="1.0"?>
  <jelly xmlns="jelly:core" xmlns:jms="jelly:jms">
  
  About to send a JMS text message
  
  <jms:connection name="queue">
    <jms:send>
      <jms:destination>myQueue</jms:destination>
      <jms:textMessage type="Chat">This is some text via the tag body</jms:textMessage>
    </jms:send>
  
    <jms:send>
      <jms:destination name="myQueue"/>
      <jms:textMessage text="This is some text via the attribute" type="Chat"/>
    </jms:send>
  </jms:connection>
  
  Messages sent!
  
  </jelly>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms/receive.jelly
  
  Index: receive.jelly
  ===================================================================
  <?xml version="1.0"?>
  <jelly xmlns="jelly:core" xmlns:jms="jelly:jms">
  
  Waiting until I receive a JMS message
  
  <jms:connection name="queue" var="conn">
    <jms:receive var="message">
      <jms:destination name="myQueue"/>
    </jms:receive>
  </jms:connection>
  
  Found message: ${message}
  
  Properties are:
  <forEach items="${message.propertyNames}" var="key">
    ${key} = ${message.getObjectProperty(key)}
  </forEach>
  
  The text body is: ${message.text}
  	
  </jelly>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/maven.xml
  
  Index: maven.xml
  ===================================================================
  <project default="java:jar">
  
  </project>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/project.xml
  
  Index: project.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE project [
    <!-- see file for description -->
    <!ENTITY commonDeps SYSTEM "file:../../commonDependencies.ent">
  ]>
  <project>
    <extend>../tag-project.xml</extend>
    <id>commons-jelly-tags-jms</id>
    <name>commons-jelly-tags-jms</name>
    <package>org.apache.commons.jelly.tags.jms</package>
  
    <description>
        This is a Jelly interface for the Java Message Service.
    </description>
    <shortDescription>Commons Jelly JMS Tag Library</shortDescription>
    
    <siteDirectory>/www/jakarta.apache.org/commons/sandbox/jelly/tags/jms</siteDirectory>
    <distributionDirectory>/www/jakarta.apache.org/builds/jakarta-commons-sandbox/jelly/tags/jms</distributionDirectory>
    <repository>
      <connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:jakarta-commons-sandbox/jelly/jelly-tags/jms/</connection>
      <url>http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/jelly/jelly-tags/jms/</url>
    </repository>
    
      
    <dependencies>
    
      &commonDeps;
    
      <!-- START for compilation -->
    
      <dependency>
        <id>commons-jelly</id>
        <version>SNAPSHOT</version>
      </dependency>
      
      <dependency>
        <id>commons-messenger</id>
        <version>1.0-dev-8</version>
      </dependency>
      
      <dependency>
        <id>jms</id>
        <version>1.0.2b</version>
      </dependency>
   
    </dependencies>
    
  </project>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/project.properties
  
  Index: project.properties
  ===================================================================
  # -------------------------------------------------------------------
  # P R O J E C T  P R O P E R T I E S
  # -------------------------------------------------------------------
  
  maven.junit.fork=true
  
  maven.compile.deprecation = on
  
  # Installation dir
  maven.dist.install.dir = /usr/local/jelly
  
  maven.checkstyle.properties=../tag-checkstyle.properties
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/jms/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  maven.log
  target
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message