1 18 package org.apache.activemq.jndi; 19 20 import javax.naming.Context ; 21 import javax.naming.NamingException ; 22 import java.util.Hashtable ; 23 import java.util.Iterator ; 24 import java.util.Map ; 25 26 38 public class ActiveMQWASInitialContextFactory extends ActiveMQInitialContextFactory { 39 40 43 public Context getInitialContext(Hashtable environment) throws NamingException { 44 45 return super.getInitialContext(transformEnvironment(environment)); 46 } 47 48 61 protected Hashtable transformEnvironment(Hashtable environment) { 62 63 Hashtable environment1 = new Hashtable (); 64 65 Iterator it = environment.entrySet().iterator(); 66 67 while (it.hasNext()) { 68 Map.Entry entry = (Map.Entry ) it.next(); 69 String key = (String ) entry.getKey(); 70 String value = (String ) entry.getValue(); 71 72 if (key.startsWith("java.naming.queue")) { 73 String key1 = key.substring("java.naming.queue.".length()); 74 key1 = key1.replace('.', '/'); 75 environment1.put("queue." + key1, value); 76 } 77 else if (key.startsWith("java.naming.topic")) { 78 String key1 = key.substring("java.naming.topic.".length()); 79 key1 = key1.replace('.', '/'); 80 environment1.put("topic." + key1, value); 81 } 82 else if (key.startsWith("java.naming.connectionFactoryNames")) { 83 String key1 = key.substring("java.naming.".length()); 84 environment1.put(key1, value); 85 } 86 else if (key.startsWith("java.naming.connection")) { 87 String key1 = key.substring("java.naming.".length()); 88 environment1.put(key1, value); 89 } 90 else if (key.startsWith(Context.PROVIDER_URL)) { 91 value = value.replace(';', ','); 95 environment1.put(Context.PROVIDER_URL, value); 96 } 97 else { 98 environment1.put(key, value); 99 } 100 } 101 102 return environment1; 103 } 104 } 105 | Popular Tags |