gpt4 book ai didi

java - Richfaces 4 和 a4j :push in Seam

转载 作者:行者123 更新时间:2023-12-02 07:37:16 25 4
gpt4 key购买 nike

我刚刚在 JBoss AS 7 上从 Richfaces 3.3.3 升级到 4.2.2,从 Seam 2.2.2 升级到 Seam 2.3。目前运行良好。

但是我必须使用标签:a4j:push,而且我不知道如何将接缝组件绑定(bind)到这个标签。

我有什么:

@Name(TestBeanInterface.NAME)
@JndiName(value=TestBeanInterface.JNDI_NAME)
@Scope(ScopeType.SESSION)
public class TestBean implements Serializable {

private static final String CDI_PUSH_TOPIC = "pushCdi";

private String userIdentifier;

@Inject
@Push(topic = CDI_PUSH_TOPIC, subtopic = "#{testBean.userIdentifier}")
private javax.enterprise.event.Event<String> pushEvent;

@PostConstruct
public void init() {
System.out.println("hey");

if (userIdentifier == null) {
userIdentifier = UUID.randomUUID().toString().replace("-", "");
}

TopicsContext topicsContext = TopicsContext.lookup();
topicsContext.getOrCreateTopic(new TopicKey(CDI_PUSH_TOPIC, userIdentifier));
}

public void sendMessage() throws Exception {
System.out.println("Send Message");
pushEvent.fire("a test message");
}

public String getUserIdentifier() {
return userIdentifier;
}

public void setUserIdentifier(String userIdentifier) {
this.userIdentifier = userIdentifier;
}
}

我得到了什么:

