Developing Apama Applications > Developing Apama Applications in Event Modeler > Creating Blocks > Defining new blocks in Apama Studio > Adding EPL code to the block definition
Adding EPL code to the block definition
In Apama Studio, when you click the Source tab of the block builder editor, Apama Studio displays the block’s definition file. Apama Studio generates and populates all XML elements including the <code> element. The <code> element contains the EPL code that specifies the block’s behavior.
Apama Studio generates skeleton EPL with comments that indicate where to insert your code. The generated code defines the actions listed below. Each of these actions is a field in the event type that defines the block. The block’s scenario will call these actions to accomplish the work of the block. For each action that Apama Studio defines, you can add custom code that specifies the exact behavior you need.
*For each block parameter, there is an action that updates that parameter.
*For each block input feed, there is an action that takes as its arguments the fields of the feed.
*For each block operation, there is an action that performs the operation.
*For each block output feed, there is an action that takes as its arguments the fields of the feed.
*setup action
*intancepreSpawnInit action
*instancePostSpawnInit action
*cleanup action
*start action (for input blocks based on existing event definitions)
*stop action (for input blocks based on existing event definitions)
*send action (for output blocks based on existing event definitions)
In addition to defining these actions, Apama Studio generates sections for adding user-defined monitors, user-defined variables, and user-defined actions. Also, the generated EPL code defines a block-level variable named blockInstanceId$. This variable contains the integer that uniquely identifies the instance of the block among those owned by the containing scenario and all its instances.
To add EPL code to the block:
1. In Apama Studio, in the Project Explorer view, double-click the block’s .bdf file.
2. In the block builder editor, click the Source tab.
3. On the Source tab, enter code as needed only where there is a white background.
Code appears either with a gray background or a white background. Code with a gray background is maintained by Apama Studio and is not editable. The sections of code with a white background are the areas where you add your custom EPL code. Remember to remove the comment flags from lines on which you specify code.
4. Save the project.
As you add and edit code in your block, you have the full range of Apama Studio features as described in Editing Apama files. You also have the full range of navigating features as described in Navigating in Apama files.
Copyright © 2013-2015 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.