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