Class BasicItemNodeLoaderFactory

All Implemented Interfaces:

public class BasicItemNodeLoaderFactory
extends Object
implements NodeLoaderFactory<BasicItem,​Object>
Node loader factory implementation for BasicItem node loaders. The key used in createNodeLoader(Object) should normally be an Item object.
Last modified
$Date: 2020-10-21 07:39:15 +0200 (Wed, 21 Oct 2020) $
  • Field Details

    • log

      private static final org.slf4j.Logger log
    • debug

      private static final boolean debug
    • loaders

      private final Map<Object,​Class<? extends NodeLoader<? extends BasicItem>>> loaders
    • autoLoadChildren

      private boolean autoLoadChildren
    • useNullLoader

      private boolean useNullLoader
  • Constructor Details

    • BasicItemNodeLoaderFactory

      public BasicItemNodeLoaderFactory()
      Creates a new factory.
  • Method Details

    • createNodeLoader

      public NodeLoader<? extends BasicItem> createNodeLoader​(Object key)
      Create a new node loader for loading nodes for the specified item type. If no loader has been registered for the given item type, a NullNodeLoader is returned or an exception is thrown depending on the useNullLoaderIfNotFound() option.
      Specified by:
      createNodeLoader in interface NodeLoaderFactory<BasicItem,​Object>
      key - An Item object
      A node loader object
      ItemNotFoundException - If no node loader is found and the useNullLoaderIfNotFound() setting is false
    • registerNodeLoader

      public void registerNodeLoader​(Object key, Class<? extends NodeLoader<? extends BasicItem>> loaderClass) throws NoSuchMethodException, ClassCastException
      Register a node loader implementation. The implementation must have a public no-argument constructor. The given class is checked with ClassUtil.checkAndLoadClass(ClassLoader, String, boolean, Class, Class...)
      key - The item type the node loader handles
      loaderClass - The class name of a class that implements NodeLoader, or null to unregister a node loader
      NoSuchMethodException - If the given class has no public no-argument constructor
      ClassCastException - If the given class doesn't implement the NodeLoader interface
    • registerCheckedNodeLoader

      protected void registerCheckedNodeLoader​(Object key, Class<? extends NodeLoader<? extends BasicItem>> loaderClass)
      Register a node loader implementation that you are sure fulfills the requirements. Eg. it must have a public no-argument constructor and implement the NodeLoader interface.
      See Also:
      registerNodeLoader(Object, Class)
    • setAutoLoadChildren

      public void setAutoLoadChildren​(boolean autoLoadChildren)
      Set a flag that determines if the factory should create node loaders that automatically loads child nodes or not. If this flag has been set this factory will wrap the node loaders with a AutoChildNodeLoader.

      This will generate a recursive pattern if the used node loader:

      • Uses this factory to create child node loaders. Eg. it should use the node loader factory provided by OverviewContext.getNodeLoaderFactory(). The node loader should NOT instantiate child new loaders by itself.
      • Uses an implementation that recurses into folder-type nodes, for example by extending AbstractNodeLoader.
      autoLoadChildren - TRUE to create node loaders that automatically loads children, FALSE otherwise
    • isAutoLoadingChildren

      public boolean isAutoLoadingChildren()
      Get the auto load children setting.
      TRUE if child nodes are automatically loaded, FALSE if not
    • useNullLoaderIfNotFound

      public boolean useNullLoaderIfNotFound()
      Get the null loader setting.
      See Also:
    • setUseNullLoaderIfNotFound

      public void setUseNullLoaderIfNotFound​(boolean useNullLoader)
      Set a flag that determines if a NullNodeLoader should be used or if an ItemNotFoundException should be thrown if no registered node loader is found for a specific key.
      useNullLoader - TRUE to use a NullNodeLoader, FALSE to throw an exception
    • registerDefaultNodeLoaders

      protected void registerDefaultNodeLoaders()
      Registers default item node loaders from BioSource to Experiment, etc.