Modules:Java Extension Points/Technical Specification
Contents |
Introduction
In this document are described all the developments needed to properly implement the Java Extension Points module.
Module Definition
Java Extension Points
- Name: Java Extension Points
- Java Package: eu.practics.javaextensionpoints
- DB Prefix: JEXP
- Commercial: No
- Dependencies:
- Openbravo 3 - From 3.0PR14Q3.2
Java Extension Points
New Window
Java Extension Points
This window can only be accessed with the System Administrator role. In this window is configured all the extension points that can be executed. Each module that fires an extension points must include a record in this window.
- Header
- JEXP_Extension_Point table. Includes all the extension point definitions as well as the description and the owner module.
- Java Classes
- JEXP_Extension_Point_Class table. Includes all the Java classes that must be executed when the extension is fired.
JavaExtensionPointBase abstract class
This class must be implemented by the modules that use any extension point.
Execute
This method is called when the extension point is fired. It only has one parameter. This parameter is an instance of the JavaExtensionPointParams class, which contains all the parameters given by the extension point.
For example: We want to add one unit to the unit price given by the extension point.
public JavaExtensionPointParams execute(JavaExtensionPointParams params) { // Get the parameter value BigDecimal unitPrice = params.getBigDecimalParameter("UnitPrice"); // Do stuff with the parameter unitPrice = unitPrice.add(BigDecimal.ONE); // Update the parameter value params.addParameter("UnitPrice", unitPrice); return params; }
JavaExtensionPointParams class
This class contains all the parameters needed by a specific extension point.
To add a parameter the method addParameter should be called:
final JavaExtensionPointParams params = new JavaExtensionPointParams(); params.addParameter("UnitPrice", price); params.addParameter("Product", product);
There are several methods to obtain the value of a parameter. All methods return null if the parameter name given doesn't exists. The methods available are:
- getParameter(name): Returns the value as Object
- getStringParameter(name): Returns the value as String
- getBigDecimalParameter(name): Returns the value as BigDecimal
- getBaseOBObjectParameter(name): Returns the value as a BaseOBObject