Top Fields Constructors Methods
org.eclipse.jetty.ee10.websocket.jakarta.common

public abstract Class JakartaWebSocketFrameHandlerFactory

extends Object
Class Inheritance
Imports
java.lang.annotation.Annotation, java.lang.invoke.MethodHandle, .MethodHandles, .MethodType, java.lang.reflect.InvocationTargetException, .Method, .Modifier, java.nio.ByteBuffer, java.util.ArrayList, .List, .Map, java.util.function.Function, jakarta.websocket.CloseReason, .Decoder, .Endpoint, .EndpointConfig, .OnClose, .OnError, .OnMessage, .OnOpen, .PongMessage, .Session, org.eclipse.jetty.ee10.websocket.jakarta.common.decoders.RegisteredDecoder, org.eclipse.jetty.ee10.websocket.jakarta.common.messages.AbstractDecodedMessageSink, .DecodedBinaryMessageSink, .DecodedBinaryStreamMessageSink, .DecodedTextMessageSink, .DecodedTextStreamMessageSink, org.eclipse.jetty.http.pathmap.UriTemplatePathSpec, org.eclipse.jetty.websocket.core.CoreSession, .WebSocketComponents, org.eclipse.jetty.websocket.core.exception.InvalidSignatureException, .InvalidWebSocketException, org.eclipse.jetty.websocket.core.messages.MessageSink, .PartialByteArrayMessageSink, .PartialByteBufferMessageSink, .PartialStringMessageSink, org.eclipse.jetty.websocket.core.util.InvokerUtils, .ReflectUtils

Field Summary

Modifier and TypeField and Description
pack-priv static final InvokerUtils.Arg[]
pack-priv static final InvokerUtils.Arg[]
protected final WebSocketComponents
protected final JakartaWebSocketContainer
private static final MethodHandle
protected final InvokerUtils.ParamIdentifier
pack-priv static final InvokerUtils.Arg[]
pack-priv 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)

public static MethodHandle

Returns:

a MethodHandle where all of the namedVariables in the target type have been statically assigned a converted value (and removed from the resulting MethodHandle#type(), or null if no target MethodHandle was provided.
bindTemplateVariables
(MethodHandle
the target MethodHandle to work with. This is assumed to contain a MethodHandle#type() where all of the initial parameters are the same parameters as found in the provided namedVariables array.
target
,
String[]
the array of named variables. Can be null.
namedVariables
,
Map<String, String>
the Map of template values (Key to Value), must have same number of entries that namedVariables has.
templateValues
)

Bind the URI Template Variables to their provided values, converting to the type that the MethodHandle target has declared.

protected JakartaWebSocketFrameHandlerMetadata
public static MessageSink
protected JakartaWebSocketFrameHandlerMetadata
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.

pack-priv static InvokerUtils.Arg[]
getArgsFor(Class<?> objectType)

public abstract JakartaWebSocketFrameHandlerMetadata
getMetadata(Class<?> endpointClass, EndpointConfig endpointConfig)

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.

private boolean
private boolean
public abstract EndpointConfig
newDefaultEndpointConfig(Class<?> endpointClass)

public JakartaWebSocketFrameHandler
newJakartaWebSocketFrameHandler(Object endpointInstance, UpgradeRequest upgradeRequest)

private MethodHandle
public static MethodHandle
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

binaryPartialArrayCallingArgsback to summary
pack-priv static final InvokerUtils.Arg[] binaryPartialArrayCallingArgs
binaryPartialBufferCallingArgsback to summary
pack-priv static final InvokerUtils.Arg[] binaryPartialBufferCallingArgs
componentsback to summary
protected final WebSocketComponents components
containerback to summary
protected final JakartaWebSocketContainer container
FILTER_RETURN_TYPE_METHODback to summary
private static final MethodHandle FILTER_RETURN_TYPE_METHOD
paramIdentifierback to summary
protected final InvokerUtils.ParamIdentifier paramIdentifier
pongCallingArgsback to summary
pack-priv static final InvokerUtils.Arg[] pongCallingArgs
textPartialCallingArgsback to summary
pack-priv static final InvokerUtils.Arg[] textPartialCallingArgs

Constructor Detail

JakartaWebSocketFrameHandlerFactoryback to summary
public JakartaWebSocketFrameHandlerFactory(JakartaWebSocketContainer container, InvokerUtils.ParamIdentifier paramIdentifier)

Method Detail

assertSignatureValidback to summary
private void assertSignatureValid(Class<?> endpointClass, Method method, Class<? extends Annotation> annotationClass)
bindTemplateVariablesback to summary
public static MethodHandle bindTemplateVariables(MethodHandle target, String[] namedVariables, Map<String, String> templateValues)

Bind the URI Template Variables to their provided values, converting to the type that the MethodHandle target has declared.

Conversion follows the JSR356 rules for @PathParam and only supports String, Primitive Types (and their Boxed version)

Parameters
target:MethodHandle

the target MethodHandle to work with. This is assumed to contain a MethodHandle#type() where all of the initial parameters are the same parameters as found in the provided namedVariables array.

namedVariables:String[]

the array of named variables. Can be null.

templateValues:Map<String, String>

the Map of template values (Key to Value), must have same number of entries that namedVariables has.

Returns:MethodHandle

a MethodHandle where all of the namedVariables in the target type have been statically assigned a converted value (and removed from the resulting MethodHandle#type(), or null if no target MethodHandle was provided.

createEndpointMetadataback to summary
protected JakartaWebSocketFrameHandlerMetadata createEndpointMetadata(EndpointConfig endpointConfig)
createMessageSinkback to summary
public static MessageSink createMessageSink(JakartaWebSocketSession session, JakartaWebSocketMessageMetadata msgMetadata)
discoverJakartaFrameHandlerMetadataback to summary
protected JakartaWebSocketFrameHandlerMetadata discoverJakartaFrameHandlerMetadata(Class<?> endpointClass, JakartaWebSocketFrameHandlerMetadata metadata)
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.

getArgsForback to summary
pack-priv static InvokerUtils.Arg[] getArgsFor(Class<?> objectType)
getMetadataback to summary
public abstract JakartaWebSocketFrameHandlerMetadata getMetadata(Class<?> endpointClass, EndpointConfig endpointConfig)
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.

matchDecodersback to summary
private boolean matchDecoders(Method onMsg, JakartaWebSocketFrameHandlerMetadata metadata, JakartaWebSocketMessageMetadata msgMetadata, Function<InvokerUtils.Arg[], MethodHandle> getMethodHandle)
matchOnMessageback to summary
private boolean matchOnMessage(Method onMsg, JakartaWebSocketFrameHandlerMetadata metadata, JakartaWebSocketMessageMetadata msgMetadata, Function<InvokerUtils.Arg[], MethodHandle> getMethodHandle)
newDefaultEndpointConfigback to summary
public abstract EndpointConfig newDefaultEndpointConfig(Class<?> endpointClass)
newJakartaWebSocketFrameHandlerback to summary
public JakartaWebSocketFrameHandler newJakartaWebSocketFrameHandler(Object endpointInstance, UpgradeRequest upgradeRequest)
toMethodHandleback to summary
private MethodHandle toMethodHandle(MethodHandles.Lookup lookup, Method method)
wrapNonVoidReturnTypeback to summary
public static MethodHandle wrapNonVoidReturnType(MethodHandle handle, JakartaWebSocketSession session)