1 46 52 package org.mr.api.jms; 53 54 import javax.naming.Reference ; 55 import java.util.Hashtable ; 56 import javax.naming.Context ; 57 import javax.naming.Name ; 58 import javax.naming.spi.ObjectFactory ; 59 60 public class MantaConnectionFactoryFactory implements ObjectFactory { 61 62 public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception 63 { 64 try 65 { 66 Reference reference = (Reference ) obj; 67 String className = reference.getClassName(); 68 if (className.equals(MantaQueueConnectionFactory.class.getName())) 69 return new MantaQueueConnectionFactory(getName(reference)); 70 if (className.equals(MantaTopicConnectionFactory.class.getName())) 71 return new MantaTopicConnectionFactory(getName(reference)); 72 if (className.equals(MantaConnectionFactory.class.getName())) 73 return new MantaConnectionFactory(getName(reference)); 74 if (className.equals(MantaXAConnectionFactory.class.getName())) 75 return new MantaXAConnectionFactory(getName(reference)); 76 77 } 78 catch (Exception ignored) 79 { 80 ignored.printStackTrace(); 81 } 82 return null; 83 } 84 85 86 protected String getName(Reference reference) 87 { 88 return (String ) reference.get("name").getContent(); 89 } 90 } 91 | Popular Tags |