User: starksm 
  Date: 01/11/28 11:15:58

  Modified:    src/main/org/jboss/naming JNDIView.java
  Log:
  Add support for displaying Proxy interfaces
  
  Revision  Changes    Path
  1.11      +60 -5     jboss/src/main/org/jboss/naming/JNDIView.java
  
  Index: JNDIView.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/naming/JNDIView.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- JNDIView.java     2001/09/11 18:35:03     1.10
  +++ JNDIView.java     2001/11/28 19:15:57     1.11
  @@ -10,6 +10,7 @@
   import java.io.IOException;
   import java.io.PrintWriter;
   import java.io.StringWriter;
  +import java.lang.reflect.Proxy;
   import java.net.URL;
   import java.util.Properties;
   import java.util.Iterator;
  @@ -34,9 +35,9 @@
   <mbean code="org.jboss.naming.JNDIView" name="JBOSS-SYSTEM:service=JNDIView" />
   to the jboss.jcml file.
   
  -@author <a href="mailto:[EMAIL PROTECTED]";>Scott Stark</a>.
  +@author <a href="mailto:[EMAIL PROTECTED]";>Scott Stark</a>.
   @author Vladimir Blagojevic <[EMAIL PROTECTED]>
  -@version $Revision: 1.10 $
  +@version $Revision: 1.11 $
   */
   public class JNDIView extends ServiceMBeanSupport implements JNDIViewMBean
   {
  @@ -316,22 +317,52 @@
                while( ne.hasMore() )
                {
                   NameClassPair pair = (NameClassPair) ne.next();
  +                String name = pair.getName();
  +                String className = pair.getClassName();
                   boolean recursive = false;
                   boolean isLinkRef = false;
  +                boolean isProxy = false;
  +                Class c = null;
                   try
                   {
  -                    Class c = loader.loadClass(pair.getClassName());
  +                    c = loader.loadClass(className);
                       if( Context.class.isAssignableFrom(c) )
                           recursive = true;
                       if( LinkRef.class.isAssignableFrom(c) )
                           isLinkRef = true;
  +                    isProxy = Proxy.isProxyClass(c);
                   }
                   catch(ClassNotFoundException cnfe)
                   {
  +                    // If this is a $Proxy* class its a proxy
  +                    if( className.startsWith("$Proxy") )
  +                    {
  +                        isProxy = true;
  +                        // We have to get the class from the binding
  +                        try
  +                        {
  +                            Object p = ctx.lookup(name);
  +                            c = p.getClass();
  +                        }
  +                        catch(NamingException e)
  +                        {
  +                            Throwable t = e.getRootCause();
  +                            if( t instanceof ClassNotFoundException )
  +                            {
  +                                // Get the class name from the exception msg
  +                                String msg = t.getMessage();
  +                                if( msg != null )
  +                                {
  +                                    // Reset the class name to the CNFE class
  +                                    className = msg;
  +                                }
  +                            }
  +                        }
  +                    }
                   }
   
  -                String name = pair.getName();
                   buffer.append(indent +  " +- " + name);
  +                // Display link targets
                   if( isLinkRef )
                   {
                       // Get the 
  @@ -347,9 +378,33 @@
                           e.printStackTrace();
                           buffer.append("[invalid]");
                       }
  +                }
  +
  +                // Display proxy interfaces
  +                if( isProxy )
  +                {
  +                    buffer.append(" (proxy: "+pair.getClassName());
  +                    if( c != null )
  +                    {
  +                        Class[] ifaces = c.getInterfaces();
  +                        buffer.append(" implements ");
  +                        for(int i = 0; i < ifaces.length; i ++)
  +                        {
  +                            buffer.append(ifaces[i]);
  +                            buffer.append(',');
  +                        }
  +                        buffer.setCharAt(buffer.length(), ')');
  +                    }
  +                    else
  +                    {
  +                        buffer.append(" implements "+className+")");
  +                    }
                   }
  -                if( verbose )
  +                else if( verbose )
  +                {
                       buffer.append(" (class: "+pair.getClassName()+")");
  +                }
  +
                   buffer.append('\n');
                   if( recursive )
                   {
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to