package monitor;
import org.omg.CORBA.ORB;
import com.sssw.jbroker.api.admin.Manageable;
import com.sssw.jbroker.api.admin.ManageableCollection;
public class Client
{
public static void main(String[] args) throws Exception
{
| // create the ORB
| ORB orb = ORB.init(args, null);
|
| // lookup the manageable
| String lookup = "corbaloc::"+args[0]+":"+args[1]+"/jBrokerAdmin";
| Manageable mgble = (Manageable) orb.string_to_object(lookup);
|
| // list the manageable
| listManageable(mgble, 0);
}
static void listManageable(Manageable mgble, int depth) throws Exception
{
| System.out.println(tab(depth) + mgble.getName() + ":");
|
| depth++;
|
| // print the properties
| String[] props = mgble.propertyNames();
| Object[] values = mgble.getProperties(props);
| for (int i=0; i < props.length; i++) {
| | if (values[i] instanceof Manageable) {
| | | System.out.println(tab(depth) + props[i] + ":");
| | | listManageable((Manageable) values[i], depth);
| | } else System.out.println(tab(depth) + props[i] + "=" + values[i]);
| }
|
| // print the manageable collection
| if (mgble instanceof ManageableCollection) {
| | ManageableCollection mgblColl = (ManageableCollection) mgble;
| | String[] names = mgblColl.list();
| | for (int i=0; i < names.length; i++) {
| | | listManageable(mgblColl.getManageable(names[i]), depth);
| | }
| }
}
private static String tab(int num)
{
| String result="";
| for (int i=0; i < num; i++) result += " ";
| return result;
}
}