Uniface Signature Definitions for use with Java call-out (UD5)

There are two (2) ways of calling Java methods from Uniface using UD5:

Before you can use the activate, you must:

See the following sections for information on these topics:

Methods with numeric parameters and return values

Java methods which return an numeric results are typically mapped to a "C" implementation signature in Uniface with a return type of long returned in $status.

Here is the source for the numeric implementation of COMPUTE.ADD, and it's signature definition.

public class COMPUTE {

    public static long ADD(double a, double b) {

	Double Da = new Double(a);

	Double Db = new Double(b);

	return Da.intValue() + Db.intValue();

    }

}
Define Operation: COMPUTE
Operation NameCommunication DefaultStatelessLiteral NameImplementationReturn ValueContext
ADDSynchronousNCADDIn $statuslong 
Define Parameter: ADD
Parameter NameInOutData TypeLiteral NameInterfaceLength
aYNBasicFloating decimal pointadouble 
bYNBasicFloating decimal pointbdouble 

Methods with String parameters and return values

Java methods which return String results are typically mapped to a "C" implementation signature in Uniface with a return type of String returned in the first parameter.

Here is the source for TESTDRIVE.FRED, and it's signature definition.

public class TESTDRIVE {

 public static String fred (String me) {

  return "hello "+me;

 }

}
Define Operation: TESTDRIVE
Operation NameCommunication DefaultStatelessLiteral NameImplementationReturn ValueContext
ADDSynchronousNCfredIn First Parameter  
Define Parameter: FRED
Parameter NameInOutData TypeLiteral NameInterfaceLength
OUTSTRNYBasicStringoutstrchar * (length 2 - 10240)400
MENYBasicStringmechar * (length 2 - 10240)400

MAIN Methods with Array String parameters and void return values

Java classes should always contain a default "main" method. This method allways returns void and takes a single parameter of type String[]. This is mapped to a "C" implementation signature in Uniface with a return type of void and a single String parameter. String parameters are assumed to be arrays of strings for operations main and maintst as well as any operations named in the "Include File Name" field of the "Define C Properties" form in the signature definition (several operations can be named separated by white space).

Here is the source for TESTDRIVE.main, and it's signature definition.

public class TESTDRIVE {

 public static void main (String args[]) {

 String res;

 try {

   res = "JDK Test Drive - iterate parameters";

   for (int i = 0; i < args.length; i++) {

      res = res + " " + args[i] + " " + i;

   }

 } catch (Exception e) {

   res = "Exception=" + e;

 }

 return res;

}
Define Operation: TESTDRIVE
Operation NameCommunication DefaultStatelessLiteral NameImplementationReturn ValueContext
MAINSynchronousNCmainNone (void)  
Define Parameter: MAIN
Parameter NameInOutData TypeLiteral NameInterfaceLength
ARGSYNBasicStringargschar * (length 2 - 10240)1000

The elements of the array are passed to main as a <GOLD> ; separated list.

Methods with non-Uniface Class names

By default UD5 uses the name which you define in Uniface as the signature name as the class name. However Java classes may be named differently to this, especially if they are contained in a package, e.g.:

com.sun.enterprise.appclient.Main

UD5 supports these names by using the Implementation specific properties of the signature definition in Uniface, e.g.:

$Revision: 1.9 $ $Date: 2014/11/05 02:24:16 $[go to top]