private Path writeTempFile(Node node) throws IOException {
    Path workDir = CauchoSystem.getWorkPath().lookup("_xsl");
    workDir.mkdirs();

    // Path temp = workDir.createTempFile("tmp", "xsl");

    WriteStream os = Vfs.lookup("null:").openWrite();
    Crc64Stream crcStream = new Crc64Stream(os.getSource());
    os.init(crcStream);
    try {
      XmlPrinter printer = new XmlPrinter(os);

      printer.printNode(node);
    } finally {
      os.close();
    }

    long crc = crcStream.getCRC();
    CharBuffer cb = new CharBuffer();
    Base64.encode(cb, crc);

    String crcValue = cb.toString().replace('/', '-');

    Path xslPath = workDir.lookup(crcValue + ".xsl");

    // temp.renameTo(xslPath);

    return xslPath;
  }
  public boolean _caucho_isModified() {
    if (_caucho_isDead) return true;

    if (_caucho_isNotModified) return false;

    if (com.caucho.server.util.CauchoSystem.getVersionId() != -7791540776389363938L) return true;

    return _caucho_depends.isModified();
  }
  /** Adds a url-pattern */
  public void addURLPattern(String pattern) throws PatternSyntaxException {
    String regexpPattern = UrlMap.urlPatternToRegexpPattern(pattern);

    int flags = (CauchoSystem.isCaseInsensitive() ? Pattern.CASE_INSENSITIVE : 0);

    Pattern regexp = Pattern.compile(regexpPattern, flags);

    _urlPatternList.add(regexp);
  }
  public boolean _caucho_isModified() {
    if (_caucho_isDead) return true;

    if (_caucho_isNotModified) return false;

    if (com.caucho.server.util.CauchoSystem.getVersionId() != -4459662849186645341L) return true;

    return _caucho_depends.isModified();
  }
Beispiel #5
0
  /** Sets the url-pattern */
  public void addURLPattern(String pattern) {
    String regexpPattern = UrlMap.urlPatternToRegexpPattern(pattern);

    int flags = (CauchoSystem.isCaseInsensitive() ? Pattern.CASE_INSENSITIVE : 0);
    try {
      _regexp = Pattern.compile(regexpPattern, flags);
    } catch (PatternSyntaxException e) {
      log.log(Level.WARNING, e.toString(), e);
    }
  }
 public boolean _caucho_isModified() {
   if (_caucho_isDead) return true;
   if (com.caucho.server.util.CauchoSystem.getVersionId() != 5783496155892875126L) return true;
   for (int i = _caucho_depends.size() - 1; i >= 0; i--) {
     com.caucho.vfs.Dependency depend;
     depend = (com.caucho.vfs.Dependency) _caucho_depends.get(i);
     if (depend.isModified()) return true;
   }
   return false;
 }
  JavaTypeExpr(Block block, String className) {
    super(block, null);

    this.type = TYPE_JAVA;
    _typeName = className;
    try {
      this.javaType = CauchoSystem.loadClass(className, false, block.getClassLoader());
    } catch (Exception e) {
      this.type = TYPE_ES;
    }
  }
