1 22 package org.jboss.ejb3.jms; 23 24 import javax.jms.Destination ; 25 import javax.jms.Queue ; 26 import javax.jms.Topic ; 27 import javax.management.ObjectName ; 28 29 import org.jboss.ejb3.KernelAbstraction; 30 import org.jboss.ejb3.KernelAbstractionFactory; 31 import org.jboss.logging.Logger; 32 33 41 public class ServerPeerJMSDestinationFactory extends JMSDestinationFactory 42 { 43 private static final Logger log = Logger.getLogger(ServerPeerJMSDestinationFactory.class); 44 45 ServerPeerJMSDestinationFactory() 47 { 48 49 } 50 51 public void createDestination(Class <? extends Destination > type, String jndiSuffix) throws Exception 52 { 53 String methodName; 54 String destinationContext; 55 if (type == Topic .class) 56 { 57 destinationContext = "topic"; 58 methodName = "createTopic"; 59 } 60 else if (type == Queue .class) 61 { 62 destinationContext = "queue"; 63 methodName = "createQueue"; 64 } 65 else 66 { 67 throw new IllegalArgumentException 69 ("Expected javax.jms.Queue or javax.jms.Topic: " + type); 70 } 71 72 String name = jndiSuffix; 73 String jndiName = destinationContext + "/" + jndiSuffix; 74 75 ObjectName serverPeerName = new ObjectName ("jboss.messaging:service=ServerPeer"); 76 77 KernelAbstraction kernel = KernelAbstractionFactory.getInstance(); 78 Object result = kernel.invoke(serverPeerName, 80 methodName, 81 new Object []{name, jndiName}, 82 new String []{"java.lang.String", "java.lang.String"}); 83 84 log.debug("result = " + result); 85 } 86 } 87 | Popular Tags |