Class JakartaWebSocketVisitor

java.lang.Object
io.micronaut.servlet.annotation.processor.JakartaWebSocketVisitor
All Implemented Interfaces:
io.micronaut.core.order.Ordered, io.micronaut.core.util.Toggleable, io.micronaut.inject.visitor.TypeElementVisitor<Object,Object>

public final class JakartaWebSocketVisitor extends Object implements io.micronaut.inject.visitor.TypeElementVisitor<Object,Object>
Validates a Jakarta WebSocket endpoint at compilation time and settles its scope.

The mappers turn the Jakarta annotations into Micronaut ones; this visitor checks what the runtime cannot recover from and reports it against the source instead of the first handshake: a server endpoint has a message handler, an endpoint has at most one handler per category, does not use partial messages, and every class it names in decoders, encoders or configurator can be instantiated. The ones that are not beans get an introspection generated, so no reflection is needed to create them.

A @ServerEndpoint is mapped onto @ServerWebSocket. A @ClientEndpoint maps onto no Micronaut annotation: it is a plain bean whose handlers the lifecycle mappers made executable, opened through the WebSocketContainer bean with the URI given to connectToServer. A client has no URI template, so @PathParam is rejected, and no reason to receive, so @OnMessage is optional.

An endpoint that declares no scope of its own is made a @Prototype, which is the Jakarta contract of one endpoint instance per connection. A declared scope wins.

Since:
6.2.0
Author:
graemerocher
  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.micronaut.inject.visitor.TypeElementVisitor

    io.micronaut.inject.visitor.TypeElementVisitor.VisitorKind
  • Field Summary

    Fields inherited from interface io.micronaut.core.order.Ordered

    HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    io.micronaut.inject.visitor.TypeElementVisitor.VisitorKind
     
    void
    visitClass(io.micronaut.inject.ast.ClassElement element, io.micronaut.inject.visitor.VisitorContext context)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.micronaut.core.order.Ordered

    getOrder

    Methods inherited from interface io.micronaut.core.util.Toggleable

    isEnabled

    Methods inherited from interface io.micronaut.inject.visitor.TypeElementVisitor

    finish, getClassType, getElementType, getSupportedOptions, query, start, visitConstructor, visitEnumConstant, visitField, visitMethod
  • Constructor Details

    • JakartaWebSocketVisitor

      public JakartaWebSocketVisitor()
  • Method Details

    • getVisitorKind

      public io.micronaut.inject.visitor.TypeElementVisitor.VisitorKind getVisitorKind()
      Specified by:
      getVisitorKind in interface io.micronaut.inject.visitor.TypeElementVisitor<Object,Object>
    • getSupportedAnnotationNames

      public Set<String> getSupportedAnnotationNames()
      Specified by:
      getSupportedAnnotationNames in interface io.micronaut.inject.visitor.TypeElementVisitor<Object,Object>
    • visitClass

      public void visitClass(io.micronaut.inject.ast.ClassElement element, io.micronaut.inject.visitor.VisitorContext context)
      Specified by:
      visitClass in interface io.micronaut.inject.visitor.TypeElementVisitor<Object,Object>