Generate a Policy Stub

Generate a policy stub with a python script.

To generate a policy stub:

  1. Navigate to <ApicsGatewayInstaller.zip extracted folder>/policyTemplate/PolicyTemplate.zip

  2. Extract the contents of the PolicyTemplate.zip into a local folder.

  3. Run the following Python script.

    python PolicyTemplate.py -t {targetDirectory} -p {policyName} -s sdk [-h|--help]
When you run the script, ensure that:
  • the target directory does not exist.

  • the policy name could be used in a pathname / filename and also as part of a Java class / method name.

  • the SDK parameter points to a directory that contains the JARs that the build and runtime relies on.

The script performs these actions:

  • Creates the files that are required for creating a policy.

  • Creates a directory structure that constitutes a valid Eclipse project that can be imported into the IDE.

  • Checks files for tokens and replaces them appropriately.

    • Checks for tokens within files and filenames and renames.

    • Uses a template of files and directories partially made up of reserved names like policyname and POLICYNAME.

    • Generates .classpath file, which is specific to Eclipse, from scratch because its contents depend on what is in the SDK folder. As the number of SDK JARs can change, tokenization cannot generate this file.

    Tokens are case sensitive to meet the lowercase for Java package name and uppercase for class name requirements.