aspose file tools
The moose likes EJB and other Java EE Technologies and the fly likes Ejb cache with singelton implementation Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply Bookmark "Ejb cache with singelton implementation" Watch "Ejb cache with singelton implementation" New topic
Author

Ejb cache with singelton implementation

arik salv
Greenhorn

Joined: Mar 24, 2012
Posts: 1
I would appreciate your advice about an issue I have.

I'm working with jboss, EJB 3.1 environment.

each time the user entering a specific screen, it should be a trigger for creating a tree data type which based on a data that saved on the database. this tree calculation can take some time, and it's can be heavy on performance.

the following requests are sent from UI :

  • 1. refreshTree - a trigger for building the tree
    2. isTreeReady - indicating whether the tree is ready to use, and called every x amount of time
    3. getTree - return the tree.


  • when building this I should take into consideration that multiple users can try to perform each one of those actions simultaneously. it's also true that 2 users share the same tree if any refresh hasn't been done.

    I've thought about implementing it as a cache as follow :



    the issue I have with that is that there can be a scenario in which :

    first user refreshing the tree - and the tree is built.
    then second user start to build the tree, and initialize the isReady flag to false, before the first user has noticed about the tree calculation - in this case the first user will need to wait to the calculation to be completed (even though he could have use the tree).

    I'm trying to think a bout using a read lock in some way (instead of the isTreeReady flag), but I can't think about any that will fit my needs.

    do you have an idea what can I do?

    thanks.
     
    I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
     
    subject: Ejb cache with singelton implementation
     
    Similar Threads
    Subtree in JTree
    How to disable a certain treenode in a jtree
    EJB3 Doubts
    Need help with wait cursor and setEnable( false )
    Static variables and inheritance