Package org.directwebremoting

Examples of org.directwebremoting.WebContext


    /* (non-Javadoc)
     * @see org.directwebremoting.Converter#convertInbound(java.lang.Class, org.directwebremoting.InboundVariable, org.directwebremoting.InboundContext)
     */
    public Object convertInbound(Class<?> paramType, InboundVariable data)
    {
        WebContext webcx = WebContextFactory.get();

        if (HttpServletRequest.class.isAssignableFrom(paramType))
        {
            return webcx.getHttpServletRequest();
        }

        if (HttpServletResponse.class.isAssignableFrom(paramType))
        {
            return webcx.getHttpServletResponse();
        }

        if (ServletConfig.class.isAssignableFrom(paramType))
        {
            return webcx.getServletConfig();
        }

        if (ServletContext.class.isAssignableFrom(paramType))
        {
            return webcx.getServletContext();
        }

        if (HttpSession.class.isAssignableFrom(paramType))
        {
            return webcx.getSession(true);
        }

        return null;
    }
View Full Code Here


        if (!sclist.isEmpty())
        {
            return sclist.getFirst();
        }

        WebContext webcx = WebContextFactory.get();
        if (webcx != null)
        {
            return webcx.getServletContext();
        }

        ServerContext serverContext = StartupUtil.getSingletonServerContext();
        if (serverContext != null)
        {
View Full Code Here

     * Create a Callback from a DWR thread,
     * i.e. where {@link WebContextFactory#get()} =! null
     */
    public Callback()
    {
        WebContext context = WebContextFactory.get();
        if (context == null)
        {
            throw new IllegalStateException("Attempt to use Callback without any ScriptSessions, from a non DWR thread. There is nowhere for replies to go.");
        }

        sessions.add(context.getScriptSession());
    }
View Full Code Here

    {
        synchronized (this)
        {
            if (moduleConfig == null)
            {
                WebContext wc = WebContextFactory.get();

                if (getInstanceMethod != null)
                {
                    try
                    {
                        // ModuleUtils utils = ModuleUtils.getInstance();
                        Object utils = getInstanceMethod.invoke(null);

                        // String moduleName = utils.getModuleName("/", wc.getServletContext());
                        String moduleName = (String) getModuleNameMethod.invoke(utils, "/", wc.getServletContext());

                        // moduleConfig = utils.getModuleConfig(moduleName, wc.getServletContext());
                        moduleConfig = (ModuleConfig) getModuleConfigMethod.invoke(utils, moduleName, wc.getServletContext());
                    }
                    catch (Exception ex)
                    {
                        throw new IllegalArgumentException(ex);
                    }
                }
                else
                {
                    HttpServletRequest request = wc.getHttpServletRequest();
                    if (request == null)
                    {
                        Loggers.STARTUP.warn("Using a FakeHttpServletRequest as part of setup");
                        request = new FakeHttpServletRequest();
                    }

                    moduleConfig = RequestUtils.getModuleConfig(request, wc.getServletContext());
                }
            }
        }

        try
View Full Code Here

                {
                    welcomeFiles = getWebXmlWelcomeFileList(servletContext);
                }
                else
                {
                    WebContext webContext = WebContextFactory.get();
                    if (webContext == null)
                    {
                        log.warn("Can't find ServletContext to check for <welcome-file-list> in web.xml. Assuming defaults.");
                        log.warn(" - To prevent this message from happening, either call the PageNormalizer from a DWR thread");
                        log.warn(" - Or seed the PageNormalizer with a ServletContext before access from outside a DWR thread");
                    }
                    else
                    {
                        ServletContext threadServletContext = webContext.getServletContext();
                        welcomeFiles = getWebXmlWelcomeFileList(threadServletContext);
                    }
                }
            }
View Full Code Here

        Object object = null;
        String scope = creator.getScope();
        boolean create = false;
        if (!Modifier.isStatic(method.getModifiers()))
        {
            WebContext webcx = WebContextFactory.get();

            // Check the various scopes to see if it is there
            if (scope.equals(Creator.APPLICATION))
            {
                object = webcx.getServletContext().getAttribute(getName());
            }
            else if (scope.equals(Creator.SESSION))
            {
                object = webcx.getSession().getAttribute(getName());
            }
            else if (scope.equals(Creator.SCRIPT))
            {
                object = webcx.getScriptSession().getAttribute(getName());
            }
            else if (scope.equals(Creator.REQUEST))
            {
                object = webcx.getHttpServletRequest().getAttribute(getName());
            }
            // Creator.PAGE scope means we create one every time anyway

            // If we don't have an object then call the creator
            try
            {
                if (object == null)
                {
                    create = true;
                    object = creator.getInstance();
                }
            }
            catch (InstantiationException ex)
            {
                // Allow Jetty RequestRetry exception to propagate to container
                Continuation.rethrowIfContinuation(ex);
                // We should log this regardless of the accessLogLevel.
                log.info("Error creating an instance of the following DWR Creator: " + ((null != creator.getClass()) ? creator.getClass().getName() : "None Specified") + ".", ex);
                throw ex;
            }

            // Remember it for next time
            if (create)
            {
                if (scope.equals(Creator.APPLICATION))
                {
                    // This might also be done at application startup by
                    // DefaultCreatorManager.addCreator(String, Creator)
                    webcx.getServletContext().setAttribute(getName(), object);
                }
                else if (scope.equals(Creator.SESSION))
                {
                    webcx.getSession().setAttribute(getName(), object);
                }
                else if (scope.equals(Creator.SCRIPT))
                {
                    webcx.getScriptSession().setAttribute(getName(), object);
                }
                else if (scope.equals(Creator.REQUEST))
                {
                    webcx.getHttpServletRequest().setAttribute(getName(), object);
                }
                // Creator.PAGE scope means we create one every time anyway
            }
        }
View Full Code Here

    }

    public void invoke(Object[] args) {

        // TODO: this only works if its the same thread as request
        WebContext wctx = WebContextFactory.get();
        String currentPage = wctx.getCurrentPage();

        // Get a DWR Util proxy for all the browsers on the current page:
        Collection sessions = wctx.getScriptSessionsByPage(currentPage);
        Util utilAll = new Util(sessions);

        ScriptBuffer referenceInvoke = getInvokeFragment(args, wctx);

        // add the reference call to the Util proxy which will cause DWR to
View Full Code Here

  // 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

        lePanier = new Panier();

        // ajout de ce panier dans la session de l'utilisateur
        // on fait cela pour ne pas avoir à modifier les autres servlets
        // de l'application existante qui se servent de cet attribut.
        WebContext ctx = WebContextFactory.get();
        HttpServletRequest req = ctx.getHttpServletRequest();
        HttpSession session = req.getSession(true);
        session.setAttribute("lePanier", lePanier);
    }
View Full Code Here

     * appel distant à la méthode ajouterProduit, sa fonction callback récupère
     * l'objet panier qu'elle peut utiliser pour en afficher le contenu.
     */
    public Panier ajouterEpreuveINDAuPanier(int id) throws DAOException {
        // récupération de la DAO dans le contexte de l'application
        WebContext ctx = WebContextFactory.get();
        ServletContext servletContext = ctx.getServletContext();
        IEpreuveDAO dao = (IEpreuveDAO) servletContext.getAttribute("epreuveDAO");

        // récupération de l'objet produit
        Epreuve ep = dao.getEpreuveInd(id);

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.