/** * Look up an implementation of the named process on the classpath and describe the input * parameter required. * * @param name Name of the Process * @return Description of the parameters required */ public static synchronized Map<String, Parameter<?>> getParameterInfo(Name name) { ProcessFactory factory = createProcessFactory(name); if (factory == null) return null; return factory.getParameterInfo(name); }
@Override public Map<String, Object> call() throws Exception { return process.execute(input, new CallableProgressListener()); } };
/** * Look up an implementation of the named process on the classpath. * * @param name Name of the Process to create * @return created process */ public static synchronized Process createProcess(Name name) { ProcessFactory factory = createProcessFactory(name); if (factory == null) return null; return factory.create(name); }
void innerRun() { if (!compareAndSetState(0, RUNNING)) { return; } try { runningThread = Thread.currentThread(); innerSet(process.execute(input, this)); } catch (Throwable ex) { innerSetException(ex); } }
boolean innerRunAndReset() { if (!compareAndSetState(0, RUNNING)) { return false; } try { runningThread = Thread.currentThread(); process.execute(input, this); // don't set the result runningThread = null; return compareAndSetState(RUNNING, 0); } catch (Throwable ex) { innerSetException(ex); return false; } }
public ProcessSelectionPage(Map<String, Object> input) { super("process selection"); this.input = input; processFactories = Processors.getProcessFactories(); selectedFactory = null; }
void innerSet(Map<String, Object> v) { for (; ; ) { int s = getState(); if (ranOrCancelled(s)) { return; } if (compareAndSetState(s, COMPLETED)) { break; } } result = v; releaseShared(0); done(); }
public Progress submit(Process task, Map<String, Object> input) { if (task == null) throw new NullPointerException(); ProgressTask ftask = new ProgressTask(task, input); execute(ftask); return ftask; } }
boolean innerIsDone() { return ranOrCancelled(getState()) && runningThread == null; }
/** * Causes this ProgressTask to report an ExecutionException with the given throwable as its * cause, unless this ProgressTask has already been set or has been canceled. * * @param t the cause of failure. */ protected void setException(Throwable t) { synchronizer.innerSetException(t); }
public boolean isCanceled() { return innerIsCancelled(); }
/** * Executes the process without setting its result, and then resets this ProgressTask to its * initial state, failing to do so if the computation encounters an exception or is canceled. * This is designed for use with processes that execute more than once. * * @return true if successfully run and reset */ protected boolean runAndReset() { return synchronizer.innerRunAndReset(); }
/** * Sets the result of this ProgressTask to the given value unless this ProgressTask has already * been set or has been canceled. * * @param value the value to set */ protected void set(Map<String, Object> value) { synchronizer.innerSet(value); }
/** Implements AQS base acquire to succeed if ran or canceled */ @Override protected int tryAcquireShared(int ignore) { return innerIsDone() ? 1 : -1; }
/** Sets this ProgressTask to the result of the computation unless it has been canceled. */ public void run() { synchronizer.innerRun(); }
public float getProgress() { return synchronizer.getProgress(); }
boolean innerIsCancelled() { return getState() == CANCELED; }
void innerSetException(Throwable t) { for (; ; ) { int s = getState(); if (ranOrCancelled(s)) { return; } if (compareAndSetState(s, COMPLETED)) { break; } } exception = t; result = null; releaseShared(0); done(); }
public void exceptionOccurred(Throwable t) { innerSetException(t); }
public boolean isCancelled() { return synchronizer.innerIsCancelled(); }