[Gd-hackers] koala changes
Chris Page
chris at chris-page.org
Sun Feb 4 12:38:04 CET 2007
On Feb 1, 2007, at 21:05 PM, Carl Gay wrote:
> On 1/21/07, Chris Page <chris at chris-page.org> wrote:
>> Why not do it more like this:
>>
>> let config = make(<http-server-configuration>,
>> init-file: "filename",
>> port: 8001,
>> xml-rpc-enabled: #t,
>> url-responders: vector(make(<url-responder>,
>> url: "/foo",
>> responder: my-
>> responder)),
>> xml-rpc-methods: vector(make(<xml-rpc-method>,
>> blah-string:
>> "blah",
>> blah: blah)));
>> let server = make(<http-server>, configuration: config);
>> start-server(server);
By the way, you probably want to implement init-file within a make
method so you have more control over initialization:
define method make
(class :: subclass(<http-server>),
#rest supplied-init-args,
#keys #all-keys)
=> http-server :: <http-server>;
let init-file-args =
if (member?(init-file:, init-args))
// Read values from the config file and add the corresponding
// initialization key/value pairs to the result.
else
#()
end;
apply(next-method, class, concatenate(supplied-init-args, init-
file-args));
end method make;
The inherited make is called with the configuration file init args
appended to the ones explicitly passed to make. The usual slot
initialization process proceeds as usual, with any values from the
optional config file being overridden by explicit key args passed to
make and then default initialization for any remaining slots.
>> Alternatively, how about using a serialization library to read/
>> write the server object?
>
> I'm not quite sure what you have in mind here.
For example, use DOOD to read/write the <http-server> object state.
Arrange for DOOD to store just the information you need to save/
restore a configuration of the server.
--
Chris Page - Dylan Programmer
Open Source Dylan Compilers: <http://www.opendylan.org/>
More information about the hackers
mailing list