![]() |
Driver Overview The following DirXML driver question and answer session was designed and written by Perin Blanchard and Shon Vella on the Novell eDirectory Engineering Team. What is a driver? A driver is the piece of code that allows DirXML to communicate with an external application in order to synchronize data between that application and NDS. How does a driver fit into the DirXML framework? DirXML can be thought of as two separate black boxes called channels. Each channel takes an event on its input and issues a set of commands on its output. The goal of the transformation from events to commands is to propagate the changes made by the application connected to the channel input into the application connected to the channel output. The transformation involves fixed logic in DirXML together with a set of configurable rules that guide the transformation of events to commands. The first channel is the Subscriber channel. NDS acts as the Subscriber channel input and a driver's SubscriptionShim acts as the Subscriber channel output. The Subscriber channel therefore accepts NDS events, generates commands with the help of the rules, and issues those commands to the SubscriptionShim which then updates the application. The second channel is the Publisher channel. The driver's PublicationShim acts as the Publisher channel input and NDS acts as the Publisher channel output. The Publisher channel therefore accepts events for the application through the PublicationShim, generates commands with the help of the rules, and issues those commands to update NDS. What are the responsibilities of a driver? A driver does only what DirXML tells it to do. (SubscriptionShim). A driver reports to DirXML any relevant events that occur in the application. (PublicationShim). Does a driver need to know anything about rules? No. It is useful for the driver writer to understand what rules do, but the driver has no responsibility for rules processing. The driver writer should have a good understanding of the responsibilities of the driver before worrying about the rules. What is an association? Associations are the mechanism used by DirXML to establish and maintain a correspondence between an object in NDS and an application object. The driver provides a unique key value for each application object, and DirXML manages the storage of those key values in NDS. A driver's responsibility with respect to associations is to provide a unique key value for each object and to notify DirXML whenever something happens that affects that unique key. In practice this means:
How does DirXML communicate with the driver? DirXML communicates with a driver through interfaces. In Java these are represented by Java interfaces. In C++ these are represented as pure abstract base classes. In the interest of brevity this document will focus primarily on the Java interfaces. A FAQ on C++ drivers is available and covers items specifically of interest to writers of C++ drivers. What are these interfaces? Interfaces implemented by driver:
Interfaces implemented by DirXML:
How are these interfaces used?
What is the XmlDocument used by the interfaces? XmlDocument is a high level abstraction representing an XML document. It allows for easy conversions between several common representations of XML, notably Document Object Model (DOM), Simple API for XML 1.0 (SAX), and a serialized, human-readable form. This allows drivers to create and consume XML documents in the form that is most convenient for the particular application. DirXML predominantly uses DOM internally, but uses the serialized form when logging messages to DSTRACE. Most drivers will probably also use DOM internally, but drivers which must pass the XML to external or remote processes will likely use the serialized form as well. How do I create a DOM document? The implementation of DOM used by DirXML is provided by nxsl.jar (which contains Novell's XSLT processor as well as many XML utility classes). To create a document that uses the same implementation as DirXML, use com.novell.xml.dom.DocumentFactory.newDocument(). It is possible for a driver to use a different implementation of DOM. However, keep in mind that documents that are passed to the driver by DirXML will always use the nxsl.jar implementation, so any extensions to DOM that might be available in another implementation will not be available in documents received from DirXML. Note also that the performance of the Novell XSLT processor is significantly better on documents created using the nxsl.jar implementation. What is the structure of the XML documents passed to and from the various interface methods? The documents passed to and from the various methods have a structure defined by nds.dtd. All documents use <nds> as the document (top-level) element, which may contain an optional <source> element. Documents that are passed as parameters to interface methods also contain a single <input> element that contains an arbitrary number of events or commands as applicable. Documents that are returned from interface methods contain a single <output> element which contains the results of the processing the events or commands contained in the input document and may contain a limited set of commands. See the following examples. DirXML sends: <nds dtdversion="1.0" ndsversion="8.5"> Shim returns: <nds dtdversion="1.0" ndsversion="8.5"> What is the difference between events and commands? The distinction is subtle but important. Many of the possible child elements of <input> can be interpreted either as commands or as events, depending on the context, and have essentially the same syntax. In general, for elements that can be used as either a command or as notification of an event the following applies: If the element is being sent to the driver the element is a command and if the element is being sent to DirXML the element is an event notification. When the driver sends an event notification to DirXML the driver is informing DirXML of something that occurred in the application. DirXML will then determine, based on configurable rules, what commands, if any, must be sent to NDS. When DirXML sends a command to the driver, DirXML has already taken an NDS event as input, applied the appropriate rules, and determined that the change in the application represented by the command is necessary. What are rules? Rules help DirXML transform an event on a channel input into a set of commands on the channel output. Rules are configurable by the System Administrator so that the rules can be customized to do whatever an individual installation requires. Some rules perform a well-defined role in the event-to-command transformation while others allow for more general customization. All rules can be implemented using XSLT stylesheets, but rules that perform well-defined roles more commonly use a DirXML-specific XML format (a "simple" rule) that more easily describes the transformation needed. Rules that use DirXML-specific XML formats can usually be created and edited using ConsoleOne snapins that guide the administrator in creating the rules so that the administrator does not have to see the raw XML that encodes the rule. However, when an XSLT stylesheet is used as a rule (either for those rules that can only be implemented using XSLT or as a replacement for one of the more common rules) the XSLT must be programmed manually. Rules are stored in the XmlData attribute of DirXML-Rule and DirXML-Stylesheet objects. The DirXML-Driver, DirXML-Subscriber, and DirXML-Publisher objects have attributes that reference the rule objects: DirXML-Driver What is rule chaining? Rule chaining is a feature added in DirXML 1.1 that allows multiple rule objects to be chained together to form the total rule processing for a rule step (Create Rule, Placement Rule). This allows a stylesheet to supplement the operation of a simple rule without having to completely replace the rule with a stylesheet. Rules are chained together using the DirXML-NextTransformation attribute on the rule object. Any number of rules may be chained; multiple simple rules and stylesheets may be freely mixed. There may not be any loops in the chain, and any simple rules used must match the rule step. In other words, if rules are being chained in the Create Rule step, any simple rules must use the simple Create Rule syntax. What does the Schema Mapping Rule do? The Schema Mapping Rule is referenced by the driver object and applies to both the Subscriber channel and to the Publisher channel. The purpose of the Schema Mapping Rule is to map schema names (particularly attribute names and class names) between the NDS namespace and the application namespace. The rule syntax is defined by the documentation for <attribute-name-map>. The Schema Mapping Rule is applied to the XML documents sent to and returned from SubscriptionShim.execute(), XmlQueryProcessor.query(), and XmlCommandProcessor().execute(). The Schema Mapping Rule is also applied to XML sent to (but not to XML returned from) SubscriptionShim.init() and PublicationShim().init(). The Schema Mapping Rule is applied before the Output Transformation Rule when DirXML issues a document to the driver and before the Input Transformation Rule when the driver issues a document to DirXML. What does the Input Transformation Rule do? The Input Transformation Rule is referenced by the driver object and applies to both the Subscriber channel and to the Publisher channel. The purpose of the Input Transformation Rule is to perform any preliminary transformation on all XML documents sent to DirXML by the driver and returned to DirXML from the driver. The Input Transformation Rule is applied to the XML document sent to XmlCommandProcessor.execute() and XmlQueryProcessor.query() (when called by the driver) and to the XML document returned from SubscriptionShim.execute(), and XmlQueryProcessor.query() (when called by DirXML). The Input Transformation Rule is applied before the Schema Mapping Rule. The Input Transformation Rule is always implemented using an XSLT stylesheet. A common application is performing data format mapping. Note that schema names will always be in the application namespace in the XML processed by the Input Transformation Rule. It is possible to use the Input Transformation Rule to transform an arbitrary XML format native to the target application to the format expected by DirXML, but this is discouraged because it makes it harder for administrators to customize the rule for site-specific needs. It is usually wiser if the driver performs this transformation itself, possibly by calling the Novell XSLT processor directly. What does the Output Transformation Rule do? The Output Transformation Rule is referenced by the driver object and applies to both the Subscriber channel and to the Publisher channel. The purpose of the Output Transformation Rule is to perform any final transformation necessary on the XML documents sent to the driver by DirXML and returned to the driver by DirXML. The Output Transformation Rule is applied to the XML document sent to SubscriptionShim.execute() and XmlQueryProcessor.query() (when called by DirXML) and to XML returned from XmlCommandProcessor.execute() and XmlQueryProcessor.query() (when called by the driver). The Output Transformation Rule is applied after the Schema Mapping Rule. The output transform is always implemented using an XSLT stylesheet. A common application is performing data format mapping. Note that schema names will always be in the application namespace in the XML processed by the Output Transformation Rule. It is possible to use the Output Transformation Rule to transform between DirXML format and an arbitrary XML format native to the target application, but this is discouraged because it makes it harder for administrators to customize the rule for site-specific needs. It is usually wiser if driver performs this transformation itself, possibly by calling the Novell XSLT processor directly. What does the Event Transformation Rule do? An Event Transformation Rule may be referenced by the Subscriber object and/or by the Publisher object (typically the Subscriber and Publisher would reference different rule objects). The purpose of an Event Transformation Rule is to perform preliminary transformations on events. When referenced by the Subscriber object the Event Transformation Rule applies to events received by DirXML from NDS and is applied before any other event processing. When referenced by the Publisher object the Event Transformation Rule applies to events issued by the driver to DirXML and is applied after the Input Transformation Rule and Schema Mapping Rules, but before any other event processing. The Event Transformation Rule is always implemented using an XSLT stylesheet. There are many common applications for the Event Transformation Rule, including:
What does the Command Transformation Rule do? A Command Transformation Rule may be referenced by the Subscriber object and/or by the Publisher object (typically the Subscriber and Publisher would reference different rule objects). The purpose of the Command Transformation Rule is to provide final processing on commands before the commands are sent to eDirectory or the application.
The Command Transformation Rule on the Publisher channel is executed after all other rules and is executed directly before the DirXML engine applies the commands in the command document to eDirectory. It is the "last chance" to modify a command before the command is applied to eDirectory. The Command Transformation Rule on the Subscriber channel is executed directly before the Schema Mapping Rule. Both the Schema Mapping Rule and the Output Transformation are executed after the Command Transformation Rule on the Subscriber channel. The Command Transformation Rule is always implemented using an XSLT stylesheet. Many applications that had to be performed in the Event Transformation Rule in DirXML 1.0 can be more easily performed in the Command Transformation Rule in DirXML 1.1. This is because all event to command processing performed by the DirMXL Engine has already been performed. Some other possible applications for the Command Transformation Rule include:
What does the Matching Rule do? A Matching Rule may be referenced by the Subscriber object and/or by the Publisher object (typically the Subscriber and Publisher would reference different rule objects). The purpose of the Matching Rule is to automatically associate objects in NDS with objects in the application. The rule syntax is defined by the documentation for <matching-rules>. The matching rule is only applied to <add> events. What does the Create Rule do? A Create Rule may be referenced by the Subscriber object and/or by the Publisher object (typically the Subscriber and Publisher would reference different rule objects). The purpose of the Create Rule is to decide whether or not to create a new object if a suitable association could not be automatically generated by the Matching Rule. A Create Rule also can perform other modifications to the <add> event such as providing default values for attributes and/or specifying an object to use as a template for creating the new object. The rule syntax is defined by the documentation for <create-rules>. The Create Rule is only applied to <add> events for which no matches for the corresponding object were found by the Matching Rule. What does the Placement Rule do? A Placement Rule may be referenced by the Subscriber object and/or by the Publisher object (typically the Subscriber and Publisher would reference different rule objects). The purpose of the Placement Rule is to determine where in the storage hierarchy to place an object that is to be created and to determine the name for the new object. For NDS and other directory applications this means generating a distinguished name for the new object. The rule syntax is defined by the documentation for <placement-rules>. The Placement Rule is only applied to <add> events which were not vetoed by the Create Rule. What does an Event Filter do? An Event Filter specifies the classes of objects and the attributes of those objects for which DirXML will process events. Separate Event Filters are specified for the Subscriber and Publisher channels. Event Filters only pass events on objects whose effective class matches one of those classes specified by the filter. Event Filters do not pass events on objects that are a subclass of a class specified in the filter unless the subclass is also specified. What is the general flow of an event through the Event Filter and rules? The following is the general order of rule processing. Note that this is an extreme over-simplification of the processing that actually occurs and that processing may stop at any point or skip to the last step if the result of processing a rule dictates it. Subscriber Channel
Publisher Channel
How do the Event Filter and the rules interact with each other? Rules and Event Filters must be explicitly constructed to complement each other. What this means really depends on the particular requirements of the installation and on the requirements of the application, but here are a few general things to keep in mind:
What do I need to know to implement a rule using an XSLT stylesheet? Understand XSLT and the XML you will be transforming A good working understanding of XSLT is a good place to start. Obtain the XSLT and XPath specifications. Make sure any tutorial or book reference on the subject is based on the final 16 November 1999 W3C Recommendation. A recommended reference for XSLT programming is XSLT Programmer's Reference, by Michael Key, published by Wrox Press. ISBN 1-861003-12-9. You also need a good working understanding of the XML specified by nds.dtd. Understand the goal of the rule you are implementing Each kind of rule accomplishes specific kinds of tasks as outlined in a general fashion above. Additional things you might need to know for each rule type are:
Start out with the identity transformation Unless you are translating to/from an XML format that is completely different from the DirXML format in the Input and Output Transformation Rules, you will want to start your stylesheet with templates that implement the identity transformation. This is so that anything in the document that you don't specifically try to intercept and change will be passed through as is. The following two templates together implement the identity transform: <xsl:template match="/" > Use the parameters that are passed into the stylesheet Except for the Input and Output Transformation Rules, rules implemented as stylesheets are passed several parameters from DirXML that the stylesheet can use:
To use these parameters include the following at the top level of your stylesheet: <xsl:param name="fromNDS"/> Use of the query processors depends on the Novell XSLT implementation of extension functions. In order to make a query you need to declare a namespace for the XdsQueryProcessor interface: this is done by adding xmlns:query="http://www.novell.com/nxsl/java/com.novell.nds.dirxml.driver.XdsQueryProcessor" to the <xsl:stylesheet> or <xsl:transform> element of the stylesheet. An example of using one of the query processors: <!-- query object name queries NDS for the passed object-name. --> Use of the command processors depends on the Novell XSLT implementation of extension functions. In order to issue a command you need to declare a namespace for the XdsCommandProcessor interface: this is done by adding xmlns:command="http://www.novell.com/nxsl/java/com.novell.nds.dirxml.driver.XdsCommandProcessor" to the <xsl:stylesheet> or <xsl:transform> element of the stylesheet. An example of using one of the command processors: <!-- update full name sets the "Full Name" attribute in the event source--> Use extension functions as needed XSLT is an excellent tool for performing some kinds of transformations and a rather poor tool for other types of transformations (non-trivial string manipulation, iterative processes, etc.). Fortunately the Novell XSLT processor implements extension functions which allow the stylesheet to call a function implemented in Java (and by extension any other language that can be accessed through JNI). Additional documentation on using extension functions with Novell's XSLT implementation can be found elsewhere. For specific examples see the above example using the query processor, and the following example that illustrates using Java for string manipulation. <!-- get-dn-prefix places the part of the passed dn that precedes the --> How do I invoke the Novell XSLT processor directly? Drivers can invoke the Novell XSLT processor directly by using the com.novell.xsl.StyleSheet class. There are various ways in which this can be set up and invoked so it pays to read the documentation, but a typical invocation is illustrated by the following code fragment. import com.novell.nds.dirxml.driver.*; Are there any other utility classes available to make my job easier? There are a number of utility classes provided by DirXML or nxsl.jar that are useful to driver writers. Among the most useful are:
Does my driver have to do anything special to work with the DirXML Remote Loader? No, if your driver makes assumptions about where it is running it may need to be modified. If, for example, your driver uses a "side-band" connection to eDirectory via LDAP and assumes it can do so on "localhost" then your driver won't work correctly with the Remote Loader. In general, if your driver strictly adheres to the DirXML interfaces and doesn't assume that it is running on the same machine as eDirectory then your driver will function properly with the DirXML Remote Loader. How can I debug my driver or rules? Use DSTRACE. Messages originating from DirXML show up in DSTRACE if you enable the DirXML Drivers events (DVRS on NetWARE). By default very little information is given, mostly just the status of events. To enable more verbose output, add the DirXML-DriverTraceLevel attribute to the DirXML-DriverSet object using Other tab on the ConsoleOne Properties dialog. Useful values for this attribute are:
Drivers may also send messages to DSTRACE by creating and using an instance of com.novell.nds.dirxml.driver.Trace. It is recommended that drivers not write directly to System.out or System.err (even though this will currently send the output to DSTRACE) because this may not be supported in future releases. Trace messages may also be directed to a file (in addition to DSTRACE) by setting the value of the DirXML-JavaTraceFile attribute on the DirXML-DriverSet object to a valid filename. Use the Other tab on the ConsoleOne Properties dialog for the DirXML-DriverSet object. Attach a Java debugger (This is currently only supported on Win32). There are a number of Java debuggers available and two common debugger APIs on the Java platform. Agent Debugger
JavaTM Platform Debugger Architecture (JPDA)
Sample: set DHOST_JVM_OPTIONS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,address=8080,suspend=n Note that if running as a server, you must set this in the System control panel under System variables.
Using the Visual Cafe 3.0 Debugger The Visual Cafe debugger is an agent-type debugger. To setup a debugging session:
Using jdb The jdb is an agent-type debugger. To setup a debugging session:
jdb -host localhost -password <password>
Using CodeWarrior 5 debugger CodeWarrior supports both agent and JPDA debugging API's. To setup a debugging session:
Environment Variables The following environment variables can be used on Win32:
The following options can be used on NetWare:
|
||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||