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