Beispiel #8
0
  /** Initialize the servlet */
  public void init() throws ServletException {
    _ejbManager = EjbManager.getCurrent();

    if (_ejbManager == null) {
      throw new ServletException(
          L.l(
              "No <ejb-server> detected.  '{0}' requires a configured <ejb-server>",
              getClass().getName()));
    }

    _workPath = CauchoSystem.getWorkPath();

    _urlPrefix = getInitParameter("url-prefix");

    _localId = getInitParameter("local-prefix");

    String protocol = getInitParameter("protocol");
    if (protocol == null) protocol = getInitParameter("protocol-container");
    if (protocol == null) protocol = getInitParameter("protocol-factory");
    if (protocol == null) protocol = getDefaultProtocolContainer();

    try {
      Class cl = CauchoSystem.loadClass(protocol);

      _protocolContainer = (ProtocolContainer) cl.newInstance();
    } catch (Exception e) {
      throw new ServletException(e);
    }

    WebApp app = (WebApp) getServletContext();

    // need to initialize in the case of message driven beans.
    // if (containerId == null)
    //  containerId = app.getURL();

    initEjb();

    if (_urlPrefix != null) initProtocol();
  }
 public void init(com.caucho.vfs.Path appDir) throws javax.servlet.ServletException {
   com.caucho.vfs.Path resinHome = com.caucho.server.util.CauchoSystem.getResinHome();
   com.caucho.vfs.MergePath mergePath = new com.caucho.vfs.MergePath();
   mergePath.addMergePath(appDir);
   mergePath.addMergePath(resinHome);
   com.caucho.loader.DynamicClassLoader loader;
   loader = (com.caucho.loader.DynamicClassLoader) getClass().getClassLoader();
   String resourcePath = loader.getResourcePathSpecificFirst();
   mergePath.addClassPath(resourcePath);
   com.caucho.vfs.Depend depend;
   depend =
       new com.caucho.vfs.Depend(appDir.lookup("Coach/AddCoach.jsp"), 9120939392708460488L, false);
   _caucho_depends.add(depend);
 }
Beispiel #10
0
  public static void appendEnvPath(Map<String, String> env, String prop, String value) {
    String oldValue = env.get(prop);

    if (oldValue == null && CauchoSystem.isWindows()) {
      String winProp = prop.toUpperCase(Locale.ENGLISH);
      oldValue = env.get(winProp);

      if (oldValue != null) prop = winProp;
    }

    if (oldValue != null && !"".equals(oldValue)) value = value + File.pathSeparator + oldValue;

    env.put(prop, value);
  }
  static Expr create(Block block, Expr rawExpr, String name) {
    ClassLoader loader = block.getClassLoader();

    try {
      Class cl;

      cl = CauchoSystem.loadClass(name, false, loader);

      if (Modifier.isPublic(cl.getModifiers())) return new JavaClassExpr(block, cl);
    } catch (Throwable e) {
    }

    return new PackageExpr(block, rawExpr, name);
  }
