1 48 package org.exolab.jms.client; 49 50 51 import java.util.Hashtable ; 52 53 import javax.naming.Context ; 54 import javax.naming.Name ; 55 import javax.naming.Reference ; 56 import javax.naming.StringRefAddr ; 57 import javax.naming.spi.ObjectFactory ; 58 59 60 73 public class JmsDestinationFactory 74 implements ObjectFactory { 75 76 public Object getObjectInstance(Object object, Name name, Context context, 78 Hashtable env) throws Exception { 79 80 Object result = null; 81 82 if (object instanceof Reference ) { 83 Reference ref = (Reference ) object; 84 String className = ref.getClassName(); 85 StringRefAddr nameref = (StringRefAddr ) ref.get("name"); 86 StringRefAddr persistref = (StringRefAddr ) ref.get("persistent"); 87 88 if (nameref != null && persistref != null) { 89 String destination = (String ) nameref.getContent(); 90 String persist = (String ) persistref.getContent(); 91 92 if (className.equals(JmsQueue.class.getName())) { 93 JmsQueue queue = new JmsQueue(destination); 94 queue.setPersistent(new Boolean (persist).booleanValue()); 95 result = queue; 96 } else if (className.equals(JmsTopic.class.getName())) { 97 JmsTopic topic = new JmsTopic(destination); 98 topic.setPersistent(new Boolean (persist).booleanValue()); 99 result = topic; 100 } else { 101 throw new Exception ( 102 "This factory cannot create objects of type " 103 + className); 104 } 105 } 106 } 107 108 return result; 109 } 110 } 111 | Popular Tags |