com.ibm.wbi.protocol.http.beans.link
Interface LinkRewriter


public interface LinkRewriter

Interface for rewriting links. Distinguishes between inline source references, which tend to contain data and do not need to be redirected through the WBI server (and indeed probably should not for performance reasons), and clickable links, which should be rewritten to "keep the user on the WBI server". This interface is part of the KeepOnServerEditor package. In order to work reentrantly (threadsafely), KeepOnServerEditor will construct a new instance of your linkrewriter to handle each request (it's a stateful object -- think about get/setBase()). Thus the class of your LinkRewriter implementation is passed as an argument to the KeepOnServerEditor, as well as some initialization data in the form of an Object. If you have data that varies with the transaction, consider sticking it in the transaction data (@see RequestInfo)

See Also:
KeepOnServerEditor

Method Summary
 java.lang.String getBase(ResponseToRequest rtr)
          The tag is interpretted by the browser to prepend a BASE url relative links on the page.
 void initialize(java.lang.Object init)
          Initialize a LinkRewriter instance
 java.lang.String rewriteLink(ResponseToRequest rtr, java.lang.String l)
          Rewrite followable links.
 java.lang.String rewriteSource(ResponseToRequest rtr, java.lang.String l)
          Rewrite source urls.
 void setBase(java.lang.String base)
          The tag was explicitely set in the document.
 

Method Detail

initialize

public void initialize(java.lang.Object init)
Initialize a LinkRewriter instance
Parameters:
init - Initialization data (e.g., String, Hashtable, custom class, etc)

rewriteLink

public java.lang.String rewriteLink(ResponseToRequest rtr,
                                    java.lang.String l)
Rewrite followable links. Includes "A HREF", "META content", "FORM action", etc. Typically these will be rewritten to go through the WBI server.
Parameters:
rtr - the ResponseToRequest (RequentEvent or ServiceResult) might be useful to get additional information about the transaction
l - the link to be rewritten, e.g., http://www.almaden.ibm.com or /foo/bar.html
Returns:
the modified link, e.g., http://wbi1.almaden.ibm.com/dictionary/dict?url=http://www.almaden.ibm.com

rewriteSource

public java.lang.String rewriteSource(ResponseToRequest rtr,
                                      java.lang.String l)
Rewrite source urls. Includes "IMG src" and "TABLE background", etc. Frequently these will be rewritten to NOT go through the WBI server.
Parameters:
rtr - the ResponseToRequest (ServiceResult or RequestEvent) might be usefl to get additional information about the transaction
l - the link to be rewritten
Returns:
the modified link

getBase

public java.lang.String getBase(ResponseToRequest rtr)
The tag is interpretted by the browser to prepend a BASE url relative links on the page.
Returns:
the base url, e.g., http://wbi1.almaden.ibm.com/whatever/

setBase

public void setBase(java.lang.String base)
The tag was explicitely set in the document. This callback is used to convey this.
Parameters:
base - The explicit base