* Get or create an application context and an application
* manager for the session
*/
- PortletApplicationContext2 applicationContext = PortletApplicationContext2
- .getApplicationContext(request.getPortletSession());
+ PortletApplicationContext2 applicationContext = getApplicationContext(request
+ .getPortletSession());
applicationContext.setResponse(response);
applicationContext.setPortletConfig(getPortletConfig());
throws IOException {
final PortletSession session = request.getPortletSession();
if (session != null) {
- PortletApplicationContext2.getApplicationContext(session)
- .removeApplication(application);
+ getApplicationContext(session).removeApplication(application);
}
// Do not send any redirects when running inside a portlet.
}
application.close();
if (session != null) {
- PortletApplicationContext2 context = PortletApplicationContext2
- .getApplicationContext(session);
+ PortletApplicationContext2 context = getApplicationContext(session);
context.removeApplication(application);
}
}
private Application createApplication(PortletRequest request)
throws PortletException, MalformedURLException {
Application newApplication = getNewApplication(request);
- final PortletApplicationContext2 context = PortletApplicationContext2
- .getApplicationContext(request.getPortletSession());
+ final PortletApplicationContext2 context = getApplicationContext(request
+ .getPortletSession());
context.addApplication(newApplication, request.getWindowID());
return newApplication;
}
throw new SessionExpiredException();
}
- PortletApplicationContext2 context = PortletApplicationContext2
- .getApplicationContext(session);
+ PortletApplicationContext2 context = getApplicationContext(session);
Application application = context.getApplicationForWindowId(request
.getWindowID());
if (application == null) {
return application;
}
// application found but not running
- PortletApplicationContext2.getApplicationContext(session)
- .removeApplication(application);
+ context.removeApplication(application);
return null;
}
return null;
}
+ /**
+ *
+ * Gets the application context for a PortletSession. If no context is
+ * currently stored in a session a new context is created and stored in the
+ * session.
+ *
+ * @param portletSession
+ * the portlet session.
+ * @return the application context for the session.
+ */
+ protected PortletApplicationContext2 getApplicationContext(
+ PortletSession portletSession) {
+ return PortletApplicationContext2.getApplicationContext(portletSession);
+ }
+
}
if (mgr == null) {
// Creates a new manager
- mgr = new PortletCommunicationManager(application);
+ mgr = createPortletCommunicationManager(application);
applicationToAjaxAppMgrMap.put(application, mgr);
}
return mgr;
}
+ protected PortletCommunicationManager createPortletCommunicationManager(
+ Application application) {
+ return new PortletCommunicationManager(application);
+ }
+
public static PortletApplicationContext2 getApplicationContext(
PortletSession session) {
PortletApplicationContext2 cx = (PortletApplicationContext2) session