nextapp.echoservlet
Class ThreadSafeInstancePeer

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

public class ThreadSafeInstancePeer
extends InstancePeer

Thread safe decorator for the instance peer, throws ThreadSesitiveOperationException, when a method is called that can not be used in a multi-threaded environment.

See Also:
Serialized Form

Constructor Summary
ThreadSafeInstancePeer(InstancePeer decorated)
           
 
Method Summary
 void exit(java.lang.String uri)
          Exits the application, redirecting an available browser window to the specified URI.
 Id generateId()
          Generates a unique (to the application) identifier.
 Id generateId(Component c)
           
 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.
 EchoInstance getInstance()
          Returns the EchoInstance object this peer supports.
 ComponentPeer getPeer(Component c)
          Returns the ComponentPeer that corresponds to the given Component.
 ComponentPeer getPeer(Id id)
          Returns the ComponentPeer that corresponds to the given Id.
 StaticText getSafeInvokeService()
          Returns the service that renders the script containing the safeInvoke() method.
 ServiceRegistry getServiceRegistry()
          Returns the ServiceRegistry that is used by this instance to hold all Service objects available to it.
 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 nextapp.echoservlet.InstancePeer
getInstancePeer, hasPeer, redraw
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadSafeInstancePeer

public ThreadSafeInstancePeer(InstancePeer decorated)
Method Detail

getClientProperties

public ClientProperties getClientProperties()
Description copied from class: InstancePeer
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.

Overrides:
getClientProperties in class InstancePeer
Returns:
The "client properties" data collected about the client of this InstancePeer.

setTitle

public void setTitle(WindowUI windowUI)
Description copied from class: InstancePeer
Causes the specified window's title to be updated on the client.

Overrides:
setTitle in class InstancePeer
Parameters:
windowUI - The peer of the window whose title should be redrawn.

exit

public void exit(java.lang.String uri)
Description copied from class: InstancePeer
Exits the application, redirecting an available browser window to the specified URI.

Overrides:
exit in class InstancePeer
Parameters:
uri - The URI to redirect the browser window to.

generateId

public Id generateId()
Description copied from class: InstancePeer
Generates a unique (to the application) identifier.

Overrides:
generateId in class InstancePeer
Returns:
An application-unique identifier.

generateId

public Id generateId(Component c)
Overrides:
generateId in class InstancePeer

getContainingPane

public PaneUI getContainingPane(ComponentPeer componentPeer)
Description copied from class: InstancePeer
Returns the PaneUI in which the given ComponentPeer is contained.

Overrides:
getContainingPane in class InstancePeer
Parameters:
componentPeer - The ComponentPeer whose containing PaneUI is to be returned.
Returns:
The PaneUI containing the given ComponentPeer.

getContainingWindow

public WindowUI getContainingWindow(ComponentPeer componentPeer)
Description copied from class: InstancePeer
Returns the WindowUI in which the given ComponentPeer is contained.

Overrides:
getContainingWindow in class InstancePeer
Parameters:
componentPeer - The ComponentPeer whose containing WindowUI is to be returned.
Returns:
The WindowUI containing the given ComponentPeer.

getController

public Service getController()
Description copied from class: InstancePeer
Returns this instance's Controller service.

Overrides:
getController in class InstancePeer
Returns:
This instance's Controller service.

getCookieManager

public CookieManager getCookieManager()
Description copied from class: InstancePeer
Returns the CookieManager used by this instance.

Overrides:
getCookieManager in class InstancePeer
Returns:
The CookieManager used by this instance.

getImageRepository

public ImageRepository getImageRepository()
Description copied from class: InstancePeer
Returns the image repository.

Overrides:
getImageRepository in class InstancePeer
Returns:
The image repository.

getInstance

public EchoInstance getInstance()
Description copied from class: InstancePeer
Returns the EchoInstance object this peer supports.

Overrides:
getInstance in class InstancePeer
Returns:
The EchoInstance object this peer supports.

getPeer

public ComponentPeer getPeer(Component c)
Description copied from class: InstancePeer
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.

Overrides:
getPeer in class InstancePeer
Parameters:
c - The component whose peer is to be retrieved.
Returns:
The peer for the specified component.

getPeer

public ComponentPeer getPeer(Id id)
Description copied from class: InstancePeer
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.

Overrides:
getPeer in class InstancePeer
Parameters:
id - The id of the peer to be retrieved.
Returns:
The peer identified by id.

getSafeInvokeService

public StaticText getSafeInvokeService()
Description copied from class: InstancePeer
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.

Overrides:
getSafeInvokeService in class InstancePeer
Returns:
The service that renders the script containing the safeInvoke() method.

getServiceRegistry

public ServiceRegistry getServiceRegistry()
Description copied from class: InstancePeer
Returns the ServiceRegistry that is used by this instance to hold all Service objects available to it.

Overrides:
getServiceRegistry in class InstancePeer
Returns:
This instance's ServiceRegistry.

getUserPrincipal

public java.security.Principal getUserPrincipal()
Description copied from class: InstancePeer
Returns the principal (user) of this application. This method provides the identical capability of HttpServletRequest.getUserPrincipal().

Overrides:
getUserPrincipal in class InstancePeer
Returns:
The principal (user) of this application.

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Description copied from class: InstancePeer
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
Overrides:
propertyChange in class InstancePeer
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)
Description copied from class: InstancePeer
Causes the service containing the given component to be re-rendered.

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

valueBound

public void valueBound(javax.servlet.http.HttpSessionBindingEvent e)
Description copied from class: InstancePeer
Listener implementation of HttpSessionBindingListener. Stores reference to session when invoked.

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

valueUnbound

public void valueUnbound(javax.servlet.http.HttpSessionBindingEvent e)
Description copied from class: InstancePeer
Listener implementation of Mcode>HttpSessionBindingListener. Removes reference to session when invoked.

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