The Global object is very similar to the Visit object with some key differences.
The Global object is shared by all instances of the application engine; ultimately, it is stored
as a ServletContext
attribute. The Global object is therefore not persistent in any way.
The Global object is specific to an individual server within a cluster; each server will have its own instance
of the Global object.
In a failover,
the engine will connect to a new instance of the Global object within the new server.
The Global object may be accessed using the global
property of either the
page or the engine (unlike the visit
property, they are completely equivalent).
Care should be taken that the Global object is threadsafe; since many engines (from many sessions,
in many threads) will access it simultanenously. The default Global object is a synchronized
HashMap
. This can be overriden with
configuration property
org.apache.tapestry.global-class
.
The most typical use of the Global object is to interface to J2EE resources such as EJB home and remote interfaces or JDBC data sources. The shared Global object can cache home and remote interfaces that are efficiently shared by all engine instances.