tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kma...@apache.org
Subject svn commit: r675439 - in /openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/webapp: viewclass.jsp viewejb.jsp viewjndi.jsp
Date Thu, 10 Jul 2008 04:53:07 GMT
Author: kmalhi
Date: Wed Jul  9 21:53:06 2008
New Revision: 675439

URL: http://svn.apache.org/viewvc?rev=675439&view=rev
Log:
Fixed some part of OPENEJB-834.
Fixed viewjndi.jsp, partially fixed viewejb.jsp (did not implement dblevins' idea yet)
Did not fix viewclass.jsp yet as there is a classloader issue
Thanks to David Blevins for all the help

Modified:
    openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/webapp/viewclass.jsp
    openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/webapp/viewejb.jsp
    openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/webapp/viewjndi.jsp

Modified: openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/webapp/viewclass.jsp
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/webapp/viewclass.jsp?rev=675439&r1=675438&r2=675439&view=diff
==============================================================================
--- openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/webapp/viewclass.jsp
(original)
+++ openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/webapp/viewclass.jsp
Wed Jul  9 21:53:06 2008
@@ -94,12 +94,14 @@
             out.print(tab+getClassRef("javax.naming.Context")+"<br>");
 
         } else {
-            Class clazz = Class.forName(className);
+            Class clazz = Class.forName(className); // TODO: Classloader issue here. 
+            //Above code throws a ClassNotFoundException because it cannot load classes from
jar in another webapps lib directory
             printClass(clazz,out);
         }
     } catch (Exception e){
         out.println("FAIL");
-        return;
+        //throw e;
+        //return;
     }
 %>
 <BR><BR>

Modified: openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/webapp/viewejb.jsp
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/webapp/viewejb.jsp?rev=675439&r1=675438&r2=675439&view=diff
==============================================================================
--- openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/webapp/viewejb.jsp
(original)
+++ openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/webapp/viewejb.jsp
Wed Jul  9 21:53:06 2008
@@ -31,6 +31,7 @@
 <%@ page import="java.io.IOException" %>
 <%@ page import="java.util.HashMap" %>
 <%@ page import="java.util.Map" %>
+<%@ page import="java.util.List" %>
 <%@ page import="java.util.Properties" %>
 <%@ page import="java.lang.reflect.Field" %>
 <%@ page import="java.lang.reflect.Method" %>
