1 22 package org.jboss.mq.kernel; 23 24 import java.util.Hashtable ; 25 import javax.jms.JMSException ; 26 import javax.naming.InitialContext ; 27 import javax.naming.NamingException ; 28 import javax.management.InstanceNotFoundException ; 29 import javax.management.MBeanException ; 30 import javax.management.ReflectionException ; 31 import org.jboss.mq.SpyQueue; 32 import org.jboss.mq.server.JMSDestinationManager; 33 import org.jboss.mq.server.JMSQueue; 34 import org.jboss.mq.SpyDestination; 35 import org.jboss.naming.Util; 36 37 43 public class Queue extends org.jboss.mq.server.jmx.Queue 44 { 45 protected JMSDestinationManager destinationManagerPojo; 46 protected Hashtable initialContextProperties; 47 48 49 public void setDestinationName(String name) 50 { 51 this.destinationName = name; 52 } 53 54 public String getDestinationName() 55 { 56 return destinationName; 57 } 58 59 protected void setupSecurityManager() throws InstanceNotFoundException , MBeanException , ReflectionException 60 { 61 } 63 64 protected void teardownSecurityManager() throws InstanceNotFoundException , MBeanException , ReflectionException 65 { 66 } 68 69 public void create() throws Exception 70 { 71 if (parameters.receiversImpl == null) 73 parameters.receiversImpl = destinationManagerPojo.getParameters().receiversImpl; 74 if (parameters.recoveryRetries == 0) 75 parameters.recoveryRetries = destinationManagerPojo.getParameters().recoveryRetries; 76 } 77 78 public void start() throws Exception 79 { 80 88 if (destinationName == null || destinationName.length() == 0) 89 { 90 throw new javax.jms.IllegalStateException ("QueueName was not set"); 91 } 92 93 spyDest = new SpyQueue(destinationName); 94 destination = new JMSQueue(spyDest, null, destinationManagerPojo, parameters); 95 96 destinationManagerPojo.addDestination(destination); 97 98 if (jndiName == null) { 99 setJNDIName("queue/" + destinationName); 100 } 101 else { 102 setJNDIName(jndiName); 104 } 105 } 106 107 public void setExpiryDestinationJndi(String jndi) throws Exception 108 { 109 InitialContext ctx = new InitialContext (); 110 parameters.expiryDestination = (SpyDestination)ctx.lookup(jndi); 111 } 112 113 public void stop() 114 { 115 try 116 { 117 if (jndiBound) 119 { 120 InitialContext ctx = getInitialContext(); 121 try 122 { 123 log.info("Unbinding JNDI name: " + jndiName); 124 Util.unbind(ctx, jndiName); 125 } 126 finally 127 { 128 ctx.close(); 129 } 130 jndiName = null; 131 jndiBound = false; 132 } 133 134 if (destinationManagerPojo != null) 135 destinationManagerPojo.closeDestination(spyDest); 136 137 } 145 catch (NamingException e) 146 { 147 throw new RuntimeException (e); 148 } 149 catch (JMSException e) 150 { 151 throw new RuntimeException (e); 152 } 153 } 154 155 protected InitialContext getInitialContext() 156 throws NamingException 157 { 158 InitialContext ctx1 = null; 159 if (initialContextProperties != null) 160 { 161 ctx1 = new InitialContext (initialContextProperties); 162 } 163 else ctx1 = new InitialContext (); 164 InitialContext ctx = ctx1; 165 return ctx; 166 } 167 168 public void destroy() 169 { 170 } 171 172 public Hashtable getInitialContextProperties() 173 { 174 return initialContextProperties; 175 } 176 177 public void setInitialContextProperties(Hashtable initialContextProperties) 178 { 179 this.initialContextProperties = initialContextProperties; 180 } 181 182 public JMSDestinationManager getDestinationManagerPojo() 183 { 184 return destinationManagerPojo; 185 } 186 187 public void setDestinationManagerPojo(JMSDestinationManager destinationManagerPojo) 188 { 189 this.destinationManagerPojo = destinationManagerPojo; 190 } 191 } 192 | Popular Tags |