1 29 30 package nextapp.echo2.webcontainer; 31 32 import java.io.Serializable ; 33 import java.security.Principal ; 34 import java.util.Map ; 35 36 import javax.servlet.http.Cookie ; 37 import javax.servlet.http.HttpSession ; 38 39 import nextapp.echo2.app.TaskQueueHandle; 40 import nextapp.echo2.webrender.ClientConfiguration; 41 import nextapp.echo2.webrender.ClientProperties; 42 import nextapp.echo2.webrender.Connection; 43 import nextapp.echo2.webrender.ServerDelayMessage; 44 import nextapp.echo2.webrender.Service; 45 import nextapp.echo2.webrender.WebRenderServlet; 46 47 50 class ContainerContextImpl 51 implements ContainerContext, Serializable { 52 53 private ContainerInstance containerInstance; 54 55 60 ContainerContextImpl(ContainerInstance containerInstance) { 61 super(); 62 this.containerInstance = containerInstance; 63 } 64 65 68 public ClientProperties getClientProperties() { 69 return containerInstance.getClientProperties(); 70 } 71 72 75 public Cookie [] getCookies() { 76 Connection conn = WebRenderServlet.getActiveConnection(); 77 if (conn == null) { 78 return null; 79 } else { 80 return conn.getRequest().getCookies(); 81 } 82 } 83 84 87 public Map getInitialRequestParameterMap() { 88 return containerInstance.getInitialRequestParameterMap(); 89 } 90 91 94 public String getServiceUri(Service service) { 95 return containerInstance.getServiceUri(service); 96 } 97 98 101 public String getServletUri() { 102 return containerInstance.getServletUri(); 103 } 104 105 108 public HttpSession getSession() { 109 return containerInstance.getSession(); 110 } 111 112 115 public Principal getUserPrincipal() { 116 Connection conn = WebRenderServlet.getActiveConnection(); 117 if (conn == null) { 118 return null; 119 } else { 120 return conn.getRequest().getUserPrincipal(); 121 } 122 } 123 124 127 public boolean isUserInRole(String role) { 128 Connection conn = WebRenderServlet.getActiveConnection(); 129 if (conn == null) { 130 return false; 131 } else { 132 return conn.getRequest().isUserInRole(role); 133 } 134 } 135 136 139 public void setClientConfiguration(ClientConfiguration clientConfiguration) { 140 containerInstance.setClientConfiguration(clientConfiguration); 141 } 142 143 146 public void setServerDelayMessage(ServerDelayMessage serverDelayMessage) { 147 containerInstance.setServerDelayMessage(serverDelayMessage); 148 } 149 150 153 public void setTaskQueueCallbackInterval(TaskQueueHandle taskQueue, int ms) { 154 containerInstance.setTaskQueueCallbackInterval(taskQueue, ms); 155 } 156 } 157 | Popular Tags |