Interface ProtocolListener

All Superinterfaces:

public interface ProtocolListener
extends java.util.EventListener

The listener interface for receiving requests for your own custom protocol implementations.

The class that is interested in processing a Protocol event implements this interface (and all the methods it contains).

The listener object created from that class is then registered with an IMozillaBrowserCanvas using the registerProtocol method.

The onOpen method is invoked when the browser needs to load a resource from a protocol that this is registered for. This method always invoked in a new Thread so multiple invokations of onOpen can happen simultaneously.

Example of use the "hello:" protocol

 IMozillaBrowserCanvas browser = BrowserFactory.spawnMozilla();
 browser.registerProtocol( "hello", new ProtocolListener() {
     public void onOpen( ProtocolEvent e ) {
         String url = e.getURL();
        //Start Requst with content type text/html
        //Send the data through, this can be called as many times as needed while data becomes available
        e.onDataAvailable(("<B>Hello</B> World: <EM>" +url.substring(url.indexOf(":")+1,url.length()) +"< * /EM>"). getBytes());
        //Tell the browser we are finished and everything went ok.

Loading the url "hello:John" will show :
Hello World: John

See Also:
IBrowserCanvas.registerProtocol(java.lang.String, com.webrenderer.event.ProtocolListener), ProtocolEvent

Method Summary
 void onOpen(ProtocolEvent e)
          Invoked when the browser needs to load a url of the registered protocol.

Method Detail


public void onOpen(ProtocolEvent e)
Invoked when the browser needs to load a url of the registered protocol.
This method is invoked in a new thread.