skip to main content
Corticon Server: Integration & Deployment Guide : Packaging and deploying Decision Services : Using Server API to compile and deploy Decision Services
 

Try Corticon Now

Using Server API to compile and deploy Decision Services

Corticon provides a Java API that can be used in custom code to compile, deploy, and manage Decision Services. The API can be used in code running an in-process Corticon Server, or can be used to manage a remote Corticon Server through the server's SOAP interface.

Using the Test Server Scripts

The test server scripts provide fully-functional commands that are structures in the Server source file [CORTICON_HOME]\src\CcServerApiTest.java. For example, to add a Decision Service that uses the Enterprise Data Connector, start the server, and then start the Axis test batch file [CORTICON_HOME]\Server\bin\testServerAxis.bat.
Enter 100 to list the 100 series of commands.
Figure 306. testServerAxis.bat 100 commands
Enter 103 named Add a Decision Service (9 parameters).
Enter the arguments as prompted invokes the addDecisionService() method. The arguments used by this method include:
1. Decision Service Name
2. Decision Service path
3. Dynamic Reload setting (also known as auto-reload)
4. Maximum Pool Size (note that Minimum Pool Size was deprecated in version 5.5. See Multi-threading, concurrency reactors, and server pools for more information.
5. Message Structure Type
6. Database Access Mode (<null>, R, RW) If you skip it, the Server defaults to <null> -- EDC for this Decision Service is turned off
7. Return Entities Mode (ALL, IN) If you skip it, the Server defaults to ALL)
8. Database Access Properties Path
9. Database Cache (true, false)

Looking at the snippet source code for addDecisionService9()


public void addDecisionService9() throws CcException
{
InputParameters lInputParameters = new InputParameters();
lInputParameters.getBaseInformation(1);
lInputParameters.getRuleAssetPath();
lInputParameters.getAutoReload();
lInputParameters.getMinPoolSize();
lInputParameters.getMaxPoolSize();
lInputParameters.getMessageStructureType();
lInputParameters.getDatabaseAccessMode();
lInputParameters.getDatabaseAccessReturnEntityMode();
lInputParameters.getDatabaseAccessPropertiesPath();
lInputParameters.getDatabaseAccessCacheEnabled();

String lstrResult = null;
if (ibRunInprocess)
{
Object[] lars = lInputParameters.getArgumentList();

Properties lpropDeploymentOptions = new Properties();

lpropDeploymentOptions.put
(ICcServer.PROPERTY_AUTO_RELOAD, (Boolean)lars[2]);
lpropDeploymentOptions.put
(ICcServer.PROPERTY_MIN_POOL_SIZE, (Integer)lars[3]);
lpropDeploymentOptions.put
(ICcServer.PROPERTY_MAX_POOL_SIZE, (Integer)lars[4]);

if ((String)lars[5] != null)
lpropDeploymentOptions.put
(ICcServer.PROPERTY_MESSAGE_STRUCTURE_TYPE, (String)lars[5]);

if (lars[6] != null)
{
lpropDeploymentOptions.put
(ICcServer.PROPERTY_DATABASE_ACCESS_MODE,
(String)lars[6]);
lpropDeploymentOptions.put
(ICcServer.PROPERTY_DATABASE_ACCESS_RETURN_ENTITIES_MODE,
(String)lars[7]);
lpropDeploymentOptions.put
(ICcServer.PROPERTY_DATABASE_ACCESS_PROPERTIES_PATH,
(String)lars[8]);
lpropDeploymentOptions.put
(ICcServer.PROPERTY_DATABASE_ACCESS_CACHING_ENABLED,
(Boolean)lars[9]);
}

getInprocessCcServer().addDecisionService
((String)lars[0], (String)lars[1], lpropDeploymentOptions);
lstrResult = "COMPLETE";
}
else
{
String lstrMethodName = "addDecisionService9";
Object[] lars = lInputParameters.getArgumentList();
lstrResult = CcMessageHandler.executeRPC
(istrApacheAxisCorticonAdminUrl, lstrMethodName, lars);
}

System.out.println(lstrResult);
}

Using the APIs to compile a Decision Service

The following code snippet is a framework of Java code that uses the method precompileDecisionService() in the ICcServer interface.
package com.progress.corticon.util;

import com.corticon.eclipse.studio.deployment.swing.CcDeployFactory;
import com.corticon.eclipse.studio.deployment.swing.ICcDeploy;

public class Example {

public static void main(String[] args) {
// TODO Auto-generated method stub
String strERFPath = "<path>/<file.erf>";
String strServiceName = "Example";
String strOutputPath = "C:/Temp";
boolean bOverwriteFile = true;

ICcDeploy d = CcDeployFactory.newDeployment();
try {
d.precompileDecisionService
(strERFPath,
strServiceName,
strOutputPath,
bOverwriteFile);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
For more examples of code that uses Corticon API methods to compile rules, see Corticon Knowledgebase article 57671.