Gonna try the reflections and ASM approach first thing tomorrow.
The hashtable solution isn't really going to be useful I guess because want to use the (in runtime) generated object in hibernate so I can store it in my DB. (hope this will be possible, though I guess I also need to adjust my hibernate mapping settings in real time somehow too)
Joined: Oct 13, 2005
If you get the reflection to work, tell us, then I can see where I was mistaken.
Well, if I get it right then "Class.forName()" can be used for dynamic class loading. But then (for what I'm trying to do) I'd have to create and compile my dynamic class somehow during runtime...and I don't really see how I can accomplish that...
I could use ASM to generate the bytecode for the class somehow but I browsed a bit through the docs on their site and it doesn't seem that easy to me. I think I will need quite some time to get it.
To tell you the whole story: The kind of system I would like to create is one where you can generate a form (with some fields) which then would automatically be mapped to a java object with the same name as the form name and the fields and their values as class variables. Thereafter I would like to pass it to hibernate to store it in my DB. (so then I would need to generate hibernate's mapping files too along the way)
I've already been working on such a of system in PHP and managed to get it more or less, but now I'm trying to create the same thing in Java.