Enhanced Class Deployment

J/Foundation now supports an easier mechanism for deploying JUDR classes. While you can continue to use the deployment descriptor to define the SQL statements to register each method in a JUDR class, you can use the Enhanced Class Deployment feature to simplify the registration of each method.

With Enhanced Class Deployment you add a properties file to your jar file that you wish to deploy JUDR's from. This properties file by default is named 'judr.properties' and resides in the root of your JAR file.

Note: You can override the default property file name (or specific multiple files) by adding the following entry in the 'manifest.txt' file for your JAR. This is optional as the default file name 'judr.properties' will be picked up automatically.
judr-registration: judr.custom.properties

For more information see, A manifest file.

Java UDR properties file

The JUDR properties file contains key/value pairs of information that instruct J/Foundation which class files you wish to register and what properties you want when you register them.
Table 1. Properties that can be set in a judr.properties file
Key Value
register-class-name A comma separated list of fully qualified package+class names. Example: com.informix.judr.Strings.
register-class-prefix A prefix that is placed in front of any Java method being registered to make a SQL equivalent. Example: Using "j_" as a prefix to the method toString() makes the SQL function "j_toString()".
register-class-default-properties The SQL properties you want on each method registered. Use a comma separated list of values. Examples: 'parallizable, variant'.
register-class-default-grantee A comma separated list of users that you want access to these JUDR's granted to. Example: 'PUBLIC, informix'

Automatic method registration

When you use the Enhanced Class Deployment to deploy classes. J/Foundation scans each class file. It will determine which methods it will automatically register for you as SQL functions/procedures. It uses the following criteria:
  • The method is public
  • The method is static
  • The return value is void or a mappable type (see Table 2)
  • The parameters to the method are empty or all of them are mappable types (see Table 2)

Once a method in a class is determined to be eligible for automatic registration, J/Foundation will automatically create the "CREATE FUNCTION/PROCEDURE" SQL statement to register the method as a Java UDR using the class-prefix, default-properties specified in the 'judr.properties' file if they are provided. It will also automatically issue a "GRANT" SQL statement to grant access to the JUDR for any users or groups specified in the default-grantee list in the 'judr.properties' file.

Example judr.properties file:
register-class-name: ClassWithNoPackage, com.informix.StringUtilities, \
 com.informix.Utilities
register-class-prefix: j_
register-class-default-grantees: PUBLIC
Example of the SQL executed by J/Foundation for one of the methods found:
CREATE PROCEDURE j_getString(integer) EXTERNAL NAME ‘myjarlabel:com.informix.StringUtilities.getString(int)’ LANGUAGE JAVA;
GRANT EXECUTE on j_getString TO PUBLIC;
Then you can execute the procedure in your SQL session
> execute procedure j_getString(56);
Basic Java types as well as Interval and Blob/Clob types are automatically mapped to the following Informix types.
Table 2. Properties that can be set in a judr.properties file
Java Type Informix Type

Character.TYPE Character.class

CHAR(1)

Boolean.TYPE Boolean.class

BOOLEAN

Integer.TYPE Integer.class

INTEGER

Long.TYPE Long.class

BIGINT

Double.TYPE Double.class

FLOAT

Float.TYPE Float.class

SMALLFLOAT

Short.TYPE Short.class

SMALLINT

StringTYPE String.class

LVARCHAR

java.sql.Date java.util.Date java.sql.Timestamp

DATETIME YEAR TO FRACTION(5)
java.sql.Time DATETIME HOUR TO SECOND
IntervalYM INTERVAL YEAR TO MONTH
IntervalDM INTERVAL DAY TO FRACTION(5)
java.sql.Blob BLOB
java.sql.Clob CLOB

Copyright© 2020 HCL Technologies Limited