Beispiel #12
0
 public void init(com.caucho.vfs.Path appDir) throws javax.servlet.ServletException {
   com.caucho.vfs.Path resinHome = com.caucho.server.util.CauchoSystem.getResinHome();
   com.caucho.vfs.MergePath mergePath = new com.caucho.vfs.MergePath();
   mergePath.addMergePath(appDir);
   mergePath.addMergePath(resinHome);
   com.caucho.loader.DynamicClassLoader loader;
   loader = (com.caucho.loader.DynamicClassLoader) getClass().getClassLoader();
   String resourcePath = loader.getResourcePathSpecificFirst();
   mergePath.addClassPath(resourcePath);
   com.caucho.vfs.Depend depend;
   depend =
       new com.caucho.vfs.Depend(
           appDir.lookup("WEB-INF/jsp/error.jsp"), -6469239493088807450L, false);
   com.caucho.jsp.JavaPage.addDepend(_caucho_depends, depend);
 }
 public void init(com.caucho.vfs.Path appDir)
   throws javax.servlet.ServletException
 {
   com.caucho.vfs.Path resinHome = com.caucho.server.util.CauchoSystem.getResinHome();
   com.caucho.vfs.MergePath mergePath = new com.caucho.vfs.MergePath();
   mergePath.addMergePath(appDir);
   mergePath.addMergePath(resinHome);
   com.caucho.loader.DynamicClassLoader loader;
   loader = (com.caucho.loader.DynamicClassLoader) getClass().getClassLoader();
   String resourcePath = loader.getResourcePathSpecificFirst();
   mergePath.addClassPath(resourcePath);
   com.caucho.vfs.Depend depend;
   depend = new com.caucho.vfs.Depend(appDir.lookup("order/download.jsp"), -8925709412953061948L, false);
   com.caucho.jsp.JavaPage.addDepend(_caucho_depends, depend);
 }
 public void init(com.caucho.vfs.Path appDir) throws javax.servlet.ServletException {
   com.caucho.vfs.Path resinHome = com.caucho.server.util.CauchoSystem.getResinHome();
   com.caucho.vfs.MergePath mergePath = new com.caucho.vfs.MergePath();
   mergePath.addMergePath(appDir);
   mergePath.addMergePath(resinHome);
   com.caucho.loader.DynamicClassLoader loader;
   loader = (com.caucho.loader.DynamicClassLoader) getClass().getClassLoader();
   String resourcePath = loader.getResourcePathSpecificFirst();
   mergePath.addClassPath(resourcePath);
   com.caucho.vfs.Depend depend;
   depend =
       new com.caucho.vfs.Depend(
           appDir.lookup("Survey_RatingList.jsp"), 4990420660777494174L, false);
   _caucho_depends.add(depend);
 }
 public void init(com.caucho.vfs.Path appDir) throws javax.servlet.ServletException {
   com.caucho.vfs.Path resinHome = com.caucho.server.util.CauchoSystem.getResinHome();
   com.caucho.vfs.MergePath mergePath = new com.caucho.vfs.MergePath();
   mergePath.addMergePath(appDir);
   mergePath.addMergePath(resinHome);
   com.caucho.loader.DynamicClassLoader loader;
   loader = (com.caucho.loader.DynamicClassLoader) getClass().getClassLoader();
   String resourcePath = loader.getResourcePathSpecificFirst();
   mergePath.addClassPath(resourcePath);
   com.caucho.vfs.Depend depend;
   depend =
       new com.caucho.vfs.Depend(appDir.lookup("EthnicGroup.jsp"), 6847378287986436659L, false);
   _caucho_depends.add(depend);
   depend = new com.caucho.vfs.Depend(appDir.lookup("Footer.jsp"), -3074380813858324039L, false);
   _caucho_depends.add(depend);
 }
 public void init(com.caucho.vfs.Path appDir) throws javax.servlet.ServletException {
   com.caucho.vfs.Path resinHome = com.caucho.server.util.CauchoSystem.getResinHome();
   com.caucho.vfs.MergePath mergePath = new com.caucho.vfs.MergePath();
   mergePath.addMergePath(appDir);
   mergePath.addMergePath(resinHome);
   com.caucho.loader.DynamicClassLoader loader;
   loader = (com.caucho.loader.DynamicClassLoader) getClass().getClassLoader();
   String resourcePath = loader.getResourcePathSpecificFirst();
   mergePath.addClassPath(resourcePath);
   com.caucho.vfs.Depend depend;
   depend =
       new com.caucho.vfs.Depend(appDir.lookup("tweetSearch.jsp"), -3076669215319968785L, false);
   _caucho_depends.add(depend);
   depend = new com.caucho.vfs.Depend(appDir.lookup("header.jsp"), 7773134504633206276L, false);
   _caucho_depends.add(depend);
 }
 public void init(com.caucho.vfs.Path appDir) throws javax.servlet.ServletException {
   com.caucho.vfs.Path resinHome = com.caucho.server.util.CauchoSystem.getResinHome();
   com.caucho.vfs.MergePath mergePath = new com.caucho.vfs.MergePath();
   mergePath.addMergePath(appDir);
   mergePath.addMergePath(resinHome);
   com.caucho.loader.DynamicClassLoader loader;
   loader = (com.caucho.loader.DynamicClassLoader) getClass().getClassLoader();
   String resourcePath = loader.getResourcePathSpecificFirst();
   mergePath.addClassPath(resourcePath);
   com.caucho.vfs.Depend depend;
   depend = new com.caucho.vfs.Depend(appDir.lookup("initpass.jsp"), 7048575714632404679L, false);
   com.caucho.jsp.JavaPage.addDepend(_caucho_depends, depend);
   depend =
       new com.caucho.vfs.Depend(appDir.lookup("login_check.jsp"), 5313538553479869376L, false);
   com.caucho.jsp.JavaPage.addDepend(_caucho_depends, depend);
 }
  public void init() throws ServletException {
    super.init();

    try {
      Class cl = _service.getClass();

      if (cl.isAnnotationPresent(WebService.class)) {
        WebService webService = (WebService) cl.getAnnotation(WebService.class);

        String endpoint = webService.endpointInterface();

        if (endpoint != null && !"".equals(endpoint))
          cl = CauchoSystem.loadClass(webService.endpointInterface());
      }

      ArrayList<Class> jaxbClasses = _jaxbClasses;

      for (Method method : cl.getMethods()) {
        if (method.getDeclaringClass().equals(Object.class)) continue;

        int modifiers = method.getModifiers();

        // Allow abstract for interfaces
        if (Modifier.isStatic(modifiers)
            || Modifier.isFinal(modifiers)
            || !Modifier.isPublic(modifiers)) continue;

        if (_context == null) JAXBUtil.introspectMethod(method, jaxbClasses);
      }

      if (_context != null) {
      } else if (_jaxbPackages != null) {
        _context = JAXBContext.newInstance(_jaxbPackages);
      } else {
        Class[] classes = jaxbClasses.toArray(new Class[jaxbClasses.size()]);
        _context = JAXBContext.newInstance(classes);
      }

      _marshaller = _context.createMarshaller();
      _marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
      _unmarshaller = _context.createUnmarshaller();
    } catch (Exception e) {
      throw new ServletException(e);
    }
  }
