Class MonitorHelper

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class MonitorHelper
    extends java.lang.Object
    implements java.lang.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$ $Date$
    • Constructor Detail

      • MonitorHelper

        public MonitorHelper()
    • Method Detail

      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
      • 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
      • addValues

        public void addValues​(java.lang.String fieldId,
                              java.io.Serializable... values)
        Adds the given value as a value provider.
        Parameters:
        fieldId - the field id
        values - the values
        Since:
        16.1.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​(java.lang.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​(java.lang.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
      • addSessionValues

        public IMonitorValuesProvider addSessionValues​(SessionConfig sessionConfig,
                                                       javax.servlet.http.HttpSession httpSession)
                                                throws PortalException
        Adds a value provider related to SessionConfig and HttpSession.
        Parameters:
        sessionConfig - the LumisXP user session.
        httpSession - the application server http session.
        Returns:
        the created values provider.
        Throws:
        PortalException
        Since:
        11.0.0
      • addMonitorUserValuesByUserId

        public IMonitorValuesProvider addMonitorUserValuesByUserId​(java.lang.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​(java.lang.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