User: starksm Date: 01/07/08 18:06:06 Modified: src/main/org/jboss/test/web/servlets Tag: Branch_2_4 DebugServlet.java ENCServlet.java Log: Merge latest changes from main to the 2.4 branch Revision Changes Path No revision No revision 1.3.2.1 +6 -102 jbosstest/src/main/org/jboss/test/web/servlets/DebugServlet.java Index: DebugServlet.java =================================================================== RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/web/servlets/DebugServlet.java,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -r1.3 -r1.3.2.1 --- DebugServlet.java 2001/06/10 00:19:33 1.3 +++ DebugServlet.java 2001/07/09 01:06:06 1.3.2.1 @@ -7,20 +7,17 @@ import java.security.Principal; import javax.naming.Context; import javax.naming.InitialContext; -import javax.naming.LinkRef; -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.NameClassPair; -import javax.naming.NameParser; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.jboss.test.web.util.Util; + /** A servlet that dumps out debugging information about its environment. - * @author [EMAIL PROTECTED] - * @version $Revision: 1.3 $ + * @author [EMAIL PROTECTED] + * @version $Revision: 1.3.2.1 $ */ public class DebugServlet extends HttpServlet { @@ -41,7 +38,7 @@ out.println("<h2>ClassLoaders</h2>"); ClassLoader cl = Thread.currentThread().getContextClassLoader(); out.println("<pre>"); - dumpClassLoader(cl, out); + Util.dumpClassLoader(cl, out); out.println("</pre>"); out.println("<h2>JNDI</h2>"); out.println("<pre>"); @@ -51,7 +48,7 @@ super.log("InitialContext.env: "+iniCtx.getEnvironment()); out.println("InitialContext.env: "+iniCtx.getEnvironment()); out.println("</pre><h3>java:comp/env</h3><pre>"); - showTree(" ", (Context) iniCtx.lookup("java:comp/env"), out); + Util.showTree(" ", (Context) iniCtx.lookup("java:comp/env"), out); } catch(Exception e) { @@ -73,97 +70,4 @@ { processRequest(request, response); } - - private void dumpClassLoader(ClassLoader cl, PrintWriter out) - { - int level = 0; - while( cl != null ) - { - String msg = "Servlet ClassLoader["+level+"]: "+cl.getClass().getName()+':'+cl.hashCode(); - super.log(msg); - out.println(msg); - if( cl instanceof URLClassLoader ) - { - URLClassLoader ucl = (URLClassLoader) cl; - URL[] urls = ucl.getURLs(); - msg = " URLs:"; - super.log(msg); - out.println(msg); - for(int u = 0; u < urls.length; u ++) - { - msg = " ["+u+"] = "+urls[u]; - super.log(msg); - out.println(msg); - } - } - cl = cl.getParent(); - level ++; - } - } - - private void showTree(String indent, Context ctx, PrintWriter out) - throws NamingException - { - ClassLoader loader = Thread.currentThread().getContextClassLoader(); - NamingEnumeration enum = ctx.list(""); - while( enum.hasMoreElements() ) - { - NameClassPair ncp = (NameClassPair)enum.next(); - String name = ncp.getName(); - out.print(indent + " +- " + name); - boolean recursive = false; - boolean isLinkRef = false; - try - { - Class c = loader.loadClass(ncp.getClassName()); - if( Context.class.isAssignableFrom(c) ) - recursive = true; - if( LinkRef.class.isAssignableFrom(c) ) - isLinkRef = true; - } - catch(ClassNotFoundException cnfe) - { - } - - if( isLinkRef ) - { - try - { - LinkRef link = (LinkRef) ctx.lookupLink(name); - out.print("[link -> "); - out.print(link.getLinkName()); - out.print(']'); - } - catch(Throwable e) - { - e.printStackTrace(); - out.print("[invalid]"); - } - } - out.println(); - - if( recursive ) - { - try - { - Object value = ctx.lookup(name); - if( value instanceof Context ) - { - Context subctx = (Context) value; - showTree(indent + " | ", subctx, out); - } - else - { - out.println(indent + " | NonContext: "+value); - } - } - catch(Throwable t) - { - out.println("Failed to lookup: "+name+", errmsg="+t.getMessage()); - } - } - - } - } - } 1.2.2.1 +9 -1 jbosstest/src/main/org/jboss/test/web/servlets/ENCServlet.java Index: ENCServlet.java =================================================================== RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/web/servlets/ENCServlet.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -r1.2 -r1.2.2.1 --- ENCServlet.java 2001/05/07 16:59:08 1.2 +++ ENCServlet.java 2001/07/09 01:06:06 1.2.2.1 @@ -17,7 +17,7 @@ /** * * @author [EMAIL PROTECTED] - * @version $Revision: 1.2 $ + * @version $Revision: 1.2.2.1 $ */ public class ENCServlet extends HttpServlet { @@ -81,6 +81,8 @@ System.out.println("Strings/s0 = "+s); s = (String) initCtx.lookup("java:comp/env/Strings/s1"); System.out.println("Strings/s1 = "+s); + s = (String) initCtx.lookup("java:comp/env/ejb/catalog/CatalogDAOClass"); + System.out.println("ejb/catalog/CatalogDAOClass = "+s); } private void testEjbRefs(Context initCtx, Context myEnv) throws NamingException { @@ -89,6 +91,12 @@ System.out.println("ejb/bean0 = "+ejb); ejb = initCtx.lookup("java:comp/env/ejb/bean1"); System.out.println("ejb/bean1 = "+ejb); + ejb = initCtx.lookup("java:comp/env/ejb/bean2"); + System.out.println("ejb/bean2 = "+ejb); + ejb = initCtx.lookup("java:comp/env/ejb/UnsecuredEJB"); + System.out.println("ejb/UnsecuredEJB = "+ejb); + ejb = initCtx.lookup("java:comp/env/ejb/SecuredEJB"); + System.out.println("ejb/SecuredEJB = "+ejb); } private void testJdbcDataSource(Context initCtx, Context myEnv) throws NamingException { _______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] http://lists.sourceforge.net/lists/listinfo/jboss-development