Sun Java System Portal Server 7 Developer's Guide

Introduction to Leaf Providers

Introduction to Leaf Providers shows the relationship between the PAPI base class and the leaf providers discussed in this chapter. The JSPProvider and URLScraperProvider extend the ProfileProviderAdapter to include support for retrieving content from JavaServer Pages and URLs respectively. The XMLProvider extends the URLScraperProvider’s functionality to scrape XML content from the named source and translate it into the markup language supported by the requesting client. The XMLProvider uses the URLScraperProvider’s built-in functionality to fetch the XML contents from HTTP, HTTPs, and file URLs.

Figure 4–1 The Building Block Providers

This image shows the building block leaf providers.

The JSPProvider

A JSPProvider is a content provider that can use JavaServer Pages to create the content for a channel on the Desktop.

The following is a description of the step-by-step process of the JSPProvider invoking a JSP.

  1. The JSPProvider.getContent() method is called and the JSPProvider looks up the JSP to be executed. It calls a common private method to service the JSP.

  2. The provider then creates request and response objects, copies information (such as cookies) from the Desktop request to those objects, initializes the session information, and checks to see if a servlet wrapper for the JSP already exists. If not, a servlet wrapper is created. The service method is then called on the wrapper.

  3. The servlet wrapper service method loads the JSP. Before loading, it checks to see if the JSP class file is out of date with the class file. If the JSP class file is out of date with the class file, it invokes the compiler to compile the JSP into a class file and read the class file into memory and uses the class loader to define the new class.

  4. Finally, the JSP servlet is instantiated and the init() method is called on the JSP.

  5. Once the JSP is loaded, the JSP’s service method is called by the servlet wrapper service method.

  6. After the JSP’s service method completes, the JSPProvider getContent() method extracts the response body from the processed JSP file and returns it as a StringBuffer.