00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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
00065 return jms.getConnectionFactory();
00066 } else if (clname.equals("org.objectweb.jonas_jms.JQueueConnectionFactory")) {
00067
00068 return jms.getQueueConnectionFactory();
00069 } else if (clname.equals("org.objectweb.jonas_jms.JTopicConnectionFactory")) {
00070
00071 return jms.getTopicConnectionFactory();
00072 } else {
00073 TraceJms.logger.log(BasicLevel.ERROR, "bad class name: " + clname);
00074 return null;
00075 }
00076 }
00077 }