Here is the question I have then, which is related to the File I/O question.
Consider a document management system that stores HTML and images in a
database.
Let's assume that I have something like a JAR file that I want to process
with an EJB.
My jar file has a manifest which is an XML document and then the rest of the
JAR file
is various documents. (For example consider a JAR file that contains an HTML
document,
and individual files for each of the images, plus the XML manifest that
lists each
file)
Let's suppose that I have a Entity bean that handles saving the HTML to a DB
and an
Entity bean that handles saving the images to the DB (maybe via Bean Managed
Persistence)
I would like to have a Session Bean which receives a URL or filename of the
JAR file,
have the Session bean, parse the XML descriptor, then read each of the
images and the
HTML from the archive file and store them in the DB via the Entity Beans.
The goal is
that since I'm using EJB I gain the security and transaction benefits of
J2EE. For example
assume that the JAR was available from a remote file server and when the
process is half
done the network link fails, I would be able to roll back my transaction
since the Session
and Entity Beans would all be part of the same transaction.
I don't think I would have to worry about Activation/Passivation of the
Session Bean since
all of the processing would happen in a single business method call.
I understand the value of resource managers, but what am I to do when my
business logic must
access files, parse XML, read stuff off of the network, etc.
-----Original Message-----
From: John Crupi [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 03, 2001 10:56 AM
To: [EMAIL PROTECTED]
Subject: Re: File I/O in an session EJB
This is a quote from the EJB spec:
An enterprise bean must not use the java.io package to attempt to access
files
and directo-ries
in the file system.
The file system APIs are not well-suited for business components to access
data. Business components
should use a resource manager API, such as JDBC API, to store data.
* An enterprise bean must not attempt to listen on a socket, accept
connections
on a socket, or
use a socket for multicast.
jc
--
John Crupi
Chief Java Architect
.COM Consulting
Sun Java Center
Cell: 301.526.7890
Nicholas Whitehead wrote:
> Marco;
>
> This is primarily a portability issue. In order to
> guarantee portability you should avoid the use of i/o,
> sockets etc, but you are not *prevented* from using
> them.
>
> //Nicholas
>
> --- Marco Pas <[EMAIL PROTECTED]> wrote:
> > Why is File I/O in a bean not a good idea ?
> >
> > I have to create a bean that reads a file and splits
> > the file...
> > I thought it was a very good idea to do this in an
> > EJB,
> > because you can take advantage of the security
> > mechanisms, etc...
> >
> > Kind Regards,
> > Marco
> >
> > -----Original Message-----
> > From: A mailing list for Enterprise JavaBeans
> > development
> > [mailto:[EMAIL PROTECTED]]On Behalf Of Mikko
> > Laanti
> > Sent: woensdag 3 januari 2001 15:49
> > To: [EMAIL PROTECTED]
> > Subject: Reading Properties from EJB?
> >
> >
> > Hi,
> >
> > In EJB Spec. there was mentioned that using direct
> > file io from Ejb is
> > not a "good idea". People also talked about this in
> > this newsletter.
> >
> > How about using Properties class? I know it's based
> > on file IO but does
> > Ejb container support it?
> >
> > Anyone know?
> >
> > Br
> >
> > - Max
> >
> >
> > email: [EMAIL PROTECTED]
> >
> >
>
===========================================================================
> > 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".
> >
>
> =====
> Nicholas Whitehead
> Home: (973) 377 9335
> Cell: (973) 615 9646
> [EMAIL PROTECTED]
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Photos - Share your holiday photos online!
> http://photos.yahoo.com/
>
>
===========================================================================
> 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".