Define the component interface and properties  Write the Java source file

Chapter 11: Creating CORBA Java Components

Choose implementation datatypes

EAServer provides two component types for Java components. These component types are functionally equivalent, except that they use different mappings between IDL datatypes and the Java datatypes that are required in your implementation class. The choices are:

The sections below describe the mappings in detail.

Java - CORBA component datatype mappings

The following table lists the datatypes displayed in EAServer Manager, the equivalent CORBA IDL types, and the Java datatypes used in Java/IDL component methods.

Table 11-1: EAServer Manager, CORBA IDL, and Java datatype equivalence

EAServer Manager display datatype

CORBA IDL type

Java type (input parameter or return value)

Java type (inout or out parameter)

integer<16>

short

short

org.omg.CORBA.ShortHolder

integer<32>

long

int

org.omg.CORBA.IntHolder

integer<64>

long long

long

org.omg.CORBA.LongHolder

float

float

float

org.omg.CORBA.FloatHolder

double

double

double

org.omg.CORBA.DoubleHolder

boolean

boolean

boolean

org.omg.CORBA.BooleanHolder

char

char

char

org.omg.CORBA.CharHolder

byte

octet

byte

org.omg.CORBA.ByteHolder

string

string

java.lang.String

org.omg.CORBA.StringHolder

binary

BCD::Binary

byte[]

BCD.Binary

decimal

BCD::Decimal

BCD.Decimal

BCD.DecimalHolder

money

BCD::Money

BCD.Money

BCD.MoneyHolder

date

MJD::Date

MJD.Date

MJD.DateHolder

time

MJD::Time

MJD.Time

MJD.TimeHolder

timestamp

MJD::Timestamp

MJD.Timestamp

MJD.TimestampHolder

ResultSet

TabularResults:: ResultSet

TabularResults.ResultSet

TabularResults.ResultSetHolder

ResultSets

TabularResults:: ResultSets

TabularResults.ResultSet[ ]

TabularResults.ResultSetsHolder

Binary, Fixed-Point, and Date/Time types The BCD and MJD IDL modules define types to represent common database column types such as binary data, fixed-point numeric data, dates, times. The BCD::Binary CORBA type maps to a Java byte array. The other BCD and MJD types map to data representations that are optimized for network transport.

To convert between the IDL-mapped datatypes and from core java.* classes, use these classes from the com.sybase.CORBA.jdbc11 package:

Class

Description

SQL

Contains methods to convert from BCD.* and MJD.* types to java.* types

IDL

Contains methods to convert from java.* types to BCD.* and MJD.* types

Chapter 1, “Java Classes and Interfaces,” in the EAServer API Reference provides reference pages for these classes.

Result set types The TabularResults IDL module defines types used to represent tabular data. Result sets are typically used only as return types, though you can pass them as parameters.

“Return result sets” describes how to create and return result sets.

User-defined IDL types A user-defined type is any type that is:

If a method definition includes user-defined types, the Java component method will use the equivalent Java datatype as specified by the CORBA Java language mappings specification. See “Overview” for more information on this document.

NoteCORBA Any and TypeCode support EAServer’s Java ORB supports the CORBA Any and TypeCode datatypes. Refer to the OMG CORBA 2.3 specification and IDL to Java Language Mapping Specification (formal/99-07-53) for information on using these types.

Holder classes for IDL types All IDL-mapped Java types have an accompanying holder class that is used for passing parameters by reference. Each holder class has the following structure:

public class <Type>Holder {
    // Current value
    public <type> value;
    // Default constructor
    public <Type>Holder() {}
    // Constructor that sets initial value
    public <Type>Holder(<type> v) {
      this.value = v;
    }
}

This structure is defined by the CORBA Java-language bindings specification.

Java - JDBC component datatype mappings

Java-JDBC type mappings are supported to provide backward compatibility with earlier EAServer versions. For new development, use the Java-CORBA types. Components using Java-JDBC type mappings cannot raise user-defined IDL exceptions; all exceptions must be thrown as the generic jaguar.util.JException class.

The table below shows the datatypes displayed in the EAServer Manager, the datatypes used by Java components, and the argument modes (in, inout, out for parameter passing modes and return to indicate the type is used for method return values).

inout and out parameters for these datatypes are passed in holder classes from the com.sybase.jaguar.util and com.sybase.CORBA.jdbc11 packages. For more information on these packages, see the reference pages in Chapter 1, “Java Classes and Interfaces,” in the EAServer API Reference.

Table 11-2: Java - JDBC component datatype mappings

EAServer Manager datatype

IDL type

Mode

Java type

boolean

boolean

input, return inout, out

boolean BooleanHolder

binary

BCD::Binary

input, return inout, out

byte[ ] BytesHolder

byte

octet

input inout, out

byte ByteHolder

date

MJD::Date

input, return inout, out

java.sql.Date com.sybase.jaguar.util.jdbc11.DateHolder

decimal

BCD::Decimal

input, return inout, out

java.math.BigDecimal com.sybase.jaguar.util.jdbc11.BigDecimalHolder

double

double

input, return inout, out

double DoubleHolder

float

float

input, return inout, out

float FloatHolder

integer<16>

short

input, return inout, out

short ShortHolder

integer<32>

long

input, return inout, out

int IntegerHolder

integer<64>

long long

input, return inout, out

long LongHolder

money

BCD::Money

input, return inout, out

java.math.BigDecimal com.sybase.jaguar.util.jdbc11.BigDecimalHolder

string

string

input, return inout, out

java.lang.String StringHolder

time

MJD::Time

input, return inout, out

java.sql.Time com.sybase.jaguar.util.jdbc11.TimeHolder

timestamp

MJD:: Timestamp

input, return inout, out

java.sql.Timestamp com.sybase.jaguar.util.jdbc11.TimestampHolder

User-defined IDL types in a method declaration are mapped to the same Java classes as for a Java/IDL component. See “User-defined IDL types” for more information.

Methods in a Java-JDBC component do not return result sets explicitly. If the IDL method definition indicates a result set or result sets are returned, the Java method must be declared to return void, and the implementation must use the EAServer JServerResultSet and JServerResultSetMetaData interfaces to send result sets back to the client.





Copyright © 2005. Sybase Inc. All rights reserved. Write the Java source file