diff options
author | Artur Signell <artur@vaadin.com> | 2012-11-21 11:52:22 +0000 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2012-11-21 11:52:22 +0000 |
commit | 8af6628891f519f319b1bd122e60207bcb013901 (patch) | |
tree | 0aa769fc0f2298d10169c2d97e14b6164e930db0 /server/src/com/vaadin | |
parent | 3fc9f19534b7d1ab06fc73b146b9d31868c205c1 (diff) | |
parent | 7d9c4c5e06a95f4aa5eb371a2f5b5418b92fac64 (diff) | |
download | vaadin-framework-8af6628891f519f319b1bd122e60207bcb013901.tar.gz vaadin-framework-8af6628891f519f319b1bd122e60207bcb013901.zip |
Merge "Reomove DynamicConnectorResource (#10227)"
Diffstat (limited to 'server/src/com/vaadin')
-rw-r--r-- | server/src/com/vaadin/server/DynamicConnectorResource.java | 95 | ||||
-rw-r--r-- | server/src/com/vaadin/server/ResourceReference.java | 25 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/LoginForm.java | 15 |
3 files changed, 13 insertions, 122 deletions
diff --git a/server/src/com/vaadin/server/DynamicConnectorResource.java b/server/src/com/vaadin/server/DynamicConnectorResource.java deleted file mode 100644 index 0e29b289e4..0000000000 --- a/server/src/com/vaadin/server/DynamicConnectorResource.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2011 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.util.Collections; -import java.util.Map; - -import com.vaadin.util.FileTypeResolver; - -/** - * A resource that is served by calling - * {@link ClientConnector#handleConnectorRequest(VaadinRequest, VaadinResponse, String)} - * with appropriate parameters. - * - * @author Vaadin Ltd - * @version @VERSION@ - * @since 7.0.0 - */ -public class DynamicConnectorResource implements Resource { - - private final ClientConnector connector; - private final String path; - private final Map<String, String> parameters; - - /** - * Creates a DynamicConnectorResoruce for the given connector that will be - * served by calling - * {@link ClientConnector#handleConnectorRequest(VaadinRequest, VaadinResponse, String)} - * with the given path. - * - * @param connector - * the connector that should serve the resource - * @param path - * the relative path of the request - */ - public DynamicConnectorResource(ClientConnector connector, String path) { - this(connector, path, null); - } - - /** - * Creates a DynamicConnectorResoruce for the given connector that will be - * served by calling - * {@link ClientConnector#handleConnectorRequest(VaadinRequest, VaadinResponse, String)} - * with the given path and the given request parameters. - * - * @param connector - * the connector that should serve the resource - * @param path - * the relative path of the request - * @param parameters - * the parameters that should be present in the request - */ - public DynamicConnectorResource(ClientConnector connector, String path, - Map<String, String> parameters) { - this.connector = connector; - this.path = path; - this.parameters = parameters; - } - - @Override - public String getMIMEType() { - return FileTypeResolver.getMIMEType(path); - } - - public String getPath() { - return path; - } - - public ClientConnector getConnector() { - return connector; - } - - public Map<String, String> getParameters() { - if (parameters == null) { - return Collections.emptyMap(); - } else { - return Collections.unmodifiableMap(parameters); - } - } - -} diff --git a/server/src/com/vaadin/server/ResourceReference.java b/server/src/com/vaadin/server/ResourceReference.java index b6a0cfda92..fbb8af89c1 100644 --- a/server/src/com/vaadin/server/ResourceReference.java +++ b/server/src/com/vaadin/server/ResourceReference.java @@ -17,8 +17,6 @@ package com.vaadin.server; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; -import java.util.Map.Entry; -import java.util.Set; import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.communication.URLReference; @@ -44,29 +42,6 @@ public class ResourceReference extends URLReference { public String getURL() { if (resource instanceof ExternalResource) { return ((ExternalResource) resource).getURL(); - } else if (resource instanceof DynamicConnectorResource) { - DynamicConnectorResource dcr = (DynamicConnectorResource) resource; - - String filename = dcr.getPath(); - StringBuilder builder = new StringBuilder(getConnectorResourceBase( - filename, dcr.getConnector())); - - Set<Entry<String, String>> entrySet = dcr.getParameters() - .entrySet(); - boolean first = true; - for (Entry<String, String> entry : entrySet) { - String key = entry.getKey(); - String value = entry.getValue(); - if (first) { - builder.append('?'); - first = false; - } else { - builder.append('&'); - } - // TODO URL encode!!! - builder.append(key).append('=').append(value); - } - return builder.toString(); } else if (resource instanceof ConnectorResource) { ConnectorResource connectorResource = (ConnectorResource) resource; diff --git a/server/src/com/vaadin/ui/LoginForm.java b/server/src/com/vaadin/ui/LoginForm.java index b1e4741450..9c131b9700 100644 --- a/server/src/com/vaadin/ui/LoginForm.java +++ b/server/src/com/vaadin/ui/LoginForm.java @@ -22,7 +22,8 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import com.vaadin.server.DynamicConnectorResource; +import com.vaadin.server.ConnectorResource; +import com.vaadin.server.ExternalResource; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinResponse; import com.vaadin.server.VaadinService; @@ -108,12 +109,22 @@ public class LoginForm extends CustomComponent { public LoginForm() { iframe.setType(Embedded.TYPE_BROWSER); iframe.setSizeFull(); - iframe.setSource(new DynamicConnectorResource(this, "login")); setSizeFull(); setCompositionRoot(iframe); addStyleName("v-loginform"); } + @Override + public void beforeClientResponse(boolean initial) { + // Generate magic URL now when UI id and connectorId are known + iframe.setSource(new ExternalResource( + ApplicationConstants.APP_PROTOCOL_PREFIX + + ApplicationConstants.APP_REQUEST_PATH + '/' + + ConnectorResource.CONNECTOR_REQUEST_PATH + + getUI().getUIId() + '/' + getConnectorId() + "/login")); + super.beforeClientResponse(initial); + } + /** * Returns byte array containing login page html. If you need to override * the login html, use the default html as basis. Login page sets its target |