Previous Contents Index DocHome Next |
iPlanet Application Server Enterprise Connector for CICS Developer's Guide |
Chapter 3 Programming Examples
This chapter describes the procedure for acquiring UIF objects and executing function objects.The iPlanet Application Server Enterprise Connector for CICS executes CICS transactions on a remote CICS server. The servlet uses the CICS connector to access the CICS server.
This chapter contains the following section:
Data Objects
Data Objects
Data objects represent data in a hierarchal fashion; circular references are not allowed. UIF prevents a data object being used as an attribute of itself. Indirect circular references are not checked by UIF.
No error message is generated if an indirect circular reference is defined. Unpredictable results occur if a circular reference is used at runtime.
The data objects contain actual data and metadata.
UIF is used to access date through the data object interface. The data object interface:
presents a unified representation of backend data types
Data objects are built from primitive types. A primitive data object contains a primitive value; e.g., integer, string. Arrays and structures are complex data objects.
Primitive Objects
Primitive Objects
A primitive data-type object contains a single value of one of the following types
integer, float, double
![]()
Figure 3-1    Primitive Object
integer, float, double
Integer, float, and double-data type objects hold a value whose type corresponds to the java-data type.When a primitive data object is assigned to a list, array, or structure, the data object is unwrapped and its value is copied into the list, array or structure. The data object itself is not used. When a primitive value is obtained by using an untyped get-method, such as getField(), getElem(), getAttr(), or getCurrent(), the returned value is wrapped in a primitive data object. In this case, the value is copied, thus, modifying the returned primitive data object does not change the source object.
fixed-length string, variable-length string
Strings correspond to the java-string data type A fixed-length string has a maximum length, whereas a variable-length string has no restrictions on its length.
fixed-size byte array, variable-size byte array
A fixed-size byte array has a maximum size, whereas a variable-size byte array has no restriction on its size.When a new value replaces an old value, the old value is released. Thus, when a new value is assigned to a variable-length string or a variable-size byte array, the old value is released. When a new value is assigned to a fixed-length string or a fixed-size byte array, the new value is copied over the old one. In the case of a fixed-length string, the copied string is truncated to fit if necessary. In the case of a fixed-size byte array, a shorted array is zero filled on the right and a longer array is truncated to fit.
The maximum length of a fixed-length string and the maximum size of a fixed-size byte array are set when the string's initial value is specified; i.e. four characters in the following example;
If a five character value is used, the value is truncated to four characters by dropping the fifth character.
Structure Objects
Structure objects contain other data objects or primitive values as fields. Each object within the structure object is referred to by a string that represents the field name. Field names have a maximum length of 32 characters. A structure's fields are heterogeneous.
Figure 3-2    Structure Object
Array Objects
An array object contains data objects or primitive values as elements in the object. array objects inherit from list objects. The difference between an array object and a list object is that the array's elements must be homogeneous. Each element within the array object is referred to by an integer that specifies its position in the array object.
Figure 3-3    Array Object
Type Information Objects
Type information objects are structured objects that contain the type information of a data object; i.e. a type information object might define the fields in a structure and their corresponding data types. Instances of data objects can be created of type information objects. Each of these instances contain a reference to a type of information object. Numerous data types can share the same type information object.
API Naming Conventions
Methods in the API conform to a naming convention that specifiesIn the following example of the form <operation><target><type>:
get is the operation, Elem is the target, and String is the type.
Operation
There are many types of operations but the two most commonly used are
None (primitive)
Attr (complex DataObject such as a list, array, or structure) that uses path to address attribute.
Elem (list/array) uses index to address element
Type
The types of operations are
Attributes and Paths
In the API, methods of the IBSPDataObject interface do not distinguish between an element in an array and a field in a structure. In this case the element or field is referred to as an attribute.The path to an element is its element number, beginning from zero. The path to a field is its field name.You may combine element numbers and field names to create paths to attributes in complex data objects, such as a field of a structure that contains a list of elements. In this case, you specify the path as the individual attributes separated by periods (.); i.e. use "field1.[01]" to identify the first element of a list at field1 in the structure.
Changing Data Types
If an attribute's type is primitive, it can not change. For example, the following code will cause an error because it tries to change the type of a primitive from an integer to a float:list.addElemInt (100) ; // assume 100 is added to element 1
list.setElemFloat (1, 3.14) ; // fails because the type of element is int
You can change the data type of non-primitive, as in the following example:
list.addElemDataObject (aStruct) ; // add a structure is to element 1
list.setElemDataObject (1, array) ; // change to array succeeds
Working with Servlet Samples
To execute a CICS transaction from a servlet
Acquiring the UIF Runtime Object
The runtime object is the entry point into UIF. It is both the object factory and the access point for creating other objects.The following is an example of acquiring a runtime object.
Creating the Service Provider Object
The service provider is the logical representation of a connection to a backend system. Typically, the service provider is not bound to a physical connection until it is absolutely necessary. A service provider must be enabled before it can be used.
Detailed Description of Service Provider
A service provider type represents a connection to a backend CICS system. It contains configuration information such as the kinds of data required to create a connection, e.g., host, port, user name, and password.A service provider type may also specify additional information required to manage a connection.
The following diagram shows the parts of a service-provider type.
![]()
Figure 3-4    Service Provider Types
The following is an example of how to create a service provider object.
Parameter
Definition
CICS
Data source name
CICS_sp1
Service provider name
Creating the Function Object
A function object is a group of related operations that share a common state. In UIF, a function object is set up and associated with a service provider before the function object is executed.
Detailed Description of Function Object
A function-object contains operations. The operations contain data-block definition and a property set whose values define access to the target CICS transaction. The data objects contain actual data values which are in the format specified in a data type. The data object element under a function object template is a data object of a specified data type. It represents the parameter block for the operation and holds the input/output information during the execution of the operation.The following diagram shows the parts of a function-object type.
![]()
Figure 3-5    Function-Object Type
The following is an example of how to create a function object.
Parameter
Definition
CICS
Data source name
phonebook
Function name
Setting Up and Executing the Function Object
Specify and enable the service provider.
The following is an example of setting up and executing a function object.Prepare the function object, set up the property set, and set up the input parameters in the function object's data block.
Samples
This section describes the three samples that are included: two Phonebook and one Telco.
Telco Sample and Programming Concepts
This sample is based on CICS and DB2 for OS/390.The Telco sample application consists of seven (7) CICS programs that access DB2 tables.
The CICS install library contains three members:
Create the sample DB2 database using the member CRETAB. It contains a JCL that creates the sample database.
Note Please read the content of the file, and customize it to your environment if needed.
Bind the CICS DB2 programs into packages and plan using the member BIND which creates the packages and plan.
Note Please read the instruction in the JOB comment, and make any necessary customizations to your site.
Create resource definitions for the sample applications in CICS by running the CICSDEF2 member. The CICSDEF2 creates definitions for the Cobol programs and defines the db2entry for the transaction.
Telco Customer Service Example
The following Telco Customer Services window shows an example of using the model in a telephone service.
Type your telephone number and PIN number in the Login Menu dialog box
![]()
.Click the Next button to display the Telco Customer Service Main Menu.
Accessing the Customer Details Dialog Box
Click on the Update Customer detail button.The Customer Details dialog box, shown below, is used to update the name, address, and telephone number of the customer. Payment method, credit card number, and credit card expiration date are not displayed and cannot be changed.
![]()
Type the change in the appropriate text box. In the dialog box, below, a new billing address has been typed into the Billing Address text box: 22 Herzl St
![]()
.Click the Update button to save the data.
Displaying the Customer Services
From the main menu press the Customer Services button.The following dialog box appears.![]()
Displaying the Customer's Billing for Any Month
Type the telephone number and billing month in the appropriate text boxes.
Press the Get Billings button to display the billings, as shown below.
![]()
Press the Get Billings button to see the billings, as shown below.
![]()
Code Samples
Code Example 3-9 Service Class package TelcoSample; public class Services { public String service_code = ""; public String service_name=""; public String price =""; public String price_unit=""; public Services(int code,String name,String in_price,String in_price_unit) { service_code=String.valueOf(code); service_name=new String(name); price=new String(in_price); "> Service Class Code Sample.
Code Example 3-10 Service Detail Class code Sample package TelcoSample; public class Service_details { public String out_service_code = ""; public String out_service_name=""; public String out_charge=""; public Service_details(int service_code,String service_name,String charge) { out_service_code=String.valueOf(service_code); out_service_name=new String(service_name); out_charge=new String(charge); } } "> Service Detail Class Code Sample
Previous Contents Index DocHome Next
Copyright © 2000 Sun Microsystems, Inc. Some preexisting portions Copyright © 2000 Netscape Communications Corp. All rights reserved.
Last Updated June 09, 2000