View Poll Results: what would you prefer for your Spring configuration?

Voters
9. You may not vote on this poll
  • XML based - external configuration files

    3 33.33%
  • Annotations - source code level configuration

    0 0%
  • MIX (Usage: maybe XML > Annotations or Annotations > XML)

    6 66.67%
Results 1 to 6 of 6

Thread: XML based VS Anotations based Configuration OR MIX?

  1. #1
    Join Date
    Oct 2008
    Posts
    286

    Default XML based VS Anotations based Configuration OR MIX?

    what would you prefer for your configuration?
    transactional best for annotations...?
    xml based best because of visibility and gives the outline...?
    how about the pros & cons...? metadata? time compiling? and other aspects that may help us to develop vast features Spring Applications...

    XML based

    - external configuration files

    OR

    Annotations
    - source code level configuration

    OR

    MIX (Usage: maybe XML > Annotations or Annotations > XML)
    - somewhere in the configuration that best for xml and annotations

    my opinion is the two configuration files are different in a way that the annotations are compile time and xml based is run time... but main goals are the same...
    Last edited by eros; Dec 11th, 2009 at 03:17 AM.
    Eros

    Environment:
    JSP 2.0
    Dojo 1.4.1
    Ext JS 3.1 (testing)
    Spring MVC 2.5.6.SEC01 (planning to Spring 3 using STS)
    STS
    SWF 2.0.9.RELEASE
    Tiles 2.0.5
    iBatis: ibatis-sqlmap-2.3.4.726

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    The annotations aren't compile time, they are scanned runtime and dependencies are injected accordingly.

    I like XML because you now have 1 location (or a few if you spread your configuration) where your configuration (application blueprint) is stored. With annotations those are scattered around the place. For the web stuff I mainly uses a mix between annotations and xml, course grained mapping is done in xml and fine grained in the classes.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Oct 2008
    Posts
    286

    Default

    yes it is, Annotations are scanned at runtime..

    my opinion is the two configuration files are different in a way that the annotations are compile time and xml based is run time... but main goals are the same...
    i gave wrong/lack of description in the above...sorry
    i mean, with the aspect of changing the configuration ..
    because annotations are with the compiled class, may not able to change it..
    while the xml based, may able to...


    For the web stuff I mainly uses a mix between annotations and xml, course grained mapping is done in xml and fine grained in the classes.
    please correct me if im wrong,,,
    loosely coupled components are coarse grained, while tightly coupled components are more likely to be fine grained.

    e.g.
    services -> coarse grained
    dao object -> fine grained
    Eros

    Environment:
    JSP 2.0
    Dojo 1.4.1
    Ext JS 3.1 (testing)
    Spring MVC 2.5.6.SEC01 (planning to Spring 3 using STS)
    STS
    SWF 2.0.9.RELEASE
    Tiles 2.0.5
    iBatis: ibatis-sqlmap-2.3.4.726

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    With coarse grained I meant the url mapping.

    in xml map all requests to account controller
    Code:
    <entry key="/account/*" value=ref="accountController" />
    in annotations

    Code:
    @RequestMapping("index")
    public void index() {}
    That way you have your coarse grained URL mapping in xml and the fine grained in Annotations.

    loosely coupled components are coarse grained, while tightly coupled components are more likely to be fine grained.
    I have no clue on what you mean with this nor do I think it holds...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5
    Join Date
    Jun 2009
    Posts
    190

    Default

    XML based configurations are easier to maintain since the configuration is at one place. From a project maintenance perspective as well.

    Easily from a single file you can find out the validators, the command objects etc from a single simple xml whereas the same becomes tedious to locate if its done using annotations.

    -Hetal

  6. #6
    Join Date
    Dec 2009
    Location
    Argentina, Bs As
    Posts
    5

    Default

    I like xmls because i can have multiple configurations of my application to distinc environments in one place... This is more easy to see.

    But i think that the transactions annotations do the things more simple that configure one to one every method.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •