6 import java.rmi.server.*;
\r
7 import java.rmi.registry.*;
\r
11 static private Registry $reg = null;
\r
12 static private MyFS $myObject = null;
\r
13 static private Nameserver.MyDNS $root = null;
\r
14 static private Properties $prop = new Properties();
\r
17 static public void main(String[] $args)throws Exception{
\r
18 if($args.length != 2){
\r
19 System.out.println("usage: java Fileserver.Main <my name> <dir>");
\r
23 System.out.println("Fileserver starting...");
\r
24 InputStream $in = ClassLoader.getSystemResourceAsStream("registry.properties");
\r
26 System.err.println("ERROR: Properties file not found!");
\r
32 $reg = LocateRegistry.getRegistry($prop.getProperty("registry.host"), Integer.parseInt($prop.getProperty("registry.port")));
\r
33 $root = (Nameserver.MyDNS) $reg.lookup("rmi://"+$prop.getProperty("registry.host")+":"+$prop.getProperty("registry.port")+"/"+$prop.getProperty("ro_id"));
\r
34 $myObject = new MyFSImpl($args[0],$args[1]);
\r
35 UnicastRemoteObject.exportObject($myObject, 0);
\r
36 $root.regServiceRecord($myObject);
\r
37 System.out.println("MyFS-Object created and registered.");
\r
39 System.out.println("Fileserver idle... Hit ENTER for shutdown.");
\r
41 Helper.readByte(System.in);
\r
44 }catch(Exception $e){
\r
45 System.err.println($e.getMessage());
\r
47 System.out.println("Nameserver shutting down...");
\r
48 if($root != null)$root.unregServiceRecord($myObject);
\r
49 UnicastRemoteObject.unexportObject($myObject, true);
\r
50 }catch(Exception $e){
\r
51 System.err.println($e.getMessage());
\r