package cmsc433; import java.io.*; import java.net.*; public class SimpleTest { public static final int port = Integer.getInteger("port", 9081).intValue(); // starts the local processor public static void startLocalProcessor() throws Exception { // the local event processing chain looks like the following: // // +------------+ +--------+ +--------------+ // | |-->| filter |-->| remoteclient |-/\/\-> // | | +--------+ +--------------+ // | dispatcher | +---------+ // | |-->| printer | // +------------+ +---------+ // Dispatcher ed = new Dispatcher (); Filter f = new Filter ("urg"); f.attach (new RemoteClient (InetAddress.getLocalHost(), port)); ed.attach (f); ed.attach (new Printer (new PrintWriter (System.out, true))); // start processing events while (true) { ed.process (new Event (new IR("Food", "Hamburger"))); ed.process (new Event (new IR("Cheese", "Limburger"))); ed.process (new Event (new IR("Drink","Beer"))); ed.process (new Event (new IR("Beer","Bitburger"))); System.out.println(); Thread.sleep (1000); } } // starts the remote processing thread public static void startRemoteProcessor() throws Exception { // the remote event processing chain looks like the following: // // +--------------+ +-------------+ +---------+ // -/\/\->| remoteserver |-->| timestamper |-->| printer | // +--------------+ +-------------+ +---------+ // final RemoteServer rb = new RemoteServer (port); Timestamper tm = new Timestamper (); rb.attach (tm); tm.attach (new Printer (new PrintWriter (System.out, true))); final Thread t = new Thread() { public void run() { rb.go(); } }; t.setDaemon(true); t.start(); } public static void main(String args[]) throws Exception { startRemoteProcessor(); startLocalProcessor(); } }