I'm looking for a way to force an EJB to be removed from the container cache. Or, at least a way to force the container to create a new EJB instance. Here is the situation. I have a stateless session bean that connects to and communicates with a socket service. It is important that the EJB maintain a connection with the socket throughout it's life, but because of some bugs in the socket service itself, the EJB needs to reinitialize the socket connection from time to time. What I'm supposed to do is write a delegate that uses the EJB, and when the delegate catches the exception indicating a corrupted socket connection, we want it to discard the EJB and get a new one. The problem is that when we discard the EJB, it goes back into the cache, and so when we ask for a new one, we are just getting the same EJB with the same bad socket connection. I'm currently using the remove() method from the EJBObject interface, but all that seems to do is place the EJB back in the pool. Is there a way to explicitly destroy an EJB instance?
This should not be EJB - it should use the singleton pattern. It can be wrapped in a session bean and deployed to the server, but as a seperate component. This singleton could have an invalidate method indicating to destroy and re-create the socket connection.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com