file I/O from an EJB

D

David Thielen

Hi;

I need to do file I/O inside an EJB (I am not clustered so everything
is on the same server). I know standard I/O is not allowed - so what's
the best approach:

1. Do it in a message bean (is this allowed - the docs I read aren't
clear).

2. Have the caller pass in everything as byte[] and return byte[] for
the caller to write.

3. Have a deamon that talks over sockets that will pass files across
the socket.

4. Something else?

thanks - dave



Windward Reports -- http://www.WindwardReports.com
DefendTek -- http://www.DefendTek.com
Page 2 Stage -- http://www.Page2Stage.com
Enemy Nations -- http://www.EnemyNations.com
me -- http://dave.thielen.com
Barbie Science Fair -- http://www.BarbieScienceFair.info
Hillary Clinton -- http://www.HillaryIn2004.org
(yes I have lots of links)
 
J

Jeff Robertson

David Thielen said:
I need to do file I/O inside an EJB (I am not clustered so everything
is on the same server). I know standard I/O is not allowed - so what's
the best approach:

1. Do it in a message bean (is this allowed - the docs I read aren't
clear).

I'm not too familiar with using message driven beans for something
like this, but it would probably involve passing the contents file
around as a byte[] inside the message, so it's really equivalent to
your #2.
2. Have the caller pass in everything as byte[] and return byte[] for
the caller to write.

Its good that you say byte[], not String. There is (or at least there
was at one time) a 64K limit on the size of Strings that could be
serialized. So even if the files in question are "text files", don't
be tempted to use String.

But even so, if the files are very huge, holding the entire file in a
byte array might have memory usage problems.
3. Have a deamon that talks over sockets that will pass files across
the socket.

Your #3 could be a WebDAV[1] server, or an FTP server, or maybe even a
Windows fileserver accessed through JCIFS[2]. All of these are
basically daemons that pass files over sockets (or, sometimes,
datagrams), and could save you the headache of re-inventing that
wheel. You'd probably not want to write something like that unless you
wanted to get into the fileserver business yourself.

Just out of curiousity, why do you need the I/O? What is this data
that needs to be saved in files, and can't be written to a database or
something instead?

[1] http://www.webdav.org
[2] http://jcifs.samba.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top