Win a copy of High Performance Python for Data Analytics this week in the Python forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

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.
 
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic