Reputation: 93
I have many ObjectFactory classes that reside in different packages. They are all standalone classes, meaning that they don't extend from any class. I cannot modify those classes.
Now, I need to provide an ObjectFactory to a command-handler class. This ObjectFactory must have a set of methods needed for this exact command-handler class.
How would I go on about scanning all the ObjectFactory classes from different packages to find one with the methods that I need?
Thank you in advance
Upvotes: 0
Views: 53
Reputation: 5463
The only way I can think of doing this is to read all the classes in the class path. Assuming that you have a specific package prefix - you can reduce the number of classes to scan.
Anyhow, look at reflections. You can get all classes with methods having some specific signature etc. with its help.
Upvotes: 1