Record Class JakartaEndpoint

java.lang.Object
java.lang.Record
io.micronaut.servlet.websocket.JakartaEndpoint
Record Components:
textMethod - The text message handler, if any
binaryMethod - The binary message handler, if any
pongMethod - The pong handler, if any
decoders - The declared decoder classes
encoders - The declared encoder classes
configurator - The declared configurator class, or null for the default
subprotocols - The declared subprotocols, in order of preference

@Internal public record JakartaEndpoint(@Nullable io.micronaut.inject.ExecutableMethod<Object,?> textMethod, @Nullable io.micronaut.inject.ExecutableMethod<Object,?> binaryMethod, @Nullable io.micronaut.inject.ExecutableMethod<Object,?> pongMethod, List<Class<?>> decoders, List<Class<?>> encoders, @Nullable Class<?> configurator, List<String> subprotocols) extends Record
What a @ServerEndpoint or @ClientEndpoint declares, read once from its bean definition.

The Jakarta model allows one message handler per category - text, binary and pong - where Micronaut has one that converts, so the handlers are classified here by the type of the message parameter, the way the compile time visitor classifies them, and the endpoint dispatches to the matching one. An object message counts as binary when a declared Decoder.Binary or Decoder.BinaryStream decodes its type, which the visitor records on the handler as @Consumes(APPLICATION_OCTET_STREAM).

Since:
6.2.0
Author:
graemerocher
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final String
     
    static final String
    The Jakarta annotations, by name so that the API is not needed to load this class.
  • Constructor Summary

    Constructors
    Constructor
    Description
    JakartaEndpoint(@Nullable io.micronaut.inject.ExecutableMethod<Object,?> textMethod, @Nullable io.micronaut.inject.ExecutableMethod<Object,?> binaryMethod, @Nullable io.micronaut.inject.ExecutableMethod<Object,?> pongMethod, List<Class<?>> decoders, List<Class<?>> encoders, @Nullable Class<?> configurator, List<String> subprotocols)
    Creates an instance of a JakartaEndpoint record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable io.micronaut.inject.ExecutableMethod<Object,?>
    Returns the value of the binaryMethod record component.
    @Nullable Class<?>
    Returns the value of the configurator record component.
    List<Class<? extends jakarta.websocket.Encoder>>
    The declared encoders the container may instantiate itself, reflectively, for RemoteEndpoint#sendObject: those the application has opted into reflection.
    Returns the value of the decoders record component.
    Returns the value of the encoders record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    static boolean
    isMapped(io.micronaut.inject.BeanDefinition<?> definition)
    Whether the annotation processor mapped the endpoint's handlers, so they can be invoked through the bean definition.
    static @Nullable JakartaEndpoint
    of(io.micronaut.inject.BeanDefinition<?> definition)
    Reads the endpoint from its bean definition.
    @Nullable io.micronaut.inject.ExecutableMethod<Object,?>
    Returns the value of the pongMethod record component.
    Returns the value of the subprotocols record component.
    @Nullable io.micronaut.inject.ExecutableMethod<Object,?>
    Returns the value of the textMethod record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • JakartaEndpoint

      public JakartaEndpoint(@Nullable io.micronaut.inject.ExecutableMethod<Object,?> textMethod, @Nullable io.micronaut.inject.ExecutableMethod<Object,?> binaryMethod, @Nullable io.micronaut.inject.ExecutableMethod<Object,?> pongMethod, List<Class<?>> decoders, List<Class<?>> encoders, @Nullable Class<?> configurator, List<String> subprotocols)
      Creates an instance of a JakartaEndpoint record class.
      Parameters:
      textMethod - the value for the textMethod record component
      binaryMethod - the value for the binaryMethod record component
      pongMethod - the value for the pongMethod record component
      decoders - the value for the decoders record component
      encoders - the value for the encoders record component
      configurator - the value for the configurator record component
      subprotocols - the value for the subprotocols record component
  • Method Details

    • of

      public static @Nullable JakartaEndpoint of(io.micronaut.inject.BeanDefinition<?> definition)
      Reads the endpoint from its bean definition.
      Parameters:
      definition - The bean definition
      Returns:
      The endpoint, or null when the bean declares neither Jakarta annotation
    • isMapped

      public static boolean isMapped(io.micronaut.inject.BeanDefinition<?> definition)
      Whether the annotation processor mapped the endpoint's handlers, so they can be invoked through the bean definition.

      A Jakarta endpoint that is a bean for another reason - a @Singleton compiled without the servlet processor - keeps its class annotation in the metadata but none of its handlers are executable; dispatching to it would silently invoke nothing. A mapped handler carries its Jakarta annotation next to the Micronaut one. An endpoint with no handler at all is not mapped either, and nothing is lost by leaving it to the container.

      Parameters:
      definition - The bean definition
      Returns:
      true if at least one handler was mapped
    • containerEncoders

      public List<Class<? extends jakarta.websocket.Encoder>> containerEncoders(JakartaEndpointComponents components)
      The declared encoders the container may instantiate itself, reflectively, for RemoteEndpoint#sendObject: those the application has opted into reflection.
      Parameters:
      components - The component resolver, which knows the reflection policy
      Returns:
      The encoder classes to pass to the container's endpoint configuration
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • textMethod

      public @Nullable io.micronaut.inject.ExecutableMethod<Object,?> textMethod()
      Returns the value of the textMethod record component.
      Returns:
      the value of the textMethod record component
    • binaryMethod

      public @Nullable io.micronaut.inject.ExecutableMethod<Object,?> binaryMethod()
      Returns the value of the binaryMethod record component.
      Returns:
      the value of the binaryMethod record component
    • pongMethod

      public @Nullable io.micronaut.inject.ExecutableMethod<Object,?> pongMethod()
      Returns the value of the pongMethod record component.
      Returns:
      the value of the pongMethod record component
    • decoders

      public List<Class<?>> decoders()
      Returns the value of the decoders record component.
      Returns:
      the value of the decoders record component
    • encoders

      public List<Class<?>> encoders()
      Returns the value of the encoders record component.
      Returns:
      the value of the encoders record component
    • configurator

      public @Nullable Class<?> configurator()
      Returns the value of the configurator record component.
      Returns:
      the value of the configurator record component
    • subprotocols

      public List<String> subprotocols()
      Returns the value of the subprotocols record component.
      Returns:
      the value of the subprotocols record component