hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roland Weber <ROLWE...@de.ibm.com>
Subject HLCA: http entities - take two
Date Sat, 22 Jan 2005 07:32:22 GMT
Hello again,

here is take two on moving http entities into their own
class hierarchy. The Decorator pattern for input/output
does not really fit, because writing or reading an entity
is not a functionality that can be implemented without
internal knowledge of the entity itself.
What I intend is closer to the Strategy pattern. There
is a strategy for writing an entity, and one for reading
an entity. The various Ic and Og classes implement such
strategies for a particular type of entity.

To reduce the number of classes, I have moved both strategies
into one for the simple in-memory entity types. I also dropped
the BasicOgEntity and BasicIcEntity classes because I don't
know what would actually be implemented there and because
I can't derive from both of them at the same time.

Here is what it looks like now, with suggestions for the
methods that go into some of the classes and interfaces.
I'm old-fashioned, so it's java.io rather than java.nio
for the time being ;-)


  HttpMessage as base interface for HttpRequest, HttpResponse
    - getHeader(), setHeader()

  HttpEntity interface
    - getContentLength(), getContentType()
  HttpOutgoingEntity interface extends HttpEntity
    - isRepeatable(), writeTo(OutputStream)
  HttpIncomingEntity interface extends HttpEntity
    - readFrom(HttpMessage, InputStream) ?
      (or have that functionality in a constructor)

  BasicEntity implements HttpEntity
    - public getContentLength(), getContentType()
    - protected setContentLength(), setContentType()

  StringEntity extends BasicEntity
    implements HttpOutgoingEntity, HttpIncomingEntity
  ByteArrayEntity extends BasicEntity
    implements HttpOutgoingEntity, HttpIncomingEntity

  InputStreamOgEntity extends BasicEntity
    implements HttpOutgoingEntity
  OutputStreamIcEntity extends BasicEntity
    implements HttpIncomingEntity


  FormDataEntity extends BasicEntity
    implements HttpOutgoingEntity, HttpIncomingEntity
      uses commons-codec, therefore in http-client

  MultipartOgEntity extends BasicEntity
    implements HttpOutgoingEntity
      based on commons-codec or code in o.a.c.hc.methods.multipart

  MultipartIcEntity extends BasicEntity
    implements HttpIncomingEntity
      based on commons-codec (only if available)
      alternative implementations based on javax.mail or
      commons-fileupload can be kept in a "contrib" component
      once they are contributed

What do you think?


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message