« public interface StorageService | Main | Classpath - fixme »

A REST-centric messaging API

Just throwing this out to see what people think. It's a hybrid of HTTP, SOAP, JAS, JavaSpaces and JMS after throwing away 95% of them - whether I kept the right 5% is the question! The API elements reflect a strong REST bias. I wanted to show what REST might look like in API form, much of the diiscussion surrounding REST is quite abstract.

The notion is that there are things called authorities, which communicate by sending and receiving messages. Messages are made of an action, headers and an entity (payload). Authorities have resources under their control and messages are used to manipulate and understand resources by making requests through an authority. Authorities are also resources.

At some point I need to think about reflecting asynchronicity in the interfaces, right now the calls look synchronous- that's REST's client-server origins leaking through. Communications are constrained using protocols (a protocol is a collection of names for headers and actions, the names are expected to imply a semantics).

public interface Resource {
  java.net.URL identity();
  Authority authority();
}
public interface Authority extends Resource {
  Message create(java.net.URL url);
  Message delete(Message req);
  Message change(Message req);
  Message snapshot(Message req);
  Message metadata(Message req);
  java.util.List protocols();
}
public interface Message {
  Protocol protocol();
  Action action();
  Entity entity();
  java.util.Map headers();
  Resource about();
  Resource from();
}
public interface Action {
  String name();
  Protocol protocol();
}
public interface Entity {
  Boolean accept(EntityVisitor v);
}
public interface EntityVisitor {
  Boolean apply(Entity e);
}
public interface Protocol extends Resource {
  java.util.List headers();
  java.util.List actions();
}

February 1, 2003 10:34 PM

Comments

Trackback Pings

TrackBack URL for this entry:
http://www.dehora.net/mt/mt-tb.cgi/906