User: starksm
Date: 01/11/28 11:19:31
Modified: src/main/org/jboss/naming Tag: Branch_2_4 JNDIView.java
Log:
Add support for displaying Proxy interfaces
Revision Changes Path
No revision
No revision
1.4.2.2 +60 -6 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.4.2.1
retrieving revision 1.4.2.2
diff -u -r1.4.2.1 -r1.4.2.2
--- JNDIView.java 2001/11/20 09:42:55 1.4.2.1
+++ JNDIView.java 2001/11/28 19:19:31 1.4.2.2
@@ -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="DefaultDomain:service=JNDIView" />
to the jboss.jcml file.
-@author [EMAIL PROTECTED]
+@author [EMAIL PROTECTED]
@author Vladimir Blagojevic <[EMAIL PROTECTED]>
-@version $Revision: 1.4.2.1 $
+@version $Revision: 1.4.2.2 $
*/
public class JNDIView extends ServiceMBeanSupport implements JNDIViewMBean
{
@@ -316,25 +317,55 @@
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
+ // Get the target of the link
try
{
LinkRef link = (LinkRef) ctx.lookupLink(name);
@@ -348,8 +379,31 @@
buffer.append("[invalid]");
}
}
- if( verbose )
+
+ // 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+")");
+ }
+ }
+ 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