Author: bdekruijff at gmail.com
Date: Thu Feb 3 11:53:38 2011
New Revision: 757
Log:
AMDATU-282 cleanup & javadoc
Modified:
branches/amdatu-dispatcher/amdatu-web/dispatcher/src/main/java/org/amdatu/web/dispatcher/context/HandlerServletContext.java
branches/amdatu-dispatcher/amdatu-web/dispatcher/src/main/java/org/amdatu/web/dispatcher/context/HttpContextManager.java
Modified:
branches/amdatu-dispatcher/amdatu-web/dispatcher/src/main/java/org/amdatu/web/dispatcher/context/HandlerServletContext.java
==============================================================================
---
branches/amdatu-dispatcher/amdatu-web/dispatcher/src/main/java/org/amdatu/web/dispatcher/context/HandlerServletContext.java
(original)
+++
branches/amdatu-dispatcher/amdatu-web/dispatcher/src/main/java/org/amdatu/web/dispatcher/context/HandlerServletContext.java
Thu Feb 3 11:53:38 2011
@@ -32,42 +32,50 @@
import org.apache.felix.http.base.internal.util.MimeTypes;
import org.osgi.service.http.HttpContext;
+/**
+ * Implementation of <code>ExtServletContext</code> that wraps a parent
+ * <code>ServletContext</code> and the <code>HttpContext</code> specific
+ * to the component wrapped by the handler it is given to. Security,
+ * resource and mimetype related calls are delegated to the
+ * <code>HttpContext</code> while generic methods are delegated to the
+ * parent <code>ServletContext</code>.
+ */
public class HandlerServletContext implements ExtServletContext {
- private final ServletContext m_extServletContext;
+ private final ServletContext m_servletContext;
private final HttpContext m_httpContext;
- public HandlerServletContext(ServletContext m_extServletContext2,
HttpContext httpContext) {
- m_extServletContext = m_extServletContext2;
+ public HandlerServletContext(ServletContext servletContext, HttpContext
httpContext) {
+ m_servletContext = servletContext;
m_httpContext = httpContext;
}
public Object getAttribute(String key) {
- return m_extServletContext.getAttribute(key);
+ return m_servletContext.getAttribute(key);
}
public Enumeration getAttributeNames() {
- return m_extServletContext.getAttributeNames();
+ return m_servletContext.getAttributeNames();
}
public ServletContext getContext(String uri) {
- return m_extServletContext.getContext(uri);
+ return m_servletContext.getContext(uri);
}
public String getContextPath() {
- return m_extServletContext.getContextPath();
+ return m_servletContext.getContextPath();
}
public String getInitParameter(String key) {
- return m_extServletContext.getInitParameter(key);
+ return m_servletContext.getInitParameter(key);
}
public Enumeration getInitParameterNames() {
- return m_extServletContext.getInitParameterNames();
+ return m_servletContext.getInitParameterNames();
}
public int getMajorVersion() {
- return m_extServletContext.getMajorVersion();
+ return m_servletContext.getMajorVersion();
}
public String getMimeType(String file) {
@@ -79,19 +87,19 @@
}
public int getMinorVersion() {
- return m_extServletContext.getMinorVersion();
+ return m_servletContext.getMinorVersion();
}
public RequestDispatcher getNamedDispatcher(String path) {
- return m_extServletContext.getNamedDispatcher(path);
+ return m_servletContext.getNamedDispatcher(path);
}
public String getRealPath(String path) {
- return m_extServletContext.getRealPath(path);
+ return m_servletContext.getRealPath(path);
}
public RequestDispatcher getRequestDispatcher(String uri) {
- return m_extServletContext.getRequestDispatcher(uri);
+ return m_servletContext.getRequestDispatcher(uri);
}
public URL getResource(String path) {
@@ -111,53 +119,54 @@
}
public Set getResourcePaths(String path) {
- return m_extServletContext.getResourcePaths(path);
+ return m_servletContext.getResourcePaths(path);
}
public String getServerInfo() {
- return m_extServletContext.getServerInfo();
+ return m_servletContext.getServerInfo();
}
@SuppressWarnings("deprecation")
public Servlet getServlet(String name) throws ServletException {
- return m_extServletContext.getServlet(name);
+ return m_servletContext.getServlet(name);
}
public String getServletContextName() {
- return m_extServletContext.getServletContextName();
+ return m_servletContext.getServletContextName();
}
@SuppressWarnings("deprecation")
public Enumeration getServletNames() {
- return m_extServletContext.getServletNames();
+ return m_servletContext.getServletNames();
}
@SuppressWarnings("deprecation")
public Enumeration getServlets() {
- return m_extServletContext.getServlets();
+ return m_servletContext.getServlets();
}
public void log(String message) {
- m_extServletContext.log(message);
+ m_servletContext.log(message);
}
public void log(Exception exception, String message) {
- m_extServletContext.log(exception, message);
+ m_servletContext.log(exception, message);
}
public void log(String message, Throwable cause) {
- m_extServletContext.log(message, cause);
+ m_servletContext.log(message, cause);
}
public void removeAttribute(String key) {
- m_extServletContext.removeAttribute(key);
+ m_servletContext.removeAttribute(key);
}
public void setAttribute(String key, Object value) {
- m_extServletContext.setAttribute(key, value);
+ m_servletContext.setAttribute(key, value);
}
- public boolean handleSecurity(HttpServletRequest arg0, HttpServletResponse
arg1) throws IOException {
- return m_httpContext.handleSecurity(arg0, arg1);
+ public boolean handleSecurity(HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse)
+ throws IOException {
+ return m_httpContext.handleSecurity(httpServletRequest,
httpServletResponse);
}
}
Modified:
branches/amdatu-dispatcher/amdatu-web/dispatcher/src/main/java/org/amdatu/web/dispatcher/context/HttpContextManager.java
==============================================================================
---
branches/amdatu-dispatcher/amdatu-web/dispatcher/src/main/java/org/amdatu/web/dispatcher/context/HttpContextManager.java
(original)
+++
branches/amdatu-dispatcher/amdatu-web/dispatcher/src/main/java/org/amdatu/web/dispatcher/context/HttpContextManager.java
Thu Feb 3 11:53:38 2011
@@ -22,6 +22,12 @@
import org.osgi.framework.Bundle;
import org.osgi.service.http.HttpContext;
+/**
+ * Registry for registered and/or local <code>HttpContext</code> instances
supporting
+ * reuse based on id.
+ *
+ * TODO transfer responsibility to httpcontext (AMDATU-283)
+ */
public final class HttpContextManager {
private final Map<String, HttpContext> m_idHttpContexts = new
HashMap<String, HttpContext>();
@@ -31,7 +37,6 @@
}
public synchronized HttpContext getHttpContext(Bundle bundle, String
contextId) {
-// String id = createId(bundle, contextId);
String id = contextId;
HttpContext context = m_idHttpContexts.get(id);
if (context == null) {
@@ -50,13 +55,8 @@
}
public synchronized void addHttpContext(Bundle bundle, String contextId,
HttpContext context) {
-// String id = createId(bundle, contextId);
String id = contextId;
m_idHttpContexts.put(id, context);
m_httpContextIds.put(context, id);
}
-
- private String createId(Bundle bundle, String contextId) {
- return bundle.getBundleId() + "-" + contextId;
- }
}