Jerald <> wrote:
> I'm trying to build a flexible plugin structure and it seems like a good
> way would be to include each plugin class in a package.
Certainly plugins can be placed into packages. It sounds, though, as if
you're trying to be too restrictive on the way plugins are written.
Enforcing a rule of one package per plugin class is forced and
unnatural, not to mention completely unnecessary.
> That assumes, of course, that there is some way to discover what classes
> exist in the package. So far I cannot find anything in the ClassLoader,
> Class or Package specs that would obviously do that. Any methods I can
> find require me to know the name of the class I want to load.
There is no such thing. It is a fundamental concept of Java class
loading that you must first know the name of the class you want, and
then load the class.
> Am I barking up the wrong tree? Is there another good way to go about this?
Yes, you are barking up the wrong tree. The right way to do this
depends on exactly what you want. Ideally, plugins would be distributed
as JAR files, and you'd read some fixed thing in the JAR file (perhaps
the manifest) to discover the name of the plugin class. That seems to
be the best way overall.
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation