<% out.print(""); %> <%@ page import=" java.lang.reflect.Method, java.lang.reflect.Modifier, java.util.Map "%> TomEE
<% String className = request.getParameter("class"); try{ if (className == null || className.trim().length() == 0) { %> <% out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print("
" + getClassRef("javax.ejb.EJBHome") + "
" + getClassRef("javax.ejb.EJBObject") + "
" + getClassRef("javax.ejb.EnterpriseBean") + "
" + getClassRef("javax.ejb.SessionBean") + "
" + getClassRef("javax.ejb.EntityBean") + "
" + getClassRef("javax.servlet.http.HttpServlet") + "
" + getClassRef("javax.servlet.http.HttpServletRequest") + "
" + getClassRef("javax.servlet.http.HttpServletResponse") + "
" + getClassRef("javax.servlet.http.HttpSession") + "
" + getClassRef("javax.naming.InitialContext") + "
" + getClassRef("javax.naming.Context") + "
"); } else { Class clazz = (Class)session.getAttribute(className); if(clazz == null) clazz = Class.forName(className); printClass(clazz,out,session); } } catch (Exception e){ out.println("Could not find class "+className+"
"); out.println("Back"); // throw e; //return; } %>

<%! public void printClass(Class clazz, javax.servlet.jsp.JspWriter out, HttpSession session) throws Exception { out.print("

"+clazz.getName()+"

"); Method[] methods = clazz.getDeclaredMethods(); out.print(""); for (int i=0; i < methods.length; i++){ printMethod( methods[i], out ); } out.print("
"); Class sup = clazz.getSuperclass(); if (sup != null) { out.print("

Extends:

"); out.print("

" + getClassRef(sup,session) + "

"); } Class[] intf = clazz.getInterfaces(); if (intf.length > 0) { out.print("

Implements:

"); out.print(""); for (int i=0; i < intf.length; i++){ out.print(""); } out.print("
" + getClassRef(intf[i],session) + "
"); } } public void printMethod(Method m, javax.servlet.jsp.JspWriter out) throws Exception { out.print(""); out.print(" "+getModifier(m)); out.print(" "+getShortClassRef(m.getReturnType())+"  "); out.print(""+m.getName()+" "); Class[] params = m.getParameterTypes(); out.print("("); for (int j=0; j < params.length; j++){ out.print(getShortClassRef(params[j])); if (j != params.length-1) { out.print(", "); } } out.print(")"); Class[] excp = m.getExceptionTypes(); if (excp.length > 0) { out.print(" throws  "); for (int j=0; j < excp.length; j++){ out.print(getShortClassRef(excp[j])); if (j != excp.length-1) { out.print(", "); } } } out.print(""); } public String getModifier(Method m) throws Exception { int mod = m.getModifiers(); if (Modifier.isPublic(mod)) { return "public"; } else if (Modifier.isPrivate(mod)) { return "private"; } else if (Modifier.isProtected(mod)) { return "protected"; } else { return ""; } } /* 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 getClassRef(name); } public String getShortClassRef(Class clazz) throws Exception { if (clazz.isPrimitive()) { return ""+clazz.getName()+""; } else if (clazz.isArray() && clazz.getComponentType().isPrimitive()) { return ""+clazz.getComponentType()+"[]"; } else if (clazz.isArray()) { String name = clazz.getComponentType().getName(); int dot = name.lastIndexOf(".")+1; String shortName = name.substring(dot,name.length()); return ""+shortName+"[]"; } else { String name = clazz.getName(); int dot = name.lastIndexOf(".")+1; String shortName = name.substring(dot,name.length()); return ""+shortName+""; } } %>