2

I want to use static values from a class as value for key for a props in spring bean configuration file. Here is an excerpt from my spring bean config file

<property name="serviceMappings">
  <props>
   <prop key="portraitMode">portraitMode</prop>
   <prop key="landscapeMode">landscapeMode</prop>
  </props>
</property>

<bean id="portraitMode" class="com.xyz.PortraitMode">
  <propery name="someDependency" ref="someDependency" />
</bean>

<bean id="landscapeMode" class="com.xyz.landscapeMode">
  <propery name="someDependency" ref="someDependency" />
</bean>

Now instead of using hard coded values "portraitMode" and "landscapeMode" while creating serviceMappings I want these values to come from constants defined in another class. Is there a way to do this in Spring ?

Pushkar
  • 541
  • 4
  • 18
  • 1
    Did you look at http://stackoverflow.com/questions/2897819/spring-using-static-final-fields-constants-for-bean-initialization ? I think it's the answer to your question. – erkfel May 26 '16 at 20:28
  • 1
    @erkfel : I don't think that question matches to what I am looking for. It is the `key` in `props` and not an arbitrary property of a bean, I want to use static final values for. – Pushkar May 31 '16 at 15:33

0 Answers0