4 Commits

Author SHA1 Message Date
Jonathan Bernard
db15eb8f88 HttpContext: Lightweight HTTP protocol support. 2013-03-14 04:50:43 -05:00
Jonathan Bernard
c887a49f8c Added LightOptionParser, NullOutputStream, bugfixes.
LightOptionParser
-----------------

Lightweight, fairly featureful option parsing mechanism idiomatic to Groovy.
Takes in a map of parameter definitions and returns a map of option values and
arguments.

NullOutputStream
----------------

Ignores all data sent its way.

ParameterizedSocket
-------------------

Added trace and debug logging to the message handling code.

SmartConfig
-----------

Fixed a bug where a property lookup on a non-existent property with no default
given caused a null pointer exception trying to resolve the class of the default
value.
2012-11-27 08:40:17 -06:00
Jonathan Bernard
b9fa0d0bbf LoggerOutputStream bugfix, ParameterizedSocket changes.
ParameterizedSocket
-------------------

Moved from transmitting a list of strings (represented by ASCII data separated
by ASCII record separators `0x1E`) to a combination of strings and paired
strings. Basically, instead of each record being processed as a whole, a record
may optionall contain the ASCII unit separator `0x1F`. If it does, the record
will be split and treated as a key-value pair. This is implemented in the
`ParameterizedSocket.Message` class.o

LoggerOutputStream
------------------

Was not initializing the internal buffer.
2012-11-22 15:24:55 -06:00
Jonathan Bernard
21cdf6909c Added ParameterizedSocket and LoggerOutputStream classes.
ParameterizedSocket
-------------------

This is a wrapper around the basic java.net.Socket class that supports sending
and receiving messages with parameters. It exposes two methods:
`void sendMessage(String... message)` and `String[] receiveMessage()`. The
line-level format of the message is:

    START_TOKEN param [SEPARATOR param ...] END_TOKEN

Where `START_TOKEN` is the ASCII "Start heading" control code `0x01`,
`SEPARATOR` is the ASCII "record separator" code `0x1E`, and `END_TOKEN` is the
ASCII "end of transmission" code `0x03`.

LoggerOutputStream
------------------

An OutputStream implementation that flushes to an org.slf4j.Logger instance.
The log level is configurable. It is important to note that data written to
the stream accumulates in an internal buffer until `flush()` is called. At this
point the data is written out as one log message to the logger. It is expected
that one would wrap this stream in an auto-flushing PrintStream or PrintWriter
in actual use.
2012-11-21 13:33:15 -06:00