• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Thread and File IO question

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I have a question relating to thread and File IO in an EJB.
Is an EJB allowed to call a method on another object that performs either File IO or threading ?
e.g. assume the following simple session bean :
public class SimpleBean implements SessionBean {
// bean methods removed
public void someBusMethod() {
// call another object with a method that does file io
someOtherObject.methodWithFileIO();
// similarly - an object that does threading
anotherObject.methodWithThreading();
}
}
Are these method calls valid ? What if your bean called a 3rd party library that performs threading / file io and you weren't aware of it - Is your bean still "legal" ?

Thanks in advance
Paul
 
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Spec C.1.2, pg 538:

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


and pg 539:

The enterprise bean must not attempt to manage threads.


The first limitation is easy to get around, there are JNDI filesystem providers that give you access to the filesystem. The issue isn't that you can't access files, just that you need to use a J2EE-portable way of doing it (this isn't an issue for the exam, but how you deal with the problem in real projects).
The second issue is particulary important. Spawning threads in an EJB container is a BAD THING. It mucks up transaction handling, can lock up container resources, is a slow resource leak (because of how the JVM gets threads from the O/S without ever releasing them) and can drag down container performance.
 
Evildoers! Eat my justice! And this tiny ad's justice too!
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic