net.wgen.op.logging
Class TraceKeyFactory

java.lang.Object
  extended bynet.wgen.op.logging.TraceKeyFactory

public class TraceKeyFactory
extends java.lang.Object

Makes TraceKeys in some consistent way, and handles storing in HttpServletRequest attributes.

Version:
$Id: TraceKeyFactory.html,v 1.2 2007/01/28 04:09:37 paulfeuer Exp $
Author:
Paul Feuer, Wireless Generation, Inc.

Field Summary
private static long _counter
          Static counter to disambiguate simultaneous requests.
static java.lang.String REQUEST_KEY__TRACE_KEY
          The key in the HttpServletRequest attributes that contains the TraceKey.
static java.lang.String SESSION_KEY__USER_ID
          The key in the HttpSession attributes that contains the end user's Id which will become a Long in the TraceKey.
 
Constructor Summary
TraceKeyFactory()
           
 
Method Summary
private static long getNextCounterValue()
          Internal static counter to disambiguate among simultaneous requests.
static TraceKey getTraceKey(javax.servlet.http.HttpServletRequest request)
          A TraceKey pulled from the request attributes, or if it doesn't exist, generated using information from the request.
static TraceKey makeKey(java.lang.Long userId, OpModule module)
          For legacy areas where you may not have access to the request, make a key given a userId and module.
private static TraceKey makeKey(java.lang.Long userId, java.lang.String requestUrl)
          Make a key given an userId.
static TraceKey makeTemporaryKey(java.lang.Long userId, java.lang.Class clazz)
          In a legacy area, make a TraceKey whose OpModule is determined by the class passed in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REQUEST_KEY__TRACE_KEY

public static final java.lang.String REQUEST_KEY__TRACE_KEY
The key in the HttpServletRequest attributes that contains the TraceKey.

See Also:
Constant Field Values

SESSION_KEY__USER_ID

public static final java.lang.String SESSION_KEY__USER_ID
The key in the HttpSession attributes that contains the end user's Id which will become a Long in the TraceKey.


_counter

private static long _counter
Static counter to disambiguate simultaneous requests.

Constructor Detail

TraceKeyFactory

public TraceKeyFactory()
Method Detail

makeKey

private static TraceKey makeKey(java.lang.Long userId,
                                java.lang.String requestUrl)
Make a key given an userId.

Parameters:
userId - the current user, if any, or 0 if the user is not known
requestUrl - the url requested that will be claimed by some application
Returns:
the traceKey

makeKey

public static TraceKey makeKey(java.lang.Long userId,
                               OpModule module)
For legacy areas where you may not have access to the request, make a key given a userId and module.

Parameters:
userId - the userId responsible for this behavior's execution
module - the module responsible for the code being executed
Returns:
the tracekey

makeTemporaryKey

public static TraceKey makeTemporaryKey(java.lang.Long userId,
                                        java.lang.Class clazz)
In a legacy area, make a TraceKey whose OpModule is determined by the class passed in.

Parameters:
userId -
clazz -
Returns:
See Also:
OpModuleRegistry.lookUpModule(Class), OpModule.getClassMatchLength(Class)

getNextCounterValue

private static long getNextCounterValue()
Internal static counter to disambiguate among simultaneous requests.


getTraceKey

public static final TraceKey getTraceKey(javax.servlet.http.HttpServletRequest request)
A TraceKey pulled from the request attributes, or if it doesn't exist, generated using information from the request. The userId value going into the TraceKey will be pulled from the request's attributes at key speficied by the static String TraceKeyFactory.SESSION_KEY_USER_ID. The TraceKey is stored

Parameters:
request -
Returns:
a trace key generated using information from the request