Groovy plug-ins

Groovy is an extension of the Java programming language. It supports Java-like agile and dynamic programming without having to rebuild the application.

In N4, you can use Groovy code to perform additional tasks, such as recording an additional service event when N4 processes a notice request or gate transaction.

For more information on the Groovy programming language, go to http://groovy-lang.org.

You can use a Groovy code compiler to check your code for errors. For information, go to http://docs.groovy-lang.org/latest/html/documentation/#_compiling_groovy.

Within N4, there are different execution methods for Groovy plug-ins:

To make use of a Groovy hook, you create a Groovy plug-in and name it as per the desired injection point. For example, if you want to inject Groovy code before the tbdunits validations, you should name the Groovy hook TbdUnitValidationGroovyImpl. Sample plug-ins are also available in the Navis N4: SDK documentation.

You can attach:

To attach a Groovy plug-in to an event, check in the Event Types view if the specific event type is notifiable. If it is, go to the General Notices view and create a general notice for the specific event type, where the action to perform is Execute Code. Then, in the designated text field, specify the name of the Groovy plug-in as api.getGroovyClassInstance("<PlugInName>").execute(event), such as api.getGroovyClassInstance("SendWQContents").execute(event).

To attach a Groovy plug-in to a business task, you create the Groovy plug-in in the Groovy plug-ins view (on page 1). Then, in the Gate Configurations view, in the Tran Type or Trk Visit form, click Edit Business Tasks. In the Business Tasks form, select the business task to which you want to attach the Groovy plug-in and select Actions Customize. In the form that opens, the following code to call the plug-in:

def myGroovy = api.getGroovyClassInstance("<Plug-InName>")

myGroovy.execute(inDao)

myGroovy = null

You can use Groovy code injections for TBD unit validations, Navis N4 Mobile Reefer Monitor, and gate workflow transaction manager. For example, the gate operating system (GOS) can run a validation when a truck passes a certain area. In this case, the GOS would run a Web service or JMS message that includes the name of the Groovy plug-in.

To make use of Groovy code injections, you create the Groovy plug-in in the Groovy plug-ins view and then provide the external application with the name of the plug-in to execute.

For more information, see "Groovy Code Injection" in the Navis N4: SDK documentation.

To make use of Groovy jobs, you create the Groovy plug-in in the Groovy plug-ins view and then create a Groovy job that includes the respective plug-in in the Groovy Jobs view (on page 1).

In other words, you can trigger custom code either:

You can test web service calls using Script Runner (Administration DBA Script Runner) or argoserviceTester (Administration Debug argoservice Tester).

You can restrict access to Groovy code and plug-ins using Groovy privileges (on page 1). You can turn Groovy-based functionality for an N4 installation on or off using Groovy settings (on page 1).

For more information, see "Code Extensibility Mechanisms in N4" in the Navis N4: SDK documentation.

For information on the Java API, see the documentation provided under Help Java API Docs.

In some N4 versions, the link to this resource is not working. As a workaround, you can access the Java API docs directly from the N4 footprint installed on your server. From within the N4 application footprint, manually open the index.html file that is located at the following location (you should only see one of the following directory paths, not both):
Navis/sparcsn4/webapps/apex/argo/api/index.html
Navis/sparcsn4/webapps/apex/model/index.html

Notes

In this Section: