问题标签 [conversation-scope]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
218 浏览

jakarta-ee - ConversationScoped EntityManager

Actually I want to migrate a Seam 2 application to Java EE 7 with CDI and are trying to imitate the behavior of the Seam Home Component.

I am creating a application-managed EntityManager with a CDI producer and want to use it in a @ConversationScoped bean. I have defined my own EntityManager as a serializable wrapper around the default EntityManager implementation, which is just calling the methods of the delegate. The CDI producer looks as follows:

Do I need to define my conversationscoped Home component as @Stateful? An entity which was loaded by findon the injected entity manager is in a second step of the conversation not longer managed. A call of joinTransactiondoes not reattach the entity to the current EntityManager.

Edit:

I want to give some more information about the use case I am facing: As mentioned I want to imitate the Home component of Seam 2. So I created a own Home super class with CRUD methods for creating, updating and removing an entity. In the method for updating an entity I use following code:

If I call joinTransaction I can see in the log that getEntityManager().joinTransaction() is called. But this gives me the exception:

javax.persistence.TransactionRequiredException: Explicitly joining a JTA transaction requires a JTA transaction be currently activ

If I comment the line jooinTransaction() I'll get the following exception on the method call getEntityManager().flush():

javax.persistence.TransactionRequiredException: no transaction is in progress

So the problem is, that I would like to call flush and only then the entity should be persisted in database.

0 投票
2 回答
804 浏览

java - 启动 CDI 对话并将 @ConversationScoped bean 注入无状态会话 bean

已经提出了类似的问题,但并没有完全解决我想要做的事情。我们有一个旧的基于 Seam 2.x 的应用程序,带有一个我们正在转换为 CDI 的批处理作业框架。作业框架使用 Seam Contexts 对象来启动对话。作业框架还加载了一个特定于作业的数据持有者(基本上是一个地图),然后可以通过 Seam Contexts 对象由链下的任何服务访问,包括来自 SLSB。其中一些服务可以更新地图,以便作业状态可以更改并从记录到记录进行检测。

看起来在 CDI 中,作业将@Inject是一个 CDI 对话对象,并手动开始/结束对话。我们还将定义一个ConversationScoped包含 Map ( MapBean) 的新 bean。我不清楚的是两件事:

首先,作业还需要@InjectMapBean以便在调用 Conversation.begin() 方法之前加载作业特定的数据。容器是否知道将此实例传递给调用链中的服务?

与此相关,根据这个问题Is it possible to @Inject a @RequestScoped bean into a @Stateless EJB? 应该可以将ConservationScopedbean 注入到 SLSB 中,但这似乎有点神奇。如果 SLSB 被不同的进程(作业、UI 调用等)使用,它是否会为每个调用获取单独的实例?

为澄清和简化的类结构而进行的编辑:

MapBean需要是一个ConversationScoped对象,包含作业的特定实例/运行的数据。

工作将是ConversationScoped

该作业可能调用 SLSB,并且当前会话范围的实例MapBean需要可用:

我们的工作和 SLSB 框架相当复杂,SLSB 可以调用许多其他服务或本地实例化的业务逻辑类,并且每个都需要访问会话范围的MapBean.

0 投票
0 回答
322 浏览

java - PrimeFaces 6.2 与 CDI 对话的问题

我将 PrimeFaces 版本更新为 6.2。一切都很顺利,除了 CDI 对话管理的问题。
更新后,似乎对话在第一次访问页面时被初始化,但在第一次调用控制器之前它就丢失了。事实上,当访问一个页面时,一个新的对话就被初始化了(这是正确的)。但是在第一次调用控制器方法之后,会初始化一个新的对话,丢失之前的对话及其所有参数值。以下调用照常保持最后一次对话。

在 PrimeFaces 6.1(和之前的版本)中,这从未发生过。

这是一个错误还是我的缺乏?

访问页面后,显示的文字是“Init value with conversation id = 1”。
通过单击该按钮,显示的文本将更改为“Value set with conversation id = 2”。
以下点击保持 cid = 2。

控制器

JSF 页面

0 投票
1 回答
134 浏览

java - 将 CDI 对话界面标记为瞬态是否安全?

您可以在@ConversationScoped bean 中注入的对话接口是否可以安全地标记瞬态(即,CDI 会在序列化期间处理它)还是我需要自定义读/写对象?

FindBugs 抱怨一个非瞬态不可序列化的实例字段。

0 投票
0 回答
77 浏览

scope - 处理多个注入的 @ConversationScoped bean 的正确方法

我在一个 @ViewScoped bean 中注入了多个 @ConversationScoped bean,这导致了很多对话锁定问题。

为了纠正这个问题,在所有@ConversationScoped bean 中,我在开始新的对话之前添加了几行代码来结束现有的对话。

正如你在进入 begin() 时看到的那样,我将在开始新的对话之前结束所有以前的对话。

这是正确的方法吗?这会引起问题吗?

0 投票
1 回答
192 浏览

xmpp - 对话中的 A/V 呼叫 (xmpp)

音视频通话没问题手机在同一个网络,但是手机在不同网络的时候音视频通话不行,我们实现自己的服务器使用http://help.conversations.im/这个参考. 我们找不到解决方案。

解决方案是什么?