public class SingleEntryTransactionResourceInterceptor extends Object implements org.aopalliance.intercept.MethodInterceptor
resource managersfor further processing. The resource managers are called after the method invocations, but it doesn't matter too much since they are called on a time frequency basis.
It acts as a sampling tool, but doesn't make any decisions or take any action with regard system or transaction-related resources. All samples are stored against the current transaction. If there is no current transaction then no action will be taken with respect to the resource management.
The default is to activate after 10s and call through every 5s.
This class supports both interceptor-based calling as well as manual calling. Long-running processes can call an this manually on every iteration and get the same behaviour of regular calls to the resouce managers.
The current thread is marked on first entry and all subsequent nested re-entries will just get passed down to the underlying delegate invocation method.
|Constructor and Description|
|Modifier and Type||Method and Description|
An alternative method allowing a manual call to check the resources.
Set the minimum number of seconds that a transaction must have been running for before method sampling begins.
Set the method-based resource managers that will be notified of the statistics.
Set the approximate time between calls to the
public void setMethodResourceManagers(List<MethodResourceManager> methodResourceManagers)
methodResourceManagers- a list of resource managers - may be null or empty
public void setElapsedTimeBeforeActivationMillis(long elapsedTimeBeforeActivationMillis)
elapsedTimeBeforeActivationMillis- an initial idle time in milliseconds
public void setResourceManagerCallFrequencyMillis(long resourceManagerCallFrequencyMillis)
registered resource managers. This applies to this instance of the interceptor and not to the transaction. If a single instance of this class is used in multiple places, then the resource managers will still only get called at a steady rate. This is mainly in order to streamline the interception prior to the activation phase, but suits the resource managers since they get given the exact methods that were called anyway.
resourceManagerCallFrequencyMillis- an approximate time between calls to the resource managers
public void performManualCheck(Method calledMethod, long deltaNs)
If you have a loop in a method that doesn't call anything that can be intercepted and handle safely, then get a pre-configured instance (usually from the application context) and mimic the interceptor call.
You should get the
Method, which is used for informational purposes, in a
single call when you calling code is loaded by the classloader. Introspecting every time
you wish to call this method is unnecessary.
calledMethod- the method that this check applies to
deltaNs- the time in milliseconds that the repeated operation took
Copyright © 2005–2017 Alfresco Software. All rights reserved.