01: /*
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 1999 Bull S.A.
04: * Contact: jonas-team@objectweb.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19: * USA
20: *
21: * Initial developer(s):
22: * Contributor(s):
23: * Philippe Durieux
24: *
25: * --------------------------------------------------------------------------
26: * $Id: JObjectFactory.java 1934 2003-04-11 12:00:56Z coqp $
27: * --------------------------------------------------------------------------
28: */
29:
30: package org.objectweb.jonas_jms;
31:
32: import java.util.Hashtable;
33: import javax.naming.Context;
34: import javax.naming.Name;
35: import javax.naming.Reference;
36: import javax.naming.spi.ObjectFactory;
37: import org.objectweb.jonas_jms.api.JmsManager;
38:
39: import org.objectweb.util.monolog.api.BasicLevel;
40:
41: /**
42: * Factory used by JNDI lookup to get Connection Factories.
43: * These factories are managed by the JMS Manager.
44: * @see javax.naming.spi.ObjectFactory
45: * @author Laurent Chauvirey, Frederic Maistre, Nicolas Tachker
46: * Contributor(s):
47: * Philippe Durieux
48: * Philippe Coq: Integration Joram 3.4 (JMS 1.1)
49: */
50: public class JObjectFactory implements ObjectFactory {
51:
52: /**
53: * Always return the unique ConnectionFactory stored in the JmsManager
54: */
55: public Object getObjectInstance(Object refObj, Name name,
56: Context nameCtx, Hashtable env) throws Exception {
57:
58: Reference ref = (Reference) refObj;
59: JmsManager jms = JmsManagerImpl.getJmsManager();
60: String clname = ref.getClassName();
61:
62: TraceJms.logger.log(BasicLevel.DEBUG, "instance " + clname);
63:
64: if (clname.equals("org.objectweb.jonas_jms.JConnectionFactory")) {
65: // ConnectionFactory
66: return jms.getConnectionFactory();
67: } else if (clname
68: .equals("org.objectweb.jonas_jms.JQueueConnectionFactory")) {
69: // QueueConnectionFactory
70: return jms.getQueueConnectionFactory();
71: } else if (clname
72: .equals("org.objectweb.jonas_jms.JTopicConnectionFactory")) {
73: // TopicConnectionFactory
74: return jms.getTopicConnectionFactory();
75: } else {
76: TraceJms.logger.log(BasicLevel.ERROR, "bad class name: "
77: + clname);
78: return null;
79: }
80: }
81: }
|