Announcement Announcement Module
No announcement yet.
performance ref attribute vs ref local tag Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • performance ref attribute vs ref local tag

    In the author proposes to replace ref tags by ref attributes.
    Is there a way with ref attributes to indicate that the needed bean is local?
    Or is this not an issue?
    I 'm having 2 xml files from which one never needs the other.

  • #2
    As far as I know, you cannot discern local from non-local references when working with ref-attributes. So a ref-attribute does always behave like "ref bean".



    • #3
      Yes, ref attribute is equivalent to ref bean. This is also explained inside the reference documentation if I'm not mistaken.


      • #4
        I am considering to slim down the xml files where we will gain readibility and maintainability but I don't know the cost in performance it wil take when I can't use the local attribute.


        • #5
          You should not think about performance - it's very minor. The parsing happens only one, when the application starts. The main difference between ref local and ref is that ref local applies a DTD constrain so you know if you have some mistakes when you are writing the file (before runtime).
          That's all there is to it!


          • #6
            Thanks for the reply.

            Rereading the ref doc now made it clear, I assumed a bit to much .
            Sorry to have wasted some of your time.

            (there should be a red headed emoticon here, but I hate those fellows)



            • #7
              performance ref attribute vs ref local tag

              In my opinion, The main dissimilarity flanked by ref local and ref is that ref local applies a DTD constrain so you be acquainted with if you have some faults when you are writing the file before runtime.

              hank freid
              Last edited by hank freid love; Jun 17th, 2008, 01:19 AM. Reason: for correction text


              • #8
                I would always use <ref local=".." /> instead of the attribute when possible. Two main reasons:
                - You're sure where the bean comes from. This becomes more relevant when your application gets larger and contains multiple chained application context files.
                - The Spring Container will fail earlier in the start-up process when something is wrong (actually when it parses the XML file. XML ID-REF constraints are used when defining a bean reference as 'local').

                In my opinion there is absolutely no noticable performance gain when using the "ref" attribute. The XML file just gets harder to read and it doen not explicitly show the semantics (who of you actually knows for sure that the 'ref' attribute is a <ref bean="..." /> ??? It is not explained in the Reference Manual as far as I know).