Logging Interceptor Sample Interceptors

Example 8. Logging Interceptor Class package interceptor; import org.idoox.config.Configurable; import org.idoox.wasp.WaspInternalException; import org.idoox.wasp.interceptor.InterceptorChain; import org.systinet.uddi.interceptor.ExceptionInterceptor; import org.systinet.uddi.interceptor.RequestInterceptor; import org.systinet.uddi.interceptor.ResponseInterceptor; import org.systinet.uddi.interceptor.StopProcessingException; import java.lang.reflect.Method; public class LoggingInterceptor implements RequestInterceptor, ResponseInterceptor, ExceptionInterceptor { public void loadConfigurable config throws WaspInternalException { no initialization required } public void destroy { no destroy required } public void interceptMethod method, Object[] args, InterceptorChain chain, int position throws StopProcessingException, Exception { System.out.printlnrequest: + method.getName; } public Object interceptMethod method, Object returnValue, InterceptorChain chain, int position throws Exception { System.out.printlnresponse: + method.getName; return returnValue; } public Exception interceptMethod method, Exception e, InterceptorChain chain, int position { System.out.printlnexception: + method.getName; return e; } } Page 538

3.3.2. Logging Interceptor Sample

Example 9. Logging Interceptor Configuration File ?xml version=1.0 encoding=UTF-8? config name=MyInterceptorConfig UDDIInterceptorInstance name=LoggingInterceptorInstance instancePerCall=false className=interceptor.LoggingInterceptor UDDIInterceptor name=LoggingInterceptor instanceName=LoggingInterceptorInstance interceptorChain=inquiry_v3 request=true response=true fault=true config Interceptor Configuration The configuration file must be present in the REGISTRY_HOMEappuddiconf directory. For details please see Example 9, Logging Interceptor Configuration File . Interceptors are called in the same order as they appear in the configuration file. • config name - the unique unambiguous name of the configuration. • UDDIInterceptorInstance - contains information about the implementation class and its instantiation. • name - The name of interceptor instance. This name is used as a link to the UDDIInterceptorinstanceName section of the configuration. • instancePerCall - If the instancePerCall attribute is set to true, then the class will be instantiated once per API call. Otherwise, this interceptor instantiates only once for all calls. • className - name of the class that implements the interceptor. • UDDIInterceptor - The UDDIInterceptor contains references to UDDI Interceptors and their types. • name - name of the interceptor. • instanceName - this attribute contains the name of the UDDIInterceptorInstance section of the configuration file. • interceptorChain - UDDIInterceptorChains are defined for each API in their configuration files. This attribute contains a reference to the required API. • request - when set true, the interceptor catches requests. • response - when set true, the interceptor catches responses. • fault - when set true, the interceptor catches faults.

3.3.3. Request Counter Interceptor Sample

In this section, we will create an interceptor that counts requests and stores the number of request to a configuration file. The steps required to create a Request Counter Interceptor are the same as those in the Section 3.3.2, Logging Interceptor Sample . Page 539

3.3.3. Request Counter Interceptor Sample

Interceptor implementation is shown in Example 10, Request Counter Interceptor Class ; the configuration file is shown in Example 11, Request Counter Interceptor Configuration File . Page 540

3.3.3. Request Counter Interceptor Sample