Announcement Announcement Module
Collapse
No announcement yet.
Annotations or XML Configuration? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Annotations or XML Configuration?

    Are there any plans to support Spring bean configuration via Java 5 annotations (like Java EE 5) instead of separate XML configuration files (or some of the more recent alternatives)?

    I realise there are some religious objections to source-level metadata, as this means adding extra dependencies to Spring. However such metadata items (annotations or commons attributes) can easily be subclassed in a project to avoid Spring-specific imports. And they are clearly of great use in defining transactions or controller URLs so why not Spring beans as well?

    We're currently using Spring 1.2.x with XDoclet, as this allows spring beans to be very easily defined (on class definitions) and injected (on setters) and we never have the situation where the XML config gets out of step with the code (easy in a large project!).

    We're looking to migrate to Spring 2.x and Java 5, and it would be great to replace the XDoclet definitions with type-safe annotation equivalents.

    I'm sure I'm not the only Spring user to have these thoughts. If I looked into prototyping some sort of classpath-based start-up scanning of annotations, would I be wasting my time?

    Thanks, Chris Nappin.

  • #2
    Have you checked this out?
    http://blog.interface21.com/main/200...on-for-spring/

    Comment


    • #3
      Originally posted by karldmoore View Post
      Thanks for the link. Yes I was aware of the Spring Java Configuration sub-project - it was demo'd at JavaPolis a few weeks ago. That's not what I'm after, because that's simply an alternative configuration mechanism separate to my Spring code.

      Looking at the comments though, it seems the java.net spring-annotations project is what I'm looking for. I'll try it out.

      Comment


      • #4
        Glad it helped, if you do go down the spring annotations route, I would be interested to hear your findings! I also read the comments and looked at the link, but I've not had time to look at it yet.

        Comment


        • #5
          Originally posted by karldmoore View Post
          Glad it helped, if you do go down the spring annotations route, I would be interested to hear your findings! I also read the comments and looked at the link, but I've not had time to look at it yet.
          Unfortunately my feedback is that I've been unable to get the spring annotations code to work, and the authors have yet to reply to my email. However from the project descriptions it looks like their direction is more supporting Java EE 5 annotations outside of a Java EE 5 container, rather than concentrating on Spring.

          I've decided that I could easily knock together a suitable solution myself. I've done a little research and found solutions to all of the steps that will be involved. I don't imagine that such a solution will involve very much code, so I wondered what the approach would be to submit a code prototype for inclusion in future versions of Spring? Do I need to create a bug report and attach a patch, or contact some of the team directly? I don't think this warrants a separate Spring sub-project, it's merely a logical extension of the current Annotation and Commons Attribute functionality already included in Spring.

          Comment

          Working...
          X