KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > naming > factory > IIOPObjectFactory


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.naming.factory;
24
25 import javax.naming.*;
26 import javax.naming.spi.*;
27
28 import java.util.Hashtable JavaDoc;
29 import com.sun.enterprise.util.ORBManager;
30
31 //START OF IASRI 4660742
32
import java.util.logging.*;
33 import com.sun.logging.*;
34 //END OF IASRI 4660742
35

36
37 /**
38  * An object factory to handle URL references.
39  * Handles references and looks up in the cosnaming contexts.
40  */

41
42 public class IIOPObjectFactory implements ObjectFactory {
43
44     // START OF IASRI 4660742
45
static Logger _logger=LogDomains.getLogger(LogDomains.JNDI_LOGGER);
46     // END OF IASRI 4660742
47

48     public static final boolean debug = false;
49     Hashtable JavaDoc env = new Hashtable JavaDoc();
50
51     public Object JavaDoc getObjectInstance(Object JavaDoc obj,
52                     Name name,
53                     Context nameCtx,
54                     Hashtable JavaDoc env) throws Exception JavaDoc
55     {
56     env.put("java.naming.factory.initial",
57         "com.sun.jndi.cosnaming.CNCtxFactory");
58
59     InitialContext ic = new InitialContext(env);
60
61     Reference ref = (Reference) obj;
62     if(debug) {
63         /** IASRI 4660742
64         System.out.println("IIOPObjectFactory " + ref +
65                 " Name:" + name);
66         **/

67         // START OF IASRI 4660742
68
if(_logger.isLoggable(Level.FINE)) {
69          _logger.log(Level.FINE,"IIOPObjectFactory " + ref +
70                      " Name:" + name);
71        }
72         // END OF IASRI 4660742
73
}
74     RefAddr refAddr = ref.get("url");
75     Object JavaDoc realObject = ic.lookup((String JavaDoc) refAddr.getContent());
76     if(debug) {
77         /** IASRI 4660742
78         System.out.println("Found Object:" + realObject);
79         **/

80         // START OF IASRI 4660742
81
if(_logger.isLoggable(Level.FINE)) {
82          _logger.log(Level.FINE,"Found Object:" + realObject);
83        }
84         // END OF IASRI 4660742
85
}
86     return realObject;
87     }
88
89 }
90
Popular Tags