tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kma...@apache.org
Subject svn commit: r675823 - in /openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/webapp: viewclass.jsp viewejb.jsp
Date Fri, 11 Jul 2008 01:36:56 GMT
Author: kmalhi
Date: Thu Jul 10 18:36:56 2008
New Revision: 675823

URL: http://svn.apache.org/viewvc?rev=675823&view=rev
Log:
Fixed OPENEJB-834.
Fixed viewclass.jsp. Now viewclass.jsp displays all the classes you click on .
It also fails gracefully, i.e. if you enter a class name and click the view button, 
if the class is not found, you get an error message and can go back and try again
How it was fixed: When a user clicks on a class, the Class object is stored in the
session and viewClass.jsp simply retrieves the class from the sesion and displays its methods.


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

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=675823&r1=675822&r2=675823&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
Thu Jul 10 18:36:56 2008
@@ -21,7 +21,8 @@
 
 <%@ page import="
 java.lang.reflect.Method,
-java.lang.reflect.Modifier
+java.lang.reflect.Modifier,
+java.util.Map
 "%>
 <html>
 <head>
@@ -72,9 +73,11 @@
             <FONT SIZE="2">
 
                 <%
+               
+     String className = request.getParameter("class");
     try{
-        String className = request.getParameter("class");
-        if (className == null) {
+       
+        if (className == null || className.trim().length() == 0) {
             out.print("<b>Enter a class name to browse:</b>");
             out.print("<FORM NAME='view' METHOD='GET' ACTION='viewclass.jsp'>");
             out.print("<INPUT type='text' NAME='class' size='40' VALUE=''>");
@@ -94,13 +97,15 @@
             out.print(tab+getClassRef("javax.naming.Context")+"<br>");
 
         } else {
-            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);
+            Class clazz = (Class)session.getAttribute(className); 
+            if(clazz == null)
+            clazz = Class.forName(className);
+            printClass(clazz,out,session);
         }
     } catch (Exception e){
-        out.println("FAIL");
-        //throw e;
+        out.println("Could not find class "+className+" <br/>");
+        out.println("<a href='viewclass.jsp'>Back</a>");
+      //  throw e;
         //return;
     }
 %>
@@ -129,7 +134,7 @@
     String tab = "&nbsp;&nbsp;&nbsp;&nbsp;";
     boolean hasMethods;
 
-    public void printClass(Class clazz, javax.servlet.jsp.JspWriter out) throws Exception
{
+    public void printClass(Class clazz, javax.servlet.jsp.JspWriter out, HttpSession session)
throws Exception {
         out.print("<b>"+clazz.getName()+"</b><br>");
         Method[] methods = clazz.getDeclaredMethods();
         hasMethods = (methods.length > 0);
@@ -163,14 +168,14 @@
         Class sup = clazz.getSuperclass();
         if (sup != null) {
             out.print("<br><b>Extends:</b><br>");
-            out.print(tab+getClassRef(sup)+"<br>");
+            out.print(tab+getClassRef(sup,session)+"<br>");
         }
 
         Class[] intf = clazz.getInterfaces();
         if (intf.length > 0) {
             out.print("<br><b>Implements:</b><br>");
             for (int i=0; i < intf.length; i++){
-                out.print(tab+getClassRef(intf[i])+"<br>");
+                out.print(tab+getClassRef(intf[i],session)+"<br>");
             }
         }
     }
@@ -220,15 +225,21 @@
         return "<font color='"+color+"'>*</font>";
     }
 
-    public String getClassRef(Class clazz) throws Exception {
+/*    public String getClassRef(Class clazz) throws Exception {
             String name = clazz.getName();
             return "<a href='viewclass.jsp?class="+name+"'>"+name+"</a>";
     }
-    
+  */    
     public String getClassRef(String name) throws Exception {
             return "<a href='viewclass.jsp?class="+name+"'>"+name+"</a>";
     }
-    
+
+   public String getClassRef(Class clazz, HttpSession session) throws Exception {
+        String name = clazz.getName();
+        session.setAttribute(name,clazz);
+        return "<a href='viewclass.jsp?class=" + name + "'>" + name + "</a>";
+    }
+
     public String getShortClassRef(Class clazz) throws Exception {
         if (clazz.isPrimitive()) {
             return "<font color='gray'>"+clazz.getName()+"</font>";
@@ -247,5 +258,6 @@
         }
     }
 
+
 %>
 

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=675823&r1=675822&r2=675823&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
Thu Jul 10 18:36:56 2008
@@ -27,6 +27,7 @@
 javax.naming.Context,
 javax.naming.InitialContext
 "%>
+<%@ page import="javax.servlet.http.HttpServletRequest" %>
 <%@ page import="javax.servlet.http.HttpSession" %>
 <%@ page import="java.io.IOException" %>
 <%@ page import="java.util.HashMap" %>
@@ -161,17 +162,17 @@
         out.print("<table>");
         printRow("JNDI Name", jndiName, out);
         if(ejb.getRemoteInterface() != null)
-        printRow("Remote Interface", getClassRef(ejb.getRemoteInterface()), out);
+        printRow("Remote Interface", getClassRef(ejb.getRemoteInterface(),session), out);
         if(ejb.getHomeInterface() != null)
-        printRow("Home Interface", getClassRef(ejb.getHomeInterface()), out);
+        printRow("Home Interface", getClassRef(ejb.getHomeInterface(),session), out);
         if(ejb.getBeanClass() != null)
-        printRow("Bean Class", getClassRef(ejb.getBeanClass()), out);
+        printRow("Bean Class", getClassRef(ejb.getBeanClass(),session), out);
         if(ejb.getBusinessLocalInterfaces().size() > 0)
-        printRow("Business Local Interfaces", getClassRefs(ejb.getBusinessLocalInterfaces()),
out);
+        printRow("Business Local Interfaces", getClassRefs(ejb.getBusinessLocalInterfaces(),session),
out);
         if(ejb.getBusinessRemoteInterfaces().size() > 0)
-        printRow("Business Remote Interfaces", getClassRefs(ejb.getBusinessRemoteInterfaces()),
out);        
+        printRow("Business Remote Interfaces", getClassRefs(ejb.getBusinessRemoteInterfaces(),session),
out);        
         if (ejb.getComponentType() == BeanType.BMP_ENTITY || ejb.getComponentType() == BeanType.CMP_ENTITY)
{
-            printRow("Primary Key", getClassRef(ejb.getPrimaryKeyClass()), out);
+            printRow("Primary Key", getClassRef(ejb.getPrimaryKeyClass(),session), out);
         }
         String pepperImg = "<img src='images/pepper.gif' border='0'>";
         out.print("</table>");
@@ -223,14 +224,15 @@
         out.print("</font></td></tr>");
     }
 
-    public String getClassRef(Class clazz) throws Exception {
+    public String getClassRef(Class clazz, HttpSession session) throws Exception {
         String name = clazz.getName();
+        session.setAttribute(name,clazz);
         return "<a href='viewclass.jsp?class=" + name + "'>" + name + "</a>";
     }
-    public String getClassRefs(List<Class> classes) throws Exception{
+    public String getClassRefs(List<Class> classes, HttpSession session) throws Exception{
         String refs = "";
         for(Class clazz: classes){
-           refs += getClassRef(clazz)+"<br/>";
+           refs += getClassRef(clazz,session)+"<br/>";
         }
         return refs;
     }



Mime
View raw message