Application Scope lesson learned today

I got an email a few days ago regarding my Document Locker openntf project. The question was why it didn’t work. I tested my application and it worked as expected. But then I thought perhaps the developer is using the code from XPinc because I added a Xpinc page in the project and I must confess I didn’t test that before releasing the project as much as I usually do.

And this was the case, they where using an XPinc application. And the lesson in this was.

application scope is only applicationScope if you run the code from an web browser and not if the XPage is runned as an XPinc application or if you run it using the new Domino 9 XPinc run on server option. 

Application Scope is private in XPinc applications, it is not an application scope that is shared between users.

  1. What about a Singleton? Would that work in a XPinc on server?

  2. I don’t exactly understand what you mean. Storing a singleton in applicationscope?
    That will work but it will be a private variable. No other users will be able to use it.

  3. The reason for this behavior is that the user interface for XPiNC apps is rendered via a local web server running inside the Notes client. While the data might reside on a Domino server, the HTML is actually being generated locally. So everything that is stored in memory during this processing (including the various scopes) is stored in the user’s memory… so applicationScope is still treated the same as it would be in the browser, except you can’t access my physical memory and I can’t access yours, so it ends up behaving like sessionScope, because there’s no way for users to access each other’s copies of that memory.

    When the same app is accessed via a browser, this process is running in the server’s memory, so all users accessing the same app via the same server are invoking operations against the same physical memory, so there’s only one copy of applicationScope… unless the app is replicated to multiple Domino servers, and not all users are accessing the same server. Server1 can’t access Server2’s memory, so if you’re accessing the app via Server1 and I’m accessing it via Server2, information you store in code>applicationScope won’t be accessible to me, and vice versa, because each server is storing its own copy of code>applicationScope in its own memory.

    So you can consider XPiNC as being a different server replica of the same app… even if you’re accessing the “real” server’s data directly, the web server is the user’s computer, so all operations that write to and read from memory behave as though each user is a server.

  4. Fredrik Norling

    Thanks for the great explanation to extend my post, Tim.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.