Reputation: 3393
In the Spring Framework, how do you determine what "properties" and other related values are available to be set in the context.xml file(s)? For example, I need to set the isolation level of a TransactionManager. Would that be:
<property name="isolation" value="SERIALIZABLE" />
<property name="isolation_level" value="Isolation.SERIALIZABLE" />
or some other values?
Upvotes: 0
Views: 87
Reputation: 3763
Putting the properties into . properties file is a good way of handling.
First define a properties file in your project structure. It is better to put .properties file with the same directory as spring applicationContext.xml.
Your properties file may seem like this :
isolation = "SERIALIZABLE"
isolation_level = Isolation.SERIALIZABLE
You can access this properties file by defining a spring bean like :
<bean id="applicationProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:YourProperties.properties"/>
</bean>
Finally you can access these properties inside Spring beans like :
<bean id="BeanName" class="YourClass">
<property name="PropertyName1" value="${isolation}"/>
<property name="PropertyName" value="${isolation_level}"/>
</bean>
There is another way to inject these values using annotations.
Upvotes: 0
Reputation: 340733
Each bean represents a class, which you can easily find by class=""
attribute. Now you simply open JavaDoc or source code of that class and look for all setters (methods following setFooBar()
naming convention). You strip set
prefix and un-capitalize the first character, making it fooBar
. These are your properties.
In your particular case you are probably talking about PlatformTransactionManager
and various implementations it has.
Upvotes: 2