ADF 11g and Webcenter; Using file based MDS repository for customization

One of the benefits for using the Webcenter technology is customization. This feature can be used to personalize the application for different end users.

Based on the standard application, smaller or larger changes (deltas) can be applied by the runtime system. The adjustments can be created both at design time (seeded customization) and specified at run-time (via the Change Persistence Framework).

We were struggling to get this to work in our application.  In the end we got it and I want to share how.

We only concentrated on the design time customization.

There are a few steps that need to be done to get it to work:

  1. Configure application and Weblogic server
  2. Configure JDeveloper
  3. Doing the design time customization
  4. Deployment of customizations

Configure application and Weblogic server:


  • Enable seeded customization for the web application project (project properties, ADF View, check the check box Enable seeded Customizations).
  • Define a class (or multiple classes) which at run time determines what the current customization context is, this class extends CustomizationClass. This class gives through the getValue () method a string that indicates the context for the customization layer, whose name is returned by GetName ().
  • The class InitializeMDSCustomizationSession is called from the beforePhase () (Restore view) in the phaselistener RequestObjectsInterceptor to prepare the MDS context that will be used in the GwmCC class to determine the current context, this class writes the property to layerValue into the MDSSession.
  • Configure in adf-config.xml the customization classes for application customization.

adf-config configuration:

<cust-config>
  <match>
    <customization-class name="oracle.adf.share.config.SiteCC"/>
    <customization-class name="nl.yenlo.customization.GwmCC"/>
  </match>
</cust-config>

GwmCC Class:

package nl.yenlo.customization;

import oracle.mds.core.MetadataObject;
import oracle.mds.core.RestrictedSession;
import oracle.mds.cust.CacheHint;
import oracle.mds.cust.CustomizationClass;

public final class GwmCC extends CustomizationClass {
    private static final String LAYER_PROPERTY = "layerValue";

