summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2013-03-21 12:26:41 +0200
committerVaadin Code Review <review@vaadin.com>2013-03-28 14:14:48 +0000
commita92166902c73a5b0e1e8e30e4876bc553f8779ab (patch)
treeb101cabe52507636eb530241bc4b8d2dec92dd6f /server
parent37527d9c5eb1174374c598cb98e85d39f7d3a37b (diff)
downloadvaadin-framework-a92166902c73a5b0e1e8e30e4876bc553f8779ab.tar.gz
vaadin-framework-a92166902c73a5b0e1e8e30e4876bc553f8779ab.zip
Refactored VaadinPortlet to have same structure as VaadinServlet (#10569)
Change-Id: Ia012fd3b200a97b394c18dca549d048695b88a43
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/server/VaadinPortlet.java52
1 files changed, 29 insertions, 23 deletions
diff --git a/server/src/com/vaadin/server/VaadinPortlet.java b/server/src/com/vaadin/server/VaadinPortlet.java
index 51bbb21d90..2cbd83aaca 100644
--- a/server/src/com/vaadin/server/VaadinPortlet.java
+++ b/server/src/com/vaadin/server/VaadinPortlet.java
@@ -376,24 +376,27 @@ public class VaadinPortlet extends GenericPortlet implements Constants,
@Deprecated
protected void handleRequest(PortletRequest request,
PortletResponse response) throws PortletException, IOException {
- RequestTimer requestTimer = new RequestTimer();
- requestTimer.start();
CurrentInstance.clearAll();
setCurrent(this);
+ handleRequest(createVaadinRequest(request),
+ createVaadinResponse(response));
+ }
- try {
- AbstractApplicationPortletWrapper portletWrapper = new AbstractApplicationPortletWrapper(
- this);
+ protected void handleRequest(VaadinPortletRequest request,
+ VaadinPortletResponse response) throws PortletException,
+ IOException {
+ RequestTimer requestTimer = new RequestTimer();
+ requestTimer.start();
- VaadinPortletRequest vaadinRequest = createVaadinRequest(request);
+ getService().setCurrentInstances(request, response);
- VaadinPortletResponse vaadinResponse = new VaadinPortletResponse(
- response, getService());
+ AbstractApplicationPortletWrapper portletWrapper = new AbstractApplicationPortletWrapper(
+ this);
- getService().setCurrentInstances(vaadinRequest, vaadinResponse);
+ try {
- RequestType requestType = getRequestType(vaadinRequest);
+ RequestType requestType = getRequestType(request);
if (requestType == RequestType.UNKNOWN) {
handleUnknownRequest(request, response);
@@ -418,43 +421,43 @@ public class VaadinPortlet extends GenericPortlet implements Constants,
try {
vaadinSession = (VaadinPortletSession) getService()
- .findVaadinSession(vaadinRequest);
+ .findVaadinSession(request);
if (vaadinSession == null) {
return;
}
if (requestType == RequestType.PUBLISHED_FILE) {
new PublishedFileHandler().handleRequest(vaadinSession,
- vaadinRequest, vaadinResponse);
+ request, response);
return;
} else if (requestType == RequestType.HEARTBEAT) {
new HeartbeatHandler().handleRequest(vaadinSession,
- vaadinRequest, vaadinResponse);
+ request, response);
return;
}
// Notify listeners
new PortletListenerNotifier().handleRequest(vaadinSession,
- vaadinRequest, vaadinResponse);
+ request, response);
/* Handle the request */
if (requestType == RequestType.FILE_UPLOAD) {
new FileUploadHandler().handleRequest(vaadinSession,
- vaadinRequest, vaadinResponse);
+ request, response);
return;
} else if (requestType == RequestType.BROWSER_DETAILS) {
new UIInitHandler().handleRequest(vaadinSession,
- vaadinRequest, vaadinResponse);
+ request, response);
return;
} else if (requestType == RequestType.UIDL) {
// Handles AJAX UIDL requests
new UidlRequestHandler(portletWrapper).handleRequest(
- vaadinSession, vaadinRequest, vaadinResponse);
+ vaadinSession, request, response);
return;
} else {
- handleOtherRequest(vaadinRequest, vaadinResponse,
- requestType, vaadinSession,
+ handleOtherRequest(request, response, requestType,
+ vaadinSession,
vaadinSession.getCommunicationManager());
}
} catch (final SessionExpiredException e) {
@@ -462,8 +465,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants,
// SessionExpiredExceptions
getLogger().finest("A user session has expired");
} catch (final Throwable e) {
- handleServiceException(vaadinRequest, vaadinResponse,
- vaadinSession, e);
+ handleServiceException(request, response, vaadinSession, e);
} finally {
if (vaadinSession != null) {
getService().cleanupSession(vaadinSession);
@@ -496,12 +498,16 @@ public class VaadinPortlet extends GenericPortlet implements Constants,
}
+ private VaadinPortletResponse createVaadinResponse(PortletResponse response) {
+ return new VaadinPortletResponse(response, getService());
+ }
+
protected VaadinPortletService getService() {
return vaadinService;
}
- private void handleUnknownRequest(PortletRequest request,
- PortletResponse response) {
+ private void handleUnknownRequest(VaadinPortletRequest request,
+ VaadinPortletResponse response) {
getLogger().warning("Unknown request type");
}