Package com.caucho.server.webapp

Examples of com.caucho.server.webapp.WebApp


      } catch (Throwable e1) {
        log.log(Level.FINE, e1.toString(), e1);
      }
      */

      WebApp webApp = server.getDefaultWebApp();
      if (webApp != null)
        webApp.accessLog(getRequestFacade(), getResponseFacade());

      return false;
    } finally {
      finishInvocation();

View Full Code Here


  public TaglibManager getTaglibManager()
    throws JspParseException, IOException
  {
    synchronized (this) {
      if (_taglibManager == null) {
        WebApp webApp = getWebApp();

        Path appDir = getAppDir();
        if (appDir == null && webApp != null)
          appDir = webApp.getRootDirectory();

        JspResourceManager resourceManager = getResourceManager();
        if (resourceManager != null) {
        }
        else if (webApp != null)
          resourceManager = new AppResourceManager(webApp);
        else {
          resourceManager = new AppDirResourceManager(appDir);
        }

        _taglibManager = new TaglibManager(resourceManager,
                                           webApp,
                                           _tagFileManager);
        _taglibManager.setWebApp(webApp);

        JspConfig jspConfig = null;

        if (webApp != null)
          jspConfig = (JspConfig) webApp.getExtension("jsp-config");

        if (jspConfig != null) {
          ArrayList<JspTaglib> tldMapList = jspConfig.getTaglibList();
          for (int i = 0; i < tldMapList.size(); i++) {
            JspTaglib taglib = tldMapList.get(i);

            _taglibManager.addLocationMap(taglib.getTaglibUri(),
                                          taglib.getTaglibLocation());
          }
        }

        if (webApp != null) {
          ArrayList<JspTaglib> taglibs = webApp.getTaglibList();
          for (int i = 0; taglibs != null && i < taglibs.size(); i++) {
            JspTaglib taglib = taglibs.get(i);

            _taglibManager.addLocationMap(taglib.getTaglibUri(),
                                          taglib.getTaglibLocation());
View Full Code Here

      while (i < args.length) {
        if (args[i].equals("-app-dir")) {
          Path appDir = Vfs.lookup(args[i + 1]);

          WebApp app = createWebApp(appDir);

          setWebApp(app);
          setAppDir(appDir);

          i += 2;
        }
        else if (args[i].equals("-class-dir") || args[i].equals("-d")) {
          setClassDirectory(Vfs.lookup(args[i + 1]));
          i += 2;
        }
        else if (args[i].equals("-compiler")) {
          JavacConfig.getLocalConfig().setCompiler(args[i + 1]);

          i += 2;
        }
        else if (args[i].equals("-conf")) {
          Path path = Vfs.lookup(args[i + 1]);

          new Config().configureBean(this, path);
          hasConf = true;

          i += 2;
        }
        else
          break;
      }

      WebApp app = getWebApp();
      if (app != null && ! hasConf) {
        Path appDir = app.getRootDirectory();

        DynamicClassLoader dynLoader = app.getEnvironmentClassLoader();
        dynLoader.addLoader(new CompilingLoader(dynLoader, appDir.lookup("WEB-INF/classes")));
        dynLoader.addLoader(new DirectoryLoader(dynLoader, appDir.lookup("WEB-INF/lib")));

        Path webXml = appDir.lookup("WEB-INF/web.xml");

        if (webXml.canRead()) {
          try {
            new Config().configureBean(app, webXml);
          } catch (Exception e) {
            log.log(Level.WARNING, e.toString(), e);
          }
        }
      }

      Path appDir = null;

      if (app == null && getAppDir() != null) {
        app = createWebApp(null);

        if (app != null)
          app.setRootDirectory(getAppDir());
        setWebApp(app);
      }

      if (app != null) {
        app.setCompileContext(true);
       
        app.init();

        appDir = getWebApp().getRootDirectory();
        setClassLoader(getWebApp().getClassLoader());
      }
View Full Code Here

    @PostConstruct
    public void init()
      throws Exception
    {
      WebApp webApp = createWebApp(_rootDir);
      _program.configure(webApp);
      Config.init(webApp);

      webApp.init();
      webApp.start();
    }
View Full Code Here

    if (cacheStream == null)
      return;

    AbstractHttpRequest req = _response.getRequest();
    WebApp webApp = req.getWebApp();
    _cacheMaxLength = webApp.getCacheMaxLength();
  }
View Full Code Here

      AbstractCacheFilterChain cache = _cacheInvocation;

      if (cache != null && res != null) {
        _cacheInvocation = null;

        WebApp webApp = res.getRequest().getWebApp();
        if (webApp != null && webApp.isActive()) {
          cache.finishCaching(res);
        }
      }
    } catch (Exception e) {
      log.log(Level.WARNING, e.toString(), e);
View Full Code Here

    /* XXX: if we've already got an error, won't this just mask it?
    if (responseStream.isCommitted())
      throw new IllegalStateException("response can't sendError() after commit");
    */

    WebApp webApp = getRequest().getWebApp();

    ErrorPageManager errorManager = null;
    if (webApp != null)
      errorManager = webApp.getErrorPageManager();
    else
      errorManager = getRequest().getServer().getErrorPageManager();

    setStatus(code, value);

    try {
      if (code == SC_NOT_MODIFIED || code == SC_NO_CONTENT) {
        _response.finishInvocation();
        return;
      }
      else if (errorManager != null) {
        // server/10su
        errorManager.sendError(_request, this, code, _statusMessage);

        // _request.killKeepalive();
        // close, but don't force a flush
        // XXX: finish(false);
        _response.finishInvocation();
        return;
      }

      setContentType("text/html");
      ServletOutputStream s = getOutputStream();

      s.println("<html>");
      if (! isCommitted()) {
        s.print("<head><title>");
        s.print(code);
        s.print(" ");
        s.print(_statusMessage);
        s.println("</title></head>");
      }
      s.println("<body>");

      s.print("<h1>");
      s.print(code);
      s.print(" ");
      s.print(_statusMessage);
      s.println("</h1>");

      if (code == SC_NOT_FOUND) {
        s.println(L.l("{0} was not found on this server.",
                      HTTPUtil.encodeString(getRequest().getPageURI())));
      }
      else if (code == SC_SERVICE_UNAVAILABLE) {
        s.println(L.l("The server is temporarily unavailable due to maintenance downtime or excessive load."));
      }

      String version = null;

      if (webApp == null) {
      }
      else if (webApp.getServer() != null
               && webApp.getServer().getServerHeader() != null) {
        version = webApp.getServer().getServerHeader();
      }
      else if (CauchoSystem.isTesting()) {
      }
      else
        version = VersionFactory.getFullVersion();
View Full Code Here

      }
    }
  */
    // server/13dh
    else if (_cacheInvocation != null) {
      WebApp webApp = _request.getWebApp();

      long maxAge = webApp.getMaxAge(_request.getRequestURI());

      if (maxAge > 0 && ! containsHeader("Cache-Control")) {
        addHeader("Cache-Control", "max-age=" + (maxAge / 1000L));
      }
    }
View Full Code Here

  public String getCharacterEncoding()
  {
    if (_charEncoding == null) {
      _charEncoding = _setCharEncoding;

      WebApp webApp = _request.getWebApp();

      if (_charEncoding == null && webApp != null && webApp.getJsp() != null)
        _charEncoding = webApp.getJsp().getCharacterEncoding();

      if (_charEncoding == null && webApp != null)
        _charEncoding = webApp.getCharacterEncoding();

      if (_charEncoding == null) {
        // server/085a
        _charEncoding = "utf-8";
      }
View Full Code Here

        continue;
      else
        break;
    }

    WebApp webApp = getRequest().getWebApp();

    String hostPrefix = null;
    String host = _request.getHeader("Host");
    String serverName = webApp.getHostName();

    if (serverName == null
        || serverName.equals("")
        || serverName.equals("default")) {
      serverName = _request.getServerName();
    }

    int port = _request.getServerPort();

    if (hostPrefix != null && ! hostPrefix.equals("")) {
    }
    else if (serverName.startsWith("http:")
             || serverName.startsWith("https:"))
      hostPrefix = serverName;
    else if (host != null) {
      hostPrefix = _request.getScheme() + "://" + host;
    }
    else {
      hostPrefix = _request.getScheme() + "://" + serverName;

      if (serverName.indexOf(':') < 0
          && port != 0 && port != 80 && port != 443)
        hostPrefix += ":" + port;
    }

    if (slash == 0)
      return hostPrefix + path;

    String uri = _request.getRequestURI();
    String contextPath = _request.getContextPath();
    String queryString = null;

    int p = path.indexOf('?');
    if (p > 0) {
      queryString = path.substring(p + 1);
      path = path.substring(0, p);
    }

    if (uri.equals(contextPath)) {
      path = uri + "/" + path;
    }
    else {
      p = uri.lastIndexOf('/');

      if (p >= 0)
        path = uri.substring(0, p + 1) + path;
    }

    try {
      if (queryString != null)
        return hostPrefix + webApp.getInvocationDecoder().normalizeUri(path) + '?' + queryString;
      else
        return hostPrefix + webApp.getInvocationDecoder().normalizeUri(path);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

TOP

Related Classes of com.caucho.server.webapp.WebApp

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.