Managing File-permissions with Java.


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Managing File-permissions with Java.

  1. #1
    Eirik Kj°lsrud Guest

    Managing File-permissions with Java.


    Hi.

    I'm creating a SMS-mobile sollution and the gateway that we use require us
    to write files to an Outqueue for SMS-messages to be sent. The files are
    simple text-files. The problem I'm dealing with is that the gateway require
    our application to "lock" the file while writing to it, that is, no other
    application can have file-permissions on our file. When the file containing
    the SMS-message is written, the file-permissions need to change to "full
    control" to allow other applications (the Gateway) to access it and delete
    it once the message is sent.

    Does anyone know how to solve this, or have a link to any useful information
    ?

    Any help would be greatly appreciated !

    Best Regards
    Eirik Kj°lsrud
    Apropos Internet, Norway

  2. #2
    Richard Livingstone Guest

    Re: Managing File-permissions with Java.


    What you are describing is a classic producer-consumer problem, where the
    production of jobs (ie writing of SMS messages) needs actually to be decoupled
    and protected from their consumption.

    One way to solve your problem without using files at all could be to use
    a MOM product such as MQ to act as the queue. In that case, there is no physical
    file involved (so no problems with half-written message files) and the queue
    is transactional ie messages appear on the queue only when they are complete
    and you commit a transaction. You could then write a decoupled consumer process(es)
    to take messages off the queue and send them, with the same transactional
    safety (ie if something crashes before you've actually sent the message,
    you still have the MQ message). MQ guarantees you don't lose messages (almost,
    anyway), is cross-platform (so you can access the queues from NT, Unix etc)
    and has lots of decent admin tools.

    Another way (inside a single VM) might be to use a synchronised instance
    of a SecurityManager and decorate it to cache the details of which files
    were being written/read. You could then use its checkWrite/checkRead permissions
    to test what is possible from the worker threads. This is really not much
    different to the previous solution in the production/consumption of jobs
    (messages) but you are using a single reference to manage the locking

    Hope this helps

    Regards

    Richard


    "Eirik Kj°lsrud" <wayback@frisurf.no> wrote:
    >
    >Hi.
    >
    >I'm creating a SMS-mobile sollution and the gateway that we use require

    us
    >to write files to an Outqueue for SMS-messages to be sent. The files are
    >simple text-files. The problem I'm dealing with is that the gateway require
    >our application to "lock" the file while writing to it, that is, no other
    >application can have file-permissions on our file. When the file containing
    >the SMS-message is written, the file-permissions need to change to "full
    >control" to allow other applications (the Gateway) to access it and delete
    >it once the message is sent.
    >
    >Does anyone know how to solve this, or have a link to any useful information
    >?
    >
    >Any help would be greatly appreciated !
    >
    >Best Regards
    >Eirik Kj°lsrud
    >Apropos Internet, Norway



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center