java - dynamically change spring beans -


How do I change the properties of bean on the runtime by using java springs? I have a Bean main view, which should be used as "Class 1" or "Class 1" or "Class 2". This decision should be done on the basis of a property-file, where the property is "Semartart" "Y" or "N".

ApplicationContext:

  & lt; Bean Id = "mainView" class = "main view" & gt; & Lt; Property Name = "angebotsClient" ref = "angebotsClient" /> & Lt; Property Name = "Class" Ref = "Class 1" /> & Lt; / Bean & gt; & Lt; Bean id = "class 1" square = "class 1" & gt; & Lt; Constructor-arg referee = "main view" /> & Lt; / Bean & gt; & Lt; Bean id = "square 2" square = "square 2" & gt; & Lt; Constructor-arg referee = "main view" /> & Lt; / Bean & gt;  

property file:

withSmartcard = y

< P> Use the property place holder to manage your property files.

  & lt; Bean id = "MyPorty Place" class = "org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" & gt; & Lt; Details & gt; Service Attributes file & lt; / Description & gt; & Lt; Property Name = "Location" value = "Classpath: /some.where.MyApp.properties" /> & Lt; / Bean & gt;  

And follow your ref attribute:

  Bean id = "main view" category = "main view" & gt; & Lt; Property Name = "angebotsClient" ref = "angebotsClient" /> & Lt; Property Name = "Class" Ref = "$ {withSmartCardClassImplementation}" /> & Lt; / Bean & gt;  

Enter some .where.MyApp.properties in your properties, which is named withSmartCardClassImplementation , which will be class1 or class2 for the price (you choose) .

  withSmartCardClassImplementation = class1  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -