samedi 14 février 2015

@Value with spring reflection

I am using reflection to invoke a method of a class, now that class as a variable annotated with @Value annotation. Now this variable is used in the invoked method but since i am using reflection its always coming as null


Any workaround for this Here is my piece of code.



public class DSCValuationEventListener {
@Value("${name.position}")
private String documentName;

@SingleConsumerEventTemplate
public SQLQuery<SpaceDocument> eventFilter(){
SQLQuery<SpaceDocument> ratesPositionPollingTemplate = new SQLQuery<SpaceDocument>(documentName, "");
return ratesPositionPollingTemplate;
}


and this called from.



ReflectionUtils.invokeMethod(method,singleConsumerPollingContainerClass.newInstance());


but documenName is alwasy null.


Need some urgent help on this.






Aucun commentaire:

Enregistrer un commentaire