@@ -84,10 +85,12 @@
                 <%
     try{
         String ejb = request.getParameter("ejb");
+        String jndiName = request.getParameter("jndiName");
+        String contextID = request.getParameter("ctxID");
         if (ejb == null) {
             out.print("No EJB specified");
         } else {
-            printEjb(ejb,out, session);
+            printEjb(ejb,jndiName,contextID,out, session);
         }
     } catch (Exception e){
         
@@ -112,35 +115,10 @@
 </html>
 
 <%!
-    private DeploymentInfo getDeployment(String id, javax.servlet.jsp.JspWriter out) {
-        // due to crazy class loader stuff, we need to use reflection
+    private DeploymentInfo getDeployment(String deploymentID) {
         try {
-            Class<?> clazz = getClass().getClassLoader().getParent().getParent().loadClass("org.apache.openejb.loader.SystemInstance");
-//            out.print("clazz=" + clazz + "<br><br>");
-//            out.print("resource=" + clazz.getClassLoader().getResource("") + "<br><br>");
-
-            Method getMethod = clazz.getMethod("get");
-//            out.print("getMethod=" + getMethod + "<br><br>");
-
-            Object systemInstance = getMethod.invoke(null);
-//            out.print("systemInstance=" + systemInstance + "<br><br>");
-
-            Method getComponentMethod = clazz.getMethod("getComponent", Class.class);
-//            out.print("getComponentMethod=" + getComponentMethod + "<br><br>");
-
-//            Field field = clazz.getDeclaredField("components");
-//            field.setAccessible(true);
-//            Object components = field.get(systemInstance);
-//            out.print("components=" + components + "<br><br>");
-
-            ContainerSystem containerSystem = (ContainerSystem) getComponentMethod.invoke(systemInstance,
ContainerSystem.class);
-//            out.print("containerSystem=" + containerSystem + "<br><br>");
-            if (containerSystem == null) {
-                return null;
-            }
-
-            DeploymentInfo ejb = containerSystem.getDeploymentInfo(id);
-//            out.print("ejb=" + ejb + "<br><br>");
+            ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
+            DeploymentInfo ejb = containerSystem.getDeploymentInfo(deploymentID);
             return ejb;
         } catch (Exception e) {
             return null;
@@ -149,9 +127,9 @@
 
     String tab = "&nbsp;&nbsp;&nbsp;&nbsp;";
 
-    public void printEjb(String name, javax.servlet.jsp.JspWriter out, HttpSession session)
throws Exception {
+    public void printEjb(String name,String jndiName, String contextID, javax.servlet.jsp.JspWriter
out, HttpSession session) throws Exception {
         String id = (name.startsWith("/")) ? name.substring(1, name.length()) : name;
-        DeploymentInfo ejb = getDeployment(id, out);
+        DeploymentInfo ejb = getDeployment(id);
 
         if (ejb == null) {
             out.print("No such EJB: " + id);
@@ -181,10 +159,17 @@
         }
         out.print("<b>" + type + "</b><br>");
         out.print("<table>");
-        printRow("JNDI Name", name, out);
+        printRow("JNDI Name", jndiName, out);
+        if(ejb.getRemoteInterface() != null)
         printRow("Remote Interface", getClassRef(ejb.getRemoteInterface()), out);
+        if(ejb.getHomeInterface() != null)
         printRow("Home Interface", getClassRef(ejb.getHomeInterface()), out);
+        if(ejb.getBeanClass() != null)
         printRow("Bean Class", getClassRef(ejb.getBeanClass()), out);
+        if(ejb.getBusinessLocalInterfaces().size() > 0)
+        printRow("Business Local Interfaces", getClassRefs(ejb.getBusinessLocalInterfaces()),
out);
+        if(ejb.getBusinessRemoteInterfaces().size() > 0)
+        printRow("Business Remote Interfaces", getClassRefs(ejb.getBusinessRemoteInterfaces()),
out);        
         if (ejb.getComponentType() == BeanType.BMP_ENTITY || ejb.getComponentType() == BeanType.CMP_ENTITY)
{
             printRow("Primary Key", getClassRef(ejb.getPrimaryKeyClass()), out);
         }
@@ -201,16 +186,22 @@
             objects = new HashMap<String, Object>();
             session.setAttribute("objects", objects);
         }
-
-        InitialContext ctx;
+        
+        
+        Context ctx;
+        if(contextID == null){
         Properties p = new Properties();
 
         p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
         p.put("openejb.loader", "embed");
 
         ctx = new InitialContext(p);
-        Object obj = ctx.lookup(name);
-        String objID = ejb.getHomeInterface().getName() + "@" + obj.hashCode();
+        }else{
+          ctx = (Context)session.getAttribute(contextID);
+        }
+        Object obj = ctx.lookup(jndiName);
+ //       String objID = ejb.getHomeInterface().getName() + "@" + obj.hashCode(); 
+        String objID = ""+obj.hashCode(); //TODO: Not the best of the ID's, more meaningful
ID would be better. Right now hashcode would suffice
         objects.put(objID, obj);
         String invokerURL = "<a href='invokeobj.jsp?obj=" + objID + "'>Invoke this
EJB</a>";
         printRow(pepperImg, invokerURL, out);
@@ -218,7 +209,7 @@
         Context enc = ejb.getJndiEnc();
         String ctxID = "enc" + enc.hashCode();
         session.setAttribute(ctxID, enc);
-        String jndiURL = "<a href='viewjndi.jsp?ctx=" + ctxID + "'>Browse this EJB's
private JNDI namespace</a>";
+        String jndiURL = "<a href='viewjndi.jsp?ctxID=" + ctxID + "'>Browse this EJB's
private JNDI namespace</a>";
         printRow(pepperImg, jndiURL, out);
         out.print("</table>");
 
@@ -236,7 +227,13 @@
         String name = clazz.getName();
         return "<a href='viewclass.jsp?class=" + name + "'>" + name + "</a>";
     }
-
+    public String getClassRefs(List<Class> classes) throws Exception{
+        String refs = "";
+        for(Class clazz: classes){
+           refs += getClassRef(clazz)+"<br/>";
+        }
+        return refs;
+    }
     public String getShortClassRef(Class clazz) throws Exception {
         if (clazz.isPrimitive()) {
             return "<font color='gray'>" + clazz.getName() + "</font>";

Modified: openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/webapp/viewjndi.jsp
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/webapp/viewjndi.jsp?rev=675439&r1=675438&r2=675439&view=diff
==============================================================================
--- openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/webapp/viewjndi.jsp
(original)
+++ openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/webapp/viewjndi.jsp
Wed Jul  9 21:53:06 2008
@@ -83,7 +83,7 @@
             selected = "";
         } 
 
-        ctxID = request.getParameter("ctx");
+        ctxID = request.getParameter("ctxID");
         ctx = null;
 
         if (ctxID == null) {
@@ -92,7 +92,6 @@
             p.put("openejb.loader", "embed");
             try {
                 ctx = new InitialContext( p );
-                ctxID = null;
                 out.print("<b>OpenEJB Global JNDI Namespace</b><br><br>");
             } catch(Exception e) {
                 out.print("<b>OpenEJB Not Installed</b><br><br>");
               
@@ -113,7 +112,6 @@
         if (ctx != null) {
             Node root = new RootNode();
             buildNode(root,ctx);
-
             printNodes(root, out, "",selected);
         }
     } catch (Exception e) {
@@ -146,7 +144,7 @@
         Node[] children = new Node[0];
         String name;
         int type = 0;
-
+		// returns the JNDI name
         public String getID() {
             if (parent instanceof RootNode) {
                 return name;
@@ -199,7 +197,7 @@
             if (obj instanceof Context) {
                 node.type = Node.CONTEXT;
                 buildNode(node, (Context) obj);
-            } else if (obj instanceof java.rmi.Remote) {
+            } else if (obj instanceof java.rmi.Remote || obj instanceof org.apache.openejb.core.ivm.IntraVmProxy)
{
                 node.type = Node.BEAN;
             } else {
                 node.type = Node.OTHER;
@@ -219,10 +217,10 @@
                 printContextNode(node, out, tabs, selected);
                 break;
             case Node.BEAN:
-                printBeanNode(node, out, tabs, selected);
+                printBeanNode(node, out, tabs);
                 break;
             default:
-                printOtherNode(node, out, tabs, selected);
+                printOtherNode(node, out, tabs);
                 break;
         }
 
@@ -232,7 +230,7 @@
         String id = node.getID();
         if (selected.startsWith(id)) {
             if (ctxID != null) {
-                out.print(tabs + "<a href='viewjndi.jsp?ctx=" + ctxID + "&selected="
+ id + "'>" + openImg + "&nbsp;&nbsp;" + node.getName() + "</a><br>");
+                out.print(tabs + "<a href='viewjndi.jsp?ctxID=" + ctxID + "&selected="
+ id + "'>" + openImg + "&nbsp;&nbsp;" + node.getName() + "</a><br>");
             } else {
                 out.print(tabs + "<a href='viewjndi.jsp?selected=" + id + "'>" + openImg
+ "&nbsp;&nbsp;" + node.getName() + "</a><br>");
             }
@@ -242,30 +240,36 @@
             }
         } else {
             if (ctxID != null) {
-                out.print(tabs + "<a href='viewjndi.jsp?ctx=" + ctxID + "&selected="
+ id + "'>" + closedImg + "&nbsp;&nbsp;" + node.getName() + "</a><br>");
+                out.print(tabs + "<a href='viewjndi.jsp?ctxID=" + ctxID + "&selected="
+ id + "'>" + closedImg + "&nbsp;&nbsp;" + node.getName() + "</a><br>");
             } else {
                 out.print(tabs + "<a href='viewjndi.jsp?selected=" + id + "'>" + closedImg
+ "&nbsp;&nbsp;" + node.getName() + "</a><br>");
             }
         }
     }
 
-    public void printBeanNode(Node node, javax.servlet.jsp.JspWriter out, String tabs, String
selected) throws Exception {
+    public void printBeanNode(Node node, javax.servlet.jsp.JspWriter out, String tabs) throws
Exception {
         String id = node.getID();
         if (ctxID != null && ctxID.startsWith("enc")) {
             // HACK!
             try {
                 Object ejb = lookup(ctx, id);
                 Object deploymentID = getDeploymentId(ejb);
-                out.print(tabs + "<a href='viewejb.jsp?ejb=" + deploymentID + "'>"
+ ejbImg + "&nbsp;&nbsp;" + node.getName() + "</a><br>");
+                out.print(tabs + "<a href='viewejb.jsp?ejb=" + deploymentID +"&jndiName="+id
+"&ctxID="+ctxID+"'>" + ejbImg + "&nbsp;&nbsp;" + node.getName() + "</a><br>");
             } catch (Exception e) {
                 out.print(tabs + ejbImg + "&nbsp;&nbsp;" + node.getName() + "<br>");
             }
         } else {
-            out.print(tabs + "<a href='viewejb.jsp?ejb=" + id + "'>" + ejbImg + "&nbsp;&nbsp;"
+ node.getName() + "</a><br>");
+            try {
+                Object ejb = lookup(ctx, id);
+                Object deploymentID = getDeploymentId(ejb);
+                out.print(tabs + "<a href='viewejb.jsp?ejb=" + deploymentID +"&jndiName="+id
+"'>" + ejbImg + "&nbsp;&nbsp;" + node.getName() + "</a><br>");
+            } catch (Exception e) {
+                out.print(tabs + ejbImg + "&nbsp;&nbsp;" + node.getName() + "<br>");
+            }
         }
     }
 
-    public void printOtherNode(Node node, javax.servlet.jsp.JspWriter out, String tabs, String
selected) throws Exception {
+    public void printOtherNode(Node node, javax.servlet.jsp.JspWriter out, String tabs) throws
Exception {
         String id = node.getID();
         Object obj = lookup(ctx, id);
         String clazz = obj.getClass().getName();
@@ -273,14 +277,9 @@
     }
 
     private Object getDeploymentId(Object ejb) throws Exception {
-        Class<?> proxyManagerClass = Class.forName("org.apache.openejb.util.proxy.ProxyManager");
-        Method getInvocationHandlerMethod = proxyManagerClass.getMethod("getInvocationHandler",
Object.class);
-        Object handler = getInvocationHandlerMethod.invoke(null, ejb);
-
-        Class<?> baseEjbProxyHandler = Class.forName("org.apache.openejb.core.ivm.BaseEjbProxyHandler");
-        Field field = baseEjbProxyHandler.getField("deploymentID");
-        Object deploymentID = field.get(handler);
-        return deploymentID;
+        org.apache.openejb.core.ivm.BaseEjbProxyHandler handler = (org.apache.openejb.core.ivm.BaseEjbProxyHandler)org.apache.openejb.util.proxy.ProxyManager.getInvocationHandler(ejb);
+        return handler.deploymentID;
+        
     }
 
     private Object lookup(Context ctx, String name) throws NamingException {



Mime
View raw message