Dive into Oracle ADF

Send me a mail
 Dive into Oracle ADF   Click to see the XML version of this web page.   (Updated: 2/3/2008; 8:12:59 PM.)
Tips and tricks from Steve Muench on Oracle ADF Framework and JDeveloper IDE

Search blog with Google:
 

Search BC4J JavaDoc:
 

June 2003
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          
May   Jul

Get Firefox!

Tuesday, June 24, 2003

"How can I persist custom user data as part of the BC4J appmodule state management mechanism?"

From your ApplicationModuleImpl subclass, you can access a java.util.Hashtable of user data by calling getSession().getUserData(). Objects you put into this hashtable will stay available to your current user based on the session id they've been assigned (BC4J calls this their SessionCookie). In order to make this user data participate in the automatic state management mechanism that BC4J provides, you need to override two methods in your application module class passivateState and activateState. These methods allow you to decide what custom information should be saved, and reloaded (respectively) from the XML-based application module state "snapshot".

I built a little sample project that you can download here: PersistingUserData.zip

  1. Run TestServlet in the IDE
  2. Point browser1 at http://localhost:8989/PersistingUserData/servlet/TestServlet
  3. Point browser2 at http://localhost:8989/PersistingUserData/servlet/TestServlet
  4. Request the following URL in browser1: 
    http://localhost:8989/PersistingUserData/servlet/TestServlet?a=b&;c=d
  5. Request the following URL in browser2:
    http://localhost:8989/PersistingUserData/servlet/TestServlet?p=q&;w=z
  6. Repeat step (2) to see that a = b and c = d for browser1 were remembered
  7. Repeat step (3) to see that p = q and w = z for browser2 were remembered

Set breakpoints on the passivateState and activateState methods in the TestModuleImpl.java class running under the debugger to see when they get called.

To force AM pool recycling for just two browser users, I've artificially set the following configuration parameters for testing/illustration purposes...
 
jbo.recyclethreshold = 0 (Don't wait before recycling AM instances)
jbo.ampool.maxpoolsize = 1 (Don't grow the pool beyond one AM instance)
jbo.ampool.minavailablesize = 1  
jbo.ampool.maxavailablesize = 1


11:57:21 AM    



© Copyright 2008 Steve Muench.