IBM BPM, V8.0.1, All platforms > Authoring services in Integration Designer > Developing monitor models > Create monitor models > Authoring XPath functions

Create an XPath function JAR

To add the Java™ function that you plan to use in your XPath expressions, create an XPath function Java archive (JAR) file in Rational Application Developer or Integration Designer.

To create the JAR file:


Procedure

  1. In the Java perspective, create a new Java project.

  2. Add the Monitor Runtime Library by right-clicking the project and selecting Build Path > Add Libraries > Monitor Runtime Library. Click Finish.

  3. Create a new Java class in the project to contain the XPath functions. You can define multiple XPath functions in a single class.

  4. Add the two required imports, which are annotations used to specify user-defined XPath functions, as follows:

    import com.ibm.wbimonitor.xml.expression.udf.XPathFunction;
    import com.ibm.wbimonitor.xml.expression.udf.XPathType;

  5. Create a public static method and annotate it with the XPath function annotation. The return types and parameter types must be included in the list of understood types. The following tables lists the Java types allowed and the corresponding XML datatypes. Those XML datatypes listed in bold are defaults. To select an XML datatype other than the default, use the XPathType annotation. You must clarify ambiguous types using the XPathType annotation on either the method itself (for return types) or on a given parameter.

    Return types
    Java return type XML datatype
    java.lang.String xs:string
    java.math.BigInteger xs:integer, xs:decimal
    java.math.BigDecimal xs:decimal
    java.lang.Boolean xs:boolean
    javax.xml.datatype.XMLGregorianCalendar xs:date, xs:time, xs:dateTime
    javax.xml.datatype.Duration xs:duration, xs:dayTimeDuration, xs:yearMonthDuration
    java.util.Calendar xs:dateTime
    java.net.URI xs:string
    java.util.UUID xs:string

    Parameter types
    Java parameter type XML datatype
    java.lang.String xs:string
    java.math.BigInteger xs:integer
    java.math.BigDecimal xs:decimal, xs:integer
    java.lang.Boolean xs:boolean
    javax.xml.datatype.XMLGregorianCalendar xs:date, xs:time, xs:dateTime
    javax.xml.datatype.Duration xs:duration, xs:dayTimeDuration, xs:yearMonthDuration

  6. Write the body of the method to produce the result that you want.

  7. If the library is not automatically imported, press Ctrl+Shift+O to import the necessary library.
  8. Compile the project and export the project as a JAR file.

  9. To verify that the XPath function works, follow the steps listed in Manage user-defined functions to associate the JAR file with an existing monitor model project. Use one of the XPath functions in an expression and then validate the model.

    Any problems that you have loading the XPath function JAR file are reported as errors.

Authoring XPath functions