There is something that is called XXXBean that has some logic that generates event. There is also some class that is called as ServletContextListener
<listener>
<listener-class>XXXServletContextListener</listener-class>
</listener>
How can event from Bean can be sent to listener?
Update.
I have a Jetty WebSocket server that is running in the listener.
public class JettyServletContextListener implements ServletContextListener {
private Server server = null;
public void contextInitialized(ServletContextEvent event) {
this.server = new Server();
server.start();
}
public void contextDestroyed(ServletContextEvent event) {
if (server != null) {
server.stop();
}
}
}
This Jetty server should notifу remote client about events in the Bean though WebSocket connection.
You can’t.
ServletContextListeners are only informed of events about the context, i.e. when it is created and destroyed. They are usually used to do some kind of intialisation.Check the documentation at http://docs.oracle.com/javaee/5/api/javax/servlet/ServletContextListener.html