Class AsyncLoggerConfigDisruptor

  • All Implemented Interfaces:
    AsyncLoggerConfigDelegate, LifeCycle, LifeCycle2

    public class AsyncLoggerConfigDisruptor
    extends AbstractLifeCycle
    implements AsyncLoggerConfigDelegate
    Helper class decoupling the AsyncLoggerConfig class from the LMAX Disruptor library.

    AsyncLoggerConfig is a plugin, and will be loaded even if users do not configure any <asyncLogger> or <asyncRoot> elements in the configuration. If AsyncLoggerConfig has inner classes that extend or implement classes from the Disruptor library, a NoClassDefFoundError is thrown if the Disruptor jar is not in the classpath when the PluginManager loads the AsyncLoggerConfig plugin from the pre-defined plugins definition file.

    This class serves to make the dependency on the Disruptor optional, so that these classes are only loaded when the AsyncLoggerConfig is actually used.

    • Constructor Detail

      • AsyncLoggerConfigDisruptor

        public AsyncLoggerConfigDisruptor()
    • Method Detail

      • setLogEventFactory

        public void setLogEventFactory​(LogEventFactory logEventFactory)
        Description copied from interface: AsyncLoggerConfigDelegate
        Notifies the delegate what LogEventFactory an AsyncLoggerConfig is using, so the delegate can determine whether to populate the ring buffer with mutable log events or not. This method may be invoced multiple times for all AsyncLoggerConfigs that use this delegate.
        Specified by:
        setLogEventFactory in interface AsyncLoggerConfigDelegate
        Parameters:
        logEventFactory - the factory used
      • stop

        public boolean stop​(long timeout,
                            TimeUnit timeUnit)
        Decreases the reference count. If the reference count reached zero, the Disruptor and its associated thread are shut down and their references set to null.
        Specified by:
        stop in interface LifeCycle2
        Overrides:
        stop in class AbstractLifeCycle
        Parameters:
        timeout - the maximum time to wait
        timeUnit - the time unit of the timeout argument
        Returns:
        true if the receiver was stopped cleanly and normally, false otherwise.
      • createRingBufferAdmin

        public RingBufferAdmin createRingBufferAdmin​(String contextName,
                                                     String loggerConfigName)
        Description copied from interface: AsyncLoggerConfigDelegate
        Creates and returns a new RingBufferAdmin that instruments the ringbuffer of this AsyncLoggerConfig.
        Specified by:
        createRingBufferAdmin in interface AsyncLoggerConfigDelegate
        Parameters:
        contextName - name of the LoggerContext
        loggerConfigName - name of the logger config
        Returns:
        the RingBufferAdmin that instruments the ringbuffer