User: starksm
Date: 01/07/25 19:44:37
Modified: src/main/org/jboss/naming ExternalContext.java JNDIView.java
JNDIViewMBean.java NamingService.java
Log:
Integrate the jnp changes to support binding the name service on a specific address
Revision Changes Path
1.7 +1 -5 jboss/src/main/org/jboss/naming/ExternalContext.java
Index: ExternalContext.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/naming/ExternalContext.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ExternalContext.java 2001/06/18 20:01:27 1.6
+++ ExternalContext.java 2001/07/26 02:44:37 1.7
@@ -47,7 +47,7 @@
@see org.jboss.naming.NonSerializableFactory
@author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>.
-@version $Revision: 1.6 $
+@version $Revision: 1.7 $
*/
public class ExternalContext extends ServiceMBeanSupport implements
ExternalContextMBean
{
@@ -314,7 +314,6 @@
public void loadProperties(String contextPropsURL) throws IOException
{
InputStream is = null;
- IOException ex = null;
contextProps = new Properties();
// See if this is a URL we can load
@@ -328,14 +327,11 @@
catch(IOException e)
{ // Failed, try to locate a classpath resource below
is = null;
- ex = e;
}
is =
Thread.currentThread().getContextClassLoader().getResourceAsStream(contextPropsURL);
if( is == null )
{
- if( ex != null )
- throw ex;
throw new IOException("Failed to locate context props as URL or
resource:"+contextPropsURL);
}
contextProps.load(is);
1.6 +483 -449 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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JNDIView.java 2001/06/18 20:01:27 1.5
+++ JNDIView.java 2001/07/26 02:44:37 1.6
@@ -29,480 +29,514 @@
import org.jboss.util.ServiceMBeanSupport;
/** A simple utlity mbean that allows one to recursively list the default
-JBoss InitialContext.
-
-Deploy by adding:
-<mbean code="org.jboss.naming.JNDIView" name="DefaultDomain:service=JNDIView" />
-to the jboss.jcml file.
-
-@author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>.
-@author Vladimir Blagojevic <[EMAIL PROTECTED]>
-@version $Revision: 1.5 $
-*/
+ JBoss InitialContext.
+
+ Deploy by adding:
+ <mbean code="org.jboss.naming.JNDIView" name="DefaultDomain:service=JNDIView" />
+ to the jboss.jcml file.
+
+ @author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>.
+ @author Vladimir Blagojevic <[EMAIL PROTECTED]>
+ @version $Revision: 1.6 $
+ */
public class JNDIView extends ServiceMBeanSupport implements JNDIViewMBean
{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
- private MBeanServer server;
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
- public JNDIView()
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+ private MBeanServer server;
+ private String listType = "text/html";
+ private boolean isHTML = true;
+ private boolean isXML = false;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+ public JNDIView()
+ {
+ }
+
+ // Public --------------------------------------------------------
+
+ /** Get the mime-type for the value returned by the list() method.
+ */
+ public String getListType()
{
+ return this.listType;
}
-
- // Public --------------------------------------------------------
+ /** Set the mime-type for the value returned by the list() method.
+ @param mimeType: text/plain, text/html, text/xml are the currently
+ supported types.
+ */
+ public void setListType(String mimeType)
+ {
+ this.listType = mimeType;
+ }
- /** List deployed application java:comp namespaces, the java:
- namespace as well as the global InitialContext JNDI namespace.
+ /** List deployed application java:comp namespaces, the java:
+ namespace as well as the global InitialContext JNDI namespace.
@param verbose, if true, list the class of each object in addition to its name
+ @param maxdepth, the maxdepth to which an given context should be listed.
*/
- public String list(boolean verbose)
- {
- StringBuffer buffer = new StringBuffer();
- Iterator applications = null;
- Context context = null;
- ClassLoader currentLoader = Thread.currentThread().getContextClassLoader();
-
- /* Get all deployed applications so that we can list their
- java: namespaces which are ClassLoader local
- */
- try
- {
- applications = (Iterator) server.invoke(
- new ObjectName(ContainerFactoryMBean.OBJECT_NAME),
- "getDeployedApplications",
- new Object[] { },
- new String[] { });
- }
- catch(Exception e)
- {
- log.exception(e);
- buffer.append("Failed to getDeployedApplications\n");
- formatException(buffer, e);
- buffer.insert(0, "<pre>");
- buffer.append("</pre>");
- return buffer.toString();
- }
-
- // List each application JNDI namespace
- while(applications.hasNext())
- {
- Application app = (Application) applications.next();
- Iterator iter = app.getContainers().iterator();
- buffer.append("<h1>Application: " + app.getName() + "</h1>\n");
- while(iter.hasNext())
+ public String list(boolean verbose, int maxdepth)
+ {
+ return list(verbose, maxdepth, "text/html");
+ }
+
+ /** List the JBoss JNDI namespace.
+ @param verbose, flag indicating if the type of object should be shown
+ @param maxdepth, the maxdepth to which an given context should be listed.
+ @param mimeType: text/plain, text/html, text/xml are the currently
+ supported types.
+ */
+ public String list(boolean verbose, int maxdepth, String mimeType)
+ {
+ isHTML = mimeType.indexOf("html") > 0;
+ isXML = mimeType.indexOf("xml") > 0;
+ StringBuffer buffer = new StringBuffer();
+ Iterator applications = null;
+ Context context = null;
+ ClassLoader currentLoader = Thread.currentThread().getContextClassLoader();
+
+ startBuffer(buffer);
+ /* Get all deployed applications so that we can list their
+ java: namespaces which are ClassLoader local
+ */
+ try
+ {
+ applications = (Iterator) server.invoke(
+ new ObjectName(ContainerFactoryMBean.OBJECT_NAME),
+ "getDeployedApplications",
+ new Object[] { }, new String[] { });
+ }
+ catch(Exception e)
+ {
+ log.exception(e);
+ formatException("Failed to getDeployedApplications", buffer, e);
+ endBuffer(buffer);
+ return buffer.toString();
+ }
+
+ // List each application JNDI namespace
+ while(applications.hasNext())
+ {
+ Application app = (Application) applications.next();
+ Iterator iter = app.getContainers().iterator();
+ startApplication(app, buffer);
+ while(iter.hasNext())
+ {
+ Container con = (Container)iter.next();
+ /* Set the thread class loader to that of the container as
+ the class loader is used by the java: context object
+ factory to partition the container namespaces.
+ */
+ Thread.currentThread().setContextClassLoader(con.getClassLoader());
+ startContainer(con, buffer);
+
+ try
{
- Container con = (Container)iter.next();
- /* Set the thread class loader to that of the container as
- the class loader is used by the java: context object
- factory to partition the container namespaces.
- */
- Thread.currentThread().setContextClassLoader(con.getClassLoader());
- String bean = con.getBeanMetaData().getEjbName();
- buffer.append("<h2>java:comp namespace of the " + bean + "
bean:</h2>\n");
-
- try
- {
- context = new InitialContext();
- context = (Context)context.lookup("java:comp");
- }
- catch(NamingException e)
- {
- buffer.append("Failed on lookup, "+e.toString(true));
- formatException(buffer, e);
- continue;
- }
- buffer.append("<pre>\n");
- list(context, " ", buffer, verbose);
- buffer.append("</pre>\n");
+ context = new InitialContext();
+ context = (Context) context.lookup("java:comp");
}
- }
-
- // List the java: namespace
- Thread.currentThread().setContextClassLoader(currentLoader);
- try
- {
- context = new InitialContext();
- context = (Context) context.lookup("java:");
- buffer.append("<h1>java: Namespace</h1>\n");
- buffer.append("<pre>\n");
- list(context, " ", buffer, verbose);
- buffer.append("</pre>\n");
- }
- catch(NamingException e)
- {
- log.exception(e);
- buffer.append("Failed to get InitialContext, "+e.toString(true));
- formatException(buffer, e);
- }
-
- // List the global JNDI namespace
- try
- {
- context = new InitialContext();
- buffer.append("<h1>Global JNDI Namespace</h1>\n");
- buffer.append("<pre>\n");
- list(context, " ", buffer, verbose);
- buffer.append("</pre>\n");
- }
- catch(NamingException e)
- {
- log.exception(e);
- buffer.append("Failed to get InitialContext, "+e.toString(true));
- formatException(buffer, e);
- }
- return buffer.toString();
- }
-
- /**
- * List deployed application java:comp namespaces, the java:
- * namespace as well as the global InitialContext JNDI namespace in a
- * XML Format.
- *
- * @param verbose, if true, list the class of each object in addition to its
name
- **/
- public String listXML() {
- StringBuffer buffer = new StringBuffer();
- Iterator applications = null;
- Context context = null;
- ClassLoader currentLoader = Thread.currentThread().getContextClassLoader();
-
- /* Get all deployed applications so that we can list their
- java: namespaces which are ClassLoader local
- */
- try
- {
- applications = (Iterator) server.invoke(
- new ObjectName(ContainerFactoryMBean.OBJECT_NAME),
- "getDeployedApplications",
- new Object[] { },
- new String[] { });
- }
- catch(Exception e)
- {
- log.exception(e);
- buffer.append( "<jndi>" );
- buffer.append( "<error>" );
- buffer.append( '\n' );
- buffer.append( "<message>" + "Failed to getDeployedApplications " +
e.toString() + "</message>" );
- buffer.append( '\n' );
- buffer.append( "</error>" );
- buffer.append( '\n' );
- buffer.append( "</jndi>" );
- buffer.append( '\n' );
- return buffer.toString();
- }
-
- buffer.append( "<jndi>" );
- buffer.append( '\n' );
- // List each application JNDI namespace
- while(applications.hasNext())
- {
- Application app = (Application) applications.next();
- Iterator iter = app.getContainers().iterator();
- buffer.append( "<application>" );
- buffer.append( '\n' );
- buffer.append( "<file>" + app.getName() + "</file>" );
- buffer.append( '\n' );
- while(iter.hasNext())
+ catch(NamingException e)
{
- Container con = (Container)iter.next();
- /* Set the thread class loader to that of the container as
- the class loader is used by the java: context object
- factory to partition the container namespaces.
- */
- Thread.currentThread().setContextClassLoader(con.getClassLoader());
- String bean = con.getBeanMetaData().getEjbName();
- buffer.append( "<context>" );
- buffer.append( '\n' );
- buffer.append( "<name>java:comp</name>" );
- buffer.append( '\n' );
- buffer.append( "<attribute name=\"bean\">" + bean + "</attribute>"
);
- buffer.append( '\n' );
- try
- {
- context = new InitialContext();
- context = (Context)context.lookup("java:comp");
- }
- catch(NamingException e)
- {
- buffer.append( "<error>" );
- buffer.append( '\n' );
- buffer.append( "<message>" + "Failed on lookup, " + e.toString(
true ) + "</message>" );
- buffer.append( '\n' );
- buffer.append( "</error>" );
- buffer.append( '\n' );
- continue;
- }
- listXML( context, buffer );
- buffer.append( "</context>" );
- buffer.append( '\n' );
+ formatException("Failed on lookup, "+e.toString(true), buffer, e);
+ endContainer(con, buffer);
+ continue;
}
- buffer.append( "</application>" );
- buffer.append( '\n' );
- }
-
- // List the java: namespace
- Thread.currentThread().setContextClassLoader(currentLoader);
- try
- {
- context = new InitialContext();
- context = (Context) context.lookup("java:");
- buffer.append( "<context>" );
- buffer.append( '\n' );
- buffer.append( "<name>java:</name>" );
- buffer.append( '\n' );
- listXML( context, buffer );
- buffer.append( "</context>" );
- buffer.append( '\n' );
- }
- catch(NamingException e)
- {
- log.exception(e);
- buffer.append( "<error>" );
- buffer.append( '\n' );
- buffer.append( "<message>" + "Failed to get InitialContext, " +
e.toString( true ) + "</message>" );
- buffer.append( '\n' );
- buffer.append( "</error>" );
- buffer.append( '\n' );
- }
-
- // List the global JNDI namespace
- try
- {
- context = new InitialContext();
- buffer.append( "<context>" );
- buffer.append( '\n' );
- buffer.append( "<name>Global</name>" );
- buffer.append( '\n' );
- listXML( context, buffer );
- buffer.append( "</context>" );
- buffer.append( '\n' );
- }
- catch(NamingException e)
- {
- log.exception(e);
- buffer.append( "<error>" );
- buffer.append( '\n' );
- buffer.append( "<message>" + "Failed to get InitialContext, " +
e.toString( true ) + "</message>" );
- buffer.append( '\n' );
- buffer.append( "</error>" );
- buffer.append( '\n' );
- }
- buffer.append( "</jndi>" );
- buffer.append( '\n' );
- return buffer.toString();
- }
+ addContext(context, null, buffer, maxdepth);
+ endContainer(con, buffer);
+ }
+ endApplication(app, buffer);
+ }
+
+ // List the java: namespace
+ Thread.currentThread().setContextClassLoader(currentLoader);
+ try
+ {
+ context = new InitialContext();
+ context = (Context) context.lookup("java:");
+ addContext(context, "java: Namespace", buffer, maxdepth);
+ }
+ catch(NamingException e)
+ {
+ log.exception(e);
+ formatException("Failed to get InitialContext, "+e.toString(true), buffer,
e);
+ }
+
+ // List the global JNDI namespace
+ try
+ {
+ context = new InitialContext();
+ addContext(context, "Global JNDI Namespace", buffer, maxdepth);
+ }
+ catch(NamingException e)
+ {
+ log.exception(e);
+ formatException("Failed to get InitialContext, "+e.toString(true), buffer,
e);
+ }
+ endBuffer(buffer);
+ return buffer.toString();
+ }
+
+ /**
+ * List deployed application java:comp namespaces, the java:
+ * namespace as well as the global InitialContext JNDI namespace in a
+ * XML Format.
+ *
+ **/
+ public String listXML()
+ {
+ return list(true, Integer.MAX_VALUE, "text/xml");
+ }
- public ObjectName getObjectName(MBeanServer server, ObjectName name)
+ public ObjectName getObjectName(MBeanServer server, ObjectName name)
throws javax.management.MalformedObjectNameException
- {
- this.server = server;
- return new ObjectName(OBJECT_NAME);
- }
-
- public String getName()
- {
- return "JNDIView";
- }
+ {
+ this.server = server;
+ return new ObjectName(OBJECT_NAME);
+ }
+
+ public String getName()
+ {
+ return "JNDIView";
+ }
+
+ private void list(Context ctx, String indent, StringBuffer buffer,
+ boolean verbose, int depth, int maxdepth)
+ {
+ if( depth == maxdepth )
+ return;
+
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ NamingEnumeration ne = ctx.list("");
+ while( ne.hasMore() )
+ {
+ NameClassPair pair = (NameClassPair) ne.next();
+ boolean recursive = false;
+ boolean isLinkRef = false;
+ try
+ {
+ Class c = loader.loadClass(pair.getClassName());
+ if( Context.class.isAssignableFrom(c) )
+ recursive = true;
+ if( LinkRef.class.isAssignableFrom(c) )
+ isLinkRef = true;
+ }
+ catch(ClassNotFoundException cnfe)
+ {
+ }
- private void list(Context ctx, String indent, StringBuffer buffer, boolean
verbose)
- {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- try
- {
- NamingEnumeration ne = ctx.list("");
- while( ne.hasMore() )
- {
- NameClassPair pair = (NameClassPair) ne.next();
- boolean recursive = false;
- boolean isLinkRef = false;
- try
- {
- Class c = loader.loadClass(pair.getClassName());
- if( Context.class.isAssignableFrom(c) )
- recursive = true;
- if( LinkRef.class.isAssignableFrom(c) )
- isLinkRef = true;
- }
- catch(ClassNotFoundException cnfe)
- {
- }
-
- 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 )
- {
- try
- {
- Object value = ctx.lookup(name);
- if( value instanceof Context )
- {
- Context subctx = (Context) value;
- list(subctx, indent + " | ", buffer, verbose);
- }
- else
- {
- buffer.append(indent + " | NonContext: "+value);
- buffer.append('\n');
- }
- }
- catch(Throwable t)
- {
- buffer.append("Failed to lookup: "+name+",
errmsg="+t.getMessage());
- buffer.append('\n');
- }
+ String name = pair.getName();
+ String className = null;
+ if( verbose )
+ className = pair.getClassName();
+ if( isLinkRef )
+ {
+ // Get the
+ try
+ {
+ LinkRef link = (LinkRef) ctx.lookupLink(name);
+ addLinkRef(link, name, className, buffer);
+ }
+ catch(Throwable e)
+ {
+ e.printStackTrace();
}
}
- ne.close();
- }
- catch(NamingException ne)
- {
- buffer.append("error while listing context "+ctx.toString () + ": " +
ne.toString(true));
- formatException(buffer, ne);
- }
- }
-
- private void listXML( Context ctx, StringBuffer buffer )
- {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- try
- {
- NamingEnumeration ne = ctx.list("");
- while( ne.hasMore() )
- {
- NameClassPair pair = (NameClassPair) ne.next();
- boolean recursive = false;
- boolean isLinkRef = false;
- try
- {
- Class c = loader.loadClass(pair.getClassName());
- if( Context.class.isAssignableFrom(c) )
- recursive = true;
- if( LinkRef.class.isAssignableFrom(c) )
- isLinkRef = true;
- }
- catch(ClassNotFoundException cnfe)
- {
- }
-
- String name = pair.getName();
- if( isLinkRef ) {
- // Get the
- try
- {
- LinkRef link = (LinkRef) ctx.lookupLink(name);
- buffer.append( "<link-ref>" );
+ if( recursive )
+ {
+ try
+ {
+ Object value = ctx.lookup(name);
+ if( value instanceof Context )
+ {
+ Context subctx = (Context) value;
+ list(subctx, indent + " | ", buffer, verbose, depth+1,
maxdepth);
+ }
+ else
+ {
+ buffer.append(indent + " | NonContext: "+value);
+ buffer.append('\n');
+ }
+ }
+ catch(Throwable t)
+ {
+ buffer.append("Failed to lookup: "+name+",
errmsg="+t.getMessage());
+ buffer.append('\n');
+ }
+ }
+ }
+ ne.close();
+ }
+ catch(NamingException ne)
+ {
+ String msg = "error while listing context "+ctx.toString() + ": " +
ne.toString(true);
+ formatException(msg, buffer, ne);
+ }
+ }
+
+ private void listXML( Context ctx, StringBuffer buffer )
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ NamingEnumeration ne = ctx.list("");
+ while( ne.hasMore() )
+ {
+ NameClassPair pair = (NameClassPair) ne.next();
+ boolean recursive = false;
+ boolean isLinkRef = false;
+ try
+ {
+ Class c = loader.loadClass(pair.getClassName());
+ if( Context.class.isAssignableFrom(c) )
+ recursive = true;
+ if( LinkRef.class.isAssignableFrom(c) )
+ isLinkRef = true;
+ }
+ catch(ClassNotFoundException cnfe)
+ {
+ }
+
+ String name = pair.getName();
+ if( isLinkRef )
+ {
+ // Get the
+ try
+ {
+ LinkRef link = (LinkRef) ctx.lookupLink(name);
+ buffer.append( "<link-ref>" );
+ buffer.append( '\n' );
+ buffer.append( "<name>" + pair.getName() + "</name>" );
+ buffer.append( '\n' );
+ buffer.append( "<link>" + link.getLinkName() + "</link>" );
+ buffer.append( '\n' );
+ buffer.append( "<attribute name=\"class\">" + pair.getClassName()
+ "</attribute>" );
+ buffer.append( '\n' );
+ buffer.append( "</link-ref>" );
+ buffer.append( '\n' );
+ }
+ catch(Throwable e)
+ {
+ e.printStackTrace();
+ buffer.append( "<link-ref>" );
+ buffer.append( '\n' );
+ buffer.append( "<name>Invalid</name>" );
+ buffer.append( '\n' );
+ buffer.append( "</link-ref>" );
+ buffer.append( '\n' );
+ }
+ }
+ else
+ {
+ if( recursive )
+ {
+ try
+ {
+ Object value = ctx.lookup(name);
+ if( value instanceof Context )
+ {
+ Context subctx = (Context) value;
+ buffer.append( "<context>" );
buffer.append( '\n' );
buffer.append( "<name>" + pair.getName() + "</name>" );
buffer.append( '\n' );
- buffer.append( "<link>" + link.getLinkName() + "</link>" );
- buffer.append( '\n' );
buffer.append( "<attribute name=\"class\">" +
pair.getClassName() + "</attribute>" );
+ buffer.append( '\n' );
+ listXML( subctx, buffer );
+ buffer.append( "</context>" );
buffer.append( '\n' );
- buffer.append( "</link-ref>" );
+ }
+ else
+ {
+ buffer.append( "<non-context>" );
buffer.append( '\n' );
- }
- catch(Throwable e)
- {
- e.printStackTrace();
- buffer.append( "<link-ref>" );
+ buffer.append( "<name>" + pair.getName() + "</name>" );
buffer.append( '\n' );
- buffer.append( "<name>Invalid</name>" );
+ buffer.append( "<attribute name=\"value\">" + value +
"</attribute>" );
buffer.append( '\n' );
- buffer.append( "</link-ref>" );
+ buffer.append( "</non-context>" );
buffer.append( '\n' );
- }
- }
- else {
- if( recursive ) {
- try {
- Object value = ctx.lookup(name);
- if( value instanceof Context ) {
- Context subctx = (Context) value;
- buffer.append( "<context>" );
- buffer.append( '\n' );
- buffer.append( "<name>" + pair.getName() + "</name>"
);
- buffer.append( '\n' );
- buffer.append( "<attribute name=\"class\">" +
pair.getClassName() + "</attribute>" );
- buffer.append( '\n' );
- listXML( subctx, buffer );
- buffer.append( "</context>" );
- buffer.append( '\n' );
- }
- else {
- buffer.append( "<non-context>" );
- buffer.append( '\n' );
- buffer.append( "<name>" + pair.getName() + "</name>"
);
- buffer.append( '\n' );
- buffer.append( "<attribute name=\"value\">" + value
+ "</attribute>" );
- buffer.append( '\n' );
- buffer.append( "</non-context>" );
- buffer.append( '\n' );
- }
- }
- catch(Throwable t) {
- buffer.append( "<error>" );
- buffer.append( '\n' );
- buffer.append( "<message>" + "Failed to lookup:
"+name+", errmsg="+t.getMessage() + "</message>" );
- buffer.append( '\n' );
- buffer.append( "</error>" );
- buffer.append( '\n' );
- }
- }
- else {
- buffer.append( "<leaf>" );
- buffer.append( '\n' );
- buffer.append( "<name>" + pair.getName() + "</name>" );
- buffer.append( '\n' );
- buffer.append( "<attribute name=\"class\">" +
pair.getClassName() + "</attribute>" );
- buffer.append( '\n' );
- buffer.append( "</leaf>" );
- buffer.append( '\n' );
- }
- }
+ }
+ }
+ catch(Throwable t)
+ {
+ buffer.append( "<error>" );
+ buffer.append( '\n' );
+ buffer.append( "<message>" + "Failed to lookup: "+name+",
errmsg="+t.getMessage() + "</message>" );
+ buffer.append( '\n' );
+ buffer.append( "</error>" );
+ buffer.append( '\n' );
+ }
+ }
+ else
+ {
+ buffer.append( "<leaf>" );
+ buffer.append( '\n' );
+ buffer.append( "<name>" + pair.getName() + "</name>" );
+ buffer.append( '\n' );
+ buffer.append( "<attribute name=\"class\">" + pair.getClassName()
+ "</attribute>" );
+ buffer.append( '\n' );
+ buffer.append( "</leaf>" );
+ buffer.append( '\n' );
+ }
}
- ne.close();
- }
- catch(NamingException ne)
- {
- buffer.append( "<error>" );
- buffer.append( '\n' );
- buffer.append( "<message>" + "error while listing context
"+ctx.toString () + ": " + ne.toString(true) + "</message>" );
- buffer.append( '\n' );
- buffer.append( "</error>" );
- buffer.append( '\n' );
- }
- }
+ }
+ ne.close();
+ }
+ catch(NamingException ne)
+ {
+ buffer.append( "<error>" );
+ buffer.append( '\n' );
+ buffer.append( "<message>" + "error while listing context "+ctx.toString()
+ ": " + ne.toString(true) + "</message>" );
+ buffer.append( '\n' );
+ buffer.append( "</error>" );
+ buffer.append( '\n' );
+ }
+ }
+
+ private void startBuffer(StringBuffer buffer)
+ {
+ if( isHTML )
+ buffer.insert(0, "<pre>");
+ else if( isXML )
+ buffer.insert(0, "<jndi>");
+ }
+ private void endBuffer(StringBuffer buffer)
+ {
+ if( isHTML )
+ buffer.append("</pre>");
+ else if( isXML )
+ buffer.append("</jndi>");
+ }
+ private void startApplication(Application app, StringBuffer buffer)
+ {
+ if( isHTML )
+ {
+ buffer.append("<h1>Application: " + app.getName() + "</h1>\n");
+ }
+ else if( isXML )
+ {
+ buffer.append( "<application>" );
+ buffer.append( '\n' );
+ buffer.append( "<file>" + app.getName() + "</file>" );
+ buffer.append( '\n' );
+ }
+ else
+ {
+ buffer.append("Application: " + app.getName() + "\n");
+ }
+ }
+ private void endApplication(Application app, StringBuffer buffer)
+ {
+ if( isHTML )
+ {
+ }
+ else if( isXML )
+ {
+ buffer.append( "</application>\n" );
+ }
+ }
+
+ private void startContainer(Container con, StringBuffer buffer)
+ {
+ String bean = con.getBeanMetaData().getEjbName();
+ if( isHTML )
+ {
+ buffer.append("<h2>java:comp namespace of the " + bean + " bean:</h2>\n");
+ }
+ else if( isXML )
+ {
+ buffer.append( "<context>" );
+ buffer.append( '\n' );
+ buffer.append( "<name>java:comp</name>" );
+ buffer.append( '\n' );
+ buffer.append( "<attribute name=\"bean\">" + bean + "</attribute>" );
+ buffer.append( '\n' );
+ }
+ else
+ {
+ buffer.append("java:comp namespace of the " + bean + " bean:\n");
+ }
+ }
+ private void endContainer(Container con, StringBuffer buffer)
+ {
+ if( isXML )
+ {
+ buffer.append( "</context>" );
+ buffer.append( '\n' );
+ }
+ }
+
+ private void addContext(Context context, String name, StringBuffer buffer, int
maxdepth)
+ {
+ if( isHTML )
+ {
+ buffer.append("<pre>\n");
+ if( name != null )
+ buffer.append("<h1>"+name+"</h1>\n");
+ list(context, " ", buffer, true, 0, maxdepth);
+ buffer.append("</pre>\n");
+ }
+ else if( isXML )
+ {
+ buffer.append( "<context>\n" );
+ if( name != null )
+ buffer.append( "<name>Global</name>\n" );
+ list(context, " ", buffer, true, 0, maxdepth);
+ buffer.append( "</context>\n" );
+ }
+ }
+ private void addLinkRef(LinkRef link, String name, String className,
StringBuffer buffer)
+ {
+ String linkName = null;
+ try
+ {
+ linkName = link.getLinkName();
+ }
+ catch(NamingException e)
+ {
+ linkName = "(invalid)";
+ }
+ if( isHTML )
+ {
+ String indent = "";
+ buffer.append(indent + " +- " + name);
+ buffer.append("[link -> ");
+ buffer.append(linkName);
+ buffer.append(']');
+ if( className != null )
+ buffer.append(" (class: "+className+")");
+ buffer.append('\n');
+ }
+ }
+
+ private void formatException(String msg, StringBuffer buffer, Throwable t)
+ {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ t.printStackTrace(pw);
+ String trace = sw.toString();
+ if( isHTML )
+ {
+ buffer.append(msg);
+ buffer.append("<pre>\n");
+ buffer.append(trace);
+ buffer.append("</pre>\n");
+ }
+ else if( isXML )
+ {
+ buffer.append( "<error>" );
+ buffer.append( '\n' );
+ buffer.append( "<message>" + msg + "</message>" );
+ buffer.append( "<trace>" + trace + "</trace>" );
+ buffer.append( '\n' );
+ buffer.append( "</error>" );
+ buffer.append( '\n' );
+ }
+ }
- private void formatException(StringBuffer buffer, Throwable t)
- {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- buffer.append("<pre>\n");
- t.printStackTrace(pw);
- buffer.append(sw.toString());
- buffer.append("</pre>\n");
- }
}
1.4 +12 -3 jboss/src/main/org/jboss/naming/JNDIViewMBean.java
Index: JNDIViewMBean.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/naming/JNDIViewMBean.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- JNDIViewMBean.java 2001/06/18 20:01:27 1.3
+++ JNDIViewMBean.java 2001/07/26 02:44:37 1.4
@@ -13,7 +13,7 @@
*
*
@author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>.
-@version $Revision: 1.3 $
+@version $Revision: 1.4 $
*/
public interface JNDIViewMBean extends org.jboss.util.ServiceMBean
{
@@ -24,9 +24,18 @@
/** List the JBoss JNDI namespace.
- @param verbose,
+ @param verbose, flag indicating if the type of object should be shown
+ @param maxdepth, the maxdepth to which an given context should be listed.
*/
- public String list(boolean verbose);
+ public String list(boolean verbose, int maxdepth);
+ /** List the JBoss JNDI namespace.
+
+ @param verbose, flag indicating if the type of object should be shown
+ @param maxdepth, the maxdepth to which an given context should be listed.
+ @param mimeType: text/plain, text/html, text/xml are the currently
+ supported types.
+ */
+ public String list(boolean verbose, int maxdepth, String mimeType);
/**
* List the JBoss JNDI namespace in XML Format
1.14 +21 -1 jboss/src/main/org/jboss/naming/NamingService.java
Index: NamingService.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/naming/NamingService.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- NamingService.java 2001/06/22 19:06:23 1.13
+++ NamingService.java 2001/07/26 02:44:37 1.14
@@ -7,6 +7,7 @@
package org.jboss.naming;
import java.io.InputStream;
+import java.net.UnknownHostException;
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.Properties;
@@ -28,7 +29,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Rickard �berg</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>.
- * @version $Revision: 1.13 $
+ * @version $Revision: 1.14 $
*
* Revisions:
* 20010622 scott.stark: Report IntialContext env for problem tracing
@@ -72,6 +73,24 @@
return naming.getRmiPort();
}
+ public String getBindAddress()
+ {
+ return naming.getBindAddress();
+ }
+ public void setBindAddress(String host) throws UnknownHostException
+ {
+ naming.setBindAddress(host);
+ }
+
+ public int getBacklog()
+ {
+ return naming.getBacklog();
+ }
+ public void setBacklog(int backlog)
+ {
+ naming.setBacklog(backlog);
+ }
+
public String getClientSocketFactory()
{
return naming.getClientSocketFactory();
@@ -165,4 +184,5 @@
// Protected -----------------------------------------------------
}
+
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development