Advanced Model development
The XPath functions available in Monitor are a subset of the XPath specification. The functions supported are shown in the following lists.
Dates are formatted using XMLSchema format
IBM Monitor extensions
Authoring User Defined XPath functions
Custom XPath functions can be written in Java. Create a Java project in WID/RAD and define a class. In that class, code methods that are to be executed as XPath functions. Each method should be declared as static. Add the Monitor Runtime to the project's dependencies. To achieve this, open the project's build path and switch to the Libraries tab. Click the Add Library button and select Monitor Runtime Library from the list of options.
In front of each method that is to be exposed, add a Java annotation that looks as follows:
@XPathFunction(namespaceName = "http://mynamespace",
localName = "myLocalName",
description = "My Description",
isSelfContained = true,
isDeterministic = true)
The annotations come from the import of com.ibm.wbimonitor.xml.expression.udf.XPathFunction.
Each function should return a value that will be the outcome of the expression. The functions can also take parameters. When the functions have been written, export the Classes as a JAR file. The JAR file should then be copied into the Monitor project.
In the ID editor, right-click on the Monitor project and select External Function Libaries... from the menu.
In the dialog, select Add JARs and pick the JAR that was added to the Monitor project.
Next, open the Monitor model and in the User Defined XPath Functions, click the Edit... button.
Select each of the function libraries to be used in this project. For each library, a prefix must be entered.
The custom user defined XPath function has now been added. In the XPath editors and expression builders, the Java code can now be referred to by its prefix and localname. At runtime, the call to the associated Java code will occur.
UDF Debugging Notes:
Getting an NPE during loading of the UDF usually means something is wrong. Currently there's not a good error message to help id the problem. Check the annotation, types, etc. For instance, accidentally setting a return type of boolean rather than Boolean will cause an NPE upon loading.
Make sure that you compile with the correct java compiler. 1.5 for 6.2. Trying to run code compiled with a 1.6 compiler will give you the following error: Caused by: java.lang.UnsupportedClassVersionError: (com/mts/BusinessDay) bad major version at offset=6
Method return types
|| |XML datatype|Java return type| |xs:string|java.lang.String| |xs:integer, xs:decimal|java.math.BigInteger| |xs:decimal|java.math.BigDecimal| |xs:boolean|java.lang.Boolean| |xs:date, xs:time, xs:dateTime|javax.xml.datatype.XMLGregorianCalendar| |xs:duration, xs:dayTimeDuration, xs:yearMonthDuration|javax.xml.datatype.Duration| |xs:dateTime|java.util.Calendar| |xs:string|java.net.URI| |xs:string|java.util.UUID|
|| |XML datatype|Java return type| |xs:string|java.lang.String| |xs:integer|java.math.BigInteger| |xs:decimal, xs:integer|java.math.BigDecimal| |xs:boolean|java.lang.Boolean| |xs:date, xs:time, xs:dateTime|javax.xml.datatype.XMLGregorianCalendar| |xs:duration, xs:dayTimeDuration, xs:yearMonthDuration|javax.xml.datatype.Duration|
If a metric is defined as Duration, the value assigned to that metric must be cast to
Two Stage Modeling
Choose which events you wish to propagate. For example, if we care about when a task starts and ends, we need only publish an event on that concept.