Announcement Announcement Module
Collapse
No announcement yet.
Property Placeholder for Imports/Bean Refs Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Property Placeholder for Imports/Bean Refs

    Can I use a property loaded from property-placeholder to make a context import dynamic?

    Code:
    <context:property-placeholder location="classpath*:/enterprise.properties"/>
    <import resource="classpath*:/Fsb${jdbc.ctxType?:Jdbc}-context.xml"/>
    Properties File
    Code:
    jdbc.ctxType=JTA
    So this way I could change the type of context file that is loaded based on a property.

    Also, can I do the same thing to make a bean ref name dynamic?

    Code:
    <bean id="personBusinessService" class="com.foo.PersonBusinessServiceImpl"
    			  p:personUidDataService-ref="personUidDataService${personUidDataService.sib?:Api}"	
    			  p:identifierLookupSearchService-ref="identifierLookupSearchService${identifierLookupSearchService.sib?:Api}"	
    			  p:contactPointBusinessService-ref="contactPointBusinessService${contactPointBusinessService.sib?:Api}"
        />
    Properties File
    Code:
    personUidDataService.sib=Stub
    Thanks...also, if this isn't the right forum group...please let me know.

    Jay

  • #2
    Hi

    See http://blog.springsource.com/2011/02...ty-management/ - you can resolve placeholders in <import /> elements (using more property sources in Spring 3.1, Spring 3.0.x allowed only system properties). But I'm afraid you can't use Spring EL (see: org.springframework.core.env.PropertySourcesProper tyResolver.getProperty(String, Class<T>))

    regards
    Grzegorz Grzybek

    Comment

    Working...
    X