FileDocCategorySizeDatePackage
NetWatch.javaAPI DocExample1996Sat Feb 17 15:15:08 GMT 2001None

NetWatch

public class NetWatch extends Object
Main program for the NetWatch program: watch the network status on a bunch of machines (i.e., in a classroom or lab). Currently only for RMI, but can be extended for TCP socket, CORBA ORB, etc.
author
Ian F. Darwin, ian@darwinsys.com
version
$Id: NetWatch.java,v 1.5 2001/02/17 20:15:08 ian Exp $ Copyright (c) 2000, Ian F. Darwin. See LEGAL.NOTICE for licensing.

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] argv)


		Properties p = null;

		NetFrame f = new NetFrame("Network Watcher", p);

		try {
			FileInputStream is = new FileInputStream("NetWatch.properties");
			p = new Properties();
			p.load(is);
			is.close();
		} catch (IOException e) {
			JOptionPane.showMessageDialog(f,
				e.toString(), "Properties error",
				JOptionPane.ERROR_MESSAGE);
		}

		// NOW CONSTRUCT PANELS, ONE FOR EACH HOST.

		// If arguments, use them as hostnames.
		if (argv.length!=0) {
			for (int i=0; i<argv.length; i++) {
				f.addHost(argv[i], p);
			}
		// No arguments. Can we use properties?
		} else if (p != null && p.size() > 0) {
			String net = p.getProperty("netwatch.net");
			int start = Integer.parseInt(p.getProperty("netwatch.start"));
			int end = Integer.parseInt(p.getProperty("netwatch.end"));
			for (int i=start; i<=end; i++) {
				f.addHost(net + "." + i, p);
			}
			for (int i=0; ; i++) {
				String nextHost = p.getProperty("nethost" + i);
				if (nextHost == null)
					break;
				f.addHost(nextHost, p);
			}
		}
		// None of the above. Fall back to localhost
		else {
			f.addHost("localhost", p);
		}

		// All done. Pack the Frame and show it.
		f.pack();
		// UtilGUI.centre(f);
		f.setVisible(true);
		f.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
		});