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)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…