The spec mentions that a number of things are not allowed in EJB.  But
you also have to understand the reason why it is not allowed.
Synchronization is not allowed because you cannot expect it to work in a
cluster of more than 1 machine.  File IO is not allowed  because you are
not sure which machine the file will be written to.  What if TX is
rolled back, the file is not going to be deleted or undone.

Having said that, I have yet to find a server which prevents you from
openning/creating/reading files or using the synchronized keyword or
openning a socket.  If you know what you are doing and what the
consequences are, just do it.

If you are going to write a file, make sure you write to a common area
where all the boxes on the cluster can see the file.  The same thing for
reading.  Depending on your situtation there will be no way to
prevent/lock multiple beans from writing to a file at the same time, but
that might not be a problem in your case.  There is nothing to prevent
another object to try to read the file before it is done being
written.  In short, you don't have the same kind of controls that you
get with a TX data source.  You will most likely find a bunch of other
issues, all of which will be easily explainable, however, you might not
be able to do much about them .

Some issues of concurrent access could be prevented by accessing a
database first.  For example, if you want to update the file, update a
control record in some database first.  This way, you can use the DB as
a easy way to do your global synchronization.  If someone else needs to
update the same file, they will block until your TX finishes and you
release the control on the DB row.

Again, if you know what you are doing, then do it.

--
-AP_
http://www.myprofiles.com/member/profile/apara_personal
http://www.myprofiles.com/member/profile/apara_business



sven van't veer wrote:

Cindy,

The EJB specification prohibits writing to files. EJB´s are transactional and clusterable objects. files can neither take part in transactions nor can the be written to in a cluster.

Imagine you deploy yor bean in a cluster containing 10 boxes. you will never know which ejb will write to the file and on what box.

sven

-----Original Message-----
From: Cindy hao [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 15, 2003 2:55 PM
To: [EMAIL PROTECTED]
Subject: Re: File I/O in EJBs


Saravana,


Thanks for responding to my email. You are  suggesting that EJBs can access
file I/O indirectly through some helper classes. But my understanding is that
EJB can not access file I/O either directly or indirectly.

Cindy

Saravana wrote:



Hi,
       In EJB's to access a file as for my knowledge, use a wrapper class

and implement Streams in that. Return a String from that method and parse
the

String using the parser, or do the processing in the class it self. Hope
this solves ur problem.

Regards

Saravana

----- Original Message -----
From: "Cindy hao" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, July 15, 2003 8:30 PM
Subject: File I/O in EJBs



Hi,
Since file I/O is prohibited in EJBs, how to access large and dynamic
generated files from EJBs? Would you please recommend an approach or
approaches with the best Qos?

Thanks in advance,

Cindy Hao




===========================================================================


To unsubscribe, send email to [EMAIL PROTECTED] and include in the


body


of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".




===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".



=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".

=========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".





=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".



Reply via email to