Class JettyWebSocketFrameHandlerFactory
- All Implemented Interfaces:
Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle
JettyWebSocketFrameHandler instances suitable for
use with jetty-native websocket API.
Will create a FrameHandler suitable for use with classes/objects that:
- Is @
WebSocketannotated - Implements
Session.Listener
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopExceptionNested classes/interfaces inherited from interface Container
Container.InheritedListener, Container.ListenerNested classes/interfaces inherited from interface Dumpable
Dumpable.DumpableContainerNested classes/interfaces inherited from interface LifeCycle
LifeCycle.Listener -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionJettyWebSocketFrameHandlerFactory(WebSocketContainer container, WebSocketComponents components) -
Method Summary
Modifier and TypeMethodDescriptioncreateMetadata(Class<?> endpointClass) voiddump(Appendable out, String indent) Dump this object (and children) into an Appendable using the provided indent after any new lines.static MethodHandles.LookupgetApplicationMethodHandleLookup(Class<?> lookupClass) Gives aMethodHandles.Lookupinstance to be used to find public methods in application classes.getMetadata(Class<?> endpointClass) static MethodHandles.LookupGives aMethodHandles.Lookupinstance to be used to find methods in server classes.newJettyFrameHandler(Object endpointInstance) Methods inherited from class ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, doStart, doStop, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, installBean, installBean, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeansMethods inherited from class AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Container
getCachedBeans, getEventListenersMethods inherited from interface Dumpable.DumpableContainer
isDumpable
-
Constructor Details
-
JettyWebSocketFrameHandlerFactory
public JettyWebSocketFrameHandlerFactory(WebSocketContainer container, WebSocketComponents components)
-
-
Method Details
-
getWebSocketComponents
-
getMetadata
-
createMetadata
-
newJettyFrameHandler
-
getServerMethodHandleLookup
Gives a
MethodHandles.Lookupinstance to be used to find methods in server classes. For lookups on application classes usegetApplicationMethodHandleLookup(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
Gives a
MethodHandles.Lookupinstance to be used to find public methods in application classes. For lookups on server classes usegetServerMethodHandleLookup()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 usingMethodHandles.publicLookup()usingMethodHandles.lookup()withMethodHandles.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
Description copied from interface:DumpableDump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.- Specified by:
dumpin interfaceDumpable- Overrides:
dumpin classContainerLifeCycle- Parameters:
out- The appendable to dump toindent- The indent to apply after any new lines.- Throws:
IOException- if unable to write to Appendable
-