// Copyright (c) 1999, 2000 Oracle Corporation
package oracle.jbo.common.ampool;
import oracle.jdeveloper.html.*;
import java.util.*;
import oracle.jbo.*;
/**
** This WebBean provides information regarding the current contents of the application module pool. You can use it
** in order to peek at the contents of the application pool.
**
** View implementation of PoolAdministrator
**
** @author Juan Oropeza
**/
public class PoolAdministrator extends WebBeanImpl
{
/**
* Constructor
*/
public PoolAdministrator() {
}
/**
** Reports pool information in an HTML format.
**/
public void reportPoolContents(HTMLDocument doc , ApplicationPool pool)
{
int nInstances = pool.getInstanceCount();
doc.addElement(new HTMLTextElement("
"));
doc.addHeader(2, "Pool Name:" + pool.getPoolName());
doc.skipLine(1);
doc.addHeader(2, "Number of instances:" + nInstances);
doc.skipLine(1);
HTMLTable table = new HTMLTable();
HTMLTableRow row = new HTMLTableRow();
doc.addElement(table);
row = new HTMLTableRow();
table.addRow(row);
row.addTextCell("Connect String");
row.addTextCell(pool.getConnectString());
row = new HTMLTableRow();
table.addRow(row);
row.addTextCell("Application Module Class");
row.addTextCell(pool.getApplicationModuleClass());
for(int i = 0; i < nInstances ; i++)
{
ApplicationModule am = pool.getInstance(i);
if(pool.isAvailable(am))
doc.addHeader(3, "Instance #" + i + " Available(Yes)");
else
doc.addHeader(3, "Instance #" + i + " Available(No)");
}
}
/**
** Renders Application Pool information to JSP page.
**/
public void render()
{
try
{
HTMLDocument doc = new HTMLDocument();
PoolMgr mgr = PoolMgr.getInstance();
Enumeration e = mgr.getPools();
while(e.hasMoreElements())
{
ApplicationPool pool = (ApplicationPool)e.nextElement();
reportPoolContents(doc, pool);
}
doc.render(out);
}
catch(Exception ex)
{
throw new RuntimeException(ex.getMessage());
}
}
}