]> source.dussan.org Git - vaadin-framework.git/commitdiff
#5743, #5742, #5741, #4275 related refactoring. Renamed com.vaadin.terminal.Receiver...
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Wed, 3 Nov 2010 21:53:53 +0000 (21:53 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Wed, 3 Nov 2010 21:53:53 +0000 (21:53 +0000)
svn changeset:15849/svn branch:6.5

26 files changed:
src/com/vaadin/terminal/PaintTarget.java
src/com/vaadin/terminal/Receiver.java [deleted file]
src/com/vaadin/terminal/ReceiverOwner.java [deleted file]
src/com/vaadin/terminal/StreamVariable.java [new file with mode: 0644]
src/com/vaadin/terminal/UploadStream.java [deleted file]
src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
src/com/vaadin/terminal/gwt/server/AbstractReceivingEvent.java [deleted file]
src/com/vaadin/terminal/gwt/server/AbstractStreamingEvent.java [new file with mode: 0644]
src/com/vaadin/terminal/gwt/server/CommunicationManager.java
src/com/vaadin/terminal/gwt/server/HttpUploadStream.java [deleted file]
src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java
src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java
src/com/vaadin/terminal/gwt/server/ReceivingEndedEventImpl.java [deleted file]
src/com/vaadin/terminal/gwt/server/ReceivingFailedEventImpl.java [deleted file]
src/com/vaadin/terminal/gwt/server/ReceivingProgressedEventImpl.java [deleted file]
src/com/vaadin/terminal/gwt/server/ReceivingStartedEventImpl.java [deleted file]
src/com/vaadin/terminal/gwt/server/StreamingFailedEventImpl.java [new file with mode: 0644]
src/com/vaadin/terminal/gwt/server/StreamingProgressedEventImpl.java [new file with mode: 0644]
src/com/vaadin/terminal/gwt/server/StreamingStartedEventImpl.java [new file with mode: 0644]
src/com/vaadin/terminal/gwt/server/StremingEndedEventImpl.java [new file with mode: 0644]
src/com/vaadin/ui/DragAndDropWrapper.java
src/com/vaadin/ui/Html5File.java
src/com/vaadin/ui/Upload.java
tests/src/com/vaadin/tests/dd/DDTest6.java
tests/src/com/vaadin/tests/dd/DragAndDropFiles.java
tests/src/com/vaadin/tests/dd/DragDropPane.java

index 2ee69247e7e40b1d3f3551c91adf27e90c81d0a3..76ebd19a7d9fb8153bb7ec85b115885f5d1b8eef 100644 (file)
@@ -152,26 +152,26 @@ public interface PaintTarget extends Serializable {
     public void addAttribute(String name, Resource value) throws PaintException;
 
     /**
-     * Adds details about {@link Receiver} to the UIDL stream. Eg. in web
+     * Adds details about {@link StreamVariable} to the UIDL stream. Eg. in web
      * terminals Receivers are typically rendered for the client side as URLs,
      * where the client side implementation can do an http post request.
      * <p>
-     * Note that a Receiver can only be used once per "paint". The same Receiver
+     * Note that a StreamVariable can only be used once per "paint". The same StreamVariable
      * can be used several times, but it must be repainted before the next
      * stream can be received.
      * 
      * @param owner
      *            the ReceiverOwner that can track the progress of streaming to
-     *            the given Receiver
+     *            the given StreamVariable
      * @param name
-     *            an identifying name for the Receiver
+     *            an identifying name for the StreamVariable
      * @param value
-     *            the Receiver to paint
+     *            the StreamVariable to paint
      * 
      * @throws PaintException
      *             if the paint operation failed.
      */
-    public void addVariable(ReceiverOwner owner, String name, Receiver value)
+    public void addVariable(VariableOwner owner, String name, StreamVariable value)
             throws PaintException;
 
     /**
diff --git a/src/com/vaadin/terminal/Receiver.java b/src/com/vaadin/terminal/Receiver.java
deleted file mode 100644 (file)
index 0841ad0..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.vaadin.terminal;
-
-import java.io.OutputStream;
-import java.io.Serializable;
-
-/**
- * Receiver is a special kind of variable whose value is streamed to a given
- * {@link OutputStream}. E.g. in web terminals Receivers can be used to send
- * large files from browsers to the server.
- * <p>
- * Note, writing to the {@link OutputStream} is not synchronized by the terminal
- * (to avoid stalls in other operations when eg. streaming to a slow network
- * service). If UI is changed as a side effect of writing to the output stream,
- * developer must handle synchronization manually.
- * <p>
- * 
- * @author IT Mill Ltd.
- * @version
- * @VERSION@
- * @since 6.5
- * @see PaintTarget#addVariable(ReceiverOwner, String, Receiver)
- * @see ReceiverOwner
- */
-public interface Receiver extends Serializable {
-
-    /**
-     * Invoked by the terminal when a new upload arrives.
-     * 
-     * @param filename
-     *            the filename of the upload if known by the terminal, usually
-     *            as specified by the client.
-     * @param MIMEType
-     *            the MIME type of the uploaded file.
-     * @return Stream to which the uploaded file should be written.
-     */
-    public OutputStream receiveUpload(String filename, String MIMEType);
-}
diff --git a/src/com/vaadin/terminal/ReceiverOwner.java b/src/com/vaadin/terminal/ReceiverOwner.java
deleted file mode 100644 (file)
index 6f19192..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-package com.vaadin.terminal;
-
-import java.io.Serializable;
-
-import com.vaadin.Application;
-import com.vaadin.terminal.ReceiverOwner.ReceivingController;
-
-/**
- * Special kind of {@link VariableOwner} that can send and receive information
- * with the terminal implementation about the progress of receiving data to its
- * Receiver. The actual communication happens via {@link ReceivingController}
- * which is fetched by the terminal when the Receiving is about to start.
- */
-public interface ReceiverOwner extends VariableOwner {
-
-    /*
-     * The monitor/control is passed to separate ReceivingController because:
-     * 
-     * - possibly some component in the future may need support for streaming to
-     * multiple Receivers at the same time.
-     * 
-     * - we don't want to bloat implementing ReceiverOwner's API. Now only one
-     * method is published and they can decide what event/methods to publish as
-     * their public API.
-     */
-
-    /**
-     * Returns a handle for the terminal via the ReceiverOwner can monitor and
-     * control the steaming of data to {@link Receiver}.
-     * <p>
-     * Most commonly ReceiverOwner implementation wants to implement this method
-     * as final and reveal its own API for the end users.
-     * 
-     * @param receiver
-     *            the Receiver whose streaming is to be controlled
-     * @return a {@link ReceivingController} that will be used to control and
-     *         monitor the progress of streaming
-     */
-    ReceivingController getReceivingController(Receiver receiver);
-
-    interface ReceivingEvent extends Serializable {
-
-        /**
-         * @return the file name of the streamed file if known
-         */
-        String getFileName();
-
-        /**
-         * @return the mime type of the streamed file if known
-         */
-        String getMimeType();
-
-        /**
-         * @return the Receiver into which the content is being streamed
-         */
-        Receiver getReceiver();
-
-        /**
-         * @return the length of the stream (in bytes) if known, else -1
-         */
-        long getContentLength();
-
-        /**
-         * @return then number of bytes streamed to Receiver
-         */
-        long getBytesReceived();
-    }
-
-    /**
-     * Event passed to
-     * {@link ReceivingController#uploadStarted(ReceivingStartedEvent)} method
-     * before the streaming of the content to {@link Receiver} starts.
-     */
-    public interface ReceivingStartedEvent extends ReceivingEvent {
-    }
-
-    /**
-     * Event passed to
-     * {@link ReceivingController#onProgress(ReceivingProgressedEvent)} method
-     * during the streaming progresses.
-     */
-    public interface ReceivingProgressedEvent extends ReceivingEvent {
-    }
-
-    /**
-     * Event passed to
-     * {@link ReceivingController#uploadFinished(ReceivingEndedEvent)} method
-     * the contents have been streamed to Receiver successfully.
-     */
-    public interface ReceivingEndedEvent extends ReceivingEvent {
-    }
-
-    /**
-     * Event passed to
-     * {@link ReceivingController#uploadFailed(ReceivingFailedEvent)} method
-     * when the streaming ended before the end of the input. The streaming may
-     * fail due an interruption by {@link ReceivingController} or due an other
-     * unknown exception in communication. In the latter case the exception is
-     * also passed to
-     * {@link Application#terminalError(com.vaadin.terminal.Terminal.ErrorEvent)}
-     * .
-     */
-    public interface ReceivingFailedEvent extends ReceivingEvent {
-
-        /**
-         * @return the exception that caused the receiving not to finish cleanly
-         */
-        Exception getException();
-
-    }
-
-    public interface ReceivingController extends Serializable {
-        /**
-         * Whether the {@link #onProgress(long, long)} method should be called
-         * during the upload.
-         * <p>
-         * {@link #onProgress(long, long)} is called in a synchronized block
-         * when the content is being received. This is potentially bit slow, so
-         * we are calling that method only if requested. The value is requested
-         * after the {@link #uploadStarted(ReceivingStartedEvent)} event, but
-         * not after reading each buffer.
-         * 
-         * @return true if this ReceiverOwner wants to by notified during the
-         *         upload of the progress of streaming.
-         * @see ReceiverOwner#onProgress(int, int)
-         */
-        boolean listenProgress();
-
-        /**
-         * This method is called by the terminal if {@link #listenProgress()}
-         * returns true when the streaming starts.
-         */
-        void onProgress(ReceivingProgressedEvent event);
-
-        void uploadStarted(ReceivingStartedEvent event);
-
-        void uploadFinished(ReceivingEndedEvent event);
-
-        void uploadFailed(ReceivingFailedEvent event);
-
-        /*
-         * Not synchronized to avoid stalls (caused by UIDL requests) while
-         * streaming the content. Implementations also most commonly atomic even
-         * without the restriction.
-         */
-        /**
-         * ReceiverOwner can set this flag to true if it wants the Terminal to
-         * stop receiving current upload.
-         * <p>
-         * Note, the usage of this method is not synchronized over the
-         * Application instance by the terminal like other methods. The
-         * implementation should only return a boolean field and especially not
-         * modify UI or implement a synchronization by itself.
-         * 
-         * @return true if the streaming should be interrupted as soon as
-         *         possible.
-         */
-        boolean isInterrupted();
-    }
-
-}
diff --git a/src/com/vaadin/terminal/StreamVariable.java b/src/com/vaadin/terminal/StreamVariable.java
new file mode 100644 (file)
index 0000000..aeadaad
--- /dev/null
@@ -0,0 +1,145 @@
+package com.vaadin.terminal;
+
+import java.io.OutputStream;
+import java.io.Serializable;
+
+import com.vaadin.Application;
+
+/**
+ * StreamVariable is a special kind of variable whose value is streamed to an
+ * {@link OutputStream} provided by the {@link #getOutputStream()} method. E.g.
+ * in web terminals {@link StreamVariable} can be used to send large files from
+ * browsers to the server without consuming large amounts of memory.
+ * <p>
+ * Note, writing to the {@link OutputStream} is not synchronized by the terminal
+ * (to avoid stalls in other operations when eg. streaming to a slow network
+ * service or file system). If UI is changed as a side effect of writing to the
+ * output stream, developer must handle synchronization manually.
+ * <p>
+ * 
+ * @author IT Mill Ltd.
+ * @version
+ * @VERSION@
+ * @since 6.5
+ * @see PaintTarget#addVariable(VariableOwner, String, StreamVariable)
+ */
+public interface StreamVariable extends Serializable {
+
+    /**
+     * Invoked by the terminal when a new upload arrives, after
+     * {@link #streamingStarted(StreamingStartedEvent)} method has been called.
+     * The terminal implementation will write the streamed variable to the
+     * returned output stream.
+     * 
+     * @return Stream to which the uploaded file should be written.
+     */
+    public OutputStream getOutputStream();
+
+    /**
+     * Whether the {@link #onProgress(long, long)} method should be called
+     * during the upload.
+     * <p>
+     * {@link #onProgress(long, long)} is called in a synchronized block when
+     * the content is being received. This is potentially bit slow, so we are
+     * calling that method only if requested. The value is requested after the
+     * {@link #uploadStarted(StreamingStartedEvent)} event, but not after
+     * reading each buffer.
+     * 
+     * @return true if this ReceiverOwner wants to by notified during the upload
+     *         of the progress of streaming.
+     * @see ReceiverOwner#onProgress(int, int)
+     */
+    boolean listenProgress();
+
+    /**
+     * This method is called by the terminal if {@link #listenProgress()}
+     * returns true when the streaming starts.
+     */
+    void onProgress(StreamingProgressedEvent event);
+
+    void streamingStarted(StreamingStartedEvent event);
+
+    void streamingFinished(StreamingEndedEvent event);
+
+    void streamingFailed(StreamingFailedEvent event);
+
+    /*
+     * Not synchronized to avoid stalls (caused by UIDL requests) while
+     * streaming the content. Implementations also most commonly atomic even
+     * without the restriction.
+     */
+    /**
+     * ReceiverOwner can set this flag to true if it wants the Terminal to stop
+     * receiving current upload.
+     * <p>
+     * Note, the usage of this method is not synchronized over the Application
+     * instance by the terminal like other methods. The implementation should
+     * only return a boolean field and especially not modify UI or implement a
+     * synchronization by itself.
+     * 
+     * @return true if the streaming should be interrupted as soon as possible.
+     */
+    boolean isInterrupted();
+
+    interface StreamingEvent extends Serializable {
+
+        /**
+         * @return the file name of the streamed file if known
+         */
+        String getFileName();
+
+        /**
+         * @return the mime type of the streamed file if known
+         */
+        String getMimeType();
+
+        /**
+         * @return the length of the stream (in bytes) if known, else -1
+         */
+        long getContentLength();
+
+        /**
+         * @return then number of bytes streamed to StreamVariable
+         */
+        long getBytesReceived();
+    }
+
+    /**
+     * Event passed to {@link #uploadStarted(StreamingStartedEvent)} method
+     * before the streaming of the content to {@link StreamVariable} starts.
+     */
+    public interface StreamingStartedEvent extends StreamingEvent {
+    }
+
+    /**
+     * Event passed to {@link #onProgress(StreamingProgressedEvent)} method
+     * during the streaming progresses.
+     */
+    public interface StreamingProgressedEvent extends StreamingEvent {
+    }
+
+    /**
+     * Event passed to {@link #uploadFinished(StreamingEndedEvent)} method the
+     * contents have been streamed to StreamVariable successfully.
+     */
+    public interface StreamingEndedEvent extends StreamingEvent {
+    }
+
+    /**
+     * Event passed to {@link #uploadFailed(StreamingFailedEvent)} method when
+     * the streaming ended before the end of the input. The streaming may fail
+     * due an interruption by {@link } or due an other unknown exception in
+     * communication. In the latter case the exception is also passed to
+     * {@link Application#terminalError(com.vaadin.terminal.Terminal.ErrorEvent)}
+     * .
+     */
+    public interface StreamingFailedEvent extends StreamingEvent {
+
+        /**
+         * @return the exception that caused the receiving not to finish cleanly
+         */
+        Exception getException();
+
+    }
+
+}
diff --git a/src/com/vaadin/terminal/UploadStream.java b/src/com/vaadin/terminal/UploadStream.java
deleted file mode 100644 (file)
index 95351e0..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/* 
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.terminal;
-
-import java.io.InputStream;
-import java.io.Serializable;
-
-/**
- * Defines a variable type, that is used for passing uploaded files from
- * terminal. Most often, file upload is implented using the
- * {@link com.vaadin.ui.Upload Upload} component.
- * 
- * @author IT Mill Ltd.
- * @version
- * @VERSION@
- * @since 3.0
- */
-public interface UploadStream extends Serializable {
-
-    /**
-     * Gets the name of the stream.
-     * 
-     * @return the name of the stream.
-     */
-    public String getStreamName();
-
-    /**
-     * Gets the input stream.
-     * 
-     * @return the Input stream.
-     */
-    public InputStream getStream();
-
-    /**
-     * Gets the input stream content type.
-     * 
-     * @return the content type of the input stream.
-     */
-    public String getContentType();
-
-    /**
-     * Gets stream content name. Stream content name usually differs from the
-     * actual stream name. It is used to identify the content of the stream.
-     * 
-     * @return the Name of the stream content.
-     */
-    public String getContentName();
-}
index 6102505883b88d56873b1dc8f1491908f204f665..73b83957c27dee2fc3f66805414369f8adb0acba 100644 (file)
@@ -51,12 +51,10 @@ import com.vaadin.terminal.PaintException;
 import com.vaadin.terminal.PaintTarget;
 import com.vaadin.terminal.Paintable;
 import com.vaadin.terminal.Paintable.RepaintRequestEvent;
-import com.vaadin.terminal.Receiver;
-import com.vaadin.terminal.ReceiverOwner;
-import com.vaadin.terminal.ReceiverOwner.ReceivingController;
-import com.vaadin.terminal.ReceiverOwner.ReceivingEndedEvent;
-import com.vaadin.terminal.ReceiverOwner.ReceivingFailedEvent;
-import com.vaadin.terminal.ReceiverOwner.ReceivingStartedEvent;
+import com.vaadin.terminal.StreamVariable;
+import com.vaadin.terminal.StreamVariable.StreamingEndedEvent;
+import com.vaadin.terminal.StreamVariable.StreamingFailedEvent;
+import com.vaadin.terminal.StreamVariable.StreamingStartedEvent;
 import com.vaadin.terminal.Terminal.ErrorEvent;
 import com.vaadin.terminal.Terminal.ErrorListener;
 import com.vaadin.terminal.URIHandler;
@@ -369,18 +367,18 @@ public abstract class AbstractCommunicationManager implements
 
     /**
      * Method used to stream content from a multipart request (either from
-     * servlet or portlet request) to given Receiver
+     * servlet or portlet request) to given StreamVariable
      * 
      * 
      * @param request
      * @param response
-     * @param receiver
+     * @param streamVariable
      * @param owner
      * @param boundary
      * @throws IOException
      */
     protected void doHandleSimpleMultipartFileUpload(Request request,
-            Response response, Receiver receiver, ReceiverOwner owner,
+            Response response, StreamVariable streamVariable, VariableOwner owner,
             String boundary) throws IOException {
         boundary = CRLF + "--" + boundary + "--";
 
@@ -530,7 +528,7 @@ public abstract class AbstractCommunicationManager implements
                 throw new UploadException(
                         "Warning: file upload ignored because the componente was read-only");
             }
-            streamToReceiver(simpleMultiPartReader, receiver, owner, filename,
+            streamToReceiver(simpleMultiPartReader, streamVariable, filename,
                     mimeType, contentLength);
         } catch (Exception e) {
             synchronized (application) {
@@ -547,13 +545,13 @@ public abstract class AbstractCommunicationManager implements
      * 
      * @param request
      * @param response
-     * @param receiver
+     * @param streamVariable
      * @param owner
      * @param contentLength
      * @throws IOException
      */
     protected void doHandleXhrFilePost(Request request, Response response,
-            Receiver receiver, ReceiverOwner owner, int contentLength)
+            StreamVariable streamVariable, VariableOwner owner, int contentLength)
             throws IOException {
 
         // These are unknown in filexhr ATM, maybe add to Accept header that
@@ -569,9 +567,9 @@ public abstract class AbstractCommunicationManager implements
             Component component = (Component) owner;
             if (component.isReadOnly()) {
                 throw new UploadException(
-                        "Warning: file upload ignored because the componente was read-only");
+                        "Warning: file upload ignored because the component was read-only");
             }
-            streamToReceiver(stream, receiver, owner, filename, mimeType,
+            streamToReceiver(stream, streamVariable, filename, mimeType,
                     contentLength);
         } catch (Exception e) {
             synchronized (application) {
@@ -583,15 +581,12 @@ public abstract class AbstractCommunicationManager implements
     }
 
     protected final void streamToReceiver(final InputStream in,
-            Receiver receiver, ReceiverOwner source, String filename,
+            StreamVariable streamVariable, String filename,
             String type, int contentLength) throws UploadException {
-        if (receiver == null) {
-            throw new IllegalStateException("Receiver for the post not found");
+        if (streamVariable == null) {
+            throw new IllegalStateException("StreamVariable for the post not found");
         }
 
-        ReceivingController controller = source
-                .getReceivingController(receiver);
-
         final Application application = getApplication();
 
         OutputStream out = null;
@@ -599,11 +594,11 @@ public abstract class AbstractCommunicationManager implements
         try {
             boolean listenProgress;
             synchronized (application) {
-                ReceivingStartedEvent startedEvent = new ReceivingStartedEventImpl(
-                        receiver, filename, type, contentLength);
-                controller.uploadStarted(startedEvent);
-                out = receiver.receiveUpload(filename, type);
-                listenProgress = controller.listenProgress();
+                StreamingStartedEvent startedEvent = new StreamingStartedEventImpl(
+                        streamVariable, filename, type, contentLength);
+                streamVariable.streamingStarted(startedEvent);
+                out = streamVariable.getOutputStream();
+                listenProgress = streamVariable.listenProgress();
             }
 
             // Gets the output target stream
@@ -625,42 +620,42 @@ public abstract class AbstractCommunicationManager implements
                     // update progress if listener set and contentLength
                     // received
                     synchronized (application) {
-                        ReceivingProgressedEventImpl progressEvent = new ReceivingProgressedEventImpl(
-                                receiver, filename, type, contentLength,
+                        StreamingProgressedEventImpl progressEvent = new StreamingProgressedEventImpl(
+                                streamVariable, filename, type, contentLength,
                                 totalBytes);
-                        controller.onProgress(progressEvent);
+                        streamVariable.onProgress(progressEvent);
                     }
                 }
-                if (controller.isInterrupted()) {
+                if (streamVariable.isInterrupted()) {
                     throw new UploadInterruptedException();
                 }
             }
 
             // upload successful
             out.close();
-            ReceivingEndedEvent event = new ReceivingEndedEventImpl(receiver,
+            StreamingEndedEvent event = new StremingEndedEventImpl(streamVariable,
                     filename, type, totalBytes);
             synchronized (application) {
-                controller.uploadFinished(event);
+                streamVariable.streamingFinished(event);
             }
 
         } catch (UploadInterruptedException e) {
             // Download interrupted by application code
             tryToCloseStream(out);
-            ReceivingFailedEvent event = new ReceivingFailedEventImpl(receiver,
+            StreamingFailedEvent event = new StreamingFailedEventImpl(streamVariable,
                     filename, type, contentLength, totalBytes, e);
             synchronized (application) {
-                controller.uploadFailed(event);
+                streamVariable.streamingFailed(event);
             }
             // Note, we are not throwing interrupted exception forward as it is
             // not a terminal level error like all other exception.
         } catch (final Exception e) {
             tryToCloseStream(out);
             synchronized (application) {
-                ReceivingFailedEvent event = new ReceivingFailedEventImpl(
-                        receiver, filename, type, contentLength, totalBytes, e);
+                StreamingFailedEvent event = new StreamingFailedEventImpl(
+                        streamVariable, filename, type, contentLength, totalBytes, e);
                 synchronized (application) {
-                    controller.uploadFailed(event);
+                    streamVariable.streamingFailed(event);
                 }
                 // throw exception for terminal to be handled (to be passed to
                 // terminalErrorHandler)
@@ -2186,6 +2181,6 @@ public abstract class AbstractCommunicationManager implements
 
     }
 
-    abstract String createReceiverUrl(ReceiverOwner owner, String name,
-            Receiver value);
+    abstract String createReceiverUrl(VariableOwner owner, String name,
+            StreamVariable value);
 }
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractReceivingEvent.java b/src/com/vaadin/terminal/gwt/server/AbstractReceivingEvent.java
deleted file mode 100644 (file)
index a3ada4e..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.vaadin.terminal.gwt.server;
-
-import com.vaadin.terminal.Receiver;
-import com.vaadin.terminal.ReceiverOwner.ReceivingEvent;
-
-/**
- * Abstract base class for ReceivingEvent implementations.
- */
-@SuppressWarnings("serial")
-abstract class AbstractReceivingEvent implements ReceivingEvent {
-    private final String type;
-    private final String filename;
-    private final Receiver receiver;
-    private final long contentLength;
-    private final long bytesReceived;
-
-    public final String getFileName() {
-        return filename;
-    }
-
-    public final String getMimeType() {
-        return type;
-    }
-
-    protected AbstractReceivingEvent(Receiver receiver, String filename,
-            String type, long length, long bytesReceived) {
-        this.receiver = receiver;
-        this.filename = filename;
-        this.type = type;
-        contentLength = length;
-        this.bytesReceived = bytesReceived;
-    }
-
-    public final Receiver getReceiver() {
-        return receiver;
-    }
-
-    public final long getContentLength() {
-        return contentLength;
-    }
-
-    public final long getBytesReceived() {
-        return bytesReceived;
-    }
-
-}
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractStreamingEvent.java b/src/com/vaadin/terminal/gwt/server/AbstractStreamingEvent.java
new file mode 100644 (file)
index 0000000..91039d0
--- /dev/null
@@ -0,0 +1,46 @@
+package com.vaadin.terminal.gwt.server;
+
+import com.vaadin.terminal.StreamVariable;
+import com.vaadin.terminal.StreamVariable.StreamingEvent;
+
+/**
+ * Abstract base class for StreamingEvent implementations.
+ */
+@SuppressWarnings("serial")
+abstract class AbstractStreamingEvent implements StreamingEvent {
+    private final String type;
+    private final String filename;
+    private final StreamVariable streamVariable;
+    private final long contentLength;
+    private final long bytesReceived;
+
+    public final String getFileName() {
+        return filename;
+    }
+
+    public final String getMimeType() {
+        return type;
+    }
+
+    protected AbstractStreamingEvent(StreamVariable streamVariable, String filename,
+            String type, long length, long bytesReceived) {
+        this.streamVariable = streamVariable;
+        this.filename = filename;
+        this.type = type;
+        contentLength = length;
+        this.bytesReceived = bytesReceived;
+    }
+
+    public final StreamVariable getReceiver() {
+        return streamVariable;
+    }
+
+    public final long getContentLength() {
+        return contentLength;
+    }
+
+    public final long getBytesReceived() {
+        return bytesReceived;
+    }
+
+}
index df937688cb4bdd8f0e99ef458f724bc5bbc7e38d..73f6732cf0555ad83a1fff01ce7f6c2ca32bc53a 100644 (file)
@@ -20,8 +20,8 @@ import com.vaadin.Application;
 import com.vaadin.terminal.ApplicationResource;
 import com.vaadin.terminal.DownloadStream;
 import com.vaadin.terminal.Paintable;
-import com.vaadin.terminal.Receiver;
-import com.vaadin.terminal.ReceiverOwner;
+import com.vaadin.terminal.StreamVariable;
+import com.vaadin.terminal.VariableOwner;
 import com.vaadin.ui.Component;
 import com.vaadin.ui.Window;
 
@@ -208,7 +208,7 @@ public class CommunicationManager extends AbstractCommunicationManager {
     /**
      * Handles file upload request submitted via Upload component.
      * 
-     * @see #createReceiverUrl(ReceiverOwner, String, Receiver)
+     * @see #createReceiverUrl(ReceiverOwner, String, StreamVariable)
      * 
      * @param request
      * @param response
@@ -231,23 +231,23 @@ public class CommunicationManager extends AbstractCommunicationManager {
         String uppUri = pathInfo.substring(startOfData);
         String[] parts = uppUri.split("/", 3); // 0 = pid, 1= name, 2 = sec key
 
-        Receiver receiver = pidToNameToReceiver.get(parts[0]).remove(parts[1]);
-        String secKey = receiverToSeckey.remove(receiver);
+        StreamVariable streamVariable = pidToNameToReceiver.get(parts[0]).remove(parts[1]);
+        String secKey = receiverToSeckey.remove(streamVariable);
         if (secKey.equals(parts[2])) {
 
-            ReceiverOwner source = (ReceiverOwner) getVariableOwner(parts[0]);
+            VariableOwner source = (VariableOwner) getVariableOwner(parts[0]);
             String contentType = request.getContentType();
             if (request.getContentType().contains("boundary")) {
                 // Multipart requests contain boundary string
                 doHandleSimpleMultipartFileUpload(
                         new HttpServletRequestWrapper(request),
-                        new HttpServletResponseWrapper(response), receiver,
+                        new HttpServletResponseWrapper(response), streamVariable,
                         source, contentType.split("boundary=")[1]);
             } else {
                 // if boundary string does not exist, the posted file is from
                 // XHR2.post(File)
                 doHandleXhrFilePost(new HttpServletRequestWrapper(request),
-                        new HttpServletResponseWrapper(response), receiver,
+                        new HttpServletResponseWrapper(response), streamVariable,
                         source, request.getContentLength());
             }
         } else {
@@ -336,8 +336,8 @@ public class CommunicationManager extends AbstractCommunicationManager {
     @Override
     protected void unregisterPaintable(Component p) {
         /* Cleanup possible receivers */
-        if (pidToNameToReceiver != null && p instanceof ReceiverOwner) {
-            Map<String, Receiver> removed = pidToNameToReceiver
+        if (pidToNameToReceiver != null) {
+            Map<String, StreamVariable> removed = pidToNameToReceiver
                     .remove(getPaintableId(p));
             if (removed != null) {
                 for (String key : removed.keySet()) {
@@ -349,12 +349,16 @@ public class CommunicationManager extends AbstractCommunicationManager {
 
     }
 
-    private Map<String, Map<String, Receiver>> pidToNameToReceiver;
+    private Map<String, Map<String, StreamVariable>> pidToNameToReceiver;
 
-    private Map<Receiver, String> receiverToSeckey;
+    private Map<StreamVariable, String> receiverToSeckey;
 
     @Override
-    String createReceiverUrl(ReceiverOwner owner, String name, Receiver value) {
+    String createReceiverUrl(VariableOwner owner, String name, StreamVariable value) {
+        
+        /*
+         * TODO figure out how this can be simplified now that ReceiverOwner is removed.
+         */
 
         /*
          * We will use the same APP/* URI space as ApplicationResources but
@@ -365,25 +369,25 @@ public class CommunicationManager extends AbstractCommunicationManager {
          * SECKEY is created on each paint to make URL's unpredictable (to
          * prevent CSRF attacks).
          * 
-         * NAME and PID from URI forms a key to fetch Receiver when handling
+         * NAME and PID from URI forms a key to fetch StreamVariable when handling
          * post
          */
         String paintableId = getPaintableId((Paintable) owner);
         String key = paintableId + "/" + name;
 
         if (pidToNameToReceiver == null) {
-            pidToNameToReceiver = new HashMap<String, Map<String, Receiver>>();
+            pidToNameToReceiver = new HashMap<String, Map<String, StreamVariable>>();
         }
-        Map<String, Receiver> nameToReceiver = pidToNameToReceiver
+        Map<String, StreamVariable> nameToReceiver = pidToNameToReceiver
                 .get(paintableId);
         if (nameToReceiver == null) {
-            nameToReceiver = new HashMap<String, Receiver>();
+            nameToReceiver = new HashMap<String, StreamVariable>();
             pidToNameToReceiver.put(paintableId, nameToReceiver);
         }
         nameToReceiver.put(name, value);
 
         if (receiverToSeckey == null) {
-            receiverToSeckey = new HashMap<Receiver, String>();
+            receiverToSeckey = new HashMap<StreamVariable, String>();
         }
         String seckey = UUID.randomUUID().toString();
         receiverToSeckey.put(value, seckey);
diff --git a/src/com/vaadin/terminal/gwt/server/HttpUploadStream.java b/src/com/vaadin/terminal/gwt/server/HttpUploadStream.java
deleted file mode 100644 (file)
index 40b5d41..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/* 
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.terminal.gwt.server;
-
-import java.io.InputStream;
-
-/**
- * AjaxAdapter implementation of the UploadStream interface.
- * 
- * @author IT Mill Ltd.
- * @version
- * @VERSION@
- * @since 5.0
- */
-@SuppressWarnings("serial")
-public class HttpUploadStream implements com.vaadin.terminal.UploadStream {
-
-    /**
-     * Holds value of property variableName.
-     */
-    private final String streamName;
-
-    private final String contentName;
-
-    private final String contentType;
-
-    /**
-     * Holds value of property variableValue.
-     */
-    private final InputStream stream;
-
-    /**
-     * Creates a new instance of UploadStreamImpl.
-     * 
-     * @param name
-     *            the name of the stream.
-     * @param stream
-     *            the input stream.
-     * @param contentName
-     *            the name of the content.
-     * @param contentType
-     *            the type of the content.
-     */
-    public HttpUploadStream(String name, InputStream stream,
-            String contentName, String contentType) {
-        streamName = name;
-        this.stream = stream;
-        this.contentName = contentName;
-        this.contentType = contentType;
-    }
-
-    /**
-     * Gets the name of the stream.
-     * 
-     * @return the name of the stream.
-     */
-    public String getStreamName() {
-        return streamName;
-    }
-
-    /**
-     * Gets the input stream.
-     * 
-     * @return the Input stream.
-     */
-    public InputStream getStream() {
-        return stream;
-    }
-
-    /**
-     * Gets the input stream content type.
-     * 
-     * @return the content type of the input stream.
-     */
-    public String getContentType() {
-        return contentType;
-    }
-
-    /**
-     * Gets the stream content name. Stream content name usually differs from
-     * the actual stream name. It is used to identify the content of the stream.
-     * 
-     * @return the Name of the stream content.
-     */
-    public String getContentName() {
-        return contentName;
-    }
-}
index 27b9ea4ae989ad25bb14ab7db54a019efb8150ae..2ea372264de26a760798b48036e9abc4e6121294 100644 (file)
@@ -29,8 +29,7 @@ import com.vaadin.terminal.ExternalResource;
 import com.vaadin.terminal.PaintException;
 import com.vaadin.terminal.PaintTarget;
 import com.vaadin.terminal.Paintable;
-import com.vaadin.terminal.Receiver;
-import com.vaadin.terminal.ReceiverOwner;
+import com.vaadin.terminal.StreamVariable;
 import com.vaadin.terminal.Resource;
 import com.vaadin.terminal.ThemeResource;
 import com.vaadin.terminal.VariableOwner;
@@ -1112,7 +1111,7 @@ public class JsonPaintTarget implements PaintTarget {
         return usedPaintableTypes;
     }
 
-    public void addVariable(ReceiverOwner owner, String name, Receiver value)
+    public void addVariable(VariableOwner owner, String name, StreamVariable value)
             throws PaintException {
         String url = manager.createReceiverUrl(owner, name, value);
         addVariable(owner, name, url);
index 37beafa17228c017c3428468d32561672d06d4d1..cf2cab0edf1f99047da200f65ad460c02c23165b 100644 (file)
@@ -24,8 +24,8 @@ import javax.servlet.http.HttpServletRequestWrapper;
 import com.vaadin.Application;
 import com.vaadin.terminal.DownloadStream;
 import com.vaadin.terminal.Paintable;
-import com.vaadin.terminal.Receiver;
-import com.vaadin.terminal.ReceiverOwner;
+import com.vaadin.terminal.StreamVariable;
+import com.vaadin.terminal.VariableOwner;
 import com.vaadin.ui.Component;
 import com.vaadin.ui.Window;
 
@@ -197,8 +197,8 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
         String contentType = request.getContentType();
         String name = request.getParameter("name");
         String ownerId = request.getParameter("rec-owner");
-        ReceiverOwner variableOwner = (ReceiverOwner) getVariableOwner(ownerId);
-        Receiver receiver = ownerToNameToReceiver.get(variableOwner).remove(
+        VariableOwner variableOwner = (VariableOwner) getVariableOwner(ownerId);
+        StreamVariable streamVariable = ownerToNameToReceiver.get(variableOwner).remove(
                 name);
 
         // clean up, may be re added on next paint
@@ -207,11 +207,11 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
         if (contentType.contains("boundary")) {
             doHandleSimpleMultipartFileUpload(
                     new PortletRequestWrapper(request),
-                    new PortletResponseWrapper(response), receiver,
+                    new PortletResponseWrapper(response), streamVariable,
                     variableOwner, contentType.split("boundary=")[1]);
         } else {
             doHandleXhrFilePost(new PortletRequestWrapper(request),
-                    new PortletResponseWrapper(response), receiver,
+                    new PortletResponseWrapper(response), streamVariable,
                     variableOwner, request.getContentLength());
         }
 
@@ -271,16 +271,16 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
                 application, assumedWindow);
     }
 
-    private Map<ReceiverOwner, Map<String, Receiver>> ownerToNameToReceiver;
+    private Map<VariableOwner, Map<String, StreamVariable>> ownerToNameToReceiver;
 
     @Override
-    String createReceiverUrl(ReceiverOwner owner, String name, Receiver value) {
+    String createReceiverUrl(VariableOwner owner, String name, StreamVariable value) {
         if (ownerToNameToReceiver == null) {
-            ownerToNameToReceiver = new HashMap<ReceiverOwner, Map<String, Receiver>>();
+            ownerToNameToReceiver = new HashMap<VariableOwner, Map<String, StreamVariable>>();
         }
-        Map<String, Receiver> nameToReceiver = ownerToNameToReceiver.get(owner);
+        Map<String, StreamVariable> nameToReceiver = ownerToNameToReceiver.get(owner);
         if (nameToReceiver == null) {
-            nameToReceiver = new HashMap<String, Receiver>();
+            nameToReceiver = new HashMap<String, StreamVariable>();
             ownerToNameToReceiver.put(owner, nameToReceiver);
         }
         nameToReceiver.put(name, value);
diff --git a/src/com/vaadin/terminal/gwt/server/ReceivingEndedEventImpl.java b/src/com/vaadin/terminal/gwt/server/ReceivingEndedEventImpl.java
deleted file mode 100644 (file)
index 06609f0..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.vaadin.terminal.gwt.server;
-
-import com.vaadin.terminal.Receiver;
-import com.vaadin.terminal.ReceiverOwner.ReceivingEndedEvent;
-
-@SuppressWarnings("serial")
-final class ReceivingEndedEventImpl extends AbstractReceivingEvent implements
-        ReceivingEndedEvent {
-
-    public ReceivingEndedEventImpl(Receiver receiver, String filename,
-            String type, long totalBytes) {
-        super(receiver, filename, type, totalBytes, totalBytes);
-    }
-
-}
diff --git a/src/com/vaadin/terminal/gwt/server/ReceivingFailedEventImpl.java b/src/com/vaadin/terminal/gwt/server/ReceivingFailedEventImpl.java
deleted file mode 100644 (file)
index c732e69..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.vaadin.terminal.gwt.server;
-
-import com.vaadin.terminal.Receiver;
-import com.vaadin.terminal.ReceiverOwner.ReceivingFailedEvent;
-
-@SuppressWarnings("serial")
-final class ReceivingFailedEventImpl extends AbstractReceivingEvent implements
-        ReceivingFailedEvent {
-
-    private final Exception exception;
-
-    public ReceivingFailedEventImpl(Receiver receiver, final String filename,
-            final String type, long contentLength, long bytesReceived,
-            final Exception exception) {
-        super(receiver, filename, type, contentLength, bytesReceived);
-        this.exception = exception;
-    }
-
-    public final Exception getException() {
-        return exception;
-    }
-
-}
diff --git a/src/com/vaadin/terminal/gwt/server/ReceivingProgressedEventImpl.java b/src/com/vaadin/terminal/gwt/server/ReceivingProgressedEventImpl.java
deleted file mode 100644 (file)
index f28f0ad..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.vaadin.terminal.gwt.server;
-
-import com.vaadin.terminal.Receiver;
-import com.vaadin.terminal.ReceiverOwner.ReceivingProgressedEvent;
-
-@SuppressWarnings("serial")
-final class ReceivingProgressedEventImpl extends AbstractReceivingEvent
-        implements ReceivingProgressedEvent {
-
-    public ReceivingProgressedEventImpl(Receiver receiver,
-            final String filename, final String type, long contentLength,
-            long bytesReceived) {
-        super(receiver, filename, type, contentLength, bytesReceived);
-    }
-
-}
diff --git a/src/com/vaadin/terminal/gwt/server/ReceivingStartedEventImpl.java b/src/com/vaadin/terminal/gwt/server/ReceivingStartedEventImpl.java
deleted file mode 100644 (file)
index beb2ac8..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.vaadin.terminal.gwt.server;
-
-import com.vaadin.terminal.Receiver;
-import com.vaadin.terminal.ReceiverOwner.ReceivingStartedEvent;
-
-@SuppressWarnings("serial")
-final class ReceivingStartedEventImpl extends AbstractReceivingEvent implements
-        ReceivingStartedEvent {
-
-    public ReceivingStartedEventImpl(Receiver receiver, final String filename,
-            final String type, long contentLength) {
-        super(receiver, filename, type, contentLength, 0);
-    }
-
-}
diff --git a/src/com/vaadin/terminal/gwt/server/StreamingFailedEventImpl.java b/src/com/vaadin/terminal/gwt/server/StreamingFailedEventImpl.java
new file mode 100644 (file)
index 0000000..23fb3b0
--- /dev/null
@@ -0,0 +1,23 @@
+package com.vaadin.terminal.gwt.server;
+
+import com.vaadin.terminal.StreamVariable;
+import com.vaadin.terminal.StreamVariable.StreamingFailedEvent;
+
+@SuppressWarnings("serial")
+final class StreamingFailedEventImpl extends AbstractStreamingEvent implements
+        StreamingFailedEvent {
+
+    private final Exception exception;
+
+    public StreamingFailedEventImpl(StreamVariable streamVariable, final String filename,
+            final String type, long contentLength, long bytesReceived,
+            final Exception exception) {
+        super(streamVariable, filename, type, contentLength, bytesReceived);
+        this.exception = exception;
+    }
+
+    public final Exception getException() {
+        return exception;
+    }
+
+}
diff --git a/src/com/vaadin/terminal/gwt/server/StreamingProgressedEventImpl.java b/src/com/vaadin/terminal/gwt/server/StreamingProgressedEventImpl.java
new file mode 100644 (file)
index 0000000..6ca751d
--- /dev/null
@@ -0,0 +1,16 @@
+package com.vaadin.terminal.gwt.server;
+
+import com.vaadin.terminal.StreamVariable;
+import com.vaadin.terminal.StreamVariable.StreamingProgressedEvent;
+
+@SuppressWarnings("serial")
+final class StreamingProgressedEventImpl extends AbstractStreamingEvent
+        implements StreamingProgressedEvent {
+
+    public StreamingProgressedEventImpl(StreamVariable streamVariable,
+            final String filename, final String type, long contentLength,
+            long bytesReceived) {
+        super(streamVariable, filename, type, contentLength, bytesReceived);
+    }
+
+}
diff --git a/src/com/vaadin/terminal/gwt/server/StreamingStartedEventImpl.java b/src/com/vaadin/terminal/gwt/server/StreamingStartedEventImpl.java
new file mode 100644 (file)
index 0000000..f0b3747
--- /dev/null
@@ -0,0 +1,15 @@
+package com.vaadin.terminal.gwt.server;
+
+import com.vaadin.terminal.StreamVariable;
+import com.vaadin.terminal.StreamVariable.StreamingStartedEvent;
+
+@SuppressWarnings("serial")
+final class StreamingStartedEventImpl extends AbstractStreamingEvent implements
+        StreamingStartedEvent {
+
+    public StreamingStartedEventImpl(StreamVariable streamVariable, final String filename,
+            final String type, long contentLength) {
+        super(streamVariable, filename, type, contentLength, 0);
+    }
+
+}
diff --git a/src/com/vaadin/terminal/gwt/server/StremingEndedEventImpl.java b/src/com/vaadin/terminal/gwt/server/StremingEndedEventImpl.java
new file mode 100644 (file)
index 0000000..9117ce9
--- /dev/null
@@ -0,0 +1,15 @@
+package com.vaadin.terminal.gwt.server;
+
+import com.vaadin.terminal.StreamVariable;
+import com.vaadin.terminal.StreamVariable.StreamingEndedEvent;
+
+@SuppressWarnings("serial")
+final class StremingEndedEventImpl extends AbstractStreamingEvent implements
+        StreamingEndedEvent {
+
+    public StremingEndedEventImpl(StreamVariable streamVariable, String filename,
+            String type, long totalBytes) {
+        super(streamVariable, filename, type, totalBytes, totalBytes);
+    }
+
+}
index d2a769c591d6e7353a4a7da9688ea2a17bb816c5..d79402217c92dd35ba23cf6fbf1fe48a105ac77f 100644 (file)
@@ -3,8 +3,11 @@
  */
 package com.vaadin.ui;
 
+import java.io.OutputStream;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import com.vaadin.event.Transferable;
 import com.vaadin.event.TransferableImpl;
@@ -15,18 +18,16 @@ import com.vaadin.event.dd.TargetDetails;
 import com.vaadin.event.dd.TargetDetailsImpl;
 import com.vaadin.terminal.PaintException;
 import com.vaadin.terminal.PaintTarget;
-import com.vaadin.terminal.Receiver;
-import com.vaadin.terminal.ReceiverOwner;
+import com.vaadin.terminal.StreamVariable;
 import com.vaadin.terminal.gwt.client.MouseEventDetails;
 import com.vaadin.terminal.gwt.client.ui.VDragAndDropWrapper;
 import com.vaadin.terminal.gwt.client.ui.dd.HorizontalDropLocation;
 import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation;
-import com.vaadin.ui.Html5File.ProxyReceiver;
 
 @SuppressWarnings("serial")
 @ClientWidget(VDragAndDropWrapper.class)
 public class DragAndDropWrapper extends CustomComponent implements DropTarget,
-        DragSource, ReceiverOwner {
+        DragSource {
 
     public class WrapperTransferable extends TransferableImpl {
 
@@ -185,22 +186,26 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget,
             getDropHandler().getAcceptCriterion().paint(target);
         }
         if (receivers != null && receivers.size() > 0) {
-            for (String id : receivers.keySet()) {
+            for (Iterator<Entry<String, Html5File>> it = receivers.entrySet()
+                    .iterator(); it.hasNext();) {
+                String id = it.next().getKey();
                 Html5File html5File = receivers.get(id);
                 if (html5File.getReceiver() != null) {
-                    target.addVariable(this, "rec-" + id,
-                            html5File.getProxyReceiver());
+                    target.addVariable(this, "rec-" + id, new ProxyReceiver(
+                            html5File));
+                    // these are cleaned from receivers once the upload has
+                    // started
                 } else {
                     // instructs the client side not to send the file
                     target.addVariable(this, "rec-" + id, (String) null);
+                    // forget the file from subsequent paints
+                    it.remove();
                 }
             }
         }
     }
 
     private DropHandler dropHandler;
-    private Html5File currentlyUploadedFile;
-    private boolean listenProgressOfUploadedFile;
 
     public DropHandler getDropHandler() {
         return dropHandler;
@@ -229,98 +234,103 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget,
         return dragStartMode;
     }
 
-    /*
-     * Single controller is enough for atm as files are transferred in serial.
-     * If parallel transfer is needed, this logic needs to go to Html5File
-     */
-    private ReceivingController controller = new ReceivingController() {
-        /*
-         * With XHR2 file posts we can't provide as much information from the
-         * terminal as with multipart request. This helper class wraps the
-         * terminal event and provides the lacking information from the
-         * Html5File.
-         */
-        class ReceivingEventWrapper implements ReceivingFailedEvent,
-                ReceivingEndedEvent, ReceivingStartedEvent,
-                ReceivingProgressedEvent {
-            private ReceivingEvent wrappedEvent;
+    final class ProxyReceiver implements StreamVariable {
 
-            ReceivingEventWrapper(ReceivingEvent e) {
-                wrappedEvent = e;
-            }
-
-            public String getMimeType() {
-                return currentlyUploadedFile.getType();
-            }
-
-            public String getFileName() {
-                return currentlyUploadedFile.getFileName();
-            }
+        private Html5File file;
 
-            public long getContentLength() {
-                return currentlyUploadedFile.getFileSize();
-            }
+        public ProxyReceiver(Html5File file) {
+            this.file = file;
+        }
 
-            public Receiver getReceiver() {
-                return currentlyUploadedFile.getReceiver();
-            }
+        private boolean listenProgressOfUploadedFile;
 
-            public Exception getException() {
-                if (wrappedEvent instanceof ReceivingFailedEvent) {
-                    return ((ReceivingFailedEvent) wrappedEvent).getException();
-                }
+        public OutputStream getOutputStream() {
+            if (file.getReceiver() == null) {
                 return null;
             }
-
-            public long getBytesReceived() {
-                return wrappedEvent.getBytesReceived();
-            }
+            return file.getReceiver().getOutputStream();
         }
 
         public boolean listenProgress() {
-            return listenProgressOfUploadedFile;
+            return file.getReceiver().listenProgress();
         }
 
-        public void onProgress(ReceivingProgressedEvent event) {
-            currentlyUploadedFile.getUploadListener().onProgress(
-                    new ReceivingEventWrapper(event));
+        public void onProgress(StreamingProgressedEvent event) {
+            file.getReceiver().onProgress(new ReceivingEventWrapper(event));
         }
 
-        public void uploadStarted(ReceivingStartedEvent event) {
-            currentlyUploadedFile = ((ProxyReceiver) event.getReceiver())
-                    .getFile();
-            listenProgressOfUploadedFile = currentlyUploadedFile
-                    .getUploadListener() != null;
+        public void streamingStarted(StreamingStartedEvent event) {
+            listenProgressOfUploadedFile = file.getReceiver() != null;
             if (listenProgressOfUploadedFile) {
-                currentlyUploadedFile.getUploadListener().uploadStarted(
+                file.getReceiver().streamingStarted(
                         new ReceivingEventWrapper(event));
             }
+            // no need tell to the client about this receiver on next paint
+            receivers.remove(file);
         }
 
-        public void uploadFinished(ReceivingEndedEvent event) {
+        public void streamingFinished(StreamingEndedEvent event) {
             if (listenProgressOfUploadedFile) {
-                currentlyUploadedFile.getUploadListener().uploadFinished(
+                file.getReceiver().streamingFinished(
                         new ReceivingEventWrapper(event));
             }
-            receivers.remove(event.getReceiver());
         }
 
-        public void uploadFailed(final ReceivingFailedEvent event) {
+        public void streamingFailed(final StreamingFailedEvent event) {
             if (listenProgressOfUploadedFile) {
-                currentlyUploadedFile.getUploadListener().uploadFailed(
+                file.getReceiver().streamingFailed(
                         new ReceivingEventWrapper(event));
             }
-            receivers.remove(event.getReceiver());
         }
 
         public boolean isInterrupted() {
-            return currentlyUploadedFile.isInterrupted();
+            return file.getReceiver().isInterrupted();
         }
 
-    };
+        /*
+         * With XHR2 file posts we can't provide as much information from the
+         * terminal as with multipart request. This helper class wraps the
+         * terminal event and provides the lacking information from the
+         * Html5File.
+         */
+        class ReceivingEventWrapper implements StreamingFailedEvent,
+                StreamingEndedEvent, StreamingStartedEvent,
+                StreamingProgressedEvent {
+
+            private StreamingEvent wrappedEvent;
+
+            ReceivingEventWrapper(StreamingEvent e) {
+                wrappedEvent = e;
+            }
+
+            public String getMimeType() {
+                return file.getType();
+            }
+
+            public String getFileName() {
+                return file.getFileName();
+            }
+
+            public long getContentLength() {
+                return file.getFileSize();
+            }
+
+            public StreamVariable getReceiver() {
+                return ProxyReceiver.this;
+            }
+
+            public Exception getException() {
+                if (wrappedEvent instanceof StreamingFailedEvent) {
+                    return ((StreamingFailedEvent) wrappedEvent).getException();
+                }
+                return null;
+            }
+
+            public long getBytesReceived() {
+                return wrappedEvent.getBytesReceived();
+            }
+        }
 
-    public ReceivingController getReceivingController(Receiver receiver) {
-        return controller;
     }
 
 }
index 6c3a91f3b0088e5ed3615dfc5cc92c8509210749..7c01f9b0a41137b7d37ed120c7732a2b4a094527 100644 (file)
@@ -1,14 +1,9 @@
 package com.vaadin.ui;
 
-import java.io.OutputStream;
 import java.io.Serializable;
 
 import com.vaadin.event.dd.DropHandler;
-import com.vaadin.terminal.Receiver;
-import com.vaadin.terminal.ReceiverOwner.ReceivingEndedEvent;
-import com.vaadin.terminal.ReceiverOwner.ReceivingFailedEvent;
-import com.vaadin.terminal.ReceiverOwner.ReceivingProgressedEvent;
-import com.vaadin.terminal.ReceiverOwner.ReceivingStartedEvent;
+import com.vaadin.terminal.StreamVariable;
 
 /**
  * {@link DragAndDropWrapper} can receive also files from client computer if
@@ -16,23 +11,10 @@ import com.vaadin.terminal.ReceiverOwner.ReceivingStartedEvent;
  * information about dragged file on server side.
  */
 public class Html5File implements Serializable {
-
-    final class ProxyReceiver implements Receiver {
-        public OutputStream receiveUpload(String filename, String MIMEType) {
-            if (receiver == null) {
-                return null;
-            }
-            return receiver.receiveUpload(filename, MIMEType);
-        }
-
-        Html5File getFile() {
-            return Html5File.this;
-        }
-    }
-
+    
     private String name;
     private long size;
-    private Receiver receiver;
+    private StreamVariable streamVariable;
     private String type;
 
     Html5File(String name, long size, String mimeType) {
@@ -41,14 +23,6 @@ public class Html5File implements Serializable {
         type = mimeType;
     }
 
-    /**
-     * The receiver that is registered to the terminal. Wraps the actual
-     * Receiver set later by Html5File user.
-     */
-    private ProxyReceiver proxyReceiver = new ProxyReceiver();
-    private boolean interrupted = false;
-    private Html5FileUploadListener listener;
-
     public String getFileName() {
         return name;
     }
@@ -62,10 +36,10 @@ public class Html5File implements Serializable {
     }
 
     /**
-     * Sets the {@link Receiver} that into which the file contents will be
-     * written. Usage of Receiver is similar to {@link Upload} component.
+     * Sets the {@link StreamVariable} that into which the file contents will be
+     * written. Usage of StreamVariable is similar to {@link Upload} component.
      * <p>
-     * If the {@link Receiver} is not set in the {@link DropHandler} the file
+     * If the {@link StreamVariable} is not set in the {@link DropHandler} the file
      * contents will not be sent to server.
      * <p>
      * <em>Note!</em> receiving file contents is experimental feature depending
@@ -73,65 +47,17 @@ public class Html5File implements Serializable {
      * 3.6 and above and recent webkit based browsers (Safari 5, Chrome 6) at
      * this time.
      * 
-     * @param receiver
+     * @param streamVariable
      *            the callback that returns stream where the implementation
      *            writes the file contents as it arrives.
      */
-    public void setReceiver(Receiver receiver) {
-        this.receiver = receiver;
-    }
-
-    public Receiver getReceiver() {
-        return receiver;
-    }
-
-    ProxyReceiver getProxyReceiver() {
-        return proxyReceiver;
-    }
-
-    /**
-     * Gets the {@link Html5FileUploadListener} that is used to track the
-     * progress of streaming the file contents to given {@link Receiver}.
-     * 
-     * @return
-     */
-    public Html5FileUploadListener getUploadListener() {
-        return listener;
+    public void setReceiver(StreamVariable streamVariable) {
+        this.streamVariable = streamVariable;
     }
 
-    /**
-     * Sets the {@link Html5FileUploadListener} that can be used to track the
-     * progress of streaming the file contents to given {@link Receiver}.
-     * 
-     * @param listener
-     * @see #setReceiver(Receiver)
-     */
-    public void setUploadListener(Html5FileUploadListener listener) {
-        this.listener = listener;
-    }
-
-    public boolean isInterrupted() {
-        return interrupted;
-    }
-
-    /**
-     * Interrupts uploading this file.
-     * 
-     * @param interrupted
-     */
-    public void setInterrupted(boolean interrupted) {
-        this.interrupted = interrupted;
-    }
-
-    public interface Html5FileUploadListener extends Serializable {
-
-        void onProgress(ReceivingProgressedEvent event);
-
-        void uploadStarted(ReceivingStartedEvent event);
-
-        void uploadFinished(ReceivingEndedEvent event);
-
-        void uploadFailed(ReceivingFailedEvent event);
+    public StreamVariable getReceiver() {
+        return streamVariable;
     }
 
+    
 }
\ No newline at end of file
index 413c0aab5221f29aaf4e719de8bc03678a9bbfa5..8e1a859f5fa97b08540f76aebeeb1ba6542d9e4a 100644 (file)
@@ -4,6 +4,7 @@
 
 package com.vaadin.ui;
 
+import java.io.OutputStream;
 import java.io.Serializable;
 import java.lang.reflect.Method;
 import java.util.Iterator;
@@ -12,7 +13,7 @@ import java.util.Map;
 
 import com.vaadin.terminal.PaintException;
 import com.vaadin.terminal.PaintTarget;
-import com.vaadin.terminal.ReceiverOwner;
+import com.vaadin.terminal.StreamVariable.StreamingStartedEvent;
 import com.vaadin.terminal.gwt.client.ui.VUpload;
 import com.vaadin.terminal.gwt.server.NoInputStreamException;
 import com.vaadin.terminal.gwt.server.NoOutputStreamException;
@@ -60,8 +61,7 @@ import com.vaadin.ui.ClientWidget.LoadStyle;
  */
 @SuppressWarnings("serial")
 @ClientWidget(value = VUpload.class, loadStyle = LoadStyle.LAZY)
-public class Upload extends AbstractComponent implements Component.Focusable,
-        ReceiverOwner {
+public class Upload extends AbstractComponent implements Component.Focusable {
 
     /**
      * Should the field be focused on next repaint?
@@ -76,7 +76,7 @@ public class Upload extends AbstractComponent implements Component.Focusable,
     /**
      * The output of the upload is redirected to this receiver.
      */
-    private com.vaadin.terminal.Receiver receiver;
+    private Receiver receiver;
 
     private boolean isUploading;
 
@@ -106,32 +106,11 @@ public class Upload extends AbstractComponent implements Component.Focusable,
     public Upload() {
     }
 
-    /**
-     * @deprecated use
-     *             {@link Upload#Upload(String, com.vaadin.terminal.Receiver)}
-     *             instead
-     */
-    @Deprecated
     public Upload(String caption, Receiver uploadReceiver) {
         setCaption(caption);
         receiver = uploadReceiver;
     }
 
-    /**
-     * Creates a new instance of Upload that redirects the uploaded data to
-     * stream given by the Receiver.
-     * 
-     * @param caption
-     *            Normal component caption. You can set the caption of the
-     *            upload submit button with setButtonCaption().
-     * @param uploadReceiver
-     *            Receiver to call to retrieve output stream when upload starts.
-     */
-    public Upload(String caption, com.vaadin.terminal.Receiver uploadReceiver) {
-        setCaption(caption);
-        receiver = uploadReceiver;
-    }
-
     /**
      * Invoked when the value of a variable has changed.
      * 
@@ -181,8 +160,8 @@ public class Upload extends AbstractComponent implements Component.Focusable,
 
         target.addAttribute("nextid", nextid);
 
-        // Post file to this receiver
-        target.addVariable(this, "action", getReceiver());
+        // Post file to this strean variable
+        target.addVariable(this, "action", getStreamVariable());
 
     }
 
@@ -194,11 +173,9 @@ public class Upload extends AbstractComponent implements Component.Focusable,
      * @version
      * @VERSION@
      * @since 3.0
-     * @deprecated use {@link com.vaadin.terminal.Receiver} instead. A "copy"
-     *             here is kept for backwards compatibility.
      */
-    @Deprecated
-    public interface Receiver extends com.vaadin.terminal.Receiver {
+    public interface Receiver extends Serializable {
+        public OutputStream receiveUpload(String filename, String mimetype);
     }
 
     /* Upload events */
@@ -753,35 +730,22 @@ public class Upload extends AbstractComponent implements Component.Focusable,
     /**
      * Returns the current receiver.
      * 
-     * @return the Receiver.
+     * @return the StreamVariable.
      */
-    public com.vaadin.terminal.Receiver getReceiver() {
+    public Receiver getReceiver() {
         return receiver;
     }
 
     /**
      * Sets the receiver.
      * 
-     * @deprecated use {@link #setReceiver(com.vaadin.terminal.Receiver)}
-     *             instead
      * @param receiver
      *            the receiver to set.
      */
-    @Deprecated
     public void setReceiver(Receiver receiver) {
         this.receiver = receiver;
     }
 
-    /**
-     * Sets the receiver.
-     * 
-     * @param receiver
-     *            the receiver to set.
-     */
-    public void setReceiver(com.vaadin.terminal.Receiver receiver) {
-        this.receiver = receiver;
-    }
-
     /**
      * {@inheritDoc}
      */
@@ -942,50 +906,66 @@ public class Upload extends AbstractComponent implements Component.Focusable,
      * Handle to terminal via Upload monitors and controls the upload during it
      * is being streamed.
      */
-    private final ReceivingController controller = new ReceivingController() {
-        public boolean listenProgress() {
-            return (progressListeners != null && !progressListeners.isEmpty());
-        }
-
-        public void onProgress(ReceivingProgressedEvent event) {
-            fireUpdateProgress(event.getBytesReceived(),
-                    event.getContentLength());
-        }
-
-        public void uploadStarted(ReceivingStartedEvent event) {
-            startUpload();
-            contentLength = event.getContentLength();
-            fireStarted(event.getFileName(), event.getMimeType());
-        }
-
-        public void uploadFinished(ReceivingEndedEvent event) {
-            fireUploadSuccess(event.getFileName(), event.getMimeType(),
-                    event.getContentLength());
-            endUpload();
-            requestRepaint();
-        }
-
-        public void uploadFailed(ReceivingFailedEvent event) {
-            Exception exception = event.getException();
-            if (exception instanceof NoInputStreamException) {
-                fireNoInputStream(event.getFileName(), event.getMimeType(), 0);
-            } else if (exception instanceof NoOutputStreamException) {
-                fireNoOutputStream(event.getFileName(), event.getMimeType(), 0);
-            } else {
-                fireUploadInterrupted(event.getFileName(), event.getMimeType(),
-                        0, exception);
-            }
-            endUpload();
-        }
-
-        public boolean isInterrupted() {
-            return interrupted;
-        }
-    };
-
-    public ReceivingController getReceivingController(
-            com.vaadin.terminal.Receiver receiver) {
-        return controller;
+    private com.vaadin.terminal.StreamVariable streamVariable;
+
+    protected com.vaadin.terminal.StreamVariable getStreamVariable() {
+        if (streamVariable == null) {
+            streamVariable = new com.vaadin.terminal.StreamVariable() {
+                private StreamingStartedEvent lastStartedEvent;
+
+                public boolean listenProgress() {
+                    return (progressListeners != null && !progressListeners
+                            .isEmpty());
+                }
+
+                public void onProgress(StreamingProgressedEvent event) {
+                    fireUpdateProgress(event.getBytesReceived(),
+                            event.getContentLength());
+                }
+
+                public boolean isInterrupted() {
+                    return interrupted;
+                }
+
+                public OutputStream getOutputStream() {
+                    OutputStream receiveUpload = receiver.receiveUpload(
+                            lastStartedEvent.getFileName(),
+                            lastStartedEvent.getMimeType());
+                    lastStartedEvent = null;
+                    return receiveUpload;
+                }
+
+                public void streamingStarted(StreamingStartedEvent event) {
+                    startUpload();
+                    contentLength = event.getContentLength();
+                    fireStarted(event.getFileName(), event.getMimeType());
+                    lastStartedEvent = event;
+                }
+
+                public void streamingFinished(StreamingEndedEvent event) {
+                    fireUploadSuccess(event.getFileName(), event.getMimeType(),
+                            event.getContentLength());
+                    endUpload();
+                    requestRepaint();
+                }
+
+                public void streamingFailed(StreamingFailedEvent event) {
+                    Exception exception = event.getException();
+                    if (exception instanceof NoInputStreamException) {
+                        fireNoInputStream(event.getFileName(),
+                                event.getMimeType(), 0);
+                    } else if (exception instanceof NoOutputStreamException) {
+                        fireNoOutputStream(event.getFileName(),
+                                event.getMimeType(), 0);
+                    } else {
+                        fireUploadInterrupted(event.getFileName(),
+                                event.getMimeType(), 0, exception);
+                    }
+                    endUpload();
+                }
+            };
+        }
+        return streamVariable;
     }
 
 }
index 38c48ae44c6756470e3a833ba393d52afc8d99a5..3401ff9acab7d337a6364303b610d67bf577e0b4 100644 (file)
@@ -26,6 +26,7 @@ import com.vaadin.event.dd.acceptcriteria.AcceptAll;
 import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
 import com.vaadin.event.dd.acceptcriteria.Not;
 import com.vaadin.event.dd.acceptcriteria.SourceIsTarget;
+import com.vaadin.terminal.StreamVariable;
 import com.vaadin.terminal.Resource;
 import com.vaadin.terminal.StreamResource;
 import com.vaadin.terminal.StreamResource.StreamSource;
@@ -46,7 +47,6 @@ import com.vaadin.ui.Table;
 import com.vaadin.ui.Tree;
 import com.vaadin.ui.Tree.TreeDragMode;
 import com.vaadin.ui.Tree.TreeTargetDetails;
-import com.vaadin.ui.Upload.Receiver;
 import com.vaadin.ui.Window;
 
 public class DDTest6 extends TestBase {
@@ -399,21 +399,50 @@ public class DDTest6 extends TestBase {
                     for (Html5File html5File : files2) {
                         String fileName = html5File.getFileName();
                         // int bytes = html5File.getFileSize();
-                        final ByteArrayOutputStream bas = new ByteArrayOutputStream() {
-                            @Override
-                            public void close() throws IOException {
-                                super.close();
-                            }
-                        };
+                        final ByteArrayOutputStream bas = new ByteArrayOutputStream();
 
-                        Receiver receiver = new Receiver() {
-                            public OutputStream receiveUpload(String filename,
-                                    String MIMEType) {
+                        StreamVariable streamVariable = new StreamVariable() {
+
+                            public OutputStream getOutputStream() {
                                 return bas;
                             }
+
+                            public boolean listenProgress() {
+                                // TODO Auto-generated method stub
+                                return false;
+                            }
+
+                            public void onProgress(
+                                    StreamingProgressedEvent event) {
+                                // TODO Auto-generated method stub
+                                
+                            }
+
+                            public void streamingStarted(
+                                    StreamingStartedEvent event) {
+                                // TODO Auto-generated method stub
+                                
+                            }
+
+                            public void streamingFinished(
+                                    StreamingEndedEvent event) {
+                                // TODO Auto-generated method stub
+                                
+                            }
+
+                            public void streamingFailed(
+                                    StreamingFailedEvent event) {
+                                // TODO Auto-generated method stub
+                                
+                            }
+
+                            public boolean isInterrupted() {
+                                // TODO Auto-generated method stub
+                                return false;
+                            }
                         };
 
-                        html5File.setReceiver(receiver);
+                        html5File.setReceiver(streamVariable);
 
                         File file = new File(fileName, bas);
                         file.setType(html5File.getType());
index a22be5c4408aa6f3baa7b7035494dbce350340a5..962f458230bf522658dcd7dfd4de42f50c837592 100644 (file)
@@ -9,18 +9,17 @@ import com.vaadin.event.dd.DragAndDropEvent;
 import com.vaadin.event.dd.DropHandler;
 import com.vaadin.event.dd.acceptcriteria.AcceptAll;
 import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
-import com.vaadin.terminal.Receiver;
-import com.vaadin.terminal.ReceiverOwner.ReceivingEndedEvent;
-import com.vaadin.terminal.ReceiverOwner.ReceivingFailedEvent;
-import com.vaadin.terminal.ReceiverOwner.ReceivingProgressedEvent;
-import com.vaadin.terminal.ReceiverOwner.ReceivingStartedEvent;
+import com.vaadin.terminal.StreamVariable;
+import com.vaadin.terminal.StreamVariable.StreamingEndedEvent;
+import com.vaadin.terminal.StreamVariable.StreamingFailedEvent;
+import com.vaadin.terminal.StreamVariable.StreamingProgressedEvent;
+import com.vaadin.terminal.StreamVariable.StreamingStartedEvent;
 import com.vaadin.tests.components.TestBase;
 import com.vaadin.ui.Component;
 import com.vaadin.ui.CssLayout;
 import com.vaadin.ui.DragAndDropWrapper;
 import com.vaadin.ui.DragAndDropWrapper.WrapperTransferable;
 import com.vaadin.ui.Html5File;
-import com.vaadin.ui.Html5File.Html5FileUploadListener;
 import com.vaadin.ui.Label;
 
 public class DragAndDropFiles extends TestBase {
@@ -63,47 +62,48 @@ public class DragAndDropFiles extends TestBase {
                             continue;
                         }
 
-                        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-
-                        Receiver receiver = new Receiver() {
-                            public OutputStream receiveUpload(String filename,
-                                    String MIMEType) {
-                                System.err.println("receiveUpload " + filename);
+                        StreamVariable streamVariable = new StreamVariable() {
 
+                            public OutputStream getOutputStream() {
                                 return new NullOutputStream();
                             }
-                        };
-                        file.setReceiver(receiver);
-                        Html5FileUploadListener listener = new Html5FileUploadListener() {
 
-                            public void uploadStarted(
-                                    ReceivingStartedEvent event) {
+                            public boolean listenProgress() {
+                                return true;
+                            }
+
+                            public void onProgress(
+                                    StreamingProgressedEvent event) {
+                                System.err.println("Progress"
+                                        + event.getBytesReceived());
+                            }
+
+                            public void streamingStarted(
+                                    StreamingStartedEvent event) {
                                 getMainWindow().showNotification(
                                         "Started uploading "
                                                 + event.getFileName());
-
                             }
 
-                            public void uploadFinished(ReceivingEndedEvent event) {
+                            public void streamingFinished(
+                                    StreamingEndedEvent event) {
                                 getMainWindow().showNotification(
                                         "Finished uploading "
                                                 + event.getFileName());
                             }
 
-                            public void uploadFailed(ReceivingFailedEvent event) {
+                            public void streamingFailed(
+                                    StreamingFailedEvent event) {
                                 getMainWindow().showNotification(
                                         "Failed uploading "
                                                 + event.getFileName());
-
                             }
 
-                            public void onProgress(
-                                    ReceivingProgressedEvent event) {
-                                System.err.println("Progress"
-                                        + event.getBytesReceived());
+                            public boolean isInterrupted() {
+                                return false;
                             }
                         };
-                        file.setUploadListener(listener);
+                        file.setReceiver(streamVariable);
                     }
                 }
 
index 1bfc66aa7e36c3ab629ca0e89ad8e42e0da68d81..5261272bee8b3fa15269a8d14f198934f938f7fb 100644 (file)
@@ -1,7 +1,6 @@
 package com.vaadin.tests.dd;
 
 import java.io.ByteArrayOutputStream;
-import java.io.IOException;
 import java.io.OutputStream;
 
 import com.vaadin.event.DataBoundTransferable;
@@ -10,6 +9,7 @@ import com.vaadin.event.dd.DragAndDropEvent;
 import com.vaadin.event.dd.DropHandler;
 import com.vaadin.event.dd.acceptcriteria.AcceptAll;
 import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
+import com.vaadin.terminal.StreamVariable;
 import com.vaadin.terminal.gwt.client.MouseEventDetails;
 import com.vaadin.ui.AbsoluteLayout;
 import com.vaadin.ui.AbsoluteLayout.ComponentPosition;
@@ -17,7 +17,6 @@ import com.vaadin.ui.Component;
 import com.vaadin.ui.DragAndDropWrapper;
 import com.vaadin.ui.Html5File;
 import com.vaadin.ui.Label;
-import com.vaadin.ui.Upload.Receiver;
 
 /**
  * replacement for a proto class to keep tests working
@@ -134,20 +133,42 @@ public class DragDropPane extends DragAndDropWrapper implements DropHandler {
             if (files != null) {
                 for (Html5File html5File : files) {
                     l.setCaption(html5File.getFileName());
-                    html5File.setReceiver(new Receiver() {
-                        public OutputStream receiveUpload(String filename,
-                                String MIMEType) {
-
-                            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream() {
-                                @Override
-                                public void close() throws IOException {
-                                    super.close();
-                                    l.setValue((new String(toByteArray())
-                                            .substring(0, 80) + "..."));
-                                }
-                            };
+                    html5File.setReceiver(new StreamVariable() {
+                        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+
+                        public OutputStream getOutputStream() {
                             return byteArrayOutputStream;
                         }
+
+                        public boolean listenProgress() {
+                            // TODO Auto-generated method stub
+                            return false;
+                        }
+
+                        public void onProgress(StreamingProgressedEvent event) {
+                            // TODO Auto-generated method stub
+
+                        }
+
+                        public void streamingStarted(StreamingStartedEvent event) {
+                            // TODO Auto-generated method stub
+
+                        }
+
+                        public void streamingFinished(StreamingEndedEvent event) {
+                            l.setValue((new String(byteArrayOutputStream
+                                    .toByteArray()).substring(0, 80) + "..."));
+                        }
+
+                        public void streamingFailed(StreamingFailedEvent event) {
+                            // TODO Auto-generated method stub
+
+                        }
+
+                        public boolean isInterrupted() {
+                            // TODO Auto-generated method stub
+                            return false;
+                        }
                     });
                 }
             }