commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luke Blanshard <>
Subject [HiveMind] Separating service declarations from their implementations
Date Fri, 02 Apr 2004 16:05:54 GMT
Hi all,

  I have what I assume to be a common desire: to define a service in one
module, and plug in one of several possible implementations in a
different module.  Furthermore, I want to select the correct
implementation at run time based on system properties or other
externally specified configuration data.

  For example, I have a service that returns a list of customers.  This
service has 2 different implementations: an EJB-based one, and a local
demo/debug version that reads from a file.  I want to declare the
service in one module, and the implementations in another module.  And I
want to select the implementation (one of these two, or even a third one
written later provided by yet a third module) at run time.

  Here's how I've approached this.  I've created a service factory that
just returns a different service -- I call it ServiceReferenceFactory. 
So I declare my customer list service as being created by this factory,
and I pass in a variable reference as the name of the service to return.
 The hivemodule looks something like this:

<service-point id="Customers" interface="pkg.CustomersService">
  <invoke-factory service-id="example.ServiceReferenceFactory">
    <service-id="${customers-implementation}" />

  Then in the implementation module I provide a default definition for
"customers-implementation" that has the id of one of the
implementations.  And I arrange symbol sources so that I can override
this default at runtime.

  My question: Isn't this kind of overkill?  Since we already have the
ability to separate service-point declarations from their
implementations, wouldn't it be reasonable to build this kind of
indirection right in to HiveMind's core?  Or am I missing something, and
we can already do what I want without this somewhat bogus service factory?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message