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 7.0 uses Java 5. If the policy is compiled
with Java 6, it cannot work.
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 dependencies to your build path: You
must specify each JAR file that is included in the RAM Java API (in
the ramclient.zip file) individually in the class
path. The name of the JAR file name in the class path must include
the full name, for example: org.eclipse.emf.ecore.xmi_2.4.1.v200902171115.jar.
- To import files from the ramclient archive,
you can download the archive from the Extensions page. To open that
page, click the Help icon and then click Extensions.
- Extract the ram.client archive
contents to add the required files to your new project.
- Right-click the project and select .
- Navigate to where you extracted the ramclient.zip file
and select all the com.ibm.ram.common,ramclient, jaxb,
and org.eclipse JAR files. You must
include the following JAR files:
com.ibm.ram.common
ramclient
jaxb-api
jaxb-impl
org.eclipse.emf.common
org.eclipse.emf.ecore.xmi
org.eclipse.emf.ecore
org.eclipse.equinox.common
org.eclipse.osgi
In V 7.5 and earlier, you must add the following JAR
files to your class path:
- 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.
When
you save your package as an Eclipse project, you must also include
these JAR files, which are required for using the Rational Asset Manager
Java APIs in a policy:
- On WebSphere Application Server:
- axis.jar
- jaxrpc.jar
- ramclient.jar
- saaj.jar
- wsdl47-1.5.1.jar
- On Tomcat:
- ramclient.jar
- org.eclipse.equinox.common (for IProgressMonitor)
In version 7.5.0.1 and later, you can include multiple
JAR files (such as ramclient.jar and the policy JAR) 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.