User: starksm 
  Date: 01/04/09 00:02:18

  Modified:    src/main/org/jboss/naming JNDIView.java
  Log:
  Display the name to which a LinkRef points to
  
  Revision  Changes    Path
  1.3       +35 -27    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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JNDIView.java     2001/03/01 06:39:57     1.2
  +++ JNDIView.java     2001/04/09 07:02:18     1.3
  @@ -13,11 +13,15 @@
   import java.net.URL;
   import java.util.Properties;
   import java.util.Iterator;
  -import javax.management.*;
  -import javax.naming.*;
  +import javax.management.MBeanServer;
  +import javax.management.ObjectName;
  +import javax.naming.Context;
  +import javax.naming.InitialContext;
  +import javax.naming.LinkRef;
  +import javax.naming.NameClassPair;
  +import javax.naming.NamingEnumeration;
  +import javax.naming.NamingException;
   
  -import org.jnp.server.Main;
  -
   import org.jboss.ejb.Application;
   import org.jboss.ejb.Container;
   import org.jboss.ejb.ContainerFactoryMBean;
  @@ -33,7 +37,7 @@
   
   @author [EMAIL PROTECTED]
   @author Vladimir Blagojevic <[EMAIL PROTECTED]>
  -@version $Revision: 1.2 $
  +@version $Revision: 1.3 $
   */
   public class JNDIView extends ServiceMBeanSupport implements JNDIViewMBean
   {
  @@ -164,20 +168,6 @@
           return "JNDIView";
       }
   
  -    public void initService()
  -      throws Exception
  -    {
  -    }
  -
  -    public void startService()
  -      throws Exception
  -    {
  -    }
  -
  -    public void stopService()
  -    {
  -    }
  -
       private void list(Context ctx, String indent, StringBuffer buffer, boolean 
verbose)
       {
           ClassLoader loader = Thread.currentThread().getContextClassLoader();
  @@ -188,26 +178,45 @@
                {
                   NameClassPair pair = (NameClassPair) ne.next();
                   boolean recursive = false;
  +                boolean isLinkRef = false;
                   try
                   {
                       Class c = loader.loadClass(pair.getClassName());
  -                    if (Context.class.isAssignableFrom (c))
  +                    if( Context.class.isAssignableFrom(c) )
                           recursive = true;
  +                    if( LinkRef.class.isAssignableFrom(c) )
  +                        isLinkRef = true;
                   }
                   catch(ClassNotFoundException cnfe)
                   {
                   }
   
  -                buffer.append(indent +  " +- " + pair.getName());
  +                String name = pair.getName();
  +                buffer.append(indent +  " +- " + name);
  +                if( isLinkRef )
  +                {
  +                    // Get the 
  +                    try
  +                    {
  +                        LinkRef link = (LinkRef) ctx.lookupLink(name);
  +                        buffer.append("[link -> ");
  +                        buffer.append(link.getLinkName());
  +                        buffer.append(']');
  +                    }
  +                    catch(Throwable e)
  +                    {
  +                        e.printStackTrace();
  +                        buffer.append("[invalid]");
  +                    }
  +                }
                   if( verbose )
                       buffer.append(" (class: "+pair.getClassName()+")");
                   buffer.append('\n');
                   if( recursive )
                   {
  -                    String ctxName = pair.getName();
  -                    try
  +                   try
                       {
  -                        Object value = ctx.lookup(ctxName);
  +                        Object value = ctx.lookup(name);
                           if( value instanceof Context )
                           {
                               Context subctx = (Context) value;
  @@ -221,12 +230,12 @@
                       }
                       catch(Throwable t)
                       {
  -                        buffer.append("Failed to lookup: "+ctxName+", 
errmsg="+t.getMessage());
  +                        buffer.append("Failed to lookup: "+name+", 
errmsg="+t.getMessage());
                           buffer.append('\n');
                       }
                  }
               }
  -            ne.close ();
  +            ne.close();
           }
           catch(NamingException ne)
           {
  @@ -245,4 +254,3 @@
           buffer.append("</pre>\n");
       }
   }
  -
  
  
  

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

Reply via email to