package webraveler.plugin; import java.util.*; import webraveler.html.HTMLPage2; import webraveler.http.HTTPRequest; import webraveler.http.HTTPResponse; import webraveler.ravel.PluginAPI; import webraveler.vurl.PluginChangePref; import webraveler.vurl.PluginConfig; /** * * A quick demo of linking to the instructor's home. * **/ public class LinkToSamPlugin extends webraveler.ravel.RavelerPlugin { /* variables */ /*constructors*/ public LinkToSamPlugin () { name = "LinkToSamPlugin"; mimeTypes.add("text/html"); } /*methods*/ public void setDefaultAttributes () { attributes = new Hashtable(); attributes.put("InsertHtml","

Return to the course home.

"); } public boolean initialize () { String fullURL; Vector attributes = new Vector(); attributes.add("InsertHtml"); PluginChangePref changePref = new webraveler.vurl.PluginChangePref("LinkToSamPlugin"); fullURL = PluginAPI.addPermanentVirtualURL(ravel,name,"changePref",changePref); PluginConfig config = new PluginConfig("LinkToSamPlugin",attributes,fullURL); fullURL = PluginAPI.addConfigVirtualURL(ravel,name,config); return true; }//initialize() public HTTPRequest execute (HTTPRequest request, Hashtable attributes) { return request; }//execute() public HTTPResponse execute (HTTPResponse response, Hashtable attributes){ System.out.println("Executing LinkToSamPlugin: "); String InsertHtml = (String) attributes.get("InsertHtml"); System.out.println("LinkToSamPlugin: InsertHtml = '"+InsertHtml+"'"); response.getHtmlPage().insertAtTop(InsertHtml); /* Change the entityBytes of the passed HTTPResponse to the HTML page w/inserted text * at the top */ response.correctContentLength(); System.out.println("LinkToSamPlugin: DONE"); return response; } //execute(HTTPResponse) public void terminate() { } // terminate() }// LinkToSamPlugin