| Author |
Find All Implementing Classes
|
Mark Fabrizio
Greenhorn
Joined: Mar 31, 2003
Posts: 7
|
|
Using jdk 1.1.8, is there a way to find all the implementing classes of a specified interface? Really what I'm after is to call a method defined in the interface for all the implementing classes. Thanks in advance, -mark-
|
 |
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
|
|
|
All the implementing classes in the WORLD, or were you containing your search to some sub-portion thereof?
|
"JavaRanch, where the deer and the Certified play" - David O'Meara
|
 |
Mark Fabrizio
Greenhorn
Joined: Mar 31, 2003
Posts: 7
|
|
|
I'm just looking for all implementing classes in the package that I am writing.
|
 |
Layne Lund
Ranch Hand
Joined: Dec 06, 2001
Posts: 3061
|
|
Is this method static? If so you can simply call it using the class name If it isn't static, then your question doesn't make much sense to me. Not only do you need to find the classes that implement the interface, you also need to call the method using objects of said interface. I don't know of anyway to arbitrarily troll memory for instances of a specific class. Perhaps if you explain the overall problem that you are trying to solve, then we can give you suggestions to help you towards the solution. Off the top of my head, one solution is to keep a list of the instances in one of your classes. Every time a new instance is created and it needs the certain method called, this new instance can register itself with the list of these instances. This is similar to how the event mechanism works in Java. HTH Layne
|
Java API Documentation
The Java Tutorial
|
 |
Mark Fabrizio
Greenhorn
Joined: Mar 31, 2003
Posts: 7
|
|
I think a static method is what I want to implement. Thanks for your help, and sorry for my somewhat vague problem description. I haven't programmed in java in a few months and I'm feeling a little rusty.
|
 |
Layne Lund
Ranch Hand
Joined: Dec 06, 2001
Posts: 3061
|
|
No prob! I'm glad something in my rambling gave you an idea for a possible solution to your problem. Keep coding! Layne
|
 |
 |
|
|
subject: Find All Implementing Classes
|
|
|