1 //import org.apache.xalan.xslt.*;
5 public class xaland_uwobo {
6 static DatagramSocket uwobo_socket;
9 public static void send_to_uwobo(String cmd)
10 throws java.io.IOException
12 /*CSC: UDP based, but not fault-tolerant */
13 byte[] cmdBytes = cmd.getBytes();
14 DatagramPacket packet =
15 new DatagramPacket(cmdBytes, cmdBytes.length,
16 InetAddress.getLocalHost(), portuwobo);
17 uwobo_socket.send(packet);
18 DatagramPacket rcv = new DatagramPacket(new byte[0], 0);
19 uwobo_socket.receive(rcv);
22 public static void main(String argv[]) throws java.io.IOException, java.net.MalformedURLException//, org.xml.sax.SAXException
24 int port = Integer.parseInt(argv[0]);
25 int port2 = Integer.parseInt(argv[1]);
26 portuwobo = Integer.parseInt(argv[2]);
27 String xsl1 = argv[3];
28 String xsl2 = argv[4];
29 String theory_xsl1 = argv[5];
30 String theory_xsl2 = argv[6];
32 DatagramSocket socket = new DatagramSocket(port);
33 uwobo_socket = new DatagramSocket();
35 /* Initialize uwobo */
36 send_to_uwobo("add " + xsl1 + " ciccontent");
37 send_to_uwobo("add " + xsl2 + " cicpres");
38 send_to_uwobo("add " + theory_xsl1 + " theorycontent");
39 send_to_uwobo("add " + theory_xsl2 + " theorypres");
42 System.out.println("Demon activated on input port " + port +
43 " and output port " + port2);
45 System.out.print("Ready...");
47 /* Warning: the packet must be a fresh one! */
48 DatagramPacket packet = new DatagramPacket(new byte[1024],1024);
49 socket.receive(packet);
50 byte data[] = packet.getData();
51 int datalen = packet.getLength();
52 String received = new String(data,0,datalen);
54 int first = received.indexOf(' ');
55 int last = received.lastIndexOf(' ');
56 String mode = received.substring(0,first-1);
57 String input = received.substring(first+1,last);
58 String output = received.substring(last+1);
60 System.out.println("request received! Parameters are");
61 System.out.println("Mode: \"" + mode + "\"");
62 System.out.println("Input file: \"" + input + "\"");
63 System.out.println("Output file: \"" + output + "\"\n");
66 send_to_uwobo("apply " + input + " " + output + " ciccontent cicpres");
68 send_to_uwobo("apply " + input + " " + output + " theorycontent theorypres");
70 InetAddress address = InetAddress.getLocalHost();
71 DatagramSocket socket2 = new DatagramSocket();
73 byte buf[] = new byte[0];
74 DatagramPacket packet2 = new DatagramPacket(buf,0,address,port2);
76 socket2.send(packet2);