I have to let an web application to listen a socket(ServerSocket), and handle the socket stream.
But the application is just deployed in Tomcat which is just a servlet container, it doesn't have JCA support. And establishing a server socket in servlet thread is unreasonable.
solution 1:
The ugly solution is to write a standalone java application to listen socket, then communicate with web server. but it is not a sound solution.
solution 2:
I wrote a ServletContextListener which starts to listen socket when contextInitialized(), once receiving a socket, it will be handed by a thread. That means a thread pool is located in ServletContext. Of course, I destroy the thread pool when contextDestroyed.
What do you think about the solutions?