I don't think there is a way to force a subclass to have a default (i.e., no-args) constructor, which is checked at compile time. With reflection you could find out if a class has a no-args constructor, but not at compile time. I don't know a lot about annotations (I haven't used them in real world projects yet), so I can't tell you if it can be done with annotations.
We are using a custom transaction model, and the model requires that the subclass implementing the SQL has a default constructor. Not to sure why, i just know that if it isn`t there some audit infomation doesn`t get generated.
Originally posted by Derick Potgieter: We are using a custom transaction model, and the model requires that the subclass implementing the SQL has a default constructor. Not to sure why, i just know that if it isn`t there some audit infomation doesn`t get generated.
Any one else with any ideas???
"custom transaction model" - red flag. what's not done in JTA that is required by your problem?
sounds like a custom persistence model. why is this necessary when there are so many ways to do it already available to you? what are you doing that improves on jdo, o/r mapping, ejb cmp? there's hibernate, ibatis, toplink, cayenne, kodo, etc.
unless you've got a good reason for doing this, it sounds to me like you're doing a lot of work for little benefit.
There's two ways to enforce something like this: at compile time, and at runtime. Come up with a runtime test suite that a component has to pass to be used with the framework. One of the tests could try to use Class.newInstance() to create an instance, or fail.
As you have discovered, concrete behaviour inheritance has no legitimate existence when we observe time to move. If you like, it is best to explain the full problem so that a "more correct" alternative can be offered. The problem should consist of an accurate detail of all abstractions.
Tony Morris Java Q&A (FAQ, Trivia)
Wait for it ... wait .... wait .... NOW! Pafiffle! A perfect tiny ad!