IBM Integration Bus, Version 9.0.0.8 Operating Systems: AIX, HP-Itanium, Linux, Solaris, Windows, z/OS

See information about the latest product version

Custom Java

You can use the Custom Java™ transform to enter Java code in a message map.

In the Graphical Data Mapping editor, you can use the Custom Java transform to enter your own Java code. You can then use the transform properties to select a Java class, and a Java method. The Java class must be available in a Java project in your workspace. You can use the content assist in the Values column to help you assign the required elements of the source schema.

Consider the Graphical Data Mapping editor behavior when you use the Custom Java transform:
  • When you include a Custom Java transform, an import is added to refer to the package qualified Java class, defining a prefix based on the class name.
  • If you need to use custom Java only in condition or filter expressions, you can add Java imports to your Java class so that the class public static methods are available through content assist when you are composing an expression.
  • The Java class that you provide to the map must have a static method that returns the appropriate type for the value of the output element, and takes parameters of the appropriate type for the wired inputs.

For example, the following Java method could be used in a Custom Java transform that had three input elements, of types a xs:string, xs:decimal and xs:boolean and the output element being a xs:decimal:

	public static BigDecimal calSomething(String memType, BigDecimal stdCost, boolean flag) {
		BigDecimal actualCost = stdCost;
		if (flag & memType.startsWith("gold")) {
			BigDecimal discRate = new BigDecimal(0.9);
			actualCost = actualCost.multiply(discRate);
		}			
		return actualCost;
	}

Mappings between the Schema type, the Java type, and the IBM Integration Bus message assembly type

The following table shows the mappings between the Schema type, the Java type, and the IBM® Integration Bus message assembly type:

Table 1. Mapping the Schema type, Java type, and message tree element type
Schema type Java type IBM Integration Bus message assembly tree element type
xs:anyURI java.lang.String CHARACTER
xs:base64Binary byte[] BLOB
xs:boolean boolean, java.lang.Boolean BOOLEAN
xs:byte byte, java.lang.Byte INTEGER
xs:date javax.xml.datatype.XMLGregorianCalendar DATE
xs:dateTime javax.xml.datatype.XMLGregorianCalendar TIMESTAMP
xs:dayTimeDuration javax.xml.datatype.Duration INTERVAL
xs:decimal java.math.BigDecimal DECIMAL
xs:double double, java.lang.Double FLOAT
xs:duration javax.xml.datatype.Duration INTERVAL
xs:float float, java.lang.Float FLOAT
xs:gDay javax.xml.datatype.XMLGregorianCalendar DATE
xs:gMonth javax.xml.datatype.XMLGregorianCalendar DATE
xs:gMonthDay javax.xml.datatype.XMLGregorianCalendar DATE
xs:gYear javax.xml.datatype.XMLGregorianCalendar DATE
xs:gYearMonth javax.xml.datatype.XMLGregorianCalendar DATE
xs:hexBinary byte[] BLOB
xs:int int, java.lang.Integer INTEGER
xs:integer java.math.BigInteger DECIMAL
xs:long long, java.lang.Long INTEGER
xs:negativeInteger java.math.BigInteger DECIMAL
xs:nonNegativeInteger java.math.BigInteger DECIMAL
xs:nonPositiveInteger java.math.BigInteger DECIMAL
xs:normalizedString java.lang.String CHARACTER
xs:positiveInteger java.math.BigInteger DECIMAL
xs:short short, java.lang.Short INTEGER
xs:string java.lang.String CHARACTER
xs:time javax.xml.datatype.XMLGregorianCalendar TIME
xs:unsignedByte Short INTEGER
xs:unsignedInt Long INTEGER
xs:unsignedLong java.math.BigInteger DECIMAL
xs:unsignedShort Int INTEGER
xs:yearMonthDuration javax.xml.datatype.Duration INTERVAL

Processing arrays and complex types

You can create Custom Java transforms to process input and outputs that are arrays or complex types. These cannot be converted from a Schema type to a defined Java type shown in the previous table.

In IBM Integration Bus, your Java class must use the MbElement class to reference the input or output element. For information about using Java and the MbElement class, see Using Java API classes for Custom Java mapping transforms.


cm28645_.htm | Last updated Friday, 21 July 2017