Package com.ponysdk.core

Examples of com.ponysdk.core.UIContext


        return get(UIContext.getCurrentWindow().getID());
    }

    private static PRootLayoutPanel get(final long windowID) {
        final String rootID = ROOT + "_" + windowID;
        final UIContext session = UIContext.get();
        PRootLayoutPanel root = session.getAttribute(rootID);
        if (root == null) {
            root = new PRootLayoutPanel();
            session.setAttribute(rootID, root);
        }
        return root;
    }
View Full Code Here


    @Before
    public void beforeTest() {
        log.info("Running #" + name.getMethodName());

        final Application application = new Application("test", "Test", new EmptySession(), new ApplicationManagerOption());
        final UIContext uiContext = new UIContext(application);
        UIContext.setCurrent(uiContext);
        txn = Txn.get();
        txn.begin(new EmptyTxnContext());
        PPusher.initialize();
View Full Code Here

        return defaultRoot;
    }

    private static Map<String, PRootPanel> ensureChilds(final long windowID) {
        final String rootID = ROOTID + "_" + windowID;
        final UIContext session = UIContext.get();
        Map<String, PRootPanel> rootByIDs = session.getAttribute(rootID);
        if (rootByIDs == null) {
            rootByIDs = new HashMap<String, PRootPanel>();
            session.setAttribute(rootID, rootByIDs);
        }
        return rootByIDs;
    }
View Full Code Here

        return get(UIContext.getCurrentWindow().getID());
    }

    private static PScript get(final long windowID) {
        final String rootID = SCRIPT_KEY + "_" + windowID;
        final UIContext session = UIContext.get();
        PScript script = session.getAttribute(rootID);
        if (script == null) {
            script = new PScript() {};
            session.setAttribute(rootID, script);
        }
        return script;
    }
View Full Code Here

    private void streamRequest(final HttpServletRequest req, final HttpServletResponse resp) {
        try {
            final Application ponyApplicationSession = (Application) req.getSession().getAttribute(Application.class.getCanonicalName());
            final Long ponySessionID = Long.parseLong(req.getParameter("ponySessionID"));
            final UIContext ponySession = ponyApplicationSession.getUIContext(ponySessionID);
            final StreamHandler streamHandler = ponySession.removeStreamListener(Long.parseLong(req.getParameter(PROPERTY.STREAM_REQUEST_ID)));
            streamHandler.onStream(req, resp);
        } catch (final Exception e) {
            log.error("Cannot stream request", e);
            try {
                resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
View Full Code Here

        final Application applicationSession = (Application) req.getSession().getAttribute(Application.class.getCanonicalName());
        if (applicationSession == null) throw new RuntimeException("Invalid session, please reload your application");

        JettyWebSocket jettyWebSocket;

        final UIContext uiContext = applicationSession.getUIContext(key);
        uiContext.acquire();
        try {
            UIContext.setCurrent(uiContext);
            jettyWebSocket = newJettyWebsocket();
            PPusher.get().initialize(jettyWebSocket);
        } finally {
            UIContext.remove();
            uiContext.release();
        }

        return jettyWebSocket;
    }
View Full Code Here

    private PString() {
        coreResourceBundle = ResourceBundle.getBundle(MESSAGES_CORE);
    }

    private static PString get() {
        final UIContext session = UIContext.get();
        PString s = session.getAttribute(PString.class.getName());
        if (s == null) {
            s = new PString();
            session.setAttribute(PString.class.getName(), s);
        }
        return s;
    }
View Full Code Here

        }

    }

    protected void registerTask(final UIRunnable runnable) {
        final UIContext uiContext = runnable.getUiContext();
        uiContext.addUIContextListener(this);
        Set<UIRunnable> runnables = runnablesByUIContexts.get(uiContext);
        if (runnables == null) {
            runnables = new HashSet<UIScheduledThreadPoolExecutor.UIRunnable>();
            runnablesByUIContexts.put(uiContext, runnables);
        }
View Full Code Here

TOP

Related Classes of com.ponysdk.core.UIContext

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.