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

ste.bshell.BshNodeExecutor Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (C) 2018 Stefano Fornari.
 * All Rights Reserved.  No use, copying or distribution of this
 * work may be made except in accordance with a valid license
 * agreement from Stefano Fornari.  This notice must be
 * included on all copies, modifications and derivatives of this
 * work.
 *
 * STEFANO FORNARI MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY
 * OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 * PURPOSE, OR NON-INFRINGEMENT. STEFANO FORNARI SHALL NOT BE LIABLE FOR ANY
 * DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
 * THIS SOFTWARE OR ITS DERIVATIVES.
 */
package ste.bshell;

import bsh.BshConsoleInterpreter;
import java.util.concurrent.Callable;
import java.util.concurrent.RunnableFuture;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 *
 */
public class BshNodeExecutor  extends ThreadPoolExecutor {

    private BshConsoleInterpreter bsh;

    public BshNodeExecutor(BshConsoleInterpreter bsh) {
        super(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue());

        if (bsh == null) {
            throw new IllegalArgumentException("bsh can not be null");
        }
        this.bsh = bsh;
    }

    @Override
    protected  RunnableFuture newTaskFor(Callable callable) {
        if (callable == null) {
            throw new IllegalArgumentException("callable can not be null");
        }
        return new NodeFuture(callable, bsh.getConsole());
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy