56 Adding Customizations to WebCenter Sites

WebCenter Sites 12c provides a modular and upgrade-safe way for you to add customizations using Weblogic Server’s shared library mechanism. WebCenter Sites’ runtime application refers this shared library, and therefore, customizations that you add to this shared library become available at runtime and in the WebCenter Sites’ class path.

There are several benefits of using the shared library. When you upgrade WebCenter Sites, your customizations will remain intact, as they are externally managed in a separate shared library. Further, errors caused by customizations during deployment will be easier for you to debug.

Working with the Shared Library

WebCenter Sites runtime (sites.war) refers a shared library called extend.sites.webapp-lib.war. Out-of-the-box, this shared library is a placeholder. You must add all WebCenter Sites customizations to extend.sites.webapp-lib.war. Here are some examples of artifacts that you would share in the shared library:

  • You are building an application that needs files such as <customapp>.js, an image (e.g. <custom>.png), and a CSS file (e.g. <custom>.css). You can add these files to <custom>.war.

  • You are building a custom tag library that will be used for creating templates. This library includes custom.tld and custom.jar.

Here’s how you create the shared library with your customizations:

  1. Assemble custom resources (.jar file) and package a shared library (.war file)

  2. Deploy the shared library to the managed server where WebCenter Sites is running

Assemble Custom Resources and Package Your Shared Library

  1. Assemble the resources (images, css, etc) in a base directory, with the relevant subdirectories. See Assembling Shared Java EE Library Files in Fusion Middleware Developing Applications for Oracle WebLogic Server for more information about building and deploying shared libraries to the WebLogic Server.

  2. Create a META-INF/MANIFEST.MF file describing the library:

    Manifest-Version: 1.0
    Specification-Title: Customizations
    Specification-Version: 1.0
    Implementation-Title: Custom Implementation
    Implementation-Version: 1.0
    Implementation-Vendor: Example.com
    Extension-Name: images
  3. Package the base directory as a WAR file. Here is what the packaging of the library looks like after you zip the library as a WAR file:

    $ jar -tf customizations.war
    META-INF/
    META-INF/MANIFEST.MF
    WEB-INF/weblogic.xml 
    mylogo.gif
    WEB-INF/lib/custom.jar
    WEB-INF/futuretense_cs/custom.tld
    customapp.js
    custom.png
Refer to the static resources from the library in the web application as if they are local to your application. If you plan to deploy two JARs together via a single shared library that your web application will reference, make sure that like the first library, the second .jar file is also placed in the /WEB-INF/lib folder.

Note:

The precedence of resource lookup is sites.war first and then the shared library. WebLogic Server serves the resource it finds first. That is:
  • Looks for the resource in the sites.war file.

  • If it doesn’t find the resource in the sites.war file, it looks for it in the shared library.

Deploy Your Shared Library to the Managed Server Where WebCenter Sites is Running

  1. Deploy the WAR as a library to the managed server where WebCenter Sites is running.

  2. You can also deploy two JARs together via a single shared library that your web application will reference.