KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > tbutils > res > ServletContextResourceProvider


1 package com.tonbeller.tbutils.res;
2
3 import java.util.Collection JavaDoc;
4 import java.util.Enumeration JavaDoc;
5 import java.util.HashSet JavaDoc;
6 import java.util.Set JavaDoc;
7
8 import javax.servlet.ServletContext JavaDoc;
9
10 /**
11  * Adapter for ServletContext initParameter
12  * @author av
13  */

14 public class ServletContextResourceProvider implements ResourceProvider {
15   private ServletContext JavaDoc sc;
16
17   public ServletContextResourceProvider(ServletContext JavaDoc sc) {
18     this.sc = sc;
19   }
20
21   public String JavaDoc getString(String JavaDoc key) {
22     return sc.getInitParameter(key);
23   }
24
25   public Collection JavaDoc keySet() {
26     Set JavaDoc set = new HashSet JavaDoc();
27     for (Enumeration JavaDoc en = sc.getInitParameterNames(); en.hasMoreElements();)
28       set.add(en.nextElement());
29     return set;
30   }
31
32   public void close() {
33   }
34   public void dump(Dumper d) {
35     d.dump(this);
36   }
37   public String JavaDoc getName() {
38     return "Servlet Context Lookup";
39   }
40 }
Popular Tags