org.apache.log4j.plugins

## Class PluginRegistry

- java.lang.Object
- - org.apache.log4j.plugins.PluginRegistry

-     public final class PluginRegistry
      extends Object

  This is a registry for Plugin instances. It provides methods to start and stop plugin objects individually and to stop all plugins for a repository.
  Author:
    Mark Womack, Paul Smith

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PluginRegistry(LoggerRepositoryEx repository)` Creates a new instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addPlugin(Plugin plugin)` Adds a plugin to the plugin registry.
    `void` | `addPluginListener(PluginListener l)` Adds a PluginListener to this registry to be notified of PluginEvents.
    `LoggerRepositoryEx` | `getLoggerRepository()` Get logger repository.
    `List` | `getPlugins()` Returns all the plugins for a given repository.
    `List` | `getPlugins(Class pluginClass)` Returns all the plugins for a given repository that are instances of a certain class.
    `boolean` | `pluginNameExists(String name)` Returns true if the specified name is already taken by an existing Plugin registered within the scope of the specified LoggerRepository.
    `void` | `removePluginListener(PluginListener l)` Removes a particular PluginListener from this registry such that it will no longer be notified of PluginEvents.
    `void` | `stopAllPlugins()` Stops all plugins in the given logger repository.
    `Plugin` | `stopPlugin(String pluginName)` Stops a plugin by plugin name and repository.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PluginRegistry

          public PluginRegistry(LoggerRepositoryEx repository)

      Creates a new instance.
      Parameters:
        `repository` - logger repository.

  - ### Method Detail

    - #### getLoggerRepository

          public LoggerRepositoryEx getLoggerRepository()

      Get logger repository.
      Returns:
        logger repository.

    - #### pluginNameExists

          public boolean pluginNameExists(String name)

      Returns true if the specified name is already taken by an existing Plugin registered within the scope of the specified LoggerRepository.
      Parameters:
        `name` - The name to check the repository for
      Returns:
        true if the name is already in use, otherwise false

    - #### addPlugin

          public void addPlugin(Plugin plugin)

      Adds a plugin to the plugin registry. If a plugin with the same name exists already, it is shutdown and removed.
      Parameters:
        `plugin` - the plugin to add.

    - #### getPlugins

          public List getPlugins()

      Returns all the plugins for a given repository.
      Returns:
        List list of plugins from the repository.

    - #### getPlugins

          public List getPlugins(Class pluginClass)

      Returns all the plugins for a given repository that are instances of a certain class.
      Parameters:
        `pluginClass` - the class the plugin must implement to be selected.
      Returns:
        List list of plugins from the repository.

    - #### stopPlugin

          public Plugin stopPlugin(String pluginName)

      Stops a plugin by plugin name and repository.
      Parameters:
        `pluginName` - the name of the plugin to stop.
      Returns:
        Plugin the plugin, if stopped, or null if the the plugin was not found in the registry.

    - #### stopAllPlugins

          public void stopAllPlugins()

      Stops all plugins in the given logger repository.

    - #### addPluginListener

          public void addPluginListener(PluginListener l)

      Adds a PluginListener to this registry to be notified of PluginEvents.
      Parameters:
        `l` - PluginListener to add to this registry

    - #### removePluginListener

          public void removePluginListener(PluginListener l)

      Removes a particular PluginListener from this registry such that it will no longer be notified of PluginEvents.
      Parameters:
        `l` - PluginListener to remove

Copyright © 2002-2018 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache Chainsaw, Chainsaw, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.