来自无状态会话bean的FileIO [英] FileIO from an stateless session bean

查看:88
本文介绍了来自无状态会话bean的FileIO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从JBoss中运行的无状态会话bean读写xml文件到磁盘.首选的方法是什么?

I need to read and write xml files to disk from a stateless session bean running in JBoss. What is the preferred way of doing this?

现在,我们正在使用java.io类访问文件系统.

Right now we are accessing the file system using the java.io classes.

我找到了一个简单的文件系统RAR示例,并且可以正常工作,但它可能比直接使用java.io更具bug.

I found a simple file system RAR example and have got that working but it may be more buggy than just using java.io directly.

推荐答案

如果您检查

If you check that Programming Restrictions section of the EJB Spec you'll find the following:

企业bean一定不能使用java.io包来尝试 访问文件和目录 文件系统.

An enterprise bean must not use the java.io package to attempt to access files and directories in the file system.

如果您可以找到更好,可能更安全,更重要的是交易方式,请重新考虑.我们有一个将PDF文档作为Blob存储在数据库中,然后通过电子邮件或Servlet将其提供给用户的系统.

If you can find a better, possibly secure and more importantly, transactional way of doing it, please reconsider. We have a system that stores PDF documents as blobs in a database and then serves them to the users by email or servlet.

基于JBoss JCA的FSManagedConnectionFactory还不错.它是基于JNDI的,并且可能在更多实例中工作,而不仅仅是在java.io上进行黑客攻击

The JBoss JCA based FSManagedConnectionFactory isn't too bad. It is JNDI based and likely to work in more instances than just hacking around java.io

这篇关于来自无状态会话bean的FileIO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