I
Ian Pilcher
I'm working on application that uses plug-in classes to handle various
data formats. No matter how I look at the problem, each plug-in class
has to implement a constructor (or static "factory" method) that takes
the appropriate agruments and another static method that checks the
compatibility of the class with a given data stream.
I'm using the reflection stuff in java.lang.reflect to check each class
when it's "registered". It's cumbersome, but it works.
The challenge comes from the "default" plug-in class. Just like it
sounds, it accepts any data format, and the program it written with the
assumption that it will always be present. Currently, it gets
registered during program startup, at which time the normal checks are
done -- with a RuntimeException thrown if I've forgotten to update the
default plug-in for a change in the required static method/constructor.
By all rights, this should be checked at compile-time. After all, the
default plug-in is part of the application. Is there any clean way to
do this?
Thanks!
data formats. No matter how I look at the problem, each plug-in class
has to implement a constructor (or static "factory" method) that takes
the appropriate agruments and another static method that checks the
compatibility of the class with a given data stream.
I'm using the reflection stuff in java.lang.reflect to check each class
when it's "registered". It's cumbersome, but it works.
The challenge comes from the "default" plug-in class. Just like it
sounds, it accepts any data format, and the program it written with the
assumption that it will always be present. Currently, it gets
registered during program startup, at which time the normal checks are
done -- with a RuntimeException thrown if I've forgotten to update the
default plug-in for a change in the required static method/constructor.
By all rights, this should be checked at compile-time. After all, the
default plug-in is part of the application. Is there any clean way to
do this?
Thanks!