The Source for Java Technology Collaboration
User: Password:



Andreas Schaefer

Andreas Schaefer's Blog

RE: File Access in EJB

Posted by schaefa on October 09, 2003 at 12:50 PM | Comments (2)

As Simon Brown pointed out the J2EE specification restrict you to access files on the file system but sometimes you have to and then you need to control the damage by keeping the breach of the specification local and not to spread it all over your code. Being confronted with this question just recently I came up with these ‘solutions’:

  • Putting a file into the archive and read it out as resource. Note that you can only read from this file.
  • Using a JNDI environment entry containing the path to the directory and/or file that then can be used to open the file later in the code. This allows the deployer to adjust the value before deployment so that it points to a valid file/directory the application can read from and write to.
  • Using JCA to expose a connection to a file that allows the client to retrieve the connection and then open an input stream like you do with an URL.
Nevertheless all of this ‘solutions’ have some problems in common. They do not work (well) in a clustered environment, are not portable and still need java.io.

First I was thinking that only a file service (like JDBC or JMS) provided by the server could solve the problem. But after thinking it through using Entity Beans seems to be a much better way to share the data on a cluster than through a file service. Then I realized that maybe each deployed EJB needs to have its own file that is not shared on the cluster. I think it is very important for each J2EE developer to see that there is much more between heaven and earth that a specification can ever capture. But it is important for the future of the code/project that ‘unportable code’ is kept localized and under control and that the assumptions and restrictions of that code is documented well.

Happy escaping - Andy

Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • wow power leveling
    wow powerleveling
    wow power leveling
    wow gold
    wow items
    feelingame.com
    wow tips
    Most Valuable WOW Power Leveling Service
    wow power leveling faq
    cheap wow power leveling
    wow power leveling
    wow powerleveling
    wow power lvl

    Posted by: wowleveling3 on December 13, 2007 at 06:04 PM

  • 网络è¥é”€è½¯ä»¶
    网络è¥é”€è½¯ä»¶
    网络è¥é”€è½¯ä»¶
    群å‘软件
    群å‘软件
    ---
    群å‘软件
    网络è¥é”€è½¯ä»¶
    论å›ç¾¤å‘软件
    网站排å软件
    群å‘软件
    推广å°åŠ©æ‰‹ç ´è§£ç‰ˆ
    论å›ç¾¤å‘软件
    网站排å软件
    群å‘软件
    网络è¥é”€è½¯ä»¶
    网站推广软件
    ä¿¡æ¯ç¾¤å‘软件
    论å›ç¾¤å‘软件
    ä¿¡æ¯ç¾¤å‘软件
    åšå®¢ç¾¤å‘软件
    qq群å‘软件
    邮件群å‘软件
    åšå®¢ç¾¤å»ºè½¯ä»¶
    ä¼ä¸šå录æœç´¢è½¯ä»¶
    ä¿¡æ¯ç¾¤å‘软件
    邮件群å‘软件
    论å›ç¾¤å‘软件
    åšå®¢ç¾¤å‘软件
    网站推广软件
    网络è¥é”€è½¯ä»¶
    全能è¥é”€ç ´è§£ç‰ˆ

    Posted by: uuok999 on December 20, 2007 at 12:24 AM





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds