java - Interservlet communication -
i have websocket servlet , rest servlet. want inform websocket servlet changes in order write these "events" via websocket server.
i find forward() , include() approach. seem me can forward onget, onpost, etc.
do miss something?
indeed, forward()
, include()
meant used when processing request. might not best option given want achieve.
what create third component, let's call eventmanager
time being, , have rest servlet signal changes eventmanager
. websocket, on other hand, notified eventmanager
new data available , new data in order write client.
in approach essential both rest servlet , websocket servlet share same instance of eventmanager
. achieve marking eventmanager
singleton ejb adding @singleton
annotation, , inject both rest servlet , websocket servlet.
Comments
Post a Comment