/**
 * A simple example that uses a HTTPMessageBus to expose a service that
 * calculates whether or not a given number is a prime. Workload is spead
 * over three parallel calculators.
 * <p/>
 * Compile with:
 *     javac -Xbootclasspath/p:../lib/jsr166.jar -classpath ../juglr-0.0.1.jar HTTPServerExample.java
 *
 * Run with:
 *     java -Xbootclasspath/p:../lib/jsr166.jar -classpath ../juglr-0.0.1.jar:. HTTPServerExample
 * <p/>
 * JSON messages should be <code>POST</code>ed to
 * <a href="http://localhost:4567/actor/calc">http://localhost:4567/calc</a>
 * looking like:
 * <pre>
 * {
 *    "isPrime" : 123
 * }
 * </pre>
 *
 * To invoke the 'list' or 'ping' handlers you can point your browser at
 * <a href="http://localhost:4567/list">http://localhost:4567/list</a> or
 * <a href="http://localhost:4567/ping/calc">http://localhost:4567/ping/calc</a>.
 * Or simply use a command line tool like <code>wget</code> or <code>curl</code>
 * to send <code>GET</code> requests to those URLs.
 * <p/>
 * To POST an isPrime request using <code>curl</code> use the following command
 * in a Unix terminal:
 * <pre>
 *     curl http://localhost:4567/actor/calc --data '{ "isPrime" : 982451653 }'
 * </pre>
 */

import juglr.*;
import static juglr.net.HTTP.*;
import static juglr.StructuredMessage.Type;

import java.io.IOException;
import java.math.BigInteger;
import java.nio.channels.SocketChannel;

public class HTTPServerExample {

    static class CalcActor extends Actor {

        public void react(Message msg) {
            if (!(msg instanceof StructuredMessage)) {
                throw new MessageFormatException("Expected StructuredMessage");
            }

            StructuredMessage resp = new StructuredMessage(Type.MAP);
            StructuredMessage json = (StructuredMessage)msg;
            if (!json.has("isPrime")) {
                resp.put("error", "No 'isPrime' key in request");
                send(resp, msg.getSender());
                return;
            }

            String test = json.get("isPrime").toString();
            try {
                BigInteger bigInt = new BigInteger(test);

                // We guess right with 0.9990234375 probability
                if (bigInt.isProbablePrime(10)) {
                    resp.put("response", "true");
                } else {
                    resp.put("response", "false");
                }
                send(resp, msg.getSender());
            } catch (NumberFormatException e) {
                resp.put("error", "Not a valid integer");
                send(resp, msg.getSender());
            }
        }
    }

    public static void main (String[] args) throws Exception {
        // Make sure the default message bus is HTTPMessageBus
        System.setProperty("juglr.busclass", "juglr.net.HTTPMessageBus");

        // Delegate work to three CalcActors in a round-robin manner
        Actor actor = new SwarmActor(
                new CalcActor(), new CalcActor(), new CalcActor());
        MessageBus.getDefault().allocateNamedAddress(actor, "calc");
        MessageBus.getDefault().start(actor.getAddress());

        // Indefinite non-busy block
        synchronized (actor) {
            actor.wait();
        }
    }

}

@@ -1271,33 +1271,19 @@
 c juglr.
-StructuredMessage
+Box
 .Type;%0A%0A
@@ -1532,33 +1532,19 @@
 tanceof 
-StructuredMessage
+Box
 )) %7B%0A   
@@ -1599,33 +1599,19 @@
 xpected 
-StructuredMessage
+Box
 %22);%0A    
@@ -1637,121 +1637,65 @@
     
-StructuredMessage resp = new StructuredMessage(Type.MAP);%0A            StructuredMessage json = (StructuredMessage
+Box resp = new Box(Type.MAP);%0A            Box json = (Box
 )msg

Refactor HTTPServerExample to use Box instead of StructuredMessage