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;
  }
예제 #2
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();
  }
 /** Gets the working directory. */
 public Path getWorkPath() {
   if (_workPath != null) return _workPath;
   else return CauchoSystem.getWorkPath();
 }