Sun Java logo     Previous      Contents      Index      Next     

Sun logo
Sun Java System Portal Server 6 2004Q2 Developer's Guide 

Chapter 4
Overview of the Leaf Providers

A portal provider is a generic connector to the resource in a channel and is the programmatic entity responsible for generating channels on the Desktop. A single provider can be used to create multiple channel instances. The leaf providers are tools for building channels for the portal.

This chapter contains the following:


Figure 4-1 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.


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.


The URLScraperProvider can retrieve and display content from a given URL.

The following is a step-by-step description of how the URLScraperProvider retrieves and displays content from the specified URL:

  1. Gets the timeout property for the provider.
  2. Gets the url property for the provider.
  3. This is the URL source for the content to be fetched. The url property is fetched from the conditional property of display profile based on the user’s clientType and locale, if defined. Otherwise the default value is returned.

  4. Gets the urlScraperRulesetID to be used by Rewriter as a string.
  5. Determines if the cookieName can be forwarded.
  6. To determine, it checks the value of cookiesToForwardAll attribute value in the display profile. If this value is false, it checks the cookiesToForwardList attribute value in the display profile.

  7. Determines if cookies from the request should be forwarded.
  8. Gets the content by:
    • Retrieving content from the specified URL.

      That is, it sends an HTTP(s) request that contains information related to this request for content and gets an HTTP(s) response that allows the provider to influence the overall response for the Desktop page (besides generating the content).


The XMLProvider can be used to convert and display an XML file according to the specified style sheet.

The XMLProvider first determines if content is available for the requesting client. This is determined by checking on the availability of the XSL stylesheet for the requesting client via the File Lookup API.

The path to the XML content can be specified as HTTP, HTTPs, or file URL. The path to the XML source is stored as a value of the property url. If the path is HTTP or HTTPs, the provider uses the super.getContent() method to fetch the XML content. If the path is a file URL, the provider reads the file into a StringBuffer.

The value for XSL file name to use for transformation is stored as value of the string property xslFileName. The value for the attribute can be either the absolute path (such as /export/home/xsl/abc.xsl) or just the file name. If just the file name has been specified, the provider will use the File Lookup API to locate the XSL file. If the absolute path is specified, it takes precedence and file lookup will not be performed to locate the XSL file.

If both the XML and the XSL files are present, the XMLProvider does the transformation using the XSLT engine. The generated contents are displayed in the channel. In order to transform the XML file, the provider uses JAXP (from JWSDP 1.3).

The XMLProvider:

  1. Takes the fully qualified path name of the XML file and returns the file, specified by the argument, as a StringBuffer.
  2. It returns null if the file does not exists or cannot be read.

  3. Gets the XSL file. If just an XSL filename has been specified, the getXSL() method locates the XSL file using the File Lookup API.
  4. Takes the XML and XSL files and does the transformation.
  5. Gets the XML contents after converting the XML file according to the specified XSL stylesheet. In order to do this, it takes the HttpServletRequest and returns an HttpServletResponse with the XML file contents as a buffer.
  6. Gets and displays the XML file contents in the channel using the getContent() method.

Previous      Contents      Index      Next     

Copyright 2004 Sun Microsystems, Inc. All rights reserved.