View Javadoc
1 /* 2 * @(#)DestinationObjectFactory.java 3 * 4 * JFoxMQ the open source JMS MOM. 5 * 6 * Corpyright 2002-2003 Huihoo Power, Inc. All Rights Reserved. This software 7 * is licensed under LGPL license. 8 * 9 * For more information, please visit: http://www.huihoo.org 10 */ 11 12 package org.huihoo.jfox.ms.jms.base; 13 14 import java.util.Hashtable; 15 16 import javax.naming.Context; 17 import javax.naming.Name; 18 import javax.naming.Reference; 19 import javax.naming.spi.ObjectFactory; 20 21 import org.huihoo.jfox.ms.jms.queue.QueueImpl; 22 import org.huihoo.jfox.ms.jms.topic.TopicImpl; 23 24 /*** 25 * <p> 26 * This class implements javax.naming.spi.ObjectFactory. It's a factory for 27 * retrieve destination object from remote references stored in a JNDI 28 * namespace. 29 * </p> 30 * 31 * @author <a href="mailto:founder_chen@yahoo.com.cn">Peter.Cheng</a> 32 * @version Revision: 1.1 Date: 2003-06-15 14:31:38 33 */ 34 35 public class DestinationObjectFactory implements ObjectFactory { 36 37 public DestinationObjectFactory() { 38 } 39 40 /*** 41 * Called by JNDI to reconstruct a destination implementation from a remote 42 * reference stored in a namespace 43 * 44 * @param obj 45 * @param name 46 * @param nameCtx 47 * @param environment 48 * @return Object 49 * @throws Exception 50 */ 51 public Object getObjectInstance( 52 Object obj, 53 Name name, 54 Context nameCtx, 55 Hashtable environment) 56 throws Exception { 57 Reference ref = (Reference)obj; 58 if (ref.getClassName().equals(TopicImpl.class.getName())) { 59 String destName = (String)ref.get("name").getContent(); 60 return new TopicImpl(destName); 61 } else { 62 if (ref.getClassName().equals(QueueImpl.class.getName())) { 63 String destName = (String)ref.get("name").getContent(); 64 return new QueueImpl(destName); 65 } else { 66 throw new Exception( 67 "Cannot create objects of type " + ref.getClassName()); 68 } 69 } 70 } 71 72 }

This page was automatically generated by Maven