IBM BPM, V8.0.1, All platforms > Programming IBM BPM > Service Component Architecture programming > SCA programming techniques
Runtime rules used for Java to Service Data Objects conversion
To correctly override generated code, or to determine possible runtime exceptions related to Java™ to Service Data Object (SDO) conversions, an understanding of the rules involved is important. The majority of the conversions are straightforward, but there are some complex cases where the runtime provides the best possibility when it converts the generated code.
Basic types and classes
The runtime performs a straightforward conversion between Service Data Objects and basic Java types and classes. Basic types and classes include:
- Char or java.lang.Character
- Boolean
- Java.lang.Boolean
- Byte or java.lang.Byte
- Short or java.lang.Short
- Int or java.lang.Integer
- Long or java.lang.Long
- Float or java.lang.Float
- Double or java.lang.Double
- Java.lang.String
- Java.math.BigInteger
- Java.math.BigDecimal
- Java.util.Calendar
- Java.util.Date
- Java.xml.namespace.QName
- Java.net.URI
- Byte[]
User-defined Java classes and arrays
When converting from a Java class or array to an SDO, the runtime creates a data object that has a URI that is generated by inverting the package name of the Java type and has a type equal to the name of the Java class.
For example, the Java class com.ibm.xsd.Customer is converted to an SDO and URI http://xsd.ibm.com with type Customer. The runtime then inspects the contents of the Java class members and assigns the values to properties in the SDO.
When converting from an SDO to a Java type, the runtime generates the package name by inverting the URI and the name of the type equals the type of the SDO.
For example, the data object with type Customer and URI http://xsd.ibm.com generates an instance of the Java package com.ibm.xsd.Customer. The runtime then extracts values from the properties of the SDO and assign those properties to fields in the instance of the Java class.
When the Java class is a user-defined interface, you must override the generated code and provide a concrete class that the runtime can instantiate. If the runtime cannot create the concrete class, an exception occurs.
Java.lang.Object
When a Java type is java.lang.Object the generated type is xsd:anyType. A module can invoke this interface with any SDO. The runtime attempts to instantiate a concrete class the same way it does for user-defined Java classes and arrays, if the runtime can find that class. Otherwise, the runtime passes the SDO to the Java interface.
Even if the method returns a java.lang.Object type, the runtime converts to an SDO only if the method returns a concrete type. The runtime uses a similar conversion to that for converting user-defined Java classes and arrays to SDOs, as described by the next paragraph.
When converting from a Java class or array to an SDO, the runtime creates a data object that has a URI that is generated by inverting the package name of the Java type and has a type equal to the name of the Java class.
For example, the Java class com.ibm.xsd.Customer is converted to an SDO and URI http://xsd.ibm.com with type Customer. The runtime then inspects the contents of the Java class members and assigns the values to properties in the SDO.
In either case, if the runtime is unable to complete the conversion an exception occurs.
Java.util container classes
When converting to a concrete Java container class such as Vector, HashMap, HashSet and the like, the runtime instantiates the appropriate container class. The runtime uses a method similar to that used for user-defined Java classes and arrays to populate the container class. If the runtime cannot locate a concrete Java class, the runtime populates the container class with the SDO.
When converting concrete Java container classes to SDOs, the runtime uses the generated schemas shown in "Java to XML conversion."
Java.util interfaces
For certain container interfaces in the java.util package, the runtime instantiates the following concrete classes:
WSDL type to Java class conversion Interface Default concrete classes Collection HashSet Map HashMap List ArrayList Set HashSet