Creating a modification plug-in for WebSphere Service Registry and Repository

Learn how to create, deploy, and configure WebSphere Service Registry and Repository plug-ins that enable you to execute custom code.

Marco Metting (mmetting@de.ibm.com), IT-Specialist, IBM

Marco Metting is an IT Specialist on the IBM Software Services for WebSphere team in Germany. His technical specialties include advising customers on how to implement especially WebSphere Service Registry and Repository and WebSphere Process Server. He is involved in several customer projects focusing on SOA governance and SOA infrastructure. You can contact Marco at mmetting@de.ibm.com.



22 July 2009

Also available in Spanish

Introduction

IBM® WebSphere® Service Registry and Repository (hereafter called Service Registry) lets you invoke plug-ins that enable custom code to be executed in order to automate tasks or do additional processing of data based on actions taking place. Actions can include creating, updating, or deleting an object; transitioning an object from one life cycle state to another; making an object governable; or removing governance from an object. Based on the action, different plug-ins are called to perform validations, modifications, or notifications before or after the user's interaction with an object stored in Service Registry. There are three plug-in types:

Modification plug-in
Invoked after a user's interaction with an object, but before committing the changes to the Service Registry database, so that additional changes can be processed. If errors occur during the process of modification, the entire transaction is rolled back.
Notification plug-in
Invoked after changes are committed to the Service Registry database. These plug-ins are not used to change the content of the Service Registry, but to perform notification tasks or log variances.
Validation plug-in
Invoked before the actions are processed to ensure the validity of certain registry transactions and to enable modification of object attributes.

These three plug-in types come in two flavours, for objects set under governance, and objects not set under governance. In this article, you'll learn how to create, configure, and deploy plug-ins in Service Registry. This process will be explained using a sample modification plug-in, but the same principles also apply to Notification and Validation plug-ins.

Sample scenario

Many customer implementations of Service Registry have to store objects of custom type, based on a custom metadata model consisting of objects, object attributes, and relationships among objects. The scenario in this article focuses on a Service Registry object of a custom type with two custom properties named minorVersion and majorVersion. During a search on two identically named artifacts within Service Registry, only the default properties are displayed, not the custom ones, so it is a good idea to fill default properties with the values of custom properties in order to find the correct artifact. Therefore the values of the two properties minorVersion and majorVersion should be concatenated and stored in the default property version.

Sample scenario
Sample scenario

In order to implement a modification plug-in that concatenates the two custom property values and stores the result in the default property version, you need to develop a custom Java™ class that implements the interface com.ibm.serviceregistry.ServiceRegistryModifier, using Service Registry V6.2.0 or later. ServiceRegistryModifier implements three methods:

Table 1. ServiceRegistryModifier methods
Method NameDescription
create()Invoked by creating an entity in Service Registry
update()Invoked by modifying an entity already in Service Registry
delete()Invoked by deleting an entity already in Service Registry

Each method must return a status object named ServiceRegistryStatus to indicate the completion of the action taking place in the method and describing the success of the modification plug-in. In the sample scenario, the two methods create() and update() will be implemented. Here is a depiction of the solution:

Solution

Process overview

  1. Start WebSphere Integration Developer and create a new Application Client Project.
  2. Configure the Java build path for the project.
  3. Create the plug-in implementation.
  4. Export the plug-in.
  5. Import the plug-in JAR file into Service Registry.
  6. Configure Service Registry to invoke the plug-in.

1. Start WebSphere Integration Developer and create a new Application Client Project

Develop the custom Java class to implement the modification plug-in:

  1. Start WebSphere Integration Developer.
  2. Select Window => Open perspective => Other => J2EE to switch to the J2EE perspective:
    Switch to the J2EE perspective
  3. Select New => Project to create a new J2EE application client project:
    Create a new J2EE application client project
  4. Enter a name for the project and click Finish. In this example, the target runtime is WebSphere Process Server V6.1, but you can also use WebSphere Application Server V6.2.

2. Configure the Java Build Path for the project

As mentioned above, in order to develop a modification plug-in, the created class must implement the interface com.ibm.serviceregistry.ServiceRegistryModifier with all of its methods. In order to resolve all necessary imports and dependencies, you must configure the Java build path for the project. Therefore two JAR files named sdo-int.jar and ServiceRegistryClient.jar are delivered with Service Registry in the root directory of the Service Registry installation .

  1. Right-click the project Sample Modification Plug-in in the Project Explorer and select Build path => Configure build path.
  2. Select the Libraries tab and click Add external JARs:
    Add external JARs
  3. Select ServiceRegistryClient.jar and sdo-int.jar from the Service Registry installation root directory and click Open.
  4. Click OK to end the Build path configuration.

3. Create the plug-in implementation

  1. Right-click on the project Sample Modification Plug-in in the Project Explorer and select New => Class.
  2. Enter the appropriate information in the dialog:
    Enter appropriate information
  3. You can directly add the interface, which should be implemented by the class interfaces: Add => Type => ServiceRegistryModifier => Add => OK:
    Add the interfaces

As you can see, all necessary methods are generated by the wizard. Now you can start inserting the custom code for the modification plug-in. In our example we only need to implement the methods create() and update(). Download the plug-in sample provided with the article for further information about the implementation and logic of the plug-in. The URIs in the code sample should match your Service Registry configuration, especially the business model.

4. Export the plug-in

After developing the necessary custom code for the plug-in, you need to export it into a JAR file, which you can then load into Service Registry and invoke:

  1. Right-click on the project in the Project Explorer and select Export => App Client JAR file.
  2. Browse the destination for the export and click Finish:
    Browse the destination for the export

5. Import the plug-in JAR file into Service Registry

You can use the Web UI of Service Registry to import the plug-in's JAR file:

  1. Open a browser window and log in to Service Registry.
  2. Select the Configuration perspective and click Go.
  3. In the navigation tree, select Active Configuration Profile => Plug-ins => JARs:
    Select Active Configuration Profile
  4. Click Load JAR Plug-in in the content pane.
  5. Click Browse and specify the path to your plug-ins JAR file. Enter a name for the plug-in and click OK:
    Specify the path and name for the plug-in

    You should receive a message saying The upload was successful.

6. Configure Service Registry to invoke the plug-in

After loading the plug-in into your Service Registry configuration, you have to enable the plug-in so that Service Registry can invoke it when needed:

  1. In the navigation tree, click on Modification properties, since this is Modification plug-in:
    Modification properties
  2. Open the Modification properties plug-in by clicking on the name.
  3. Find the line beginning with modifiers=
  4. Enter the package name of the plug-in's Java class combined with the Java class name:
    Enter the package name of the plug-in's Java class combined with the Java class name
  5. Click Apply and then OK.

Service Registry is now configured to invoke the plug-in.

Conclusion

In this article, you've learned about the different types of Service Registry plug-ins, implemented a custom plug-in, and configured Service Registry to invoke it. You can now go on to develop different types of plug-ins yourself, and use the downloadable sample to invoke custom plug-ins for execution by Service Registry.


Download

DescriptionNameSize
Code sampleplug_in_sample.zip11 KB

Resources

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into WebSphere on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=416173
ArticleTitle=Creating a modification plug-in for WebSphere Service Registry and Repository
publish-date=07222009