Class PerfLogUtils
Several tools for the Foundation Performance Logging and Monitoring.
- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: PerfLogUtils.java 1258 2026-06-04 18:33:06Z tquadrat $
- Since:
- 0.25.0
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.perflog.PerfLogUtils"
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA holder forPerformanceTrackerthat allows to use it with try-with-resources. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe domain name part of theObjectNameidentifying thePerfLogMBeanin the MBean server: "org.tquadrat.foundation.PerfLog"static final Stringstatic final StringThe name of the system property that controls whether to use a dedicatedMBeanServer: "org.tquadrat.foundation.perflog.UseDedicatedMBeanServer". -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final PerfLogManagerCreates an instance ofPerfLogManagerthat handles the connection with the underlyingPerfLogMBean.static final PerfLogManagercreatePerfLogManager(Thread.UncaughtExceptionHandler uncaughtExceptionHandler) Creates an instance ofPerfLogManagerthat handles the connection with the underlyingPerfLogMBean.static final PerfLogManagercreatePerfLogManager(MBeanServer mbeanServer) Creates an instance ofPerfLogManagerthat handles the connection with the underlyingPerfLogMBean.static final PerfLogManagercreatePerfLogManager(MBeanServer mbeanServer, Thread.UncaughtExceptionHandler uncaughtExceptionHandler) Creates an instance ofPerfLogManagerthat handles the connection with the underlyingPerfLogMBean.static PerformanceSectionNameCreates a new instance for an implementation ofPerformanceSectionNamebased on the given value.static final ObjectNameReturns theObjectNamefor thePerfLogMBean.static final PerfLogUtils.PerformanceTrackerHolderCreates aPerformanceTrackerfor thePerformanceSectionwith the given name.static final PerfLogUtils.PerformanceTrackerHolderhold(Optional<? extends PerformanceTracker> tracker) Creates a holder for the givenPerformanceTracker.static final PerfLogUtils.PerformanceTrackerHolderhold(PerfLogManager manager, PerformanceSectionName name) static final PerfLogUtils.PerformanceTrackerHolderhold(PerformanceSectionName name) static final PerfLogUtils.PerformanceTrackerHolderholdAndStart(String value) Creates aPerformanceTrackerfor thePerformanceSectionwith the given name and immediately starts it.static final PerfLogUtils.PerformanceTrackerHolderholdAndStart(Optional<? extends PerformanceTracker> tracker) Creates a holder for the givenPerformanceTrackerand immediately starts it.static final PerfLogUtils.PerformanceTrackerHolderholdAndStart(PerfLogManager manager, PerformanceSectionName name) Creates aPerformanceTrackerfor thePerformanceSectionwith the given name and immediately starts it.static final PerfLogUtils.PerformanceTrackerHolderCreates aPerformanceTrackerfor thePerformanceSectionwith the given name and immediately starts it.static final MBeanServerRetrieves theMBeanServerthat is used for the registration of thePerfLogMBean.
-
Field Details
-
DOMAIN_NAME
The domain name part of the
ObjectNameidentifying thePerfLogMBeanin the MBean server: "org.tquadrat.foundation.PerfLog".It is also used for the creation of the MBean server, if a dedicated MBean server is needed; usually the Platform MBean server is used.
- See Also:
-
MBEAN_TYPE
- See Also:
-
SYSTEM_PROPERTY_UsedDedicatedMBeanServer
The name of the system property that controls whether to use a dedicated
MBeanServer: "org.tquadrat.foundation.perflog.UseDedicatedMBeanServer".If not provided or set to
false, the platform MBean server is used.- See Also:
-
-
Constructor Details
-
PerfLogUtils
private PerfLogUtils()Not instance allowed for this class!
-
-
Method Details
-
createPerfLogManager
Creates an instance of
PerfLogManagerthat handles the connection with the underlyingPerfLogMBean.When called multiple times with references to different MBean servers, each of these calls will create a new instance of
PerfLogMBean.- Parameters:
mbeanServer- The MBean server that holds thePerfLogMBean.- Returns:
- The new performance logging manager.
- See Also:
-
createPerfLogManager
public static final PerfLogManager createPerfLogManager(MBeanServer mbeanServer, Thread.UncaughtExceptionHandler uncaughtExceptionHandler) Creates an instance of
PerfLogManagerthat handles the connection with the underlyingPerfLogMBean.When called multiple times with references to different MBean servers, each of these calls will create a new instance of
PerfLogMBean.- Parameters:
mbeanServer- The MBean server that holds thePerfLogMBean.uncaughtExceptionHandler- The implementation ofThread.UncaughtExceptionHandlerthat is used for the timeout monitoring thread.- Returns:
- The new performance logging manager.
- See Also:
-
createPerfLogManager
Creates an instance of
PerfLogManagerthat handles the connection with the underlyingPerfLogMBean.The method uses the
MBeanServerthat is returned fromobtainMBeanServer().- Returns:
- The new performance logging manager.
-
createPerfLogManager
public static final PerfLogManager createPerfLogManager(Thread.UncaughtExceptionHandler uncaughtExceptionHandler) Creates an instance of
PerfLogManagerthat handles the connection with the underlyingPerfLogMBean.The method uses the
MBeanServerthat is returned fromobtainMBeanServer().- Parameters:
uncaughtExceptionHandler- The implementation ofThread.UncaughtExceptionHandlerthat is used for the timeout monitoring thread.- Returns:
- The new performance logging manager.
-
createPerformanceSectionName
Creates a new instance for an implementation ofPerformanceSectionNamebased on the given value.- Parameters:
value- The value for the new name.- Returns:
- The new name.
-
getPerfLogMBeanObjectName
Returns theObjectNamefor thePerfLogMBean.- Returns:
- The object name for the performance logging MBean.
-
hold
public static final PerfLogUtils.PerformanceTrackerHolder hold(Optional<? extends PerformanceTracker> tracker) Creates a holder for the given
PerformanceTracker.This is a convenience method that allows to use a performance tracker with
try-with-resources.- Parameters:
tracker- An instance ofOptionalthat holds the tracker.- Returns:
- A holder for the given tracker.
- Throws:
ClassCastException- If called with an instance ofHolderinstead of a rawPerformanceTracker.
-
hold
Creates a
PerformanceTrackerfor thePerformanceSectionwith the given name.It creates an instance of
PerfLogManageron the fly, using theMBeanServerreturned byobtainMBeanServer().This is a convenience method that allows to use a performance tracker with
try-with-resources.- Parameters:
name- The name of the performance section.- Returns:
- A holder for the given tracker.
-
hold
public static final PerfLogUtils.PerformanceTrackerHolder hold(PerfLogManager manager, PerformanceSectionName name) Creates a
PerformanceTrackerfor thePerformanceSectionwith the given name.This is a convenience method that allows to use a performance tracker with
try-with-resources.- Parameters:
manager- The Performance Logging Manager that connects to thePerfLogMBean.name- The name of the performance section.- Returns:
- A holder for the given tracker.
-
hold
Creates a
PerformanceTrackerfor thePerformanceSectionwith the given name.It creates an instance of
PerfLogManageron the fly, using theMBeanServerreturned byobtainMBeanServer().This is a convenience method that allows to use a performance tracker with
try-with-resources.- Parameters:
value- The name of the performance section.- Returns:
- A holder for the given tracker.
-
holdAndStart
public static final PerfLogUtils.PerformanceTrackerHolder holdAndStart(Optional<? extends PerformanceTracker> tracker) Creates a holder for the given
PerformanceTrackerand immediately starts it.This is a convenience method that allows to use a performance tracker with
try-with-resources.- Parameters:
tracker- An instance ofOptionalthat holds the tracker.- Returns:
- A holder for the given tracker.
-
holdAndStart
Creates a
PerformanceTrackerfor thePerformanceSectionwith the given name and immediately starts it.It creates an instance of
PerfLogManageron the fly, using theMBeanServerreturned byobtainMBeanServer().This is a convenience method that allows to use a performance tracker with
try-with-resources.- Parameters:
name- The name of the performance section.- Returns:
- A holder for the given tracker.
-
holdAndStart
public static final PerfLogUtils.PerformanceTrackerHolder holdAndStart(PerfLogManager manager, PerformanceSectionName name) Creates a
PerformanceTrackerfor thePerformanceSectionwith the given name and immediately starts it.It creates an instance of
PerfLogManageron the fly, using theMBeanServerreturned byobtainMBeanServer().This is a convenience method that allows to use a performance tracker with
try-with-resources.- Parameters:
manager- The Performance Logging Manager that connects to thePerfLogMBean.name- The name of the performance section.- Returns:
- A holder for the given tracker.
-
holdAndStart
Creates a
PerformanceTrackerfor thePerformanceSectionwith the given name and immediately starts it.It creates an instance of
PerfLogManageron the fly, using theMBeanServerreturned byobtainMBeanServer().This is a convenience method that allows to use a performance tracker with
try-with-resources.- Parameters:
value- The name of the performance section.- Returns:
- A holder for the given tracker.
-
obtainMBeanServer
Retrieves the
MBeanServerthat is used for the registration of thePerfLogMBean.If the system property "org.tquadrat.foundation.perflog.UseDedicatedMBeanServer" is set to
true, a dedicated MBean server for the domain "org.tquadrat.foundation.PerfLog" will be used, otherwise the MBean server that is returned byManagementFactory.getPlatformMBeanServer()is returned.- Returns:
- The MBean server.
- See Also:
-
