Activating Caching You built a portlet using the wizard and successfully added it to a page.

7-66 Oracle Fusion Middleware Developers Guide for Oracle Portal invalidation requests directly to Oracle Web Cache. PDK-Java uses the Java API for Web Cache JAWC to generate invalidation requests. This section describes how to configure Oracle Web Cache and use the invalidation-based caching sample that comes with PDK-Java. Not all requests sent to Oracle Web Cache are cached. In order for the content to be cached, the content must include directives that tell Oracle Web Cache to cache the content. Usually Oracle Web Cache uses the URL associated with the request as the cache key, but you can specify additional keys by setting special HTTP headers, known as surrogate control headers, on the response. To configure a Java portlet to use invalidation-based caching, you do the following: ■ Configuring Oracle Web Cache. Refer to Oracle Fusion Middleware Administrators Guide for Oracle Web Cache for more information. ■ Section 7.2.9.4.1, Configuring the Provider Servlet ■ Section 7.2.9.4.2, Defining the Oracle Web Cache Invalidation Port ■ Section 7.2.9.4.3, Configuring the XML Provider Definition ■ Section 7.2.9.4.4, Manually Invalidating the Cache

7.2.9.4.1 Configuring the Provider Servlet To enable invalidation-based caching, you must

switch it on at the provider servlet level. The flag is set in an initialization parameter inside the PDK-Java Web application deployment descriptor, web.xml. For example: servlet ... servlet-classoracle.webdb.provider.v2.adapter.SOAPServletservlet-class init-param param-nameinvalidation_cachingparam-name param-valuetrueparam-value init-param servlet If the flag is not defined here, then invalidation-based caching is switched off. The status of this flag can be checked by displaying the providers test page. If the testPageURI property is not set in the sample.properties file, then the provider code displays the test page in the old default style. The old style test page correctly picks up the invalidation caching flag from the web.xml file. The format of the test page URL is as follows: http:provider_hostname:portjpdkproviderssample

7.2.9.4.2 Defining the Oracle Web Cache Invalidation Port If you are using an Oracle

Application Server installation type where PDK-Java was automatically pre-installed for example, an Oracle Portal and Wireless type installation, you should find that Oracle Web Cache invalidation settings have already been preconfigured in MID_ TIER_ORACLE_HOMEportalconfcache.xml. In this case, you can safely ignore the instructions in this section and proceed to Section 7.2.9.4.3, Configuring the XML Provider Definition . Otherwise, you will need to configure the invalidation portlet for Oracle Web Cache. First, you need the user name and password for the invalidation ports of the Oracle Web Cache instances associated with your application server. After you obtain those, use the provided oracle.webdb.provider.v2.cache.Obfuscate Java utility to convert the user name and password into an obfuscated string of the format required by the JAWC API. In a default Oracle Application Server installation, the user name for the invalidation port is usually invalidator and the password is usually the Enhancing Java Portlets 7-67 same as the application server administrators password. For example, suppose you installed Oracle Application Server in D:\as904, with an invalidation port user name of invalidator and a password of welcome. You would run the following command: D:\as904\jdk\bin\java -classpath D:\as904\j2ee\home\shared-lib\oracle.jpdk\1.0\pdkjava.jar oracle.webdb.provider.v2.cache.Obfuscate invalidator:welcome If successful, the command should print a hexadecimal string like the following: 0510198d5df8efd5779406342be2528aa0cccb179ea6b77baf49f019f5075a3a11 Now, use this information to create a JAWC configuration file, cache.xml, which specifies one or more Oracle Web Cache instances and their invalidation ports. For example: ?xml version=1.0? webcache invalidation host=cache.mycompany.com port=4001 authorization=0510198d5df8efd5779406342be2528aa0cccb179ea6b77baf49f019f5075a3a11 webcache JAWC finds this configuration file using the system property file. To set this system property for a Oracle WebLogic Server, simply add an appropriate line to the .product.properties file for the particular instance in which PDK-Java is installed for example, MW_HOMEwlserver_10.3.product.properties and then restart that instance.

7.2.9.4.3 Configuring the XML Provider Definition Using a combination of tags in

provider.xml, you can activate automatic invalidation-based caching for an entire portlet or some of its pages. To turn on automatic invalidation-based caching, you need to declare it as follows either at the level of individual pages or the renderer, to indicate that invalidation-based caching should be activated for all pages: useInvalidationCachingtrueuseInvalidationCaching If your portlet supports personalization through the Edit or Edit Defaults modes, you may also want to declare autoInvalidatetrueautoInvalidate for your renderer. This declaration causes invalidation of all the cached content for the portlet Note: The command that follows assumes that pdkjava.jar and jawc.jar are present in ORACLE_ HOME j2eehomeshared-liboracle.jpdk1.0, as required by the PDK-Java installation guide. If you are using a standalone Oracle Containers for Java EE installation, you need to substitute in the path to the java executable an external Java 2 SDK installation. Note: Since the location of the cache configuration file is defined as a system property, only one cache may be defined for each server instance. It is not possible to have two different Web Provider instances behind separate Oracle Web Cache configurations.