Apache > Incubators > Imperius
 

SPL Editor Guide

Introduction

The SPL Policy editor is an Eclipse based text editor that expedites authoring and validation of SPL policies. The SPL editor greatly simplifies the process of creating policies with the help of policy templates, auto-completion and expression list prompting. SPL editor also allows easy import and export of policies.

Some of the salient features of the SPL Editor include:

  • Policy authoring
  • Policy Import/Export
  • Customizable syntax highlighting.
  • Policy outline view for quick policy navigation
  • Error location indication
  • Automatic syntax and semantic validation
  • Statement auto-completion.
  • Policy Execution.
  • Policy execution simulation

Getting Started

Prerequisites

To use the JavaSPL editor you will first need to download and install eclipse platform 3.3 or later , EMF 2.3 or later and the ANTLR v2 plugin

Download or build the SPL Editor

Download and extract SPLEditor.zip to a temporary location. You can also Build the editor from source

Install the Editor

To install the editor simply unzip SPLEditor.zip into your ECLIPSE_HOME and restart Eclipse

Using the Editor

Create SPL Project

  1. Launch Eclipse and Select File / New / Project from the Eclipse main menu and expand the Policy folder. Icon
  2. Select the SPL Project and click Next .
  3. Enter a Name for your project
  4. Your new SPL Editor is now ready for use

Create a SPL Policy

  1. Right-click on the project in the Navigator view
  2. Select New -> File to display the New File dialog box, expand the Policy folder and Select SPL Policy option and click Next . Icon
  3. Enter a name for the source file in the File name field and click Next
  4. Choose from one of the built-in policy templates and click Finish
  5. Replace the < > template sections of the generated policy appropriately
  6. Add the jar file that contains the anchor classes imported by the policy to the project classpath
  7. Save the policy (Ctrl+s)

Import a SPL Policy

  1. Right click on the SPL project where the policy is to be imported and click on Import . Optionally, you could do File -> Import Icon
  2. Select Policy -> SPL Policy and click Next
  3. Make sure the Policy Binding is set to Java and browse the local file system for the directory where the policy file resides Icon
  4. A list of polices will be displayed in the text box below. Select the ones you would like to import
  5. Set the Destination to project where the policy needs to be imported
  6. Click on Finish
  7. Double-click on the policy to open it into the editor
  8. Add the jar file that contains the anchor classes imported by the policy to the project classpath

Editing a SPL Policy

Icon

  • To access anchor object members, after the instance name, simply type ‘.’ and a drop down list with the properties and methods will appear.
  • To access built-in and custom operators and actions list type Ctrl + space. A drop down list with all supported operators and actions will appear.
  • An outline view on the right enables users to quickly navigate the policy file.
  • If syntax or semantic errors exist then they will be displayed in the problems pane at the bottom.

User-Defined Expressions

SPL allows users to add custom actions or expressions to the runtime. The Editor needs to be configured to recognize these custom expressions.

  1. Right click on the project and select Properties . This opens a dialog box.
  2. Expand the policy option and either select add custom jar or delete the custom jar to the project
  3. Browse the local filesystem and select the jar file that contains the custom expressions classes and the customexpressions.properties.(Refer the User Guide). Icon
  4. The list of classes inside the jar will get displayed. Click Apply to add the jars to the classpath and register the custom expressions.
  5. Clicking Ctrl + space in the policy section should display the newly added custom expressions in the drop-down list
  6. To delete the custom expressions from the runtime use the Delete Custom Jar option in the Properties panel. Icon

Customizing the SPL Editor

Icon

The SPL Policy editor allows users to customize the syntax highlighting. From the main menu select Window->Preferences to show preferences dialog box. Expand the Policy node on left and click on Policy Editor .