|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
DummyContext.java | - | 14.3% | 13.8% | 14% |
|
1 | package org.jboss.cache.transaction; | |
2 | ||
3 | import javax.naming.Binding; | |
4 | import javax.naming.CompoundName; | |
5 | import javax.naming.Context; | |
6 | import javax.naming.ContextNotEmptyException; | |
7 | import javax.naming.Name; | |
8 | import javax.naming.NameAlreadyBoundException; | |
9 | import javax.naming.NameClassPair; | |
10 | import javax.naming.NameNotFoundException; | |
11 | import javax.naming.NameParser; | |
12 | import javax.naming.NamingEnumeration; | |
13 | import javax.naming.NamingException; | |
14 | import javax.naming.NotContextException; | |
15 | import javax.naming.OperationNotSupportedException; | |
16 | import javax.naming.directory.Attributes; | |
17 | import javax.naming.directory.DirContext; | |
18 | import javax.naming.directory.InvalidAttributesException; | |
19 | import java.util.HashMap; | |
20 | import java.util.Hashtable; | |
21 | ||
22 | /** | |
23 | * @author bela | |
24 | * Date: May 15, 2003 | |
25 | * Time: 6:21:37 PM | |
26 | */ | |
27 | public class DummyContext implements Context | |
28 | { | |
29 | ||
30 | HashMap bindings = new HashMap(); | |
31 | ||
32 | /** | |
33 | * Retrieves the named object. | |
34 | * If <tt>name</tt> is empty, returns a new instance of this context | |
35 | * (which represents the same naming context as this context, but its | |
36 | * environment may be modified independently and it may be accessed | |
37 | * concurrently). | |
38 | * | |
39 | * @param name the name of the object to look up | |
40 | * @return the object bound to <tt>name</tt> | |
41 | * @throws NamingException if a naming exception is encountered | |
42 | * @see #lookup(String) | |
43 | * @see #lookupLink(Name) | |
44 | */ | |
45 | 0 | public Object lookup(Name name) throws NamingException |
46 | { | |
47 | 0 | return null; |
48 | } | |
49 | ||
50 | /** | |
51 | * Retrieves the named object. | |
52 | * See {@link #lookup(Name)} for details. | |
53 | * | |
54 | * @param name the name of the object to look up | |
55 | * @return the object bound to <tt>name</tt> | |
56 | * @throws NamingException if a naming exception is encountered | |
57 | */ | |
58 | 20713 | public Object lookup(String name) throws NamingException |
59 | { | |
60 | 20713 | return bindings.get(name); |
61 | } | |
62 | ||
63 | /** | |
64 | * Binds a name to an object. | |
65 | * All intermediate contexts and the target context (that named by all | |
66 | * but terminal atomic component of the name) must already exist. | |
67 | * | |
68 | * @param name the name to bind; may not be empty | |
69 | * @param obj the object to bind; possibly null | |
70 | * @throws NameAlreadyBoundException if name is already bound | |
71 | * @throws InvalidAttributesException if object did not supply all mandatory attributes | |
72 | * @throws NamingException if a naming exception is encountered | |
73 | * @see #bind(String,Object) | |
74 | * @see #rebind(Name,Object) | |
75 | * @see DirContext#bind(Name,Object, | |
76 | *Attributes) | |
77 | */ | |
78 | 0 | public void bind(Name name, Object obj) throws NamingException |
79 | { | |
80 | } | |
81 | ||
82 | /** | |
83 | * Binds a name to an object. | |
84 | * See {@link #bind(Name,Object)} for details. | |
85 | * | |
86 | * @param name the name to bind; may not be empty | |
87 | * @param obj the object to bind; possibly null | |
88 | * @throws NameAlreadyBoundException if name is already bound | |
89 | * @throws InvalidAttributesException if object did not supply all mandatory attributes | |
90 | * @throws NamingException if a naming exception is encountered | |
91 | */ | |
92 | 741 | public void bind(String name, Object obj) throws NamingException |
93 | { | |
94 | 741 | bindings.put(name, obj); |
95 | } | |
96 | ||
97 | /** | |
98 | * Binds a name to an object, overwriting any existing binding. | |
99 | * All intermediate contexts and the target context (that named by all | |
100 | * but terminal atomic component of the name) must already exist. | |
101 | * <p/> | |
102 | * <p> If the object is a <tt>DirContext</tt>, any existing attributes | |
103 | * associated with the name are replaced with those of the object. | |
104 | * Otherwise, any existing attributes associated with the name remain | |
105 | * unchanged. | |
106 | * | |
107 | * @param name the name to bind; may not be empty | |
108 | * @param obj the object to bind; possibly null | |
109 | * @throws InvalidAttributesException if object did not supply all mandatory attributes | |
110 | * @throws NamingException if a naming exception is encountered | |
111 | * @see #rebind(String,Object) | |
112 | * @see #bind(Name,Object) | |
113 | * @see DirContext#rebind(Name,Object, | |
114 | *Attributes) | |
115 | * @see DirContext | |
116 | */ | |
117 | 0 | public void rebind(Name name, Object obj) throws NamingException |
118 | { | |
119 | } | |
120 | ||
121 | /** | |
122 | * Binds a name to an object, overwriting any existing binding. | |
123 | * See {@link #rebind(Name,Object)} for details. | |
124 | * | |
125 | * @param name the name to bind; may not be empty | |
126 | * @param obj the object to bind; possibly null | |
127 | * @throws InvalidAttributesException if object did not supply all mandatory attributes | |
128 | * @throws NamingException if a naming exception is encountered | |
129 | */ | |
130 | 0 | public void rebind(String name, Object obj) throws NamingException |
131 | { | |
132 | 0 | bindings.put(name, obj); |
133 | } | |
134 | ||
135 | /** | |
136 | * Unbinds the named object. | |
137 | * Removes the terminal atomic name in <code>name</code> | |
138 | * from the target context--that named by all but the terminal | |
139 | * atomic part of <code>name</code>. | |
140 | * <p/> | |
141 | * <p> This method is idempotent. | |
142 | * It succeeds even if the terminal atomic name | |
143 | * is not bound in the target context, but throws | |
144 | * <tt>NameNotFoundException</tt> | |
145 | * if any of the intermediate contexts do not exist. | |
146 | * <p/> | |
147 | * <p> Any attributes associated with the name are removed. | |
148 | * Intermediate contexts are not changed. | |
149 | * | |
150 | * @param name the name to unbind; may not be empty | |
151 | * @throws NameNotFoundException if an intermediate context does not exist | |
152 | * @throws NamingException if a naming exception is encountered | |
153 | * @see #unbind(String) | |
154 | */ | |
155 | 0 | public void unbind(Name name) throws NamingException |
156 | { | |
157 | } | |
158 | ||
159 | /** | |
160 | * Unbinds the named object. | |
161 | * See {@link #unbind(Name)} for details. | |
162 | * | |
163 | * @param name the name to unbind; may not be empty | |
164 | * @throws NameNotFoundException if an intermediate context does not exist | |
165 | * @throws NamingException if a naming exception is encountered | |
166 | */ | |
167 | 333 | public void unbind(String name) throws NamingException |
168 | { | |
169 | 333 | bindings.remove(name); |
170 | } | |
171 | ||
172 | /** | |
173 | * Binds a new name to the object bound to an old name, and unbinds | |
174 | * the old name. Both names are relative to this context. | |
175 | * Any attributes associated with the old name become associated | |
176 | * with the new name. | |
177 | * Intermediate contexts of the old name are not changed. | |
178 | * | |
179 | * @param oldName the name of the existing binding; may not be empty | |
180 | * @param newName the name of the new binding; may not be empty | |
181 | * @throws NameAlreadyBoundException if <tt>newName</tt> is already bound | |
182 | * @throws NamingException if a naming exception is encountered | |
183 | * @see #rename(String,String) | |
184 | * @see #bind(Name,Object) | |
185 | * @see #rebind(Name,Object) | |
186 | */ | |
187 | 0 | public void rename(Name oldName, Name newName) throws NamingException |
188 | { | |
189 | } | |
190 | ||
191 | /** | |
192 | * Binds a new name to the object bound to an old name, and unbinds | |
193 | * the old name. | |
194 | * See {@link #rename(Name,Name)} for details. | |
195 | * | |
196 | * @param oldName the name of the existing binding; may not be empty | |
197 | * @param newName the name of the new binding; may not be empty | |
198 | * @throws NameAlreadyBoundException if <tt>newName</tt> is already bound | |
199 | * @throws NamingException if a naming exception is encountered | |
200 | */ | |
201 | 0 | public void rename(String oldName, String newName) throws NamingException |
202 | { | |
203 | } | |
204 | ||
205 | /** | |
206 | * Enumerates the names bound in the named context, along with the | |
207 | * class names of objects bound to them. | |
208 | * The contents of any subcontexts are not included. | |
209 | * <p/> | |
210 | * <p> If a binding is added to or removed from this context, | |
211 | * its effect on an enumeration previously returned is undefined. | |
212 | * | |
213 | * @param name the name of the context to list | |
214 | * @return an enumeration of the names and class names of the | |
215 | * bindings in this context. Each element of the | |
216 | * enumeration is of type <tt>NameClassPair</tt>. | |
217 | * @throws NamingException if a naming exception is encountered | |
218 | * @see #list(String) | |
219 | * @see #listBindings(Name) | |
220 | * @see NameClassPair | |
221 | */ | |
222 | 0 | public NamingEnumeration list(Name name) throws NamingException |
223 | { | |
224 | 0 | return null; |
225 | } | |
226 | ||
227 | /** | |
228 | * Enumerates the names bound in the named context, along with the | |
229 | * class names of objects bound to them. | |
230 | * See {@link #list(Name)} for details. | |
231 | * | |
232 | * @param name the name of the context to list | |
233 | * @return an enumeration of the names and class names of the | |
234 | * bindings in this context. Each element of the | |
235 | * enumeration is of type <tt>NameClassPair</tt>. | |
236 | * @throws NamingException if a naming exception is encountered | |
237 | */ | |
238 | 0 | public NamingEnumeration list(String name) throws NamingException |
239 | { | |
240 | 0 | return null; |
241 | } | |
242 | ||
243 | /** | |
244 | * Enumerates the names bound in the named context, along with the | |
245 | * objects bound to them. | |
246 | * The contents of any subcontexts are not included. | |
247 | * <p/> | |
248 | * <p> If a binding is added to or removed from this context, | |
249 | * its effect on an enumeration previously returned is undefined. | |
250 | * | |
251 | * @param name the name of the context to list | |
252 | * @return an enumeration of the bindings in this context. | |
253 | * Each element of the enumeration is of type | |
254 | * <tt>Binding</tt>. | |
255 | * @throws NamingException if a naming exception is encountered | |
256 | * @see #listBindings(String) | |
257 | * @see #list(Name) | |
258 | * @see Binding | |
259 | */ | |
260 | 0 | public NamingEnumeration listBindings(Name name) throws NamingException |
261 | { | |
262 | 0 | return null; |
263 | } | |
264 | ||
265 | /** | |
266 | * Enumerates the names bound in the named context, along with the | |
267 | * objects bound to them. | |
268 | * See {@link #listBindings(Name)} for details. | |
269 | * | |
270 | * @param name the name of the context to list | |
271 | * @return an enumeration of the bindings in this context. | |
272 | * Each element of the enumeration is of type | |
273 | * <tt>Binding</tt>. | |
274 | * @throws NamingException if a naming exception is encountered | |
275 | */ | |
276 | 0 | public NamingEnumeration listBindings(String name) throws NamingException |
277 | { | |
278 | 0 | return null; |
279 | } | |
280 | ||
281 | /** | |
282 | * Destroys the named context and removes it from the namespace. | |
283 | * Any attributes associated with the name are also removed. | |
284 | * Intermediate contexts are not destroyed. | |
285 | * <p/> | |
286 | * <p> This method is idempotent. | |
287 | * It succeeds even if the terminal atomic name | |
288 | * is not bound in the target context, but throws | |
289 | * <tt>NameNotFoundException</tt> | |
290 | * if any of the intermediate contexts do not exist. | |
291 | * <p/> | |
292 | * <p> In a federated naming system, a context from one naming system | |
293 | * may be bound to a name in another. One can subsequently | |
294 | * look up and perform operations on the foreign context using a | |
295 | * composite name. However, an attempt destroy the context using | |
296 | * this composite name will fail with | |
297 | * <tt>NotContextException</tt>, because the foreign context is not | |
298 | * a "subcontext" of the context in which it is bound. | |
299 | * Instead, use <tt>unbind()</tt> to remove the | |
300 | * binding of the foreign context. Destroying the foreign context | |
301 | * requires that the <tt>destroySubcontext()</tt> be performed | |
302 | * on a context from the foreign context's "native" naming system. | |
303 | * | |
304 | * @param name the name of the context to be destroyed; may not be empty | |
305 | * @throws NameNotFoundException if an intermediate context does not exist | |
306 | * @throws NotContextException if the name is bound but does not name a | |
307 | * context, or does not name a context of the appropriate type | |
308 | * @throws ContextNotEmptyException if the named context is not empty | |
309 | * @throws NamingException if a naming exception is encountered | |
310 | * @see #destroySubcontext(String) | |
311 | */ | |
312 | 0 | public void destroySubcontext(Name name) throws NamingException |
313 | { | |
314 | } | |
315 | ||
316 | /** | |
317 | * Destroys the named context and removes it from the namespace. | |
318 | * See {@link #destroySubcontext(Name)} for details. | |
319 | * | |
320 | * @param name the name of the context to be destroyed; may not be empty | |
321 | * @throws NameNotFoundException if an intermediate context does not exist | |
322 | * @throws NotContextException if the name is bound but does not name a | |
323 | * context, or does not name a context of the appropriate type | |
324 | * @throws ContextNotEmptyException if the named context is not empty | |
325 | * @throws NamingException if a naming exception is encountered | |
326 | */ | |
327 | 0 | public void destroySubcontext(String name) throws NamingException |
328 | { | |
329 | } | |
330 | ||
331 | /** | |
332 | * Creates and binds a new context. | |
333 | * Creates a new context with the given name and binds it in | |
334 | * the target context (that named by all but terminal atomic | |
335 | * component of the name). All intermediate contexts and the | |
336 | * target context must already exist. | |
337 | * | |
338 | * @param name the name of the context to create; may not be empty | |
339 | * @return the newly created context | |
340 | * @throws NameAlreadyBoundException if name is already bound | |
341 | * @throws InvalidAttributesException if creation of the subcontext requires specification of | |
342 | * mandatory attributes | |
343 | * @throws NamingException if a naming exception is encountered | |
344 | * @see #createSubcontext(String) | |
345 | * @see DirContext#createSubcontext | |
346 | */ | |
347 | 0 | public Context createSubcontext(Name name) throws NamingException |
348 | { | |
349 | 0 | return null; |
350 | } | |
351 | ||
352 | /** | |
353 | * Creates and binds a new context. | |
354 | * See {@link #createSubcontext(Name)} for details. | |
355 | * | |
356 | * @param name the name of the context to create; may not be empty | |
357 | * @return the newly created context | |
358 | * @throws NameAlreadyBoundException if name is already bound | |
359 | * @throws InvalidAttributesException if creation of the subcontext requires specification of | |
360 | * mandatory attributes | |
361 | * @throws NamingException if a naming exception is encountered | |
362 | */ | |
363 | 0 | public Context createSubcontext(String name) throws NamingException |
364 | { | |
365 | 0 | return null; |
366 | } | |
367 | ||
368 | /** | |
369 | * Retrieves the named object, following links except | |
370 | * for the terminal atomic component of the name. | |
371 | * If the object bound to <tt>name</tt> is not a link, | |
372 | * returns the object itself. | |
373 | * | |
374 | * @param name the name of the object to look up | |
375 | * @return the object bound to <tt>name</tt>, not following the | |
376 | * terminal link (if any). | |
377 | * @throws NamingException if a naming exception is encountered | |
378 | * @see #lookupLink(String) | |
379 | */ | |
380 | 0 | public Object lookupLink(Name name) throws NamingException |
381 | { | |
382 | 0 | return null; |
383 | } | |
384 | ||
385 | /** | |
386 | * Retrieves the named object, following links except | |
387 | * for the terminal atomic component of the name. | |
388 | * See {@link #lookupLink(Name)} for details. | |
389 | * | |
390 | * @param name the name of the object to look up | |
391 | * @return the object bound to <tt>name</tt>, not following the | |
392 | * terminal link (if any) | |
393 | * @throws NamingException if a naming exception is encountered | |
394 | */ | |
395 | 0 | public Object lookupLink(String name) throws NamingException |
396 | { | |
397 | 0 | return null; |
398 | } | |
399 | ||
400 | /** | |
401 | * Retrieves the parser associated with the named context. | |
402 | * In a federation of namespaces, different naming systems will | |
403 | * parse names differently. This method allows an application | |
404 | * to get a parser for parsing names into their atomic components | |
405 | * using the naming convention of a particular naming system. | |
406 | * Within any single naming system, <tt>NameParser</tt> objects | |
407 | * returned by this method must be equal (using the <tt>equals()</tt> | |
408 | * test). | |
409 | * | |
410 | * @param name the name of the context from which to get the parser | |
411 | * @return a name parser that can parse compound names into their atomic | |
412 | * components | |
413 | * @throws NamingException if a naming exception is encountered | |
414 | * @see #getNameParser(String) | |
415 | * @see CompoundName | |
416 | */ | |
417 | 0 | public NameParser getNameParser(Name name) throws NamingException |
418 | { | |
419 | 0 | return null; |
420 | } | |
421 | ||
422 | /** | |
423 | * Retrieves the parser associated with the named context. | |
424 | * See {@link #getNameParser(Name)} for details. | |
425 | * | |
426 | * @param name the name of the context from which to get the parser | |
427 | * @return a name parser that can parse compound names into their atomic | |
428 | * components | |
429 | * @throws NamingException if a naming exception is encountered | |
430 | */ | |
431 | 0 | public NameParser getNameParser(String name) throws NamingException |
432 | { | |
433 | 0 | return null; |
434 | } | |
435 | ||
436 | /** | |
437 | * Composes the name of this context with a name relative to | |
438 | * this context. | |
439 | * Given a name (<code>name</code>) relative to this context, and | |
440 | * the name (<code>prefix</code>) of this context relative to one | |
441 | * of its ancestors, this method returns the composition of the | |
442 | * two names using the syntax appropriate for the naming | |
443 | * system(s) involved. That is, if <code>name</code> names an | |
444 | * object relative to this context, the result is the name of the | |
445 | * same object, but relative to the ancestor context. None of the | |
446 | * names may be null. | |
447 | * <p/> | |
448 | * For example, if this context is named "wiz.com" relative | |
449 | * to the initial context, then | |
450 | * <pre> | |
451 | * composeName("east", "wiz.com") </pre> | |
452 | * might return <code>"east.wiz.com"</code>. | |
453 | * If instead this context is named "org/research", then | |
454 | * <pre> | |
455 | * composeName("user/jane", "org/research") </pre> | |
456 | * might return <code>"org/research/user/jane"</code> while | |
457 | * <pre> | |
458 | * composeName("user/jane", "research") </pre> | |
459 | * returns <code>"research/user/jane"</code>. | |
460 | * | |
461 | * @param name a name relative to this context | |
462 | * @param prefix the name of this context relative to one of its ancestors | |
463 | * @return the composition of <code>prefix</code> and <code>name</code> | |
464 | * @throws NamingException if a naming exception is encountered | |
465 | * @see #composeName(String,String) | |
466 | */ | |
467 | 0 | public Name composeName(Name name, Name prefix) throws NamingException |
468 | { | |
469 | 0 | return null; |
470 | } | |
471 | ||
472 | /** | |
473 | * Composes the name of this context with a name relative to | |
474 | * this context. | |
475 | * See {@link #composeName(Name,Name)} for details. | |
476 | * | |
477 | * @param name a name relative to this context | |
478 | * @param prefix the name of this context relative to one of its ancestors | |
479 | * @return the composition of <code>prefix</code> and <code>name</code> | |
480 | * @throws NamingException if a naming exception is encountered | |
481 | */ | |
482 | 0 | public String composeName(String name, String prefix) |
483 | throws NamingException | |
484 | { | |
485 | 0 | return null; |
486 | } | |
487 | ||
488 | /** | |
489 | * Adds a new environment property to the environment of this | |
490 | * context. If the property already exists, its value is overwritten. | |
491 | * See class description for more details on environment properties. | |
492 | * | |
493 | * @param propName the name of the environment property to add; may not be null | |
494 | * @param propVal the value of the property to add; may not be null | |
495 | * @return the previous value of the property, or null if the property was | |
496 | * not in the environment before | |
497 | * @throws NamingException if a naming exception is encountered | |
498 | * @see #getEnvironment() | |
499 | * @see #removeFromEnvironment(String) | |
500 | */ | |
501 | 0 | public Object addToEnvironment(String propName, Object propVal) |
502 | throws NamingException | |
503 | { | |
504 | 0 | return null; |
505 | } | |
506 | ||
507 | /** | |
508 | * Removes an environment property from the environment of this | |
509 | * context. See class description for more details on environment | |
510 | * properties. | |
511 | * | |
512 | * @param propName the name of the environment property to remove; may not be null | |
513 | * @return the previous value of the property, or null if the property was | |
514 | * not in the environment | |
515 | * @throws NamingException if a naming exception is encountered | |
516 | * @see #getEnvironment() | |
517 | * @see #addToEnvironment(String,Object) | |
518 | */ | |
519 | 0 | public Object removeFromEnvironment(String propName) |
520 | throws NamingException | |
521 | { | |
522 | 0 | return null; |
523 | } | |
524 | ||
525 | /** | |
526 | * Retrieves the environment in effect for this context. | |
527 | * See class description for more details on environment properties. | |
528 | * <p/> | |
529 | * <p> The caller should not make any changes to the object returned: | |
530 | * their effect on the context is undefined. | |
531 | * The environment of this context may be changed using | |
532 | * <tt>addToEnvironment()</tt> and <tt>removeFromEnvironment()</tt>. | |
533 | * | |
534 | * @return the environment of this context; never null | |
535 | * @throws NamingException if a naming exception is encountered | |
536 | * @see #addToEnvironment(String,Object) | |
537 | * @see #removeFromEnvironment(String) | |
538 | */ | |
539 | 0 | public Hashtable getEnvironment() throws NamingException |
540 | { | |
541 | 0 | return null; |
542 | } | |
543 | ||
544 | /** | |
545 | * Closes this context. | |
546 | * This method releases this context's resources immediately, instead of | |
547 | * waiting for them to be released automatically by the garbage collector. | |
548 | * <p/> | |
549 | * <p> This method is idempotent: invoking it on a context that has | |
550 | * already been closed has no effect. Invoking any other method | |
551 | * on a closed context is not allowed, and results in undefined behaviour. | |
552 | * | |
553 | * @throws NamingException if a naming exception is encountered | |
554 | */ | |
555 | 63 | public void close() throws NamingException |
556 | { | |
557 | } | |
558 | ||
559 | /** | |
560 | * Retrieves the full name of this context within its own namespace. | |
561 | * <p/> | |
562 | * <p> Many naming services have a notion of a "full name" for objects | |
563 | * in their respective namespaces. For example, an LDAP entry has | |
564 | * a distinguished name, and a DNS record has a fully qualified name. | |
565 | * This method allows the client application to retrieve this name. | |
566 | * The string returned by this method is not a JNDI composite name | |
567 | * and should not be passed directly to context methods. | |
568 | * In naming systems for which the notion of full name does not | |
569 | * make sense, <tt>OperationNotSupportedException</tt> is thrown. | |
570 | * | |
571 | * @return this context's name in its own namespace; never null | |
572 | * @throws OperationNotSupportedException if the naming system does | |
573 | * not have the notion of a full name | |
574 | * @throws NamingException if a naming exception is encountered | |
575 | * @since 1.3 | |
576 | */ | |
577 | 0 | public String getNameInNamespace() throws NamingException |
578 | { | |
579 | 0 | return null; |
580 | } | |
581 | } |
|