The funny thing about the servlet API in 0.3 Fred is that, while
arguments are floated about how it's good because it's a standard,
the fact is we don't correctly implement the standard -- we only use
about 1% of it.  Here's an example of the ServletRequest
implementation in Freenet.servlet.util.FreenetServletRequest:


    public RequestDispatcher getRequestDispatcher(String s) {return null;}
    public boolean isSecure() {return false;}
    public Locale getLocale() {return null;}
    public Enumeration getLocales() {return null;}
    public int getContentLength() { return -1; }
    public String getContentType() { return null; }
    public String getProtocol() { return null; }
    public String getScheme() { return null; }
    public String getServerName() { return null; }
    public int getServerPort() { return 0; }
    public String getRemoteAddr() { return null; }
    public String getRemoteHost() { return null; }
    public String getRealPath(String s) { return null; }
    public ServletInputStream getInputStream() throws java.io.IOException { 
return null; }
    public String getParameter(String s) { return null; }
    public String[] getParameterValues(String s) { return null; }
    public Enumeration getParameterNames() { return null; }
    public Object getAttribute(String s) { return null; }
    public void setAttribute(String s, Object o) {}
    public Enumeration getAttributeNames() {return null;}
    public void removeAttribute(String s) {}
    public BufferedReader getReader() throws java.io.IOException
    {
    return new BufferedReader(new InputStreamReader(in));
    }
    public String getCharacterEncoding() { return null; }
    public InputStream getNormalInputStream() {return in;}


This is just the tip of the iceberg.  If you read over this you get the
idea that, "Hey there's a whole lot of completely unused baggage in here
meant for the traditional HTTP web-application environment."  Try looking
at the other classes in Freenet.servlet -- it gets worse.

As has been discussed, the servlet API in its 0.3 form had to be at least
temporarily discarded while developing 0.4.  Before we bring back this
hulking, klunky beast, let's consider using a much simpler plug-in model.

The only thing that really matters about the servlet API is that you can
write a class that will run as a plug-in to the node that implements this
method:

    public void service(ServletRequest req, ServletResponse resp);

And that you can use req and resp to obtain the input and output streams
on the socket.

So why don't we just do it this way?

    public void service(Node n, InputStream in, OutputStream out);

You can use the node to obtain an InternalClient instance and you're
good to go (ClientFactory cf = new InternalClient(n)).

-- 

# tavin cole
#
# "The process of scientific discovery is, in effect,
#  a continual flight from wonder."
#                                   - Albert Einstein


_______________________________________________
Devl mailing list
Devl at freenetproject.org
http://lists.freenetproject.org/mailman/listinfo/devl

Reply via email to