• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to do remote file i/o within EJB

 
Yan Zhou
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I wonder what my options are to read in a remote file (on client side) and store that in database as BLOB. I need to do this all in EJB. I know that there are better ways to do that than EJB, but that allows me to use existing EJB transaction & security framework.

The only option I could think of is a stateful session bean, which holds on to an Oracle BLOB object and its OutputStream object. The client keeps calling on the EJB method, sending a block of bytes each time, and the stateful session bean keeps writing these bytes into BLOB. My worry is that how do I make sure that the BLOB and OutputStream object are GCed, I could put them in ejbRemove(), but that is not ganranteed to be called.

I also thought about network I/O, but not sure how to use that in EJB, since I do not want to create any socket (I may not have permission to open a port on server).

Any suggestions?

Thanks.
Yan
 
Andreas Schaefer
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not quite sure if I like your solution because it seems to me to be quite slow. Nevertheless I can anwser this:

With a SFSB the ejbCreateXXX() method is called when you call the appropriate create method on the Local/Remote interface as well as ejbRemove() is called when you call remote() on the Local/Remote interface. They only exception to this rule is when a business method on the SFSB does throw a System Exception (Error, RuntimeException or RemoteException) because then the SFSB is discarded immediately and ejbRemove() is not and cannot be called.

-Andy
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!