| ILOG JRules User Guide > Integrating Application Data > Concepts > Web Service Binding > Web Service Request Caching |
Web Service Request Caching |
PREVIOUS NEXT |
Invoking an operation on a distant Web service server may be time-consuming. Therefore, when the result of an operation depends only on its parameter values, you can use a cache mechanism to memorize the previous result of an operation. The following diagrams illustrate how caching works.
In the first diagram, an invocation is propagated to the server to get the value of get(2) when the cache does not contain this value. When the get(2) value is returned, the value is stored in the cache buffer.
In the following diagram, get(1) is evaluated. There is no need to query the result from the web server, as get(1) is a value contained in the cache buffer.
Each invocation is identified in the cache value table by a unique key. The IlrWSInvocationCache interface defines how the key is determined from the information of an invocation, and how the buffer is implemented.
| Note |
| The use of WSDL files in the XOM is now deprecated. We recommend you use the JAX-WS API instead. |
The default mode for the cache is deactivated. To activate cache mode for each operation, you can use an instance of IlrWSDefaultDataDriver, which is the default implementation of IlrWSDataDriver. If you want to implement your own data driver, you can use an instance of IlrWSDataDriver. Both interfaces use the IlrWSInvocationCache interface. You must provide this interface to activate the cache mode.
Then, when the server invokes an operation, it searches the stored result using the input parameter values. If it cannot find a stored result, a SOAP operation is committed to the server.
A default implementation is given with the IlrWSInvocationCacheDefaultImpl class. This class is implemented with a soft reference; that is, it will be cleared if the JVM needs more memory and there are no unreferenced or weakly-referenced objects.
IlrRuleset aRuleset =...; IlrWSDataDriver driver =...; new IlrWSDefaultDataDriver ( aRuleset.getReflect() ); // Activate a method cache IlrDynamicMethod method =...; IlrWSInvocationCache cache = new IlrWSInvocationCacheDefaultImpl (); driver.setInvocationCacheInstanceOnMethod ( cache, method, true );
The cache structure activated for a method can be shared between different instances of the same port type in order to limit memory use.
The following code extract shows how the method IlrWSDataDriver.setInvocationCacheInstanceOnMethod can be used to enable a cache on any execution of a XOM.
IlrRuleset aRuleset =.; IlrWSDataDriver driver =.; new IlrWSDefaultDataDriver ( aRuleset.getReflect() ); // Activate a method cache List methods = ...; driver.setInvocationCacheClass ( methods, "myPackage.MyCacheClass" );
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |