On Sat, 16 Oct 2004 19:58:52 -0700, Martha Goys wrote:
> Andrew Thompson wrote:
>> On Sat, 16 Oct 2004 00:21:51 -0700, Martha Goys wrote:
>>
>>>Sorry if this is a "Classloader 101"-type question, but is there a way
>>>to programatically find all classes (in the current classpath)
>>
>> No.
>>
>>>..that implement an interface?
>>
>> Yes.
>>
>> There is no way to find all the classes on the current classpath,
>> but if you have a list of classes it is possible to determine if
>> any implement a particular interface.
>>
>> Why do you feel you need to do this? What is the end result
>> you wish to achieve?
>
> I'd like to list all classes implementing a certain interface in a UI,
> so that users can choose which to instantiate and use. The interface is
> used to define a simple plugin architecture, and I felt it would be
> easiest if there was a programmatic way to 'search' for classes that
> implement this interface, versus having to manually add the class names
> to a properties file, etc.
The properties file is probably the way to go, if
your app. is JWS'd, the properties file will be
updated when changed. But..
>..I.e. if they're in the classpath, they'd
> 'automagically' be available and listed in the UI. Minor, but thought
> it would be nice touch.
Exactly how are thes plug-ins stored, as classes
on the file-system? As classes in a jar file?
Are they delivered as required over the net?
(In the first two situations, you *can* find the
names of classes that are in a particular directory/package
on the file-system, or in a jar file)
--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane