Stefan said:
I want to fetch all classes defined by a specified package (so I only have
to setup a package to let my controller load the classes), but I cannot find
a way to do this.
There is no way to do this.
A package in Java is open; classes may become available at any time
during the execution of the application, and do not become available
until the first time someone attempts to use them. Because of this,
there's no way to list all of the classes that are available.
This may sound strange if your conception of a package is a directory or
JAR file on disk (and, in fact, it's quite possible to get a list of
class files in a JAR or directory)... but Java's classes may instead
come from a web server which may not provide a file listing service at
all (this is fairly common in the case of applets), or even from a
custom classloader that generates code on the fly from the class name,
so that there are actually an inifinite number of classes to be loaded!
The common solution to this problem is to ask for a configuration
resource of a fixed name, and list the available classes in that
configuration resource. A developer would then package their classes
and their appropriate configuration resources as a single JAR file and
distribute it. This technique is used in so large a number of existing
Java software systems that you'd be quite unlikely to confuse anyone
with the request. Systems that use this include the Java SDK API
classes for at least SE and EE versions (I'm not that familiar with ME).
For a good example, look for some documentation on writing providers for
JavaMail.
--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation