From: <tan...@us...> - 2003-01-21 14:27:22
|
Update of /cvsroot/openjms/openjms/src/main/org/exolab/jms/client In directory sc8-pr-cvs1:/tmp/cvs-serv25258/src/main/org/exolab/jms/client Modified Files: JmsTopicPublisher.java Log Message: fixed NPE if publisher closed twice Index: JmsTopicPublisher.java =================================================================== RCS file: /cvsroot/openjms/openjms/src/main/org/exolab/jms/client/JmsTopicPublisher.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** JmsTopicPublisher.java 12 Oct 2001 07:55:31 -0000 1.8 --- JmsTopicPublisher.java 21 Jan 2003 14:27:19 -0000 1.9 *************** *** 39,43 **** * OF THE POSSIBILITY OF SUCH DAMAGE. * ! * Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved. * * $Id$ --- 39,43 ---- * OF THE POSSIBILITY OF SUCH DAMAGE. * ! * Copyright 2000-2003 (C) Exoffice Technologies Inc. All Rights Reserved. * * $Id$ *************** *** 48,57 **** package org.exolab.jms.client; import javax.jms.JMSException; - import javax.jms.TopicPublisher; import javax.jms.Message; - import javax.jms.DeliveryMode; import javax.jms.Topic; ! import org.exolab.jms.message.DestinationImpl; /** --- 48,58 ---- package org.exolab.jms.client; + import javax.jms.DeliveryMode; + import javax.jms.InvalidDestinationException; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.Topic; ! import javax.jms.TopicPublisher; ! /** *************** *** 120,170 **** // implementation of JmsTopicPublisher.publish public void publish(Topic topic, Message message, int deliveryMode, ! int priority, long timeToLive) ! throws JMSException ! { ! try { ! // ensure that a topic has been specified ! if (topic == null) { ! throw new JMSException("publish failed : No topic specified"); ! } ! ! // ensure that a message has been specified ! if (message == null) { ! throw new JMSException("send failed b/c message is null"); ! } ! // the timestamp, expiration time and the client ids are all ! // generated by the message manager ! if (timeToLive > 0) { ! message.setJMSExpiration(System.currentTimeMillis() + ! timeToLive); ! } else { ! message.setJMSExpiration(0); ! } ! // if the queue is an instance of a TemporaryTopic then ! // override the deliveryMode to NON_PERSISTENT ! if (topic instanceof JmsTemporaryTopic) { ! message.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT); ! } else { ! message.setJMSDeliveryMode(deliveryMode); ! } ! message.setJMSPriority(priority); ! message.setJMSDestination(topic); ! super.sendMessage(message); ! } catch (Exception exception) { ! throw new JMSException("Error in publish " + exception); } } // overwrites of JmsMessageProducer.close ! public void close() ! throws JMSException ! { ! // unregister this publisher from the session amd then call the base ! // class method. ! ((JmsTopicSession)_session).removePublisher(this); ! super.close(); } --- 121,163 ---- // implementation of JmsTopicPublisher.publish public void publish(Topic topic, Message message, int deliveryMode, ! int priority, long timeToLive) throws JMSException { ! if (topic == null) { ! throw new InvalidDestinationException( ! "Argument 'topic' is null"); ! } ! if (message == null) { ! throw new JMSException("Argument 'message' is null"); ! } ! // the timestamp, expiration time and the client ids are all ! // generated by the message manager ! if (timeToLive > 0) { ! message.setJMSExpiration(System.currentTimeMillis() + timeToLive); ! } else { ! message.setJMSExpiration(0); ! } ! // if the queue is an instance of a TemporaryTopic then ! // override the deliveryMode to NON_PERSISTENT ! if (topic instanceof JmsTemporaryTopic) { ! message.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT); ! } else { ! message.setJMSDeliveryMode(deliveryMode); } + + message.setJMSPriority(priority); + message.setJMSDestination(topic); + super.sendMessage(message); } // overwrites of JmsMessageProducer.close ! public void close() throws JMSException { ! if (_session != null) { ! // unregister this publisher from the session amd then call the ! // base class method. ! ((JmsTopicSession)_session).removePublisher(this); ! super.close(); ! } } |