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
- Set up your workspace.
- Make sure that the Java™ version
of your workspace matches the Java version on the server. For example, IBM® WebSphere® Application Server version 8.0 uses Java 6. If the policy is compiled
with Java 7 or 5, it cannot
work.
- Extract the ramclient.zip file to a folder.
The ramclient.zip file contains a set of required .jar files
for the Rational® Asset Manager Java
API, and is available on the Extensions page
of any deployed Rational Asset Manager server
instance. You can also access it directly from here: http://<hostname>:<port>/ram/ramclient.zip (such
as http://<localhost>:<9080>/ram/ramclient.zip).
Procedure
- Set up the project:
- 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.
- Import the sample policy governor into the /src subdirectory
of the project, by right-clicking the project and selecting Import.
- Select Archive File and click Next.
- Click Browse and select the SampleGovernor archive
file.
- Click Finish. The
contents are added to your new project.
- Add the dependency to the ramclient.jar file
to your build path.
- Right-click the project and select .
- Navigate to where you extracted the ramclient.zip file
and select the ramclient.jar file.
- Write the policies:
- 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.
- 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
- 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.
- 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.
- Log in to the product as a repository administrator.
- On the Administration page, click Custom
Extensions.
- Add a new policy extension.
- Enter the fully qualified class name (package and class)
of your policy governor.
- 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.