Class JettyWebSocketFrameHandlerFactory

java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.websocket.common.JettyWebSocketFrameHandlerFactory
All Implemented Interfaces:
org.eclipse.jetty.util.component.Container, org.eclipse.jetty.util.component.Destroyable, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.component.Dumpable.DumpableContainer, org.eclipse.jetty.util.component.LifeCycle

public class JettyWebSocketFrameHandlerFactory extends org.eclipse.jetty.util.component.ContainerLifeCycle
Factory to create JettyWebSocketFrameHandler instances suitable for use with jetty-native websocket API.

Will create a FrameHandler suitable for use with classes/objects that:

  • Is @WebSocket annotated
  • Extends WebSocketAdapter
  • Implements WebSocketListener
  • Implements WebSocketConnectionListener
  • Implements WebSocketPartialListener
  • Implements WebSocketPingPongListener
  • Implements WebSocketFrameListener
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener, org.eclipse.jetty.util.component.AbstractLifeCycle.StopException

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container

    org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.Listener

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable

    org.eclipse.jetty.util.component.Dumpable.DumpableContainer

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

    org.eclipse.jetty.util.component.LifeCycle.Listener
  • Field Summary

    Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    FAILED, STARTED, STARTING, STOPPED, STOPPING

    Fields inherited from interface org.eclipse.jetty.util.component.Dumpable

    KEY
  • Constructor Summary

    Constructors
    Constructor
    Description
    JettyWebSocketFrameHandlerFactory(org.eclipse.jetty.websocket.api.WebSocketContainer container, org.eclipse.jetty.websocket.core.WebSocketComponents components)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.eclipse.jetty.websocket.core.internal.messages.MessageSink
    createMessageSink(MethodHandle msgHandle, Class<? extends org.eclipse.jetty.websocket.core.internal.messages.MessageSink> sinkClass, Executor executor, WebSocketSession session)
     
    createMetadata(Class<?> endpointClass)
     
    void
    dump(Appendable out, String indent)
     
    Gives a MethodHandles.Lookup instance to be used to find public methods in application classes.
    getMetadata(Class<?> endpointClass)
     
    Gives a MethodHandles.Lookup instance to be used to find methods in server classes.
    org.eclipse.jetty.websocket.core.WebSocketComponents
     
    newJettyFrameHandler(Object endpointInstance)
     

    Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle

    addBean, addBean, addEventListener, addManaged, contains, destroy, doStart, doStop, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeans

    Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop, toString

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface org.eclipse.jetty.util.component.Container

    getCachedBeans, getEventListeners

    Methods inherited from interface org.eclipse.jetty.util.component.Dumpable

    dumpSelf

    Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer

    isDumpable
  • Constructor Details

    • JettyWebSocketFrameHandlerFactory

      public JettyWebSocketFrameHandlerFactory(org.eclipse.jetty.websocket.api.WebSocketContainer container, org.eclipse.jetty.websocket.core.WebSocketComponents components)
  • Method Details

    • getWebSocketComponents

      public org.eclipse.jetty.websocket.core.WebSocketComponents getWebSocketComponents()
    • getMetadata

      public JettyWebSocketFrameHandlerMetadata getMetadata(Class<?> endpointClass)
    • createMetadata

      public JettyWebSocketFrameHandlerMetadata createMetadata(Class<?> endpointClass)
    • newJettyFrameHandler

      public JettyWebSocketFrameHandler newJettyFrameHandler(Object endpointInstance)
    • createMessageSink

      public static org.eclipse.jetty.websocket.core.internal.messages.MessageSink createMessageSink(MethodHandle msgHandle, Class<? extends org.eclipse.jetty.websocket.core.internal.messages.MessageSink> sinkClass, Executor executor, WebSocketSession session)
    • getServerMethodHandleLookup

      public static MethodHandles.Lookup getServerMethodHandleLookup()

      Gives a MethodHandles.Lookup instance to be used to find methods in server classes. For lookups on application classes use getApplicationMethodHandleLookup(Class) instead.

      This uses the caller sensitive MethodHandles.lookup(), this will allow MethodHandle access to server classes we need to use and will give access permissions to private methods as well.

      Returns:
      a lookup object to be used to find methods on server classes.
    • getApplicationMethodHandleLookup

      public static MethodHandles.Lookup getApplicationMethodHandleLookup(Class<?> lookupClass)

      Gives a MethodHandles.Lookup instance to be used to find public methods in application classes. For lookups on server classes use getServerMethodHandleLookup() instead.

      This uses MethodHandles.publicLookup() as we only need access to public method of the lookupClass. To look up a method on the lookupClass, it must be public and the class must be accessible from this module, so if the lookupClass is in a JPMS module it must be exported so that the public methods of the lookupClass are accessible outside of the module.

      The MethodHandles.Lookup.in(Class) allows us to search specifically in the endpoint Class to avoid any potential linkage errors which could occur if the same class is present in multiple web apps. Unlike using MethodHandles.publicLookup() using MethodHandles.lookup() with MethodHandles.Lookup.in(Class) will cause the lookup to lose its public access to the lookup class if they are in different modules.

      MethodHandles.privateLookupIn(Class, MethodHandles.Lookup) is also unsuitable because it requires the caller module to read the target module, and the target module to open reflective access to the lookupClasses private methods. This is possible but requires extra configuration to provide private access which is not necessary for the purpose of accessing the public methods.

      Parameters:
      lookupClass - the desired lookup class for the new lookup object.
      Returns:
      a lookup object to be used to find methods on the lookupClass.
    • dump

      public void dump(Appendable out, String indent) throws IOException
      Specified by:
      dump in interface org.eclipse.jetty.util.component.Dumpable
      Overrides:
      dump in class org.eclipse.jetty.util.component.ContainerLifeCycle
      Throws:
      IOException