Clover coverage report - Lingo - 1.0-SNAPSHOT
Coverage timestamp: Fri May 13 2005 08:50:34 BST
file stats: LOC: 100   Methods: 11
NCLOC: 55   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
OneWayRequestor.java 75% 68.8% 63.6% 67.7%
coverage coverage
 1   
 /** 
 2   
  * 
 3   
  * Copyright 2005 LogicBlaze, Inc.
 4   
  * 
 5   
  * Licensed under the Apache License, Version 2.0 (the "License"); 
 6   
  * you may not use this file except in compliance with the License. 
 7   
  * You may obtain a copy of the License at 
 8   
  * 
 9   
  * http://www.apache.org/licenses/LICENSE-2.0
 10   
  * 
 11   
  * Unless required by applicable law or agreed to in writing, software
 12   
  * distributed under the License is distributed on an "AS IS" BASIS, 
 13   
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 14   
  * See the License for the specific language governing permissions and 
 15   
  * limitations under the License. 
 16   
  * 
 17   
  **/
 18   
 package org.logicblaze.lingo.jms.impl;
 19   
 
 20   
 import org.logicblaze.lingo.jms.JmsProducer;
 21   
 import org.logicblaze.lingo.jms.Requestor;
 22   
 import org.apache.commons.logging.Log;
 23   
 import org.apache.commons.logging.LogFactory;
 24   
 
 25   
 import javax.jms.Destination;
 26   
 import javax.jms.JMSException;
 27   
 import javax.jms.Message;
 28   
 import javax.jms.Session;
 29   
 
 30   
 /**
 31   
  * A simple requestor which only supports one-way and so does not need a consumer.
 32   
  *
 33   
  * @version $Revision: 1.1 $
 34   
  */
 35   
 public class OneWayRequestor implements Requestor {
 36   
     private static final Log log = LogFactory.getLog(OneWayRequestor.class);
 37   
 
 38   
     private JmsProducer producer;
 39   
     private Destination serverDestination;
 40   
     private long counter;
 41   
 
 42  46
     public OneWayRequestor(JmsProducer producer, Destination serverDestination) {
 43  46
         this.producer = producer;
 44  46
         this.serverDestination = serverDestination;
 45   
     }
 46   
 
 47  101
     public void oneWay(Destination destination, Message message) throws JMSException {
 48  101
         populateHeaders(message);
 49  101
         doSend(destination, message);
 50   
     }
 51   
 
 52  114
     public Session getSession() {
 53  114
         return producer.getSession();
 54   
     }
 55   
 
 56  0
     public void close() throws JMSException {
 57  0
         producer.close();
 58   
     }
 59   
 
 60  0
     public Message receive(long timeout) throws JMSException {
 61  0
         throw new JMSException("receive(timeout) not implemented for OneWayRequestor");
 62   
     }
 63   
 
 64  0
     public Message request(Destination destination, Message message) throws JMSException {
 65  0
         throw new JMSException("request() not implemented for OneWayRequestor");
 66   
     }
 67   
 
 68  0
     public Message request(Destination destination, Message message, long timeout) throws JMSException {
 69  0
         throw new JMSException("request() not implemented for OneWayRequestor");
 70   
     }
 71   
 
 72  9
     protected void populateHeaders(Message message) throws JMSException {
 73   
     }
 74   
 
 75  101
     protected void doSend(Destination destination, Message message) throws JMSException {
 76  101
         if (destination == null) {
 77  68
             destination = serverDestination;
 78   
         }
 79  101
         if (log.isDebugEnabled()) {
 80  0
             log.debug("Sending message to: " + destination + " message: " + message);
 81   
         }
 82  101
         producer.getMessageProducer().send(destination, message);
 83   
     }
 84   
 
 85   
     /**
 86   
      * Creates a new correlation ID. Note that because the correlationID is used
 87   
      * on a per-temporary destination basis, it does not need to be unique across
 88   
      * more than one destination. So a simple counter will suffice.
 89   
      *
 90   
      * @return
 91   
      */
 92  69
     public String createCorrelationID() {
 93  69
         return Long.toString(nextCounter());
 94   
     }
 95   
 
 96  69
     protected synchronized long nextCounter() {
 97  69
         return ++counter;
 98   
     }
 99   
 }
 100