• Post Reply Bookmark Topic Watch Topic
  • New Topic

File IO in EJBs  RSS feed

 
guido sac
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can I access and write files in EJBs? I know access with java.io is forbidden, is there no other way?
Thanks a lot!
 
Tim Holloway
Bartender
Posts: 18716
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you could use JNI, which is evn MORE forbidden!
However, the reason for forbidding file I/O in EJBs isn't that it will cause the EJB to abort - it's because (in Sun's option) it's architecturally dirty.
In fact, both properties and database access ultimately end up as I/O (and sometimes network activity - also verboten). However, the container supplier is expected to understand that. If an EJB started doing I/O all over the place, there's the possibility that things can get seriously out of sync. Thus, the edict that file I/O should be done at the container level and not within EJBs.
EJBs are supposed to be lightweight components, and once you start doing file I/O and things like that, you're beginning to gain weight. You CAN do file I/O in an EJB, but it will cost you 7000 cleverness points in the geek ratings and you may discover that your EJB won't work if you move it to some other appserver (or some other version of the appserver you're using now).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!