spring - Update field annotated with @Value in runtime -
let's imagine have such component in spring:
@component public class mycomponent { @value("${someproperty}") private string text; } if define property placeholder:
<context:property-placeholder location="classpath:myprops.properties"/> and mypropos.properties contains value someproperty value injected text field when context initialized. that's quite simple , easy.
but let's have service enables user change value of someproperty:
public void changeprop(string name, string newvalue); is there chance can re-inject newvalue text field. mean should quite straight forward.. it's nothing different after-initialization injection. can not imagine spring not have support this? can fire event or something?
i on own basically, wander maybe there already? if not know spring class in fact handling injections @ first place? reuse code there perform on own if solution not exists.
i expect spring not have support this, because normal injection done while creating bean, not put in service.
anyway: in this blog entry "reloadable application properties spring 3.1, java 7 , google guava", can find idea solution.
the key idea use post processor build list of fields property fields. , if properties changed on can use list update fields.
Comments
Post a Comment