Sharing of NEF Objects Across Threads

The NEF is designed for complex multi-user and multi-threaded applications and is thread-safe. In order to help ensure that a large number of users of a large application don't end up using too many system resources many objects and instances are shared across users and threads. In fact, almost any object that does not end in "Context" is generally shared. For example, navigation trees, navigation pages, forms (dialogs), queries, schemas, etc. are all shared across users. To help protect users from modifying each other's data, specific state classes are used to manage per-user interactions with the frameworks. Here are some examples:

Navigation

All navigation trees and navigation pages (<navigation-tree>, <page>, <body> etc.) are shared. The com.netspective.navigate.NavigationContext class manages the per-user interaction. For every request/response cycle of the web application process, users will use the same instances of the structural elements (trees, pages, bodies, etc) but will have their own state object (the NavigationContext) which manages a particular the individual user's navigation state (like what page they are on). If there are any value sources defined for page captions, headings or other values then the NavigationContext is the Value Context that is used for resolving the value source expressions. This way, value source values may be dynamic per-user yet they can share the definition in the XML files.

Forms and Dialogs

All forms (dialogs), form fields, validation rules and criteria (<dialog>, <field>, <validation> etc.) are shared. The com.netspective.sparx.form.DialogContext class manages the per-user interaction. For every request/response cycle of the web application process, users will use the same instances of the structural elements (dialogs, fields, etc) but will have their own state object (the DialogContext) which manages a particular the individual user's form state (like what values were typed in, if there are any validation errors, etc). If there are any value sources defined for dialog headings, field captions, message text, or other values then the DialogContext is the Value Context that is used for resolving the value source expressions. This way, value source values may be dynamic per-user yet they can share the definition in the XML files.