Package org.agilewiki.jactor2.core.reactors

Examples of org.agilewiki.jactor2.core.reactors.ThreadBoundReactor


class Any<RESPONSE_TYPE> extends AOp<RESPONSE_TYPE> {
    final AOp<RESPONSE_TYPE>[] requests;

    public Any(final AOp<RESPONSE_TYPE>... _requests) throws Exception {
        super("any", new NonBlockingReactor());
        requests = _requests;
    }
View Full Code Here


class A2 extends AOp<Long> {
    final long delay;

    A2(final String _name, final long _delay) throws Exception {
        super(_name, new NonBlockingReactor());
        delay = _delay;
    }
View Full Code Here

        new Plant(2);

        try {

            //Create an ExceptionBlade.
            ExceptionBlade exceptionBlade = new ExceptionBlade(new NonBlockingReactor());

            try {
                //Create and call an exception request.
                exceptionBlade.exceptionAOp().call();
                System.out.println("can not get here");
            } catch (IOException ise) {
                System.out.println("got first IOException, as expected");
            }

            //Create an ExceptionHandlerBlade.
            ExceptionHandlerBlade exceptionHandlerBlade =
                    new ExceptionHandlerBlade(exceptionBlade, new NonBlockingReactor());
            //Create a test request, call it and print the results.
            System.out.println(exceptionHandlerBlade.testAOp().call());

        } finally {
            //shutdown the facility
View Full Code Here

        new Plant(2);

        try {

            //Create blades.
            SampleBlade2 bladeA = new SampleBlade2(new NonBlockingReactor());

            //Initialize blades to 1.
            bladeA.updateAOp(1).signal();

            //Change blades to 2.
            System.out.println("was " + bladeA.updateAOp(2).call() + " but is now 2");

            //Create bladeB with a reference to blades.
            IndirectBlade bladeB = new IndirectBlade(bladeA, new NonBlockingReactor());

            //Indirectly change blades to 42.
            System.out.println("was " + bladeB.indirectAOp(42).call() + " but is now 42");

        } finally {
View Full Code Here

class All extends AOp<Void> {
    final AOp<Void>[] requests;

    All(final AOp<Void>... _requests) throws Exception {
        super("All", new NonBlockingReactor());
        requests = _requests;
    }
View Full Code Here

    }
}

class A1 extends AOp<Void> {
    A1(final String _name) throws Exception {
        super(_name, new NonBlockingReactor());
    }
View Full Code Here

public class HungRequestTest extends CallTestBase {
    public void testa() throws Exception {
        new Plant();
        try {
            final Hanger blade1 = new Hanger(new NonBlockingReactor());
            try {
                call(blade1.hiAOp());
            } catch (final ReactorClosedException sce) {
            }
            final Hung blade2 = new Hung(new NonBlockingReactor(), new Hanger(
                    new NonBlockingReactor()));
            try {
                call(blade2.hoAOp());
            } catch (final ReactorClosedException sce) {
            }
        } finally {
View Full Code Here

public class PubSubSample {
    public static void main(final String[] args) throws Exception {
        final Plant plant = new Plant();
        try {
            NonBlockingReactor reactor = new NonBlockingReactor();
            RequestBus<String> requestBus =
                    new RequestBus<String>(reactor);
            new SubscribeAOp<String>(requestBus, reactor) {
                @Override
                protected void processContent(String _content) throws Exception {
View Full Code Here

public class PubSubTest extends CallTestBase {
    public void testI() throws Exception {
        System.out.println("I");
        new Plant();
        try {
            final NonBlockingReactor reactor = new NonBlockingReactor();
            final RequestBus<Void> requestBus = new RequestBus<Void>(reactor);
            call(requestBus.signalsContentSOp(null));
            final Subscription<Void> s1 = call(new SubscribeAOp<Void>(
                    requestBus, reactor) {
                @Override
View Full Code Here

    public void testJ() throws Exception {
        System.out.println("J");
        new Plant();
        try {
            final AtomicInteger counter = new AtomicInteger();
            final NonBlockingReactor busReactor = new NonBlockingReactor();
            final CommonReactor subscriberReactor = new NonBlockingReactor();
            final RequestBus<Void> requestBus = new RequestBus<Void>(busReactor);
            call(requestBus.sendsContentAOp(null));
            assertEquals(counter.get(), 0);
            call(new SubscribeAOp<Void>(requestBus, subscriberReactor) {
                @Override
                protected void processContent(final Void _content,
                                              AsyncRequestImpl _asyncRequestImpl,
                                              AsyncResponseProcessor<Void> _asyncResponseProcessor)
                        throws Exception {
                    System.out.println("ping");
                    counter.incrementAndGet();
                    _asyncResponseProcessor.processAsyncResponse(null);
                }
            });
            call(requestBus.sendsContentAOp(null));
            assertEquals(counter.get(), 1);
            subscriberReactor.close();
            try {
                call(requestBus.sendsContentAOp(null));
            } catch (final ReactorClosedException e) {
            }
            assertEquals(counter.get(), 1);
View Full Code Here

TOP

Related Classes of org.agilewiki.jactor2.core.reactors.ThreadBoundReactor

Copyright © 2018 www.massapicom. 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.