KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > corba > NamingContext


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA & USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library 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 library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Philippe Merle.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.corba;
28
29 /**
30  * This class encapsulates a CosNaming::NamingContext reference.
31  *
32  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
33  *
34  * @version 0.3
35  */

36
37 public class NamingContext
38 {
39     // ==================================================================
40
//
41
// Internal state.
42
//
43
// ==================================================================
44

45     /**
46      ** To store the CosNaming::NamingContext reference.
47      **/

48     private org.omg.CosNaming.NamingContext JavaDoc namingContext_;
49
50     // ==================================================================
51
//
52
// Constructor.
53
//
54
// ==================================================================
55

56     /**
57      ** The constructor.
58      **
59      ** @param namingContext The naming context to encapsulate.
60      **/

61     public
62     NamingContext(org.omg.CosNaming.NamingContext JavaDoc namingContext)
63     {
64         namingContext_ = namingContext;
65     }
66
67     // ==================================================================
68
//
69
// Internal methods.
70
//
71
// ==================================================================
72

73     // ==================================================================
74
//
75
// Public methods.
76
//
77
// ==================================================================
78

79     /**
80      ** Obtain the CosNaming::NamingContext reference.
81      **
82      ** @return The CosNaming::NamingContext reference.
83      **/

84     public org.omg.CosNaming.NamingContext JavaDoc
85     getNamingContext()
86     {
87         return namingContext_;
88     }
89
90     /**
91      ** Set the CosNaming::NamingContext reference.
92      **
93      ** @param namingContext The CosNaming::NamingContext reference.
94      **/

95     public void
96     setNamingContext(org.omg.CosNaming.NamingContext JavaDoc namingContext)
97     {
98         namingContext_ = namingContext;
99     }
100
101     /**
102      ** Convert a string path to a CosNaming::Name.
103      **
104      ** @param path The string path.
105      **
106      ** @return The associated CosNaming::Name.
107      **/

108     public static org.omg.CosNaming.NameComponent JavaDoc[]
109     toName(String JavaDoc path)
110     {
111         // TODO: Must be completed to support path and not just name.
112

113         org.omg.CosNaming.NameComponent JavaDoc[] result =
114         new org.omg.CosNaming.NameComponent JavaDoc[1];
115         result[0] = new org.omg.CosNaming.NameComponent JavaDoc(path, "");
116         return result;
117     }
118
119     /**
120      ** Rebind a path name to an object reference.
121      **
122      ** @param path The path name.
123      ** @param objRef The object reference.
124      **/

125     public void
126     rebind(String JavaDoc path,
127            org.omg.CORBA.Object JavaDoc objRef)
128     {
129         try
130         {
131             namingContext_.rebind(toName(path), objRef);
132         }
133         catch(org.omg.CosNaming.NamingContextPackage.InvalidName JavaDoc exc)
134         {
135             // Wrap the CosNaming::NamingContext::InvalidName exception.
136
throw new UserExceptionWrapper(exc);
137         }
138         catch(org.omg.CosNaming.NamingContextPackage.NotFound JavaDoc exc)
139         {
140             // Wrap the CosNaming::NamingContext::NotFound exception.
141
throw new UserExceptionWrapper(exc);
142         }
143         catch(org.omg.CosNaming.NamingContextPackage.CannotProceed JavaDoc exc)
144         {
145             // Wrap the CosNaming::NamingContext::CannotProceed exception.
146
throw new UserExceptionWrapper(exc);
147         }
148     }
149
150     /**
151      ** Unbind a path name.
152      **
153      ** @param path The path name.
154      **/

155     public void
156     unbind(String JavaDoc path)
157     {
158         try
159         {
160             namingContext_.unbind(toName(path));
161         }
162         catch(org.omg.CosNaming.NamingContextPackage.InvalidName JavaDoc exc)
163         {
164             // Wrap the CosNaming::NamingContext::InvalidName exception.
165
throw new UserExceptionWrapper(exc);
166         }
167         catch(org.omg.CosNaming.NamingContextPackage.NotFound JavaDoc exc)
168         {
169             // Wrap the CosNaming::NamingContext::NotFound exception.
170
throw new UserExceptionWrapper(exc);
171         }
172         catch(org.omg.CosNaming.NamingContextPackage.CannotProceed JavaDoc exc)
173         {
174             // Wrap the CosNaming::NamingContext::CannotProceed exception.
175
throw new UserExceptionWrapper(exc);
176         }
177     }
178 }
179
Popular Tags