IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Accessing the file system from a SessionBean
I know this is a no-no according to the spec but we need to do it. What is the recommended way of doing this? We have a web application which uploads a file, the SessionBean then needs to read the file do some transformations and save the data to the DB. I thought of writing a simple, JCA connector to do the work (only implement the real base stuff, no CCI, etc.) since it is allowed to do that kind of stuff, does that make sense?

Thanks,
New Re: Accessing the file system from a SessionBean
Out of curiousity, is an immediate response necessary (that the file was stored, etc.)? For example, you could (since you have the file in memory as it's uploaded) stuff the contents into a JMS message and send it off to an MDB (message driven bean). It would be in a message, not a file, so no worries about file processing.

Dan
New Re: Accessing the file system from a SessionBean
One of the issues is that these are very large files (30m+) and therefore we don't want the whole file to be in memory at any 1 time.
New Just open the file.
Pick a directory, devise a naming scheme to prevent collisions. Be CERTAIN to close the files explicitly.

Shellman is right about doing something like this in an async fashion if you can (MDB). Just send a url for the file as the message. Then you can dump the file into a private web server's doc area, put it into an ftp server, or use the local file system and let the bean retrieve it based on whatever url scheme you're using. This is best if you can process the file in a streaming sort of fashion - otherwise you might as well pick a directory and go with it.

Also, what's your process location strategy - is the session bean colocated in the web tier or in another tier? Sharing file systems gets trickier if you have to span machines. I'm not a fan of NFS in a high availability environment or in putting beans in separate processes if you can avoid it. The distribution mechanism is many orders of magnitude slower than local calls and adds little value.




"I believe that many of the systems we build today in Java would be better built in Smalltalk and Gemstone."

     -- Martin Fowler, JAOO 2003
     Accessing the file system from a SessionBean - (bluke) - (3)
         Re: Accessing the file system from a SessionBean - (dshellman) - (1)
             Re: Accessing the file system from a SessionBean - (bluke)
         Just open the file. - (tuberculosis)

You getting this down?
44 ms