Java and exec Commands

The java command has been added and the exec prog command has been enhanced for JPOs.

The syntax for these commands is as follows:

java CLASS_NAME [-method METHOD_NAME] [ARGS] [-construct ARG];
exec program PROGRAM_NAME [-method METHOD_NAME] [ARGS] [-construct ARG];

where ARGS is zero or more space-delimited strings and ARG is a single string. If the method returns an int, then this is assumed to be the exit code from the method (which has meaning to the ENOVIA Live Collaboration system when used as a trigger program, wizard utility program, etc.). If the method returns an Object, then the exit code is set to zero and the object is serialized and passed back in the program's output stream. Obviously, this serialized object is of no use in the MQL environment, but is very useful in the ENOVIA Studio Customization Toolkit environment (see next section).

The java command takes any class name and finds that class both inside a JPO and outside the ENOVIA Live Collaboration database. The class name must be in its fully mangled form.

The classname selectable can be used on JPO programs to print the classname specified.

The exec program command can be used to avoid having to know the mangled class name. However, the class has to live inside a JPO (no search is made outside the ENOVIA Live Collaboration database).

The -construct clause is used to pass arguments to the constructor. (Note: if more than one argument needs to be passed to the constructor, the -construct clause can be repeated as many times as necessary on a single command). This may be necessary to establish an object's identity. For example, if a JPO named "emxProject" held business logic for managing business objects of type "Project", then this JPO would undoubtedly be derived from the ENOVIA Business Process Services emxDomainObject JPO (which derives from the ENOVIA Studio Customization Toolkit BusinessObject class).

import matrix.db.*;
public class ${CLASSNAME} extends ${CLASS:emxDomainObject} {
  public ${CLASSNAME}(Context context, String[] args) throws Exception
  {
    super(args[0]);
  }
  public int ComputeEndDate(Context context, String[] args) throws Exception
  {
     // do work here to compute this Project's end date?
     return 0;
  }
}

With this assumption, to compute the end date of an existing Project, the following command would be executed inside a Tcl method on the schema type Project:

exec prog Project -method ComputeEndDate -construct ${OBJECTID}

A minor addition was also made to launching methods on a business object so that the term "method" is not overloaded when using a JPO method. The new syntax allows either the keyword "method" or "class" to be used. For a JPO it reads better to use the keyword "class":

exec bus T N R class Project -method ComputeEndDate -construct ${OBJECTID}

Note: As stated earlier, once constructed, an object stays in existence until the transaction is completed. This means subsequent method calls need not supply the -construct clause.