SOA Governance and API Management : CentraSite Developers Guide : Developing Custom Actions : Adding Custom Actions Using APIs : Creating Action Rules : Creating a Rule in a Java Class
Creating a Rule in a Java Class
Perform the following steps to create a rule in a Java class:
To create a rule in a Java class
1. Create a Java action executor class that implements the com.softwareag.centrasite.policy.api.IActionExecutor interface. To view the Javadoc for this interface, see the CentraSite Java API Reference.
Important:  
The Java executor class must return an AssertionResult object that contains the completion code ResultStatus.SUCCESS (if the action was successful) or ResultStatus.FAILURE (if the action failed). There are other possible completion codes (for example, ResultStatus.IN_PROCESS), however, these codes are used by internal processes and are not intended to be returned by user-defined actions. Custom actions that you create must only return a completion code of ResultStatus.SUCCESS or ResultStatus.FAILURE.
2. Create a .zip file that contains the following:
*A folder named lib, which should contain a jar file with the action’s executor class and the external libraries.
*A folder named META-INF, which should contain a property file named assertion.properties, which is the build file for the action. It includes an entry of the following format:
com.softwareag.centrasite.policy.rule.class=<fully_qualified_class_name>
3. Upload the .zip file, as described in Uploading Action Rules to Action Templates.
For example, the sample Java action rule provided in the your CentraSite installation has the following file structure:
*<CentraSite_Install_Dir>\demos\CustomActions\Java\META-INF\assertions.properties
This is the build file for the action. It includes an entry of the following format:
com.softwareag.centrasite.policy.rule.class=<fully_qualified_class_name>
*<CentraSite_Install_Dir>\demos\CustomActions\Java\src\com\softwareag\demo\actions\UniqueNameChecker.java
This is the sample source file for the action executor. You can modify this file as needed and compile it using the build file.
*<CentraSite_Install_Dir>\demos\CustomActions\Java\build_demos_customer.xml
This build file has the default target “zip”, which will compile the Java file, build a jar out of it and pack it as a zip file.
*<CentraSite_Install_Dir>\demos\CustomActions\Java\uniquenamechecker.zip
You create this .zip file by executing the ant command ant -f build_demos_customer.xml.
Example:
C:\SoftwareAG\CentraSite\demos\CustomActions\Java>ant -f build_demos_customer.xml
This .zip file contains the following components:
*A folder named lib, which contains a jar file with the action’s executor class and the external libraries.
*A folder named META-INF, which contains the property file assertion.properties, which is the build file for the action.
For more information about the sample Java action, see Sample Custom Actions.
Copyright © 2015- 2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback