Configuring Barracuda (specifying pluggable implementations)

"Christian Cryder" <[email protected]>
Newsgroups gmane.comp.java.enhydra.barracuda.general
Message-ID <[email protected]>
Hi folks,

Jake and I have been having some conversations on how to make it easier for
developers to specify alternate implementations of interfaces within
Barracuda.

The core.event package is one of the more common places where developers
might need to do this, and right now its pretty cumbersome...you have to
extend ApplicationGateway and override provider methods. Blech.

I've been thinking there's got to be an easier way, and so I spent some time
tonight working on a sample implementation fpr your review. Here are the
details (from what I just checked into cvs)...

------------------------------
<b>csc_060903.3</b> - Preliminary work for Jake's review on a new way to
configure
pluggable classes. Basically, I modified
org.enhydra.barracuda.plankton.Classes to offer
a couple of new methods for getting a Class or an instance of a Class (using
some simple
caching for efficiency sake). Then I created a new
org.enhydra.barracuda.core.event.A_Classes.
This class defines constants that refer to default class names...they can be
overridden
via the Object Repository scripting approach. The basic idea here is that
when a class needs
to instantiate something that implements the interface, it uses
Classes.newInstance(String clName),
where clName is the value defined in A_Classes. I have currently implemented
this in
ApplicationGateway, for both DefaultEventGateway and DefaultEventPool. This
is to provide
an example of the approach I have in mind. Jake and others...your comments
and feedback would
be appreciated.
------------------------------

Basically, what this means is that when you want to provide a different
implementation of a class, all you have to do is something like this in your
object-repository.xml:

    <object class="org.enhydra.barracuda.core.event.A_Classes">
      <prop name="DEFAULT_EVENT_POOL">foo.blah.MyCustomEventPool</prop>
    </object>

This is essentially overriding the class name that will be used for event
pooling. It could also be used for configuring the classes in question,
again via statics. For instance, if I wanted to configure MyCustomEventPool,
I could add another section in my object repository just like this:

    <object class="foo.blah.MyCustomEventPool">
      <prop name="RUN_REALLY_FAST">true</prop>
    </object>

At any rate, I'd encourage those of you who are interested, to take a peak
at the latest version of ApplicationGateway and let me know what you think.
Your comments and feedback would be very welcome.

Christian
----------------------------------------------
Christian Cryder
Internet Architect, ATMReports.com
Project Chair, BarracudaMVC - http://barracudamvc.org
----------------------------------------------
"Coffee? I could quit anytime, just not today"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.