question on writing extensible code

david-8uUts6sDVDvs2Lz0fTdYFQ at public.gmane.org david-8uUts6sDVDvs2Lz0fTdYFQ at public.gmane.org
Sat Jun 27 23:03:36 EDT 2009


> any suggested reading on this?  i'm particularly interested allowing
> customers to write their own modules and in handling upgrades.  i've
> gotten some ideas from several free software projects but it would be
> enjoyable to read up on the topic.
>
> thanks for any tips,
> eric c.

What you're looking for is some kind of plugin architecture.  I've tried
to do this from scratch, and the biggest obstacle is that there's no way
in Java to enumerate all the classes in a package, all the classes that
extend another class, or all the classes that implement an interface. 
These classes have to register with your handler somehow.

If you're looking for a larger, more robust solution, Eclipse and OSGi (or
some other OSGi stack other than Equinox, which is what Eclipse uses) is
all about that kind of thing.  I'm using it at http://www.metatomix.com,
and it works well.  Each Eclipse plugin you write has its own class
loader, and can publish as few or as many classes as it wants.  There's a
mechanism called Extension Points for doing exactly what you're talking
about (a plugin can say "I provide Foo functionality, so count me in the
list if you're looking for implementers of Foo".

Eclipse also allows you to have different versions of the same plugin
accessible at the same time.







More information about the Discuss mailing list