Beispiel #19
0
 public void init(com.caucho.vfs.Path appDir) throws javax.servlet.ServletException {
   com.caucho.vfs.Path resinHome = com.caucho.server.util.CauchoSystem.getResinHome();
   com.caucho.vfs.MergePath mergePath = new com.caucho.vfs.MergePath();
   mergePath.addMergePath(appDir);
   mergePath.addMergePath(resinHome);
   com.caucho.loader.DynamicClassLoader loader;
   loader = (com.caucho.loader.DynamicClassLoader) getClass().getClassLoader();
   String resourcePath = loader.getResourcePathSpecificFirst();
   mergePath.addClassPath(resourcePath);
   com.caucho.vfs.Depend depend;
   depend = new com.caucho.vfs.Depend(appDir.lookup("bms/info.jsp"), -3507448949258287785L, false);
   com.caucho.jsp.JavaPage.addDepend(_caucho_depends, depend);
   depend =
       new com.caucho.vfs.Depend(
           appDir.lookup("WEB-INF/tld/MyTld.tld"), 2313055599944075409L, false);
   com.caucho.jsp.JavaPage.addDepend(_caucho_depends, depend);
   com.caucho.jsp.JavaPage.addDepend(
       _caucho_depends,
       new com.caucho.make.ClassDependency(dms.tag.CategorySelectTag.class, 4895540770968086576L));
   com.caucho.jsp.JavaPage.addDepend(
       _caucho_depends,
       new com.caucho.make.ClassDependency(dms.tag.CitySelectTag.class, -8095317528224568575L));
   com.caucho.jsp.JavaPage.addDepend(
       _caucho_depends,
       new com.caucho.make.ClassDependency(dms.tag.DomainSelectTag.class, -6906637344929707994L));
   com.caucho.jsp.JavaPage.addDepend(
       _caucho_depends,
       new com.caucho.make.ClassDependency(dms.tag.ServiceSelectTag.class, 1551605886958229292L));
   com.caucho.jsp.JavaPage.addDepend(
       _caucho_depends,
       new com.caucho.make.ClassDependency(dms.tag.GroupSelectTag.class, 8341835262871728445L));
   depend =
       new com.caucho.vfs.Depend(appDir.lookup("WEB-INF/tld/fmt.tld"), 308338869353100094L, false);
   com.caucho.jsp.JavaPage.addDepend(_caucho_depends, depend);
   com.caucho.jsp.JavaPage.addDepend(
       _caucho_depends,
       new com.caucho.make.ClassDependency(
           org.apache.taglibs.standard.tag.rt.fmt.FormatDateTag.class, 7844905413159918656L));
 }
