summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2013-03-26 19:02:51 +0200
committerVaadin Code Review <review@vaadin.com>2013-03-27 16:15:22 +0000
commit5e77672975c6d272072baeec77005c847535fd97 (patch)
tree968eef92f8ea6e4ee4d09b48f47fceebf37908ac /server/src/com/vaadin
parent3c351deadfd4980ee43a1c86870a4c50ed78b310 (diff)
downloadvaadin-framework-5e77672975c6d272072baeec77005c847535fd97.tar.gz
vaadin-framework-5e77672975c6d272072baeec77005c847535fd97.zip
Removed CommunicationManager and PortletCommunicationManager
* Moved AbstractCommunicationManager abstract methods getThemeResourceAsStream and createBootstrapHandler to VaadinService * Made ACM non-abstract and renamed to LegacyCommunicationManager * Lifted anonymous inner BootstrapHandler subclasses into named public classes Change-Id: I31739ce8a506d572e75ca8cd5509be215e01693d
Diffstat (limited to 'server/src/com/vaadin')
-rw-r--r--server/src/com/vaadin/server/AbstractClientConnector.java2
-rw-r--r--server/src/com/vaadin/server/ClientConnector.java2
-rw-r--r--server/src/com/vaadin/server/CommunicationManager.java93
-rw-r--r--server/src/com/vaadin/server/DragAndDropService.java4
-rw-r--r--server/src/com/vaadin/server/JsonCodec.java4
-rw-r--r--server/src/com/vaadin/server/JsonPaintTarget.java4
-rw-r--r--server/src/com/vaadin/server/LegacyCommunicationManager.java (renamed from server/src/com/vaadin/server/AbstractCommunicationManager.java)43
-rw-r--r--server/src/com/vaadin/server/LegacyPaint.java2
-rw-r--r--server/src/com/vaadin/server/PortletCommunicationManager.java147
-rw-r--r--server/src/com/vaadin/server/UnsupportedBrowserHandler.java2
-rw-r--r--server/src/com/vaadin/server/VaadinPortlet.java4
-rw-r--r--server/src/com/vaadin/server/VaadinPortletService.java25
-rw-r--r--server/src/com/vaadin/server/VaadinService.java34
-rw-r--r--server/src/com/vaadin/server/VaadinServlet.java2
-rw-r--r--server/src/com/vaadin/server/VaadinServletService.java26
-rw-r--r--server/src/com/vaadin/server/VaadinSession.java6
-rw-r--r--server/src/com/vaadin/server/communication/ConnectorHierarchyWriter.java4
-rw-r--r--server/src/com/vaadin/server/communication/PortletBootstrapHandler.java101
-rw-r--r--server/src/com/vaadin/server/communication/PublishedFileHandler.java12
-rw-r--r--server/src/com/vaadin/server/communication/ResourceWriter.java10
-rw-r--r--server/src/com/vaadin/server/communication/ServerRpcHandler.java8
-rw-r--r--server/src/com/vaadin/server/communication/ServletBootstrapHandler.java36
-rw-r--r--server/src/com/vaadin/server/communication/UidlRequestHandler.java8
-rw-r--r--server/src/com/vaadin/server/communication/UidlWriter.java6
-rw-r--r--server/src/com/vaadin/ui/ConnectorTracker.java6
25 files changed, 248 insertions, 343 deletions
diff --git a/server/src/com/vaadin/server/AbstractClientConnector.java b/server/src/com/vaadin/server/AbstractClientConnector.java
index cf579585ea..80ef9a0375 100644
--- a/server/src/com/vaadin/server/AbstractClientConnector.java
+++ b/server/src/com/vaadin/server/AbstractClientConnector.java
@@ -233,7 +233,7 @@ public abstract class AbstractClientConnector implements ClientConnector,
@Override
public JSONObject encodeState() throws JSONException {
- return AbstractCommunicationManager.encodeState(this, getState());
+ return LegacyCommunicationManager.encodeState(this, getState());
}
/**
diff --git a/server/src/com/vaadin/server/ClientConnector.java b/server/src/com/vaadin/server/ClientConnector.java
index 5e95b18281..294f94f2be 100644
--- a/server/src/com/vaadin/server/ClientConnector.java
+++ b/server/src/com/vaadin/server/ClientConnector.java
@@ -300,7 +300,7 @@ public interface ClientConnector extends Connector {
/**
* Called by the framework to encode the state to a JSONObject. This is
* typically done by calling the static method
- * {@link AbstractCommunicationManager#encodeState(ClientConnector, SharedState)}
+ * {@link LegacyCommunicationManager#encodeState(ClientConnector, SharedState)}
* .
*
* @return a JSON object with the encoded connector state
diff --git a/server/src/com/vaadin/server/CommunicationManager.java b/server/src/com/vaadin/server/CommunicationManager.java
deleted file mode 100644
index 44e8f87d9f..0000000000
--- a/server/src/com/vaadin/server/CommunicationManager.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2000-2013 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.server;
-
-import java.io.InputStream;
-
-import javax.servlet.ServletContext;
-
-import com.vaadin.ui.UI;
-
-/**
- * Application manager processes changes and paints for single application
- * instance.
- *
- * This class handles applications running as servlets.
- *
- * @see AbstractCommunicationManager
- *
- * @author Vaadin Ltd.
- * @since 5.0
- *
- * @deprecated As of 7.0. Will likely change or be removed in a future version
- */
-@Deprecated
-@SuppressWarnings("serial")
-public class CommunicationManager extends AbstractCommunicationManager {
-
- /**
- * TODO New constructor - document me!
- *
- * @param session
- */
- public CommunicationManager(VaadinSession session) {
- super(session);
- }
-
- @Override
- protected BootstrapHandler createBootstrapHandler() {
- return new BootstrapHandler() {
- @Override
- protected String getServiceUrl(BootstrapContext context) {
- String pathInfo = context.getRequest().getPathInfo();
- if (pathInfo == null) {
- return null;
- } else {
- /*
- * Make a relative URL to the servlet by adding one ../ for
- * each path segment in pathInfo (i.e. the part of the
- * requested path that comes after the servlet mapping)
- */
- return VaadinServletService
- .getCancelingRelativePath(pathInfo);
- }
- }
-
- @Override
- public String getThemeName(BootstrapContext context) {
- String themeName = context.getRequest().getParameter(
- VaadinServlet.URL_PARAMETER_THEME);
- if (themeName == null) {
- themeName = super.getThemeName(context);
- }
- return themeName;
- }
- };
- }
-
- @Override
- public InputStream getThemeResourceAsStream(UI uI, String themeName,
- String resource) {
- VaadinServletService service = (VaadinServletService) uI.getSession()
- .getService();
- ServletContext servletContext = service.getServlet()
- .getServletContext();
- return servletContext.getResourceAsStream("/"
- + VaadinServlet.THEME_DIR_PATH + '/' + themeName + "/"
- + resource);
- }
-}
diff --git a/server/src/com/vaadin/server/DragAndDropService.java b/server/src/com/vaadin/server/DragAndDropService.java
index e403f4d4cb..a83e83ef7f 100644
--- a/server/src/com/vaadin/server/DragAndDropService.java
+++ b/server/src/com/vaadin/server/DragAndDropService.java
@@ -50,13 +50,13 @@ public class DragAndDropService implements VariableOwner, ClientConnector {
private DragAndDropEvent dragEvent;
- private final AbstractCommunicationManager manager;
+ private final LegacyCommunicationManager manager;
private AcceptCriterion acceptCriterion;
private ErrorHandler errorHandler;
- public DragAndDropService(AbstractCommunicationManager manager) {
+ public DragAndDropService(LegacyCommunicationManager manager) {
this.manager = manager;
}
diff --git a/server/src/com/vaadin/server/JsonCodec.java b/server/src/com/vaadin/server/JsonCodec.java
index 9a70efab28..d533ed99f3 100644
--- a/server/src/com/vaadin/server/JsonCodec.java
+++ b/server/src/com/vaadin/server/JsonCodec.java
@@ -667,7 +667,7 @@ public class JsonCodec implements Serializable {
} else if (value instanceof Connector) {
Connector connector = (Connector) value;
if (value instanceof Component
- && !(AbstractCommunicationManager
+ && !(LegacyCommunicationManager
.isComponentVisibleToClient((Component) value))) {
return encodeNull();
}
@@ -871,7 +871,7 @@ public class JsonCodec implements Serializable {
for (Entry<?, ?> entry : map.entrySet()) {
ClientConnector key = (ClientConnector) entry.getKey();
- if (AbstractCommunicationManager.isConnectorVisibleToClient(key)) {
+ if (LegacyCommunicationManager.isConnectorVisibleToClient(key)) {
EncodeResult encodedValue = encode(entry.getValue(), null,
valueType, connectorTracker);
jsonMap.put(key.getConnectorId(),
diff --git a/server/src/com/vaadin/server/JsonPaintTarget.java b/server/src/com/vaadin/server/JsonPaintTarget.java
index 35ff8659ad..ca70391f64 100644
--- a/server/src/com/vaadin/server/JsonPaintTarget.java
+++ b/server/src/com/vaadin/server/JsonPaintTarget.java
@@ -61,7 +61,7 @@ public class JsonPaintTarget implements PaintTarget {
private boolean closed = false;
- private final AbstractCommunicationManager manager;
+ private final LegacyCommunicationManager manager;
private int changes = 0;
@@ -87,7 +87,7 @@ public class JsonPaintTarget implements PaintTarget {
* @throws PaintException
* if the paint operation failed.
*/
- public JsonPaintTarget(AbstractCommunicationManager manager,
+ public JsonPaintTarget(LegacyCommunicationManager manager,
Writer outWriter, boolean cachingRequired) throws PaintException {
this.manager = manager;
diff --git a/server/src/com/vaadin/server/AbstractCommunicationManager.java b/server/src/com/vaadin/server/LegacyCommunicationManager.java
index 29dc5b2f81..2b99da7828 100644
--- a/server/src/com/vaadin/server/AbstractCommunicationManager.java
+++ b/server/src/com/vaadin/server/LegacyCommunicationManager.java
@@ -17,7 +17,6 @@
package com.vaadin.server;
import java.io.IOException;
-import java.io.InputStream;
import java.io.PrintWriter;
import java.io.Serializable;
import java.io.Writer;
@@ -61,7 +60,7 @@ import com.vaadin.ui.UI;
*/
@Deprecated
@SuppressWarnings("serial")
-public abstract class AbstractCommunicationManager implements Serializable {
+public class LegacyCommunicationManager implements Serializable {
// TODO PUSH move
public static final String WRITE_SECURITY_TOKEN_FLAG = "writeSecurityToken";
@@ -111,10 +110,10 @@ public abstract class AbstractCommunicationManager implements Serializable {
*
* @param session
*/
- public AbstractCommunicationManager(VaadinSession session) {
+ public LegacyCommunicationManager(VaadinSession session) {
this.session = session;
- // TODO Common to all sessions - handle at VaadinService level
- session.addRequestHandler(getBootstrapHandler());
+ session.addRequestHandler(session.getService().createBootstrapHandler(
+ session));
session.addRequestHandler(UNSUPPORTED_BROWSER_HANDLER);
session.addRequestHandler(CONNECTOR_RESOURCE_HANDLER);
requireLocale(session.getLocale().toString());
@@ -199,7 +198,7 @@ public abstract class AbstractCommunicationManager implements Serializable {
/**
* Resolves a dependency URI, registering the URI with this
- * {@code AbstractCommunicationManager} if needed and returns a fully
+ * {@code LegacyCommunicationManager} if needed and returns a fully
* qualified URI.
*
* @deprecated As of 7.1. See #11413.
@@ -334,13 +333,6 @@ public abstract class AbstractCommunicationManager implements Serializable {
}
/**
- * @deprecated As of 7.1. Likely to be removed or replaced in the future.
- */
- @Deprecated
- public abstract InputStream getThemeResourceAsStream(UI uI,
- String themeName, String resource);
-
- /**
* @deprecated As of 7.1. See #11412.
*/
@Deprecated
@@ -527,29 +519,6 @@ public abstract class AbstractCommunicationManager implements Serializable {
}
/**
- * Gets the bootstrap handler that should be used for generating the pages
- * bootstrapping applications for this communication manager.
- *
- * @return the bootstrap handler to use
- */
- private BootstrapHandler getBootstrapHandler() {
- if (bootstrapHandler == null) {
- bootstrapHandler = createBootstrapHandler();
- }
-
- return bootstrapHandler;
- }
-
- /**
- * @return
- *
- * @deprecated As of 7.0. Will likely change or be removed in a future
- * version
- */
- @Deprecated
- protected abstract BootstrapHandler createBootstrapHandler();
-
- /**
* Handles a request by passing it to each registered {@link RequestHandler}
* in turn until one produces a response. This method is used for requests
* that have not been handled by any specific functionality in the terminal
@@ -634,6 +603,6 @@ public abstract class AbstractCommunicationManager implements Serializable {
}
private static final Logger getLogger() {
- return Logger.getLogger(AbstractCommunicationManager.class.getName());
+ return Logger.getLogger(LegacyCommunicationManager.class.getName());
}
}
diff --git a/server/src/com/vaadin/server/LegacyPaint.java b/server/src/com/vaadin/server/LegacyPaint.java
index 09477aaf3e..8d59dfd5ea 100644
--- a/server/src/com/vaadin/server/LegacyPaint.java
+++ b/server/src/com/vaadin/server/LegacyPaint.java
@@ -50,7 +50,7 @@ public class LegacyPaint implements Serializable {
public static void paint(Component component, PaintTarget target)
throws PaintException {
// Only paint content of visible components.
- if (!AbstractCommunicationManager.isComponentVisibleToClient(component)) {
+ if (!LegacyCommunicationManager.isComponentVisibleToClient(component)) {
return;
}
diff --git a/server/src/com/vaadin/server/PortletCommunicationManager.java b/server/src/com/vaadin/server/PortletCommunicationManager.java
deleted file mode 100644
index fdec421741..0000000000
--- a/server/src/com/vaadin/server/PortletCommunicationManager.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright 2000-2013 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.server;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.portlet.MimeResponse;
-import javax.portlet.PortletContext;
-import javax.portlet.PortletRequest;
-import javax.portlet.PortletResponse;
-import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
-import javax.portlet.ResourceURL;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import com.vaadin.shared.ApplicationConstants;
-import com.vaadin.ui.UI;
-
-/**
- * TODO document me!
- *
- * @author peholmst
- *
- *
- * @deprecated As of 7.0. Will likely change or be removed in a future version
- */
-@Deprecated
-@SuppressWarnings("serial")
-public class PortletCommunicationManager extends AbstractCommunicationManager {
-
- public PortletCommunicationManager(VaadinSession session) {
- super(session);
- }
-
- @Override
- protected BootstrapHandler createBootstrapHandler() {
- return new BootstrapHandler() {
- @Override
- public boolean handleRequest(VaadinSession session,
- VaadinRequest request, VaadinResponse response)
- throws IOException {
- PortletRequest portletRequest = ((VaadinPortletRequest) request)
- .getPortletRequest();
- if (portletRequest instanceof RenderRequest) {
- return super.handleRequest(session, request, response);
- } else {
- return false;
- }
- }
-
- @Override
- protected String getServiceUrl(BootstrapContext context) {
- ResourceURL portletResourceUrl = getRenderResponse(context)
- .createResourceURL();
- portletResourceUrl.setResourceID(VaadinPortlet.RESOURCE_URL_ID);
- return portletResourceUrl.toString();
- }
-
- private RenderResponse getRenderResponse(BootstrapContext context) {
- PortletResponse response = ((VaadinPortletResponse) context
- .getResponse()).getPortletResponse();
-
- RenderResponse renderResponse = (RenderResponse) response;
- return renderResponse;
- }
-
- @Override
- protected void appendMainScriptTagContents(
- BootstrapContext context, StringBuilder builder)
- throws JSONException, IOException {
- // fixed base theme to use - all portal pages with Vaadin
- // applications will load this exactly once
- String portalTheme = ((VaadinPortletRequest) context
- .getRequest())
- .getPortalProperty(VaadinPortlet.PORTAL_PARAMETER_VAADIN_THEME);
- if (portalTheme != null
- && !portalTheme.equals(context.getThemeName())) {
- String portalThemeUri = getThemeUri(context, portalTheme);
- // XSS safe - originates from portal properties
- builder.append("vaadin.loadTheme('" + portalThemeUri
- + "');");
- }
-
- super.appendMainScriptTagContents(context, builder);
- }
-
- @Override
- protected String getMainDivStyle(BootstrapContext context) {
- VaadinService vaadinService = context.getRequest().getService();
- return vaadinService.getDeploymentConfiguration()
- .getApplicationOrSystemProperty(
- VaadinPortlet.PORTLET_PARAMETER_STYLE, null);
- }
-
- @Override
- protected JSONObject getApplicationParameters(
- BootstrapContext context) throws JSONException,
- PaintException {
- JSONObject parameters = super.getApplicationParameters(context);
- VaadinPortletResponse response = (VaadinPortletResponse) context
- .getResponse();
- MimeResponse portletResponse = (MimeResponse) response
- .getPortletResponse();
- ResourceURL resourceURL = portletResponse.createResourceURL();
- resourceURL.setResourceID("v-browserDetails");
- parameters.put("browserDetailsUrl", resourceURL.toString());
-
- // Always send path info as a query parameter
- parameters.put(
- ApplicationConstants.SERVICE_URL_PATH_AS_PARAMETER,
- true);
-
- return parameters;
- }
-
- };
-
- }
-
- @Override
- public InputStream getThemeResourceAsStream(UI uI, String themeName,
- String resource) {
- VaadinPortletSession session = (VaadinPortletSession) uI.getSession();
- PortletContext portletContext = session.getPortletSession()
- .getPortletContext();
- return portletContext.getResourceAsStream("/"
- + VaadinPortlet.THEME_DIR_PATH + '/' + themeName + "/"
- + resource);
- }
-
-}
diff --git a/server/src/com/vaadin/server/UnsupportedBrowserHandler.java b/server/src/com/vaadin/server/UnsupportedBrowserHandler.java
index 55d5a5c78f..65a99ce79c 100644
--- a/server/src/com/vaadin/server/UnsupportedBrowserHandler.java
+++ b/server/src/com/vaadin/server/UnsupportedBrowserHandler.java
@@ -24,7 +24,7 @@ import java.io.Writer;
*
* <p>
* This handler is usually added to the application by
- * {@link AbstractCommunicationManager}.
+ * {@link LegacyCommunicationManager}.
* </p>
*/
@SuppressWarnings("serial")
diff --git a/server/src/com/vaadin/server/VaadinPortlet.java b/server/src/com/vaadin/server/VaadinPortlet.java
index cc92edf6b2..51bbb21d90 100644
--- a/server/src/com/vaadin/server/VaadinPortlet.java
+++ b/server/src/com/vaadin/server/VaadinPortlet.java
@@ -50,7 +50,7 @@ import javax.servlet.http.HttpServletResponse;
import com.liferay.portal.kernel.util.PortalClassInvoker;
import com.liferay.portal.kernel.util.PropsUtil;
-import com.vaadin.server.AbstractCommunicationManager.Callback;
+import com.vaadin.server.LegacyCommunicationManager.Callback;
import com.vaadin.server.communication.FileUploadHandler;
import com.vaadin.server.communication.HeartbeatHandler;
import com.vaadin.server.communication.PortletListenerNotifier;
@@ -525,7 +525,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants,
private void handleOtherRequest(VaadinPortletRequest request,
VaadinResponse response, RequestType requestType,
VaadinSession vaadinSession,
- AbstractCommunicationManager communicationManager)
+ LegacyCommunicationManager communicationManager)
throws PortletException, IOException, MalformedURLException {
if (requestType == RequestType.APP || requestType == RequestType.RENDER) {
if (!communicationManager.handleOtherRequest(request, response)) {
diff --git a/server/src/com/vaadin/server/VaadinPortletService.java b/server/src/com/vaadin/server/VaadinPortletService.java
index 8c1e7af0fa..6023f6448b 100644
--- a/server/src/com/vaadin/server/VaadinPortletService.java
+++ b/server/src/com/vaadin/server/VaadinPortletService.java
@@ -17,6 +17,7 @@
package com.vaadin.server;
import java.io.File;
+import java.io.InputStream;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -24,7 +25,9 @@ import java.util.logging.Logger;
import javax.portlet.PortletContext;
import javax.portlet.PortletRequest;
+
import com.vaadin.server.VaadinPortlet.RequestType;
+import com.vaadin.server.communication.PortletBootstrapHandler;
import com.vaadin.ui.UI;
public class VaadinPortletService extends VaadinService {
@@ -196,12 +199,6 @@ public class VaadinPortletService extends VaadinService {
return type;
}
- @Override
- protected AbstractCommunicationManager createCommunicationManager(
- VaadinSession session) {
- return new PortletCommunicationManager(session);
- }
-
public static PortletRequest getCurrentPortletRequest() {
VaadinRequest currentRequest = VaadinService.getCurrentRequest();
if (currentRequest instanceof VaadinPortletRequest) {
@@ -235,6 +232,17 @@ public class VaadinPortletService extends VaadinService {
}
@Override
+ public InputStream getThemeResourceAsStream(UI uI, String themeName,
+ String resource) {
+ VaadinPortletSession session = (VaadinPortletSession) uI.getSession();
+ PortletContext portletContext = session.getPortletSession()
+ .getPortletContext();
+ return portletContext.getResourceAsStream("/"
+ + VaadinPortlet.THEME_DIR_PATH + '/' + themeName + "/"
+ + resource);
+ }
+
+ @Override
public String getMainDivId(VaadinSession session, VaadinRequest request,
Class<? extends UI> uiClass) {
PortletRequest portletRequest = ((VaadinPortletRequest) request)
@@ -245,4 +253,9 @@ public class VaadinPortletService extends VaadinService {
*/
return "v-" + portletRequest.getWindowID();
}
+
+ @Override
+ protected BootstrapHandler createBootstrapHandler(VaadinSession session) {
+ return new PortletBootstrapHandler();
+ }
}
diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java
index ada0fac107..9be1c64880 100644
--- a/server/src/com/vaadin/server/VaadinService.java
+++ b/server/src/com/vaadin/server/VaadinService.java
@@ -17,6 +17,7 @@
package com.vaadin.server;
import java.io.File;
+import java.io.InputStream;
import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
@@ -282,6 +283,13 @@ public abstract class VaadinService implements Serializable {
public abstract File getBaseDirectory();
/**
+ * Creates the bootstrap handler that should be used to generate the initial
+ * HTML bootstrapping a new {@link UI} in the given session.
+ */
+ protected abstract BootstrapHandler createBootstrapHandler(
+ VaadinSession session);
+
+ /**
* Adds a listener that gets notified when a new Vaadin service session is
* initialized for this service.
* <p>
@@ -441,7 +449,7 @@ public abstract class VaadinService implements Serializable {
Locale locale = request.getLocale();
session.setLocale(locale);
session.setConfiguration(getDeploymentConfiguration());
- session.setCommunicationManager(createCommunicationManager(session));
+ session.setCommunicationManager(new LegacyCommunicationManager(session));
ServletPortletHelper.initDefaultUIProvider(session, this);
onVaadinSessionStarted(request, session);
@@ -468,17 +476,6 @@ public abstract class VaadinService implements Serializable {
}
/**
- * Create a communication manager to use for the given service session.
- *
- * @param session
- * the service session for which a new communication manager is
- * needed
- * @return a new communication manager
- */
- protected abstract AbstractCommunicationManager createCommunicationManager(
- VaadinSession session);
-
- /**
* Creates a new Vaadin service session.
*
* @param request
@@ -735,6 +732,19 @@ public abstract class VaadinService implements Serializable {
}
/**
+ * TODO PUSH Document
+ *
+ * TODO Pass UI or VaadinSession?
+ *
+ * @param uI
+ * @param themeName
+ * @param resource
+ * @return
+ */
+ public abstract InputStream getThemeResourceAsStream(UI uI,
+ String themeName, String resource);
+
+ /**
* Creates and returns a unique ID for the DIV where the UI is to be
* rendered.
*
diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java
index 599c3d6bec..bb5a4a8ab5 100644
--- a/server/src/com/vaadin/server/VaadinServlet.java
+++ b/server/src/com/vaadin/server/VaadinServlet.java
@@ -39,7 +39,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.vaadin.sass.internal.ScssStylesheet;
-import com.vaadin.server.AbstractCommunicationManager.Callback;
+import com.vaadin.server.LegacyCommunicationManager.Callback;
import com.vaadin.server.communication.FileUploadHandler;
import com.vaadin.server.communication.HeartbeatHandler;
import com.vaadin.server.communication.PublishedFileHandler;
diff --git a/server/src/com/vaadin/server/VaadinServletService.java b/server/src/com/vaadin/server/VaadinServletService.java
index 7120e3a5c5..f453a6b140 100644
--- a/server/src/com/vaadin/server/VaadinServletService.java
+++ b/server/src/com/vaadin/server/VaadinServletService.java
@@ -17,12 +17,15 @@
package com.vaadin.server;
import java.io.File;
+import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import com.vaadin.server.VaadinServlet.RequestType;
+import com.vaadin.server.communication.ServletBootstrapHandler;
import com.vaadin.ui.UI;
public class VaadinServletService extends VaadinService {
@@ -174,12 +177,6 @@ public class VaadinServletService extends VaadinService {
return getServlet().getApplicationUrl((VaadinServletRequest) request);
}
- @Override
- protected AbstractCommunicationManager createCommunicationManager(
- VaadinSession session) {
- return new CommunicationManager(session);
- }
-
public static HttpServletRequest getCurrentServletRequest() {
VaadinRequest currentRequest = VaadinService.getCurrentRequest();
if (currentRequest instanceof VaadinServletRequest) {
@@ -199,6 +196,18 @@ public class VaadinServletService extends VaadinService {
}
@Override
+ public InputStream getThemeResourceAsStream(UI uI, String themeName,
+ String resource) {
+ VaadinServletService service = (VaadinServletService) uI.getSession()
+ .getService();
+ ServletContext servletContext = service.getServlet()
+ .getServletContext();
+ return servletContext.getResourceAsStream("/"
+ + VaadinServlet.THEME_DIR_PATH + '/' + themeName + "/"
+ + resource);
+ }
+
+ @Override
public String getMainDivId(VaadinSession session, VaadinRequest request,
Class<? extends UI> uiClass) {
String appId = null;
@@ -225,4 +234,9 @@ public class VaadinServletService extends VaadinService {
appId = appId + "-" + hashCode;
return appId;
}
+
+ @Override
+ protected BootstrapHandler createBootstrapHandler(VaadinSession session) {
+ return new ServletBootstrapHandler();
+ }
}
diff --git a/server/src/com/vaadin/server/VaadinSession.java b/server/src/com/vaadin/server/VaadinSession.java
index d3619ebabf..92a3399bb5 100644
--- a/server/src/com/vaadin/server/VaadinSession.java
+++ b/server/src/com/vaadin/server/VaadinSession.java
@@ -110,7 +110,7 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable {
protected WebBrowser browser = new WebBrowser();
- private AbstractCommunicationManager communicationManager;
+ private LegacyCommunicationManager communicationManager;
private long cumulativeRequestDuration = 0;
@@ -262,7 +262,7 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable {
* version
*/
@Deprecated
- public AbstractCommunicationManager getCommunicationManager() {
+ public LegacyCommunicationManager getCommunicationManager() {
return communicationManager;
}
@@ -320,7 +320,7 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable {
}
public void setCommunicationManager(
- AbstractCommunicationManager communicationManager) {
+ LegacyCommunicationManager communicationManager) {
if (communicationManager == null) {
throw new IllegalArgumentException("Can not set to null");
}
diff --git a/server/src/com/vaadin/server/communication/ConnectorHierarchyWriter.java b/server/src/com/vaadin/server/communication/ConnectorHierarchyWriter.java
index 0d1370528d..963886edbb 100644
--- a/server/src/com/vaadin/server/communication/ConnectorHierarchyWriter.java
+++ b/server/src/com/vaadin/server/communication/ConnectorHierarchyWriter.java
@@ -26,7 +26,7 @@ import org.json.JSONException;
import org.json.JSONObject;
import com.vaadin.server.AbstractClientConnector;
-import com.vaadin.server.AbstractCommunicationManager;
+import com.vaadin.server.LegacyCommunicationManager;
import com.vaadin.server.ClientConnector;
import com.vaadin.server.PaintException;
import com.vaadin.ui.UI;
@@ -62,7 +62,7 @@ public class ConnectorHierarchyWriter implements Serializable {
for (ClientConnector child : AbstractClientConnector
.getAllChildrenIterable(connector)) {
- if (AbstractCommunicationManager
+ if (LegacyCommunicationManager
.isConnectorVisibleToClient(child)) {
children.put(child.getConnectorId());
}
diff --git a/server/src/com/vaadin/server/communication/PortletBootstrapHandler.java b/server/src/com/vaadin/server/communication/PortletBootstrapHandler.java
new file mode 100644
index 0000000000..593c49bbeb
--- /dev/null
+++ b/server/src/com/vaadin/server/communication/PortletBootstrapHandler.java
@@ -0,0 +1,101 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.server.communication;
+
+import java.io.IOException;
+
+import javax.portlet.MimeResponse;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.ResourceURL;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import com.vaadin.server.BootstrapHandler;
+import com.vaadin.server.PaintException;
+import com.vaadin.server.VaadinPortlet;
+import com.vaadin.server.VaadinPortletRequest;
+import com.vaadin.server.VaadinPortletResponse;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.server.VaadinResponse;
+import com.vaadin.server.VaadinService;
+import com.vaadin.server.VaadinSession;
+import com.vaadin.shared.ApplicationConstants;
+
+public class PortletBootstrapHandler extends BootstrapHandler {
+ @Override
+ public boolean handleRequest(VaadinSession session, VaadinRequest request,
+ VaadinResponse response) throws IOException {
+ PortletRequest portletRequest = ((VaadinPortletRequest) request)
+ .getPortletRequest();
+ if (portletRequest instanceof RenderRequest) {
+ return super.handleRequest(session, request, response);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ protected String getServiceUrl(BootstrapContext context) {
+ ResourceURL portletResourceUrl = getRenderResponse(context)
+ .createResourceURL();
+ portletResourceUrl.setResourceID(VaadinPortlet.RESOURCE_URL_ID);
+ return portletResourceUrl.toString();
+ }
+
+ private RenderResponse getRenderResponse(BootstrapContext context) {
+ PortletResponse response = ((VaadinPortletResponse) context
+ .getResponse()).getPortletResponse();
+
+ RenderResponse renderResponse = (RenderResponse) response;
+ return renderResponse;
+ }
+
+ @Override
+ protected void appendMainScriptTagContents(BootstrapContext context,
+ StringBuilder builder) throws JSONException, IOException {
+ // fixed base theme to use - all portal pages with Vaadin
+ // applications will load this exactly once
+ String portalTheme = ((VaadinPortletRequest) context.getRequest())
+ .getPortalProperty(VaadinPortlet.PORTAL_PARAMETER_VAADIN_THEME);
+ if (portalTheme != null && !portalTheme.equals(context.getThemeName())) {
+ String portalThemeUri = getThemeUri(context, portalTheme);
+ // XSS safe - originates from portal properties
+ builder.append("vaadin.loadTheme('" + portalThemeUri + "');");
+ }
+
+ super.appendMainScriptTagContents(context, builder);
+ }
+
+ @Override
+ protected String getMainDivStyle(BootstrapContext context) {
+ VaadinService vaadinService = context.getRequest().getService();
+ return vaadinService.getDeploymentConfiguration()
+ .getApplicationOrSystemProperty(
+ VaadinPortlet.PORTLET_PARAMETER_STYLE, null);
+ }
+
+ @Override
+ protected JSONObject getApplicationParameters(BootstrapContext context)
+ throws JSONException, PaintException {
+ JSONObject parameters = super.getApplicationParameters(context);
+ VaadinPortletResponse response = (VaadinPortletResponse) context
+ .getResponse();
+ MimeResponse portletResponse = (MimeResponse) response
+ .getPortletResponse();
+ ResourceURL resourceURL = portletResponse.createResourceURL();
+ resourceURL.setResourceID("v-browserDetails");
+ parameters.put("browserDetailsUrl", resourceURL.toString());
+
+ // Always send path info as a query parameter
+ parameters
+ .put(ApplicationConstants.SERVICE_URL_PATH_AS_PARAMETER, true);
+
+ return parameters;
+ }
+} \ No newline at end of file
diff --git a/server/src/com/vaadin/server/communication/PublishedFileHandler.java b/server/src/com/vaadin/server/communication/PublishedFileHandler.java
index 3261dc7b9f..71fd80099a 100644
--- a/server/src/com/vaadin/server/communication/PublishedFileHandler.java
+++ b/server/src/com/vaadin/server/communication/PublishedFileHandler.java
@@ -25,8 +25,8 @@ import javax.servlet.http.HttpServletResponse;
import com.vaadin.annotations.JavaScript;
import com.vaadin.annotations.StyleSheet;
-import com.vaadin.server.AbstractCommunicationManager;
import com.vaadin.server.Constants;
+import com.vaadin.server.LegacyCommunicationManager;
import com.vaadin.server.RequestHandler;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinResponse;
@@ -36,11 +36,11 @@ import com.vaadin.shared.ApplicationConstants;
/**
* Serves a connector resource from the classpath if the resource has previously
* been registered by calling
- * {@link AbstractCommunicationManager#registerDependency(String, Class)}.
- * Sending arbitrary files from the classpath is prevented by only accepting
- * resource names that have explicitly been registered. Resources can currently
- * only be registered by including a {@link JavaScript} or {@link StyleSheet}
- * annotation on a Connector class.
+ * {@link LegacyCommunicationManager#registerDependency(String, Class)}. Sending
+ * arbitrary files from the classpath is prevented by only accepting resource
+ * names that have explicitly been registered. Resources can currently only be
+ * registered by including a {@link JavaScript} or {@link StyleSheet} annotation
+ * on a Connector class.
*
* @author Vaadin Ltd
* @since 7.1
diff --git a/server/src/com/vaadin/server/communication/ResourceWriter.java b/server/src/com/vaadin/server/communication/ResourceWriter.java
index 3ba3f3f598..86f8dd3b36 100644
--- a/server/src/com/vaadin/server/communication/ResourceWriter.java
+++ b/server/src/com/vaadin/server/communication/ResourceWriter.java
@@ -25,7 +25,7 @@ import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
-import com.vaadin.server.AbstractCommunicationManager;
+import com.vaadin.server.LegacyCommunicationManager;
import com.vaadin.server.JsonPaintTarget;
import com.vaadin.ui.CustomLayout;
import com.vaadin.ui.UI;
@@ -54,7 +54,7 @@ public class ResourceWriter implements Serializable {
throws IOException {
// TODO PUSH Refactor so that this is not needed
- AbstractCommunicationManager manager = ui.getSession()
+ LegacyCommunicationManager manager = ui.getSession()
.getCommunicationManager();
// Precache custom layouts
@@ -69,8 +69,10 @@ public class ResourceWriter implements Serializable {
final String resource = (String) i.next();
InputStream is = null;
try {
- is = manager.getThemeResourceAsStream(ui, manager.getTheme(ui),
- resource);
+ is = ui.getSession()
+ .getService()
+ .getThemeResourceAsStream(ui, manager.getTheme(ui),
+ resource);
} catch (final Exception e) {
// FIXME: Handle exception
getLogger().log(Level.FINER,
diff --git a/server/src/com/vaadin/server/communication/ServerRpcHandler.java b/server/src/com/vaadin/server/communication/ServerRpcHandler.java
index 23e8087196..da146abe3f 100644
--- a/server/src/com/vaadin/server/communication/ServerRpcHandler.java
+++ b/server/src/com/vaadin/server/communication/ServerRpcHandler.java
@@ -33,10 +33,10 @@ import java.util.logging.Logger;
import org.json.JSONArray;
import org.json.JSONException;
-import com.vaadin.server.AbstractCommunicationManager;
-import com.vaadin.server.AbstractCommunicationManager.InvalidUIDLSecurityKeyException;
import com.vaadin.server.ClientConnector;
import com.vaadin.server.JsonCodec;
+import com.vaadin.server.LegacyCommunicationManager;
+import com.vaadin.server.LegacyCommunicationManager.InvalidUIDLSecurityKeyException;
import com.vaadin.server.ServerRpcManager;
import com.vaadin.server.ServerRpcManager.RpcInvocationException;
import com.vaadin.server.ServerRpcMethodInvocation;
@@ -130,7 +130,7 @@ public class ServerRpcHandler implements Serializable {
// response.
// TODO This seems to be dead code
request.setAttribute(
- AbstractCommunicationManager.WRITE_SECURITY_TOKEN_FLAG,
+ LegacyCommunicationManager.WRITE_SECURITY_TOKEN_FLAG,
true);
return;
} else {
@@ -170,7 +170,7 @@ public class ServerRpcHandler implements Serializable {
*/
private void handleBurst(UI uI, String burst) {
// TODO PUSH Refactor so that this is not needed
- AbstractCommunicationManager manager = uI.getSession()
+ LegacyCommunicationManager manager = uI.getSession()
.getCommunicationManager();
try {
diff --git a/server/src/com/vaadin/server/communication/ServletBootstrapHandler.java b/server/src/com/vaadin/server/communication/ServletBootstrapHandler.java
new file mode 100644
index 0000000000..8e2849cef5
--- /dev/null
+++ b/server/src/com/vaadin/server/communication/ServletBootstrapHandler.java
@@ -0,0 +1,36 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.server.communication;
+
+import com.vaadin.server.BootstrapHandler;
+import com.vaadin.server.VaadinServlet;
+import com.vaadin.server.VaadinServletService;
+
+public class ServletBootstrapHandler extends BootstrapHandler {
+ @Override
+ protected String getServiceUrl(BootstrapContext context) {
+ String pathInfo = context.getRequest().getPathInfo();
+ if (pathInfo == null) {
+ return null;
+ } else {
+ /*
+ * Make a relative URL to the servlet by adding one ../ for each
+ * path segment in pathInfo (i.e. the part of the requested path
+ * that comes after the servlet mapping)
+ */
+ return VaadinServletService.getCancelingRelativePath(pathInfo);
+ }
+ }
+
+ @Override
+ public String getThemeName(BootstrapContext context) {
+ String themeName = context.getRequest().getParameter(
+ VaadinServlet.URL_PARAMETER_THEME);
+ if (themeName == null) {
+ themeName = super.getThemeName(context);
+ }
+ return themeName;
+ }
+} \ No newline at end of file
diff --git a/server/src/com/vaadin/server/communication/UidlRequestHandler.java b/server/src/com/vaadin/server/communication/UidlRequestHandler.java
index c200abb31d..b128a34c7d 100644
--- a/server/src/com/vaadin/server/communication/UidlRequestHandler.java
+++ b/server/src/com/vaadin/server/communication/UidlRequestHandler.java
@@ -27,11 +27,11 @@ import java.util.logging.Logger;
import org.json.JSONException;
-import com.vaadin.server.AbstractCommunicationManager;
-import com.vaadin.server.AbstractCommunicationManager.Callback;
-import com.vaadin.server.AbstractCommunicationManager.InvalidUIDLSecurityKeyException;
import com.vaadin.server.ClientConnector;
import com.vaadin.server.Constants;
+import com.vaadin.server.LegacyCommunicationManager;
+import com.vaadin.server.LegacyCommunicationManager.Callback;
+import com.vaadin.server.LegacyCommunicationManager.InvalidUIDLSecurityKeyException;
import com.vaadin.server.RequestHandler;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinResponse;
@@ -167,7 +167,7 @@ public class UidlRequestHandler implements RequestHandler {
// security key
Object writeSecurityTokenFlag = request
- .getAttribute(AbstractCommunicationManager.WRITE_SECURITY_TOKEN_FLAG);
+ .getAttribute(LegacyCommunicationManager.WRITE_SECURITY_TOKEN_FLAG);
if (writeSecurityTokenFlag != null) {
writer.write(ui.getSession().getCommunicationManager()
diff --git a/server/src/com/vaadin/server/communication/UidlWriter.java b/server/src/com/vaadin/server/communication/UidlWriter.java
index 0086affe91..d49e7d9cbf 100644
--- a/server/src/com/vaadin/server/communication/UidlWriter.java
+++ b/server/src/com/vaadin/server/communication/UidlWriter.java
@@ -32,8 +32,8 @@ import org.json.JSONException;
import com.vaadin.annotations.JavaScript;
import com.vaadin.annotations.StyleSheet;
-import com.vaadin.server.AbstractCommunicationManager;
-import com.vaadin.server.AbstractCommunicationManager.ClientCache;
+import com.vaadin.server.LegacyCommunicationManager;
+import com.vaadin.server.LegacyCommunicationManager.ClientCache;
import com.vaadin.server.ClientConnector;
import com.vaadin.server.JsonPaintTarget;
import com.vaadin.server.SystemMessages;
@@ -73,7 +73,7 @@ public class UidlWriter implements Serializable {
ArrayList<ClientConnector> dirtyVisibleConnectors = ui
.getConnectorTracker().getDirtyVisibleConnectors();
VaadinSession session = ui.getSession();
- AbstractCommunicationManager manager = session
+ LegacyCommunicationManager manager = session
.getCommunicationManager();
// Paints components
ConnectorTracker uiConnectorTracker = ui.getConnectorTracker();
diff --git a/server/src/com/vaadin/ui/ConnectorTracker.java b/server/src/com/vaadin/ui/ConnectorTracker.java
index 7d741e1b28..bd66f3b368 100644
--- a/server/src/com/vaadin/ui/ConnectorTracker.java
+++ b/server/src/com/vaadin/ui/ConnectorTracker.java
@@ -32,7 +32,7 @@ import org.json.JSONException;
import org.json.JSONObject;
import com.vaadin.server.AbstractClientConnector;
-import com.vaadin.server.AbstractCommunicationManager;
+import com.vaadin.server.LegacyCommunicationManager;
import com.vaadin.server.ClientConnector;
import com.vaadin.server.GlobalResourceHandler;
import com.vaadin.server.StreamVariable;
@@ -296,7 +296,7 @@ public class ConnectorTracker implements Serializable {
uninitializedConnectors.remove(connector);
diffStates.remove(connector);
iterator.remove();
- } else if (!AbstractCommunicationManager
+ } else if (!LegacyCommunicationManager
.isConnectorVisibleToClient(connector)
&& !uninitializedConnectors.contains(connector)) {
uninitializedConnectors.add(connector);
@@ -473,7 +473,7 @@ public class ConnectorTracker implements Serializable {
public ArrayList<ClientConnector> getDirtyVisibleConnectors() {
ArrayList<ClientConnector> dirtyConnectors = new ArrayList<ClientConnector>();
for (ClientConnector c : getDirtyConnectors()) {
- if (AbstractCommunicationManager.isConnectorVisibleToClient(c)) {
+ if (LegacyCommunicationManager.isConnectorVisibleToClient(c)) {
dirtyConnectors.add(c);
}
}