JObjectFactory.java

00001 /*
00002  * JOnAS: Java(TM) Open Application Server
00003  * Copyright (C) 1999 Bull S.A.
00004  * Contact: jonas-team@objectweb.org
00005  * 
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or any later version.
00010  * 
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00019  * USA
00020  *
00021  * Initial developer(s): 
00022  * Contributor(s): 
00023  * Philippe Durieux
00024  *
00025  * --------------------------------------------------------------------------
00026  * $Id: JObjectFactory.java,v 1.6 2003/04/11 12:00:55 coqp Exp $
00027  * --------------------------------------------------------------------------
00028  */
00029 
00030 package org.objectweb.jonas_jms; 
00031 
00032 import java.util.Hashtable;
00033 import javax.naming.Context;
00034 import javax.naming.Name;
00035 import javax.naming.Reference;
00036 import javax.naming.spi.ObjectFactory;
00037 import org.objectweb.jonas_jms.api.JmsManager;
00038 
00039 import org.objectweb.util.monolog.api.BasicLevel;
00040 
00050 public class JObjectFactory implements ObjectFactory {
00051 
00055     public Object getObjectInstance(Object refObj, Name name, Context nameCtx, Hashtable env) throws Exception {
00056 
00057         Reference ref = (Reference) refObj;
00058         JmsManager jms = JmsManagerImpl.getJmsManager();
00059         String clname = ref.getClassName();
00060 
00061         TraceJms.logger.log(BasicLevel.DEBUG, "instance " + clname);
00062 
00063         if (clname.equals("org.objectweb.jonas_jms.JConnectionFactory")) {
00064             // ConnectionFactory
00065             return jms.getConnectionFactory();
00066         } else if (clname.equals("org.objectweb.jonas_jms.JQueueConnectionFactory")) {
00067             // QueueConnectionFactory
00068             return jms.getQueueConnectionFactory();
00069         } else if (clname.equals("org.objectweb.jonas_jms.JTopicConnectionFactory")) {
00070             // TopicConnectionFactory
00071             return jms.getTopicConnectionFactory();
00072         } else {
00073             TraceJms.logger.log(BasicLevel.ERROR, "bad class name: " +  clname);
00074             return null;
00075         }
00076     }
00077 }

Generated on Tue Feb 15 15:05:50 2005 for JOnAS by  doxygen 1.3.9.1