]> matita.cs.unibo.it Git - helm.git/commitdiff
xaland-uwobo created
authorClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Wed, 20 Dec 2000 14:55:26 +0000 (14:55 +0000)
committerClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Wed, 20 Dec 2000 14:55:26 +0000 (14:55 +0000)
helm/xsltd/xaland-uwobo/.cvsignore [new file with mode: 0644]
helm/xsltd/xaland-uwobo/xaland_uwobo.java [new file with mode: 0644]

diff --git a/helm/xsltd/xaland-uwobo/.cvsignore b/helm/xsltd/xaland-uwobo/.cvsignore
new file mode 100644 (file)
index 0000000..6b468b6
--- /dev/null
@@ -0,0 +1 @@
+*.class
diff --git a/helm/xsltd/xaland-uwobo/xaland_uwobo.java b/helm/xsltd/xaland-uwobo/xaland_uwobo.java
new file mode 100644 (file)
index 0000000..d0ed630
--- /dev/null
@@ -0,0 +1,79 @@
+import org.apache.xalan.xslt.*;
+import java.net.*;
+import java.io.*;
+
+public class xaland_uwobo {
+   static DatagramSocket uwobo_socket;
+   static int portuwobo;
+
+   public static void send_to_uwobo(String cmd)
+   throws java.io.IOException
+   {
+      /*CSC: UDP based, but not fault-tolerant */
+      byte[] cmdBytes = cmd.getBytes();
+      DatagramPacket packet =
+       new DatagramPacket(cmdBytes, cmdBytes.length,
+        InetAddress.getLocalHost(), portuwobo);
+      uwobo_socket.send(packet);
+      DatagramPacket rcv = new DatagramPacket(new byte[0], 0);
+      uwobo_socket.receive(rcv);
+   }
+
+   public static void main(String argv[]) throws  java.io.IOException, java.net.MalformedURLException, org.xml.sax.SAXException
+   {
+      int port  = Integer.parseInt(argv[0]);
+      int port2 = Integer.parseInt(argv[1]);
+      portuwobo = Integer.parseInt(argv[2]);
+      String xsl1 = argv[3];
+      String xsl2 = argv[4];
+      String theory_xsl1 = argv[5];
+      String theory_xsl2 = argv[6];
+
+      DatagramSocket socket = new DatagramSocket(port);
+      uwobo_socket = new DatagramSocket();
+
+      /* Initialize uwobo */
+      send_to_uwobo("add " + xsl1 + " ciccontent");
+      send_to_uwobo("add " + xsl2 + " cicpres");
+      send_to_uwobo("add " + theory_xsl1 + " theorycontent");
+      send_to_uwobo("add " + theory_xsl2 + " theorypres");
+
+
+      System.out.println("Demon activated on input port " + port +
+       " and output port " + port2);
+      while(true) {
+         System.out.print("Ready...");
+
+         /* Warning: the packet must be a fresh one! */
+         DatagramPacket packet = new DatagramPacket(new byte[1024],1024);
+         socket.receive(packet);
+         byte data[] = packet.getData();
+         int datalen = packet.getLength();
+         String received = new String(data,0,datalen);
+
+         int first = received.indexOf(' ');
+         int last  = received.lastIndexOf(' ');
+         String mode = received.substring(0,first);
+         String input = received.substring(first+1,last);
+         String output = received.substring(last+1);
+
+         System.out.println("request received! Parameters are");
+         System.out.println("Mode: " + mode + " ");
+         System.out.println("Input file: \"" + input + "\"");
+         System.out.println("Output file: \"" + output  + "\"\n");
+
+         if (mode == "cic")
+            send_to_uwobo("apply ciccontent cicpres " + input + " " + output);
+         else
+            send_to_uwobo("apply theorycontent theorypres " + input + " " + output);
+
+         InetAddress address = InetAddress.getLocalHost();
+         DatagramSocket socket2 = new DatagramSocket();
+
+         byte buf[] = new byte[0];
+         DatagramPacket packet2 = new DatagramPacket(buf,0,address,port2);
+
+         socket2.send(packet2);
+      }
+   }
+}