Christy's version

christy [2001-12-07 17:08:17]
Christy's version
Filename
habmonitors/CloseableFrame.java
habmonitors/Console.java
habmonitors/Corbawith1.4/.serviceList
habmonitors/Corbawith1.4/EventService.java
habmonitors/Corbawith1.4/Hello.idl
habmonitors/Corbawith1.4/HelloClient.java
habmonitors/Corbawith1.4/HelloServer.java
habmonitors/Corbawith1.4/NYCPassListService.java
habmonitors/Corbawith1.4/ResidentsListService.java
habmonitors/FileIO.java
habmonitors/FilterThread.java
habmonitors/FrontEnd.java
habmonitors/FrontEndFrame.java
habmonitors/FrontEndPanel.java
habmonitors/GateKeeper.java
habmonitors/Habitat.java
habmonitors/README
habmonitors/ServiceInterface.java
habmonitors/Treaty.java
habmonitors/monitors/ControlFrontEnd.java
habmonitors/monitors/ControlFrontEndFrame.java
habmonitors/monitors/ControlFrontEndPanel.java
habmonitors/monitors/EventService.java
habmonitors/monitors/Monitor.java
habmonitors/portal/HabitatMonitor.java
habmonitors/portal/HabitatPortal.java
habmonitors/services/.AmTrakServiceList
habmonitors/services/.NYPDServiceList
habmonitors/services/.TexasServiceList
habmonitors/services/AlertService.java
habmonitors/services/EventService.java
habmonitors/services/MapService.java
habmonitors/services/NYCPassListService.java
habmonitors/services/ResidentsListService.java
diff --git a/habmonitors/CloseableFrame.java b/habmonitors/CloseableFrame.java
new file mode 100644
index 0000000..d377afb
--- /dev/null
+++ b/habmonitors/CloseableFrame.java
@@ -0,0 +1,23 @@
+package psl.habitats;
+
+import java.awt.*;
+import java.awt.event.*;
+
+public class CloseableFrame extends Frame {
+  public CloseableFrame() {
+    addWindowListener(new WindowAdapter() {public void
+        windowClosing(WindowEvent e ) {System.exit(0); }} );
+    setSize(300,200);
+		setLocation(300,200);
+  }
+	public void sTitle(String name) {
+    setTitle(name);
+	}
+  public static void main(String[] args) {
+    CloseableFrame c = new CloseableFrame();
+    c.show();
+  }
+}
+
+
+
diff --git a/habmonitors/Console.java b/habmonitors/Console.java
new file mode 100644
index 0000000..14a16ab
--- /dev/null
+++ b/habmonitors/Console.java
@@ -0,0 +1,26 @@
+package psl.habitats;
+
+import java.awt.*;
+import java.util.*;
+import java.awt.event.*;
+
+public class Console extends CloseableFrame {
+	TextArea log;
+	Panel cf_panel;
+
+public Console() {
+  log = new TextArea();
+  cf_panel = new Panel();
+  cf_panel.add(log);
+}
+
+  public void cf_show(String name) {
+		setTitle(name);
+		add(cf_panel);
+		show();
+  }
+
+  public void cf_add(String mesg) {
+		log.append(mesg);
+  }
+}
diff --git a/habmonitors/Corbawith1.4/.serviceList b/habmonitors/Corbawith1.4/.serviceList
new file mode 100644
index 0000000..67174ed
--- /dev/null
+++ b/habmonitors/Corbawith1.4/.serviceList
@@ -0,0 +1,2 @@
+Maps,psl.habitats.services.GatherInfo
+Hello,psl.habitats.services.HelloServer
diff --git a/habmonitors/Corbawith1.4/EventService.java b/habmonitors/Corbawith1.4/EventService.java
new file mode 100644
index 0000000..ef7a7f5
--- /dev/null
+++ b/habmonitors/Corbawith1.4/EventService.java
@@ -0,0 +1,168 @@
+package psl.habitats.services;
+import psl.habitats.*;
+
+import java.util.Vector;
+import java.util.Hashtable;
+import java.util.Enumeration;
+
+public class EventService implements ServiceInterface {
+  String myDescription = "Event_Manager";
+  Habitat masterHabitat = null;
+
+  private final Hashtable informationCatalogue = new Hashtable();
+
+  private static final String key1 = "First_Name";
+  private static final String key2 = "Last_Name";
+  private static final String key3 = "Boarding_City";
+  private static final String key4 = "Boarding_Date";
+  private static final String key5 = "Address";
+  private static final String key6 = "Telephone";
+  private static final String key7 = "SSN";
+  private static final String key8 = "Image";
+  private static final String key9 = "Age";
+
+  public void initialize(Habitat _h){
+    masterHabitat = _h;
+  }
+  public String getDescription(){
+    return myDescription;
+  }
+	public void startDisplay(){
+    // start the GUI here
+  }
+
+  private static final String PHASE_ONE_PEER = "NYC_Passengers_Query";
+  private static final String PHASE_TWO_PEER = "ResidentsListService";
+  private static final String PHASE_THREE_PEER = "AlertServcie";
+
+  int phaseOneProgress = 0, phaseTwoProgress = 0, phaseThreeProgress = 0;
+
+  public Hashtable performService(String _senderService, Hashtable ipList) {
+    Hashtable result = new Hashtable();
+    if(_senderService.equals(PHASE_ONE_PEER)) {
+      switch (phaseOneProgress) {
+      case 0:
+        result.put(key1, "Alpa");
+        phaseOneProgress++;
+        break;
+
+      case 1:
+        for (Enumeration e=ipList.keys(); e.hasMoreElements(); ) {
+          String key = e.nextElement().toString();
+          informationCatalogue.put(key, ipList.get(key));
+        }
+        result.put("Terminate_Session", "SESSION_ENDED");
+        phaseOneProgress = 0;
+
+        // initiate phase-II
+        phaseTwo();
+        break;
+
+      }
+
+    } else if(_senderService.equals(PHASE_TWO_PEER)) {
+      switch (phaseTwoProgress) {
+      case 0:
+        result.put(key1, informationCatalogue.get(key1));
+        result.put(key2, informationCatalogue.get(key2));
+        phaseTwoProgress++;
+        break;
+
+      case 1:
+        for (Enumeration e=ipList.keys(); e.hasMoreElements(); ) {
+          String key = e.nextElement().toString();
+          informationCatalogue.put(key, ipList.get(key));
+        }
+        result.put("Terminate_Session", "SESSION_ENDED");
+        phaseTwoProgress = 0;
+
+        // initiate phase-III
+        phaseThree();
+        break;
+
+      }
+    } else if(_senderService.equals(PHASE_THREE_PEER)) {
+      switch (phaseThreeProgress) {
+      case 0:
+        for (Enumeration e=informationCatalogue.keys(); e.hasMoreElements(); ) {
+          String key = e.nextElement().toString();
+          if (key.equals(key3) || key.equals(key4)) continue;
+          result.put(key, informationCatalogue.get(key));
+        }
+        phaseThreeProgress++;
+        break;
+
+      case 1:
+        phaseThreeProgress = 0;
+        result.put("Terminate_Session", "SESSION_ENDED");
+        break;
+
+      }
+    }
+
+    return result;
+  }
+  private void phaseOne(String name) {
+    // invoked by user entering chor's name
+    // some intelligent workflow suggested that service to be contacted
+    String useService = "NYC_Passengers_Query";
+    if (!Habitat.localService(useService)) {
+      Hashtable ipList = new Hashtable();
+      ipList.put("habitatCategory","NYCTransitHabitat");
+      ipList.put("EventType","ServiceRequest");
+      ipList.put("Request4Service", useService);
+      ipList.put("totalParams","1");
+      ipList.put("params1", key1);
+      ipList.put("totalRetvals", "4");
+      ipList.put("retvals1", key1);
+      ipList.put("retvals2", key2);
+      ipList.put("retvals3", key3);
+      ipList.put("retvals4", key4);
+
+      masterHabitat.gk.broadcast_req("NYCTransitHabitat", ipList);
+    }
+  }
+
+  private void phaseTwo() {
+    String useService = "TexasResidentInfo";
+    if (!Habitat.localService(useService)) {
+      Hashtable ipList = new Hashtable();
+      ipList.put("habitatCategory","TexasStateHabitat");
+      ipList.put("EventType","ServiceRequest");
+      ipList.put("Request4Service", useService);
+      ipList.put("totalParams","2");
+      ipList.put("params1", key1);
+      ipList.put("params2", key2);
+      ipList.put("totalRetvals", "5");
+      ipList.put("retvals3", key5);
+      ipList.put("retvals4", key6);
+      ipList.put("retvals5", key7);
+      ipList.put("retvals6", key8);
+      ipList.put("retvals7", key9);
+
+      masterHabitat.gk.broadcast_req("TexasStateHabitat", ipList);
+    }
+  }
+
+  private void phaseThree() {
+    String useService = "AlertService";
+    if (!Habitat.localService(useService)) {
+      Hashtable ipList = new Hashtable();
+      ipList.put("habitatCategory","NYCTransitHabitat");
+      ipList.put("EventType","ServiceRequest");
+      ipList.put("Request4Service", useService);
+      ipList.put("totalParams","2");
+      ipList.put("params1", key1);
+      ipList.put("params2", key2);
+      ipList.put("params3", key5);
+      ipList.put("params4", key6);
+      ipList.put("params5", key7);
+      ipList.put("params6", key8);
+      ipList.put("params7", key9);
+      ipList.put("totalRetvals", "0");
+
+      masterHabitat.gk.broadcast_req("NYCTransitHabitat", ipList);
+    }
+  }
+
+}
diff --git a/habmonitors/Corbawith1.4/Hello.idl b/habmonitors/Corbawith1.4/Hello.idl
new file mode 100644
index 0000000..e36c5dd
--- /dev/null
+++ b/habmonitors/Corbawith1.4/Hello.idl
@@ -0,0 +1,10 @@
+module HelloApp
+{
+  interface Hello
+  {
+  string sayHello();
+  oneway void shutdown();
+  };
+};
+
+
diff --git a/habmonitors/Corbawith1.4/HelloClient.java b/habmonitors/Corbawith1.4/HelloClient.java
new file mode 100644
index 0000000..5e6eb5b
--- /dev/null
+++ b/habmonitors/Corbawith1.4/HelloClient.java
@@ -0,0 +1,39 @@
+import HelloApp.*;
+import org.omg.CosNaming.*;
+import org.omg.CosNaming.NamingContextPackage.*;
+import org.omg.CORBA.*;
+
+public class HelloClient
+{
+  // static Hello helloImpl;
+
+  public static void main(String args[])
+    {
+      try{
+        // create and initialize the ORB
+				ORB orb = ORB.init(args, null);
+
+        // get the root naming context
+        org.omg.CORBA.Object objRef =
+	    orb.resolve_initial_references("NameService");
+        // Use NamingContextExt instead of NamingContext. This is
+        // part of the Interoperable naming Service.
+        NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
+
+        // resolve the Object Reference in Naming
+        String name = "Hello";
+        // helloImpl = HelloHelper.narrow(ncRef.resolve_str(name));
+        psl.habitats.ServiceInterface helloImpl = (ncRef.resolve_str(name));
+
+        // System.out.println("Obtained a handle on server object: " + helloImpl);
+        // System.out.println(helloImpl.sayHello());
+        // helloImpl.shutdown();
+
+	} catch (Exception e) {
+          System.out.println("ERROR : " + e) ;
+	  e.printStackTrace(System.out);
+	  }
+    }
+
+}
+
diff --git a/habmonitors/Corbawith1.4/HelloServer.java b/habmonitors/Corbawith1.4/HelloServer.java
new file mode 100644
index 0000000..07cf8c9
--- /dev/null
+++ b/habmonitors/Corbawith1.4/HelloServer.java
@@ -0,0 +1,85 @@
+package psl.habitats.services;
+
+import HelloApp.*;
+import org.omg.CosNaming.*;
+import org.omg.CosNaming.NamingContextPackage.*;
+import org.omg.CORBA.*;
+import org.omg.PortableServer.*;
+import org.omg.PortableServer.POA;
+import java.util.Properties;
+
+class HelloImpl extends HelloPOA {
+  private ORB orb;
+
+  public void setORB(ORB orb_val) {
+    orb = orb_val;
+  }
+
+  // implement sayHello() method
+  public String sayHello() {
+    return "\nHello world !!\n";
+  }
+
+  // implement shutdown() method
+  public void shutdown() {
+    orb.shutdown(false);
+  }
+}
+
+public class HelloServer extends psl.habitats.ServiceInterface {
+
+	public HelloServer() {
+		roleName = "HelloServer";
+	}
+
+   // public static void main(String args[]) {
+	 public void initialize() {
+		String init_args[] = {"-ORBInitialPort", "1050", "-ORBInitialHost", "localhost"};
+		System.out.println("init_args" + init_args.length);
+    try{
+      // create and initialize the ORB
+      ORB orb = ORB.init(init_args, null);
+
+      // get reference to rootpoa & activate the POAManager
+      POA rootpoa = (POA)orb.resolve_initial_references("RootPOA");
+      rootpoa.the_POAManager().activate();
+
+      // create servant and register it with the ORB
+      HelloImpl helloImpl = new HelloImpl();
+      helloImpl.setORB(orb);
+
+      // get object reference from the servant
+      org.omg.CORBA.Object ref = rootpoa.servant_to_reference(helloImpl);
+      Hello href = HelloHelper.narrow(ref);
+
+      // get the root naming context
+      // NameService invokes the name service
+      org.omg.CORBA.Object objRef =
+      orb.resolve_initial_references("NameService");
+      // Use NamingContextExt which is part of the Interoperable
+      // Naming Service (INS) specification.
+      NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
+
+      // bind the Object Reference in Naming
+      String name = "Hello";
+      NameComponent path[] = ncRef.to_name( name );
+      ncRef.rebind(path, href);
+
+      System.out.println("HelloServer ready and waiting ...");
+
+      // wait for invocations from clients
+      orb.run();
+    }
+
+      catch (Exception e) {
+        System.err.println("ERROR: " + e);
+        e.printStackTrace(System.out);
+      }
+
+      System.out.println("HelloServer Exiting ...");
+  }
+	public void startDisplay() {}
+	public Vector performService(Hashtable ipList) {}
+
+}
+
diff --git a/habmonitors/Corbawith1.4/NYCPassListService.java b/habmonitors/Corbawith1.4/NYCPassListService.java
new file mode 100644
index 0000000..07bfa53
--- /dev/null
+++ b/habmonitors/Corbawith1.4/NYCPassListService.java
@@ -0,0 +1,51 @@
+package psl.habitats.services;
+import psl.habitats.*;
+
+import java.util.Date;
+import java.util.Vector;
+import java.util.Hashtable;
+
+public class NYCPassListService implements ServiceInterface {
+  private static final String myDescription = "NYC_Passengers_Query";
+  Habitat masterHabitat = null;
+  public void initialize(Habitat _h) {
+  }
+  public String getDescription(){
+    return myDescription;
+  }
+  public void startDisplay() { }
+
+  private static final String key1 = "First_Name";
+  private static final String key2 = "Last_Name";
+  private static final String key3 = "Boarding_City";
+  private static final String key4 = "Boarding_Date";
+
+  public Hashtable performService(String _senderService, Hashtable ipList) {
+    Hashtable result = new Hashtable();
+    if(ipList.containsKey(key1) || ipList.containsKey(key2)){
+      result.put(key1, lookup(key1, masterHabitat.getName()));
+      result.put(key2, lookup(key2, masterHabitat.getName()));
+      result.put(key3, lookup(key3, masterHabitat.getName()));
+      result.put(key4, lookup(key4, masterHabitat.getName()));
+    } else
+      return null;
+    return result;
+  }
+
+  private static final String HABITAT_NAME = "Amtrak_Habitat";
+  private String lookup(String key, String forHab) {
+    if(forHab == HABITAT_NAME) {
+      if (key == key1)
+        return ("Alpa");
+      else if (key == key2)
+        return ("Shah");
+      else if(key == key3)
+        return ("Texas");
+      else if (key == key4)
+        return new Date().toString();
+      else
+        return null;
+    } else
+      return null;
+  }
+}
diff --git a/habmonitors/Corbawith1.4/ResidentsListService.java b/habmonitors/Corbawith1.4/ResidentsListService.java
new file mode 100644
index 0000000..0842a09
--- /dev/null
+++ b/habmonitors/Corbawith1.4/ResidentsListService.java
@@ -0,0 +1,56 @@
+package psl.habitats.services;
+import psl.habitats.*;
+
+import java.util.Vector;
+import java.util.Hashtable;
+
+public class ResidentsListService {
+  String myDescription = "TexasResidentInfo";
+  Habitat masterHabitat = null;
+
+  public void initialize(Habitat _h){
+    masterHabitat = _h;
+  }
+  public String getName(){
+    return myDescription;
+  }
+	public void startDisplay(){}
+  public Hashtable performService(String _senderService, Hashtable ipList) {
+    Hashtable result = new Hashtable();
+    if (ipList.containsKey(key1) && ipList.containsKey(key2)) {
+      result.put(key5, lookup(key5, masterHabitat.getName()));
+      result.put(key6, lookup(key6, masterHabitat.getName()));
+      result.put(key7, lookup(key7, masterHabitat.getName()));
+      result.put(key8, lookup(key8, masterHabitat.getName()));
+      result.put(key9, lookup(key9, masterHabitat.getName()));
+    } else
+      return null;
+    return result;
+  }
+
+  private static final String key1 = "First_Name";
+  private static final String key2 = "Last_Name";
+  private static final String key5 = "Address";
+  private static final String key6 = "Telephone";
+  private static final String key7 = "SSN";
+  private static final String key8 = "Image";
+  private static final String key9 = "Age";
+
+  private String lookup(String key, String forHab) {
+    if(forHab == "TexasStateHabitat") {
+      if (key == key5)
+        return ("608 CEPSR");
+      else if (key == key6)
+        return "7184";
+      else if (key == key7)
+        return "987-65-4321";
+      else if (key == key8)
+        return "http://www.web.com/picture.jpg";
+      else if (key == key9)
+        return "17";
+      else
+        return null;
+    } else
+      return null;
+  }
+}
diff --git a/habmonitors/FileIO.java b/habmonitors/FileIO.java
new file mode 100644
index 0000000..e996ac5
--- /dev/null
+++ b/habmonitors/FileIO.java
@@ -0,0 +1,73 @@
+package psl.habitats;
+
+import java.io.*;
+import java.util.*;
+
+public class FileIO {
+
+    String[][] data;
+    int[] cols;
+    int[] rows;
+    int numCols;
+    int numRows;
+
+    /* constructor - read and parse input file, stroing data to data array */
+    public FileIO() { }
+
+
+    public Hashtable readFile(String inputFilename, String delimiter) {
+	Hashtable h = new Hashtable();
+        try {
+
+            FileReader fr = new FileReader(inputFilename);
+	    BufferedReader input = new BufferedReader(fr);
+	    String currentLine;
+
+	    // read first line of file
+	    currentLine = input.readLine();
+
+	    // store data to array
+	    while (currentLine!=null) {
+		StringTokenizer stok =
+		    new StringTokenizer(currentLine, delimiter);
+
+		h.put(stok.nextToken(), stok.nextToken());
+
+		// read next line of file
+		currentLine = input.readLine();
+	    }
+        } catch (FileNotFoundException e) {
+            System.out.println("File not found: " + e.toString());
+        } catch (IOException e) {
+            System.out.println("IOException : " + e.toString());
+        } catch (NumberFormatException e) {
+            System.out.println("Invalid Data: " + e.toString());
+        }
+
+	return h;
+    }
+
+    // write new datafile with only 'n' attributes per sample and a
+    // label for each sample
+    public void writeFile(String outputFilename, String habitatName) {
+        try {
+            FileWriter fw = new FileWriter(outputFilename);
+            PrintWriter output = new PrintWriter(fw);
+
+	    output.println(habitatName);
+            output.flush();
+
+	    fw.close();
+
+        } catch (FileNotFoundException e) {
+            System.out.println("File not found: " + e.toString());
+        } catch (IOException e) {
+            System.out.println("IOException : " + e.toString());
+        } catch (NumberFormatException e) {
+            System.out.println("Invalid Data: " + e.toString());
+        }
+    }
+
+
+} // FileIO
+
diff --git a/habmonitors/FilterThread.java b/habmonitors/FilterThread.java
new file mode 100644
index 0000000..7840b4d
--- /dev/null
+++ b/habmonitors/FilterThread.java
@@ -0,0 +1,27 @@
+package psl.habitats;
+
+import java.lang.*;
+import siena.*;
+
+class FilterThread extends Thread {
+	public Filter f1;
+	public Notifiable interestedParty;
+	public Siena s = null;
+
+	public FilterThread(Siena sie, Filter f, Notifiable c) {
+		f1 = f;
+		interestedParty = c;
+		s = sie;
+	}
+
+	public void run() {
+		if ((interestedParty == null) || (f1 == null)) {
+			// Alpa: need to do something like exit
+		}
+		try {
+			s.subscribe(f1,interestedParty);
+		} catch (siena.SienaException se) {
+			se.printStackTrace();
+		}
+	}
+}
diff --git a/habmonitors/FrontEnd.java b/habmonitors/FrontEnd.java
new file mode 100644
index 0000000..fac297e
--- /dev/null
+++ b/habmonitors/FrontEnd.java
@@ -0,0 +1,26 @@
+package psl.habitats;
+/**
+ * FrontEnd.java
+ *
+ *
+ * Created: Thu Nov 15 09:26:46 2001
+ *
+ * @author Christy Lauridsen
+ * @version
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+
+public class FrontEnd
+{
+    public static void main(String[] args)
+    {
+	FrontEndFrame frame = new FrontEndFrame();
  frame.pack();
+	frame.setVisible(true);
+    }
+} // FrontEnd
+
+
+
diff --git a/habmonitors/FrontEndFrame.java b/habmonitors/FrontEndFrame.java
new file mode 100644
index 0000000..c7f88b5
--- /dev/null
+++ b/habmonitors/FrontEndFrame.java
@@ -0,0 +1,28 @@
+package psl.habitats;
+/**
+ * FrontEndFrame.java
+ *
+ *
+ * Created: Thu Nov 15 09:26:14 2001
+ *
+ * @author Christy Lauridsen
+ * @version
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+
+class FrontEndFrame extends JFrame
+{
+    public FrontEndFrame()
+    {
+	setTitle("Habitats Front End");
+	setLocation(100, 100);
+	setSize(500, 500);
+	setDefaultCloseOperation(EXIT_ON_CLOSE);
+	Container contentPane = getContentPane();
+	contentPane.add(new FrontEndPanel());
+
+    }
+} // FrontEndFrame
diff --git a/habmonitors/FrontEndPanel.java b/habmonitors/FrontEndPanel.java
new file mode 100644
index 0000000..71e5528
--- /dev/null
+++ b/habmonitors/FrontEndPanel.java
@@ -0,0 +1,66 @@
+package psl.habitats;
+/**
+ * FrontEndPanel
+ *
+ *
+ * Created: Thu Nov 15 09:23:42 2001
+ *
+ * @author Christy Lauridsen
+ * @version
+ */
+
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+
+
+class FrontEndPanel extends JPanel
+{
+    public FrontEndPanel()
+    {
+	setLayout(new BorderLayout());
+	add(new TextAreaPanel(), BorderLayout.CENTER);
+	add(new InputPanel(), BorderLayout.SOUTH);
+    }
+
+    /////// Private data /////
+    private JTextArea h_textArea    = new JTextArea(8, 40);
+    private JButton h_execButton = new JButton("Execute");
+    private JTextField h_execField  = new JTextField(20);
+
+    /////// Inner classes /////
+    class TextAreaPanel extends JPanel
+    {
+	public TextAreaPanel()
+	{
+	    setLayout( new BorderLayout() );
+	    h_textArea = new JTextArea(8, 40);
+	    h_textArea.setText(">");
+	    JScrollPane scrollPane = new JScrollPane(h_textArea);
+	    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
+	    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+	    add(scrollPane, BorderLayout.CENTER);
+	}
+    }
+
+    class InputPanel extends JPanel
+    {
+	public InputPanel()
+	{
+	    add(new JLabel("Command:"));
+	    add(h_execField);
+	    add(h_execButton);
+	    h_execButton.addActionListener(new ActionListener()
+					      {
+						  public void actionPerformed(ActionEvent ev)
+						      {
+							  String h_exec = h_execField.getText();
+							  h_textArea.append(h_exec + "\n>");
+							  h_execField.setText("");
+						      }
+					      }
+					   );
+	}
+    }
+} // FrontEndPanel
diff --git a/habmonitors/GateKeeper.java b/habmonitors/GateKeeper.java
new file mode 100644
index 0000000..6f2bddf
--- /dev/null
+++ b/habmonitors/GateKeeper.java
@@ -0,0 +1,372 @@
+package psl.habitats;
+import java.io.*;
+import java.util.Iterator;
+import java.util.Enumeration;
+import java.util.Vector;
+import java.util.Hashtable;
+import siena.*;
+import org.omg.CosNaming.*;
+import org.omg.CosNaming.NamingContextPackage.*;
+import org.omg.CORBA.*;
+
+// Alpa : need to replace the siena Notification with a generalised service descritpion
+// Alpa: need to add someway of removing treaty when recieved BYE
+
+public class GateKeeper implements Notifiable {
+    static private Habitat masterHabitat;
+    static private Hashtable summits_list;
+    static private final Hashtable currServiceReqList = new Hashtable();
+    static private String sienaMaster = "senp://canal.psl.cs.columbia.edu:31331";
+    static HierarchicalDispatcher hd = null;
+    static String myDescription = "Gatekeeper";
+
+    public GateKeeper(Habitat h, String sm) {
+	masterHabitat = h;
+	summits_list = new Hashtable();
+	// connect to siena
+	myDescription += "_" + masterHabitat.getName();
+	hd = new HierarchicalDispatcher();
+	try {
+	    if (sm != null) sienaMaster = sm;
+	    hd.setMaster(sienaMaster);
+	    // masterHabitat.log(": master is " + sienaMaster);
+	} catch (siena.InvalidSenderException ihe) {
+	    ihe.printStackTrace();
+	} catch (IOException ioe) {
+	    ioe.printStackTrace();
+	}
+	Filter filter = null;
+
+	filter = new Filter();
+	filter.addConstraint("habitatCategory", masterHabitat.getCategory());
+	new FilterThread(hd, filter, this).start();
+
+	filter = new Filter();
+	filter.addConstraint("habitatName", masterHabitat.getName());
+	new FilterThread(hd, filter, this).start();
+    }
+
+    public void notify(Notification[] e) {}
+    public void notify(Notification n) {
+	masterHabitat.log("GateKeeper: recevied ");
+	AttributeValue rav = n.getAttribute("EventType");
+	if (rav == null) {
+	    masterHabitat.log("Received a null attribute for: EventType");
+	    return;
+	}
+
+	String av = rav.stringValue();
+
+	if(av.equals("ServiceRequest")) {
+	    processServiceRequest(n);
+	} else if(av.equals("Response2ServiceRequest")) {
+	    processResponse2ServiceRequest(n);
+	}
+    }
+
+    private static final String SERVER_S = "ServerService";
+    private static final String CLIENT_S = "ClientService";
+    private static final String TOTALPARAMS = "totalParams";
+    private static final String TOTALRETVALS = "totalRetvals";
+
+    public void broadcast_req(String clientService, String serverService, Hashtable h) {
+	masterHabitat.log("GateKeeper: broadcast_req for " + serverService);
+	// maintain local reference to hashTable: h
+	currServiceReqList.put(clientService, h);
+
+	Notification n = new siena.Notification();
+	for (Enumeration e=h.keys(); e.hasMoreElements(); ) {
+	    String key = e.nextElement().toString();
+	    n.putAttribute(key, "" + h.get(key));
+	}
+	n.putAttribute("source", masterHabitat.getName());
+	n.putAttribute(SERVER_S, serverService);
+	n.putAttribute(CLIENT_S, clientService);
+
+	try {
+	    masterHabitat.log("GateKeeper: broadcasting: ");
+	    // send out event
+	    hd.publish(n);
+	} catch (siena.SienaException se) {
+	    se.printStackTrace();
+	}
+    }
+
+    private boolean allowed(String _sName, String _sDesc) {
+	return true;
+    }
+
+    private int getNextID() {
+	return (int) (Math.random() * 1000);
+    }
+
+    public void processServiceRequest(Notification n) {
+	masterHabitat.log(myDescription + ":: processing a Service Request ");
+	// do some simple security clearance
+	// assign an ID number
+	// create a new treaty and add it to the list of sumits
+	// if security cleared create a proxy of the service object
+
+	String clientHabitat = null, clientService = null, serverService = null;
+	int totalParams = 0, totalRetvals = 0;
+	Notification res_notif = new Notification();
+
+	AttributeValue av = n.getAttribute("source");
+	if (av != null) clientHabitat = av.stringValue();
+
+	av = n.getAttribute(CLIENT_S);
+	if (av != null) clientService = av.stringValue();
+
+	av = n.getAttribute(SERVER_S);
+	if (av != null) serverService = av.stringValue();
+
+	av = n.getAttribute(TOTALPARAMS);
+	if (av != null) totalParams = av.intValue();		// total parameters
+
+	av = n.getAttribute(TOTALRETVALS);
+	if (av != null)	totalRetvals = av.intValue(); 	// total return values
+
+	masterHabitat.log("Service Request for -> " + serverService + " from -> " + clientHabitat);
+	masterHabitat.localService("Security Check on " + clientHabitat);
+	if(allowed(clientHabitat, clientService)) {
+	    masterHabitat.localService("Security Check Cleared on " + clientHabitat);
+	    // send a +ve response
+	    int ID = getNextID();
+	    res_notif.putAttribute("habitatName", clientHabitat);
+	    res_notif.putAttribute("EventType", "Response2ServiceRequest");
+	    res_notif.putAttribute("Access", "Allowed");			// could have used ID only but just in case
+	    res_notif.putAttribute("Treaty", "AcceptedAll");
+	    /* AcceptAll = all the ip_params and op_params sent in the
+	     *  request were allowed. OR
+	     *  New Treaty = the new treaty description follows thsi event
+	     *  that gives a new description of the ip_params and the op_params
+	     *  currently only AcceptAll implemented
+	     */
+	    res_notif.putAttribute(CLIENT_S, clientService);
+	    res_notif.putAttribute(SERVER_S, serverService);
+	    res_notif.putAttribute("ID", ID);
+
+	    Vector params = new Vector();
+	    Vector retvals = new Vector();
+
+	    for (int i=1; i<=totalParams; i++) {
+		av = n.getAttribute("params" + i);
+		if (av != null) params.add(av.stringValue());
+	    }
+
+	    for (int i=1; i<=totalRetvals; i++) {
+		av = n.getAttribute("retvals" + i);
+		if (av != null) retvals.add(av.stringValue());
+	    }
+
+	    masterHabitat.localService("Negotiating with " + clientHabitat);
+	    masterHabitat.localService("New Treaty and Summit ID created for " + clientHabitat);
+
+	    Treaty t = null;
+	    summits_list.put(new Integer(ID),
+			     t = new Treaty(serverService, clientService, ID,
+					    clientHabitat, masterHabitat.getName(),
+					    params, retvals));
+
+	    Filter f1 = new Filter();
+	    f1.addConstraint("CurrentSummitID", ID + "_" + serverService);
+	    new FilterThread(hd, f1, new SummitHandler(clientService, serverService, t, this)).start();
+
+	}
+	else {
+	    // send a -ve response
+	    res_notif.putAttribute("habitatName", clientHabitat);
+	    res_notif.putAttribute("EventType", "Response2ServiceRequest");
+	    res_notif.putAttribute("Access", "Denied");
+	}
+
+	try {
+	    // treaty created, now send reply to requesting habService
+	    hd.publish(res_notif);
+	} catch (siena.SienaException se) {
+	    se.printStackTrace();
+	}
+    }
+
+    private Vector get_IP_params_from_Notification(Notification n) {
+	return (new Vector());
+    }
+
+    public void processResponse2ServiceRequest(Notification n) {
+	masterHabitat.log( myDescription + " :: Recieved Response2ServiceRequest");
+	AttributeValue av = n.getAttribute("Access");
+	int ID;
+	if (av != null) {
+	    if ((av.stringValue()).equals("Allowed")) {
+		av = n.getAttribute("ID");
+		if (av != null) {
+		    ID = av.intValue();
+		    String clientHabService = n.getAttribute(CLIENT_S).stringValue();
+		    String serverHabService = n.getAttribute(SERVER_S).stringValue();
+		    masterHabitat.log( myDescription + " :: Allowed access to " + serverHabService);
+
+		    Hashtable oldHash = (Hashtable) currServiceReqList.get(clientHabService);
+		    String serverHabitat = oldHash.get("habitatCategory") + "";
+
+		    int totalParams = Integer.parseInt("" + oldHash.get("totalParams"));
+		    int totalRetvals = Integer.parseInt("" + oldHash.get("totalRetvals"));
+
+		    // figure out num params/retvals
+		    Vector params = new Vector(totalParams), retvals = new Vector(totalRetvals);
+		    for (int i=1; i<=totalParams; i++) params.add(oldHash.get("params" + i));
+		    for (int i=1; i<=totalRetvals; i++) retvals.add(oldHash.get("retvals" + i));
+
+		    masterHabitat.log( myDescription + " :: Creating New Treaty ");
+		    Treaty t = null;
+		    summits_list.put(new Integer(ID),
+				     t = new Treaty(serverHabService, clientHabService, ID,
+						    serverHabitat, masterHabitat.getName(),
+						    params, retvals));
+
+		    // t.printIPList(); t.printOPList();
+		    // treaty created, now notify requesting habService
+		    Hashtable newHash
+			= masterHabitat.getService(clientHabService).performService(serverHabService, null);
+
+		    masterHabitat.log( myDescription + "Notifying Service " + clientHabService + "to start using Remote Service " + serverHabService);
+
+		    n = new siena.Notification();
+		    for (Enumeration e = newHash.keys(); e.hasMoreElements(); ) {
+			String key = e.nextElement().toString();
+			if (t.valid_ip_param(key) || t.valid_op_param(key))
+			    n.putAttribute(key, "" + newHash.get(key));
+			else masterHabitat.log("Invalid IP");
+		    }
+		    n.putAttribute("CurrentSummitID", ID + "_" + serverHabService);
+
+		    Filter f1 = new Filter();
+		    f1.addConstraint("CurrentSummitID", ID + "_" + clientHabService);
+		    new FilterThread(hd, f1, new SummitHandler(serverHabService, clientHabService, t, this)).start();
+
+		    try {
+			masterHabitat.log("GateKeeper: publishing: ");
+			// send out to server
+			hd.publish(n);
+		    } catch (SienaException se) {
+			se.printStackTrace();
+		    }
+
+		} else { /* nothing */ }
+	    } else {
+		masterHabitat.log("Access Denied");
+		// masterHabitat.notifyService(); .. wake up the service waiting for this failure notification
+	    }
+	    // response to the service request
+	    // create a treaty with the params
+	    // save the ID number recieved by the remote GK
+	    // notify the service to start using the service
+	} else { /* nothing */ }
+	masterHabitat.log("GateKeeper: processResponse2ServiceRequest ended: ");
+    }
+
+    class SummitHandler implements Notifiable {
+	final Treaty treaty;
+	final GateKeeper masterGK;
+	final String targetService;
+	final String localService;
+	public SummitHandler(String ts, String ls, Treaty _t, GateKeeper _gk) {
+	    treaty = _t;
+	    masterGK = _gk;
+	    targetService = ts;
+	    localService = ls;
+	}
+  	public void notify(Notification n[]) {}
+  	public void notify(Notification n) {
+	    masterHabitat.log("SummitHandler: notify ");
+	    // need validation in here
+
+	    Notification send_notif = new Notification();
+	    Hashtable retvals = new Hashtable();
+
+	    boolean terminateSummit = false;
+	    for (Iterator i = n.attributeNamesIterator(); i.hasNext(); ) {
+		String key = "" + i.next();
+		if (!key.equals("CurrentSummitID") && !key.equals("habitatCategory")) {
+		    if (treaty.valid_ip_param(key) || treaty.valid_op_param(key)) {
+			retvals.put(key, n.getAttribute(key).stringValue());
+		    } else {
+			send_notif.clear();
+			send_notif.putAttribute("Terminate Summit" , "Invalid number of params");
+			terminateSummit = true;
+			break;
+		    }
+		}
+	    }
+
+	    masterHabitat.log(treaty.printIPList());
+	    masterHabitat.log(treaty.printOPList());
+	    if (! terminateSummit) {
+		ServiceInterface sInf = masterHabitat.getService(localService);
+		Hashtable newHash = sInf.performService(treaty.serverHabService, retvals);
+
+		send_notif = new siena.Notification();
+		boolean isResultNull = false;
+
+		if (newHash == null) {
+		    send_notif.clear();
+		    send_notif.putAttribute("Terminate Summit" , "Nothing to be returned");
+		} else {
+		    for (Enumeration e = newHash.keys(); e.hasMoreElements(); ) {
+			String key = e.nextElement().toString();
+			if (treaty.valid_ip_param(key) || treaty.valid_op_param(key)) {
+			    send_notif.putAttribute(key, "" + newHash.get(key));
+			} else {
+			    // masterHabitat.log("SummitHandler: here, terminating, " + key);
+			    send_notif.clear();
+			    send_notif.putAttribute("Terminate Summit" , "Invalid number of retvals");
+			    break;
+			}
+		    }
+		}
+	    }
+	    send_notif.putAttribute("CurrentSummitID", treaty.getID() + "_" + targetService);
+	    try {
+		// send out to server
+		hd.publish(send_notif);
+	    } catch (SienaException se) {
+		se.printStackTrace();
+	    }
+
+
+	    /* Notification send_notif = new Notification();
+	       send_notif.putAttribute("currentSummitID", ID);
+	       Treaty currTreaty = (Treaty) masterGK.summits_list.get(new Integer(ID));
+	       // check for termination by peer
+	       if (send_notif.size() != currTreaty.get_IP_size()) {
+	       send_notif.putAttribute("Terminate Summit" , "Invalid number of params");
+	       return;
+	       } else {
+	       Vector ip = (Vector) currTreaty.getIPList();
+	       Hashtable forService = new Hashtable();
+	       for(int i =0; i < ip.size(); i++) {
+	       String ip_par = (String) ip.elementAt(i);
+	       AttributeValue av = send_notif.getAttribute(ip_par);
+	       if (av!= null) {
+	       forService.put(ip_par, av.stringValue()); // need to pass the list to the params
+	       }
+	       }
+
+				// might be replaced by a lookup on a corba object
+				ServiceInterface _service = masterHabitat.getService(currTreaty.servUsed);
+				Vector result2Bsent = _service.performService(forService);
+
+				for (int _v = 0; _v < result2Bsent.size(); _v++) {
+				MyAttributeValuePair _avp = (MyAttributeValuePair) result2Bsent.elementAt(_v);
+				if (currTreaty.valid_op_param(_avp.getValue())) {
+				send_notif.putAttribute(_avp.getAttribute(), _avp.getValue());
+				}
+				else {
+				send_notif.clear();
+				send_notif.putAttribute("Terminate Summit" , "Invalid number of params");
+				// break;
+				}
+				}
+				}*/
+	}
+    }
+}
diff --git a/habmonitors/Habitat.java b/habmonitors/Habitat.java
new file mode 100644
index 0000000..0962df3
--- /dev/null
+++ b/habmonitors/Habitat.java
@@ -0,0 +1,140 @@
+package psl.habitats;
+
+import java.io.*;
+import java.util.*;
+
+
+import psl.habitats.portal.HabitatPortal;
+import psl.habitats.portal.HabitatMonitor;
+
+
+public class Habitat {
+    String roleName, category;
+    Hashtable serviceObjects;
+    HabitatPortal hp = null;
+    HabitatMonitor hm = null;
+
+    public final GateKeeper gk;
+    public Habitat(String name, String c, String file, String sienaMaster) {
+	roleName = name;
+	category = c;
+	serviceObjects = new Hashtable();
+	FileIO fileRW = new FileIO();
+	Hashtable serviceList;
+
+	/*
+	  FrontEnd fe = new FrontEnd();
+	  Console ad = new Console();
+	  ad.cf_show("Admin Frame");
+	  ad.cf_show("Admin Console");
+	*/
+
+	// read the services
+	if (file == null) file = ".serviceList";
+	serviceList = fileRW.readFile(file, ",");
+
+	// set the sienaMaster
+	if (sienaMaster == null)
+	    sienaMaster = "senp://canal.psl.cs.columbia.edu:31331";
+
+	gk = new GateKeeper(this, sienaMaster);
+
+	//CKL
+	hm = new HabitatMonitor(name);
+
+	// initialize the services
+	for (Enumeration e = serviceList.elements() ; e.hasMoreElements() ;) {
+	    try {
+		Class t = Class.forName((String) e.nextElement());
+		ServiceInterface s = (ServiceInterface) t.newInstance();
+		serviceObjects.put(s.getDescription(), s);
+		s.initialize(this);
+		// ad.cf_add("Started sevice " + s.getDescription()+ "\n");
+		System.out.println("Started sevice " + s.getDescription()+ "\n");
+
+		hm.addmonitor(s.getDescription());
+
+		statusMsg(s.getDescription(),
+			  (" Started sevice " + s.getDescription()));
+		log("Found sevice " + s.getDescription());
+
+		// s.startDisplay();
+
+	    } catch (Exception ex) {
+		ex.printStackTrace();
+	    }
+	}
+
+	hp = new HabitatPortal(name, serviceObjects.elements());
+	hm.fix(hp);
+
+
+	/*    	for (Enumeration e = serviceList.elements() ; e.hasMoreElements() ;) {
+	    try {
+		//		String name = (String) e.nextElement());
+
+	    hm.addmonitor((String) e.nextElement());
+	    } catch (Exception ex) {
+		ex.printStackTrace();
+	    }
+	    }*/
+
+    }
+
+    //CKL
+    public void statusMsg(String servname, String message) {
+	hm.writemonitor(message, servname);
+	    //	hm.msgToMon(servname, message);
+    }
+    //end CKL
+
+    public String getName() {
+	return roleName;
+    }
+    public String getCategory() {
+	return category;
+    }
+    public ServiceInterface getService(String _svdes) {
+	return((ServiceInterface)serviceObjects.get(_svdes));
+    }
+    static public boolean localService(String servDes) {
+	return false;
+    }
+    public void log(String msg) {
+	hm.log(msg);
+    }
+
+    public void msgToMon(String servname, String message) {
+	//System.out.println("christy: CFEP - writemonitor - " + message);
+	hm.writemonitor(message, servname);
+    }
+
+    private static void usage() {
+	System.out.println("java psl.habitats.Habitat <habName> <habCategory> [-sl <file>] [-sm <uri>]");
+	System.out.println(" <habName>     : habitat name");
+	System.out.println(" <habCategory> : habitat category");
+	System.out.println(" [-sl <file>]  : initial serviceList file [default: .serviceList]");
+	System.out.println(" [-sm <uri>]   : siena master             [default: senp://canal:31331/");
+	System.exit(0);
+    }
+    public static void main(String args[]) {
+	if (args.length < 2) usage();
+
+	String habName = args[0];
+	String habCategory = args[1];
+	String file = null, sm = null;
+
+	int i = 2;
+	while (i<args.length) {
+	    if (args[i].equals("-sl")) file = args[++i];
+	    else if (args[i].equals("-sm")) sm = args[++i];
+	    i++;
+	}
+
+	new Habitat(habName, habCategory, file, sm);
+    }
+}
+
+
+
+
diff --git a/habmonitors/README b/habmonitors/README
new file mode 100644
index 0000000..a802772
--- /dev/null
+++ b/habmonitors/README
@@ -0,0 +1,11 @@
+NOTE : ServiceList for any habitat is in the services directory !
+Step 1: Start Siena
+	java -cp siena-1.2.0.jar siena.StartServer -host canal -port 31331
+
+Step 2: Start the Amtrak and Texas services
+	java psl.habitats.Habitat AmTrak NYCTransitHabitat  -sl .AmTrakServiceList -sm senp://canal:31331
+	java psl.habitats.Habitat Texas TexasStateHabitat -sl .TexasServiceList -sm senp://canal:31331
+
+Step 3: Start the NYPD Habitat
+	java psl.habitats.Habitat NYPD NYPD -sl .NYPDServiceList -sm senp://canal:31331
+
diff --git a/habmonitors/ServiceInterface.java b/habmonitors/ServiceInterface.java
new file mode 100644
index 0000000..7580139
--- /dev/null
+++ b/habmonitors/ServiceInterface.java
@@ -0,0 +1,13 @@
+package psl.habitats;
+
+import javax.swing.JPanel;
+import java.util.Hashtable;
+
+public interface ServiceInterface {
+  public void initialize(Habitat _h);
+  public String getDescription();
+	public JPanel startDisplay();
+  public String getDetailDescription();
+  public Hashtable performService(String _senderService, Hashtable ipList);
+	// public void startDisplay(Graphics g){}
+}
diff --git a/habmonitors/Treaty.java b/habmonitors/Treaty.java
new file mode 100644
index 0000000..51c3de0
--- /dev/null
+++ b/habmonitors/Treaty.java
@@ -0,0 +1,73 @@
+package psl.habitats;
+
import java.util.Vector;
+import java.util.Enumeration;
+
+class Treaty {
+	final int ID;
+	final String clientHabitat;
+	final String serverHabitat;
  final String clientHabService;
+	final String serverHabService;
+
  final int numParameters;
+  final int numReturnValues;
+
  final Vector allowed_params;
+	final Vector allowed_retvals;
+
+	public Treaty(String serSvc, String cliSvc, int id,
+                String s, String c, Vector params, Vector retvals) {
    ID = id;
    clientHabitat = c;
    serverHabitat = s;
    clientHabService = cliSvc;
+    serverHabService = serSvc;
    
    allowed_params = new Vector(params);
    allowed_retvals = new Vector(retvals);
    
    numParameters = allowed_params.size();
    numReturnValues = allowed_retvals.size();
+	}
+
+	//////////////////////////////////////////////////////
+	// 				general getter functions
+	//////////////////////////////////////////////////////
+	String getServiceUsed() { return serverHabService; }
+	int    getID()          { return ID;               }
+	int    get_IP_size()    { return numParameters;    }
+	
  //////////////////////////////////////////////////////
+	// 				functions for input params
+	//////////////////////////////////////////////////////
+
+	public void add_ip_param(Object param) {
+		allowed_params.add(param);
+	}
+	public void add_ip_list(Vector param_list) {
+		allowed_params.addAll(param_list);
+	}
+	public boolean valid_ip_param(Object param) {
+		return (allowed_params.contains(param));
+	}
+	public boolean valid_ip_list(Vector param_list) {
+		return (allowed_params.containsAll(param_list));
+	}
+	public Vector getIPList() {
+		return (allowed_params);
+	}
+
+	//////////////////////////////////////////////////////
+	// 				functions for return types
+	//////////////////////////////////////////////////////
+
+	public void add_op_param(Object param) {
+		allowed_retvals.add(param);
+	}
+	public void add_op_list(Vector param_list) {
+		allowed_retvals.addAll(param_list);
+	}
+	public boolean valid_op_param(Object param) {
+		return (allowed_retvals.contains(param));
+	}
+	public boolean valid_op_list(Vector param_list) {
+		return (allowed_retvals.containsAll(param_list));
+	}
+
  //////////////////////////////////////////////////////
+	// 				functions for printing
+	//////////////////////////////////////////////////////
  public String printIPList() {
    StringBuffer sb = new StringBuffer(" Printing IP List ==> ");
+    if (allowed_retvals.size() > 0) {
      for (Enumeration e = allowed_params.elements(); e.hasMoreElements(); )
+        sb.append(" .. " + e.nextElement());
+    }
+    return sb + "";
  }
+  public String printOPList() {
    StringBuffer sb = new StringBuffer(" Printing OP List ==> ");
+    if (allowed_retvals.size() > 0) {
    for (Enumeration e = allowed_retvals.elements(); e.hasMoreElements(); )
+      sb.append(" .. " + e.nextElement());
+    }
    return sb + "";
  }
+}
diff --git a/habmonitors/monitors/ControlFrontEnd.java b/habmonitors/monitors/ControlFrontEnd.java
new file mode 100644
index 0000000..f2a19e4
--- /dev/null
+++ b/habmonitors/monitors/ControlFrontEnd.java
@@ -0,0 +1,46 @@
+
+/**
+ * ControlFrontEnd.java
+ *
+ *
+ * Created: Thu Nov 15 09:26:46 2001
+ *
+ * @author Christy Lauridsen
+ * @version
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import java.lang.*;
+
+public class ControlFrontEnd
+{
+    public static void main(String[] args)
+    {
+	ControlFrontEndFrame frame = new ControlFrontEndFrame();
+	frame.setVisible(true);
+
+	// get services, set up...
+	EventService eserv = new EventService();
+
+	frame.addMe(eserv.myName());
+
+	while (true) {
+	    eserv.sendMessages();
+
+	    if (eserv.wantwrite()) {
+		frame.msgToMon(eserv.myName(), eserv.writeToMonitor());
+	    }
+
+	    int sleepTime = 10000;
+	    try {
+                Thread.sleep(sleepTime);
+            } catch (InterruptedException e) {
+            }
+	}
+    }
+} // ControlFrontEnd
+
+
+
diff --git a/habmonitors/monitors/ControlFrontEndFrame.java b/habmonitors/monitors/ControlFrontEndFrame.java
new file mode 100644
index 0000000..ca033df
--- /dev/null
+++ b/habmonitors/monitors/ControlFrontEndFrame.java
@@ -0,0 +1,40 @@
+
+/**
+ * ControlFrontEndFrame.java
+ *
+ *
+ * Created: Thu Nov 15 09:26:14 2001
+ *
+ * @author Christy Lauridsen
+ * @version
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+
+class ControlFrontEndFrame extends JFrame
+{
+    ControlFrontEndPanel cfep = new ControlFrontEndPanel();
+
+    public ControlFrontEndFrame()
+    {
+	setTitle("Habitats Front End");
+	setLocation(100, 100);
+	setSize(500, 500);
+	setDefaultCloseOperation(EXIT_ON_CLOSE);
+	Container contentPane = getContentPane();
+	//	contentPane.add(new ControlFrontEndPanel());
+	contentPane.add(cfep);
+    }
+
+    void msgToMon(String servname, String message) {
+	cfep.msgToMon(servname, message);
+    }
+
+    void addMe(String servname) {
+	cfep.addService(servname);
+    }
+
+} // ControlFrontEndFrame
+
diff --git a/habmonitors/monitors/ControlFrontEndPanel.java b/habmonitors/monitors/ControlFrontEndPanel.java
new file mode 100644
index 0000000..88ee392
--- /dev/null
+++ b/habmonitors/monitors/ControlFrontEndPanel.java
@@ -0,0 +1,79 @@
+/**
+ * ControlFrontEndPanel
+ *
+ *
+ * Created: Thu Nov 15 09:23:42 2001
+ *
+ * @author Christy Lauridsen
+ * @version
+ */
+
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+
+
+class ControlFrontEndPanel extends JPanel
+{
+    Monitor m = new Monitor();
+
+    public ControlFrontEndPanel()
+    {
+	setLayout(new GridLayout(0,1));
+
+	for (int i = 0; i < 3; i++) {
+	    add(new ServiceOptionsPanel("Service"+i));
+	}
+    }
+
+    void addService(String sname) {
+	add(new ServiceOptionsPanel(sname));
+    }
+
+    void msgToMon(String servname, String message) {
+	m.writemonitor(message, servname);
+    }
+
+    class ServiceOptionsPanel extends JPanel
+    {
+	String mname;
+	JTextField mtext = new JTextField(10);
+
+	public ServiceOptionsPanel(String name)
+	{
+	    mname = name;
+	    JButton monitor = new JButton("Monitor");
+	    JButton write = new JButton("Write");
+	    JButton remove = new JButton("Remove");
+	    add(new JLabel(mname));
+	    add(monitor);
+	    add(mtext);
+	    add(write);
+	    add(remove);
+	    monitor.addActionListener(new ActionListener()
+		{
+		    public void actionPerformed(ActionEvent ev)
+		    {
+			m.addmonitor(mname);
+		    }
+		});
+	    write.addActionListener(new ActionListener()
+		{
+		    public void actionPerformed(ActionEvent ev)
+		    {
+			m.writemonitor(mtext.getText(), mname);
+		    }
+		});
+	    remove.addActionListener(new ActionListener()
+		{
+		    public void actionPerformed(ActionEvent ev)
+		    {
+			m.removemonitor(mname);
+		    }
+		});
+	}
+
+    }
+
+} // ControlFrontEndPanel
diff --git a/habmonitors/monitors/EventService.java b/habmonitors/monitors/EventService.java
new file mode 100644
index 0000000..5730140
--- /dev/null
+++ b/habmonitors/monitors/EventService.java
@@ -0,0 +1,37 @@
+
+/**
+ * EventService.java
+ *
+ *
+ * Created: Sun Nov 18 06:05:15 2001
+ *
+ * @author Christina K. Lauridsen
+ * @version
+ */
+
+public class EventService  {
+    boolean needwrite = false;
+    String mstr;
+
+    public EventService() {
+    }
+
+    void sendMessages() {
+	needwrite = true;
+	mstr = "hello i'm the event service.";
+    }
+
+    boolean wantwrite() {
+	return needwrite;
+    }
+
+    String writeToMonitor() {
+	needwrite = false;
+	return mstr;
+    }
+
+    String myName() {
+	return "EventService";
+    }
+
+} // EventService
diff --git a/habmonitors/monitors/Monitor.java b/habmonitors/monitors/Monitor.java
new file mode 100644
index 0000000..6187f4e
--- /dev/null
+++ b/habmonitors/monitors/Monitor.java
@@ -0,0 +1,79 @@
+
+/**
+ * Monitor.java
+ *
+ *
+ * Created: Thu Nov 15 09:26:14 2001
+ *
+ * @author Christy Lauridsen
+ * @version
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import java.util.*;
+
+class Monitor //extends JFrame
+{
+    boolean noframe = true;
+    JFrame f = new JFrame("Monitors");
+    Hashtable monitors = new Hashtable();
+
+    public Monitor() {}
+
+    void addmonitor(String name) {
+
+	if (monitors.get(name) != null) { return; }
+
+	monitors.put(name, new TextAreaPanel(name));
+
+	(f.getContentPane()).add((TextAreaPanel)monitors.get(name));
+
+	f.validate();
+
+	if (noframe) {
+	    (f.getContentPane()).setLayout(new GridLayout(0,2));
+	    f.setSize(500, 500);
+	    f.setVisible(true);
+	    noframe = false;
+	}
+    }
+
+    void writemonitor(String str, String svcname) {
+	try {
+	    ((TextAreaPanel)(monitors.get(svcname))).h_textArea.append(str+"\n>");
+	} catch (Exception e) {
+	}
+    }
+
+    void removemonitor(String svcname) {
+	try {
+	    f.remove((Component)monitors.get(svcname));
+	    f.validate();
+	    monitors.remove(svcname);
+	} catch (Exception e) {
+	}
+    }
+
+    /////// Inner classes /////
+    class TextAreaPanel extends JPanel
+    {
+	JTextArea h_textArea = new JTextArea(8, 20);
+
+	public TextAreaPanel(String name)
+	{
+	    setLayout( new BorderLayout() );
+	    h_textArea.setText(">");
+	    JScrollPane scrollPane = new JScrollPane(h_textArea);
+	    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
+	    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+	    add(scrollPane, BorderLayout.CENTER);
+	    add(new JLabel(name), BorderLayout.SOUTH);
+	}
+    }
+
+
+} // Monitor
+
+
diff --git a/habmonitors/portal/HabitatMonitor.java b/habmonitors/portal/HabitatMonitor.java
new file mode 100644
index 0000000..122f8df
--- /dev/null
+++ b/habmonitors/portal/HabitatMonitor.java
@@ -0,0 +1,214 @@
+package psl.habitats.portal;
+
+import psl.habitats.ServiceInterface;
+
+import java.awt.Dimension;
+import java.awt.CardLayout;
+import java.awt.GridLayout;
+import java.awt.BorderLayout;
+import java.awt.*;
+
+import javax.swing.JList;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JLabel;
+import javax.swing.JTextArea;
+import javax.swing.JScrollPane;
+
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+import java.util.Vector;
+import java.util.Hashtable;
+import java.util.Enumeration;
+
+public class HabitatMonitor extends JFrame {
+  private static final int WIDTH = 800;
+  private static final int HEIGHT = 400;
+  private static final int CTRL_WIDTH = 200;
+
+  private final Hashtable _portals;
+
+  private final JPanel _mainPanel;
+    private final JPanel _logPanel;
+    private final JPanel _svcPanel;
+    private final JPanel _svcPane;
+    private final JLabel _logLabel;
+    private final JLabel _svcLabel;
+    //  private final JPanel _ctrlPanel;
+    //  private final JList _servicesList;
+    //  private final JLabel _dataLabel;
+    //  private final JPanel _portalPanel;
+  private final JTextArea _logArea;
+  private final JScrollPane _logPane;
+
+    Hashtable monitors = new Hashtable();
+    Hashtable messages = new Hashtable();
+
+    //  private final CardLayout _cardLayout;
+
+  public HabitatMonitor(String habitatName) {
+      //, Enumeration services,
+      //		HabitatPortal hp) {
+
+    // Data struRctures ///////////////////////////////////////////////////
+    _portals = new Hashtable();
+
+    // GUI stuff /////////////////////////////////////////////////////////
+    //    Point p = hp.getLocation();
+    //    System.out.println("christy:  location: " + p.x + " " + p.y);
+    //    Dimension d = hp.getSize();
+
+    setTitle(habitatName + " Monitor");
+    setSize(HabitatMonitor.WIDTH, HabitatMonitor.HEIGHT);
+    //    setLocation(p.x, p.y+(HabitatMonitor.HEIGHT*6+50));
+
+    //    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+    setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
+
+    //CKL
+    _mainPanel = new JPanel(new GridLayout(0,1));
+    //_mainPanel = new JPanel(new BorderLayout());
+    //    _ctrlPanel = new JPanel(new GridLayout(2, 1, 5, 5));
+    //    _dataLabel = new JLabel("");
+    //    _portalPanel = new JPanel(_cardLayout = new CardLayout());
+
+    _logPanel = new JPanel(new BorderLayout());
+    _logLabel = new JLabel(habitatName + " Habitat Monitor");
+    _logPane = new JScrollPane(_logArea = new JTextArea("", 8, 10));
+    _logArea.setEditable(false);
+
+    _svcPanel = new JPanel(new BorderLayout());
+    _svcPane = new JPanel(new GridLayout(0,2));
+    _svcLabel = new JLabel("Service Monitors");
+    //    _svcPane = new JScrollPane(_logArea = new JTextArea("some text", 8, 10));
+    //    _svcArea.setEditable(false);
+
+    _logPanel.add(_logLabel, BorderLayout.NORTH);
+    _logPanel.add(_logPane, BorderLayout.CENTER);
+
+    _svcPanel.add(_svcLabel, BorderLayout.NORTH);
+    _svcPanel.add(_svcPane, BorderLayout.CENTER);
+
+
+    //    _mainPanel.add(_ctrlPanel, BorderLayout.WEST);
+    //    _mainPanel.add(_portalPanel, BorderLayout.CENTER);
+    _mainPanel.add(_logPanel, BorderLayout.NORTH);
+    _mainPanel.add(_svcPanel, BorderLayout.CENTER);
+    //    _mainPanel.add(_logPane);
+
+    //    _ctrlPanel.add(_servicesList);
+    //    _ctrlPanel.add(new JScrollPane(_dataLabel));
+    //    _ctrlPanel.setMinimumSize(new Dimension(CTRL_WIDTH, HEIGHT));
+
+    getContentPane().add(_mainPanel);
+
+    // getContentPane().add(_logPanel);
+
+    //    getContentPane().add(_svcPanel);
+
+
+    //    show();
+  }
+
+    public void fix(HabitatPortal hap) {
+	//public void fix(Point p) {
+	Point p = hap.getLocation();
+	setLocation(p.x, p.y+(HabitatMonitor.HEIGHT+100));
+	show();
+    }
+
+
+
+    public void addmonitor(String name) {
+	//	String name = _portals.get(service);
+
+	if (monitors.get(name) != null) { return; }
+	monitors.put(name, new TextAreaPanel(name));
+	//(f.getContentPane()).add((TextAreaPanel)monitors.get(name));
+	_svcPane.add((TextAreaPanel)monitors.get(name));
+	rewritemonitor(name);
+	//	f.validate();
+	/*	if (noframe) {
+	    (f.getContentPane()).setLayout(new GridLayout(0,2));
+	    f.setSize(500, 500);
+	    f.setVisible(true);
+	    noframe = false;
+	    }*/
+    }
+
+    public void writemonitor(String str, String svcname) {
+	try {
+	    //new -- save messages
+	    String output = (str + "\n"); //>");
+	    //	    messages.add(output);
+	    if (messages.get(svcname) == null) {
+		messages.put(svcname, new Vector());
+	    }
+	    ((Vector)(messages.get(svcname))).add(output);
+
+	    ((TextAreaPanel)
+	     (monitors.get(svcname))).h_textArea.append(output);
+	} catch (Exception e) {
+	}
+    }
+
+    void rewritemonitor(String svcname) {
+	try {
+	    for (Enumeration e =
+		     ((Vector)(messages.get(svcname))).elements();
+		 e.hasMoreElements() ;) {
+
+		//		System.out.println("christy: want to write enumeration: " +
+		//				   ((String) e.nextElement()));
+		((TextAreaPanel)
+		 (monitors.get(svcname)))
+		    .h_textArea.append((String) e.nextElement());
+	    }
+	} catch (Exception e) {
+	}
+    }
+
+    /*    void writemonitor(String str, String svcname) {
+	try {
+	    ((TextAreaPanel)(monitors.get(svcname))).h_textArea.append(str+"\n>");
+	} catch (Exception e) {
+	}
+	}*/
+
+    /////// Inner classes /////
+    class TextAreaPanel extends JPanel
+    {
+	JTextArea h_textArea = new JTextArea(8, 20);
+
+	public TextAreaPanel(String name)
+	{
+	    setLayout( new BorderLayout() );
+	    //	    h_textArea.setText(">");
+	    JScrollPane scrollPane = new JScrollPane(h_textArea);
+	    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
+	    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+	    add(scrollPane, BorderLayout.CENTER);
+	    add(new JLabel(name), BorderLayout.SOUTH);
+	}
+    }
+
+
+
+  public void updatePortal(String key) {
+      //    _cardLayout.show(_portalPanel, key);
+  }
+  public void log(String msg) {
+    _logArea.append(msg + "\n");
+  }
+
+  private String generateHTML(Object o) {
+    if (o instanceof ServiceInterface)
+      return ((ServiceInterface) o).getDetailDescription();
+    else return "INVALID";
+  }
+
+  public static void main(String args[]) {
+      new HabitatMonitor("HabitatMonitor"); //, null, null);
+  }
+}
diff --git a/habmonitors/portal/HabitatPortal.java b/habmonitors/portal/HabitatPortal.java
new file mode 100644
index 0000000..ad10bc0
--- /dev/null
+++ b/habmonitors/portal/HabitatPortal.java
@@ -0,0 +1,121 @@
+package psl.habitats.portal;
+
+import psl.habitats.ServiceInterface;
+
+import java.awt.Dimension;
+import java.awt.CardLayout;
+import java.awt.GridLayout;
+import java.awt.BorderLayout;
+
+import javax.swing.JList;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JLabel;
+import javax.swing.JTextArea;
+import javax.swing.JScrollPane;
+
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+import java.util.Vector;
+import java.util.Hashtable;
+import java.util.Enumeration;
+
+public class HabitatPortal extends JFrame {
+  private static final int WIDTH = 800;
+  private static final int HEIGHT = 450;
+  private static final int CTRL_WIDTH = 200;
+
+  private final Hashtable _portals;
+
+  private final JPanel _mainPanel;
+  private final JPanel _ctrlPanel;
+  private final JList _servicesList;
+  private final JLabel _dataLabel;
+  private final JPanel _portalPanel;
+    //  private final JTextArea _logArea;
+    //  private final JScrollPane _logPane;
+
+  private final CardLayout _cardLayout;
+
+  public HabitatPortal(String habitatName, Enumeration services) {
+
+    // Data struRctures ///////////////////////////////////////////////////
+    _portals = new Hashtable();
+
+    // GUI stuff /////////////////////////////////////////////////////////
+
+    // for demo
+    if (habitatName.charAt(0) == 'N') {
+	setLocation(100, 50);
+    } else if (habitatName.charAt(0) == 'A') {
+	setLocation(200, 100);
+    } else if (habitatName.charAt(0) == 'T') {
+	setLocation(300, 150);
+    }
+
+    setTitle(habitatName);
+    setSize(HabitatPortal.WIDTH, HabitatPortal.HEIGHT);
+    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+    _mainPanel = new JPanel(new BorderLayout());
+    _ctrlPanel = new JPanel(new GridLayout(2, 1, 5, 5));
+    _dataLabel = new JLabel("");
+    _portalPanel = new JPanel(_cardLayout = new CardLayout());
+    //    _logPane = new JScrollPane(_logArea = new JTextArea("some text", 8, 10));
+    //    _logArea.setEditable(false);
+
+
+
+    if (services != null) {
+      Vector servicesListing = new Vector();
+      while (services.hasMoreElements()) {
+        ServiceInterface si = (ServiceInterface) services.nextElement();
+        String serviceDesc = si.getDescription();
+        servicesListing.add(serviceDesc);
+        _portalPanel.add(si.startDisplay(), serviceDesc);
+
+        _portals.put(serviceDesc, si);
+      }
+      _servicesList = new JList(servicesListing.toArray());
+    } else _servicesList = new JList(new String[] { "hello", "there" });
+
+    _servicesList.addListSelectionListener(new ListSelectionListener() {
+      public void valueChanged(ListSelectionEvent lse) {
+        String service = "" + _servicesList.getSelectedValue();
+        try {
+          _dataLabel.setText(generateHTML(_portals.get(service)));
+          _cardLayout.show(_portalPanel, service);
+        } catch (Exception e) { }
+      }
+    });
+
+    _mainPanel.add(_ctrlPanel, BorderLayout.WEST);
+    _mainPanel.add(_portalPanel, BorderLayout.CENTER);
+    //    _mainPanel.add(_logPane, BorderLayout.SOUTH);
+
+    _ctrlPanel.add(_servicesList);
+    _ctrlPanel.add(new JScrollPane(_dataLabel));
+    _ctrlPanel.setMinimumSize(new Dimension(CTRL_WIDTH, HEIGHT));
+
+    getContentPane().add(_mainPanel);
+    show();
+  }
+
+  public void updatePortal(String key) {
+    _cardLayout.show(_portalPanel, key);
+  }
+  public void log(String msg) {
+      //    _logArea.append(msg + "\n");
+  }
+
+  private String generateHTML(Object o) {
+    if (o instanceof ServiceInterface)
+      return ((ServiceInterface) o).getDetailDescription();
+    else return "INVALID";
+  }
+
+  public static void main(String args[]) {
+    new HabitatPortal("HabitatPortal", null);
+  }
+}
diff --git a/habmonitors/services/.AmTrakServiceList b/habmonitors/services/.AmTrakServiceList
new file mode 100644
index 0000000..b13831a
--- /dev/null
+++ b/habmonitors/services/.AmTrakServiceList
@@ -0,0 +1,2 @@
+NYC_Passengers_Query,psl.habitats.services.NYCPassListService
+AlertService,psl.habitats.services.AlertService
diff --git a/habmonitors/services/.NYPDServiceList b/habmonitors/services/.NYPDServiceList
new file mode 100644
index 0000000..b3386f7
--- /dev/null
+++ b/habmonitors/services/.NYPDServiceList
@@ -0,0 +1,3 @@
+Maps,psl.habitats.services.MapService
+EventListener,psl.habitats.services.EventService
+AlertService,psl.habitats.services.AlertService
diff --git a/habmonitors/services/.TexasServiceList b/habmonitors/services/.TexasServiceList
new file mode 100644
index 0000000..9dd876e
--- /dev/null
+++ b/habmonitors/services/.TexasServiceList
@@ -0,0 +1,2 @@
+TexasResidentInfo,psl.habitats.services.ResidentsListService
+AlertService,psl.habitats.services.AlertService
diff --git a/habmonitors/services/AlertService.java b/habmonitors/services/AlertService.java
new file mode 100644
index 0000000..18ac624
--- /dev/null
+++ b/habmonitors/services/AlertService.java
@@ -0,0 +1,71 @@
+package psl.habitats.services;
+import psl.habitats.*;
+
+import javax.swing.*;
+
+import java.util.Date;
+import java.util.Vector;
+import java.util.Hashtable;
+import java.util.Enumeration;
+
+public class AlertService implements ServiceInterface {
+  private static final String myDescription = "AlertService";
+  Habitat masterHabitat = null;
+  public void initialize(Habitat _h) {
+    masterHabitat = _h;
+  }
+  public String getDescription(){
+    return myDescription;
+  }
+  public String getDetailDescription(){
+    StringBuffer _stringBuffer = new StringBuffer();
+    _stringBuffer.setLength(0);
+    _stringBuffer.append("<html><body>");
+    _stringBuffer.append("<h1>" + getDescription() + "</h1>");
+    _stringBuffer.append("<table border=4>");
+    _stringBuffer.append("<tr><td>Purpose</td><td>Hit Panic Button</td></tr>");
+    _stringBuffer.append("<tr><td>Availablity</td><td>Selected</td></tr>");
+    _stringBuffer.append("<tr><td>Monitor</td><td>True</td></tr>");
+    _stringBuffer.append("<tr><td>Monitor-Mode</td><td>Text</td></tr>");
+    _stringBuffer.append("</table>");
+    _stringBuffer.append("</body></html>");
+    return _stringBuffer + "";
+  }
+  private JPanel panel;
+  public JPanel startDisplay() {
+    return (panel = new JPanel());
+  }
+
+  private static final String key1 = "First_Name";
+  private static final String key2 = "Last_Name";
+  private static final String key3 = "Boarding_City";
+  private static final String key4 = "Boarding_Date";
+  private static final String key5 = "Address";
+  private static final String key6 = "Telephone";
+  private static final String key7 = "SSN";
+  private static final String key8 = "Age";
+  private static final String key9 = "Image";
+
+  public Hashtable performService(String _senderService, Hashtable ipList) {
+    StringBuffer _stringBuffer = new StringBuffer();
+    _stringBuffer.setLength(0);
+    _stringBuffer.append("<html><body>\n");
+    _stringBuffer.append("<h1>" + getDescription() + "</h1>\n");
+    _stringBuffer.append("<table border=4>\n");
+    for (Enumeration e=ipList.keys(); e.hasMoreElements(); ) {
+      String key = e.nextElement().toString();
+      if (key.equals(key9)) continue;
+      _stringBuffer.append("<tr><td>"+key+"</td><td>"+ipList.get(key)+"</td></tr>\n");
+    }
+    _stringBuffer.append("<tr><td colspan=2><img src="+ipList.get(key9)+"></td></tr>\n");
+    _stringBuffer.append("</table>\n");
+    _stringBuffer.append("</body></html>\n");
+
+    JLabel label = new JLabel("" + _stringBuffer);
+    JOptionPane.showMessageDialog(panel, label, "Alert Service", JOptionPane.WARNING_MESSAGE);
+    masterHabitat.log("" + _stringBuffer);
+    System.out.println("JUST LOGGED: " + _stringBuffer);
+
+    return null;
+  }
+}
diff --git a/habmonitors/services/EventService.java b/habmonitors/services/EventService.java
new file mode 100644
index 0000000..ae41cbe
--- /dev/null
+++ b/habmonitors/services/EventService.java
@@ -0,0 +1,270 @@
+package psl.habitats.services;
+import psl.habitats.*;
+
+import java.awt.*;
+import java.awt.event.*;import javax.swing.*;
+
+import java.util.Vector;
+import java.util.Hashtable;
+import java.util.Enumeration;
+
+public class EventService implements ServiceInterface {
+    String myDescription = "Event_Manager";
+    Habitat masterHabitat = null;
+
+    private final Hashtable informationCatalogue = new Hashtable();
+
+    private static final String key1 = "First_Name";
+    private static final String key2 = "Last_Name";
+    private static final String key3 = "Boarding_City";
+    private static final String key4 = "Boarding_Date";
+    private static final String key5 = "Address";
+    private static final String key6 = "Telephone";
+    private static final String key7 = "SSN";
+    private static final String key8 = "Age";
+    private static final String key9 = "Image";
+
+    //CKL
+    //ControlFrontEndFrame frame = new ControlFrontEndFrame();
+
+    public void initialize(Habitat _h){
+	masterHabitat = _h;
+    }
+    public String getDescription() {
+	return myDescription;
+    }
+    public String getDetailDescription(){
+	StringBuffer _stringBuffer = new StringBuffer();
+	_stringBuffer.setLength(0);
+	_stringBuffer.append("<html><body>");
+	_stringBuffer.append("<h1>" + getDescription() + "</h1>");
+	_stringBuffer.append("<table border=4>");
+	_stringBuffer.append("<tr><td>Purpose</td><td>Receive and Update Events </td></tr>");
+	_stringBuffer.append("<tr><td>Availablity</td><td>Local</td></tr>");
+	_stringBuffer.append("<tr><td>Monitor</td><td>True</td></tr>");
+	_stringBuffer.append("<tr><td>Monitor-Mode</td><td>Text</td></tr>");
+	_stringBuffer.append("</table>");
+	_stringBuffer.append("</body></html>");
+	return _stringBuffer + "";
+    }
+
+    private String phaseOneData;
+    public JPanel startDisplay(){
+	// start the GUI here
+	final JPanel panel = new JPanel(new GridLayout(20, 1));
+	final JLabel label = new JLabel("Enter name: ");
+	final JTextField text = new JTextField(20);    JButton button = new JButton("Action!");    panel.add(new JLabel("FOR USE BY AUTHORISED PERSONNEL!"));
+	{JPanel p = new JPanel(new GridLayout(1, 2));p.add(new JLabel("Type of Event: "));p.add(new JTextField(10));panel.add(p);}    {JPanel p = new JPanel(new GridLayout(1, 2));p.add(new JLabel("Available Data: "));p.add(new JTextField(10));panel.add(p);}
+	{JPanel p = new JPanel(new GridLayout(1, 2));p.add(new JLabel("Description: "));p.add(new JTextField(10));panel.add(p);}
+	{JPanel p = new JPanel(new GridLayout(1, 2));p.add(label);p.add(text);panel.add(p);}
+	panel.add(button);
+
+	button.addActionListener(new ActionListener() {
+		public void actionPerformed(ActionEvent ae) {
+		    phaseOneData = text.getText();
+		    phaseOne();
+		    //CKL
+		    //		    phaseTwo();
+		}
+	    });
+	return panel;
+    }
+
+    private static final String PHASE_ONE_PEER = "NYC_Passengers_Query";
+    private static final String PHASE_TWO_PEER = "TexasResidentInfo";
+    private static final String PHASE_THREE_PEER = "AlertService";
+
+    int phaseOneProgress = 0, phaseTwoProgress = 0, phaseThreeProgress = 0;
+
+    private String hashtableListing(Hashtable h) {
+	StringBuffer sb = new StringBuffer("");
+	for (Enumeration e = h.keys(); e.hasMoreElements(); ) {
+	    String key = "" + e.nextElement();
+	    sb.append("key: " + key + ", val: " + h.get(key));
+	}
+	return "" + sb;
+    }
+    public Hashtable performService(String _senderService, Hashtable ipList) {
+	Hashtable result = new Hashtable();
+
+	//CKL
+	//	System.out.println("christy: in performService");
+
+
+	if(_senderService.equals(PHASE_ONE_PEER)) {
+	    masterHabitat.log(myDescription + " :: PHASE_ONE_PEER " + PHASE_ONE_PEER);
+	    switch (phaseOneProgress) {
+	    case 0:
+		result.put(key1, phaseOneData);
+		phaseOneProgress++;
+		break;
+
+	    case 1:
+		for (Enumeration e=ipList.keys(); e.hasMoreElements(); ) {
+		    String key = e.nextElement().toString();
+		    informationCatalogue.put(key, ipList.get(key));
+		}
+		masterHabitat.log(myDescription + ":: Terminating Session with " + PHASE_TWO_PEER);
+		result.put("Terminate_Session", "SESSION_ENDED");
+		phaseOneProgress = 0;
+
+		// initiate phase-II
+		phaseTwo();
+		break;
+
+	    }
+
+	} else if(_senderService.equals(PHASE_TWO_PEER)) {
+	    masterHabitat.log(myDescription + ":: PHASE_TWO_PEER " + PHASE_TWO_PEER);
+	    switch (phaseTwoProgress) {
+	    case 0:
+		result.put(key1, informationCatalogue.get(key1));
+		result.put(key2, informationCatalogue.get(key2));
+		phaseTwoProgress++;
+		break;
+
+	    case 1:
+		for (Enumeration e=ipList.keys(); e.hasMoreElements(); ) {
+		    String key = e.nextElement().toString();
+		    informationCatalogue.put(key, ipList.get(key));
+		}
+		result.put("Terminate_Session", "SESSION_ENDED");
+		masterHabitat.log(myDescription + " Terminating Session with " + PHASE_TWO_PEER);
+		phaseTwoProgress = 0;
+
+		// initiate phase-III
+		phaseThree();
+		break;
+
+	    }
+	} else if(_senderService.equals(PHASE_THREE_PEER)) {
+	    masterHabitat.log(myDescription + ":: PHASE_THREE_PEER" + PHASE_THREE_PEER);
+	    switch (phaseThreeProgress) {
+	    case 0:
+		for (Enumeration e=informationCatalogue.keys(); e.hasMoreElements(); ) {
+		    String key = e.nextElement().toString();
+		    if (key.equals(key3) || key.equals(key4)) continue;
+		    result.put(key, informationCatalogue.get(key));
+		    // masterHabitat.log("$$$$$$$$Sending this " + key);
+		}
+		phaseThreeProgress++;
+		break;
+
+	    case 1:
+		phaseThreeProgress = 0;
+		masterHabitat.log(myDescription + " Terminating Session with " + PHASE_THREE_PEER);
+		result.put("Terminate_Session", "SESSION_ENDED");
+		break;
+	    }
+	}
+
+	masterHabitat.log(myDescription + ": performService, returning: " + hashtableListing(result));
+	return result;
+    }
+    private void phaseOne() {
+
+	masterHabitat.log(myDescription + " : Active ");
+	masterHabitat.log(myDescription + " : Entering Phase One ");
+
+	//	public void statusMsg(String servname, String message) {
+
+	masterHabitat.statusMsg(myDescription,  " Received some new Info - processing it .. ");
+	masterHabitat.statusMsg(myDescription,  " Number of Steps Suggested -> 3 ");
+	masterHabitat.statusMsg(myDescription,  " Entering Phase One ");
+	masterHabitat.statusMsg(myDescription,  " Need to gather information on 'NYC Passengers'" );
+	masterHabitat.statusMsg(myDescription,  " Contact Habitat -> 'NYCTransitHabitat'");
+	masterHabitat.statusMsg(myDescription,  " Contact Service -> 'NYC_Passengers_Query'");
+
+
+
+	/*	masterHabitat.log(myDescription + " Received some new Info - processing it .. ");
+	masterHabitat.log(myDescription + " Number of Steps Suggested -> 3 ");
+	masterHabitat.log(myDescription + " Entering Phase One ");
+	masterHabitat.log(myDescription + " Need to gather information on 'NYC Passengers'" );
+	masterHabitat.log(myDescription + " Contact Habitat -> 'NYCTransitHabitat'");
+	masterHabitat.log(myDescription + " Contact Service -> 'NYC_Passengers_Query'");
+	*/
+
+	// invoked by user entering chor's name
+	// some intelligent workflow suggested that service to be contacted
+	String useService = "NYC_Passengers_Query";
+
+	//CKL
+	//	System.out.println("christy: in phase one");
+
+	if(!Habitat.localService(useService)) {
+
+	    //CKL
+	    //	    System.out.println("christy: not local service");
+
+	    Hashtable ipList = new Hashtable();
+	    ipList.put("habitatCategory","NYCTransitHabitat");
+	    ipList.put("EventType","ServiceRequest");
+	    ipList.put("Request4Service", useService);
+	    ipList.put("totalParams","1");
+	    ipList.put("params1", key1);
+	    ipList.put("totalRetvals", "4");
+	    ipList.put("retvals1", key1);
+	    ipList.put("retvals2", key2);
+	    ipList.put("retvals3", key3);
+	    ipList.put("retvals4", key4);
+
+	    masterHabitat.statusMsg(myDescription, " Need Remote Service, await response");
+	    masterHabitat.log(myDescription + " : Request for GateKeeper action ");
+
+	    masterHabitat.gk.broadcast_req(myDescription, useService, ipList);
+
+
+	    //	    masterHabitat.log(myDescription + " Requesting Gatekeeper to contact Remote Service");
+	}
+	masterHabitat.log(myDescription + ": phaseOne, returned");
+	masterHabitat.statusMsg(myDescription, " phaseOne, returned");
+    }
+
+    private void phaseTwo() {
+	masterHabitat.log(myDescription + ": phaseTwo");
+	String useService = "TexasResidentInfo";
+	if (!Habitat.localService(useService)) {
+	    Hashtable ipList = new Hashtable();
+	    ipList.put("habitatCategory","TexasStateHabitat");
+	    ipList.put("EventType","ServiceRequest");
+	    ipList.put("Request4Service", useService);
+	    ipList.put("totalParams","2");
+	    ipList.put("params1", key1);
+	    ipList.put("params2", key2);
+	    ipList.put("totalRetvals", "5");
+	    ipList.put("retvals1", key5);
+	    ipList.put("retvals2", key6);
+	    ipList.put("retvals3", key7);
+	    ipList.put("retvals4", key8);
+	    ipList.put("retvals5", key9);
+
+	    masterHabitat.gk.broadcast_req(myDescription, useService, ipList);
+	}
+	masterHabitat.log(myDescription + ": phaseTwo, returned");
+    }
+
+    private void phaseThree() {
+	masterHabitat.log(myDescription + ": phaseThree");
+	String useService = "AlertService";
+	if (!Habitat.localService(useService)) {
+	    Hashtable ipList = new Hashtable();
+	    ipList.put("habitatCategory","NYCTransitHabitat");
+	    ipList.put("EventType","ServiceRequest");
+	    ipList.put("Request4Service", useService);
+	    ipList.put("totalParams","7");
+	    ipList.put("params1", key1);
+	    ipList.put("params2", key2);
+	    ipList.put("params3", key5);
+	    ipList.put("params4", key6);
+	    ipList.put("params5", key7);
+	    ipList.put("params6", key8);
+	    ipList.put("params7", key9);
+	    ipList.put("totalRetvals", "0");
+
+	    masterHabitat.gk.broadcast_req(myDescription, useService, ipList);
+	}
+	masterHabitat.log(myDescription + ": phaseThree, returned");
+    }
+
+}
diff --git a/habmonitors/services/MapService.java b/habmonitors/services/MapService.java
new file mode 100644
index 0000000..f81321e
--- /dev/null
+++ b/habmonitors/services/MapService.java
@@ -0,0 +1,36 @@
+package psl.habitats.services;
+
+import psl.habitats.*;
+
+import javax.swing.*;
+import java.util.Hashtable;
+
+public class MapService implements ServiceInterface {  
  private static String serviceDescription = "MapService";
+  public MapService() {	}
+  public void initialize(Habitat _h) { }
+  public String getDescription() {
+    return serviceDescription;
+  }
+  public JPanel startDisplay() {
+    return new JPanel();
+  }
+
+  public String getDetailDescription(){
+    StringBuffer _stringBuffer = new StringBuffer();
+    _stringBuffer.setLength(0);
+    _stringBuffer.append("<html><body>");
+    _stringBuffer.append("<h1>" + getDescription() + "</h1>");
+    _stringBuffer.append("<table border=4>");
+    _stringBuffer.append("<tr><td>Purpose</td><td>Maps Database</td></tr>");
+    _stringBuffer.append("<tr><td>Availablity</td><td>Not available</td></tr>");
+    _stringBuffer.append("<tr><td>Monitor</td><td>Probably</td></tr>");
+    _stringBuffer.append("<tr><td>Monitor-Mode</td><td>NA</td></tr>");
+    _stringBuffer.append("</table>");
+    _stringBuffer.append("</body></html>");
+  return _stringBuffer + "";
+  }
+
+  public Hashtable performService(String _senderService, Hashtable ipList) {
+    return null;
+  }
+}
diff --git a/habmonitors/services/NYCPassListService.java b/habmonitors/services/NYCPassListService.java
new file mode 100644
index 0000000..5c75b76
--- /dev/null
+++ b/habmonitors/services/NYCPassListService.java
@@ -0,0 +1,78 @@
+package psl.habitats.services;
+import psl.habitats.*;
+
+import javax.swing.*;
+
+import java.util.Date;
+import java.util.Vector;
+import java.util.Hashtable;
+
+public class NYCPassListService implements ServiceInterface {
+  private static final String myDescription = "NYC_Passengers_Query";
+  Habitat masterHabitat = null;
+  public void initialize(Habitat _h) {
+    masterHabitat = _h;
+  }
+  public String getDescription(){
+    return myDescription;
+  }
+  public JPanel startDisplay() {
+    return new JPanel();
+  }
+
+  public String getDetailDescription(){
+    StringBuffer _stringBuffer = new StringBuffer();
+    _stringBuffer.setLength(0);
+    _stringBuffer.append("<html><body>");
+    _stringBuffer.append("<h1>" + getDescription() + "</h1>");
+    _stringBuffer.append("<table border=4>");
+    _stringBuffer.append("<tr><td>Purpose     </td><td>AmTrak Passenger List</td></tr>");
+    _stringBuffer.append("<tr><td>Availablity </td><td>Local/Remote         </td></tr>");
+    _stringBuffer.append("<tr><td>Monitor     </td><td>True                 </td></tr>");
+    _stringBuffer.append("<tr><td>Monitor-Mode</td><td>Text                 </td></tr>");
+    _stringBuffer.append("</table>");
+    _stringBuffer.append("</body></html>");
+    return _stringBuffer + "";
+  }
+
+  private static final String key1 = "First_Name";
+  private static final String key2 = "Last_Name";
+  private static final String key3 = "Boarding_City";
+  private static final String key4 = "Boarding_Date";
+
+  public Hashtable performService(String _senderService, Hashtable ipList) {
+    masterHabitat.log(myDescription + ": performService for " + _senderService);
+    Hashtable result = new Hashtable();
+    if(ipList.containsKey(key1) || ipList.containsKey(key2)){
+      result.put(key1, lookup("" + ipList.get(key1), key1, masterHabitat.getName()));
+      result.put(key2, lookup("" + ipList.get(key1), key2, masterHabitat.getName()));
+      result.put(key3, lookup("" + ipList.get(key1), key3, masterHabitat.getName()));
+      result.put(key4, lookup("" + ipList.get(key1), key4, masterHabitat.getName()));
+    } else
+      result = null;
+    masterHabitat.log(myDescription + ": returning requested Data ");
+    return result;
+  }
+
+  private static final String HABITAT_NAME = "AmTrak";
+  private String lookup(String key1, String key, String forHab) {
+    if (forHab.equals(HABITAT_NAME)) {
+      if (key1.equalsIgnoreCase("john")) return "" + johnHash.get(key);
+      if (key1.equalsIgnoreCase("gail")) return "" + gailHash.get(key);
+    }
+    return null;
+  }
+  private static final Hashtable gailHash = new Hashtable();
+  private static final Hashtable johnHash = new Hashtable();
+  static {
+    gailHash.put(key1, "Gail");
+    gailHash.put(key2, "Kaiser");
+    gailHash.put(key3, "Texas");
+    gailHash.put(key4, "Friday morning");
+
+    johnHash.put(key1, "John");
+    johnHash.put(key2, "Salasin");
+    johnHash.put(key3, "Texas");
+    johnHash.put(key4, "Yesterday");
+  }
+}
diff --git a/habmonitors/services/ResidentsListService.java b/habmonitors/services/ResidentsListService.java
new file mode 100644
index 0000000..c3e9ba5
--- /dev/null
+++ b/habmonitors/services/ResidentsListService.java
@@ -0,0 +1,87 @@
+package psl.habitats.services;
+import psl.habitats.*;
+
+import javax.swing.*;
+
+import java.util.Vector;
+import java.util.Hashtable;
+
+public class ResidentsListService implements ServiceInterface {
+  String myDescription = "TexasResidentInfo";
+  Habitat masterHabitat = null;
+
+  public void initialize(Habitat _h){
+    masterHabitat = _h;
+  }
+  public String getDescription() {
+    return myDescription;
+  }
+  public JPanel startDisplay() {
+    return new JPanel();
+  }
+  public String getDetailDescription(){
+    StringBuffer _stringBuffer = new StringBuffer();
+    _stringBuffer.setLength(0);
+    _stringBuffer.append("<html><body>");
+    _stringBuffer.append("<h1>" + getDescription() + "</h1>");
+    _stringBuffer.append("<table border=4>");
+    _stringBuffer.append("<tr><td>Purpose</td><td>Texas Residents Credentials </td></tr>");
+    _stringBuffer.append("<tr><td>Availablity</td><td>Local/Remote</td></tr>");
+    _stringBuffer.append("<tr><td>Monitor</td><td>True</td></tr>");
+    _stringBuffer.append("<tr><td>Monitor-Mode</td><td>Text</td></tr>");
+    _stringBuffer.append("</table>");
+    _stringBuffer.append("</body></html>");
+    return _stringBuffer + "";
+  }
+
+  private static final String key1 = "First_Name";
+  private static final String key2 = "Last_Name";
+  private static final String key5 = "Address";
+  private static final String key6 = "Telephone";
+  private static final String key7 = "SSN";
+  private static final String key8 = "Image";
+  private static final String key9 = "Age";
+
+  public Hashtable performService(String _senderService, Hashtable ipList) {
+    masterHabitat.log(myDescription + ": performService for " + _senderService);
+    Hashtable result = new Hashtable();
+    if (ipList.containsKey(key1) && ipList.containsKey(key2)) {
+      result.put(key5, lookup("" + ipList.get(key1), key5, masterHabitat.getName()));
+      result.put(key6, lookup("" + ipList.get(key1), key6, masterHabitat.getName()));
+      result.put(key7, lookup("" + ipList.get(key1), key7, masterHabitat.getName()));
+      result.put(key8, lookup("" + ipList.get(key1), key8, masterHabitat.getName()));
+      result.put(key9, lookup("" + ipList.get(key1), key9, masterHabitat.getName()));
+    } else
+      result = null;
+    masterHabitat.log(myDescription + ": returning requested data ");
+    return result;
+  }
+
+  private static final String HABITAT_NAME = "Texas";
+  private String lookup(String key1, String key, String forHab) {
+    if (forHab.equals(HABITAT_NAME)) {
+      if (key1.equalsIgnoreCase("john")) return "" + johnHash.get(key);
+      if (key1.equalsIgnoreCase("gail")) return "" + gailHash.get(key);
+    }
+    return null;
+  }
+  private static final Hashtable gailHash = new Hashtable();
+  private static final Hashtable johnHash = new Hashtable();
+  static {
+    gailHash.put(key1, "Gail");
+    gailHash.put(key2, "Kaiser");
+    gailHash.put(key5, "New Jersey");
+    gailHash.put(key6, "(212) 939-7100");
+    gailHash.put(key7, "123-45-6789");
+    gailHash.put(key8, "http://www.psl.cs.columbia.edu/personnel/gail.jpg");
+    gailHash.put(key9, "18");
+
+    johnHash.put(key1, "John");
+    johnHash.put(key2, "Salasin");
+    johnHash.put(key5, "DARPA");
+    johnHash.put(key6, "(800) SAL-ASIN");
+    johnHash.put(key7, "987-65-4321");
+    johnHash.put(key8, "http://www.cs.columbia.edu/~ajs248/intropic.jpg");
+    johnHash.put(key9, "18");
+  }
+}