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 StupidPlugin extends webraveler.ravel.RavelerPlugin { /* variables */ /*constructors*/ public StupidPlugin () { name = "StupidPlugin"; 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("StupidPlugin"); fullURL = PluginAPI.addPermanentVirtualURL(ravel,name,"changePref",changePref); PluginConfig config = new PluginConfig("StupidPlugin",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 StupidPlugin: "); String InsertHtml = (String) attributes.get("InsertHtml"); System.out.println("StupidPlugin: 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("StupidPlugin: DONE"); return response; } //execute(HTTPResponse) public void terminate() { } // terminate() }// StupidPlugin