Coverage report

  %line %branch
org.apache.commons.jelly.tags.jms.DestinationTag
0% 
0% 

 1  
 /*
 2  
  * Copyright 2002,2004 The Apache Software Foundation.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.apache.commons.jelly.tags.jms;
 17  
 
 18  
 import javax.jms.Destination;
 19  
 import javax.jms.JMSException;
 20  
 
 21  
 import org.apache.commons.jelly.JellyTagException;
 22  
 import org.apache.commons.jelly.TagSupport;
 23  
 import org.apache.commons.jelly.XMLOutput;
 24  
 import org.apache.commons.messenger.Messenger;
 25  
 
 26  
 /** Creates a Destination object from a String name.
 27  
   *
 28  
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
 29  
   * @version $Revision: 1.5 $
 30  
   */
 31  0
 public class DestinationTag extends TagSupport {
 32  
 
 33  
     /** The variable name to create */
 34  
     private String var;
 35  
 
 36  
     /** Stores the name of the map entry */
 37  
     private String name;
 38  
 
 39  
     // Tag interface
 40  
     //-------------------------------------------------------------------------
 41  
     public void doTag(XMLOutput output) throws JellyTagException {
 42  0
         ConnectionContext messengerTag = (ConnectionContext) findAncestorWithClass( ConnectionContext.class );
 43  0
         if ( messengerTag == null ) {
 44  0
             throw new JellyTagException("<jms:destination> tag must be within a <jms:connection> or <jms:send> or <jms:receive> tag");
 45  
         }
 46  
 
 47  0
         Destination destination = null;
 48  
         try {
 49  0
             Messenger messenger = messengerTag.getConnection();
 50  0
             if (messenger == null) {
 51  0
                 throw new JellyTagException("No JMS Connection could be found!" );
 52  
             }
 53  0
             String subject = (name != null) ? name : getBodyText();
 54  0
             destination = messenger.getDestination( subject );
 55  0
         }
 56  
         catch (JMSException e) {
 57  0
             throw new JellyTagException(e);
 58  
         }
 59  
 
 60  0
         if ( var != null ) {
 61  0
             context.setVariable( var, destination );
 62  
         }
 63  
         else {
 64  0
             MessageOperationTag tag = (MessageOperationTag) findAncestorWithClass( MessageOperationTag.class );
 65  0
             if ( tag == null ) {
 66  0
                 throw new JellyTagException("<jms:destination> tag must be within a <jms:send> or <jms:receive> tag or the 'var' attribute should be specified");
 67  
             }
 68  0
             tag.setDestination( destination );
 69  
         }
 70  0
     }
 71  
 
 72  
 
 73  
     // Properties
 74  
     //-------------------------------------------------------------------------
 75  
 
 76  
     /** Sets the name of the Destination
 77  
       */
 78  
     public void setName(String name) {
 79  0
         this.name = name;
 80  0
     }
 81  
 
 82  
     /** Sets the variable name to use for the Destination
 83  
       */
 84  
     public void setVar(String var) {
 85  0
         this.var = class="keyword">var;
 86  0
     }
 87  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.