Package org.directwebremoting

Examples of org.directwebremoting.WebContext


  // The only reason to send the call to this servlet is if we somehow wish to
  // update other users.
  @Deprecated
  public String openURL(String url) {
    _logger.debug("openurl called with        "+ url ); //$NON-NLS-1$
    WebContext wctx = WebContextFactory.get();
        ScriptBuffer script = new ScriptBuffer();
        script.appendScript("window.open(") //$NON-NLS-1$
        .appendData(url)
        .appendScript(");");        //$NON-NLS-1$
        wctx.getScriptSession().addScript(script);
        return ""; //$NON-NLS-1$
  }
View Full Code Here


     * Generates and returns a new unique id suitable to use for the
     * CSRF session cookie. This method is itself exempted from CSRF checking.
     */
    public String generateId()
    {
        WebContext webContext = WebContextFactory.get();
        IdGenerator idGenerator = webContext.getContainer().getBean(IdGenerator.class);
        return idGenerator.generate();
    }
View Full Code Here

     * that called this method.
     * 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

     * @param topic The topic that has been published to
     * @param data The published data
     */
    public void publish(String topic, RealRawData data)
    {
        WebContext webContext = WebContextFactory.get();
        ConverterManager converterManager = webContext.getContainer().getBean(ConverterManager.class);
        Hub hub = HubFactory.get();

        MessageEvent event = new DefaultMessageEvent(hub, converterManager, data);
        hub.publish(topic, event);
    }
View Full Code Here

     * @param subscriptionId The ID to pass back to link to client side data
     */
    @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);
View Full Code Here

     * @return true iff someone was unsubscribed
     */
    @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

        response.setContentType(MimeConstants.MIME_HTML);
        PrintWriter out = response.getWriter();
        out.print("<html><head><title>DWR - System Monitor</title></head><body>");

        WebContext webContext = WebContextFactory.get();

        out.print("<h1>DWR - System Monitor</h1>");
        out.print("<h2>Global Settings:</h2>");

        String contextPath = webContext.getContextPath();
        out.print("<p>ContextPath: " + contextPath + "</p>");
        out.print("<p>Current Page: " + webContext.getCurrentPage() + "</p>");

        //ScriptSession scriptSession = webContext.getScriptSession();

        Container container = webContext.getContainer();
        SortedMap<String, Object> beans = new TreeMap<String, Object>();
        SortedMap<String, String> settings = new TreeMap<String, String>();
        SortedMap<String, String> urls = new TreeMap<String, String>();
        for (String name : container.getBeanNames())
        {
            Object bean = container.getBean(name);
            if (name.startsWith("url:"))
            {
                urls.put(name.substring(4), bean.getClass().getName());
            }
            else if (bean instanceof String)
            {
                settings.put(name, bean.toString());
            }
            else
            {
                beans.put(name, bean);
            }
        }

        // Add all the beans to an ID map for <a name=ID>
        IdManager ids = new IdManager();

        // Remove the URL re-writers from the Settings map
        for (Map.Entry<String, String> urlEntry : urls.entrySet())
        {
            for (Iterator<Map.Entry<String, String>> it = settings.entrySet().iterator(); it.hasNext();)
            {
                Map.Entry<String, String> settingEntry = it.next();
                if (urlEntry.getKey().equals(settingEntry.getValue()))
                {
                    it.remove();
                    urls.put(urlEntry.getKey(), urlEntry.getValue() + " (" + settingEntry.getKey() + ")");
                }
            }
        }

        out.print("<h2>Beans:</h2>");
        for (Map.Entry<String, Object> entry : beans.entrySet())
        {
            String name = entry.getKey();
            Object object = entry.getValue();

            digWhatever(out, ids, name, object);
        }

        out.print("<h2>Settings:</h2>");
        for (Map.Entry<String, String> entry : settings.entrySet())
        {
            out.print("<p>" + entry.getKey() + ": \"" + entry.getValue() + "\"</p>");
        }

        out.print("<h2>URLs:</h2>");
        String prefix = contextPath + webContext.getHttpServletRequest().getServletPath();
        for (Map.Entry<String, String> entry : urls.entrySet())
        {
            out.print("<p><a href='" + prefix + entry.getKey() + "'>" + entry.getKey() + "</a>: " + entry.getValue() + "</p>");
        }

        webContext.getContextPath();
        out.print("</body></html>");
    }
View Full Code Here

            BSFManager bsfman = new BSFManager();

            try
            {
                WebContext context = WebContextFactory.get();
                bsfman.declareBean("context", context, context.getClass());
            }
            catch (BSFException ex)
            {
                log.warn("Failed to register WebContext with scripting engine: " + ex.getMessage());
            }
View Full Code Here

        try
        {
            ServletConfig servletConfig = container.getBean(ServletConfig.class);
            ServletContext servletContext = container.getBean(ServletContext.class);

            WebContext ec = new DefaultWebContext(container, request, response, servletConfig, servletContext);
            user.set(ec);
        }
        catch (Exception ex)
        {
            log.fatal("Failed to create an ExecutionContext", ex);
View Full Code Here

     * which executes a {@link Callback} which has been called by the browser
     */
    @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);
View Full Code Here

TOP

Related Classes of org.directwebremoting.WebContext

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.