001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)JBINamingContextImpl.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.framework.jboss;
030:
031: import java.io.Serializable;
032:
033: import java.util.Enumeration;
034: import java.util.Hashtable;
035:
036: import javax.naming.Context;
037: import javax.naming.NamingEnumeration;
038: import javax.naming.NamingException;
039: import javax.naming.OperationNotSupportedException;
040:
041: /**
042: * Naming context implementation for Jboss.
043: *
044: * @author Sun Microsystems, Inc.
045: */
046: public class JBINamingContextImpl implements Context, Serializable {
047: /**
048: * Hashtable to store bindings.
049: */
050: private Hashtable mBindings = null;
051:
052: /**
053: * Environment.
054: */
055: private Hashtable mEnvironment = null;
056:
057: /**
058: * Creates a new instance of JBINamingContextImpl.
059: */
060: public JBINamingContextImpl() {
061: mBindings = new Hashtable();
062: }
063:
064: /**
065: * Creates a new JBINamingContextImpl object.
066: *
067: * @param env environment.
068: */
069: public JBINamingContextImpl(Hashtable env) {
070: this .mEnvironment = env;
071: }
072:
073: /**
074: * Returns the environment.
075: *
076: * @return environemtn table.
077: *
078: * @throws javax.naming.NamingException if environment is not set.
079: */
080: public java.util.Hashtable getEnvironment()
081: throws javax.naming.NamingException {
082: return this .mEnvironment;
083: }
084:
085: /**
086: * Returns the binding within a namespace.
087: *
088: * @return binding.
089: *
090: * @throws javax.naming.NamingException Not supported.
091: * @throws OperationNotSupportedException Not supported.
092: */
093: public String getNameInNamespace()
094: throws javax.naming.NamingException {
095: throw new OperationNotSupportedException();
096: }
097:
098: /**
099: * Gets the name parser.
100: *
101: * @param name name.
102: *
103: * @return name parser.
104: *
105: * @throws javax.naming.NamingException Not supported.
106: * @throws OperationNotSupportedException Not supported.
107: */
108: public javax.naming.NameParser getNameParser(javax.naming.Name name)
109: throws javax.naming.NamingException {
110: throw new OperationNotSupportedException();
111: }
112:
113: /**
114: * Gets the name parser.
115: *
116: * @param name string representation of name.
117: *
118: * @return Name parser.
119: *
120: * @throws javax.naming.NamingException Not supported.
121: * @throws OperationNotSupportedException Not supported.
122: */
123: public javax.naming.NameParser getNameParser(String name)
124: throws javax.naming.NamingException {
125: throw new OperationNotSupportedException();
126: }
127:
128: /**
129: * Adds the binding to the environment values.
130: *
131: * @param propName Property name.
132: * @param propVal value.
133: *
134: * @return object that has been added.
135: *
136: * @throws javax.naming.NamingException Not supported.
137: * @throws OperationNotSupportedException Not supported.
138: */
139: public Object addToEnvironment(String propName, Object propVal)
140: throws javax.naming.NamingException {
141: throw new OperationNotSupportedException();
142: }
143:
144: /**
145: * Not supported.
146: *
147: * @param name Not supported.
148: * @param obj Not supported.Not supported.
149: *
150: * @throws javax.naming.NamingException Not supported.
151: * @throws OperationNotSupportedException Not supported.
152: */
153: public void bind(javax.naming.Name name, Object obj)
154: throws javax.naming.NamingException {
155: throw new OperationNotSupportedException();
156: }
157:
158: /**
159: * Binds the name to the object.
160: *
161: * @param name key name.
162: * @param obj object.
163: *
164: * @throws javax.naming.NamingException if name is null or not valid.
165: */
166: public void bind(String name, Object obj)
167: throws javax.naming.NamingException {
168: try {
169: this .mBindings.put(name, obj);
170: } catch (Exception e) {
171: throw new javax.naming.NamingException("Bind failed "
172: + e.getMessage());
173: }
174: }
175:
176: /**
177: * Closes the hash table.
178: *
179: * @throws javax.naming.NamingException if bindings is not intitialised.
180: */
181: public void close() throws javax.naming.NamingException {
182: this .mBindings.clear();
183: }
184:
185: /**
186: *
187: * Not supported method.
188: * @param name Not supported
189: * @param prefix Not supported
190: *
191: * @return Not supported
192: *
193: * @throws javax.naming.NamingException Not supported.
194: * @throws OperationNotSupportedException Not supported.
195: */
196: public javax.naming.Name composeName(javax.naming.Name name,
197: javax.naming.Name prefix)
198: throws javax.naming.NamingException {
199: throw new OperationNotSupportedException();
200: }
201:
202: /**
203: * Not supported.
204: *
205: * @param name Not supported.
206: * @param prefix Not supported.
207: *
208: * @return Not supported.
209: *
210: * @throws javax.naming.NamingException Not supported.
211: * @throws OperationNotSupportedException Not supported.
212: */
213: public String composeName(String name, String prefix)
214: throws javax.naming.NamingException {
215: throw new OperationNotSupportedException();
216: }
217:
218: /**
219: * Not supported.
220: *
221: * @param name Not supported.
222: *
223: * @return Not supported.
224: *
225: * @throws javax.naming.NamingException Not supported.
226: * @throws OperationNotSupportedException Not supported.
227: */
228: public Context createSubcontext(javax.naming.Name name)
229: throws javax.naming.NamingException {
230: throw new OperationNotSupportedException();
231: }
232:
233: /**
234: * Not supported.
235: *
236: * @param name Not supported.
237: *
238: * @return Not supported.
239: *
240: * @throws javax.naming.NamingException Not supported.
241: * @throws OperationNotSupportedException Not supported.
242: */
243: public Context createSubcontext(String name)
244: throws javax.naming.NamingException {
245: throw new OperationNotSupportedException();
246: }
247:
248: /**
249: * Not supported.
250: *
251: * @param name Not supported.
252: *
253: * @throws javax.naming.NamingException Not supported.
254: * @throws OperationNotSupportedException Not supported.
255: */
256: public void destroySubcontext(javax.naming.Name name)
257: throws javax.naming.NamingException {
258: throw new OperationNotSupportedException();
259: }
260:
261: /**
262: * Not supported.
263: *
264: * @param name Not supported.
265: *
266: * @throws javax.naming.NamingException Not supported.
267: * @throws OperationNotSupportedException Not supported.
268: */
269: public void destroySubcontext(String name)
270: throws javax.naming.NamingException {
271: throw new OperationNotSupportedException();
272: }
273:
274: /**
275: * Not supported.
276: *
277: * @param name Not supported.
278: *
279: * @return Not supported.
280: *
281: * @throws javax.naming.NamingException if name not found.
282: */
283: public javax.naming.NamingEnumeration list(String name)
284: throws javax.naming.NamingException {
285: Enumeration enumr = null;
286:
287: try {
288: enumr = this .mBindings.elements();
289: } catch (Exception e) {
290: e.printStackTrace();
291: throw new NamingException(e.getMessage());
292: }
293:
294: return new NamingEnumerationImpl(enumr);
295: }
296:
297: /**
298: * Not supported.
299: *
300: * @param name Not supported.
301: *
302: * @return Not supported.
303: *
304: * @throws javax.naming.NamingException Not supported.
305: * @throws OperationNotSupportedException Not supported.
306: */
307: public javax.naming.NamingEnumeration list(javax.naming.Name name)
308: throws javax.naming.NamingException {
309: throw new OperationNotSupportedException();
310: }
311:
312: /**
313: * Not supported.
314: *
315: * @param name Not supported.
316: *
317: * @return Not supported.
318: *
319: * @throws javax.naming.NamingException Not supported.
320: * @throws OperationNotSupportedException Not supported.
321: */
322: public javax.naming.NamingEnumeration listBindings(String name)
323: throws javax.naming.NamingException {
324: throw new OperationNotSupportedException();
325: }
326:
327: /**
328: * Not supported.
329: *
330: * @param name Not supported.
331: *
332: * @return Not supported.
333: *
334: * @throws javax.naming.NamingException Not supported.
335: * @throws OperationNotSupportedException Not supported.
336: */
337: public javax.naming.NamingEnumeration listBindings(
338: javax.naming.Name name) throws javax.naming.NamingException {
339: throw new OperationNotSupportedException();
340: }
341:
342: /**
343: * Retrieves the value corresponding to the key name.
344: *
345: * @param name key name.
346: *
347: * @return object value.
348: *
349: * @throws javax.naming.NamingException if name not found.
350: */
351: public Object lookup(String name)
352: throws javax.naming.NamingException {
353: Object obj = null;
354:
355: try {
356: obj = this .mBindings.get(name);
357: } catch (Exception e) {
358: throw new javax.naming.NamingException("Lookup failed "
359: + e.getMessage());
360: }
361:
362: return obj;
363: }
364:
365: /**
366: * Not supported.
367: *
368: * @param name Not supported.
369: *
370: * @return Not supported.
371: *
372: * @throws javax.naming.NamingException Not supported.
373: * @throws OperationNotSupportedException Not supported.
374: */
375: public Object lookup(javax.naming.Name name)
376: throws javax.naming.NamingException {
377: throw new OperationNotSupportedException();
378: }
379:
380: /**
381: * Not supported.
382: *
383: * @param name Not supported.
384: *
385: * @return Not supported.
386: *
387: * @throws javax.naming.NamingException Not supported.
388: * @throws OperationNotSupportedException Not supported.
389: */
390: public Object lookupLink(javax.naming.Name name)
391: throws javax.naming.NamingException {
392: throw new OperationNotSupportedException();
393: }
394:
395: /**
396: * Not supported.
397: *
398: * @param name Not supported.
399: *
400: * @return Not supported.
401: *
402: * @throws javax.naming.NamingException Not supported.
403: * @throws OperationNotSupportedException Not supported.
404: */
405: public Object lookupLink(String name)
406: throws javax.naming.NamingException {
407: throw new OperationNotSupportedException();
408: }
409:
410: /**
411: * Not supported.
412: *
413: * @param name Not supported.
414: * @param obj Not supported.
415: *
416: * @throws javax.naming.NamingException Not supported.
417: * @throws OperationNotSupportedException Not supported.
418: */
419: public void rebind(String name, Object obj)
420: throws javax.naming.NamingException {
421: throw new OperationNotSupportedException();
422: }
423:
424: /**
425: * Not supported.
426: *
427: * @param name Not supported.
428: * @param obj Not supported.
429: *
430: * @throws javax.naming.NamingException Not supported.
431: * @throws OperationNotSupportedException Not supported.
432: */
433: public void rebind(javax.naming.Name name, Object obj)
434: throws javax.naming.NamingException {
435: throw new OperationNotSupportedException();
436: }
437:
438: /**
439: * Not supported.
440: *
441: * @param propName Not supported.
442: *
443: * @return Not supported.
444: *
445: * @throws javax.naming.NamingException Not supported.
446: * @throws OperationNotSupportedException Not supported.
447: */
448: public Object removeFromEnvironment(String propName)
449: throws javax.naming.NamingException {
450: throw new OperationNotSupportedException();
451: }
452:
453: /**
454: * Not supported.
455: *
456: * @param oldName Not supported.
457: * @param newName Not supported.
458: *
459: * @throws javax.naming.NamingException Not supported.
460: * @throws OperationNotSupportedException Not supported.
461: */
462: public void rename(javax.naming.Name oldName,
463: javax.naming.Name newName)
464: throws javax.naming.NamingException {
465: throw new OperationNotSupportedException();
466: }
467:
468: /**
469: * Not supported.
470: *
471: * @param oldName Not supported.
472: * @param newName Not supported.
473: *
474: * @throws javax.naming.NamingException Not supported.
475: * @throws OperationNotSupportedException Not supported.
476: */
477: public void rename(String oldName, String newName)
478: throws javax.naming.NamingException {
479: throw new OperationNotSupportedException();
480: }
481:
482: /**
483: * Unbinds the key and value.
484: *
485: * @param name name to unbind.
486: *
487: * @throws javax.naming.NamingException if name not found.
488: */
489: public void unbind(String name) throws javax.naming.NamingException {
490: Object obj = null;
491:
492: try {
493: this .mBindings.remove(name);
494: } catch (Exception e) {
495: throw new NamingException("Cannot unbind " + e.getMessage());
496: }
497: }
498:
499: /**
500: * Not supported.
501: *
502: * @param name Not supported.
503: *
504: * @throws javax.naming.NamingException Not supported.
505: * @throws OperationNotSupportedException Not supported.
506: */
507: public void unbind(javax.naming.Name name)
508: throws javax.naming.NamingException {
509: throw new OperationNotSupportedException();
510: }
511:
512: /**
513: * Enumeration implementation.
514: *
515: * @author Sun Microsystems, Inc.
516: *
517: */
518: private class NamingEnumerationImpl implements NamingEnumeration {
519: /**
520: *
521: */
522: private Enumeration mEnumeration = null;
523:
524: /**
525: * Creates a new NamingEnumerationImpl object.
526: *
527: * @param mEnumeration enumeration.
528: */
529: NamingEnumerationImpl(Enumeration mEnumeration) {
530: this .mEnumeration = mEnumeration;
531: }
532:
533: /**
534: * Closes the mEnumeration.
535: *
536: * @throws NamingException naming exception.
537: */
538: public void close() throws NamingException {
539: this .mEnumeration = null;
540: }
541:
542: /**
543: * If there are more items.
544: *
545: * @return true if there is.
546: *
547: * @throws NamingException naming exception.
548: */
549: public boolean hasMore() throws NamingException {
550: return this .hasMoreElements();
551: }
552:
553: /**
554: * Retunrs true if the mEnumeration has more elements.
555: *
556: * @return true if there are more elements.
557: */
558: public boolean hasMoreElements() {
559: return this .mEnumeration.hasMoreElements();
560: }
561:
562: /**
563: * Retrieves the next item in the mEnumeration.
564: *
565: * @return next item.
566: *
567: * @throws NamingException naming exception.
568: */
569: public Object next() throws NamingException {
570: return this .nextElement();
571: }
572:
573: /**
574: * Retuens the next element in the mEnumeration.
575: *
576: * @return object.
577: */
578: public Object nextElement() {
579: return this.mEnumeration.nextElement();
580: }
581: }
582: }
|