1 55 56 package org.jboss.axis.components.jms; 57 58 import javax.jms.ConnectionFactory ; 59 import javax.jms.Queue ; 60 import javax.jms.QueueConnectionFactory ; 61 import javax.jms.QueueSession ; 62 import javax.jms.Topic ; 63 import javax.jms.TopicConnectionFactory ; 64 import javax.jms.TopicSession ; 65 import javax.naming.Context ; 66 import javax.naming.InitialContext ; 67 import java.util.HashMap ; 68 import java.util.Hashtable ; 69 70 75 public class JNDIVendorAdapter extends JMSVendorAdapter 76 { 77 private Context context; 78 public final static String CONNECTION_FACTORY_JNDI_NAME = 79 "transport.jms.ConnectionFactoryJNDIName"; 80 81 public QueueConnectionFactory getQueueConnectionFactory(HashMap cfConfig) 82 throws Exception 83 { 84 return (QueueConnectionFactory )getConnectionFactory(cfConfig); 85 } 86 87 public TopicConnectionFactory getTopicConnectionFactory(HashMap cfConfig) 88 throws Exception 89 { 90 return (TopicConnectionFactory )getConnectionFactory(cfConfig); 91 } 92 93 private ConnectionFactory getConnectionFactory(HashMap cfProps) 94 throws Exception 95 { 96 if (cfProps == null) 97 throw new IllegalArgumentException ("noCFProps"); 98 String jndiName = (String )cfProps.get(CONNECTION_FACTORY_JNDI_NAME); 99 if (jndiName == null || jndiName.trim().length() == 0) 100 throw new IllegalArgumentException ("noCFName"); 101 102 Hashtable environment = new Hashtable (cfProps); 103 context = new InitialContext (environment); 104 return (ConnectionFactory )context.lookup(jndiName); 105 } 106 107 public Queue getQueue(QueueSession session, String name) 108 throws Exception 109 { 110 return (Queue )context.lookup(name); 111 } 112 113 public Topic getTopic(TopicSession session, String name) 114 throws Exception 115 { 116 return (Topic )context.lookup(name); 117 } 118 } | Popular Tags |