lundi 18 mars 2019

Is it possible to scan a package hierarchy at runtime to find where a method is called?

I have a utility method which reads a value from the environment and returns a default if the property is not defined.

public String Env.getString(String name, String defaultValue);

I would like to scan the whole application (a REST microservice), on demand, to list all calls to that method. The goal is to be able to generate a dump of all the environment properties in use and the current values.

How can I use reflection (or some other scheme) to seach all classes in a given hierarchy to find calls to the utility method? As I also have getInteger, getBooleanetc an even better solution would find all methods like Env.get...





Aucun commentaire:

Enregistrer un commentaire