View Javadoc
1 /* 2 * @(#)ConnectionFactoryObjectFactory.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.QueueConnectionFactoryImpl; 22 import org.huihoo.jfox.ms.jms.topic.TopicConnectionFactoryImpl; 23 24 /*** 25 * <p> 26 * This factory object implements the ObjectFactory interface and is used to 27 * resolve a reference to a connection factory. All 28 * {@link org.huihoo.jfoxms.jms.base.ConnectionFactoryImpl}objects support the 29 * java.naming.Referenceable interface and make explicit reference to this 30 * factory. 31 * </p> 32 * 33 * @see org.huihoo.jfoxms.jms.topic.TopicConnectionFactoryImpl 34 * @see org.huihoo.jfoxms.jms.queue.QueueConnectionFactoryImpl 35 * 36 * @author <a href="mailto:founder_chen@yahoo.com.cn">Peter.Cheng</a> 37 * @version Revision: 1.1 Date: 2003-05-15 21:46:05 38 */ 39 40 public class ConnectionFactoryObjectFactory implements ObjectFactory { 41 42 /*** 43 * Default Consturctor 44 */ 45 public ConnectionFactoryObjectFactory() { 46 } 47 48 /*** 49 * Creates an object using the location or reference information specified. 50 * 51 * @param obj 52 * @param name 53 * @param nameCtx 54 * @param environment 55 * @return The object created 56 * @throws Exception 57 */ 58 public Object getObjectInstance( 59 Object obj, 60 Name name, 61 Context nameCtx, 62 Hashtable environment) 63 throws Exception { 64 Reference ref = (Reference)obj; 65 if (ref 66 .getClassName() 67 .equals(QueueConnectionFactoryImpl.class.getName())) { 68 String url = (String)ref.get("CFUrl").getContent(); 69 return new QueueConnectionFactoryImpl(url); 70 } else { 71 if (ref 72 .getClassName() 73 .equals(TopicConnectionFactoryImpl.class.getName())) { 74 String url = (String)ref.get("CFUrl").getContent(); 75 return new TopicConnectionFactoryImpl(url); 76 } else { 77 throw new Exception( 78 "Cannot create objects of type " + ref.getClassName()); 79 } 80 } 81 } 82 }

This page was automatically generated by Maven