Beispiel #20
0
  /** Finds the web-app matching the current entry. */
  public WebAppUriMap findEntryByURI(String uri) {
    if (_appDeploy.isModified()) _uriToAppCache.clear();

    WebAppUriMap entry = _uriToAppCache.get(uri);

    if (entry != null) return entry;

    String cleanUri = uri;
    if (CauchoSystem.isCaseInsensitive()) cleanUri = cleanUri.toLowerCase(Locale.ENGLISH);

    // server/105w
    try {
      cleanUri = getInvocationDecoder().normalizeUri(cleanUri);
    } catch (java.io.IOException e) {
      log.log(Level.FINER, e.toString(), e);
    }

    entry = findByURIImpl(cleanUri);

    _uriToAppCache.put(uri, entry);

    return entry;
  }
  /** Parses the access log string. */
  private ArrayList<Segment> parseFormat(String format) {
    ArrayList<Segment> segments = new ArrayList<Segment>();
    CharBuffer cb = new CharBuffer();

    int i = 0;
    while (i < _format.length()) {
      char ch = _format.charAt(i++);

      if (ch != '%' || i >= _format.length()) {
        cb.append((char) ch);
        continue;
      }

      String arg = null;
      ch = _format.charAt(i++);
      if (ch == '>') ch = _format.charAt(i++);
      else if (ch == '{') {
        if (cb.length() > 0) segments.add(new Segment(this, Segment.TEXT, cb.toString()));
        cb.clear();
        while (i < _format.length() && _format.charAt(i++) != '}') cb.append(_format.charAt(i - 1));
        arg = cb.toString();
        cb.clear();

        ch = _format.charAt(i++);
      }

      switch (ch) {
        case 'b':
        case 'c':
        case 'h':
        case 'i':
        case 'l':
        case 'n':
        case 'r':
        case 's':
        case 'T':
        case 'D':
        case 'o':
        case 'u':
        case 'U':
        case 'v':
          if (cb.length() > 0) segments.add(new Segment(this, Segment.TEXT, cb.toString()));
          cb.clear();
          segments.add(new Segment(this, ch, arg));
          break;

        case 't':
          if (cb.length() > 0) segments.add(new Segment(this, Segment.TEXT, cb.toString()));
          cb.clear();
          if (arg != null) _timeFormat = arg;
          segments.add(new Segment(this, ch, arg));
          break;

        default:
          cb.append('%');
          i--;
          break;
      }
    }

    cb.append(CauchoSystem.getNewlineString());
    segments.add(new Segment(this, Segment.TEXT, cb.toString()));

    return segments;
  }
 /** Gets the working directory. */
 public Path getWorkPath() {
   if (_workPath != null) return _workPath;
   else return CauchoSystem.getWorkPath();
 }
  /**
   * Adds an attribute.
   *
   * @param name the attribute name
   * @param value the attribute value
   */
  public void addAttribute(QName name, String value) throws JspParseException {
    if (IS_EL_IGNORED.equals(name)) {
      boolean isIgnored = value.equals("true");

      if (_parseState.isELIgnoredPageSpecified() && isIgnored != _parseState.isELIgnored())
        throw error(L.l("isELIgnored values conflict"));

      _parseState.setELIgnored(isIgnored);
      _parseState.setELIgnoredPageSpecified(true);
    }

    /*
    else if (name.equals("isScriptingInvalid"))
      _parseState.setScriptingInvalid(value.equals("true"));
    */
    else if (IS_VELOCITY_ENABLED.equals(name)) _parseState.setVelocityEnabled(value.equals("true"));
    else if (INFO.equals(name)) {
      String oldInfo = _parseState.getInfo();

      if (oldInfo != null && !value.equals(oldInfo))
        throw error(
            L.l(
                "info '{0}' conflicts with previous value of info '{1}'.  Check the .jsp and any included .jsp files for conflicts.",
                value, oldInfo));

      _parseState.setInfo(value);
    } else if (CONTENT_TYPE.equals(name)) {
      String oldContentType = _parseState.getContentType();

      if (oldContentType != null && !value.equals(oldContentType))
        throw error(
            L.l(
                "contentType '{0}' conflicts with previous value of contentType '{1}'.  Check the .jsp and any included .jsp files for conflicts.",
                value, oldContentType));

      _parseState.setContentType(value);
      String charEncoding = parseCharEncoding(value);
      if (charEncoding != null) _parseState.setCharEncoding(charEncoding);
    } else if (PAGE_ENCODING.equals(name)) {
      String oldEncoding = _parseState.getPageEncoding();

      /*
           // jsp/01f1
           if (oldEncoding != null) {
      String oldCanonical = Encoding.getMimeName(oldEncoding);
      String newCanonical = Encoding.getMimeName(value);

      if (! newCanonical.equals(oldCanonical))
        throw error(L.l("pageEncoding '{0}' conflicts with previous value of pageEncoding '{1}'.  Check the .jsp and any included .jsp files for conflicts.", value, oldEncoding));
           }
           */

      try {
        _parseState.setPageEncoding(value);
        // _parseState.setCharEncoding(value);
      } catch (JspParseException e) {
        log.log(Level.FINER, e.toString(), e);

        throw error(e.getMessage());
      }
    } else if (LANGUAGE.equals(name)) {
      if (!value.equals("java"))
        throw error(L.l("'{0}' is not supported as a JSP scripting language.", value));
    } else if (IMPORT.equals(name)) {
      _parseState.addImport(value);
    } else if (SESSION.equals(name)) {
      boolean isValid = false;

      if (value.equals("true")) isValid = _parseState.setSession(true);
      else if (value.equals("false")) isValid = _parseState.setSession(false);
      else throw error(L.l("session expects 'true' or 'false' at '{0}'", value));

      _parseState.markSessionSet();

      if (!isValid) throw error(L.l("session is assigned different values."));
    } else if (BUFFER.equals(name)) {
      boolean isValid = _parseState.setBuffer(processBufferSize(value));

      _parseState.markBufferSet();

      if (!isValid) throw error(L.l("buffer is assigned different values."));

      if (_parseState.getBuffer() == 0 && !_parseState.isAutoFlush())
        throw error(L.l("buffer must be non-zero when autoFlush is false."));
    } else if (ERROR_PAGE.equals(name)) {
      String errorPage = _parseState.getErrorPage();

      String newErrorPage = getRelativeUrl(value);

      _parseState.setErrorPage(newErrorPage);

      if (errorPage != null && !errorPage.equals(newErrorPage)) {
        _parseState.setErrorPage(null);
        throw error(L.l("errorPage is assigned different value '{0}'.", newErrorPage));
      }
    } else if (IS_ERROR_PAGE.equals(name)) {
      boolean isValid = false;

      if (value.equals("true")) isValid = _parseState.setErrorPage(true);
      else if (value.equals("false")) isValid = _parseState.setErrorPage(false);
      else throw error(L.l("isErrorPage expects 'true' or 'false' at '{0}'", value));

      _parseState.markErrorPage();

      if (!isValid) throw error(L.l("isErrorPage is assigned different values."));
    } else if (AUTO_FLUSH.equals(name)) {
      boolean isValid = false;

      if (value.equals("true")) isValid = _parseState.setAutoFlush(true);
      else if (value.equals("false")) isValid = _parseState.setAutoFlush(false);
      else throw error(L.l("autoFlush expects 'true' or 'false' at '{0}'", value));

      if (!isValid) throw error(L.l("autoFlush is assigned different values."));

      if (_parseState.getBuffer() == 0 && !_parseState.isAutoFlush())
        throw error(L.l("buffer must be non-zero when autoFlush is false."));

      _parseState.markAutoFlushSet();
    } else if (IS_THREAD_SAFE.equals(name)) {
      boolean isValid = false;

      if (value.equals("true")) isValid = _parseState.setThreadSafe(true);
      else if (value.equals("false")) isValid = _parseState.setThreadSafe(false);
      else throw error(L.l("isThreadSafe expects 'true' or 'false' at '{0}'", value));

      _parseState.markThreadSafeSet();

      if (!isValid) throw error(L.l("isThreadSafe is assigned different values."));
    } else if (EXTENDS.equals(name)) {
      Class cl = null;

      try {
        cl = CauchoSystem.loadClass(value);
      } catch (Exception e) {
        throw error(e);
      }

      if (!HttpJspPage.class.isAssignableFrom(cl))
        throw error(
            L.l(
                "'{0}' must implement HttpJspPage.  The class named by jsp:directive.page extends='...' must implement HttpJspPage.",
                value));

      Class oldExtends = _parseState.getExtends();

      if (oldExtends != null && !cl.equals(oldExtends))
        throw error(
            L.l(
                "extends '{0}' conflicts with previous value of extends '{1}'.  Check the .jsp and any included .jsp files for conflicts.",
                value, oldExtends.getName()));

      _parseState.setExtends(cl);
    } else if (TRIM_WS.equals(name)) {
      if (value.equals("true")) _parseState.setTrimWhitespace(true);
      else if (value.equals("false")) _parseState.setTrimWhitespace(false);
      else throw error(L.l("trimDirectiveWhitespaces expects 'true' or 'false' at '{0}'", value));
    } else if (DEFER.equals(name)) {
      if (value.equals("true")) _parseState.setDeferredSyntaxAllowedAsLiteral(true);
      else if (value.equals("false")) _parseState.setDeferredSyntaxAllowedAsLiteral(false);
      else
        throw error(
            L.l("deferredSyntaxAllowedAsLiteral expects 'true' or 'false' at '{0}'", value));
    } else {
      throw error(
          L.l(
              "'{0}' is an unknown JSP page directive attribute.  See the JSP documentation for a complete list of page directive attributes.",
              name.getName()));
    }
  }