22:23:28,191 INFO  [org.atmosphere.cpr.AtmosphereFramework] (MSC service thread 1-2) Atmosphere is using async support: org.atmosphere.container.BlockingIOCometSupport running under container: JBoss Web/7.0.13.Final
22:23:28,193 INFO [org.atmosphere.cpr.AtmosphereFramework] (MSC service thread 1-2) Installed WebSocketProtocol org.atmosphere.websocket.protocol.SimpleHttpProtocol
22:23:28,201 INFO [org.atmosphere.cpr.AtmosphereFramework] (MSC service thread 1-2) Installed Default AtmosphereInterceptor [Android Interceptor Support, SSE Interceptor Support, JSONP Interceptor Support]. Set org.atmosphere.cpr.AtmosphereInterceptor.disableDefaults in your xml to disable them.
22:23:28,203 WARN [org.atmosphere.cpr.AtmosphereFramework] (MSC service thread 1-2) No BroadcasterCache configured. Broadcasted message between client reconnection will be LOST. It is recommended to configure the HeaderBroadcasterCache.
22:23:28,204 INFO [org.atmosphere.cpr.AtmosphereFramework] (MSC service thread 1-2) HttpSession supported: false
22:23:28,205 INFO [org.atmosphere.cpr.AtmosphereFramework] (MSC service thread 1-2) Using BroadcasterFactory: org.atmosphere.cpr.DefaultBroadcasterFactory
22:23:28,205 INFO [org.atmosphere.cpr.AtmosphereFramework] (MSC service thread 1-2) Using WebSocketProcessor: org.atmosphere.websocket.DefaultWebSocketProcessor
22:23:28,206 INFO [org.atmosphere.cpr.AtmosphereFramework] (MSC service thread 1-2) Using Broadcaster: org.atmosphere.cpr.DefaultBroadcaster
22:23:28,208 INFO [org.atmosphere.cpr.AtmosphereFramework] (MSC service thread 1-2) Atmosphere Framework 1.0.0.beta5 started.
22:23:28,212 INFO [org.atmosphere.cpr.MeteorServlet] (MSC service thread 1-2) Installed Filter/Meteor org.richfaces.webapp.PushHandlerFilter mapped to /*
22:23:28,234 INFO [org.atmosphere.cpr.AtmosphereFramework] (MSC service thread 1-2) Installed AtmosphereHandler org.atmosphere.handler.ReflectorServletProcessor mapped to context-path: /*
22:23:28,236 INFO [org.atmosphere.handler.ReflectorServletProcessor] (MSC service thread 1-2) Installing Servlet null
22:23:28,238 INFO [org.atmosphere.handler.ReflectorServletProcessor] (MSC service thread 1-2) Installing Filter PushHandlerFilter
.....
22:23:38,101 INFO [stdout] (http-localhost-127.0.0.1-8080-1) hey
22:23:38,538 WARN [org.jboss.seam.mock.MockViewHandler] (http-localhost-127.0.0.1-8080-1) You should catch the exception before Seam: java.lang.IllegalArgumentException: no file extension in servlet path: /__richfaces_push
at org.jboss.seam.mock.MockViewHandler.getActionURL(MockViewHandler.java:49) [jboss-seam.jar:2.3.0.Beta2]
at org.jboss.seam.jsf.SeamViewHandler.getActionURL(SeamViewHandler.java:75) [jboss-seam.jar:2.3.0.Beta2]
at org.jboss.seam.faces.FacesManager.redirect(FacesManager.java:168) [jboss-seam.jar:2.3.0.Beta2]
at org.jboss.seam.faces.Redirect.execute(Redirect.java:154) [jboss-seam.jar:2.3.0.Beta2]
at org.jboss.seam.exception.DebugPageHandler.handle(DebugPageHandler.java:32) [jboss-seam.jar:2.3.0.Beta2]
at org.jboss.seam.exception.Exceptions.handle(Exceptions.java:76) [jboss-seam.jar:2.3.0.Beta2]
at org.jboss.seam.web.ExceptionFilter.endWebRequestAfterException(ExceptionFilter.java:114) [jboss-seam.jar:2.3.0.Beta2]
at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:70) [jboss-seam.jar:2.3.0.Beta2]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam.jar:2.3.0.Beta2]
at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45) [jboss-seam.jar:2.3.0.Beta2]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam.jar:2.3.0.Beta2]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73) [jboss-seam.jar:2.3.0.Beta2]
at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158) [jboss-seam.jar:2.3.0.Beta2]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:397) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
at java.lang.Thread.run(Thread.java:679) [rt.jar:1.6.0_24]

最佳答案

这些是我最终在推送工作后在 Richfaces 论坛上写的笔记。请仔细阅读并看看这是否有帮助。

  • 我使用的是 servlet v3 容器 (web.xml: web-app version="3.0"),因此不需要在 web.xml 中显式声明推送 servlet。

    <
  • 我在 web.xml 中看到过一些 PushFilter 的示例,这肯定给我带来了问题,只有在删除它后我才让它正常工作。

  • 我已经看到建议在 web.xml 中使用它,但我不需要:

    <context-param>
    <param-name>org.richfaces.push.handlerMapping</param-name>
    <param-value>/__richfaces_push</param-value>
    </context-param>
  • 0.8.0-RC1之后(不包括)的Atmosphere版本似乎有问题这会导致 WebSockets 出现 NoClassDefFound 错误(无论如何)。最新版本0.8.2无法运行。

  • 需要java文件中与topicsContext相关的行 - 这就是导致“主题'主题名称'未配置错误”的原因。展示示例中缺少这些内容,但在组件指南中引用了这些内容。

pom.xml

<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime</artifactId>
<version>0.8.0-RC1</version>
<type>jar</type>
</dependency>

域.xml

<jvm-options>-Dcom.sun.grizzly.http.asyncwrite.enabled=true</jvm-options>
<jvm-options>-Dcom.sun.grizzly.http.asyncwrite.maxBufferPoolSize=10000</jvm-options>

web.xml

<context-param>
<param-name>org.richfaces.push.jms.disable</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.atmosphere.useBlocking</param-name>
<param-value>true</param-value>
</context-param>
<servlet>
<description>AtmosphereServlet</description>
<servlet-name>AtmosphereServlet</servlet-name>
<servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
<async-supported>true</async-supported>
</servlet>

测试.xhtml

<h:outputText id="uid" value="uid: #{testBean.userIdentifier}"/>
<a4j:push address="#{testBean.userIdentifier}@pushCdi"
onerror="alert('error: ' + event.rf.data)"
ondataavailable="alert('data: ' + event.rf.data)">
<a4j:ajax event="dataavailable"/>
</a4j:push>

TestBean.java

@ViewScoped
public class TestBean implements Serializable {

private static final String CDI_PUSH_TOPIC = "pushCdi";
private String userIdentifier;
@Inject
@Push(topic = CDI_PUSH_TOPIC, subtopic = "#{testBean.userIdentifier}")
private javax.enterprise.event.Event<String> pushEvent;

@PostConstruct
public void init() {

if (userIdentifier == null) {
userIdentifier = UUID.randomUUID().toString().replace("-", "");
}

TopicsContext topicsContext = TopicsContext.lookup();
topicsContext.getOrCreateTopic(new TopicKey(CDI_PUSH_TOPIC, userIdentifier));
}

public void sendMessage() throws Exception {
Log.log("sendMessage");
pushEvent.fire("a test message");
}

// add getters & setters

关于java - Richfaces 4 和 a4j :push in Seam,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12035045/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com