Example usage for org.apache.commons.javaflow.api Continuation startWith

List of usage examples for org.apache.commons.javaflow.api Continuation startWith

Introduction

In this page you can find the example usage for org.apache.commons.javaflow.api Continuation startWith.

Prototype

public static Continuation startWith(final Runnable target) 

Source Link

Document

Starts executing the specified Runnable object in an environment that allows Continuation#suspend() .

Usage

From source file:net.sf.jasperreports.engine.fill.JRContinuationSubreportRunner.java

@Override
public JRSubreportRunResult start() {
    continuation = Continuation.startWith(this);
    return runResult();
}

From source file:org.apache.commons.javaflow.examples.again.AgainExample.java

public static void main(final String[] argv) throws Exception {
    Continuation cc = Continuation.startWith(new Execution());
    System.out.println("In main loop after prologue");
    cc = cc.resume(); // will loop in Execution due to call to again()
    System.out.println("In main done");
    System.out.println("===");
}

From source file:org.apache.commons.javaflow.examples.cdi.owb.OWBApplication.java

public void run() {
    int i = 0;//from   w  ww.j av a  2 s. c  o m
    for (Continuation cc = Continuation.startWith(execution); null != cc; cc = cc.resume(i += 100)) {
        System.out.println("SUSPENDED " + cc.value());
    }

    System.out.println("===");
}

From source file:org.apache.commons.javaflow.examples.cdi.weld.WeldApplication.java

public void run(@Observes ContainerInitialized event) {
    System.out.println("Execution is proxy? " + (execution instanceof ProxyObject));
    int i = 0;// w w  w.  ja  v a  2s .co  m
    for (Continuation cc = Continuation.startWith(execution); null != cc; cc = cc.resume(i += 100)) {
        System.out.println("SUSPENDED " + cc.value());
    }

    System.out.println("===");

}

From source file:org.apache.commons.javaflow.examples.inheritance.InheritanceExample.java

public static void main(final String[] argv) throws Exception {

    for (Continuation cc = Continuation.startWith(new Execution()); null != cc; cc = cc.resume()) {
        System.out.println("Interrupted " + cc.value());
    }//from ww w .j  a  v a  2 s .  c  om

    System.out.println("===");
}

From source file:org.apache.commons.javaflow.examples.inner_outer.InnerOuterExample.java

public static void main(final String[] argv) throws Exception {

    final String[] strings = { "A", "B", "C" };
    for (Continuation cc = Continuation.startWith(new Execution()); null != cc;) {
        final int valueFromContinuation = (Integer) cc.value();
        System.out.println("Interrupted " + valueFromContinuation);
        // Let's continuation resume
        cc = cc.resume(strings[valueFromContinuation % strings.length]);
    }/*  ww  w . j a v a  2  s  .c  o  m*/

    System.out.println("ALL DONE");

}

From source file:org.apache.commons.javaflow.examples.interceptor.InterceptorExample.java

public static void main(final String[] argv) throws Exception {

    int i = 0;/*from   ww  w.jav  a2  s.c om*/
    for (Continuation cc = Continuation.startWith(new Execution()); null != cc; cc = cc.resume(i += 100)) {
        System.out.println("SUSPENDED " + cc.value());
    }

    System.out.println("===");

}

From source file:org.apache.commons.javaflow.examples.invokedynamic.DynamicInvokerExample.java

public static void main(String[] args) throws Exception {
    Class<Runnable> dynamicClass = generateDynamicInvokerClass(
            "org/apache/commons/javaflow/examples/invokedynamic/SimpleDynamicInvoker");
    Runnable demo = dynamicClass.newInstance();

    for (Continuation cc = Continuation.startWith(demo); null != cc; cc = cc.resume()) {
        System.out.println("Interrupted " + cc.value());
    }/*from   w w  w  .j av a 2s .com*/
}

From source file:org.apache.commons.javaflow.examples.nested.ExecutionOuter.java

@Override
public @continuable void run() {
    for (int i = 1; i <= 5; i++) {
        System.out.println("Execution " + i);
        for (Continuation cc = Continuation.startWith(new ExecutionInner(i)); null != cc; cc = cc.resume()) {

            System.out.println("\tFrom inner " + cc.value());
            Continuation.suspend(i);//from   w  w w . j av a 2 s . c  o  m
        }
    }
}

From source file:org.apache.commons.javaflow.examples.nested.NestedExample.java

public static void main(final String[] argv) throws Exception {

    for (Continuation cc = Continuation.startWith(new ExecutionOuter()); null != cc; cc = cc.resume()) {
        System.out.println("Interrupted " + cc.value());
    }//  w  w  w . jav a 2  s . c o m

    System.out.println("===");

}