KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > dyade > aaa > jndi2 > scn > scnURLContext


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  * Copyright (C) 2001 - 2004 ScalAgent Distributed Technologies
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18  * USA.
19  *
20  * Initial developer(s): David Feliot
21  * Contributor(s):
22  */

23 package fr.dyade.aaa.jndi2.scn;
24
25 import java.util.Hashtable JavaDoc;
26 import javax.naming.Context JavaDoc;
27 import javax.naming.Name JavaDoc;
28 import javax.naming.NameNotFoundException JavaDoc;
29 import javax.naming.NameParser JavaDoc;
30 import javax.naming.NamingEnumeration JavaDoc;
31 import javax.naming.NamingException JavaDoc;
32 import javax.naming.OperationNotSupportedException JavaDoc;
33 import javax.naming.spi.InitialContextFactory JavaDoc;
34 import javax.naming.spi.ResolveResult JavaDoc;
35
36 import fr.dyade.aaa.jndi2.client.NamingContextFactory;
37
38 import org.objectweb.util.monolog.api.BasicLevel;
39 import org.objectweb.util.monolog.api.Logger;
40
41 /**
42  * Context implementation for the "scn:comp" namespace.
43  * Package must be named .../scn (See Initial Context)
44  * Most operations consist of retrieving the actual CompNamingContext
45  * and sending it the operation for processing.
46  */

