8 Oracle WebLogic Tuxedo Connector JATMI VIEWs
This chapter includes the following sections:
Overview of Oracle WebLogic Tuxedo Connector VIEW Buffers
Note:
See Using a VIEW Typed Buffer in Programming a Tuxedo ATMI Application Using C at http://docs.oracle.com/cd/E13203_01/tuxedo/tux100/pgc/pgbuf.html
.
Oracle WebLogic Tuxedo Connector allows you to create a Java VIEW buffer type analogous to an Oracle Tuxedo VIEW buffer type derived from an independent C structure. This allows Oracle WebLogic Server applications and Oracle Tuxedo applications to pass information using a common structure. Oracle WebLogic Tuxedo Connector VIEW buffers do not support FML VIEWs or FML VIEWs/Java conversions.
Parent topic: Oracle WebLogic Tuxedo Connector JATMI VIEWs
How to Create a VIEW Description File
Note:
fbname
and null
fields are not relevant for independent Java and C structures and are ignored by the Java and C VIEW compiler. You must include a value (for example, a dash) as a placeholder in these fields.
Your Oracle WebLogic Server application and your Oracle Tuxedo application must share the same information structure as defined by the VIEW description. The following format is used for each structure in the VIEW description file:
$ /* VIEW structure */ VIEW viewname type cname fbname count flag size null
where
-
The file name is the same as the VIEW name.
-
You can have only one VIEW description per file.
-
The VIEW description file is the same file used for both the Oracle WebLogic Tuxedo Connector
viewj
compiler and the Oracle Tuxedoviewc
compiler. -
viewname
is the name of the information structure. -
You can include a comment line by prefixing it with the # or $ character.
-
The following table describes the fields that must be specified in the VIEW description file for each structure.
Table 8-1 VIEW Description File Fields
Field | Description |
---|---|
|
Data type of the field. Can be set to |
|
Name of the field as it appears in the information structure. |
|
Ignored. |
|
Number of times field occurs. |
|
Specifies any of the following optional flag settings:
|
|
For |
|
User-specified NULL value, or minus sign ( The default NULL value for all numeric types is 0 (0.0 for dec_t). For character types, the default NULL value is ` Constants used, by convention, as escape characters can also be used to specify a NULL value. The VIEW compiler recognizes the following escape constants: \ddd (where d is an octal digit), \0, \n, \t, \v, \r, \f, \\, \', and \". You may enclose STRING, CARRAY, and char NULL values in double or single quotes. The VIEW compiler does not accept unescaped quotes within a user-specified NULL value. You can also specify the keyword NONE in the NULL field of a VIEW member description, which means that there is no NULL value for the member. The maximum size of default values for string and character array members is 2660 characters. |
Example VIEW Description File
The following provides an example VIEW description which uses VIEW buffers to send information to and receive information from an Oracle Tuxedo application. The file name for this VIEW is infoenc
.
Example 8-1 Example VIEW Description
VIEW infoenc #type cname fbname count flag size null float amount AMOUNT 2 - - 0.0 short status STATUS 2 - - 0 int term TERM 2 - - 0 char mychar MYCHAR 2 - - - string name NAME 1 - 16 - carray carray1 CARRAY1 1 - 10 - dec_t decimal DECIMAL 1 - 9 - #size ignored by viewj/viewj32 END
Parent topic: How to Create a VIEW Description File
How to Use the viewj Compiler
To compile a VIEW
typed buffer, run the viewj
command, specifying the package name and the name of the VIEW description file as arguments. The output file is written to the current directory.
To use the viewj
compiler, enter the following command:
java weblogic.wtc.jatmi.viewj [options] [package] viewfile
To use the viewj32
compiler, enter the following command:
java weblogic.wtc.jatmi.viewj32 [options] [package] viewfile
The arguments for this command are defined as follows:
Table 8-2 Argument
Argument | Description |
---|---|
options |
Note: |
package |
The package name to be included in the Example: |
viewfile |
Name of the VIEW description file. Example: |
For example:
-
A VIEW buffer is compiled as follows:
java weblogic.wtc.jatmi.viewj -compat_names examples.wtc.atmi.simpview infoenc
-
A VIEW32 buffer is compiled as follows:
java weblogic.wtc.jatmi.viewj32 -compat_names -modify_strings examples.wtc.atmi.simpview infoenc
Parent topic: Oracle WebLogic Tuxedo Connector JATMI VIEWs
How to Pass Information to and from a VIEW Buffer
The output of the viewj
and viewj32
command is a .java
source file that contains set
and get
accessor methods for each field in the VIEW description file. Use these set
and get
accessor methods in your Java applications to pass information to and from a VIEW buffer.
The AssociatedFieldHandling
flag is used to specify if the set
and get
methods use the values of the associated length and count fields if they are specified in the VIEW description file.
-
set
methods set the count for an array field and set the length for a string or carray field. -
Array
get
methods return an array that is at most the size of the associated count field. -
String and carray
get
methods return data that is at most the length of the associated length field.
Use one of the following to set or get the state of the AssociatedFieldHandling
flag:
-
Use the -
associated_fields
option for theviewj
andviewj32
compiler to set theAssociatedFieldHandling
flag to true. -
Invoke the
void setAssociatedFieldHandling(boolean state)
method in your Java application to set the state of theAssociatedFieldHandling
flag.-
If false, the
set
andget
methods ignore the length and count fields. -
If true, the
set
andget
methods use the values of the associated length and count fields if they are specified in the VIEW description file. -
The default state is false.
-
-
Invoke the
boolean getAssociatedFieldHandling()
method in your Java application to return the current state ofAssociatedFieldHandling
.
Parent topic: Oracle WebLogic Tuxedo Connector JATMI VIEWs
How to Use VIEW Buffers in JATMI Applications
Use the following steps when incorporating VIEW buffers in your JATMI applications:
Parent topic: Oracle WebLogic Tuxedo Connector JATMI VIEWs
How to Get VIEW32 Data In and Out of FML32 Buffers
A helper class is available to add and get VIEW32 data in and out of an FML32 buffer. The class name is wtc.jatmi.FViewFld
. This class assists programmers in developing JATMI-based applications that use VIEW32 field type for FML32 buffers.
No change to configuration is required. You still configure the VIEW32 class path using the ViewTbl32Classes
attribute in the WTCResources
section of the WLS configuration file.
The following access methods are available in this helper class.
-
FViewFld(String vname, TypedView32 vdata)
; -
FviewFld(FviewFld to_b_clone)
; -
void setViewName(String vname)
-
String getViewName();
-
void setViewData(TypedView32 vdata)
-
void TypedView32 getViewData();
Example 8-2 How to Add and Retrieve an Embedded TypedView32 buffer in a TypedFML32 Buffer
String toConvert = new String("hello world"); TypedFML32 MyData = new TypedFML32(new MyFieldTable()); Long d1 = new Long(1234); Float d2 = new Float(12.32); MyView data = new myView(); FviewFld vfld; data.setamount((float)100.96); data.setstatus((short)3); vfld = new FviewFld("myView", data); try { myData.Fchg(MyFieldTable.FLD0, 0, toConvert); myData.Fchg(MyFieldTable.FLD1, 0, 1234); myData.Fchg(MyFieldTable.FLD2, 0, d2); myData.Fchg(MyFieldTable.myview, 0, vfld); } catch (Ferror fe) { log("An error occurred putting data into the FML32 buffer. The error is " + fe); } try { myRtn = myTux.tpcall("FMLVIEW", myData, 0); } catch(TPReplyException tre) { …. } TypedFML32 myDataBack = (TypedFML32)myRtn.getReplyBuffer(); Integer myNewLong; Float myNewFloat; myView View; String myNewString; try { myNewString = (String)myDataBack.Fget(MyFieldTable.FLD0, 0); myNewLong = (Integer)myDataBack.Fget(MyFieldTable.FLD1, 0); myNewFloat = (Float)myDataBack.Fget(MyFieldTable.FLD2, 0); vfld = (FviewFld)myDataBack.Fget(MyFieldTable.myview, 0); view = (myView)vfld.getViewData(); } catch (Ferror fe) { …. }
The following code listing is an example FML Description(MyFieldTable) related to the example in Example 8-2.
*base 20000 #name number type flags comments FLD0 10 string - - FLD1 20 long - - FLD2 30 float - - myview 50 view32 - defined in View description file
Parent topic: How to Use VIEW Buffers in JATMI Applications
Using the XmlViewCnv Class for XML to and From View/View(32) Translation
Use the XmlViewCnv
class to perform XML to View /View(32) or View/View(32) to XML translation. The following code listing is an example that uses the XmlViewCnv
class for conversion to and from XML buffer formats.
import examples.wtc.atmi.simpview.infoenc; // View class import weblogic.wtc.gwt.XmlViewCnv; import weblogic.wtc.jatmi.TypedBuffer; public class xml2view { public static void main(String[] args) { String xmlDoc = "<VIEW32><infoenc><amount>1000.0</amount><infoenc></VIEW32>"; infoenc convertMe = new infoenc(); convertMe = (infoenc) XmlViewCnv.XMLToView( xmlDoc, convertMe.getClass(), convertMe.getSubtype()); convertMe = (infoenc) echo.Echo(convertMe); result = XmlViewCnv.ViewToXML( (TypedBuffer) convertMe, convertMe.getClass(), true); System.out.println(result); } }
Translating Nested Views
Nested views are views which contains one or more members of type struct
, which are themselves a view. This section provides an example of converting a nested view to XML.
The following is a nested view file:
VIEW file VIEW MYVIEW1 #type Cname Fbname Count Flag Size null long long1 - 1 - - 0 string string1 - 1 - 20 '\0` END VIEW MYVIEW2 #type Cname Fbname Count Flag Size null long long1 - 1 - - 0 bool bool1 - 1 - - 0 signedchar schar1 - 1 - - 0 struct MYVIEW1 myview1 2 - - NONE END
The translated XML string is:
<VIEW32> <MYVIEW2> <bool1>true</bool1> <long1>100</long1> <myview1><VIEW32><MYVIEW1> <string1>aa11</string1> <long1>100</long1> </MYVIEW1></VIEW32></myview1> <myview1><VIEW32><MYVIEW1> <string1>bb22</string1> <long1>100</long1> </MYVIEW1></VIEW32></myview1> <schar1>100</schar1> </MYVIEW2> </VIEW32>