Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Get Active Servers Detailed Information

 
Amy Howard
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My application servlet connects multiple ejb servers. I created the following method called getActiveServerList() without throws NamingException error.
* * Inputs : Detailed information stored in XML file for each connection
* * Outputs : Active server detailed information
Does someone know a better solution? Thanks in advance!
private TreeMap getActiveServerList(){
TreeMap serverList = new TreeMap();
ServerConfigMapper srvCfgMap = ServerConfigMapper.getInstance().
TreeMap serverDetailsFromXml = srvCfgMap.getServers();
Set servers = serverDetailsFromXml.entrySet();
Iterator it = servers.iterator();
while (it.hasNext()){
Map.Entry serverEntryFromXML = (Map.Entry) it.next();
ServerMapObject server = (ServerMapObject) serverEntryFromXml.getValue ();
/* find the JNDI Name*/
String serviceName = server.getEjbJNDI();

try{
//Get the initial context
Hashtable env= new Hashtable();

//Get the server iiop from XML
env.put(Context.PROVIDER_URL, server.getIiopUrl());
//To clear a cache
env.put ("com.ibm.websphere.naming.jndicache.cacheobject", "none");
//Get a naming context
InitialContext initCtx = new InitialContext (env);
Object jndiRef = initCtx.lookup(serviceName);
if (jndiRef != null) {
serverList.put(server.getServer(), server);
}
}catch(NamingException ne){
}catch(Exception e){
}
return serverList;
}
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the EJB forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic