Class JavaxWebSocketFrameHandlerFactory
- Direct Known Subclasses:
JavaxWebSocketClientFrameHandlerFactory
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final WebSocketComponentsprotected final JavaxWebSocketContainerprotected final InvokerUtils.ParamIdentifier -
Constructor Summary
ConstructorsConstructorDescriptionJavaxWebSocketFrameHandlerFactory(JavaxWebSocketContainer container, InvokerUtils.ParamIdentifier paramIdentifier) -
Method Summary
Modifier and TypeMethodDescriptionstatic MethodHandlebindTemplateVariables(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.protected JavaxWebSocketFrameHandlerMetadatacreateEndpointMetadata(javax.websocket.EndpointConfig endpointConfig) static MessageSinkcreateMessageSink(JavaxWebSocketSession session, JavaxWebSocketMessageMetadata msgMetadata) protected JavaxWebSocketFrameHandlerMetadatadiscoverJakartaFrameHandlerMetadata(Class<?> endpointClass, JavaxWebSocketFrameHandlerMetadata metadata) static MethodHandles.LookupgetApplicationMethodHandleLookup(Class<?> lookupClass) Gives aMethodHandles.Lookupinstance to be used to find public methods in application classes.abstract JavaxWebSocketFrameHandlerMetadatagetMetadata(Class<?> endpointClass, javax.websocket.EndpointConfig endpointConfig) static MethodHandles.LookupGives aMethodHandles.Lookupinstance to be used to find methods in server classes.abstract javax.websocket.EndpointConfignewDefaultEndpointConfig(Class<?> endpointClass) newJakartaWebSocketFrameHandler(Object endpointInstance, UpgradeRequest upgradeRequest) static MethodHandlewrapNonVoidReturnType(MethodHandle handle, JavaxWebSocketSession session)
-
Field Details
-
container
-
paramIdentifier
-
components
-
-
Constructor Details
-
JavaxWebSocketFrameHandlerFactory
public JavaxWebSocketFrameHandlerFactory(JavaxWebSocketContainer container, InvokerUtils.ParamIdentifier paramIdentifier)
-
-
Method Details
-
getMetadata
public abstract JavaxWebSocketFrameHandlerMetadata getMetadata(Class<?> endpointClass, javax.websocket.EndpointConfig endpointConfig) -
newDefaultEndpointConfig
-
newJakartaWebSocketFrameHandler
public JavaxWebSocketFrameHandler newJakartaWebSocketFrameHandler(Object endpointInstance, UpgradeRequest upgradeRequest) -
createMessageSink
public static MessageSink createMessageSink(JavaxWebSocketSession session, JavaxWebSocketMessageMetadata msgMetadata) -
wrapNonVoidReturnType
public static MethodHandle wrapNonVoidReturnType(MethodHandle handle, JavaxWebSocketSession session) -
createEndpointMetadata
protected JavaxWebSocketFrameHandlerMetadata createEndpointMetadata(javax.websocket.EndpointConfig endpointConfig) -
discoverJakartaFrameHandlerMetadata
protected JavaxWebSocketFrameHandlerMetadata discoverJakartaFrameHandlerMetadata(Class<?> endpointClass, JavaxWebSocketFrameHandlerMetadata metadata) -
bindTemplateVariables
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- the target MethodHandle to work with. This is assumed to contain aMethodHandle.type()where all of the initial parameters are the same parameters as found in the providednamedVariablesarray.namedVariables- the array of named variables. Can be null.templateValues- the Map of template values (Key to Value), must have same number of entries thatnamedVariableshas.- Returns:
- a MethodHandle where all of the
namedVariablesin the target type have been statically assigned a converted value (and removed from the resultingMethodHandle.type(), or null if notargetMethodHandle was provided.
-
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.
-