com.thinlink.xp

An Extensible Protocol Implementation in Java

Extensible Protocol (XP) is a bidirectional protocol on which XML documents are exchanged between two endpoints.

The com.thinlink.xp package implements XP draft 00 using stream sockets and the Apache Crimson processor.  You use an event-listener interface and the Document Object Model to build, send and receive XML documents.

Author: Tom Harding
tomh@thinlink.com


Download

Download com.thinlink.xp Version 0.2.0 [416K]
Browse Documentation
com.thinlink.xp is distributed under the GNU General Public License.
Modifications to the crimson parser are distributed in accordance with the Apache Software License agreement.


What is XP good for?

XP will work best for applications that use relatively long-lasting, contextual conversations.

XP is extremely simple and lets you build outward from the wire, rather than inward from a complex software interface. XP's only dictate is that everything that crosses the wire is XML.  There is no distinction of the representation of control information from that of data.  If you need to define an authentication procedure, use XML documents.  If you want to add error reporting, use XML documents.  If you want to use your existing document types as valid messages in your protocol, go right ahead.

XP might be used for generic frameworks, homegrown special-purpose protocols, or anything in between -- about the same range as XML itself.  


Why is com.thinlink.xp based on the Crimson processor?

XP requires some subtle behavior from the underlying processor; namely, the ability to identify and parse multiple documents from the input stream. Apache Crimson was relatively easy to adapt to this task because it relies mostly on built-in Java I/O.  I would love to see other processors tested and/or modified to support XP.
 

How do I use com.thinlink.xp?

Running the Sample
To run the sample, you might type:

cd xp_0_2_0
javaw -classpath .;xp.jar;crimson.jar HelloEndpoint.HelloEndpoint

General instructions
You will need to import these packages:
import java.net.*;
import org.w3c.dom.*;
import com.thinlink.xp.*;
Create an Endpoint.  For example:
Endpoint endpoint = new Endpoint();
endpoint.setSocket(new Socket("xp.acme.com", 1222));
The other side needs to be waiting to accept a connection, and also must be prepared to speak XP.  Start the Endpoint's XP processing like this:
endpoint.start();
To send a request (i.e. act like a client), you could do this...
endpoint.sendRequest(myDocument, null);

(To process responses, you would need to pass a DocumentListener.  See docs.)

To register DocumentListeners to process unsolicited requests (i.e. act like a server), call
endpoint.addDocumentListener