Record Class JakartaEndpoint
- Record Components:
textMethod- The text message handler, if anybinaryMethod- The binary message handler, if anypongMethod- The pong handler, if anydecoders- The declared decoder classesencoders- The declared encoder classesconfigurator- The declared configurator class, ornullfor the defaultsubprotocols- The declared subprotocols, in order of preference
@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 -
Constructor Summary
ConstructorsConstructorDescriptionJakartaEndpoint(@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 aJakartaEndpointrecord class. -
Method Summary
Modifier and TypeMethodDescription@Nullable io.micronaut.inject.ExecutableMethod<Object, ?> Returns the value of thebinaryMethodrecord component.@Nullable Class<?> Returns the value of theconfiguratorrecord component.containerEncoders(JakartaEndpointComponents components) The declared encoders the container may instantiate itself, reflectively, forRemoteEndpoint#sendObject: those the application has opted into reflection.decoders()Returns the value of thedecodersrecord component.encoders()Returns the value of theencodersrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static booleanisMapped(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 JakartaEndpointof(io.micronaut.inject.BeanDefinition<?> definition) Reads the endpoint from its bean definition.@Nullable io.micronaut.inject.ExecutableMethod<Object, ?> Returns the value of thepongMethodrecord component.Returns the value of thesubprotocolsrecord component.@Nullable io.micronaut.inject.ExecutableMethod<Object, ?> Returns the value of thetextMethodrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
SERVER_ENDPOINT
The Jakarta annotations, by name so that the API is not needed to load this class.- See Also:
-
CLIENT_ENDPOINT
- See Also:
-
ON_MESSAGE
- See Also:
-
-
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 aJakartaEndpointrecord class.- Parameters:
textMethod- the value for thetextMethodrecord componentbinaryMethod- the value for thebinaryMethodrecord componentpongMethod- the value for thepongMethodrecord componentdecoders- the value for thedecodersrecord componentencoders- the value for theencodersrecord componentconfigurator- the value for theconfiguratorrecord componentsubprotocols- the value for thesubprotocolsrecord component
-
-
Method Details
-
of
Reads the endpoint from its bean definition.- Parameters:
definition- The bean definition- Returns:
- The endpoint, or
nullwhen 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
@Singletoncompiled 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:
trueif 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, forRemoteEndpoint#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
-
hashCode
-
equals
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 withObjects::equals(Object,Object). -
textMethod
Returns the value of thetextMethodrecord component.- Returns:
- the value of the
textMethodrecord component
-
binaryMethod
Returns the value of thebinaryMethodrecord component.- Returns:
- the value of the
binaryMethodrecord component
-
pongMethod
Returns the value of thepongMethodrecord component.- Returns:
- the value of the
pongMethodrecord component
-
decoders
-
encoders
-
configurator
Returns the value of theconfiguratorrecord component.- Returns:
- the value of the
configuratorrecord component
-
subprotocols
Returns the value of thesubprotocolsrecord component.- Returns:
- the value of the
subprotocolsrecord component
-