Using RMI from a Jython Script

The Remote Method Invocation (RMI) Interface of TPAE allows to connect from an external program to TPAE. Using RMI business objects can be red, written and updated by the control of a Jython script. To use RMI Scripting a current version of Jython has to be installed on the system where the script should be executed.

The script then connects to the RMI Port of TPAE which is by default Port 1099 (Maximo up to Version 6) or 13400 (Maximo 7 and higher). This port can be changed using the mxe.registry.port property. The following picture shows the concept:

RMI Base concept

Based on this knowledge we can develope our first RMI Script, which only connects to the MX Server and after that disconnects:

import psdi.util.MXSession as MXSession

session = MXSession.getSession()
session.setHost('192.168.158.135:13400/MXServer')
session.setUserName('maxadmin')
session.setPassword('maxadmin')
session.connect()

# ... Do your stuff here ...

session.disconnect()

One word to the Path “MXServer” in the setHost() function call. This has to be the name, which is provided in the Maximo Properties in the parameter mxe.name. This means, that you can have several RMI listeners for multiple Maximo installations on the same host (e.g. mx.name = MXTest, mx.name = MXProd).

In a second step the script can be extended to correctly handle error situations. To achive this you can utilize the Jython error handling functionality:

try:
# perform some task that may raise an exception

except Exception, value:
# perform some exception handling

finally:
# perform tasks that must always be completed (Will be performed before the exception is # raised.)

The new connection section of the script now looks as follows:

import psdi.util.MXSession as MXSession
from psdi.util import MXException

try:
    session = MXSession.getSession()
    session.setHost('192.168.158.135:13400/MXServer')
    session.setUserName('maxadmin')
    session.setPassword('maxadmin')
    session.connect()

except MXException, conex:
    print 'conex.getErrorGroup()     :',conex.getErrorGroup()
    print 'conex.getErrorKey()       :',conex.getErrorKey()
    print 'conex.getDetail()         :',conex.getDetail()
    print 'conex.getDisplayMessage() :',conex.getDisplayMessage()
    exit

# ... Do your stuff here ...

TPAE Scripting customization points

In this blog I will shortly document the different ways a Jython script can be triggered in TPAE. The following launch points and invocation methods are available to start a script:

Launch points

A launch point is a configuration objects which triggers an automation script if a certain condition occurs. When a launch point is deactivated, the script associated with that launch point does not run. The The following launch point types can be defined in TPAE:

Object Launch Point

  • Execute scripts on MBO events such as init, add, update, or delete (TPAE 7.5)
  • Starting from TPAE 7.6 this kind of Launch Point has a much more fine granular configuration.
  • Execute the script on:
    • Initialize Value: executed when the MBO is initialized
    • Validate Application: executed when the MBO is validated against business rules, but is not yet saved in the Database
    • Allow Object Creation: Indicates whether Maximo business objects can be created.
    • Allow Object Deletion: Indicates whether Maximo business objects can be deleted.
    • Save: executed in the process of saving the MBO. In this case more fine granular specifications about the execution time (before Save, after Save, After Commit) can be made.

Attribute Launch Point

  • Execute scripts based on the change of an attribute. This type of launchpoint is used for field validations or other actions.
  • Starting from TPAE 7.6 this kind of Launch Point has a much more fine granular configuration.
  • Execute the script on:
    • Initialize access restriction: Sets the access level for the attribute’s field. (Example: Read/Write to Read only)
    • Initialize value: Sets the initial value for the attribute’s field.
    • Validate: Checks whether the value in the attribute’s field is valid.
    • Retrieve list: Retrieves a list of valid values for the attribute’s field. For example, in an invoice, you can set up the supplier field to return a list of approved vendors.
    • Run action: Runs an action that is based on the value that is in the field.
  • Example can be found here

Action Launch Point

  • Execute scripts in the context of workflow/escalation actions
  • Execute scripts in the context of a Menu or Button (Sample here)

Custom condition Launch Point

  • Workflow conditions and conditional expressions can be utilized by Custom condition launch point

Other Methods

Manually Run from Scripting Application

  • Run a script without any launchpoint defined. (Sample here)

Remote Method Invocation (RMI)

  • Runs scripts from outside TPAE. See here for further details.

Interfaces (starting from Maximo 7.6)

  • Runs in context of Integration Framework to convert data
1 2 3 4