Configuración de almacenamiento en memoria caché de mandatos
Los mandatos que se pueden almacenar en memoria caché se almacenan en ésta para poder volver a utilizarlos con un mecanismo para servlets y archivos JSP (JavaServer Server Pages).
Acerca de esta tarea
Se puede generar un ID de memoria caché exclusivo a partir del nombre del mandato más el valor del símbolo.
Para utilizar el almacenamiento en memoria caché de mandatos debe:
Procedimiento

Ejemplo
En los ejemplos de código siguientes se muestra cómo utilizar el mandato en memoria caché para un mandato de cotización bursátil simple.
Este ejemplo de código ilustra un bean del mandato de cotización bursátil. Acepta un ticker de bolsa como parámetro de entrada y genera un precio como parámetro de salida:
public class QuoteCommand extends CacheableCommandImpl
{
private String ticker;
private double price;
// called to validate that command input parameters have been set
public boolean isReadyToCallExecute() {
return (ticker!=null);
}
// called by a cache-hit to copy output properties to this object
public void setOutputProperties(TargetableCommand fromCommand) {
QuoteCommand f = (QuoteCommand)fromCommand;
this.price = f.price;
}
//bbusiness logic method called when the stock price must be retrieved
public void performExecute()throws Exception {...}
//input parameters for the command
public void setTicker(String ticker) { this.ticker=ticker;}
public String getTicker() { return ticker;}
//output parameters for the command
public double getPrice() { return price;};
}
Este código de ejemplo muestra cómo utilizar la política de memoria caché para almacenar en la memoria caché el objeto del mandato de cotización bursátil utilizando el ticker de bolsa como clave de memoria caché y un tiempo de vida de 60 segundos:
<cache>
<cache-entry>
<class>command</class>
<sharing-policy>not-shared</sharing-policy>
<name>QuoteCommand</name>
<cache-id>
<component type="method" id="getTicker">
<required>true</required>
</component>
<priority>3</priority>
<timeout>60</timeout>
</cache-id>
</cache-entry>
</cache>