Lets assume, that there is application written in pure JSP, it is using server-side code extensively (creates a lot of background threads, uses few external libraries, does a lot of processing) and regular JSP/servlet web ui. As the application is getting bigger and bigger, more requirements are to be met - clustering, more ajax, failover etc. It seems, that the natural extension would be to migrate to EJB (and JSF for ui side). Now, here is the question: if existing code does use external library, and that library does launch new threads, open some sockets and fire callbacks when it receives some data, how to interface it with EJB?
To be more specific:
- the application does some stock transaction processing
- there is Trade object in JSP
- there is StockServer object in JSP
- StockServer does use external library to receive stock prices and confirmation about trades
- when new trade is placed, new Trade object is created, stored to DB and some messages between StockServer and external library are passed, both ways.
Now, with EJB, it seems that Trade should become entity bean being stored to DB as well, but how to reorganize StockServer class? I am reading through "Enterprise Java Beans 3.0" book by B. Burke and R. Monson-Haefel and so far I've found only information that I am supposed to not create any new threads from bean code. So, what is 'usual' attempt to create system like the above?