Class Hook<E>

java.lang.Object
org.jppf.utils.hooks.Hook<E>
Type Parameters:
E -

public class Hook<E> extends Object
Author:
Laurent Cohen
  • Constructor Details

    • Hook

      public Hook(JPPFProperty<String> property, Class<E> infClass, E defaultImpl, ClassLoader loader)
      Register a hook defined via a configuration property, of which a single instance is discovered and invoked.
      Parameters:
      property - the name of the property used to specify the hook implementation class name.
      infClass - the class of the hook's interface.
      defaultImpl - the default implementation, which may be null.
      loader - the class loader used to load the implemntation.
    • Hook

      public Hook(JPPFProperty<String> property, Class<E> infClass, E defaultImpl, ClassLoader loader, Class<?>[] paramTypes, Object... params)
      Register a hook defined via a configuration property, of which a single instance is discovered and invoked.
      Parameters:
      property - the name of the property used to specify the hook implementation class name.
      infClass - the class of the hook's interface.
      defaultImpl - the default implementation, which may be null.
      loader - the class loader used to load the implemntation.
      paramTypes - types of the parameters to pass to the constructor.
      params - the parameters to pass to the constructor.
    • Hook

      public Hook(Class<E> infClass, E defaultImpl, ClassLoader loader, boolean single)
      Register a hook defined via SPI.
      Parameters:
      infClass - the class of the hook's interface.
      defaultImpl - the default implementation, which may be null.
      loader - the class loader used to load the implemntation.
      single - determines whether only the first looked up implementation should be used, or all the instances found.
    • Hook

      public Hook(Class<E> infClass, E defaultImpl, ClassLoader loader, boolean single, Class<?>[] paramTypes, Object... params)
      Register a hook defined via SPI.
      Parameters:
      infClass - the class of the hook's interface.
      defaultImpl - the default implementation, which may be null.
      loader - the class loader used to load the implemntation.
      single - determines whether only the first looked up implementation should be used, or all the instances found.
      paramTypes - types of the parameters to pass to the constructor.
      params - the parameters to pass to the constructor.
  • Method Details

    • getInterfaceName

      public String getInterfaceName()
      Get the hook interface.
      Returns:
      the class object for the hook's interface.
    • getType

      public HookType getType()
      Get the type of this hook.
      Returns:
      the type as a typesafe HookType enum value.
    • invoke

      public Object[] invoke(String methodName, Object... parameters)
      Invoke each instance of this hook.
      Parameters:
      methodName - the name of the implementation method to invoke.
      parameters - the parameters supplied to each method invocation.
      Returns:
      this method always return null.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getInstances

      public List<HookInstance<E>> getInstances()
      Get the list of instances of this hook.
      Returns:
      a list of HookInstance objects.
    • dispose

      public void dispose()
      Cleanup this hook and release its resources.