Revisited: Oracle ADF and Virtual Private Database

At the end of my previous post, I stated:

There’s one more thing I’m not really sure of (yet). In section 39.7 of their Fusion Middleware Developer’s Guide, Oracle shows a (in my opinion rather hacky) way to make sure Session information is saved between different incarnations of the ApplicationModule. I’m not sure if this is needed in our approach, since we set the year at the start of each JSF lifecycle anyway. But I implemented it, “just in case”, it doesn’t harm anyone.

After my post, the discussion on the Oracle Forum continued. As Anton stated in his contribution to the discussion, having a redundant solution potentially does harm the performance of the application as a whole. He also suggests that the solution with a PhaseListener may be worse in terms of performance than a ApplicationModule that has proper passivation/activation code in place (see section 39.7 of the Fusion Middleware Developer’s Guide).

Although I was not convinced about that immediately, I think Anton is actually rigtht. When using a PhaseListener, it is certain that the value in the ApplicationModule will be updated at every request from the browser. Passivation or activation on the other hand only occurs when the application module that comes from the application module pool is actually an other application module intance than the one that was used for the previous request. Only in a situation where there are very many users logged in, chances are that every request will be handled by a different application module instance. (See section 39.2.2.1, Understanding When Passivation and Activation Occurs in the developers guide.)

The only way to prove any influence on performance would be to carry out some benchmark, but that seems a whole lot of work to do right. But I did a test with and without the PhaseListener to see if there were any functional differences, and I couldn’t find any. In other words, once the passivation/activation code is in place, the PhaseListener does not add anything useful anymore. And because the passivation/activation solution is (at least theoretuically) better, performanc-wise, I decided to remove the PhaseListener from my application.