Top Description Fields Constructors Methods
org.eclipse.jetty.websocket.common

public Class JettyWebSocketFrameHandlerFactory

extends ContainerLifeCycle
Class Inheritance
Imports
java.io.IOException, .InputStream, .Reader, java.lang.annotation.Annotation, java.lang.invoke.MethodHandle, .MethodHandles, java.lang.reflect.Method, .Modifier, java.nio.ByteBuffer, java.util.Map, java.util.concurrent.ConcurrentHashMap, org.eclipse.jetty.util.component.ContainerLifeCycle, org.eclipse.jetty.websocket.api.Callback, .Frame, .Session, .WebSocketContainer, org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose, .OnWebSocketError, .OnWebSocketFrame, .OnWebSocketMessage, .OnWebSocketOpen, .WebSocket, org.eclipse.jetty.websocket.api.exceptions.InvalidWebSocketException, org.eclipse.jetty.websocket.common.internal.ByteBufferMessageSink, .PartialByteBufferMessageSink, org.eclipse.jetty.websocket.core.WebSocketComponents, org.eclipse.jetty.websocket.core.exception.InvalidSignatureException, org.eclipse.jetty.websocket.core.messages.InputStreamMessageSink, .PartialStringMessageSink, .ReaderMessageSink, .StringMessageSink, org.eclipse.jetty.websocket.core.util.InvokerUtils, .ReflectUtils

Factory to create JettyWebSocketFrameHandler instances suitable for use with jetty-native websocket API.

Will create a org.eclipse.jetty.websocket.core.FrameHandler suitable for use with classes/objects that:

Field Summary

Modifier and TypeField and Description
private static final InvokerUtils.Arg[]
private static final InvokerUtils.Arg[]
private final WebSocketComponents
private final WebSocketContainer
private static final InvokerUtils.Arg[]
private final Map<Class<?>, JettyWebSocketFrameHandlerMetadata>
private static final InvokerUtils.Arg[]
private static final InvokerUtils.Arg[]
private static final InvokerUtils.Arg[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
assertSignatureValid(Class<?> endpointClass, Method method, Class<? extends Annotation> annotationClass)

private JettyWebSocketFrameHandlerMetadata
createAnnotatedMetadata(WebSocket anno, Class<?> endpointClass)

private JettyWebSocketFrameHandlerMetadata
createListenerMetadata(Class<?> endpointClass)

public JettyWebSocketFrameHandlerMetadata
createMetadata(Class<?> endpointClass)

public void
dump(Appendable
The appendable to dump to
out
,
String
The indent to apply after any new lines.
indent
)

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.dump.

Implements org.eclipse.jetty.util.component.Dumpable.dump.

Dump this object (and children) into an Appendable using the provided indent after any new lines.

private Method
findMethod(Class<?> klass, String name, Class<?>... parameters)

public static MethodHandles.Lookup

Returns:

a lookup object to be used to find methods on the lookupClass.
getApplicationMethodHandleLookup
(Class<?>
the desired lookup class for the new lookup object.
lookupClass
)

Gives a MethodHandles.Lookup instance to be used to find public methods in application classes.

public JettyWebSocketFrameHandlerMetadata
getMetadata(Class<?> endpointClass)

public static MethodHandles.Lookup

Returns:

a lookup object to be used to find methods on server classes.
getServerMethodHandleLookup
()

Gives a MethodHandles.Lookup instance to be used to find methods in server classes.

public WebSocketComponents
private boolean
public JettyWebSocketFrameHandler
newJettyFrameHandler(Object endpointInstance)

private MethodHandle
Inherited from org.eclipse.jetty.util.component.ContainerLifeCycle:
addBeanaddBeanaddEventListeneraddManagedcontainsdestroydoStartdoStopdumpdumpdumpObjectsdumpStdErrgetBeangetBeansgetBeansgetContainedBeansgetContainedBeansisAutoisManagedisUnmanagedmanageremoveBeanremoveBeansremoveEventListenersetBeansstartstopunmanageupdateBeanupdateBeanupdateBeansupdateBeans

Field Detail

binaryBufferCallingArgsback to summary
private static final InvokerUtils.Arg[] binaryBufferCallingArgs
binaryPartialBufferCallingArgsback to summary
private static final InvokerUtils.Arg[] binaryPartialBufferCallingArgs
componentsback to summary
private final WebSocketComponents components
containerback to summary
private final WebSocketContainer container
inputStreamCallingArgsback to summary
private static final InvokerUtils.Arg[] inputStreamCallingArgs
metadataMapback to summary
private final Map<Class<?>, JettyWebSocketFrameHandlerMetadata> metadataMap
readerCallingArgsback to summary
private static final InvokerUtils.Arg[] readerCallingArgs
textCallingArgsback to summary
private static final InvokerUtils.Arg[] textCallingArgs
textPartialCallingArgsback to summary
private static final InvokerUtils.Arg[] textPartialCallingArgs

Constructor Detail

JettyWebSocketFrameHandlerFactoryback to summary
public JettyWebSocketFrameHandlerFactory(WebSocketContainer container, WebSocketComponents components)

Method Detail

assertSignatureValidback to summary
private void assertSignatureValid(Class<?> endpointClass, Method method, Class<? extends Annotation> annotationClass)
createAnnotatedMetadataback to summary
private JettyWebSocketFrameHandlerMetadata createAnnotatedMetadata(WebSocket anno, Class<?> endpointClass)
createListenerMetadataback to summary
private JettyWebSocketFrameHandlerMetadata createListenerMetadata(Class<?> endpointClass)
createMetadataback to summary
public JettyWebSocketFrameHandlerMetadata createMetadata(Class<?> endpointClass)
dumpback to summary
public void dump(Appendable out, String indent) throws IOException

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.dump.

Implements org.eclipse.jetty.util.component.Dumpable.dump.

Doc from org.eclipse.jetty.util.component.Dumpable.dump.

Dump 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.

Parameters
out:Appendable

The appendable to dump to

indent:String

The indent to apply after any new lines.

Annotations
@Override
Exceptions
IOException:
if unable to write to Appendable
findMethodback to summary
private Method findMethod(Class<?> klass, String name, Class<?>... parameters)
getApplicationMethodHandleLookupback to summary
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 java.lang.invoke.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 java.lang.invoke.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:Class<?>

the desired lookup class for the new lookup object.

Returns:MethodHandles.Lookup

a lookup object to be used to find methods on the lookupClass.

getMetadataback to summary
public JettyWebSocketFrameHandlerMetadata getMetadata(Class<?> endpointClass)
getServerMethodHandleLookupback to summary
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:MethodHandles.Lookup

a lookup object to be used to find methods on server classes.

getWebSocketComponentsback to summary
public WebSocketComponents getWebSocketComponents()
isOverriddenback to summary
private boolean isOverridden(Method method)
newJettyFrameHandlerback to summary
public JettyWebSocketFrameHandler newJettyFrameHandler(Object endpointInstance)
toMethodHandleback to summary
private MethodHandle toMethodHandle(MethodHandles.Lookup lookup, Method method)