Go to primary content
Agile Product Lifecycle Management SDK Developer Guide - Developing PLM Extensions
Release 9.3.6
E71153-01 ,Oracle and/or its affiliates. All rights reserved.
  Go To Table Of Contents
Contents

Previous
Previous
 
 

C Groovy Implementation in Event Framework

This appendix describes the Groovy scripting language and sources of information about this tool. Other topics addressed, include procedures to start a script, access the SDK using scripts, and sample use cases.

C.1 What Is Groovy?

Groovy is an object-oriented programming language that can be used as a scripting language for the Java Platform.

C.1.1 Sources of Information

World Wide Web provides links to many sites that offer information about Groovy. Publishers and vendors of the print media also offer information on this tool. A few are listed below.

  • From World Wide Web:

    • Groovy Home - Provides links to documentation, downloads, tutorial, user guide, Eclipse plugin examples, advanced usage guide, and other sites maintained by Groovy Home (http://groovy.codehaus.org/)

  • From publishers and vendors:

    • Publisher: Manning Publications - Groovy in Action by Dierk Koenig, Andrew Glover, Paul King, and Guillaume Laforge

    • Publisher: Morgan Kaufmann - Groovy Programming: An Introduction for Java Developers by Kenneth Barclay and John Savage

C.1.2 Script PX or Java PX?

Scripts are suitable for rapid development and deployment of applications with simple business logic. They empower Agile PLM Administrators and power users to develop extensions unique to their requirements and make rapid modifications when necessary. Scripts are not suitable for developing complex applications with performance critical data structures.

Use scripts to:

  • Automate functions with simple business logic such as data validation, notification, or defaulting field values

  • Implement unique customization for existing applications

  • Build extensions to existing systems

  • Rapid prototyping

  • Write test use cases

C.2 Event Framework Implementation

Event framework implementation requires running the scripting engine. Key implementation considerations are summarized below.

C.2.1 Key implementation considerations

  • The scripting engine runs inside the Java 2 Platform Enterprise Edition (J2EE) on the Agile PLM server and is based on the Groovy language.

  • Groovy is fully embedded in Event framework.

  • Groovy is the only supported scripting language.

  • Script codes are currently stored in CLOB fields in the Agile PLM database.

  • Event Script objects (Event Script PX handlers) that you develop are text files that are deployed from the Event Management Node by selecting Event Management > Event Handlers in Java Client.

  • Scripts can call the Script API and Agile SDK.

  • The Agile PLM Administrator Guide provides both background information and sample procedures to understand and manage Events.

C.2.2 Starting a Script

  1. Use void invokeScript(IBaseScriptObj obj) to start your script. InvokeScript is script's starting point of the execution and IBaseScriptObj is the base interface for all Event Script Objects.

  2. The run time type of the Obj is dynamically resolved based on the type of Event that invoked this script. For example, if the script is invoked on a Create Event, then ICreateScriptObj is dynamically resolved as the type of Obj at run time. You can invoke any method defined on ICreateScriptObj and its super-interfaces on the instance of this Obj.

  3. Use IAgileSession getAgileSDKSession() to access the SDK session and invoke SDK functions.

  4. Use AgileDSLException to return ”exception” information from scripts.

C.2.3 Accessing SDK with Scripts

You can access an SDK session and Java PX Event object when writing SDK programs in a script.

/*** Returns agile SDK session.* @return agile SDK session* @throws AgileDSLException* if the method fails* @since \@Agile93@
*/public IAgileSession getAgileSDKSession() throws AgileDSLException;

/*** Returns PX eventInfo.* @return PX eventInfo* @throws AgileDSLException* if the method fails* @since \@Agile93@*/public IEventInfo getPXEventInfo() throws AgileDSLException;

C.2.4 Use Cases

You can find Script PX Handler examples for most Event types in "Client-Side Components." These handlers use the Pre/Post triggers and Synchronous/Asynchronous executions and cause different actions when they are invoked.