Class MockSpringFactoriesLoader

java.lang.Object
org.springframework.core.io.support.SpringFactoriesLoader
org.springframework.core.test.io.support.MockSpringFactoriesLoader

public class MockSpringFactoriesLoader extends org.springframework.core.io.support.SpringFactoriesLoader
Simple mock SpringFactoriesLoader implementation that can be used for testing purposes.
Since:
6.0
Author:
Phillip Webb
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.springframework.core.io.support.SpringFactoriesLoader

    org.springframework.core.io.support.SpringFactoriesLoader.ArgumentResolver, org.springframework.core.io.support.SpringFactoriesLoader.FailureHandler
  • Field Summary

    Fields inherited from class org.springframework.core.io.support.SpringFactoriesLoader

    FACTORIES_RESOURCE_LOCATION
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    Create a new MockSpringFactoriesLoader instance with the default classloader.
     
    Create a new MockSpringFactoriesLoader instance with the given classloader.
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final <T> void
    add(Class<T> factoryType, Class<? extends T>... factoryImplementations)
    Add factory implementations to this instance.
    void
    add(String factoryType, String... factoryImplementations)
    Add factory implementations to this instance.
    <T> void
    addInstance(Class<T> factoryType, T... factoryInstances)
    Add factory instances to this instance.
    <T> void
    addInstance(String factoryType, T... factoryInstance)
    Add factory instances to this instance.
    protected <T> @Nullable T
    instantiateFactory(String implementationName, Class<T> type, @Nullable org.springframework.core.io.support.SpringFactoriesLoader.ArgumentResolver argumentResolver, org.springframework.core.io.support.SpringFactoriesLoader.FailureHandler failureHandler)
     

    Methods inherited from class org.springframework.core.io.support.SpringFactoriesLoader

    forDefaultResourceLocation, forDefaultResourceLocation, forResourceLocation, forResourceLocation, load, load, load, load, loadFactories, loadFactoriesResource, loadFactoryNames

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • instantiateFactory

      protected <T> @Nullable T instantiateFactory(String implementationName, Class<T> type, @Nullable org.springframework.core.io.support.SpringFactoriesLoader.ArgumentResolver argumentResolver, org.springframework.core.io.support.SpringFactoriesLoader.FailureHandler failureHandler)
      Overrides:
      instantiateFactory in class org.springframework.core.io.support.SpringFactoriesLoader
    • add

      @SafeVarargs public final <T> void add(Class<T> factoryType, Class<? extends T>... factoryImplementations)
      Add factory implementations to this instance.
      Parameters:
      factoryType - the factory type class
      factoryImplementations - the implementation classes
    • add

      public void add(String factoryType, String... factoryImplementations)
      Add factory implementations to this instance.
      Parameters:
      factoryType - the factory type class name
      factoryImplementations - the implementation class names
    • addInstance

      public <T> void addInstance(Class<T> factoryType, T... factoryInstances)
      Add factory instances to this instance.
      Parameters:
      factoryType - the factory type class
      factoryInstances - the implementation instances to add
    • addInstance

      public <T> void addInstance(String factoryType, T... factoryInstance)
      Add factory instances to this instance.
      Parameters:
      factoryType - the factory type class name
      factoryInstance - the implementation instances to add