0

我想使用 @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);
    }
} 

贾克斯:

@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 services 向 JSF bean 发送事件。
我在 Liberty 18.0.0.x 上使用了 JavaEE 8 webprofile。
什么是错误?如何解决这个问题?

4

0 回答 0