Previous Topic: Agent Transaction APIsNext Topic: Agent API Examples


Agent VSE APIs

VSE enables you to stub out processes, services, or parts of them along well-defined boundaries. The internal elements of these processes and services can be replaced with a layer run by DevTest according to custom user-defined rules. These layers that DevTest runs are known as a model. Usually, a default starting point for those rules is obtained from a recording of live system interactions.

DevTest already supports VSE for the HTTP protocol (allowing virtualization of web applications and web services), JMS, and JDBC to a certain extent. The agent provides APIs to enable virtualization directly from within server processes, thus making it protocol agnostic. Virtualization can be enabled for HTTP, JMS, and JDBC but also for RMI, EJB, or any custom Java objects.

DevTest (or any other client of the agent) can achieve this virtualization by using the following APIs defined in com.itko.lisa.remote.client.VSEClient as obtained by AgentClient.getInstance().getVSEClient().

Note: You can view detailed information about this class in the JavaDocs for the agent. The JavaDocs are located in the LISA_HOME\doc directory.

/**
  * Returns a list of all class/interface names whose name matches the supplied regular expression
  * or that extend/implement a class/interface whose name matches the supplied regular expression
  * if implementing is true. Searching for annotations is supported through the syntax:
  * class regex@annotation regex (e.g. ".*.Remote@.*.Stateless").
  * @param agentInfo
  * @param regex
  * @param impl
  * @return
  */
 public String[] getMatchingClasses(IAgentInfo info, String regex, boolean impl) throws JMSInvocationException
 
 /**
  * Register a VSE callback with the specified agent whose onFrameRecord will be invoked
  * in recording mode for all virtualized methods and whose onFramePlayback method will be invoked
  * in playback mode for all virtualized methods.
  * @param info
  * @param callback
  */
 public void registerVSECallback(IAgentInfo info, IVSECallback callback);
 
 /**
  * Unegister a VSE callback with the specified agent.
  * @param info
  * @param callback
  */
 public void unregisterVSECallback(IAgentInfo info, IVSECallback callback);
 
 /**
  * Start calling our virtualization recording callback on the specified agent.
  * @param agentInfo
  * @throws RemoteException
  */
 public void startVSERecording(IAgentInfo agentInfo) throws JMSInvocationException
 
 /**
  * Start calling our virtualization playback callback on the specified agent.
  * @param agentInfo
  * @throws RemoteException
  */
 public void startVSEPlayback(IAgentInfo agentInfo) throws JMSInvocationException
 
 /**
  * Stop virtualizing on the specified agent.
  * @param agentInfo
  * @throws RemoteException
  */
 public void stopVSE(IAgentInfo agentInfo) throws JMSInvocationException
 
 /**
  * Virtualizes the specified class/interface and all its descendants on the specified agent.
  * @param agentInfo
  * @param className
  * @return
  */
 public void virtualize(IAgentInfo agentInfo, String className) throws JMSInvocationException

The interface for the callback APIs is defined by com.itko.lisa.remote.vse.IVSECallback and defines the following methods:

/**
  * This is the method that gets invoked by agents that have VSE recording turned on
  * when a virtualize method gets called. The VSE frame has all the information needed
  * to later replay the method in playback mode.
  * @param frame
  * @throws RemoteException
  */
 void onFrameRecord(VSEFrame frame) throws RemoteException;
 
 /**
  * This is the method that gets invoked by agents that have VSE playback turned on
  * when a virtualize method gets called. The VSE frame has all the information needed
  * to match an existing recorded frame so its result (and by reference arguments)
  * can be set appropriately.
  * @param frame
  * @return
  * @throws RemoteException
  */
 VSEFrame onFramePlayback(VSEFrame frame) throws RemoteException;

Finally, the com.itko.lisa.remote.vse.VSEFrame object is a POJO with getters and setters for the following properties:

/** Get/sets a unique identifier for this frame */
 public String getFrameId();
 public void setFrameId(String frameId);
 
 /** The agent id this frame originates from */
 public long getAgentGuid();
 public void setAgentGuid(long agentId);
 
 /** The thread name this frame method was invoked on */
 public String getThreadName();
 public void setThreadName(String threadName);
 
 /** The name of the class this frame method was invoked on */
 public String getClassName();
 public void setClassName(String className);
 
 /** A unique identifier that tracks objects for the span of the VM's life */
 public String getSourceId();
 public void setSourceId(String srcId);
 
 /** The session id of the innermost session-scoped protocol enclosing this frame */
 public String getSessionId();
 public void setSessionId(String sessionId);
 
 /** The name of the method that was invoked */
 public String getMethod();
 public void setMethod(String method);
 
 /** The XStream'ed arguments array to the method that was invoked */
 public String[] getArgumentsXML();
 public void setArgumentsXML(String[] argumentsXML);
 
 /** The XStream'ed result of the method that was invoked */
 public String getResultXML();
 public void setResultXML(String resultXML);
 
 /** The (server) time the method was invoked */
 public long getTime();
 public void setTime(long time);
 
 /** The time the method took to execute */
 public long getClockDuration();
 public void setClockDuration(long duration);
 
 /** Whether to use getCode or the ResultXML to compute the desired result in playback mode */
 public boolean isUseCode();
 public void setUseCode(boolean useCode);
 
 /**
  * The code to execute on the server if isUseCode is true. This can be arbitrary code
  * that has access to the object ($0) and method arguments ($1, $2,...)
  */
 public String getCode();
 public void setCode(String code);