47 public class scnURLContext implements Context JavaDoc {
48
49   public final static Logger logger;
50   
51   static {
52     logger = fr.dyade.aaa.util.Debug.getLogger("fr.dyade.aaa.jndi2.scn");
53   }
54
55   static private final String JavaDoc URL_PREFIX = "scn:comp/";
56   static private final String JavaDoc ENV_PREFIX = "env";
57     
58   private Hashtable JavaDoc myEnv;
59   private InitialContextFactory JavaDoc namingFactory;
60     
61   /**
62    * Constructor
63    */

64   public scnURLContext(Hashtable JavaDoc env) throws NamingException JavaDoc {
65     if (logger.isLoggable(BasicLevel.DEBUG))
66       logger.log(BasicLevel.DEBUG,
67                  "scnURLContext.<init>(" + env + ')');
68     if (env != null) {
69       // clone env to be able to change it.
70
myEnv = (Hashtable JavaDoc)env.clone();
71
72       String JavaDoc factoryClassName = (String JavaDoc)myEnv.get("scn.naming.factory.class");
73       if (factoryClassName == null) {
74         namingFactory = new NamingContextFactory();
75       } else {
76         try {
77           Class JavaDoc factoryClass = Class.forName(factoryClassName);
78           namingFactory =
79             (InitialContextFactory JavaDoc)factoryClass.newInstance();
80         } catch (Exception JavaDoc exc) {
81           NamingException JavaDoc ne = new NamingException JavaDoc();
82           ne.setRootCause(exc);
83           throw ne;
84         }
85       }
86     }
87   }
88   
89   /*
90    * get name without the url prefix
91    */

92   private String JavaDoc getRelativeName(String JavaDoc name) throws NamingException JavaDoc {
93     // We suppose that all names must be prefixed as this
94
if (!name.startsWith(URL_PREFIX)) {
95       throw new NameNotFoundException JavaDoc("Invalid name:" + name);
96     }
97
98     name = name.substring(URL_PREFIX.length());
99     return name;
100   }
101
102   /*
103    * Resolve the name inside the javaURLContext
104    * Result must be a Context + the name in this Context
105    */

106   private ResolveResult JavaDoc findContextFor(String JavaDoc name) throws NamingException JavaDoc {
107     String JavaDoc rname = getRelativeName(name);
108     Context JavaDoc context = null;
109
110     if (rname.equals("")) {
111       // null name refers to this context
112
context = new scnURLContext(myEnv);
113     } else {
114       // other names are component independant
115
context = namingFactory.getInitialContext(myEnv);
116     }
117     
118     // Check context is not null to avoid nullPointerException
119
if (context == null) {
120       throw new NameNotFoundException JavaDoc("No context for this component");
121     }
122     
123     // Build a ResolveResult object to return
124
ResolveResult JavaDoc r = new ResolveResult JavaDoc(context, rname);
125     return r;
126   }
127
128   // ------------------------------------------------------------------
129
// Context implementation
130
// ------------------------------------------------------------------
131

132   /**
133    * Retrieves the named object.
134    *
135    * @param name the name of the object to look up
136    * @return the object bound to name
137    * @throws NamingException if a naming exception is encountered
138    */

139   public Object JavaDoc lookup(Name JavaDoc name) throws NamingException JavaDoc {
140     // Just use the string version for now.
141
return lookup(name.toString());
142   }
143
144   /**
145    * Retrieves the named object.
146    *
147    * @param name the name of the object to look up
148    * @return the object bound to name
149    * @throws NamingException if a naming exception is encountered
150    */

151   public Object JavaDoc lookup(String JavaDoc name) throws NamingException JavaDoc {
152     if (logger.isLoggable(BasicLevel.DEBUG))
153       logger.log(BasicLevel.DEBUG,
154                  "scnURLContext.lookup(" + name + ')');
155     // Name empty: returns a new instance of this context.
156
if (name.equals("")) {
157       return new scnURLContext(myEnv);
158     }
159
160     // Retrieve the correct context to resolve the reminding name
161
ResolveResult JavaDoc r = findContextFor(name);
162     Context JavaDoc ctx = (Context JavaDoc) r.getResolvedObj();
163     String JavaDoc rname = r.getRemainingName().toString();
164     
165
166     Object JavaDoc o = ctx.lookup(rname);
167     return o;
168     ////////////////////////////
169
// Resolve the name in its proper context
170
//return ctx.lookup(rname);
171
}
172     
173   /**
174    * Binds a name to an object.
175    *
176    * @param name the name to bind; may not be empty
177    * @param obj the object to bind; possibly null
178    * @throws NameAlreadyBoundException if name is already bound
179    * @throws javax.naming.directory.InvalidAttributesException
180    * if object did not supply all mandatory attributes
181    * @throws NamingException if a naming exception is encountered
182    *
183    * @see #bind(String, Object)
184    * @see #rebind(Name, Object)
185    * @see javax.naming.directory.DirContext#bind(Name, Object,
186    * javax.naming.directory.Attributes)
187    */

188   public void bind(Name JavaDoc name, Object JavaDoc obj) throws NamingException JavaDoc {
189     // Just use the string version for now.
190
bind(name.toString(), obj);
191   }
192
193   /**
194    * Binds a name to an object.
195    * All intermediate contexts and the target context (that named by all
196    * but terminal atomic component of the name) must already exist.
197    *
198    * @param name
199    * the name to bind; may not be empty
200    * @param obj
201    * the object to bind; possibly null
202    * @throws NameAlreadyBoundException if name is already bound
203    * @throws javax.naming.directory.InvalidAttributesException
204    * if object did not supply all mandatory attributes
205    * @throws NamingException if a naming exception is encountered
206    */

207   public void bind(String JavaDoc name, Object JavaDoc obj) throws NamingException JavaDoc {
208     // Retrieve the correct context for this name
209
ResolveResult JavaDoc r = findContextFor(name);
210     Context JavaDoc ctx = (Context JavaDoc) r.getResolvedObj();
211     String JavaDoc rname = r.getRemainingName().toString();
212
213     // Bind the name in its proper context
214
ctx.bind(rname, obj);
215   }
216
217   /**
218    * Binds a name to an object, overwriting any existing binding.
219    * All intermediate contexts and the target context (that named by all
220    * but terminal atomic component of the name) must already exist.
221    *
222    * If the object is a DirContext, any existing attributes
223    * associated with the name are replaced with those of the object.
224    * Otherwise, any existing attributes associated with the name remain
225    * unchanged.
226    *
227    * @param name
228    * the name to bind; may not be empty
229    * @param obj
230    * the object to bind; possibly null
231    * @throws javax.naming.directory.InvalidAttributesException
232    * if object did not supply all mandatory attributes
233    * @throws NamingException if a naming exception is encountered
234    *
235    */

236   public void rebind(Name JavaDoc name, Object JavaDoc obj) throws NamingException JavaDoc {
237     // Just use the string version for now.
238
rebind(name.toString(), obj);
239   }
240
241   /**
242    * Binds a name to an object, overwriting any existing binding.
243    * See {@link #rebind(Name, Object)} for details.
244    *
245    * @param name
246    * the name to bind; may not be empty
247    * @param obj
248    * the object to bind; possibly null
249    * @throws javax.naming.directory.InvalidAttributesException
250    * if object did not supply all mandatory attributes
251    * @throws NamingException if a naming exception is encountered
252    */

253   public void rebind(String JavaDoc name, Object JavaDoc obj) throws NamingException JavaDoc {
254     // Retrieve the correct context for this name
255
ResolveResult JavaDoc r = findContextFor(name);
256     Context JavaDoc ctx = (Context JavaDoc) r.getResolvedObj();
257     String JavaDoc rname = r.getRemainingName().toString();
258
259     // Rebind the name in its proper context
260
ctx.rebind(rname, obj);
261   }
262
263   /**
264    * Unbinds the named object.
265    * Removes the terminal atomic name in name
266    * from the target context--that named by all but the terminal
267    * atomic part of name.
268    *
269    * This method is idempotent.
270    * It succeeds even if the terminal atomic name
271    * is not bound in the target context, but throws
272    * NameNotFoundException
273    * if any of the intermediate contexts do not exist.
274    *
275    * Any attributes associated with the name are removed.
276    * Intermediate contexts are not changed.
277    *
278    * @param name
279    * the name to unbind; may not be empty
280    * @throws NameNotFoundException if an intermediate context does not exist
281    * @throws NamingException if a naming exception is encountered
282    * @see #unbind(String)
283    */

284   public void unbind(Name JavaDoc name) throws NamingException JavaDoc {
285     // Just use the string version for now.
286
unbind(name.toString());
287   }
288
289   /**
290    * Unbinds the named object.
291    * See {@link #unbind(Name)} for details.
292    *
293    * @param name
294    * the name to unbind; may not be empty
295    * @throws NameNotFoundException if an intermediate context does not exist
296    * @throws NamingException if a naming exception is encountered
297    */

298   public void unbind(String JavaDoc name) throws NamingException JavaDoc {
299     // Retrieve the correct context for this name
300
ResolveResult JavaDoc r = findContextFor(name);
301     Context JavaDoc ctx = (Context JavaDoc) r.getResolvedObj();
302     String JavaDoc rname = r.getRemainingName().toString();
303
304     // Unbind the name in its proper context
305
ctx.unbind(rname);
306   }
307
308   /**
309    * Binds a new name to the object bound to an old name, and unbinds
310    * the old name. This operation is not supported (read only env.)
311    *
312    * @param oldName
313    * the name of the existing binding; may not be empty
314    * @param newName
315    * the name of the new binding; may not be empty
316    * @throws NamingException if a naming exception is encountered
317    */

318   public void rename(Name JavaDoc oldName, Name JavaDoc newName) throws NamingException JavaDoc {
319     // Just use the string version for now.
320
rename(oldName.toString(), newName.toString());
321   }
322
323   /**
324    * Binds a new name to the object bound to an old name, and unbinds
325    * the old name. Not supported.
326    *
327    * @param oldName
328    * the name of the existing binding; may not be empty
329    * @param newName
330    * the name of the new binding; may not be empty
331    * @throws NamingException if a naming exception is encountered
332    */

333   public void rename(String JavaDoc oldName, String JavaDoc newName) throws NamingException JavaDoc {
334     throw new OperationNotSupportedException JavaDoc("Rename not supported in scn:comp in " + this.getClass().getName());
335   }
336
337   /**
338    * Enumerates the names bound in the named context, along with the
339    * class names of objects bound to them.
340    * The contents of any subcontexts are not included.
341    *
342    * If a binding is added to or removed from this context,
343    * its effect on an enumeration previously returned is undefined.
344    *
345    * @param name
346    * the name of the context to list
347    * @return an enumeration of the names and class names of the
348    * bindings in this context. Each element of the
349    * enumeration is of type NameClassPair.
350    * @throws NamingException if a naming exception is encountered
351    *
352    * @see #list(String)
353    * @see #listBindings(Name)
354    * @see NameClassPair
355    */

356   public NamingEnumeration JavaDoc list(Name JavaDoc name) throws NamingException JavaDoc {
357     // Just use the string version for now.
358
return list(name.toString());
359   }
360
361   /**
362    * Enumerates the names bound in the named context, along with the
363    * class names of objects bound to them.
364    * See {@link #list(Name)} for details.
365    *
366    * @param name
367    * the name of the context to list
368    * @return an enumeration of the names and class names of the
369    * bindings in this context. Each element of the
370    * enumeration is of type NameClassPair.
371    * @throws NamingException if a naming exception is encountered
372    */

373   public NamingEnumeration JavaDoc list(String JavaDoc name) throws NamingException JavaDoc {
374     // Retrieve the correct context to resolve the reminding name
375
ResolveResult JavaDoc r = findContextFor(name);
376     Context JavaDoc ctx = (Context JavaDoc) r.getResolvedObj();
377     String JavaDoc rname = r.getRemainingName().toString();
378
379     // List the correct Context
380
return ctx.list(rname);
381   }
382
383   /**
384    * Enumerates the names bound in the named context, along with the
385    * objects bound to them.
386    * The contents of any subcontexts are not included.
387    *
388    * If a binding is added to or removed from this context,
389    * its effect on an enumeration previously returned is undefined.
390    *
391    * @param name
392    * the name of the context to list
393    * @return an enumeration of the bindings in this context.
394    * Each element of the enumeration is of type
395    * Binding.
396    * @throws NamingException if a naming exception is encountered
397    *
398    * @see #listBindings(String)
399    * @see #list(Name)
400    * @see Binding
401    */

402   public NamingEnumeration JavaDoc listBindings(Name JavaDoc name) throws NamingException JavaDoc {
403     // Just use the string version for now.
404
return listBindings(name.toString());
405   }
406
407   /**
408    * Enumerates the names bound in the named context, along with the
409    * objects bound to them.
410    * See {@link #listBindings(Name)} for details.
411    *
412    * @param name
413    * the name of the context to list
414    * @return an enumeration of the bindings in this context.
415    * Each element of the enumeration is of type
416    * Binding.
417    * @throws NamingException if a naming exception is encountered
418    */

419   public NamingEnumeration JavaDoc listBindings(String JavaDoc name) throws NamingException JavaDoc {
420     // Retrieve the correct context to resolve the reminding name
421
ResolveResult JavaDoc r = findContextFor(name);
422     Context JavaDoc ctx = (Context JavaDoc) r.getResolvedObj();
423     String JavaDoc rname = r.getRemainingName().toString();
424
425     // List the correct Context
426
return ctx.listBindings(rname);
427   }
428
429   /**
430    * Destroys the named context and removes it from the namespace.
431    * Any attributes associated with the name are also removed.
432    * Intermediate contexts are not destroyed.
433    *
434    * This method is idempotent.
435    * It succeeds even if the terminal atomic name
436    * is not bound in the target context, but throws
437    * NameNotFoundException
438    * if any of the intermediate contexts do not exist.
439    *
440    * In a federated naming system, a context from one naming system
441    * may be bound to a name in another. One can subsequently
442    * look up and perform operations on the foreign context using a
443    * composite name. However, an attempt destroy the context using
444    * this composite name will fail with
445    * NotContextException, because the foreign context is not
446    * a "subcontext" of the context in which it is bound.
447    * Instead, use unbind() to remove the
448    * binding of the foreign context. Destroying the foreign context
449    * requires that the destroySubcontext() be performed
450    * on a context from the foreign context's "native" naming system.
451    *
452    * @param name
453    * the name of the context to be destroyed; may not be empty
454    * @throws NameNotFoundException if an intermediate context does not exist
455    * @throws NotContextException if the name is bound but does not name a
456    * context, or does not name a context of the appropriate type
457    * @throws ContextNotEmptyException if the named context is not empty
458    * @throws NamingException if a naming exception is encountered
459    *
460    * @see #destroySubcontext(String)
461    */

462   public void destroySubcontext(Name JavaDoc name) throws NamingException JavaDoc {
463     // Just use the string version for now.
464
destroySubcontext(name.toString());
465   }
466
467   /**
468    * Destroys the named context and removes it from the namespace.
469    * See {@link #destroySubcontext(Name)} for details.
470    *
471    * @param name
472    * the name of the context to be destroyed; may not be empty
473    * @throws NameNotFoundException if an intermediate context does not exist
474    * @throws NotContextException if the name is bound but does not name a
475    * context, or does not name a context of the appropriate type
476    * @throws ContextNotEmptyException if the named context is not empty
477    * @throws NamingException if a naming exception is encountered
478    */

479   public void destroySubcontext(String JavaDoc name) throws NamingException JavaDoc {
480     throw new OperationNotSupportedException JavaDoc("destroySubcontext not supported in scn:comp in " + this.getClass().getName());
481   }
482
483   /**
484    * Creates and binds a new context.
485    * Creates a new context with the given name and binds it in
486    * the target context (that named by all but terminal atomic
487    * component of the name). All intermediate contexts and the
488    * target context must already exist.
489    *
490    * @param name
491    * the name of the context to create; may not be empty
492    * @return the newly created context
493    *
494    * @throws NameAlreadyBoundException if name is already bound
495    * @throws javax.naming.directory.InvalidAttributesException
496    * if creation of the subcontext requires specification of
497    * mandatory attributes
498    * @throws NamingException if a naming exception is encountered
499    *
500    * @see #createSubcontext(String)
501    * @see javax.naming.directory.DirContext#createSubcontext
502    */

503   public Context JavaDoc createSubcontext(Name JavaDoc name) throws NamingException JavaDoc {
504     // Just use the string version for now.
505
return createSubcontext(name.toString());
506   }
507
508   /**
509    * Creates and binds a new context.
510    * See {@link #createSubcontext(Name)} for details.
511    *
512    * @param name
513    * the name of the context to create; may not be empty
514    * @return the newly created context
515    *
516    * @throws NameAlreadyBoundException if name is already bound
517    * @throws javax.naming.directory.InvalidAttributesException
518    * if creation of the subcontext requires specification of
519    * mandatory attributes
520    * @throws NamingException if a naming exception is encountered
521    */

522   public Context JavaDoc createSubcontext(String JavaDoc name) throws NamingException JavaDoc {
523     // Retrieve the correct context to resolve the reminding name
524
ResolveResult JavaDoc r = findContextFor(name);
525     Context JavaDoc ctx = (Context JavaDoc) r.getResolvedObj();
526     String JavaDoc rname = r.getRemainingName().toString();
527     
528     // create subcontext
529
return ctx.createSubcontext(rname);
530   }
531
532   /**
533    * Retrieves the named object, following links except
534    * for the terminal atomic component of the name.
535    * If the object bound to name is not a link,
536    * returns the object itself.
537    *
538    * @param name
539    * the name of the object to look up
540    * @return the object bound to name, not following the
541    * terminal link (if any).
542    * @throws NamingException if a naming exception is encountered
543    *
544    * @see #lookupLink(String)
545    */

546   public Object JavaDoc lookupLink(Name JavaDoc name) throws NamingException JavaDoc {
547     // Just use the string version for now.
548
return lookupLink(name.toString());
549   }
550
551   /**
552    * Retrieves the named object, following links except
553    * for the terminal atomic component of the name.
554    * See {@link #lookupLink(Name)} for details.
555    *
556    * @param name
557    * the name of the object to look up
558    * @return the object bound to name, not following the
559    * terminal link (if any)
560    * @throws NamingException if a naming exception is encountered
561    */

562   public Object JavaDoc lookupLink(String JavaDoc name) throws NamingException JavaDoc {
563     // Name empty: returns a new instance of this context.
564
if (name.equals("")) {
565       return new scnURLContext(myEnv);
566     }
567
568     // Retrieve the correct context to resolve the reminding name
569
ResolveResult JavaDoc r = findContextFor(name);
570     Context JavaDoc ctx = (Context JavaDoc) r.getResolvedObj();
571     String JavaDoc rname = r.getRemainingName().toString();
572
573     // Resolve the name in its proper context
574
return ctx.lookupLink(rname);
575   }
576
577   /**
578    * Retrieves the parser associated with the named context.
579    * In a federation of namespaces, different naming systems will
580    * parse names differently. This method allows an application
581    * to get a parser for parsing names into their atomic components
582    * using the naming convention of a particular naming system.
583    * Within any single naming system, NameParser objects
584    * returned by this method must be equal (using the equals()
585    * test).
586    *
587    * @param name
588    * the name of the context from which to get the parser
589    * @return a name parser that can parse compound names into their atomic
590    * components
591    * @throws NamingException if a naming exception is encountered
592    *
593    * @see #getNameParser(String)
594    * @see CompoundName
595    */

596   public NameParser JavaDoc getNameParser(Name JavaDoc name) throws NamingException JavaDoc {
597     return null;
598   }
599
600   /**
601    * Retrieves the parser associated with the named context.
602    * See {@link #getNameParser(Name)} for details.
603    *
604    * @param name
605    * the name of the context from which to get the parser
606    * @return a name parser that can parse compound names into their atomic
607    * components
608    * @throws NamingException if a naming exception is encountered
609    */

610   public NameParser JavaDoc getNameParser(String JavaDoc name) throws NamingException JavaDoc {
611     return null;
612   }
613
614   /**
615    * Composes the name of this context with a name relative to
616    * this context.
617    *
618    * @param name
619    * a name relative to this context
620    * @param prefix
621    * the name of this context relative to one of its ancestors
622    * @return the composition of prefix and name
623    * @throws NamingException if a naming exception is encountered
624    *
625    * @see #composeName(String, String)
626    */

627   public Name JavaDoc composeName(Name JavaDoc name, Name JavaDoc prefix) throws NamingException JavaDoc {
628     throw new OperationNotSupportedException JavaDoc("scnURLContext: composeName not supported");
629   }
630
631   /**
632    * Composes the name of this context with a name relative to
633    * this context: Not supported.
634    *
635    * @param name
636    * a name relative to this context
637    * @param prefix
638    * the name of this context relative to one of its ancestors
639    * @return the composition of prefix and name
640    * @throws NamingException if a naming exception is encountered
641    */

642   public String JavaDoc composeName(String JavaDoc name, String JavaDoc prefix) throws NamingException JavaDoc {
643     throw new OperationNotSupportedException JavaDoc("composeName not supported in scn:comp in " + this.getClass().getName());
644   }
645
646   /**
647    * Adds a new environment property to the environment of this
648    * context. If the property already exists, its value is overwritten.
649    * See class description for more details on environment properties.
650    *
651    * @param propName
652    * the name of the environment property to add; may not be null
653    * @param propVal
654    * the value of the property to add; may not be null
655    * @return the previous value of the property, or null if the property was
656    * not in the environment before
657    * @throws NamingException if a naming exception is encountered
658    *
659    * @see #getEnvironment()
660    * @see #removeFromEnvironment(String)
661    */

662   public Object JavaDoc addToEnvironment(String JavaDoc propName, Object JavaDoc propVal) throws NamingException JavaDoc {
663     if (myEnv == null) {
664       myEnv = new Hashtable JavaDoc();
665     }
666     return myEnv.put(propName, propVal);
667   }
668
669   /**
670    * Removes an environment property from the environment of this
671    * context. See class description for more details on environment
672    * properties.
673    *
674    * @param propName
675    * the name of the environment property to remove; may not be null
676    * @return the previous value of the property, or null if the property was
677    * not in the environment
678    * @throws NamingException if a naming exception is encountered
679    *
680    * @see #getEnvironment()
681    * @see #addToEnvironment(String, Object)
682    */

683   public Object JavaDoc removeFromEnvironment(String JavaDoc propName) throws NamingException JavaDoc {
684     if (myEnv == null) {
685       return null;
686     }
687     return myEnv.remove(propName);
688   }
689
690   /**
691    * Retrieves the environment in effect for this context.
692    * See class description for more details on environment properties.
693    *
694    * The caller should not make any changes to the object returned:
695    * their effect on the context is undefined.
696    * The environment of this context may be changed using
697    * addToEnvironment() and removeFromEnvironment().
698    *
699    * @return the environment of this context; never null
700    * @throws NamingException if a naming exception is encountered
701    *
702    * @see #addToEnvironment(String, Object)
703    * @see #removeFromEnvironment(String)
704    */

705   public Hashtable JavaDoc getEnvironment() throws NamingException JavaDoc {
706     if (myEnv == null) {
707       myEnv = new Hashtable JavaDoc();
708     }
709     return myEnv;
710   }
711
712   /**
713    * Closes this context.
714    * This method releases this context's resources immediately, instead of
715    * waiting for them to be released automatically by the garbage collector.
716    *
717    * This method is idempotent: invoking it on a context that has
718    * already been closed has no effect. Invoking any other method
719    * on a closed context is not allowed, and results in undefined behaviour.
720    *
721    * @throws NamingException if a naming exception is encountered
722    */

723   public void close() throws NamingException JavaDoc {
724     myEnv = null;
725   }
726
727   /**
728    * Retrieves the full name of this context within its own namespace.
729    * Not implemented.
730    *
731    * @return this context's name in its own namespace; never null
732    * @throws OperationNotSupportedException if the naming system does
733    * not have the notion of a full name
734    * @throws NamingException if a naming exception is encountered
735    */

736   public String JavaDoc getNameInNamespace() throws NamingException JavaDoc {
737     throw new OperationNotSupportedException JavaDoc("getNameInNamespace not implemented in scn:comp in " + this.getClass().getName());
738   }
739 }
740
741
Popular Tags