Announcement Announcement Module
Collapse
No announcement yet.
Q: any way to generate POJOs getters/setters automatically? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Q: any way to generate POJOs getters/setters automatically?

    Hi, all,

    I was wondering, considering POJO-centric nature of Spring framework, if anyone has come up with a way to generate getters/setters automatically (I'm NOT talking about IDE features here)? Can this be done through the new 'annotation' feature of JDK1.5? What about XDoclet? I came across this 'request for new feature' today on Sun's site:

    http://bugs.sun.com/bugdatabase/view...bug_id=4979053

    Any standard way this problem is tackled in Spring community? The 'problem' is the code becomes very verbose with lots of setters/getters, especially if class is supposed to be highly customizable (so, sometimes I'm ending up with 50-70%% of the code in setters/getters and only the rest in business logic).

    The rest seems to be great so far. IoC - turns out to be quite helpful pattern. Thanks for all hints!

  • #2
    You can use XDoclet to generate getters/setters: XDoclet - @JavaBean Tag Reference.
    HTH

    Comment


    • #3
      isn't it for BeanInfo class declaration only?..

      Originally posted by irbouho
      You can use XDoclet to generate getters/setters: XDoclet - @JavaBean Tag Reference.
      HTH
      But it says that this tag is for "declaration of JavaBean BeanInfo classes"... So, I think the bean class itself is still required with all its getters/setters...

      Comment


      • #4
        Whilst it would be possible to generate getters and setters at runtime with something CGLIB, it isn't much use since they wouldn't be available at compile time so you couldn't write code that would access them.

        I'm not too sure, but it might be possible to use the JDK 5.0 annotation compiler extension mechanism to get around this. However, that seems like an overly complex solution for something I can do in IDEA with few taps on the ol' keyboard.

        Rob

        Comment

        Working...
        X