    /**
     * {@inheritDoc}
     */
    @Override
    public CacheHint getCacheHint() {
        return CacheHint.REQUEST;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String getName() {
        return "layer";
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String[] getValue(final RestrictedSession restrictedSession, final MetadataObject metadataObject) {
        // potentially return multiple values
        // to have customizations applied for various layer values - in this order
        // note: when creating seeded customizations, only one value is active at any moment in time
        String gwm = (String)restrictedSession.getProperty(LAYER_PROPERTY);
        if (gwm == null) {
            gwm = "gwm1";
        }
        return new String[] {gwm};
    }
}

RequestObjectsInterceptor class:

import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;
import nl.yenlo.customization.InitializeMDSCustomizationSession;

public final class RequestObjectsInterceptor implements PhaseListener {

    /**
     * Which phase(s) the listener will execute.
     * @return PhaseId.RESTORE_VIEW
     */
    @Override
    public PhaseId getPhaseId() {
        return PhaseId.RESTORE_VIEW;
    }

    @Override
    public void beforePhase(final PhaseEvent phaseEvent) {
        InitializeMDSCustomizationSession.initializeMDSSession();
    }

    /**
     * Nothing.
     * @param phaseEvent phase event
     */
    @Override
    public void afterPhase(final PhaseEvent phaseEvent) {
        // Nothing
    }
}

InitializeMDSCustomizationSessionclass:

package nl.yenlo.customization;

import nl.yenlo.view.app.bean.RequestContext;
import nl.yenlo.util.JSFUtil;

import oracle.adf.share.ADFContext;

import oracle.mds.core.MDSSession;

/**
 * Helper class.
 */
public final class InitializeMDSCustomizationSession {
    private InitializeMDSCustomizationSession() {
        // not initialized
    }

    private static final String LAYER_PROPERTY = "layerValue";

    /**
     * Initialize MDS session.
     */
    public static void initializeMDSSession() {
        final ADFContext adfContext = ADFContext.getCurrent();
        if (adfContext != null) {
            final MDSSession mdsSess = (MDSSession)adfContext.getMDSSessionAsObject();

            if (mdsSess != null) {
                final RequestContext requestContext = (RequestContext)JSFUtil.getManagedBeanValue("requestContext");
                final String gwm = mwpRequestContext.getLayer();
                mdsSess.setProperty(LAYER_PROPERTY, gwm);
            }
        }
    }
}
  • Configure in the adf-config.xml file the MDS Repository which will be used as a target by deployment of the application.
<mdsC:adf-mds-config version="11.1.1.000">
  <mds-config xmlns="http://xmlns.oracle.com/mds/config">
    <persistence-config>
      <metadata-namespaces>
        <namespace path="/persdef/" metadata-store-usage="MDS_MWPCustomizations"/>
      </metadata-namespaces>
      <metadata-store-usages>
        <metadata-store-usage id="MDS_MWPCustomizations" default-cust-store="true" deploy-target="true">
          <metadata-store class-name="oracle.mds.persistence.stores.file.FileMetadataStore">
            <property name="metadata-path" value="/APP/MDS"/>
            <property name="partition-name" value="mwpcustomizations"/>
          </metadata-store>
        </metadata-store-usage>
      </metadata-store-usages>
    </persistence-config>
    <cust-config>
      <match>
        <customization-class name="oracle.adf.share.config.SiteCC"/>
        <customization-class name="nl.yenlo.customization.GwmCC"/>
      </match>
    </cust-config>
  </mds-config>
</mdsC:adf-mds-config>

Make sure the path exist on the Weblogic machine; in this case /APP/MDS. You don’t need to create a directory with the partition this will be created automagically by deployment.

To create the MDS in the Enterprise Manager, go to Metadata Repositories; option register / deregister, click on Register button, define new Query name eg MDSSYS; directory / APP / MDS (which must be exactly correct).

Configure JDeveloper:


The configuration file is CustomizationLayerValues.xml and is located in the jdeveloperjdev directory.
This file contains entries for all the customization layers and each layer customization all supported values. For example:

<cust-layer name="layer" id-prefix="G">
      <!-- Generated id-prefix would be "s1" and "s2" for values
	"site1" and "site2".-->
      <cust-layer-value value="gwm1" display-name="Layer 1" id-prefix="lay1" />
      <cust-layer-value value="gwm2" display-name="Layer 2" id-prefix="lay2" />
      <cust-layer-value value="gwm3" display-name="Layer 3"  id-prefix="lay3" />
   </cust-layer>
  • The customization classes have to be added as an extension in JDeveloper and should be placed in JDeveloperjdevlibpatches (packed in a jar) to make them available as JDeveloper starts the customization role.

Doing the design time customization:


  • Go to the Tools menu in JDeveloper, select the Preferences option, select the Roles node, select radio button Customization Developer, click OK, JDeveloper now reports that a restart is required and asks you to accept. Click OK to restart JDeveloper
  • JDeveloper starts in Customization mode, in the lower right corner you can see the Customization Context box, here you can select the context for which layer you want to do the customization. Note!: In customization mode, you can’t edit all the resources. Only XML-based resources are eligible for customization. So for example, not Java classes or CSS files. The main files you can work on in this fashion are JSPX and JSFF. Some XML files are single (application wide) read (faces-config.xml, ADF page definition, etc) These are not eligible for customization – even if multiple versions exist: there can be only one active at runtime for the entire application.
  • Open the resource you want to customize.make a change by drag & drop in the window structure or the property palette. Note: in customization mode, the JSPX and JSFF sources are not directly editable in the source editor.
  • Save your changes. The document customization public_htmlclientsmdssyscustlayer..layerId..file.jspx.xml is now written.

as an example the contents of the document:

<mds:customization version="11.1.1.55.36"
                   xmlns:mds="http://xmlns.oracle.com/mds">
  <mds:move node="sdf2p" parent="kolom2" position="last"/>
  <mds:move node="sdf1p" parent="kolom3" position="last"/>
</mds:customization>

Note: Make sure that the rules in the customization document are correct, pay attention to additional rules about invisible elements editing.

Deployment of customizations:

Customizations are recorded in files (XML files with the deltas that describe the customization for a particular page for a particular value in a customization layer). These files will be put on the file system during development.

These are the steps to make sure your customizations are deployed:

  • Create a MAR file with the customizations (MAR Deployment Profile at the level of the Application (and not the web application project)
  • Deploy a MAR file  eg in directory appearadfApplicationadf META-INFmetadata.mar
  • Make sure the MAR file is included in the EAR file in the root folder:

We’re using Maven to make our ear, we’ve added the following into the pom:

<copy file="adfApplication/adf/META-INF/metadata.mar" todir="${project.build.directory}/earSource" />
  • Make sure the adf-config.xml file is included in the ear, we’ve copied the local Jdeveloper file to a folder from which we copy it in the ear with maven:
<copy file="adfApplication/adf/META-INF/adf-config.xml"  todir="${project.build.directory}/earSource/adf/META-INF"  />
  • Make sure the MDS which is configured in the adf-config file exists on the Weblogic server.

During the deployment metadata from the MAR is copied / imported into the target repository and Partition identified in the adf-config.xml for the application.

Comments are closed.

Algemeen (8)
GlassFish (43)
Java (56)
Managed Services (9)
Oracle (88)
Private Cloud Hosting (2)
SOA/BPEL/ESB (6)
Software development (40)
Strategie (6)
WSO2 (2)

WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.

  • 071 - 82 000 82
  • Rijndijk 137 | 2394 AG Hazerswoude-Rijndijk
Oracle SOA specialized partner
Java
GlassFish
WSO2
DEMO
i-bridge
Rabobank
Greencat
Jan de Rijk
Reuma Revalidatie Rotterdam
Robeco
VU Medisch Centrum
CHS
LUMC
TomTom
TKP
NCCW
Erasmus MC
UMCG
VIR
ANWB
BVA Auctions
D-Reizen
STEDIN