1 7 package com.inversoft.verge.mvc.view.jsp.model; 8 9 10 import java.util.HashMap ; 11 import java.util.Map ; 12 13 import javax.servlet.jsp.PageContext ; 14 15 import com.inversoft.verge.mvc.model.ModelResolution; 16 17 18 30 public class ModelResolutionRegistry { 31 32 35 public static final String MAP_KEY = "_inversoftModelResolutions_"; 36 37 38 41 public ModelResolutionRegistry() { 42 super(); 43 } 44 45 46 54 public static void store(String key, ModelResolution modelResolution, 55 PageContext pageContext) { 56 57 assert (key != null) : "key == null"; 58 assert (modelResolution != null) : "modelResolution == null"; 59 60 Map map = (Map ) pageContext.getAttribute(MAP_KEY); 61 if (map == null) { 62 map = new HashMap (); 63 pageContext.setAttribute(MAP_KEY, map); 64 } 65 66 map.put(key, modelResolution); 67 } 68 69 75 public static ModelResolution lookup(String key, PageContext pageContext) { 76 77 assert (key != null) : "key == null"; 78 79 Map map = (Map ) pageContext.getAttribute(MAP_KEY); 80 if (map == null) { 81 map = new HashMap (); 82 pageContext.setAttribute(MAP_KEY, map); 83 } 84 85 return (ModelResolution) map.get(key); 86 } 87 } 88 | Popular Tags |