The share-app mode is a deployment mode in SwingWeb that allows only one instance of a swing application to be used
as presentation and interaction instance simultanously to all the web users accessing the particular application. The reason share-app mode
is supported in swingweb is to reduce resource requirement of swingweb application in particular situation. In normal swing
application case, the user starts the swing application in a separate jvm on local machine and at most only one instance of
the application (with a few windows maybe) are started in the jvm. For swingweb, the situation becomes more overwhelming - if 100
users connect to your swingweb application - your web server have to support running 100 instances of the same swing application -
each with own instances of windows, buttons, label, peers and resources. It's probably fine for intranet application, but for internet
application development like a e-commerce site, swingweb approach simply will not scale - not without the share-app mode.
The basic concept of share-app mode is simple - you can have a same component instance that can render and react to user action differently
simultanously because the component states is kept within each user session. For example, imagine that there is a MyViewComponent instance
that contains 10 different views - with only one view being rendered in the component (using CardLayout). Instead of saving the
current view as a state in the component, we keep the current view in user session. Thus, different users could see different
things - the component acts different to the user action too because of the session state. Alternatively, the current view can also be
corresponding to a value in the url of browser client. Thus the container renders different depending on the user URL.
An example is that you can have a JLabel instance that show different text to different users, simply because
the text of the JLabel is kept in session - not as a class variable in the JLabel. The concept is very simple and yet powerful.
It is to be understood fully before you start working on shareapp mode application - as it allows you to develop heavy duty sites
(e.g. Amazon) by just using swing. The next two sections will introduce the SessionLocal and URLLocal, two major elements that are used to
support the share-app mode.