1 4 package dwr; 5 6 import uk.ltd.getahead.dwr.CreatorManager; 7 import uk.ltd.getahead.dwr.Creator; 8 import uk.ltd.getahead.dwr.ExecutionContext; 9 import org.w3c.dom.Element ; 10 11 import javax.servlet.http.HttpSession ; 12 import java.util.Collection ; 13 import java.util.Map ; 14 import java.util.HashMap ; 15 16 20 public class SessionCreatorManager 21 implements CreatorManager 22 { 23 static ThreadLocal sessions = new ThreadLocal (); 24 boolean debug; 25 26 public SessionCreatorManager() { 27 } 28 29 public boolean isDebug() { 30 return debug; 31 } 32 33 public void setDebug(boolean debug) { 34 this.debug = debug; 35 } 36 37 public void addCreatorType(String typename, Class clazz) { 38 } 39 40 public void addCreator(String type, String javascript, Element allower) { 41 } 42 43 public Collection getCreatorNames() { 44 Map map = getCreatorMap(); 45 return map.keySet(); 46 } 47 48 public Creator getCreator(String name) { 49 Map map = getCreatorMap(); 50 return (Creator)map.get(name); 51 } 52 53 public void addCreator(String s, Object callable) { 54 Map map = getCreatorMap(); 55 map.put(s, new SessionCreator(callable)); 56 } 57 58 public void removeCreator(String scriptName) { 59 Map map = getCreatorMap(); 60 map.remove(scriptName); 61 } 62 63 private Map getCreatorMap() { 64 HttpSession session = ExecutionContext.get().getSession(); 65 Map map = (Map ) session.getAttribute("CreatorMap"); 66 if (map == null) { 67 map = new HashMap (); 68 session.setAttribute("CreatorMap", map); 69 } 70 return map; 71 } 72 } 73 | Popular Tags |