|
Hi LVH,
I am not sure how advanced a programmer you are because your profile doesn't mention it. I am gonna describe here a solution and if you need more guidance let me know.
Java has a very nice feature called "Reflection". For your problem this is the perfect solution. what you have to do is to create a factory class that is able to read your configuration file and based on what you have in there it will create instances of your objects.
In order to be able to do this you have to make your classes obey to some standards. First one you already have, they are all derived from a parent class or implement the same interface. This helps with the design of your factory class.
The second requirement is for your classes to have a constructor with the same signature. To keep it simple for now you can make your classes to have a no parameters constructor.
Then you have to modify your configuration file to specify the name of each class as "package.Table" or something similar.
Now when you start your program you create the factory instance with the configuration file as parameter. While you read the class names from the file you can instantiate them using reflection with the call java.lang.Class.newInstance(). Here you have to deal with a number of exceptions.
If this is not clear enough I can write a small example for you when I have 20 minutes. But I would like to see you try it first. Post the code here. Cheers.
__________________
Daniel @ [ To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. ]
Language is froth on the surface of thought
|