@Observer无法在JSF @Viewscoped带注释的Bean中工作

时间:2019-01-24 10:28:21

标签: jsf cdi jsf-2.3

我想使用@ViewScoped在托管bean上实现CDI事件
这是我的示例代码:
用于JSF的CDI托管Bean:

@ViewScoped
@Named
public class SampleBean implements Serializable {

    public void pushEvent(@Observes String str) {
        System.out.println("Bean " + str);
    }
    // And other methods and properties .
}

无状态服务:

@Stateless
@LocalBean
public class ExampleService {

    @Inject
    private Event<String> event;


    public void execute(String str) {
        event.fire(str);
    }
} 

JaxRs:

@Path("/test")
@RequestScoped
public class ExampleResources {

    @EJB
    private ExampleService service;

    @GET
    @Path("/execute")
    @Produces("application/json")
    public Response executeOperation(@QueryParam("str") String str) {
        service.execute(str);
        return Response.ok("String : " + str).build();
    }
}    

我想从Rest或soap Web服务向JSF bean发送事件。
我在Liberty 18.0.0.x上使用了JavaEE 8 webprofile。
什么是错?如何解决这个问题?

0 个答案:

没有答案
相关问题