List Connection Caches(this howto is deprecated)Tag(s): DEPRECATED


Here a Servlet that will display Connection Caches installed. This is done by querying the Jaguar's Repository.
package com.rgagnon.servlet;

import javax.servlet.*;
import javax.servlet.http.*;

import org.omg.CORBA.*;
import SessionManager.*;
import com.sybase.jaguar.system.Repository;
import com.sybase.jaguar.system.RepositoryHelper;
import com.sybase.jaguar.system.*;

public class ListCache extends HttpServlet {
    public void init(ServletConfig config) throws ServletException {
        super.init(config);
    }

    public void destroy() { }

    protected void processRequest
       (HttpServletRequest request, HttpServletResponse response)
       throws ServletException, java.io.IOException {
        response.setContentType("text/html");
        java.io.PrintWriter out = response.getWriter();

        try {
            String hostname = request.getServerName();
            String servername =
               com.sybase.jaguar.server.Jaguar.getServerName();

            java.util.Properties props = new java.util.Properties();
            props.put("org.omg.CORBA.ORBClass", "com.sybase.CORBA.ORB");
            ORB orb = ORB.init((String[])null, props);
            Repository repository =
                RepositoryHelper.narrow(orb.string_to_object
                   ("Jaguar/Repository"));

            out.println
             ("<html><head><title>Connection Caches</title></head><body>");
            out.println
             ("<b>hostname</b> " + hostname + "   [" + servername + "]");

            out.println("<P>Connection caches:<p><ul>") ;
            String connView[][] = repository.items("ConnCache", "");
            j = connView.length;
            for(int k = 0; k < j; k++) {
              out.println
                ("<li>" + connView[k][1]
                 + "<font size='1'>[" + connView[k][3] + "]</FONT>" );
            }

            out.println("</body></html>");
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        finally {
            out.close();
        }

    }

    protected void doGet
      (HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException {
        processRequest(request, response);
    }

    protected void doPost
      (HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException {
        processRequest(request, response);
    }

    public String getServletInfo() {
        return "List Connection caches";
    }

}

blog comments powered by Disqus