PublicationShim init

Initializes the publisher of the DirXML driver.

Syntax

Java

  public XmlDocument init (
     XmlDocument   initParameters)
  

C++

  #include "NativeInterface.h"
  
  XmlDocument * METHOD_CALL init (
     XmlDocument   *initParameters);
  

Parameters

initParameters
(IN) Points to an XML document that contains the configuration information for the publisher.

Return Values

Returns an XML document containing a status report on the initialization operation. The status can be "success", "warning", "error", or "fatal". If "fatal" is returned, the driver start is aborted.

Remarks

The DirXML engine calls the init method to allow the publisher object to perform any channel-specific initialization necessary before monitoring the application and publishing changes to DirXML.

The initParameters argument contains an XML document with initialization data such as authentication information, driver-specific publisher parameters, and the publisher channel filter.

When the DirXML engine calls the PublicationShim init method, it sends an XML document similar to the following.

  <nds dtdversion="1.0" ndsversion="8.5">
     <source>
        <product version="1.0">DirXML</product>
        <contact>Novell, Inc.</contact>
     </source>
     <input>
        <init-params src-dn="\PERIN-TAO\novell\Driver Set\Java Skeleton
                 Driver\Publisher">
           <authentication-info>
              <server>server.app:400</server>
              <user>User1</user>
              <password><!-- content suppressed --></password>
           </authentication-info>
           <driver-filter>
              <allow-class class-name="User">
                 <allow-attr attr-name="Given Name"/>
                 <allow-attr attr-name="Surname"/>
              </allow-class>
           </driver-filter>
           <publisher-options>
        <pub-1 display-name="Sample Publisher option">String for
                     Publisherr</pub-1>
              <polling-interval display-name="Polling interval in
                       seconds">4</polling-interval>
     </publisher-options>
        </init-params>
     </input>
  </nds>
  

Most of the information in the initialization document corresponds to information configured using ConsoleOne in the DirXML-Driver object properties dialog.

The src-dn attribute on the <init-params> element is the distinguished name of the DirXML-Publisher object that corresponds to the driver’s publisher object. The DirXML-Publisher object is the eDirectory object that contains the publisher channel filter and references to the publisher channel rules.

The content of the <authentication-info> element corresponds to the driver authentication parameters found in the DirXML-Driver properties dialog. The content of the <password> element is suppressed because the trace facility suppresses sensitive data (as defined by DirXML). The actual password value is available to the driver.

The content of the <publisher-options> element corresponds to driver-specific options specified in the DirXML-Driver properties dialog. Driver-specific options are specified using an XML file that describes the options. See DriverShim init for an example XML file used with the skeleton driver. For information about the possible elements in this document, see publisher-options.

The <driver-filter> element contains the publisher filter. This filter is a list of the classes and attributes for which the publisher sends events to the DirXML engine. For information about the possible elements in the filter, see driver-filter.

Sample Code

Java Sample Code

The following code from the skeleton driver retrieves the document, gets the publisher configuration parameters, sets the polling interval, and constructs a filter.

  public XmlDocument init(XmlDocument initParameters )
  {
        tracer.trace("init");
  
        //get the driver filter for the publication shim to use 
        //for filtering application events
        Document initDoc = initParameters.getDocument();
  
        //get any non-authentication options from the init document
        ShimParams params = getShimParams(initDoc,"publisher",PUBLISHER_PARAMS);
  
        //get any the polling interval that may have been passed in
        int pi = params.getIntParam("polling-interval");
        if (pi != -1)
        {
           //change our default polling interval to whatever was setup 
           //using ConsoleOne
           pollingInterval = pi;
        }
  
        //setup a filter for use in start()
         //NOTE: the skeleton publisher doesn’t actually make use of the
         // filter, but this code is here to illustrate how to create the
         // filter based on the init parameters
        NodeList filterList = initDoc.getElementsByTagName("driver-
                 filter");
        int      i = 0;
        Element   filterElement;
        while ((filterElement = (Element)filterList.item(i++)) != null)
        {
           String   type = filterElement.getAttribute("type");
           if (type.length() == 0 || type.equals("publisher"))
           {
              filter = new DriverFilter(filterElement);
              break;
           }
        }
        if (filter == null)
        {
           //if weren’t able to setup a filter, setup a null
           //filter so we don’t have to check for filter != 0 everywhere
           filter = new DriverFilter();
        }
        return createSuccessDocument();
     }
  

In the DirXML sample code, see the init method in the SolutionPublicationShim.java file and the PublicationShimImpl.java file.

C++ Sample Code

The following code from the C++ skeleton driver retrieves the document, gets the publisher configuration parameters, sets a polling interval, and constructs a filter.

  XmlDocument * METHOD_CALL SkeletonPublisher::init(
     XmlDocument * initParameters)
  
  {
     try
     {
        common.tracer->trace("init");
  
        //construct a driver filter for the publication shim to use for filtering
        //application events In an actual driver, the publisher would use
        //the filter to filter events from the application
        //to avoid publishing unnecessary events to DirXML.
        Document * initDoc = initParameters->getDocument();
  
        //get any non-authentication options from the init document
        CommonImpl::ShimParams * params = common.getShimParams(initDoc, TEXT_PUBLISHER,PUBLISHER_PARAMS);
  
        //get any the polling interval that may have been passed in
        int pi = params->getIntParam(TEXT_POLLING_INTERVAL);
        if (pi != -1)
        {
           //change our default polling interval to whatever was 
           //set up using ConsoleOne
           pollingInterval = pi;
        }
        //setup a filter for use in start()
        //NOTE: the skeleton publisher doesn't actually make use of the
        // filter, but this code is here to illustrate how to create the
        // filter based on the init parameters
        Element   * filterElement = (Element *)initDoc->getElementsByTagName (common.ndsDtd->TAG_DRIVER_FILTER)->item(0);
        if (filterElement != 0)
        {
           filter = DriverFilter_new(filterElement);
        } else
        {
           //if weren't able to setup a filter, setup a null
           //filter so we don't have to check for filter != 0 everywhere
           filter = DriverFilter_new(0);
        }
        return common.setReturnDocument(common.createSuccessDocument());
     } catch (ShimException e)
     {
        return   common.setReturnDocument(common.createStatusDocument (STATUS_LEVEL_FATAL,e.getMessage()));
     } catch (...)
     {
        //something bad happened...
        return   common.setReturnDocument(common.createStatusDocument( STATUS_LEVEL_FATAL,MSG_BAD));
     }
  }
  

In the DirXML sample code, see the init method in the PublicationShimImpl.cpp file.