[This local archive copy is from the official and canonical URL, http://newton.thinlink.com/xp/; please refer to the canonical source document if possible.]
The com.thinlink.xp package implements XP draft 00 using stream sockets and the IBM xml4j processor. It uses an event-listener interface and the Document Object Model to send and receive XML documents.
Author: Tom Harding
tomh@thinlink.com
Download com.thinlink.xp Version 0.1.0 plus xml4j mods [219K]
Browse Documentation
XP is extremely simple and lets you build outward from the wire, rather than inward from a complex software interface. It provides only a transport for moving documents from one end to the other, and the response tagging necessary to allow interleaved responses and multiple responses to a single request.
With XP, literally 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.
To run the sample, you might type:cd xp_0_1_0
java -classpath .;xp.jar;xp_xml4j.jar;/xml4j_2_0_3/xml4j.jar HelloEndpoint
You will need to import these packages:
import java.net.*;Create an Endpoint. For example:
import org.w3c.dom.*;
import com.thinlink.xp.*;import com.ibm.xml.parser.*; // TXDocument needed for now. See docs.
endpoint Endpoint = new Endpoint();Of course, 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.setSocket(new Socket("xp.acme.com", 1222));endpoint.start();To send a request (i.e. act like a client), you could do this...endpoint.sendRequest(myDocument, null);To register DocumentListeners to process unsolicited requests (i.e. act like a server), call endpoint.addDocumentListener.(To process responses, you would need to pass a DocumentListener. See docs.)