1 24 package com.scalagent.kjoram; 25 26 import com.scalagent.kjoram.jms.TempDestDeleteRequest; 27 28 import java.util.Vector ; 29 import java.util.Hashtable ; 30 31 import com.scalagent.kjoram.excepts.JMSException; 32 import com.scalagent.kjoram.excepts.JMSSecurityException; 33 34 35 public class TemporaryQueue extends Queue 36 { 37 38 private Connection cnx; 39 40 47 public TemporaryQueue(String agentId, Connection cnx) 48 { 49 super(agentId); 50 this.cnx = cnx; 51 } 52 53 56 public TemporaryQueue() 57 {} 58 59 60 public String toString() 61 { 62 return "TempQueue:" + agentId; 63 } 64 65 71 public void delete() throws JMSException 72 { 73 if (cnx == null) 74 throw new JMSSecurityException("Forbidden call as this TemporaryQueue" 75 + " does not belong to this connection."); 76 77 if (JoramTracing.dbgClient) 78 JoramTracing.log(JoramTracing.DEBUG, "--- " + this 79 + ": deleting..."); 80 81 Session sess; 83 MessageConsumer cons; 84 for (int i = 0; i < cnx.sessions.size(); i++) { 85 sess = (Session) cnx.sessions.elementAt(i); 86 for (int j = 0; j < sess.consumers.size(); j++) { 87 cons = (MessageConsumer) sess.consumers.elementAt(j); 88 if (agentId.equals(cons.targetName)) 89 throw new JMSException("Consumers still exist for this temp." 90 + " queue."); 91 } 92 } 93 cnx.syncRequest(new TempDestDeleteRequest(agentId)); 95 96 if (JoramTracing.dbgClient) 97 JoramTracing.log(JoramTracing.DEBUG, this + ": deleted."); 98 } 99 100 104 Connection getCnx() 105 { 106 return cnx; 107 } 108 109 public Hashtable code() { 110 return super.code(); 111 } 112 113 public static Object decode(Hashtable h) { 114 TemporaryQueue ret = new TemporaryQueue(); 115 ret.setAgentId((String ) h.get("agentId")); 116 ret.addInstanceTable(ret.getId(), ret); 118 return ret; 119 } 120 } 121 | Popular Tags |