org.hopto.pentaj.jexin.client
Class TraceServer

java.lang.Object
  extended by org.hopto.pentaj.jexin.client.TraceServer

public class TraceServer
extends java.lang.Object

 TODO Get checked exceptions from method and allow any with 0 arg ctor to be injected (how to make this work when
 I'm sending all the injectables up front?
 TODO Keep map of methods by Method with signature, etc?? 
 TODO Allow checked exceptions in injectable exceptions config but only allow them to be thrown from methods that declare them
 
Sends limited stack trace information to a client and allows the client to inject RuntimeExceptions in real time either before or after a method. This class is only intended to be used by the TraceAspect. It should be instantiated as a Spring singleton and only in non-production environments. Protocol details:
  1. A client connects (any currently connected client will be disconnected)
  2. The node name (String) is sent to the client
  3. A Map of ID (Integer) to description (String) is sent to the client for all injectable exceptions
  4. When the first monitored method is called a STACK_FRAME_START_ACTION is sent to the client
  5. The thread ID (long) is sent to the client
  6. The thread name (String) is sent to the client
  7. The method signature (String) is sent to the client
  8. The injectable exceptions for the method (int[]) is sent to the client
  9. The client responds with the PROCEED_ACTION or the ID of an error to be injected
  10. If the most recent stack frame is ending with a return and not throwing an exception, a STACK_FRAME_END_ACTION is sent to the client followed by the thread ID (long)
  11. If the most recent stack frame is ending because an exception was thrown, a STACK_FRAME_EXCEPTION_ACTION is sent to the client followed by the thread ID (long) then followed by the Throwable description (String) (this includes any exception injected because of the client's response to the STACK_FRAME_START_ACTION)
  12. If a child stack frame is starting (the client received another STACK_FRAME_START_ACTION before the current frame ends), go to step 3
If STACK_FRAME_END_ACTION or STACK_FRAME_EXCEPTION_ACTION occurs before the first STACK_FRAME_START_ACTION the client should discard them.


Field Summary
static int DEFAULT_PORT
           
static int DEFAULT_READ_TIMEOUT
           
 
Constructor Summary
TraceServer()
           
TraceServer(javax.net.ServerSocketFactory socketFactory)
           
 
Method Summary
 void destroy()
          Closes client and server sockets
 void init()
          Sets up the exception set and server thread and socket to accept new clients
 void setInjectableExceptions(java.util.Set<InjectableException> injectableExceptions)
           
 void setNodeName(java.lang.String nodeName)
           
 void setPort(int port)
           
 void setReadTimeout(int readTimeout)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PORT

public static final int DEFAULT_PORT
See Also:
Constant Field Values

DEFAULT_READ_TIMEOUT

public static final int DEFAULT_READ_TIMEOUT
See Also:
Constant Field Values
Constructor Detail

TraceServer

public TraceServer()

TraceServer

public TraceServer(javax.net.ServerSocketFactory socketFactory)
Method Detail

setNodeName

public void setNodeName(java.lang.String nodeName)

setPort

public void setPort(int port)

setReadTimeout

public void setReadTimeout(int readTimeout)

setInjectableExceptions

public void setInjectableExceptions(java.util.Set<InjectableException> injectableExceptions)

init

public void init()
Sets up the exception set and server thread and socket to accept new clients


destroy

public void destroy()
Closes client and server sockets