import java.applet.*; import java.awt.*; import java.awt.event.*; import org.omg.CORBA.*; import WebFlow.*; import WebFlow.event.*; import java.io.*; import java.net.*; import java.util.*; //swing interface import javax.swing.*; public class ProcessTree extends JApplet implements ActionListener { private ORB orb; private String IOR; private WebFlowContext ws = null; //shows the current modules hierarchy private JTextArea status; //editfield for the root module IOR file URL private JTextField URLfield; private String IorURL; //Offset to indicate step left for each next layer private String Offset = " "; //=============================functions declaration========================= public void init() { //create orb if (!createOrb()) { status.append("Error creating ORB"); System.out.println("Error creating ORB"); return; } IorURL = getParameter("IorURL"); if (IorURL==null) IorURL = new String(); System.err.println(IorURL); //set up the applet interface setAppletInterface(""); IOR = ReadSTRFromURL(IorURL); if (IORtoWebFlowContext(IOR)) { // status.append("\n\nEstablished connection\n"); } else { status.append("\n\nError establishing connection\n"); return; } //Debugging purposes only, ot be removed if (ws.isWFServer()) { System.out.println(ws.getObjectID() + " is a server\n "); } else { System.out.println(ws.getObjectID() +" is a Context\n "); } //end debugging code //Processing Hierarchy System.out.println("Tree for the master IOR file URL " + IorURL + "\n"); status.append("Tree for the master IOR file URL " + IorURL +"\n"); status.append(getHierarchy(0, ws)); } //create ORB public boolean createOrb() { try { orb = ORB.init(this, new java.util.Properties()); return true; } catch (Exception e) { orb=null; return false; } } //Accepts IOR of the server to connect //Returns true if connects false otherwise public boolean IORtoWebFlowContext(String IOR) { try { org.omg.CORBA.Object MasterObj=orb.string_to_object(IOR); if (MasterObj!=null) System.out.println("orb.string_to_object Ok"); else { System.out.println("orb.string_to_object returned null"); return false; } ws = WebFlowContextHelper.narrow(MasterObj); System.out.println("Narrowed"); return true; } catch (Exception e) { return false; } } //recursively adds module hierarchy into the string result public String getHierarchy(int level, WebFlowContext node) { org.omg.CORBA.Object[] SlaveServers = node.toArray(); //get the number of staces at the beginning of the line to pront "nice" String thisOffset = new String(""); for (int j=0; j