com.vaadin.terminal.gwt.server
Class PortletApplicationContext2

java.lang.Object
  extended by com.vaadin.terminal.gwt.server.AbstractWebApplicationContext
      extended by com.vaadin.terminal.gwt.server.PortletApplicationContext2
All Implemented Interfaces:
ApplicationContext, Serializable, EventListener, HttpSessionBindingListener

public class PortletApplicationContext2
extends AbstractWebApplicationContext

TODO Write documentation, fix JavaDoc tags. This is automatically registered as a HttpSessionBindingListener when PortletSession#setAttribute() is called with the context as value.

Author:
peholmst
See Also:
Serialized Form

Nested Class Summary
static interface PortletApplicationContext2.PortletListener
           
 
Nested classes/interfaces inherited from interface com.vaadin.service.ApplicationContext
ApplicationContext.TransactionListener
 
Field Summary
protected  PortletConfig portletConfig
           
protected  Map<Application,Set<PortletApplicationContext2.PortletListener>> portletListeners
           
protected  HashMap<String,Application> portletWindowIdToApplicationMap
           
protected  PortletSession session
           
 
Fields inherited from class com.vaadin.terminal.gwt.server.AbstractWebApplicationContext
applications, applicationToAjaxAppMgrMap, browser, listeners
 
Constructor Summary
PortletApplicationContext2()
           
 
Method Summary
protected  void addApplication(Application application, String portletWindowId)
           
 void addPortletListener(Application app, PortletApplicationContext2.PortletListener listener)
           
protected  PortletCommunicationManager createPortletCommunicationManager(Application application)
           
 void firePortletActionRequest(Application app, Root root, ActionRequest request, ActionResponse response)
           
 void firePortletEventRequest(Application app, Root root, EventRequest request, EventResponse response)
           
 void firePortletRenderRequest(Application app, Root root, RenderRequest request, RenderResponse response)
           
 void firePortletResourceRequest(Application app, Root root, ResourceRequest request, ResourceResponse response)
           
 PortletURL generateActionURL(String action)
          Creates a new action URL.
 String generateApplicationResourceURL(ApplicationResource resource, String mapKey)
          Generate a URL that can be used as the relative location of e.g.
static PortletApplicationContext2 getApplicationContext(PortletSession session)
           
 Application getApplicationForWindowId(String portletWindowId)
           
protected  PortletCommunicationManager getApplicationManager(Application application)
           
 File getBaseDirectory()
          Returns application context base directory.
 PortletConfig getPortletConfig()
           
 PortletSession getPortletSession()
           
protected  void removeApplication(Application application)
           
 void removePortletListener(Application app, PortletApplicationContext2.PortletListener listener)
           
 void sendPortletEvent(Root root, QName name, Serializable value)
          Sends a portlet event to the indicated destination.
 void setPortletConfig(PortletConfig config)
           
 void setPortletMode(Root root, PortletMode portletMode)
          Sets the portlet mode.
 void setSharedRenderParameter(Root root, String name, String value)
          Sets a shared portlet parameter.
 
Methods inherited from class com.vaadin.terminal.gwt.server.AbstractWebApplicationContext
addTransactionListener, endTransaction, getApplications, getBrowser, getLastRequestTime, getTotalSessionTime, getURLKey, isApplicationResourceURL, removeTransactionListener, setLastRequestTime, startTransaction, valueBound, valueUnbound
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

portletListeners

protected Map<Application,Set<PortletApplicationContext2.PortletListener>> portletListeners

session

protected transient PortletSession session

portletConfig

protected transient PortletConfig portletConfig

portletWindowIdToApplicationMap

protected HashMap<String,Application> portletWindowIdToApplicationMap
Constructor Detail

PortletApplicationContext2

public PortletApplicationContext2()
Method Detail

getBaseDirectory

public File getBaseDirectory()
Description copied from interface: ApplicationContext
Returns application context base directory. Typically an application is deployed in a such way that is has an application directory. For web applications this directory is the root directory of the web applications. In some cases applications might not have an application directory (for example web applications running inside a war).

