1

In my small project I have 3 entity classes. These classes should be "extendable" by the end user by configuration (eg. human readable text based, probably xml). With extendable I mean adding fields and proper JPA annotations (including something like @ManyToOne) to them so the generated class is then a "normal" entity class.

I've already very vaguley heard of javassist, cglib, Aspectj due to using hibernate and spring. However which one would be appropriate to use? Does this work with spring? I mean when the application starts it must

  1. create the entities from config
  2. start spring context
  3. make spring "scan" them (packagesToScan) or Programmatically loading Entity classes with JPA 2.0?

My further question is if there is already some kind of library / tool that includes reading a configuration file and create the entity from it?

Community
  • 1
  • 1
beginner_
  • 7,230
  • 18
  • 70
  • 127
  • are you thinking of code generation or or on the fly entity object creation? – Farzad Mar 13 '13 at 20:00
  • either. But after having a brief look at javassist documentation and the potential problem from creating classes on the fly within an application container, I think code generation would be a lot easier to do. What I need is some tool to add fields and annotations to existing entity (by extending it) and that tool must be usable by an administrator, eg. not a developer (then he could just extend it in code). the downside of bytecode generation would be that if base entity changes in updated it will have to be repeated? – beginner_ Mar 13 '13 at 20:10
  • @beginner_: From your last comment I would say that what you want is to have a model that is bootstrapped by the existing classes and where the non developer user can insert fields and mark others (by mark read annotate). With that model you would then generate classes using a generation framework, maybe you should look a bit into eclipse's EMF http://www.eclipse.org/modeling/emf/ – pabrantes Mar 17 '13 at 00:15
  • does that work outside of eclipse? It's a bit more and seems more complex than what I want. – beginner_ Mar 17 '13 at 10:03

0 Answers0