[JBoss-dev] CVS update: jbosstest/src/main/org/jboss/test/web/util ClassInClasses.java weblog4j.properties Util.java

2001-07-08 Thread Scott M Stark

  User: starksm 
  Date: 01/07/08 18:06:07

  Modified:src/main/org/jboss/test/web/util Tag: Branch_2_4 Util.java
  Added:   src/main/org/jboss/test/web/util Tag: Branch_2_4
ClassInClasses.java weblog4j.properties
  Log:
  Merge latest changes from main to the 2.4 branch
  
  Revision  ChangesPath
  No   revision
  
  
  No   revision
  
  
  1.2.2.1   +123 -1jbosstest/src/main/org/jboss/test/web/util/Util.java
  
  Index: Util.java
  ===
  RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/web/util/Util.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- Util.java 2001/06/01 14:08:49 1.2
  +++ Util.java 2001/07/09 01:06:07 1.2.2.1
  @@ -1,14 +1,24 @@
   package org.jboss.test.web.util;
   
  +import java.io.PrintWriter;
  +import java.io.StringWriter;
   import java.net.URL;
  +import java.net.URLClassLoader;
   import java.util.Date;
  +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;
   
   /** A trivial utility class that is placed into the lib/util.jar directory
   of the war archive and used by servlets in the war to test access to the
   lib jars.
   
   @author  [EMAIL PROTECTED]
  -@version $Revision: 1.2 $
  +@version $Revision: 1.2.2.1 $
   */
   public class Util
   {
  @@ -32,5 +42,117 @@
   System.out.println("getResource('web2log4j.properties') via CL = 
"+web2PropsURL2);
   System.out.println("getResource('/log4j.properties') via CL = "+propsURL2);
   return propsURL;
  +}
  +
  +public static 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());
  +}
  +   }
  +
  +}
  +}
  +
  +public static void dumpClassLoader(ClassLoader cl, PrintWriter out)
  +{
  +int level = 0;
  +while( cl != null )
  +{
  +String msg = "Servlet ClassLoader["+level+"]: 
"+cl.getClass().getName()+':'+cl.hashCode();
  +out.println(msg);
  +if( cl instanceof URLClassLoader )
  +{
  +URLClassLoader ucl = (URLClassLoader) cl;
  +URL[] urls = ucl.getURLs();
  +msg = "  URLs:";
  +out.println(msg);
  +for(int u = 0; u < urls.length; u ++)
  +{
  +msg = "  ["+u+"] = "+urls[u];
  +out.println(msg);
  +}
  +}
  +cl = cl.getParent();
  +level ++;
  +}
  +}
  +
  +public static void dumpENC(Print

[JBoss-dev] CVS update: jbosstest/src/main/org/jboss/test/web/util ClassInClasses.java weblog4j.properties Util.java

2001-06-23 Thread starksm

  User: starksm 
  Date: 01/06/23 20:47:11

  Modified:src/main/org/jboss/test/web/util Util.java
  Added:   src/main/org/jboss/test/web/util ClassInClasses.java
weblog4j.properties
  Log:
  Add tests of accessing WEB-INF elements from a JSP page
  
  Revision  ChangesPath
  1.3   +123 -1jbosstest/src/main/org/jboss/test/web/util/Util.java
  
  Index: Util.java
  ===
  RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/web/util/Util.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Util.java 2001/06/01 14:08:49 1.2
  +++ Util.java 2001/06/24 03:47:11 1.3
  @@ -1,14 +1,24 @@
   package org.jboss.test.web.util;
   
  +import java.io.PrintWriter;
  +import java.io.StringWriter;
   import java.net.URL;
  +import java.net.URLClassLoader;
   import java.util.Date;
  +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;
   
   /** A trivial utility class that is placed into the lib/util.jar directory
   of the war archive and used by servlets in the war to test access to the
   lib jars.
   
   @author  [EMAIL PROTECTED]
  -@version $Revision: 1.2 $
  +@version $Revision: 1.3 $
   */
   public class Util
   {
  @@ -32,5 +42,117 @@
   System.out.println("getResource('web2log4j.properties') via CL = 
"+web2PropsURL2);
   System.out.println("getResource('/log4j.properties') via CL = "+propsURL2);
   return propsURL;
  +}
  +
  +public static 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());
  +}
  +   }
  +
  +}
  +}
  +
  +public static void dumpClassLoader(ClassLoader cl, PrintWriter out)
  +{
  +int level = 0;
  +while( cl != null )
  +{
  +String msg = "Servlet ClassLoader["+level+"]: 
"+cl.getClass().getName()+':'+cl.hashCode();
  +out.println(msg);
  +if( cl instanceof URLClassLoader )
  +{
  +URLClassLoader ucl = (URLClassLoader) cl;
  +URL[] urls = ucl.getURLs();
  +msg = "  URLs:";
  +out.println(msg);
  +for(int u = 0; u < urls.length; u ++)
  +{
  +msg = "  ["+u+"] = "+urls[u];
  +out.println(msg);
  +}
  +}
  +cl = cl.getParent();
  +level ++;
  +}
  +}
  +
  +public static void dumpENC(PrintWriter out) throws NamingException
  +{
  +   InitialContext iniCtx = new InitialContext();
  +   Context