Java Richfaces 4和a4j:推入式接缝

Java Richfaces 4和a4j:推入式接缝,java,jsf,jboss,richfaces,seam,Java,Jsf,Jboss,Richfaces,Seam,我刚刚在JBossAS7上从Richfaces 3.3.3升级到4.2.2,从Seam 2.2.2升级到Seam 2.3。目前效果不错 但是我必须使用标签:a4j:push,我不知道如何将seam组件绑定到这个组件 我所拥有的: @Name(TestBeanInterface.NAME) @JndiName(value=TestBeanInterface.JNDI_NAME) @Scope(ScopeType.SESSION) public class TestBean implements S

我刚刚在JBossAS7上从Richfaces 3.3.3升级到4.2.2,从Seam 2.2.2升级到Seam 2.3。目前效果不错

但是我必须使用标签:a4j:push,我不知道如何将seam组件绑定到这个组件

我所拥有的:

@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;
}
}

这些是我最终完成推送工作后在Richfaces论坛上写的笔记。请看一下,看看这是否有帮助

  • 我使用的是ServletV3容器(web.xml:webappversion=“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>
    
    
    org.richfaces.push.handler映射
    /__里丘推
    
  • 高于(不包括)0.8.0-RC1的大气版本似乎存在问题 这会导致WebSocket出现NoClassDefFound错误(无论如何都是这样)。最新版本0.8.2不起作用

  • 需要java文件中与topicsContext相关的行-这就是导致“主题“topic name”未配置错误”的原因。showcase示例中缺少这些选项,但在《组件指南》中引用了这些选项

pom.xml

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

组织气氛
大气运行时间
0.8.0-RC1
罐子
domain.xml

<jvm-options>-Dcom.sun.grizzly.http.asyncwrite.enabled=true</jvm-options>
<jvm-options>-Dcom.sun.grizzly.http.asyncwrite.maxBufferPoolSize=10000</jvm-options>
-Dcom.sun.grizzly.http.asyncwrite.enabled=true
-Dcom.sun.grizzly.http.asyncwrite.maxBufferPoolSize=10000
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>

org.richfaces.push.jms.disable
真的
org.atmosphere.useBlocking
真的
大气小卫星
大气小卫星
org.atmosphere.cpr.AtmosphereServlet
真的
test.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
@ViewScoped
公共类TestBean实现了可序列化{
私有静态最终字符串CDI\u PUSH\u TOPIC=“pushCdi”;
私有字符串用户标识符;
@注入
@Push(topic=CDI_Push_topic,subtopic=“#{testBean.userIdentifier}”)
私有javax.enterprise.event.event pushEvent;
@施工后
公共void init(){
if(userIdentifier==null){
userIdentifier=UUID.randomUUID().toString().replace(“-”,”);
}
TopicsContext TopicsContext=TopicsContext.lookup();
getOrCreateTopic(新TopicKey(CDI_PUSH_TOPIC,userIdentifier));
}
public void sendMessage()引发异常{
Log.Log(“发送消息”);
pushEvent.fire(“测试消息”);
}
//添加getter和setter

Hello Oversteer,谢谢你的回答。问题:我得到了java.lang.ClassNotFoundException:org.apache.catalina.comet.CometProcessor,但我的库中有atmosphere compact。我在哪里写domain.xml?我应该说清楚(但没有)domain.xml内容仅为glassfish,因此对此表示歉意。在类路径中是否有atmosphere compat jbossweb*.jar?好的……我处于不稳定状态……我无法创建任何非seam bean的bean……请看一看,我尝试做什么。
@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