java - How to achieve conditional resource import in a Spring XML context? -


What would I want to achieve "ability to move" (i.e., based on the property defined in a configuration file)

< / P>
  & lt; Import condition = "some.property.name" resource = "some-context.xml" />  

Where the asset is being resolved (for boolean) and when the correct reference is imported, otherwise it is not.

I have some research yet:

  • Write a custom namespace handler (and related class), so that I registered my own custom element in my own namespace Can do For example: & lt; Myns: import condition = "some.property.name" resource = "some-reference.xml" />

    The problem with this approach is that I do not want to repeat the logic of importing the entire resource from Spring and it is not clear to me that I want to appoint to do this the wanted.

  • To increase the behavior of overriding DefaultBeanDefinitionDocumentReader "import" element parsing and interpretation (which is in the importBeanDefinitionResource method). Although I'm not sure where I can register this extension.
  • The closest standard spring components are to use:

      & lt; Import Resources = "whatever - $ {yyzzy} .xml" />  

    Where $ {xyzzy} repeats a property with system properties. (I use a hamy custom version of the reference loader class which adds the objects of the system properties before starting the loading process from other locations.)

    But you can import lots of unnecessary stuff Can be participated with .. and the reason for the use of different combinations to be immediately urgent

  • using the new Spring expression language separately
  • Bean aliases with placeholders in the target name:
  • These moves include:

    • Placeholder and property replacement
    • ,
    • Lazy Bean Initialization, and
    • Smart Bean factories.

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -