Hi,
Is there a nice portable way to programatically list the EJBeans on the
server ?
I have the following piece of code that works under WebLogic but not under
WebSphere because of the narrowing mechanism stuff.
-- Aravind
import java.util.*;
import javax.naming.*;
import javax.ejb.*;
public class Dump{
public static void main(String[] args) {
try {
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.jndi.CosNaming.CNInitialContextFactory");
p.put("java.naming.provider.url", "iiop://localhost:9019");
Context ctx = new InitialContext(p);
dumpEJBs(ctx);
}
catch (Exception e) {
System.out.println("Error:\n" + e);
}
}
private static void dumpEJBs(Context ctx) {
try {
NamingEnumeration enum = ctx.listBindings("");
while (enum.hasMore()) {
Binding binding = (Binding)enum.next();
Object object = binding.getObject();
System.out.println(">>> Debug Classname: " +
object.getClass().getName());
if (object instanceof EJBHome)
System.out.println("Classname: " + object.getClass().getName());
}
else if (object instanceof Context) {
try {
dumpEJBs((Context)object);
}
catch (Exception e) {
System.out.println("Error: " + e);
}
}
}
}
catch (NamingSecurityException nse) {
}
catch (SecurityException se) {
}
catch (Exception e) {
System.out.println("Error: " + e);
}
}
}
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".