Custom Module Sample Custom Registry Modules

Example 6. 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 setCounterCounter counter; public Counter newCounter; interface Counter { public long getRestart; public void setRestartlong restart; } } public void loadConfigurable config { System.out.printlnMY MODULE CONFIG READING; RestartConfig restartConfig = RestartConfig config.narrowRestartConfig.class; if restartConfig = null { counter = restartConfig.getCounter; if counter == null { counter = restartConfig.newCounter; restartConfig.setCountercounter; } try { restart = counter.getRestart; } catch Exception e { counter.setRestart0; } } } public void init { System.out.printlnMY MODULE STARTED; counter.setRestart++restart; System.out.printlnUDDI REGISTRY: number of restarts = + restart; } public void destroy { } } Page 535

3.2.2. Custom Module Sample

Example 7. Example configuration file for custom module ?xml version=1.0 encoding=UTF-8? config name=myconf module loader=com.systinet.example.module.ExampleModule name=MyModule module config

3.3. Interceptors

Interceptors can monitor or modify the requests and responses of Oracle Service Registry as shown in Figure 9 . They are at the lowest level of Oracle Service Registry API call processing, and can be used for: • Logging requests. See Section 3.3.2, Logging Interceptor Sample . • Computing message statistics. See Section 3.3.3, Request Counter Interceptor Sample . • Changing request arguments adding default values • Prohibiting some API calls Figure 9. Registry Interceptors There are three types of Oracle Service Registry interceptor: • Request Interceptor Monitors or modifies request arguments, stops processing requests, or throws an exception. This type of interceptor accepts a called method object and its arguments. • Response Interceptor Monitors or modifies response values or throws an exception. This interceptor accepts a called method object and its response value. • Exception Interceptor Monitors, modifies, or changes an exception. This interceptor accepts a called method object and its thrown exception. If you want to directly access the Oracle Service Registry API see Section 3.2.1, Accessing Registry APIs for more information.

3.3.1. Creating and Deploying Interceptors

To create an Interceptor, follow these steps: 1. Write a class that implements the org.systinet.uddi.interceptor interface. 2. Copy your interceptor implementation class to the directory REGISTRY_HOMEappuddiservicesWasp- infclasses . 3. Create a configuration file for your interceptor in the REGISTRY_HOMEappuddiconf directory. See Section Interceptor Configuration . Page 536

3.3.1. Creating and Deploying Interceptors

4. Shutdown Oracle Service Registry, delete the REGISTRY_HOMEwork directory, and restart the registry.

3.3.2. Logging Interceptor Sample

This section includes step-by-step instructions how to create the interceptor that logs requests. To create a logging interceptor: 1. Create Java file LoggingInterceptor.java as shown in Example 8, Logging Interceptor Class . 2. Compile the interceptor using Java -classpath REGISTRY_HOME\app\uddi\services\Wasp- inf\lib\application_core.jar; REGISTRY_HOME\lib\wasp.jar LoggingInterceptor.java 3. Copy LoggingInterceptor.class to the REGISTRY_HOMEappuddiservicesWasp-infclassesinterceptor directory. 4. Create the configuration file Myinterceptor.xml in REGISTRY_HOMEappuddiconf folder. For details, please see Example 9, Logging Interceptor Configuration File . 5. Shutdown Oracle Service Registry, delete the REGISTRY_HOMEwork directory, and restart the registry. Page 537

3.3.2. Logging Interceptor Sample