samedi 25 février 2017

How to trace java method invocations using java reflection?

what i have?

  1. A Java class with specific method (say execute()) enforced by interface contracts.
  2. Inside the execute method, there is a DAO call to respective DAO implementation.
  3. The DAOImpl uses ORM framework like ibatis to query DB.
Class Test implements Executable{

    public void execute(){
        ...........
        ParentDAO dao = {some utility class that gets me right implementation (ParentDAOImpl) with right data source }

        dao.getEmployees({required params});
        ...................
    }

}
public class ParentDAOImpl extends SqlMapClientDaoSupport implements ParentDAO {

    public void getEmployees({data}) {
        SqlMapClientTemplate template = getSqlMapClientTemplate();

        template.queryForObject("getEmployees", data); // assume there is an xml configuration that has "getEmployees" Object
    }

}

Also, method name (getEmployees) in DAOImpl and the object name in xml configuration may not be same.

What i am trying to do?

I am trying to come up with an API that tells what is the SQL query or stored procedure that is used behind the screens given the class name ("Test"). How do I it ?





Aucun commentaire:

Enregistrer un commentaire