At 09:21 AM 11/20/2001 -0500, Adam Turoff wrote:
....
>... Perhaps what's *really*
>missing is something more basic - a reusable infrastructure for pluggable
>implementations of a standard interface (DBD::*, XML::SAX::*,
>P5EE::Message::*, etc.). Then the email/SOAP/Jabber/XML-RPC/JMS/stem
>transport discussion is effectively moot.
(I am starting a new thread for this response.)
I am working on this: a simple API to access pluggable implementations of
standard API's (like DBI/DBD), and I will have something to show shortly.
It is tightly integrated with the configuration system, so that a developer
using a P5EE Component (P5EE::Component?) can get, for instance, the
default message queue like this:
$context = P5EE->context(); # a singleton per process
$mq = $context->component("MessageQueue");
or an alternate message queue like this:
$pri_mq = $context->component("MessageQueue","priority");
Simplified code for this is as follows.
The component() method consults the config data and instantiates the
"MessageQueue" of the appropriate physical class, perhaps caches it with
the appropriate name, and returns it.
# a method of P5EE::Context (simplified)
sub component {
my ($self, $component_type, $component_name) = @_;
$component_name = "default" if (!defined $component_name);
my ($global_config, $component_config, $class, $method, @args);
$global_config = $self->config();
$component_config = $global_config->{$component_type}{$component_name};
$class = $component_config->{class};
($method, @args) = @{$component_config->{constructor}};
eval("use $class;");
return $class->$method(@args);
}
This is a very simple but functional design, which, if accepted, would
free us up to identify "pluggable components", divide them up, and get
working on their abstract interfaces and some sample implementations.
Some components/interfaces I have thought of might be
P5EE::Serializer - transforms a perl struct to a scalar and back
P5EE::TemplateProcessor - encapsulates template system details
P5EE::Service - like Java Servlet w/ $request/$response
P5EE::MessageQueue - a message queue with configurable quality of service
All implementations of the MessageQueue component would normally be
derived from the P5EE::MessageQueue class (P5EE::MessageQueue::MQSeries,
P5EE::MessageQueue::EMail, etc.) but at very least would need to implement
the methods defined by the interface.
I'll have more soon.
Stephen