KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > walend > somnifugi > SomniContext


1 package net.walend.somnifugi;
2
3 import java.util.Hashtable JavaDoc;
4
5 import javax.naming.Context JavaDoc;
6 import javax.naming.NamingException JavaDoc;
7 import javax.naming.Name JavaDoc;
8 import javax.naming.NamingEnumeration JavaDoc;
9 import javax.naming.NameParser JavaDoc;
10 import javax.naming.OperationNotSupportedException JavaDoc;
11 import javax.naming.InvalidNameException JavaDoc;
12 import javax.naming.CompositeName JavaDoc;
13 import javax.naming.NameClassPair JavaDoc;
14 import javax.naming.Binding JavaDoc;
15
16 /**
17 SomniContext is used by SomniContextFactory as a workhorse Context.
18
19 @author <a HREF="http://walend.net">David Walend</a> <a HREF="mailto:david@walend.net">david@walend.net</a>
20 @author <a HREF="http://www.jumpi.org">Peter Klauser</a> <a HREF="mailto:klp@users.sourceforge.net">klp@users.sourceforge.net</a>
21 */

22
23 public abstract class SomniContext
24     implements Context JavaDoc
25 {
26     private String JavaDoc name;
27
28     private Hashtable JavaDoc<Object JavaDoc,Object JavaDoc> environment;
29
30     SomniContext(String JavaDoc name,Hashtable JavaDoc<Object JavaDoc,Object JavaDoc> environment)
31     {
32         this.name = name;
33         this.environment = environment;
34     }
35
36     public abstract Object JavaDoc lookup(String JavaDoc name)
37         throws NamingException JavaDoc;
38     
39     public Object JavaDoc lookup(Name JavaDoc name)
40         throws NamingException JavaDoc
41     {
42         return lookup(name.toString());
43     }
44     
45     public void bind(String JavaDoc name,Object JavaDoc obj)
46         throws NamingException JavaDoc
47     {
48         throw new OperationNotSupportedException JavaDoc("Binding not supported.");
49     }
50     
51     public void bind(Name JavaDoc name,Object JavaDoc obj)
52         throws NamingException JavaDoc
53     {
54         bind(name.toString(),obj);
55     }
56     
57     public void rebind(String JavaDoc name,Object JavaDoc obj)
58         throws NamingException JavaDoc
59     {
60         throw new OperationNotSupportedException JavaDoc("Rebinding not supported.");
61     }
62     
63     public void rebind(Name JavaDoc name,Object JavaDoc obj)
64         throws NamingException JavaDoc
65     {
66         rebind(name.toString(),obj);
67     }
68     
69     public void unbind(String JavaDoc name)
70         throws NamingException JavaDoc
71     {
72         throw new OperationNotSupportedException JavaDoc("Unbind not supported.");
73     }
74
75     public void unbind(Name JavaDoc name)
76         throws NamingException JavaDoc
77     {
78         unbind(name.toString());
79     }
80     
81     public void rename(String JavaDoc oldname, String JavaDoc newname)
82         throws NamingException JavaDoc
83     {
84         throw new OperationNotSupportedException JavaDoc("Rename not supported.");
85     }
86     
87     public void rename(Name JavaDoc oldname,Name JavaDoc newname)
88         throws NamingException JavaDoc
89     {
90         rename(oldname.toString(),newname.toString());
91     }
92     
93     public NamingEnumeration JavaDoc<NameClassPair JavaDoc> list(String JavaDoc name)
94         throws NamingException JavaDoc
95     {
96         throw new OperationNotSupportedException JavaDoc("List not supported.");
97     }
98     
99     public NamingEnumeration JavaDoc<NameClassPair JavaDoc> list(Name JavaDoc name)
100         throws NamingException JavaDoc
101     {
102         return list(name.toString());
103     }
104     
105     public NamingEnumeration JavaDoc<Binding JavaDoc> listBindings(String JavaDoc name)
106         throws NamingException JavaDoc
107     {
108         throw new OperationNotSupportedException JavaDoc("ListBindings not supported.");
109     }
110     
111     public NamingEnumeration JavaDoc<Binding JavaDoc> listBindings(Name JavaDoc name)
112         throws NamingException JavaDoc
113     {
114         return listBindings(name.toString());
115     }
116     
117     public void destroySubcontext(String JavaDoc name)
118         throws NamingException JavaDoc
119     {
120         throw new OperationNotSupportedException JavaDoc("Subcontexts not supported.");
121     }
122     
123     public void destroySubcontext(Name JavaDoc name)
124         throws NamingException JavaDoc
125     {
126         destroySubcontext(name.toString());
127     }
128     
129     public Context JavaDoc createSubcontext(String JavaDoc name)
130         throws NamingException JavaDoc
131     {
132         throw new OperationNotSupportedException JavaDoc("Subcontexts not supported.");
133     }
134     
135     public Context JavaDoc createSubcontext(Name JavaDoc name)
136         throws NamingException JavaDoc
137     {
138         return createSubcontext(name.toString());
139     }
140     
141     public Object JavaDoc lookupLink(String JavaDoc name)
142         throws NamingException JavaDoc
143     {
144         return lookup(name);
145     }
146     
147     public Object JavaDoc lookupLink(Name JavaDoc name)
148         throws NamingException JavaDoc
149     {
150         return lookupLink(name.toString());
151     }
152     
153     public NameParser JavaDoc getNameParser(String JavaDoc name)
154         throws NamingException JavaDoc
155     {
156         throw new OperationNotSupportedException JavaDoc("GetNameParser not supported.");
157     }
158     
159     public NameParser JavaDoc getNameParser(Name JavaDoc name)
160         throws NamingException JavaDoc
161     {
162         return getNameParser(name.toString());
163     }
164     
165     public String JavaDoc composeName(String JavaDoc name, String JavaDoc prefix)
166         throws NamingException JavaDoc
167     {
168         Name JavaDoc result = composeName(((Name JavaDoc) (new CompositeName JavaDoc(name))), ((Name JavaDoc) (new CompositeName JavaDoc(prefix))));
169         return result.toString();
170     }
171     
172     public Name JavaDoc composeName(Name JavaDoc name, Name JavaDoc prefix)
173         throws NamingException JavaDoc
174     {
175         Name JavaDoc result = (Name JavaDoc)prefix.clone();
176         result.addAll(name);
177         return result;
178     }
179     
180     public Object JavaDoc addToEnvironment(String JavaDoc propName, Object JavaDoc propVal)
181         throws NamingException JavaDoc
182     {
183         return environment.put(propName, propVal);
184     }
185     
186     public Object JavaDoc removeFromEnvironment(String JavaDoc propName)
187         throws NamingException JavaDoc
188     {
189         return environment.remove(propName);
190     }
191     
192     public Hashtable JavaDoc<Object JavaDoc,Object JavaDoc> getEnvironment()
193         throws NamingException JavaDoc
194     {
195         return environment;
196     }
197     
198     public String JavaDoc getNameInNamespace()
199         throws NamingException JavaDoc
200     {
201         return name;
202     }
203     
204     public void close()
205         throws NamingException JavaDoc
206     {
207         //no op
208
}
209     
210 }
211 /*
212 Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 David Walend
213 All rights reserved.
214
215 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
216
217 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
218
219 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
220
221 Neither the name of the SomnifugiJMS Project, walend.net, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission from David Walend.
222
223 Credits in redistributions in source or binary forms must include a link to http://somnifugi.sourceforge.net .
224
225 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
226 The net.walend.somnifugi.sql92 package is modified code from the openmq project, https://mq.dev.java.net/ , Copyright (c) of Sun, and carries the CDDL license, repeated here: You can obtain a copy of the license at https://glassfish.dev.java.net/public/CDDLv1.0.html. See the License for the specific language governing permissions and limitations under the License.
227
228 =================================================================================
229
230 For more information and the latest version of this software, please see http://somnifugi.sourceforge.net and http://walend.net or email <a HREF="mailto:david@walend.net">david@walend.net</a>.
231
232 */

233
Popular Tags