I have been wondering about this question too. The main thing is that the
EJB spec doesn't allow an EJB to access the local file system, because a
bean developer has no way of knowing how or where the application developer
and application deployer are going to assemble their system. 

So if you access a local file system, and a really cool cluster-o-rama EJB
server has the capability to move EJB's to the physical machine best suited
for them on the fly--this is within spec, but would break any EJB that rely
on access to a local file system.

Weblogic has a T3 file system that is a work around. It is really poor. 

My suggestion would be so create some sort of JNDI bindable file service.
The difficulty comes from the fact that streams are not serializable. If you
went all out, you could even make it JCA compatible so you could access it
like a JDBC DataSource pool. Here are a couple of scenarios:

1) Simple Local Ref
        
        Make an object that the EJB can instantiated or look-up. It would
take a URL as an argument. Then it would open a FileStream to that local
file and hand it back to the EJB. The FileStream would have to be Transient,
and the object capable of dealing with the disappearance and failure of the
stream.

        The object would assume that the file is always available via the
local file system. You could use something like NFS to mount the filesystem
in the same location across your EJB server machines. 


2) Remote Ref

        This would be just like scenario 1, but instead of using a network
file system to distribute the files, write network code into the object. For
example, if you just need reads, then you could make it take the URL and
have it fetch files from a web server. If you want
read/write/versioning/etc. You could make it act as a WebDAV adapter. You
might even be happy with just an FTP server.

3) File Service.

        Create an object that acts like a DataSource object, it grabs a
network file system connection out of a JCA compliant network file system
connection pool.

        The "FileSource" object would take parameters to grab a connection
of the pool, and to place it back in the pool. The pool objects would then
need to be connections to some sort of network file server, like WebDAV,
FTP, or NFS. Then you could manage the file system like any JCA resource. It
would be the most scalable. The draw back would be that you would need to
know about your file system at configuration time.

        I hope that these help,
        but the long and short of it is that I don't know of any file system
objects for EJB that are server independent.

        Lucas McGregor

-----Original Message-----
From: Simon Stewart [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 16, 2002 10:06 AM
To: Mark Gulbrandsen
Cc: [EMAIL PROTECTED]
Subject: Re: [JBoss-user] File-system access


And is there a portable way of doing this? Portable between different
app servers, that is....

On Tue, Apr 16, 2002 at 10:30:08AM -0600, Mark Gulbrandsen wrote:
> 
> Maybe I could ask a different question.
> 
> Can I assign a resource so that I can do a jndi lookup?
> 
> Can I configure JBoss to load an arbitrary jar file and set it to a jndi
> name such as "jndi:/user/resource1.jar" "jndi:/usr/resource2.jar"? Then, a
> context lookup would return a JarFile for each of these resource jars. Is
> this possible with Branch_3_0?
> 
> -Mark

Cheers,

Simon

-- 
"You can't have everything...Where would you put it?" --- Steven Wright

_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to