Class MonitorHelper

  • All Implemented Interfaces:
    AutoCloseable

    public class MonitorHelper
    extends Object
    implements AutoCloseable
    Monitor helper class responsible for providing an easy way to add and remove values in the current IMonitorContext.
    The basic usage for this class is:
    
            try(MonitorHelper monitorHelper = new MonitorHelper())
            {
                    monitorHelper.addWebResourceValues(myWebResource); // for example
                    // do things with web resource values in monitor context
            }
            // at this point, web resource values are not in context any more
     

    If a more granular control is required, a block like this can be made:
    
            try(MonitorHelper monitorHelper = new MonitorHelper())
            {
                    monitorHelper.addWebResourceValues(myWebResource); // for example
                    
                    // do things with web resource values in monitor context
                    
                    IMonitorValuesProvider myServiceInstanceValueProvider = monitorHelper.addServiceInstanceValues(String serviceInstanceId); // for example
                    
                    // do things with service instance in monitor context
                    
                    monitorHelper.removeAddedValues(myServiceInstanceValueProvider); // no needed to be performed in try-finally because the monitor helper will auto remove all values in #close()
                    
                    // at this point service instance values are not in monitor context any more
            }
            // at this point, web resource values are not in context any more
     

    Each instance of this class must be used only in the thread it was created.
    Since:
    9.0.0
    Version:
    $Revision: 23034 $ $Date: 2019-08-05 16:52:47 -0300 (Mon, 05 Aug 2019) $
    • Constructor Detail

      • MonitorHelper

        public MonitorHelper()
    • Method Detail

      • removeAddedValues

        public void removeAddedValues​(IMonitorValuesProvider provider)
        Removes the given provider from context.
        Parameters:
        provider - the provider.
        Since:
        9.0.0
      • addValues

        public void addValues​(IMonitorValuesProvider valuesProvider)
        Adds the given provider in the context.
        Parameters:
        valuesProvider - the provider.
        Since:
        9.0.0
      • addWebResourceValues

        public IMonitorValuesProvider addWebResourceValues​(WebResource webResource)
        Add a value provider related to the given web resource.
        Parameters:
        webResource - the web resource.
        Returns:
        the created values provider.
        Since:
        9.0.0
      • addServiceInstanceValues

        public IMonitorValuesProvider addServiceInstanceValues​(ServiceInstanceConfig serviceInstanceConfig)
        Add a value provider related to the given service instance.
        Parameters:
        serviceInstanceConfig - the service instance.
        Returns:
        the created values provider.
        Since:
        9.0.0
      • addServiceInstanceValues

        public IMonitorValuesProvider addServiceInstanceValues​(String serviceInstanceId)
        Add a value provider related to the given service instance.
        Parameters:
        serviceInstanceId - the service instance identifier.
        Returns:
        the created values provider.
        Since:
        9.0.0
      • addServerValues

        public IMonitorValuesProvider addServerValues()
        Add a value provider related to the server.
        Returns:
        the created values provider.
        Since:
        9.0.0
      • addServiceValues

        public IMonitorValuesProvider addServiceValues​(String serviceId)
        Add a value provider related to the given service.
        Parameters:
        serviceId - the service identifier.
        Returns:
        the created values provider.
        Since:
        9.0.0
      • addServiceInterfaceInstanceValues

        public IMonitorValuesProvider addServiceInterfaceInstanceValues​(ServiceInterfaceInstanceConfig serviceInterfaceInstanceConfig)
        Add a value provider related to the given interface instance.
        Parameters:
        serviceInterfaceInstanceConfig - the interface instance.
        Returns:
        the created values provider.
        Since:
        9.0.0
      • addMonitorUserValuesByUserId

        public IMonitorValuesProvider addMonitorUserValuesByUserId​(String userId)
        Adds a value provider related to MonitorUser with the given user identifier.
        Parameters:
        userId - the monitor user identifier.
        Returns:
        the created values provider.
        Since:
        12.0.0
      • addMonitorUserValuesByTrackId

        public IMonitorValuesProvider addMonitorUserValuesByTrackId​(String trackId)
        Adds a value provider related to MonitorUser with the given track identifier.
        Parameters:
        trackId - the monitor user track identifier.
        Returns:
        the created values provider.
        Since:
        12.0.0