Examples of ScriptSession


Examples of org.directwebremoting.ScriptSession

    /**
     * Sets the script session for the game.
     */
    @Override
    public void setScriptSessionGame() {
        final ScriptSession scriptSession = WebContextFactory.get().getScriptSession();
        final HttpSession session = WebContextFactory.get().getSession();
        final Game game = (Game) session.getAttribute("game");
        final String email = (String) session.getAttribute("email");
        scriptSession.setAttribute("game", game);
        scriptSession.setAttribute("email", email);
    }
View Full Code Here

Examples of org.directwebremoting.ScriptSession

     * Used by the page unloader.
     */
    public void pageUnloaded()
    {
        WebContext wctx = WebContextFactory.get();
        ScriptSession scriptSession = wctx.getScriptSession();

        log.debug("pageUnloaded is invalidating scriptSession: " + scriptSession);
        scriptSession.invalidate();
    }
View Full Code Here

Examples of org.directwebremoting.ScriptSession

    @SuppressWarnings("unchecked")
    public void subscribe(String topic, String subscriptionId)
    {
        WebContext webContext = WebContextFactory.get();
        Hub hub = HubFactory.get();
        final ScriptSession session = webContext.getScriptSession();

        // Create a subscription block
        BrowserMessageListener subscription = new BrowserMessageListener(session, topic, subscriptionId);

        Map<String, BrowserMessageListener> subscriptions = (Map<String, BrowserMessageListener>) session.getAttribute(ATTRIBUTE_SUBSCRIPTIONS);
        if (subscriptions == null)
        {
            subscriptions = new HashMap<String, BrowserMessageListener>();
        }
        subscriptions.put(subscriptionId, subscription);
        session.setAttribute(ATTRIBUTE_SUBSCRIPTIONS, subscriptions);

        hub.subscribe(subscription.topic, subscription);
    }
View Full Code Here

Examples of org.directwebremoting.ScriptSession

    @SuppressWarnings("unchecked")
    public boolean unsubscribe(String subscriptionId)
    {
        WebContext webContext = WebContextFactory.get();
        Hub hub = HubFactory.get();
        ScriptSession session = webContext.getScriptSession();

        Map<String, BrowserMessageListener> subscriptions = (Map<String, BrowserMessageListener>) session.getAttribute(ATTRIBUTE_SUBSCRIPTIONS);
        BrowserMessageListener subscription = subscriptions.get(subscriptionId);

        return hub.unsubscribe(subscription.topic, subscription);
    }
View Full Code Here

Examples of org.directwebremoting.ScriptSession

    /* (non-Javadoc)
     * @see org.directwebremoting.AjaxFilter#doFilter(java.lang.Object, java.lang.reflect.Method, java.lang.Object[], org.directwebremoting.AjaxFilterChain)
     */
    public Object doFilter(Object obj, Method method, Object[] params, AjaxFilterChain chain) throws Exception
    {
        ScriptSession session = WebContextFactory.get().getScriptSession();
        Long lastAccess = (Long) session.getAttribute(ATTRIBUTE_LAST_ACTION);

        // Free pass in if you've not done anything so far.
        if (lastAccess != null)
        {
            long now = System.currentTimeMillis();
            if (now > lastAccess + actionTimeoutMillis)
            {
                session.addScript(new ScriptBuffer(onTimeout));
                session.invalidate();
                throw new DwrConvertedException("Your session has timed out");
            }
        }

        Object reply = chain.doFilter(obj, method, params);

        session.setAttribute(ATTRIBUTE_LAST_ACTION, System.currentTimeMillis());

        return reply;
    }
View Full Code Here

Examples of org.directwebremoting.ScriptSession

        if (data.isNull())
        {
            return null;
        }

        ScriptSession session = WebContextFactory.get().getScriptSession();
        String id = data.getValue();

        return new DefaultJavascriptObject(session, id);
    }
View Full Code Here

Examples of org.directwebremoting.ScriptSession

     */
    @SuppressWarnings("unchecked")
    public static <T> void executeCallback(String key, RealRawData data) throws ConversionException
    {
        WebContext webContext = WebContextFactory.get();
        ScriptSession session = webContext.getScriptSession();
        ConverterManager converterManager = webContext.getContainer().getBean(ConverterManager.class);

        Map<String, Class<T>> typeMap = (Map<String, Class<T>>) session.getAttribute(KEY_TYPE);
        Class<T> type = typeMap.remove(key);
        session.removeAttribute(KEY_TYPE);
        session.setAttribute(KEY_TYPE, typeMap);

        try
        {
            Method method = Callback.class.getMethod("dataReturned", type);

            Property property = new ParameterProperty(new MethodDeclaration(method), 0);
            InboundVariable iv = data.getInboundVariable();
            Object callbackData  = converterManager.convertInbound(type, iv, property);

            Map<String, Callback<T>> callbackMap = (Map<String, Callback<T>>) session.getAttribute(KEY_TYPE);
            Callback<T> callback = callbackMap.remove(key);
            session.removeAttribute(KEY_TYPE);
            session.setAttribute(KEY_CALLBACK, callbackMap);

            callback.dataReturned((T) callbackData);
        }
        catch (Exception ex)
        {
View Full Code Here

Examples of org.directwebremoting.ScriptSession

     * Internal method to find or create a StoreProvider for a given user.
     */
    @Override
    protected StoreProvider<T> getStoreProvider()
    {
        ScriptSession session = WebContextFactory.get().getScriptSession();

        @SuppressWarnings("unchecked")
        StoreProvider<T> storeProvider = (StoreProvider<T>) session.getAttribute(attributeName);

        if (storeProvider == null)
        {
            storeProvider = factory.create(session);
            session.setAttribute(attributeName, storeProvider);
        }

        return storeProvider;
    }
View Full Code Here

Examples of org.directwebremoting.ScriptSession

        if (data.isNull())
        {
            return null;
        }

        ScriptSession session = WebContextFactory.get().getScriptSession();
        String id = data.getValue();

        DefaultJavascriptObject object = new DefaultJavascriptObject(session, id);

        return Proxy.newProxyInstance(paramType.getClassLoader(), new Class[] { paramType }, object);
View Full Code Here

Examples of org.directwebremoting.ScriptSession

        if (data.isNull())
        {
            return null;
        }

        ScriptSession session = WebContextFactory.get().getScriptSession();
        String id = data.getValue();

        return new DefaultJavascriptFunction(session, id);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.