public class RemoteDelegateInvocationHandler extends Object implements InvocationHandler
| Modifier and Type | Field and Description |
|---|---|
static boolean |
collectStatistics
If true method invocations are counted and measured per method.
|
boolean |
logInvocationDetails
If true, args and return values will be logged as well.
|
boolean |
logInvocations
If true, all invocations are logged.
|
static long |
logMinDurationMillis
Minimum milliseconds a method needs to execute before being logged.
0 to disable. |
static int |
logMinReturnedCollectionSize
Minimum size of returned collection to get logged.
0 to disable. |
static String |
MDC_SESSION_KEY
the mdc session key
|
static Pattern |
mdcFilter
Optional filter to log only RMI-calls for certain MappedDiagnosticContexts.
If set, statements are only collected for logging if the MDC is valid and the pattern matches the toString-value of the MDC. |
| Constructor and Description |
|---|
RemoteDelegateInvocationHandler(org.tentackle.persist.rmi.RemoteDelegateImpl<?> delegate)
Creates an invocation handler for a
RemoteDelegate. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
cleanupDbAfterException()
Cleans up the db after an exception.
|
protected void |
clearMDC()
Clears the MDC.
|
org.tentackle.persist.rmi.RemoteDelegateImpl<?> |
getDelegate()
Gets the delegate.
|
protected RemoteException |
handleInvocationException(Object proxy,
Method method,
Object[] args,
Throwable cause)
Handles an invocation exception.
Figures out the real exception cause and throws it, skipping InvocationTargetExceptions. |
Object |
invoke(Object proxy,
Method method,
Object[] args) |
protected Object |
invokeImpl(Object proxy,
Method method,
Object[] args)
Invokes the delegate's method.
|
protected boolean |
isMDCValid()
Checks whether the mapped diagnostic context is valid for statistics logging.
|
protected void |
lockDbForThread()
Locks the Db for exclusive use by current thread.
|
protected void |
log(Method method,
Object[] args,
Object retval,
Duration duration)
Logs the invocation.
|
protected boolean |
needDuration()
Returns whether measuring the duration is necessary.
|
protected void |
updateMDC()
Updates the
MappedDiagnosticContext with the session data. |
protected void |
updateThreadLocal()
Updates the thread local memory.
|
public static final String MDC_SESSION_KEY
public static boolean collectStatistics
public boolean logInvocations
public boolean logInvocationDetails
public static long logMinDurationMillis
For analysis and debugging purposes only.
public static int logMinReturnedCollectionSize
For analysis and debugging purposes only.
public static Pattern mdcFilter
public RemoteDelegateInvocationHandler(org.tentackle.persist.rmi.RemoteDelegateImpl<?> delegate)
RemoteDelegate.
The invocation handler may be used to intercept remote method invocations.
The default implementation just sets the session info into the MappedDiagnosticContext.
delegate - the remote delegatepublic org.tentackle.persist.rmi.RemoteDelegateImpl<?> getDelegate()
protected void updateMDC()
MappedDiagnosticContext with the session data.protected void clearMDC()
protected boolean isMDCValid()
protected void updateThreadLocal()
protected void lockDbForThread()
protected RemoteException handleInvocationException(Object proxy, Method method, Object[] args, Throwable cause)
proxy - the dynamic proxymethod - the method to invokeargs - the method's argumentscause - the invocation exceptionprotected void cleanupDbAfterException()
Invoked from handleInvocationException(java.lang.Object, java.lang.reflect.Method, java.lang.Object[], java.lang.Throwable).
protected Object invokeImpl(Object proxy, Method method, Object[] args) throws RemoteException
If the invocation failed for some reason the stacktrace is logged.
proxy - the dynamic proxymethod - the method to invokeargs - the method's argumentsRemoteException - if invocation failedprotected boolean needDuration()
protected void log(Method method, Object[] args, Object retval, Duration duration)
method - the method executedargs - the method argsretval - the method's return valueduration - the duration when execution was started, null if don't careCopyright © 2016 Krake Softwaretechnik. All rights reserved.