Beispiel #24
0
  public Process launchManager(String[] argv) throws IOException {
    System.out.println(
        L.l(
            "Resin/{0} launching watchdog at {1}:{2}",
            VersionFactory.getVersion(), getWatchdogAddress(), getWatchdogPort()));

    log.fine(this + " starting ResinWatchdogManager");

    Path resinHome = getResinHome();
    Path resinRoot = getRootDirectory();

    ProcessBuilder builder = new ProcessBuilder();

    builder.directory(new File(resinRoot.getNativePath()));

    Map<String, String> env = builder.environment();

    env.putAll(System.getenv());

    String classPath = WatchdogArgs.calculateClassPath(resinHome);

    env.put("CLASSPATH", classPath);

    String libexecPath;

    if (is64bit()) {
      libexecPath = resinHome.lookup("libexec64").getNativePath();

      appendEnvPath(env, "LD_LIBRARY_PATH", libexecPath);
      appendEnvPath(env, "LD_LIBRARY_PATH_64", libexecPath);
      appendEnvPath(env, "DYLD_LIBRARY_PATH", libexecPath);
      if (CauchoSystem.isWindows())
        appendEnvPath(env, "Path", resinHome.lookup("win64").getNativePath());
    } else {
      libexecPath = resinHome.lookup("libexec").getNativePath();

      appendEnvPath(env, "LD_LIBRARY_PATH", libexecPath);
      appendEnvPath(env, "DYLD_LIBRARY_PATH", libexecPath);
      if (CauchoSystem.isWindows())
        appendEnvPath(env, "Path", resinHome.lookup("win32").getNativePath());
    }

    ArrayList<String> list = new ArrayList<String>();

    list.add(_config.getJavaExe());

    // #3759 - user args are first so they're displayed by ps
    list.addAll(_config.getWatchdogJvmArgs());

    list.add("-Dresin.watchdog=" + _id);
    list.add("-Djava.util.logging.manager=com.caucho.log.LogManagerImpl");
    list.add("-Djavax.management.builder.initial=com.caucho.jmx.MBeanServerBuilderImpl");
    list.add("-Djava.awt.headless=true");
    list.add("-Dresin.home=" + resinHome.getFullPath());
    list.add("-Dresin.root=" + resinRoot.getFullPath());

    for (int i = 0; i < argv.length; i++) {
      if (argv[i].startsWith("-Djava.class.path=")) {
        // IBM JDK startup issues
      } else if (argv[i].startsWith("-J")) {
        list.add(argv[i].substring(2));
      }
    }

    // #2566
    list.add("-Xrs");

    if (!_config.hasWatchdogXss()) list.add("-Xss256k");
    if (!_config.hasWatchdogXmx()) list.add("-Xmx32m");

    // XXX: can this just be copied from original args?
    if (!list.contains("-d32")
        && !list.contains("-d64")
        && is64bit()
        && !CauchoSystem.isWindows()) {
      list.add("-d64");
    }

    if (!list.contains("-server") && !list.contains("-client") && !CauchoSystem.isWindows()) {
      // #3331, windows can't add -server automatically
      list.add("-server");
    }

    list.add("com.caucho.boot.WatchdogManager");

    for (int i = 0; i < argv.length; i++) {
      if (argv[i].equals("-conf") || argv[i].equals("--conf")) {
        list.add(argv[i]);
        list.add(resinHome.lookup(argv[i + 1]).getNativePath());
        i++;
      } else list.add(argv[i]);
    }

    list.add("--log-directory");
    list.add(getLogDirectory().getFullPath());

    builder = builder.command(list);

    // builder.redirectErrorStream(true);

    Process process = null;

    try {
      process = builder.start();
    } catch (Exception e) {
      e.printStackTrace();
    }

    InputStream stdIs = process.getInputStream();
    InputStream stdErr = process.getErrorStream();
    OutputStream stdOs = process.getOutputStream();

    ProcessThreadReader reader = new ProcessThreadReader(stdIs);
    reader.setDaemon(true);
    reader.start();

    ProcessThreadReader errorReader = new ProcessThreadReader(stdErr);
    errorReader.setDaemon(true);
    errorReader.start();

    try {
      Thread.sleep(1000);
    } catch (Exception e) {

    }

    // stdIs.close();
    stdOs.close();

    return process;
  }
  /**
   * Loads the compiled stylesheet .class file
   *
   * @param className the mangled classname for the stylesheet
   */
  protected StylesheetImpl loadStylesheet(String systemId, String className) throws Exception {
    LruCache<String, SoftReference<StylesheetImpl>> cache;

    ClassLoader parentLoader = Thread.currentThread().getContextClassLoader();

    cache = _stylesheetCache.getLevel(parentLoader);

    if (cache == null) {
      cache = new LruCache<String, SoftReference<StylesheetImpl>>(256);
      _stylesheetCache.set(cache, parentLoader);
    }

    SoftReference<StylesheetImpl> stylesheetRef;

    stylesheetRef = cache.get(className);

    StylesheetImpl stylesheet = null;

    if (stylesheetRef != null) stylesheet = stylesheetRef.get();

    try {
      if (stylesheet != null && !stylesheet.isModified()) return stylesheet;
    } catch (Throwable e) {
      log.log(Level.FINER, e.toString(), e);
    }

    Path classPath = getWorkPath().lookup(className.replace('.', '/') + ".class");
    if (!classPath.canRead())
      throw new ClassNotFoundException("can't find compiled XSL `" + className + "'");

    DynamicClassLoader loader;
    loader = SimpleLoader.create(parentLoader, getWorkPath(), className);

    Class cl = null;

    // If the loading fails, remove the class because it may be corrupted
    try {
      cl = CauchoSystem.loadClass(className, false, loader);
    } catch (Error e) {
      try {
        classPath.remove();
      } catch (IOException e1) {
        log.log(Level.FINE, e1.toString(), e1);
      }

      throw e;
    }

    stylesheet = (StylesheetImpl) cl.newInstance();
    Path path;

    path = getSearchPath().lookup("").lookup(systemId);
    /*
    try {
    } catch (TransformerException e) {
      log.log(Level.FINE, e.toString(), e);

      path = Vfs.lookup(systemId);
    }
      */

    // stylesheet.init(path);
    stylesheet.init(getStylePath());
    stylesheet.setURIResolver(_uriResolver);

    stylesheetRef = new SoftReference<StylesheetImpl>(stylesheet);
    cache.put(className, stylesheetRef);

    return stylesheet;
  }