Returns:
The application base directory or null if the application has no base directory.

getApplicationManager

protected PortletCommunicationManager getApplicationManager(Application application)

createPortletCommunicationManager

protected PortletCommunicationManager createPortletCommunicationManager(Application application)

getApplicationContext

public static PortletApplicationContext2 getApplicationContext(PortletSession session)

removeApplication

protected void removeApplication(Application application)
Overrides:
removeApplication in class AbstractWebApplicationContext

addApplication

protected void addApplication(Application application,
                              String portletWindowId)

getApplicationForWindowId

public Application getApplicationForWindowId(String portletWindowId)

getPortletSession

public PortletSession getPortletSession()

getPortletConfig

public PortletConfig getPortletConfig()

setPortletConfig

public void setPortletConfig(PortletConfig config)

addPortletListener

public void addPortletListener(Application app,
                               PortletApplicationContext2.PortletListener listener)

removePortletListener

public void removePortletListener(Application app,
                                  PortletApplicationContext2.PortletListener listener)

firePortletRenderRequest

public void firePortletRenderRequest(Application app,
                                     Root root,
                                     RenderRequest request,
                                     RenderResponse response)

firePortletActionRequest

public void firePortletActionRequest(Application app,
                                     Root root,
                                     ActionRequest request,
                                     ActionResponse response)

firePortletEventRequest

public void firePortletEventRequest(Application app,
                                    Root root,
                                    EventRequest request,
                                    EventResponse response)

firePortletResourceRequest

public void firePortletResourceRequest(Application app,
                                       Root root,
                                       ResourceRequest request,
                                       ResourceResponse response)

generateApplicationResourceURL

public String generateApplicationResourceURL(ApplicationResource resource,
                                             String mapKey)
Description copied from interface: ApplicationContext
Generate a URL that can be used as the relative location of e.g. an ApplicationResource. This method should only be called from the processing of a UIDL request, not from a background thread. The return value is null if used outside a suitable request.

Specified by:
generateApplicationResourceURL in interface ApplicationContext
Overrides:
generateApplicationResourceURL in class AbstractWebApplicationContext
mapKey - a key for the resource that can later be extracted from a URL with ApplicationContext.getURLKey(URL, String)

generateActionURL

public PortletURL generateActionURL(String action)
Creates a new action URL.

Parameters:
action -
Returns:
action URL or null if called outside a MimeRequest (outside a UIDL request or similar)

sendPortletEvent

public void sendPortletEvent(Root root,
                             QName name,
                             Serializable value)
                      throws IllegalStateException
Sends a portlet event to the indicated destination. Internally, an action may be created and opened, as an event cannot be sent directly from all types of requests. The event destinations and values need to be kept in the context until sent. Any memory leaks if the action fails are limited to the session. Event names for events sent and received by a portlet need to be declared in portlet.xml .

Parameters:
root - a window in which a temporary action URL can be opened if necessary
name - event name
value - event value object that is Serializable and, if appropriate, has a valid JAXB annotation
Throws:
IllegalStateException

setSharedRenderParameter

public void setSharedRenderParameter(Root root,
                                     String name,
                                     String value)
                              throws IllegalStateException
Sets a shared portlet parameter. Internally, an action may be created and opened, as shared parameters cannot be set directly from all types of requests. The parameters and values need to be kept in the context until sent. Any memory leaks if the action fails are limited to the session. Shared parameters set or read by a portlet need to be declared in portlet.xml .

Parameters:
root - a window in which a temporary action URL can be opened if necessary
name - parameter identifier
value - parameter value
Throws:
IllegalStateException

setPortletMode

public void setPortletMode(Root root,
                           PortletMode portletMode)
                    throws IllegalStateException,
                           PortletModeException
Sets the portlet mode. This may trigger a new render request. Portlet modes used by a portlet need to be declared in portlet.xml .

Parameters:
root - a window in which the render URL can be opened if necessary
portletMode - the portlet mode to switch to
Throws:
PortletModeException - if the portlet mode is not allowed for some reason (configuration, permissions etc.)
IllegalStateException


Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.