01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package org.jboss.mq.referenceable;
23:
24: import org.jboss.logging.Logger;
25:
26: /**
27: * This class is used to create instances of of: SpyTopic SpyQueue classes from
28: * a javax.naming.Reference instance.
29: *
30: * @author Hiram Chirino (Cojonudo14@hotmail.com)
31: * @created August 16, 2001
32: * @version $Revision: 57198 $
33: */
34: public class SpyDestinationObjectFactory implements
35: javax.naming.spi.ObjectFactory {
36:
37: static Logger cat = Logger
38: .getLogger(SpyDestinationObjectFactory.class);
39:
40: /**
41: * SpyTopicObjectFactory constructor
42: */
43: public SpyDestinationObjectFactory() {
44: super ();
45: }
46:
47: /**
48: * getObjectInstance method
49: *
50: * @param reference Description of Parameter
51: * @param name Description of Parameter
52: * @param contex Description of Parameter
53: * @param properties Description of Parameter
54: * @return The ObjectInstance value
55: * @exception java.lang.Exception Description of Exception
56: */
57: public java.lang.Object getObjectInstance(
58: java.lang.Object reference, javax.naming.Name name,
59: javax.naming.Context contex, java.util.Hashtable properties)
60: throws java.lang.Exception {
61:
62: cat.debug("SpyDestinationObjectFactory->getObjectInstance()");
63:
64: try {
65:
66: javax.naming.Reference ref = (javax.naming.Reference) reference;
67: if (ref.getClassName().equals("org.jboss.mq.SpyTopic")) {
68:
69: String dest = (String) ref.get("name").getContent();
70: return new org.jboss.mq.SpyTopic(dest);
71: } else if (ref.getClassName().equals(
72: "org.jboss.mq.SpyQueue")) {
73:
74: String dest = (String) ref.get("name").getContent();
75: return new org.jboss.mq.SpyQueue(dest);
76: }
77: } catch (RuntimeException ignore) {
78: } catch (Exception ignore) {
79: // This method should not throw an exception since
80: // It would prevent another ObjectFactory from attempting
81: // to create an instance of the object.
82: }
83: return null;
84: }
85: }
|