Creating new scenario functions
Many Apama applications are implemented partially or entirely as scenarios. Apama Studio supplies many pre-packaged scenario functions that can be used in conditions or actions when defining rules for scenarios. In addition, you can define your own scenario functions within Apama Studio.
Note: When you create a new function, you should place it in the project’s default functions directory. This directory is found in the project’s catalogs directory. The function directory has a name in the form <project_name> functions. So, for example, the default functions directory of a project named My_Project will be catalogs\My_Project functions. If you place the function in the default function directory, scenarios created in the project will automatically find them and they will be available in Event Modeler when you are displaying the scenario.
To define a new scenario function:
1. If you are in the Apama Workbench perspective, click the Show All Folders icon if necessary to display the enhanced view that shows all the project’s resources. 2. In the Project Explorer view or the Workbench Project view, open the catalogs folder of the project where you want to add the EPL file.
3. Right click the functions folder within the catalogs folder. It will have a name such as MyProject functions. Select New > Scenario Function.
In the
Workbench Project view you can also select the functions folder and click the
New Scenario Function button
.
4. In the New Scenario Function wizard, specify information for the following fields:
a. The Containing Folder field is the folder where the function definition file will be saved; by default this is the functions folder you selected in Step 4, but you can select another folder using the Browse button.
b. In the Function Name field enter a unique name for the function. By convention, this should be in uppercase.
c. In the Display Name field enter the name that will be displayed in the Apama Event Modeler tool. By default this the same as the Function Name but you can change it if you like; it does not need to be unique.
d. In the Return type field specify the type for the value returned by the function.
e. In the Description field specify the descriptive text that will accompany the function in the Apama Event Modeler tool.
5. Click Finish. This generates the definition file for the function and opens the file in the Apama editor.
6. The function definition file is an XML file. To implement the behavior of the function you need add the EPL code to the action statement in the file’s <code> element. In the .fdf file, this section is labeled:
// TODO: put MonitorScript code to implement the function here
After you have added a new scenario function to a project, when you look at a scenario in the project with the Apama Event Modeler, the new function will be included in the Event Modeler’s function catalog associated with the project.
For more information on using functions in scenarios, see
Using Functions in Event Modeler in
Developing Apama Applications in Event Modeler. For more information on the XML format of the function definition file, see
File Definition Formats.
For more information on using functions in scenarios, see "Using functions in Event Modeler" in
Developing Apama Applications in Event Modeler. For more information on the XML format of the function definition file, see
File Definition Formats.
Copyright © 2013
Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.