I want to implement CDI event on a managed bean with @ViewScoped
this is my example code :
CDI managed bean for JSF:
@ViewScoped
@Named
public class SampleBean implements Serializable {
public void pushEvent(@Observes String str) {
System.out.println("Bean " + str);
}
// And other methods and properties .
}
Stateless Service :
@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();
}
}
I want to sent event to JSF bean from Rest or soap web services .
I used JavaEE 8 webprofile on Liberty 18.0.0.x .
What is mistake ? How can fix this problem ?