All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.directwebremoting.extend.OutputStreamLoaderInputStreamFactory Maven / Gradle / Ivy

Go to download

DWR is easy Ajax for Java. It makes it simple to call Java code directly from Javascript. It gets rid of almost all the boilerplate code between the web browser and your Java code. This version 4.0.2 works with Jakarta Servlet 4.0.2.

The newest version!
package org.directwebremoting.extend;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

import org.directwebremoting.io.FileTransfer;
import org.directwebremoting.io.InputStreamFactory;
import org.directwebremoting.io.OutputStreamLoader;

/**
 * Used when the {@link FileTransfer} has a {@link OutputStreamLoader}, but what
 * it really wants is an {@link InputStreamFactory}
 * @author Joe Walker [joe at getahead dot ltd dot uk]
 */
public class OutputStreamLoaderInputStreamFactory implements InputStreamFactory
{
    public OutputStreamLoaderInputStreamFactory(OutputStreamLoader outputStreamLoader)
    {
        this.outputStreamLoader = outputStreamLoader;
    }

    public InputStream getInputStream() throws IOException
    {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        outputStreamLoader.load(out);
        return new ByteArrayInputStream(out.toByteArray());
    }

    public void close() throws IOException
    {
        outputStreamLoader = null;
    }

    /**
     * The object we are proxying to
     */
    private OutputStreamLoader outputStreamLoader;
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy