Interface ServiceLoader<T>

Type Parameters:
T - The type of service to be loaded.
All Known Implementing Classes:
GenericHandlerLoader, IIOServiceLoader, ListenerAdapterLoader, MiddlewareHandlerLoader, RequestHandlerLoader, SocketHandlerLoader, SQLDriverLoader

public interface ServiceLoader<T>
A simple service loader interface for managing instances of a specified type. This interface defines methods to create a new instance of a class and to load a service provider for further processing.
Since:
3.0.0-SNAPSHOT
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    load(T provider)
    Loads a service provider and performs necessary operations.
    default T
    newInstance(Class<T> clazz, Object... args)
    Creates a new instance of the specified class using its default constructor.
  • Method Details

    • newInstance

      Creates a new instance of the specified class using its default constructor. This method provides a convenient way to instantiate objects without requiring explicit knowledge of the constructor details.
      Parameters:
      clazz - The class for which a new instance should be created.
      args - The arguments for creating the new instance.
      Returns:
      A new instance of the specified class.
      Throws:
      NoSuchMethodException - If the default constructor is not found in the specified class.
      InvocationTargetException - If the constructor invocation fails.
      InstantiationException - If an instance of the class cannot be created (e.g., if it is an interface or an abstract class).
      IllegalAccessException - If the default constructor is not accessible due to access restrictions.
    • load

      boolean load(T provider)
      Loads a service provider and performs necessary operations. This method is intended to be implemented by concrete classes that use this interface to define the specific behavior of loading a service provider.
      Parameters:
      provider - The instance of the service provider to be loaded.
      Returns:
      true if the provider is successfully loaded, false otherwise.