Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java ServerEndpointConfig.Configurator实例应该是线程安全的吗?_Java_Multithreading_Jakarta Ee_Websocket_Tyrus - Fatal编程技术网

Java ServerEndpointConfig.Configurator实例应该是线程安全的吗?

Java ServerEndpointConfig.Configurator实例应该是线程安全的吗?,java,multithreading,jakarta-ee,websocket,tyrus,Java,Multithreading,Jakarta Ee,Websocket,Tyrus,我想在websocket连接之间共享一些信息。共享数据有点复杂,因此我无法使用EndpointConfig.getUserProperties()。我想扩展ServerEndpointConfig.Configurator并添加我自己的数据结构。(我不想覆盖其他方法,如getEndpointInstance)。问题是我应该使用线程安全的数据结构吗?或者,我可以使用任何数据结构,web套接字容器将保证以安全的方式访问我的ServerEndpointConfig.Configurator实例。这感觉

我想在websocket连接之间共享一些信息。共享数据有点复杂,因此我无法使用
EndpointConfig.getUserProperties()
。我想扩展
ServerEndpointConfig.Configurator
并添加我自己的数据结构。(我不想覆盖其他方法,如
getEndpointInstance
)。问题是我应该使用线程安全的数据结构吗?或者,我可以使用任何数据结构,web套接字容器将保证以安全的方式访问我的
ServerEndpointConfig.Configurator
实例。

这感觉太粗糙了。
Configurator应该是不可变的(检查),而不是共享点。
在JavaEE环境中有一种更好的方法。
Websocket规范为CDI/EJB提供了一些支持。您可以插入
@ApplicationScoped
@Singleton
bean,并使用它共享数据(该bean必须同步)。
这里有一个共享的反例