Developing custom policies

To use the custom policy review API to write policies, you must first create a policy governor. To add the custom policies, the policy governor must include a reference to each custom policy. You set up a policy governor class and policy implementation, and then add the policy governor to your repository.

Before you begin

Procedure

  1. Set up the project:
    1. Create a Java project for your custom policy. You can use the sample policy governor and the policies in the SampleGovernor.jar file to get started by importing them into your project and modifying them to create custom policies.
    2. Import the sample policy governor into the /src subdirectory of the project, by right-clicking the project and selecting Import.
    3. Select Archive File and click Next.
    4. Click Browse and select the SampleGovernor archive file.
    5. Click Finish. The contents are added to your new project.
  2. Add the dependency to the ramclient.jar file to your build path.
    1. Right-click the project and select Build Path > Add External Archives.
    2. Navigate to where you extracted the ramclient.zip file and select the ramclient.jar file.
  3. Write the policies:
    1. You can create a policy with or without extending one of the supplied policies, such as MyPolicy. You can use methods in a supplied policy file and change the methods. For example, in the test() method, you can approve or fail an asset policy test depending on a specific set of asset type details for your governance model.

      For information on what APIs you can use in writing custom policies, see APIs to use in custom policies

      Note: You can store policies in a map and get a policy by ID; for example, private Map policies;. To retrieve a policy from the map, enter the policy ID in the getPolicies().get(id) method.
    2. In the Governor class, add a reference to each new policy. Your Governor class must include a reference to each custom policy in the policy governor. For example, for MyPolicy, these lines are added to the MyGovernor class (in MyGovernor.java):
      	//My XML Policy
      		Policy policy = new MyPolicy(this);
      		policies.put(policy.getID(), policy);

      You can use the Rational Asset Manager Java APIs to work with the current asset and other assets within a custom policy. For examples on how to use the Java APIs, see: Using Rational Asset Manager Java API. Examples and additional information about the APIs you can use are on the custom policies wiki page on jazz.net

  4. Install the policies. You package your custom policies by exporting the project as a .jar file and then adding it as a new policy extension.
    1. Export the project as a .jar file.

      You can include multiple .jar files (such as any other required .jar files, and the policy .jar file) as a .zip file when you upload a policy.

    2. Log in to the product as a repository administrator.
    3. On the Administration page, click Custom Extensions.
    4. Add a new policy extension.
    5. Enter the fully qualified class name (package and class) of your policy governor.
    6. Browse to the .jar file that you exported in step 4a. Your policy is available to use in a lifecycle or policy process.
    For additional instructions on how to add your governor, see Defining external policy governors.

What to do next

Test and debug your policy. For instructions, see Testing and debugging policies.

Feedback