KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > dyade > aaa > jndi2 > msg > LookupReply


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  * Copyright (C) 2001 - ScalAgent Distributed Technologies
4  * Copyright (C) 1996 - Dyade
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * 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): Sofiane Chibani
22  * Contributor(s): David Feliot, Nicolas Tachker
23  */

24 package fr.dyade.aaa.jndi2.msg;
25
26 import javax.naming.*;
27
28 import org.objectweb.util.monolog.api.BasicLevel;
29 import org.objectweb.util.monolog.api.Logger;
30
31 public class LookupReply extends JndiReply {
32   
33   public static final Logger logger = fr.dyade.aaa.util.Debug.getLogger(
34       LookupReply.class.getName());
35   
36   private Object JavaDoc obj;
37
38   public LookupReply(Object JavaDoc obj) {
39     this.obj = obj;
40   }
41
42   public final Object JavaDoc getObject() throws NamingException {
43     return resolveObject(obj);
44   }
45
46   public final static Object JavaDoc resolveObject(Object JavaDoc obj) throws NamingException {
47     if (obj instanceof Reference) {
48       try {
49         return javax.naming.spi.NamingManager.getObjectInstance(
50           obj, null, null, null);
51       } catch (Exception JavaDoc e) {
52         if (logger.isLoggable(BasicLevel.DEBUG))
53           logger.log(BasicLevel.DEBUG, "", e);
54         NamingException ne = new NamingException(e.getMessage());
55         ne.setRootCause(e);
56         throw ne;
57       }
58     } else {
59       return obj;
60     }
61   }
62 }
63
Popular Tags