Package com.ponysdk.core.stm

Examples of com.ponysdk.core.stm.Txn


        if (UIContext.get() == null) {
            begin();
            try {
                if (listenerCollection.isEmpty()) return;
                final Txn txn = Txn.get();
                txn.begin(txnContext);
                try {
                    for (final Object data : collection) {
                        for (final DataListener listener : listenerCollection) {
                            listener.onData(data);
                        }
                    }
                    txn.commit();
                } catch (final Throwable e) {
                    log.error("Cannot process open socket", e);
                    txn.rollback();
                }
            } finally {
                end();
            }
        } else {
View Full Code Here


        if (UIContext.get() == null) {
            begin();
            try {
                if (listenerCollection.isEmpty()) return;
                final Txn txn = Txn.get();
                txn.begin(txnContext);
                try {
                    for (final DataListener listener : listenerCollection) {
                        listener.onData(data);
                    }
                    txn.commit();
                } catch (final Throwable e) {
                    log.error("Cannot process open socket", e);
                    txn.rollback();
                }
            } finally {
                end();
            }
        } else {
View Full Code Here

    @Override
    public void onClose() {
        begin();
        try {
            final Txn txn = Txn.get();
            txn.begin(txnContext);
            try {
                doClose();
                txn.commit();
            } catch (final Throwable e) {
                log.error("Cannot process open socket", e);
                txn.rollback();
            }
        } finally {
            end();
        }
    }
View Full Code Here

    @Override
    public void onOpen() {
        begin();
        try {
            final Txn txn = Txn.get();
            txn.begin(txnContext);
            try {
                doOpen();
                txn.commit();
            } catch (final Throwable e) {
                log.error("Cannot process open socket", e);
                txn.rollback();
            }
        } finally {
            end();
        }
    }
View Full Code Here

    public boolean execute(final Runnable runnable) {
        try {
            if (UIContext.get() == null) {
                begin();
                try {
                    final Txn txn = Txn.get();
                    txn.begin(txnContext);
                    try {
                        runnable.run();
                        txn.commit();
                    } catch (final Throwable e) {
                        log.error("Cannot process commmand", e);
                        txn.rollback();
                        return false;
                    }
                } finally {
                    end();
                }
View Full Code Here

                final UIContext previousUIContext = application.getUIContext(reloadedViewID);
                if (previousUIContext != null) previousUIContext.destroy();
            }

            try {
                final Txn txn = Txn.get();
                txn.begin(new TxnContextHttp(true, request, response));
                try {

                    final long receivedSeqNum = data.getLong(APPLICATION.SEQ_NUM);
                    uiContext.updateIncomingSeqNum(receivedSeqNum);

                    final EntryPoint entryPoint = initializePonySession(uiContext);

                    final String historyToken = data.getString(HISTORY.TOKEN);
                    if (historyToken != null && !historyToken.isEmpty()) uiContext.getHistory().newItem(historyToken, false);

                    final PCookies pCookies = uiContext.getCookies();
                    final JSONArray cookies = data.getJSONArray(PROPERTY.COOKIES);
                    for (int i = 0; i < cookies.length(); i++) {
                        final JSONObject jsoObject = cookies.getJSONObject(i);
                        final String name = jsoObject.getString(PROPERTY.KEY);
                        final String value = jsoObject.getString(PROPERTY.VALUE);
                        pCookies.cacheCookie(name, value);
                    }

                    if (isNewHttpSession) {
                        entryPoint.start(uiContext);
                    } else {
                        entryPoint.restart(uiContext);
                    }
                    txn.commit();
                } catch (final Throwable e) {
                    log.error("Cannot send instructions to the browser, Session ID #" + session.getId(), e);
                    txn.rollback();
                }
            } finally {
                UIContext.remove();
            }
        }
View Full Code Here

        if (uiContext == null) { throw new ServerException(ServerException.INVALID_SESSION, "Invalid session (no UIContext found), please reload your application (viewID #" + key + ")."); }

        uiContext.acquire();
        UIContext.setCurrent(uiContext);
        try {
            final Txn txn = Txn.get();
            txn.begin(new TxnContextHttp(false, request, response));
            try {
                final Long receivedSeqNum = checkClientMessage(request.getSession(), data, uiContext);

                if (receivedSeqNum != null) {
                    process(uiContext, data);

                    final List<JSONObject> datas = uiContext.expungeIncomingMessageQueue(receivedSeqNum);
                    for (final JSONObject jsoObject : datas) {
                        process(uiContext, jsoObject);
                    }
                }

                txn.commit();
            } catch (final Throwable e) {
                log.error("Cannot process client instruction", e);
                txn.rollback();
            }
        } finally {
            UIContext.remove();
            uiContext.release();
        }
View Full Code Here

TOP

Related Classes of com.ponysdk.core.stm.Txn

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.