[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [eclipselink-users] JMX / Getting DB Settings via web interface

This is very interesting, thank you.

 

I am looking for something a bit different – I want to be able to actually get a list of the persistence unit names that I’ve set up in persistence.xml – as well as certain properties (eg the jdbc url, read/write connections etc) – this is more of a general mechanism to check app configuration status from a webpage.

 

Thanks,

 

Tony

 

From: eclipselink-users-bounces@xxxxxxxxxxx [mailto:eclipselink-users-bounces@xxxxxxxxxxx] On Behalf Of Mike Norman
Sent: Monday, November 19, 2007 4:29 PM
To: EclipseLink User Discussions
Subject: Re: [eclipselink-users] JMX / Getting DB Settings via web interface

 

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.

--
Oracle Email Signature Logo
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

GIF image