Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
424 views
in Technique[技术] by (71.8m points)

jakarta ee - Java EE programmers do not write to files

Today one person told to me that "Java EE programmers do not write to files". Why can I not write to files from within a Java EE container (for example from JBoss)? What is wrong?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You should do everything within the Java EE container itself: you can have no certainty that you will have any consistent access to the filesystem. There are many reasons for this, the most obvious being that applications running within a container will have:

  • no certainty that any subsequent invocation of an EJB would even be on the same physical server with access to the same files/filesystem (e.g. upon clustering)
  • no possibility of interfering with each other (multiple applications attempting to write to the same file)
  • no security issues (one app writing confidential data which another app could read)

You should also assume that you shouldn't:

  • create your own threads (the container will manage this for you; if you create your own you may starve other applications in the container of CPU time)
  • use socket-IO (also has security issues)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...