In this section, we will show you how to extend BEA AquaLogic Service Registry functionality with your custom modules. Custom modules can be added to BEA AquaLogic Service Registry as shown in Figure 8.
To create and deploy a registry module, follow these steps:
Write a class that implements org.systinet.uddi.module.Module.
Copy your module implementation class to the directory REGISTRY_HOME/app/uddi/services/WASP-INF/classes.
Create a configuration file for the module in REGISTRY_HOME/app/uddi/conf.
Shutdown BEA AquaLogic Service Registry, delete the REGISTRY_HOME/work directory, and restart the registry.
The main class of the custom module must implement org.systinet.uddi.module.Module interface that has these methods:
load() is invoked as the first method of the module. You can put reading of the configuration file in here.
init() is invoked after the load() method. Put the core implementation of your module in here. Write non-blocking code or start a new thread.
destroy() is invoked just before the BEA AquaLogic Service Registry shutdown.
To access the BEA AquaLogic Service Registry API you must obtain the API stub using the getApiInstance() method of the API implementation class. For example to obtain the stub of the Statistics API use:
StatisticsApi statapi = StatisticsApiImpl.getApiInstance();
Mapping between API interface classes and implementation classes is stored in the REGISTRY_HOME/app/uddi/services/WASP-INF/package.xml file. See Table 53, “Mapping API Interface and Implemenation Classes”.
Table 53. Mapping API Interface and Implemenation Classes
Interface class | Implementation class |
---|---|
org.systinet.uddi.client.v1.InquireSoap | com.systinet.uddi.inquiry.v1.InquiryApiImpl |
org.systinet.uddi.client.v1.PublishSoap | com.systinet.uddi.publishing.v1.PublishingApiImpl |
org.systinet.uddi.client.v2.Publish | com.systinet.uddi.publishing.v2.PublishingApiImpl |
org.systinet.uddi.client.v2.Inquire | com.systinet.uddi.inquiry.v2.InquiryApiImpl |
org.systinet.uddi.client.v3.UDDI_Security_PortType | com.systinet.uddi.v3.SecurityApiImpl |
org.systinet.uddi.client.v3.UDDI_Publication_PortType | com.systinet.uddi.publishing.v3.PublishingApiImpl |
org.systinet.uddi.client.v3.UDDI_Inquiry_PortType | com.systinet.uddi.inquiry.v3.InquiryApiImpl |
org.systinet.uddi.client.subscription.v3.UDDI_Subscription_PortType | com.systinet.uddi.subscription.v3.SubscriptionApiImpl |
org.systinet.uddi.client.custody.v3.UDDI_CustodyTransfer_PortType | com.systinet.uddi.custody.v3.CustodyApiImpl |
org.systinet.uddi.replication.v3.ReplicationApi | com.systinet.uddi.replication.v3.ReplicationApiImpl |
org.systinet.uddi.client.wsdl2uddi.v3.Wsdl2uddiApi | com.systinet.uddi.wsdl2uddi.v3.Wsdl2uddiApiImpl |
org.systinet.uddi.client.wsdl2uddi.v2.Wsdl2uddiApi | com.systinet.uddi.wsdl2uddi.v2.Wsdl2uddiApiImpl |
org.systinet.uddi.client.category.v3.CategoryApi | com.systinet.uddi.category.v3.CategoryApiImpl |
org.systinet.uddi.client.taxonomy.v3.TaxonomyApi | com.systinet.uddi.taxonomy.v3.TaxonomyApiImpl |
org.systinet.uddi.statistics.StatisticsApi | com.systinet.uddi.statistics.StatisticsApiImpl |
org.systinet.uddi.admin.AdministrationUtilsApi | com.systinet.uddi.admin.AdministrationUtilsApiImpl |
org.systinet.uddi.permission.PermissionApi | com.systinet.uddi.permission.PermissionApiImpl |
org.systinet.uddi.group.GroupApi | com.systinet.uddi.group.GroupApiImpl |
org.systinet.uddi.account.AccountApi | com.systinet.uddi.account.AccountApiImpl |
org.systinet.uddi.configurator.ConfiguratorApi | com.systinet.uddi.configurator.cluster.ConfiguratorApiImpl |
This section includes step-by-step instructions how to create a registry module that counts the number of restarts of BEA AquaLogic Service Registry and saves the result to a configuration file.
Follow these steps:
Create Java file ExampleModule.java as shown in Example 7
Compile the module using java -classpath "%REGISTRY_HOME%\app\uddi\services\WASP-INF\lib\application_ core.jar; %REGISTRY_HOME%\lib\wasp.jar" ExampleModule.java
Copy all module classes (ExampleModule.class, ExampleModule$RestartConfig$Counter.class, ExampleModule$RestartConfig.class) to the REGISTRY_HOME/app/uddi/services/WASP-INF/classes/com/systinet/example/module directory.
Create the configuration file mymodule.xml in REGISTRY_HOME/app/uddi/conf folder. For details, please see Example 8.
Shutdown BEA AquaLogic Service Registry, delete the REGISTRY_HOME/work directory, and restart the registry.
The number of restarts will be printed in the window console in which you started BEA AquaLogic Service Registry. See also the configuration file of the module where a new element counter is created.
Example 7. ExampleModule.java
package com.systinet.example.module; import org.idoox.config.Configurable; import org.systinet.uddi.module.Module; public class ExampleModule implements Module { private long restart = 0; private RestartConfig.Counter counter; interface RestartConfig { public Counter getCounter(); public void setCounter(Counter counter); public Counter newCounter(); interface Counter { public long getRestart(); public void setRestart(long restart); } } public void load(Configurable config) { System.out.println("MY MODULE CONFIG READING"); RestartConfig restartConfig = (RestartConfig) config.narrow(RestartConfig.class); if (restartConfig != null) { counter = restartConfig.getCounter(); if (counter == null) { counter = restartConfig.newCounter(); restartConfig.setCounter(counter); } try { restart = counter.getRestart(); } catch (Exception e) { counter.setRestart(0); } } } public void init() { System.out.println("MY MODULE STARTED"); counter.setRestart(++restart); System.out.println("UDDI REGISTRY: number of restarts = " + restart); } public void destroy() { } }