T
tomjbr.56770318
I would like to figure out how you can implement a method like this,
which should locate all classes that are available at the classpath
that implements a certain interface:
'public Class[] getImplementingClasses(Class someInterface)'
or even better:
'public Class[] getSubtypes(Class someBaseType)'
(where basetype can be either an interface or a baseclass, while each
returned subtype can be either a subclass or subinterface)
When I was googling, I found 'Commons Discovery' at
http://commons.apache.org/discovery/
The homepage there is claiming that:
"Fundamentally, Discovery locates classes that implement a given Java
interface."
So, this seemed to be what I was looking for.
However, I can not figure out or see any example about how I actually
can retrieve a list of the classes that implement a given interface...
Can someone please provide a code example, either by using Commons
Discovery, or some other open source component (or maybe it is even
fairly simple with the Java Core library ?)
/ Tom
which should locate all classes that are available at the classpath
that implements a certain interface:
'public Class[] getImplementingClasses(Class someInterface)'
or even better:
'public Class[] getSubtypes(Class someBaseType)'
(where basetype can be either an interface or a baseclass, while each
returned subtype can be either a subclass or subinterface)
When I was googling, I found 'Commons Discovery' at
http://commons.apache.org/discovery/
The homepage there is claiming that:
"Fundamentally, Discovery locates classes that implement a given Java
interface."
So, this seemed to be what I was looking for.
However, I can not figure out or see any example about how I actually
can retrieve a list of the classes that implement a given interface...
Can someone please provide a code example, either by using Commons
Discovery, or some other open source component (or maybe it is even
fairly simple with the Java Core library ?)
/ Tom