On Fri, Jun 22, 2001 at 02:44:16AM -0500, Brandon wrote:
>
> > I don't quite see how this relates. My objection to the use of the
> > servlet in Fred was that it was taking arbitrary TCP streams and
> > wrapping them as servlets in order to have the hendled - which _is_
> > bloat because java.net.Socket (or Freenet.Connection) object contains
> > all the information that a TCP connections provides. Servlets are used
> > for HTTP servers, and wrap the application level request, and therefore
> > contain a bunch of information methods to describe the application level
> > options.
>
> You have a common misconception about the servlet API. It is a standard
> API for writing Internet services. Such as HTTP, FTP, finger, echo, etc.. HTTP
> Servlets are a second-level abstraction which makes it easy to write Web
> services. The proper way for FProxy to be written is as an HTTP Servlet.
> It's not. It's written as a servlet. So it has some code which is redudant
> since it's provided by the HTTP Servlet API. It should be rewritten to be
> an HTTP Servlet. This wasn't done because since the HTTP code was already
> written, it was faster to just write it as a plain Servlet. Doing so was
> the quickest path to have a product out that people could use.
>
> However, without HTTP Servlets, the plain servlet API was still a useful
> choice for programming FProxy and other node plugins. The servlet API is a
> standard. It is well documented. Books and tutorials are available. It's
> really easy to figure out how to write a TCP/IP service using the Servlet
> API. There is no actual pragmatic advantage to rolling your own service
> API. It is true that the current batch of services doesn't use 90% of what
> the servlet API offers. I have no problem with that. Although FProxy
> should undeniably be rewritten to take advantage of the HTTP Servlet API.
I'd like to ground this discussion in reality by repeating an actual code
example I brought up a while ago that shows precisely how well the servlet API
fits into Fred. This is from Freenet/servlet/util/FreenetServletResponse.java:
public class FreenetServletResponse implements ServletResponse
{
OutputStream out;
public FreenetServletResponse() {out=null;}
public FreenetServletResponse(OutputStream o) {out=o;}
public boolean isCommitted() {return false;}
public int getBufferSize() {return -1;}
public void setBufferSize(int x) {}
public void setLocale(Locale l) {}
public Locale getLocale() {return null;}
public void flushBuffer() {}
public void reset() {}
public void setContentLength(int x) {}
public void setContentType(String s) {}
public ServletOutputStream getOutputStream() throws java.io.IOException {
return null; }
public PrintWriter getWriter() throws IOException
{
return new PrintWriter(new BufferedWriter(new OutputStreamWriter(out)));
}
public String getCharacterEncoding() { return null; }
public OutputStream getNormalOutputStream() {return out;}
}
Clearly, in its present state, this is nothing more than a bloated wrapper
around an OutputStream. FreenetServletRequest is the exact same thing --
a bloated wrapper around an InputStream.
Now, compare the method that is actually used to call the servlet in 0.3:
void service(ServletRequest request, ServletResponse response);
with the method in the 0.4 plugin API:
void service(Node node, InputStream in, OutputStream out);
(it is also worth noting that the implementor of the former method must
immediately cast request and response to objects of type
FreenetServletRequest and FreenetServletResponse)
I am not going to make this email any longer by including the code from the
other files in Freenet/servlet. Suffice it to say that they adhere to the
same pattern -- big, woolly interfaces and abstract classes with virtually
everything in them unused or unimplemented.
Not only is this stuff currently unused, but it is totally unclear to me how
it could be fleshed out in a way that is useful or that would make sense
within Fred. *Please*, Brandon and Steven, explain how these classes could
be fleshed out! I'm not trying to flame bait you here -- I really don't
see it. Specifics and actual code would be immensely helpful. So far all
I have heard is "we could flesh it out more and it would be useful."
--
# tavin cole
#
# "Technology is a way of organizing the universe so that
# man doesn't have to experience it."
#
# - Max Frisch
_______________________________________________
Devl mailing list
Devl at freenetproject.org
http://lists.freenetproject.org/mailman/listinfo/devl