Vespa, Anthony J wrote:
Hello,
I'm building an app using Eclipselink and I would like to have a little
servlet that essentially reads the in-memory settings (eg things like
what persistence units are configured to which dbs, what cachs
statistics can I get, etc) - I've looked through the api for toplink and
can't seem to find anything to do this.
Any ideas for getting this sort of info?
Thx!
-Tony
I did something vaguely similar a long time ago ... I needed to access
the internal IdentityMapManager
to print out which threads were holding onto locks.
For EclipseLink, the basic starting point would be:
...
import org.eclipse.persistence.sessions.factories.SessionManager;
public class
EclipseLinkSpyServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
ServletContext sctx = getServletContext();
sctx.log("EclipseLinkSpyServlet
- doGet");
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<html><body><head><title>EclipseLinkSpyServlet</title></head>");
pw.println("<body><h1><center>EclipseLinkSpyServlet</center></h1><br>");
// key is String name of session, value is (obviously) a Session
Map sessions = SessionManager.getManager().getSessions();
For each session, you can ask it for its org.eclipse.persistence.sessions.Login
via getDatasourceLogin()
which has a lot of database information.
--
Mike Norman | Principal Software Designer | 613.288.4638
Oracle Server Technologies | TopLink Product
45 O'Connor Street, Suite 400 | Ottawa, ON K1P 1A4 | (fax) 613.238.2818
|