NextApp Echo
App Container 1.1.4

nextapp.echoservlet
Class InstancePeer

java.lang.Object
  extended bynextapp.echoservlet.InstancePeer
All Implemented Interfaces:
java.util.EventListener, javax.servlet.http.HttpSessionBindingListener, java.beans.PropertyChangeListener, java.io.Serializable

public final class InstancePeer
extends java.lang.Object
implements javax.servlet.http.HttpSessionBindingListener, java.beans.PropertyChangeListener, java.io.Serializable

A peer object for an user instance of an Echo application. Like EchoInstance, one instance of this class is created for each user.

See Also:
Serialized Form

Method Summary
 Id generateId()
          Generates a unique (to the application) identifier.
 ClientProperties getClientProperties()
          Returns the "client properties" data collected about the client of this InstancePeer.
 PaneUI getContainingPane(ComponentPeer componentPeer)
          Returns the PaneUI in which the given ComponentPeer is contained.
 WindowUI getContainingWindow(ComponentPeer componentPeer)
          Returns the WindowUI in which the given ComponentPeer is contained.
 Service getController()
          Returns this instance's Controller service.
 CookieManager getCookieManager()
          Returns the CookieManager used by this instance.
 ImageRepository getImageRepository()
          Returns the image repository.
 nextapp.echo.EchoInstance getInstance()
          Returns the EchoInstance object this peer supports.
 ComponentPeer getPeer(nextapp.echo.Component c)
          Returns the ComponentPeer that corresponds to the given Component.
 ComponentPeer getPeer(Id id)
          Returns the ComponentPeer that corresponds to the given Id.
 Service getSafeInvokeService()
          Returns the service that renders the script containing the safeInvoke() method.
 java.security.Principal getUserPrincipal()
          Returns the principal (user) of this application.
 void propertyChange(java.beans.PropertyChangeEvent e)
          Handler for PropertyChangeEvents.
 void redraw(ComponentPeer componentPeer)
          Causes the service containing the given component to be re-rendered.
 void setTitle(WindowUI windowUI)
          Causes the specified window's title to be updated on the client.
 void valueBound(javax.servlet.http.HttpSessionBindingEvent e)
          Listener implementation of HttpSessionBindingListener.
 void valueUnbound(javax.servlet.http.HttpSessionBindingEvent e)
          Listener implementation of Mcode>HttpSessionBindingListener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

generateId

public Id generateId()
Generates a unique (to the application) identifier.

Returns:
An application-unique identifier.

getClientProperties

public ClientProperties getClientProperties()
Returns the "client properties" data collected about the client of this InstancePeer. This data contains information such as the browser name, version, and the clients screen resolution.

Returns:
The "client properties" data collected about the client of this InstancePeer.

getContainingPane

public PaneUI getContainingPane(ComponentPeer componentPeer)
Returns the PaneUI in which the given ComponentPeer is contained.

Parameters:
componentPeer - The ComponentPeer whose containing PaneUI is to be returned.
Returns:
The PaneUI containing the given ComponentPeer.

getContainingWindow

public WindowUI getContainingWindow(ComponentPeer componentPeer)
Returns the WindowUI in which the given ComponentPeer is contained.

Parameters:
componentPeer - The ComponentPeer whose containing WindowUI is to be returned.
Returns:
The WindowUI containing the given ComponentPeer.

getController

public Service getController()
Returns this instance's Controller service.

Returns:
This instance's Controller service.

getCookieManager

public CookieManager getCookieManager()
Returns the CookieManager used by this instance.

Returns:
The CookieManager used by this instance.

getImageRepository

public ImageRepository getImageRepository()
Returns the image repository.

Returns:
The image repository.

getInstance

public nextapp.echo.EchoInstance getInstance()
Returns the EchoInstance object this peer supports.

Returns:
The EchoInstance object this peer supports.

getPeer

public ComponentPeer getPeer(nextapp.echo.Component c)
Returns the ComponentPeer that corresponds to the given Component. A component will have a peer only if it has been registered. A component will be registered if all of its ancestors are visible, and the window that contains it is registered with this InstancePeer. If a peer cannot be found for the component, an EchoServletException (A RuntimeException) will be thrown.

Parameters:
c - The component whose peer is to be retrieved.
Returns:
The peer for the specified component.

getPeer

public ComponentPeer getPeer(Id id)
Returns the ComponentPeer that corresponds to the given Id. If a peer cannot be found which corresponds to the specified Id, a null value is returned.

Parameters:
id - The id of the peer to be retrieved.
Returns:
The peer identified by id.

getSafeInvokeService

public Service getSafeInvokeService()
Returns the service that renders the script containing the safeInvoke() method. The safeInvoke() method is used to execute script code which may generate errors. Different safeInvoke() implementations are used on different browsers based on the browser's support of JavaScript 1.4's try/catch/finally blocks.

Returns:
The service that renders the script containing the safeInvoke() method.

getUserPrincipal

public java.security.Principal getUserPrincipal()
Returns the principal (user) of this application. This method provides the identical capability of HttpServletRequest.getUserPrincipal().

Returns:
The principal (user) of this application.

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Handler for PropertyChangeEvents. This class registers with all registered components and their immediately non-visible siblings to receive property changes. The InstancePeer needs to monitor all changes in its represented EchoInstance and its components such that it can update the client browser to reflect the application's state.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
e - A property change event describing a property change to the application represented by this peer or one of its components.

redraw

public void redraw(ComponentPeer componentPeer)
Causes the service containing the given component to be re-rendered.

Parameters:
componentPeer - A ComponentPeer whose represented Component has changed and therefore needs to be updated on the client browser.

setTitle

public void setTitle(WindowUI windowUI)
Causes the specified window's title to be updated on the client.

Parameters:
windowUI - The peer of the window whose title should be redrawn.

valueBound

public void valueBound(javax.servlet.http.HttpSessionBindingEvent e)
Listener implementation of HttpSessionBindingListener. Stores reference to session when invoked.

Specified by:
valueBound in interface javax.servlet.http.HttpSessionBindingListener
See Also:
HttpSessionBindingListener.valueBound(HttpSessionBindingEvent)

valueUnbound

public void valueUnbound(javax.servlet.http.HttpSessionBindingEvent e)
Listener implementation of Mcode>HttpSessionBindingListener. Removes reference to session when invoked.

Specified by:
valueUnbound in interface javax.servlet.http.HttpSessionBindingListener
See Also:
HttpSessionBindingListener.valueUnbound(HttpSessionBindingEvent)

NextApp Echo
App Container 1.1.4