Class Log4jContextFactory

    • Constructor Detail

      • Log4jContextFactory

        public Log4jContextFactory​(ContextSelector selector)
        Initializes this factory's ContextSelector with the specified selector.
        Parameters:
        selector - the selector to use
      • Log4jContextFactory

        public Log4jContextFactory​(ShutdownCallbackRegistry shutdownCallbackRegistry)
        Constructs a Log4jContextFactory using the ContextSelector from Constants.LOG4J_CONTEXT_SELECTOR and the provided ShutdownRegistrationStrategy.
        Parameters:
        shutdownCallbackRegistry - the ShutdownRegistrationStrategy to use
        Since:
        2.1
      • Log4jContextFactory

        public Log4jContextFactory​(ContextSelector selector,
                                   ShutdownCallbackRegistry shutdownCallbackRegistry)
        Constructs a Log4jContextFactory using the provided ContextSelector and ShutdownRegistrationStrategy.
        Parameters:
        selector - the selector to use
        shutdownCallbackRegistry - the ShutdownRegistrationStrategy to use
        Since:
        2.1
    • Method Detail

      • getContext

        public LoggerContext getContext​(String fqcn,
                                        ClassLoader loader,
                                        Object externalContext,
                                        boolean currentContext)
        Loads the LoggerContext using the ContextSelector.
        Specified by:
        getContext in interface LoggerContextFactory
        Parameters:
        fqcn - The fully qualified class name of the caller.
        loader - The ClassLoader to use or null.
        currentContext - If true returns the current Context, if false returns the Context appropriate for the caller if a more appropriate Context can be determined.
        externalContext - An external context (such as a ServletContext) to be associated with the LoggerContext.
        Returns:
        The LoggerContext.
      • getContext

        public LoggerContext getContext​(String fqcn,
                                        ClassLoader loader,
                                        Object externalContext,
                                        boolean currentContext,
                                        ConfigurationSource source)
        Loads the LoggerContext using the ContextSelector.
        Parameters:
        fqcn - The fully qualified class name of the caller.
        loader - The ClassLoader to use or null.
        externalContext - An external context (such as a ServletContext) to be associated with the LoggerContext.
        currentContext - If true returns the current Context, if false returns the Context appropriate for the caller if a more appropriate Context can be determined.
        source - The configuration source.
        Returns:
        The LoggerContext.
      • getContext

        public LoggerContext getContext​(String fqcn,
                                        ClassLoader loader,
                                        Object externalContext,
                                        boolean currentContext,
                                        Configuration configuration)
        Loads the LoggerContext using the ContextSelector using the provided Configuration
        Parameters:
        fqcn - The fully qualified class name of the caller.
        loader - The ClassLoader to use or null.
        externalContext - An external context (such as a ServletContext) to be associated with the LoggerContext.
        currentContext - If true returns the current Context, if false returns the Context appropriate for the caller if a more appropriate Context can be determined.
        configuration - The Configuration.
        Returns:
        The LoggerContext.
      • getContext

        public LoggerContext getContext​(String fqcn,
                                        ClassLoader loader,
                                        Object externalContext,
                                        boolean currentContext,
                                        URI configLocation,
                                        String name)
        Loads the LoggerContext using the ContextSelector.
        Specified by:
        getContext in interface LoggerContextFactory
        Parameters:
        fqcn - The fully qualified class name of the caller.
        loader - The ClassLoader to use or null.
        externalContext - An external context (such as a ServletContext) to be associated with the LoggerContext.
        currentContext - If true returns the current Context, if false returns the Context appropriate for the caller if a more appropriate Context can be determined.
        configLocation - The location of the configuration for the LoggerContext (or null).
        name - The name of the context or null.
        Returns:
        The LoggerContext.
      • shutdown

        public void shutdown​(String fqcn,
                             ClassLoader loader,
                             boolean currentContext,
                             boolean allContexts)
        Description copied from interface: LoggerContextFactory
        Shuts down the LoggerContext.
        Specified by:
        shutdown in interface LoggerContextFactory
        Parameters:
        fqcn - The fully qualified class name of the caller.
        loader - The ClassLoader to use or null.
        currentContext - If true shuts down the current Context, if false shuts down the Context appropriate for the caller if a more appropriate Context can be determined.
        allContexts - if true all LoggerContexts that can be located will be shutdown.
      • hasContext

        public boolean hasContext​(String fqcn,
                                  ClassLoader loader,
                                  boolean currentContext)
        Checks to see if a LoggerContext is installed.
        Specified by:
        hasContext in interface LoggerContextFactory
        Parameters:
        fqcn - The fully qualified class name of the caller.
        loader - The ClassLoader to use or null.
        currentContext - If true returns the current Context, if false returns the Context appropriate for the caller if a more appropriate Context can be determined.
        Returns:
        true if a LoggerContext has been installed, false otherwise.
        Since:
        3.0
      • getSelector

        public ContextSelector getSelector()
        Returns the ContextSelector.
        Returns:
        The ContextSelector.
      • getShutdownCallbackRegistry

        public ShutdownCallbackRegistry getShutdownCallbackRegistry()
        Returns the ShutdownCallbackRegistry
        Returns:
        the ShutdownCallbackRegistry
        Since:
        2.4
      • addShutdownCallback

        public Cancellable addShutdownCallback​(Runnable callback)
        Description copied from interface: ShutdownCallbackRegistry
        Adds a Runnable shutdown callback to this class.
        Specified by:
        addShutdownCallback in interface ShutdownCallbackRegistry
        Parameters:
        callback - the shutdown callback to be executed upon shutdown.
        Returns:
        a Cancellable wrapper of the provided callback or null if the shutdown hook is disabled and cannot be added.
      • isShutdownHookEnabled

        public boolean isShutdownHookEnabled()