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 "%> @@ -72,9 +73,11 @@ <% + + String className = request.getParameter("class"); try{ - String className = request.getParameter("class"); - if (className == null) { + + if (className == null || className.trim().length() == 0) { out.print("Enter a class name to browse:"); out.print("
"); out.print(""); @@ -94,13 +97,15 @@ out.print(tab+getClassRef("javax.naming.Context")+"
"); } 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+"
"); + out.println("Back"); + // throw e; //return; } %> @@ -129,7 +134,7 @@ String tab = "    "; 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(""+clazz.getName()+"
"); Method[] methods = clazz.getDeclaredMethods(); hasMethods = (methods.length > 0); @@ -163,14 +168,14 @@ Class sup = clazz.getSuperclass(); if (sup != null) { out.print("
Extends:
"); - out.print(tab+getClassRef(sup)+"
"); + out.print(tab+getClassRef(sup,session)+"
"); } Class[] intf = clazz.getInterfaces(); if (intf.length > 0) { out.print("
Implements:
"); for (int i=0; i < intf.length; i++){ - out.print(tab+getClassRef(intf[i])+"
"); + out.print(tab+getClassRef(intf[i],session)+"
"); } } } @@ -220,15 +225,21 @@ return "*"; } - public String getClassRef(Class clazz) throws Exception { +/* public String getClassRef(Class clazz) throws Exception { String name = clazz.getName(); return ""+name+""; } - + */ public String getClassRef(String name) throws Exception { return ""+name+""; } - + + public String getClassRef(Class clazz, HttpSession session) throws Exception { + String name = clazz.getName(); + session.setAttribute(name,clazz); + return "" + name + ""; + } + public String getShortClassRef(Class clazz) throws Exception { if (clazz.isPrimitive()) { return ""+clazz.getName()+""; @@ -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(""); 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 = ""; out.print("
"); @@ -223,14 +224,15 @@ out.print("
"); } - 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 "" + name + ""; } - public String getClassRefs(List classes) throws Exception{ + public String getClassRefs(List classes, HttpSession session) throws Exception{ String refs = ""; for(Class clazz: classes){ - refs += getClassRef(clazz)+"
"; + refs += getClassRef(clazz,session)+"
"; } return refs; }