Package org.agilewiki.jactor

Examples of org.agilewiki.jactor.Mailbox


*/
public class AsyncTest extends TestCase {
    public void testExceptions()
            throws Exception {
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        Mailbox doerMailbox = mailboxFactory.createAsyncMailbox();
        Mailbox driverMailbox = mailboxFactory.createAsyncMailbox();
        try {
            Doer doer = new Doer();
            doer.initialize(doerMailbox);
            Driver driver = new Driver();
            driver.initialize(driverMailbox);
View Full Code Here


*/
public class SharedMailboxTest extends TestCase {
    public void testExceptions()
            throws Exception {
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        Mailbox sharedMailbox = mailboxFactory.createMailbox();
        try {
            Doer doer = new Doer();
            doer.initialize(sharedMailbox);
            Driver driver = new Driver();
            driver.initialize(sharedMailbox);
View Full Code Here

*/
public class SyncTest extends TestCase {
    public void testExceptions()
            throws Exception {
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        Mailbox doerMailbox = mailboxFactory.createMailbox();
        Mailbox driverMailbox = mailboxFactory.createMailbox();
        try {
            Doer doer = new Doer();
            doer.initialize(doerMailbox);
            Driver driver = new Driver();
            driver.initialize(driverMailbox);
View Full Code Here

     */
    @Override
    final public void acceptRequest(final APCRequestSource apcRequestSource,
            final Request request, final RP rp) throws Exception {
        final RequestSource rs = (RequestSource) apcRequestSource;
        final Mailbox sourceMailbox = rs.getMailbox();
        if (sourceMailbox == mailbox) {
            syncSend(rs, request, rp);
            return;
        }
        if (sourceMailbox == null) {
View Full Code Here

    final public void acceptEvent(final APCRequestSource apcRequestSource,
            final Request request) throws Exception {
        final RequestSource rs = (RequestSource) apcRequestSource;
        final ExceptionHandler sourceExceptionHandler = rs
                .getExceptionHandler();
        final Mailbox sourceMailbox = rs.getMailbox();
        if (sourceMailbox == mailbox) {
            syncSendEvent(rs, request, sourceExceptionHandler);
            return;
        }
        if (sourceMailbox == null) {
            asyncSendEvent(rs, request);
            return;
        }
        final EventQueue<List<JAMessage>> eventQueue = mailbox
                .getEventQueue();
        final EventQueue<List<JAMessage>> srcController = sourceMailbox
                .getEventQueue().getController();
        if (eventQueue.getController() == srcController) {
            syncSendEvent(rs, request, sourceExceptionHandler);
            return;
        }
View Full Code Here

     * @param request                The request.
     * @param sourceExceptionHandler Exception handler of the source actor.
     */
    private void syncSendEvent(final RequestSource rs, final Request request,
            final ExceptionHandler sourceExceptionHandler) {
        final Mailbox oldSourceMailbox = rs.getMailbox();
        final JARequest oldSourceRequest = oldSourceMailbox.getCurrentRequest();
        final JAEventRequest jaRequest = new JAEventRequest(rs, this, request,
                mailbox);
        mailbox.setCurrentRequest(jaRequest);
        try {
            setExceptionHandler(null);
            request.processRequest(this, JANoResponse.nrp);
        } catch (final Throwable ex) {
            final ExceptionHandler eh = getExceptionHandler();
            if (eh != null)
                try {
                    eh.process(ex);
                    return;
                } catch (final Throwable x) {
                    getMailboxFactory().eventException(request, x);
                }
            else {
                getMailboxFactory().eventException(request, ex);
            }
        }
        oldSourceMailbox.setCurrentRequest(oldSourceRequest);
        oldSourceMailbox.setExceptionHandler(sourceExceptionHandler);
    }
View Full Code Here

public class CalculatorTest extends TestCase {
    public void test1() {
        System.err.println("test 1");
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        try {
            Mailbox mailbox = mailboxFactory.createMailbox();
            Calculator calculator = new Calculator();
            calculator.initialize(mailbox);
            JAFuture future = new JAFuture();
            future.send(calculator, new Set(1));
            future.send(calculator, new Add(2));
View Full Code Here

    public void test2() {
        System.err.println("test 2");
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        try {
            Mailbox mailbox = mailboxFactory.createMailbox();
            Driver1 driver = new Driver1();
            driver.initialize(mailbox);
            JAFuture future = new JAFuture();
            System.err.println(SimpleRequest.req.send(future, driver));
        } catch (Throwable e) {
View Full Code Here

    public void test3() {
        System.err.println("test 3");
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        try {
            Mailbox mailbox = mailboxFactory.createMailbox();
            Driver2 driver = new Driver2();
            driver.initialize(mailbox);
            JAFuture future = new JAFuture();
            System.err.println(SimpleRequest.req.send(future, driver));
        } catch (Throwable e) {
View Full Code Here

    public void test4() {
        System.err.println("test 4");
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        try {
            Mailbox mailbox = mailboxFactory.createMailbox();
            Driver3 driver = new Driver3();
            driver.initialize(mailbox);
            JAFuture future = new JAFuture();
            System.err.println(SimpleRequest.req.send(future, driver));
        } catch (Throwable e) {
View Full Code Here

TOP

Related Classes of org.agilewiki.jactor.Mailbox

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.