Reputation: 484
I'm trying to find a way to initialize a Bean's Property by invoking a method that uses another Property as a parameter.
<context:property-placeholder location="classpath:application.properties" />
<bean id="decoder" class="foo.Decoder" />
<bean id="dataSource" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close">
<!-- Here I'm trying to call the do() method on a Decoder instance -->
<!-- The application.dbUrl is defined in application.properties file -->
<!-- ... can't find the right syntax. If any. Thanks! -->
<property name="URL" value="#{decoder.do(application.dbUrl)}" />
</bean>
Upvotes: 1
Views: 276
Reputation: 4024
Try this
<property name="URL" value="#{decoder.do('${application.dbUrl}')}" />
Notice the ${..}
which will instruct the SpEL parser to lookup it as property and not treat it as plain string value.
Let know in comments if any more information is required.
Upvotes: 1