mardi 30 août 2016

Java custom method annotation to access the runtime processed field inside the annotated method [duplicate]

This question already has an answer here:

I want to fire method foo(x) every time method bar(y) is called.

bar(y){
    x = 1 + y  
    return x*2
} 

foo(x) {
    httpPost(x)
}

My strategy is to:

@fireX
bar(y){
    x = 1 + y  
    return x*2
}

some how in runtime access x using reflections (may be) and then fire foo(x).

Possible? or is there is any other better way to do this differently than

bar(y){
    x = 1 + y 
    foo(x) 
    return x*2
}

Thanks in advance





Aucun commentaire:

Enregistrer un commentaire