Examples of GrowableInMemoryPipe


Examples of uk.org.ogsadai.activity.io.GrowableInMemoryPipe

    {
        validateInput(INPUT);
        validateOutput(OUTPUT);
        mInput = getInput();
        mOutput = getOutput();
        final GrowableInMemoryPipe pipe = new GrowableInMemoryPipe();
       
        Thread writeThread = new Thread(new Runnable() {
           
            @Override
            public void run()
            {
                try
                {
                    Object block;
                    while ((block = pipe.read()) != ControlBlock.NO_MORE_DATA)
                    {
                        mOutput.write(block);
                    }
                }
                catch (PipeClosedException e)
                {
                    pipe.closeForReading();
                }
                catch (PipeIOException e)
                {
                    mOutputError = e;
                    pipe.closeForReading();
                    mOutput.closeForWritingDueToError();
                }
                catch (DataError e)
                {
                    mOutputError = e;
                    mOutput.closeForWritingDueToError();
                }
                catch (PipeTerminatedException e)
                {
                    mOutputError = e;
                    pipe.closeForReading();
                    mOutput.closeForWriting();
                }
            }
        });
        writeThread.start();

        try
        {
            Object block;
            while ((block = mInput.read()) != ControlBlock.NO_MORE_DATA)
            {
                pipe.write(block);
            }
            pipe.closeForWriting();
            writeThread.join();
        }
        catch (PipeClosedException e)
        {  
            if (mOutputError instanceof ActivityUserException)
            {
                throw (ActivityUserException)mOutputError;
            }
            if (mOutputError instanceof ActivityProcessingException)
            {
                throw (ActivityProcessingException)mOutputError;
            }
            if (mOutputError instanceof ActivityTerminatedException)
            {
                throw (ActivityTerminatedException)mOutputError;
            }
            return;
        }
        catch (PipeIOException e)
        {
            pipe.closeForWritingDueToError();
            throw new ActivityProcessingException(e);
        }
        catch (PipeTerminatedException e)
        {
            pipe.closeForWriting();
            throw new ActivityTerminatedException();
        }
        catch (InterruptedException e)
        {
            Thread.currentThread().interrupt();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.