1 package com.tonbeller.tbutils.res; 2 3 import java.util.Collection ; 4 import java.util.Enumeration ; 5 import java.util.HashSet ; 6 import java.util.Set ; 7 8 import javax.servlet.ServletContext ; 9 10 14 public class ServletContextResourceProvider implements ResourceProvider { 15 private ServletContext sc; 16 17 public ServletContextResourceProvider(ServletContext sc) { 18 this.sc = sc; 19 } 20 21 public String getString(String key) { 22 return sc.getInitParameter(key); 23 } 24 25 public Collection keySet() { 26 Set set = new HashSet (); 27 for (Enumeration 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 getName() { 38 return "Servlet Context Lookup"; 39 } 40 } | Popular Tags |