Record Class OnSPILoad

java.lang.Object
java.lang.Record
com.tnsai.hooks.events.OnSPILoad
Record Components:
eventId - ULID-shaped correlation id
timestamp - when the load occurred
context - surrounding hook context
spiInterface - fully-qualified name of the SPI interface
providerClass - fully-qualified name of the implementation
classLoader - loader that resolved the provider
providingJar - jar / module providing the implementation, when knowable; empty for inline / classpath providers
trusted - framework's classification — typically derived from allow-list config; defaults to true when no policy is configured
All Implemented Interfaces:
HookEvent, PluginHookEvent

public record OnSPILoad(String eventId, Instant timestamp, HookContext context, String spiInterface, String providerClass, ClassLoader classLoader, Optional<String> providingJar, boolean trusted) extends Record implements PluginHookEvent
Fires when a ServiceLoader-discovered provider is loaded (issue #63). Use for supply-chain audit (which providers loaded from where) or as a security gate (block providers from untrusted jars).

Block on this event causes the framework to skip the provider — the framework does NOT fail startup on a blocked provider; it logs a structured warning. Missing functionality from a blocked provider is the operator's problem, not a framework crash.

classLoader is the ServiceLoader's loader for the provider — useful for hooks that gate by classloader hierarchy (e.g. allow only providers loaded by the application classloader, reject providers from a child / plugin classloader).

Since:
0.5.0 (issue #63)
  • Constructor Details

    • OnSPILoad

      public OnSPILoad(String eventId, Instant timestamp, HookContext context, String spiInterface, String providerClass, ClassLoader classLoader, Optional<String> providingJar, boolean trusted)
      Creates an instance of a OnSPILoad record class.
      Parameters:
      eventId - the value for the eventId record component
      timestamp - the value for the timestamp record component
      context - the value for the context record component
      spiInterface - the value for the spiInterface record component
      providerClass - the value for the providerClass record component
      classLoader - the value for the classLoader record component
      providingJar - the value for the providingJar record component
      trusted - the value for the trusted record component
  • Method Details

    • eventType

      public String eventType()
      Description copied from interface: HookEvent
      Short stable string identifier of the event kind, e.g. "PreToolUse". Default implementation derives it from the concrete record's simple class name; concrete records may override if a different naming is desirable.
      Specified by:
      eventType in interface HookEvent
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • eventId

      public String eventId()
      Returns the value of the eventId record component.
      Specified by:
      eventId in interface HookEvent
      Returns:
      the value of the eventId record component
    • timestamp

      public Instant timestamp()
      Returns the value of the timestamp record component.
      Specified by:
      timestamp in interface HookEvent
      Returns:
      the value of the timestamp record component
    • context

      public HookContext context()
      Returns the value of the context record component.
      Specified by:
      context in interface HookEvent
      Returns:
      the value of the context record component
    • spiInterface

      public String spiInterface()
      Returns the value of the spiInterface record component.
      Returns:
      the value of the spiInterface record component
    • providerClass

      public String providerClass()
      Returns the value of the providerClass record component.
      Returns:
      the value of the providerClass record component
    • classLoader

      public ClassLoader classLoader()
      Returns the value of the classLoader record component.
      Returns:
      the value of the classLoader record component
    • providingJar

      public Optional<String> providingJar()
      Returns the value of the providingJar record component.
      Returns:
      the value of the providingJar record component
    • trusted

      public boolean trusted()
      Returns the value of the trusted record component.
      Returns:
      the value of the trusted record component