KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > interop > naming > NameService


1 /**
2  *
3  * Copyright 2004-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.geronimo.interop.naming;
19
20 import java.util.HashMap JavaDoc;
21 import javax.naming.NamingException JavaDoc;
22
23 import org.apache.geronimo.interop.adapter.Adapter;
24
25 public class NameService {
26     private static NameService ns = null;
27
28     public static synchronized NameService getInstance() {
29         if (ns == null) {
30             ns = new NameService();
31             ns.init();
32             
33         }
34         return ns;
35     }
36
37     private org.apache.geronimo.interop.naming.InitialContext context;
38
39     /*
40      * TODO: Do we need this method?
41      */

42     public void bindAdapter(Adapter adp) {
43         NamingContext.getInstance(NameService.class).bindAdapter(adp);
44     }
45
46     public void unbindAdapter(Adapter adp) {
47         NamingContext.getInstance(NameService.class).unbindAdapter(adp);
48     }
49
50     public static org.apache.geronimo.interop.naming.InitialContext getInitialContext() {
51         return getInstance().context;
52     }
53
54     public HashMap JavaDoc getMap() {
55         return context.getMap();
56     }
57
58     public Object JavaDoc lookup(String JavaDoc name) throws NamingException JavaDoc {
59         return context.lookup(name);
60     }
61
62     protected void init() {
63         context = new org.apache.geronimo.interop.naming.InitialContext(null);
64     }
65 }
66
Popular Tags