Package org.agilewiki.jactor2.core.impl

Examples of org.agilewiki.jactor2.core.impl.Plant


    public void testReactor() throws Exception {
        System.out.println("R");
        new Plant();
        try {
            final Reactor reactor = new NonBlockingReactor();

            final MyCloseable mac1 = new MyCloseable();
            final MyCloseable mac2 = new MyCloseable();
            final MyCloseable mac3 = new MyCloseable();
            final MyCloseable mac4 = new MyCloseable();
            final MyFailedCloseable mfac = new MyFailedCloseable();
            reactor.addCloseable(mac1);
            reactor.addCloseable(mac2);
            reactor.addCloseable(mac3);
            reactor.addCloseable(mac4);
            reactor.addCloseable(mfac);
            reactor.removeCloseable(mac4);

            reactor.close();

            assertEquals(mac1.closed, 1);
            assertEquals(mac2.closed, 1);
            assertEquals(mac3.closed, 1);
            assertEquals(mac4.closed, 0);
View Full Code Here


     * if the reactor is not a common reactor, sends a response of null via
     * a bound response processor.
     */
    public void onCancel() {
        cancelAll();
        final Reactor targetReactor = getTargetReactor();
        if (!(targetReactor instanceof CommonReactor)) {
            try {
                new BoundResponseProcessor<RESPONSE_TYPE>(targetReactor, this)
                        .processAsyncResponse(null);
            } catch (final Exception e) {
View Full Code Here

     * @return True when the closeable was added to the list.
     */
    @Override
    public boolean addCloseable(final Closeable _closeable) {
        if (startedClosing()) {
            throw new ReactorClosedException(
                    "call to addCloseable when reactor already started closing: "
                            + reason);
        }
        if (this == _closeable) {
            return false;
View Full Code Here

public class SwingBoundReactorSample {
    public static void main(final String[] _args) throws Exception {
        //Create a plant with 5 threads.
        Plant plant = new Plant(5);

        new HelloWorld(new SwingBoundReactor()).createAndShowAOp().signal();
    }
View Full Code Here

        //Get a reference to the main thread.
        final Thread mainThread = Thread.currentThread();

        //Create a thread-bound processing.
        final ThreadBoundReactor reactor =
                new ThreadBoundReactor(new Runnable() {
                    @Override
                    public void run() {
                        //Interrupt the main thread when there are messages to process
                        mainThread.interrupt();
                    }
                });

        //Create an blades that uses the thread-bound processing.
        final SampleThreadBoundBlade threadBoundBlade = new SampleThreadBoundBlade(reactor);

        //Terminate the blades.
        new SOp<Void>("finBlade", threadBoundBlade.getReactor()) {
            @Override
            protected Void processSyncOperation(RequestImpl _requestImpl) throws Exception {
                threadBoundBlade.fin();
                return null;
            }
        }.signal();

        //Process messages when this thread is interrupted.
        while (true) {
            try {
                //Wait for an interrupt.
                Thread.sleep(60000);
            } catch (InterruptedException e) {
                //Process messages when the main thread is interrupted.
                reactor.run();
            }
        }
    }
View Full Code Here

     *
     * @param _requestImpl    The reactor with the hung request.
     */
    public void onHungRequest(final RequestMtImpl<?> _requestImpl)
            throws Exception {
        final ReactorImpl reactor = _requestImpl.getTargetReactorImpl();
        reactor.error("request hung -> reactor close");
        reactor.fail("hung request");
    }
View Full Code Here

     * @param _requestImpl    The reactor with the hung request.
     * @param _error          The StackOverflowError.
     */
    public void onStackOverflowError(final RequestMtImpl<?> _requestImpl,
            final StackOverflowError _error) {
        final ReactorImpl reactor = _requestImpl.getTargetReactorImpl();
        reactor.error("stack overflow error -> reactor close", _error);
        try {
            reactor.fail("stack overflow");
        } catch (final Exception e) {

        }
    }
View Full Code Here

     * @param _requestImpl    The reactor with the hung request.
     * @param _exception      The runtime exception
     */
    public void onRuntimeException(final RequestMtImpl<?> _requestImpl,
            final RuntimeException _exception) {
        final ReactorImpl reactor = _requestImpl.getTargetReactorImpl();
        reactor.error("runtime exception -> reactor close", _exception);
        try {
            reactor.fail("runtime exception");
        } catch (final Exception e) {

        }
    }
View Full Code Here

     *
     * @param _response The response to this request.
     */
    @Override
    public void processAsyncResponse(final RESPONSE_TYPE _response) {
        final Timer timer = asyncOperation.getTimer();
        timer.updateNanos(timer.nanos() - start, true);
        processObjectResponse(_response);
    }
View Full Code Here

     *
     * @param _response An exception.
     */
    @Override
    public void processAsyncException(final Exception _response) {
        final Timer timer = asyncOperation.getTimer();
        timer.updateNanos(timer.nanos() - start, false);
        processObjectResponse(_response);
    }
View Full Code Here

TOP

Related Classes of org.agilewiki.jactor2.core.impl.Plant

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.