org.apache.solr.core

## Class PluginBag<T>

- java.lang.Object
- - org.apache.solr.core.PluginBag<T>

- All Implemented Interfaces:
    AutoCloseable

      public class PluginBag<T>
      extends Object
      implements AutoCloseable

  This manages the lifecycle of a set of plugin of the same type .

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `PluginBag.LazyPluginHolder<T>` A class that loads plugins Lazily.
    `static class` | `PluginBag.PluginHolder<T>` An indirect reference to a plugin.
    `static class` | `PluginBag.RuntimeLib` This represents a Runtime Jar.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PluginBag(Class<T> klass, SolrCore core)` Constructs a non-threadsafe plugin registry
    `PluginBag(Class<T> klass, SolrCore core, boolean needThreadSafety)` Pass needThreadSafety=true if plugins can be added and removed concurrently with lookups.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Set<String>` | `checkContains(Collection<String> names)` Check if any of the mentioned names are missing.
    `void` | `close()` Close this registry.
    `boolean` | `contains(String name)`
    `T` | `get(String name)` Get a plugin by name.
    `T` | `get(String name, boolean useDefault)` Fetches a plugin by name , or the default
    `Map<String,PluginBag.PluginHolder<T>>` | `getRegistry()`
    `boolean` | `isLoaded(String name)` To check if a plugin by a specified name is already loaded
    `Set<String>` | `keySet()`
    `T` | `put(String name, T plugin)` register a plugin by a name

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

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

- - ### Constructor Detail

    - #### PluginBag

          public PluginBag(Class<T> klass,
                           SolrCore core,
                           boolean needThreadSafety)

      Pass needThreadSafety=true if plugins can be added and removed concurrently with lookups.

    - #### PluginBag

          public PluginBag(Class<T> klass,
                           SolrCore core)

      Constructs a non-threadsafe plugin registry

  - ### Method Detail

    - #### checkContains

          public Set<String> checkContains(Collection<String> names)

      Check if any of the mentioned names are missing. If yes, return the Set of missing names

    - #### get

          public T get(String name)

      Get a plugin by name. If the plugin is not already instantiated, it is done here

    - #### get

          public T get(String name,
                       boolean useDefault)

      Fetches a plugin by name , or the default
      Parameters:
        `name` - name using which it is registered
        `useDefault` - Return the default , if a plugin by that name does not exist

    - #### keySet

          public Set<String> keySet()

    - #### put

          public T put(String name,
                       T plugin)

      register a plugin by a name

    - #### getRegistry

          public Map<String,PluginBag.PluginHolder<T>> getRegistry()

    - #### contains

          public boolean contains(String name)

    - #### isLoaded

          public boolean isLoaded(String name)

      To check if a plugin by a specified name is already loaded

    - #### close

          public void close()

      Close this registry. This will in turn call a close on all the contained plugins
      Specified by:
        `close` in interface `AutoCloseable`

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.