Package com.caucho.quercus.page

Examples of com.caucho.quercus.page.QuercusPage


              StringWriter writer = new StringWriter(new CharBuffer(1024));
              writer.openWrite();
             
              ByteArrayInputStream bais = new ByteArrayInputStream(templateAsString.getBytes());
              VfsStream stream = new VfsStream(bais, null);       
              QuercusPage page = quercus.parse(new ReadStream(stream));
             
              WriteStream ws = new WriteStream(writer);
             
              Env env = quercus.createEnv(page, ws, deliveryContext.getHttpServletRequest(), deliveryContext.getHttpServletResponse());
              env.start();
                         
              Value value = page.executeTop(env);
              ws.flush();

              String output = ((StringWriter)ws.getSource()).getString();           
             
              Object returnObject = value.toJavaObject();
 
              //logger.info("output:" + output);
          pw.println(output);
        }
        catch (Throwable e)
        {
          e.printStackTrace();
      }
    }
      else if(scriptController != null)
      {
        scriptController.getRequest().setAttribute("org.infoglue.cms.deliver.scriptLogic", scriptController);
        scriptController.getRequest().setAttribute("org.infoglue.cms.deliver.portalLogic", portletController);
        scriptController.getRequest().setAttribute("model", model);
        try
        {
          QuercusContext quercus = new QuercusContext();
          quercus.setServletContext(scriptController.getRequest().getSession().getServletContext());
          Path pwd = new FilePath(CmsPropertyHandler.getContextRootPath());
          quercus.setPwd(pwd);
          if (! Alarm.isTest() && ! quercus.isResin()) {
            Vfs.setPwd(pwd);
            WorkDir.setLocalWorkDir(pwd.lookup("WEB-INF/work"));
          }

          quercus.init();
          quercus.start();
         
              StringWriter writer = new StringWriter(new CharBuffer(1024));
              writer.openWrite();
             
              ByteArrayInputStream bais = new ByteArrayInputStream(templateAsString.getBytes());
              VfsStream stream = new VfsStream(bais, null);       
              QuercusPage page = quercus.parse(new ReadStream(stream));
             
              WriteStream ws = new WriteStream(writer);
             
              Env env = quercus.createEnv(page, ws, scriptController.getRequest(), scriptController.getResponse());
              env.start();
                         
              Value value = page.executeTop(env);
              ws.flush();

              String output = ((StringWriter)ws.getSource()).getString();           
             
              Object returnObject = value.toJavaObject();
View Full Code Here


      out = ws;
    } else
      out = new WriteStream(StdoutStream.create());

    QuercusPage page = new InterpretedPage(program);
   
    Env quercus_context = new Env(quercus, page, out, null, null);
    quercus_context.start();
   
    return quercus_context;
View Full Code Here

      out = ws;
    } else
      out = new WriteStream(StdoutStream.create());

    QuercusPage page = new InterpretedPage(program);
    quercus_context = new Env(quercus, page, out, null, null);
    quercus_context.start();
  }
View Full Code Here

    WriteStream ws = null;
   
    try {
      Path path = getPath(request);

      QuercusPage page;

      try {
        page = getQuercus().parse(path);
      }
      catch (FileNotFoundException ex) {
        // php/2001
        log.log(Level.FINER, ex.toString(), ex);

        response.sendError(HttpServletResponse.SC_NOT_FOUND);

        return;
      }

      ws = openWrite(response);
     
      // php/6006
      ws.setNewlineString("\n");

      QuercusContext quercus = getQuercus();
     
      env = quercus.createEnv(page, ws, request, response);
      quercus.setServletContext(_servletContext);
     
      try {
        env.start();
       
        // GoogleAppEngine SDK is missing non-essential Jetty classes
        // (Jetty also hides server classes from webapp)
        //env.setGlobalValue("request", env.wrapJava(request));
        //env.setGlobalValue("response", env.wrapJava(response));
        //env.setGlobalValue("servletContext", env.wrapJava(_servletContext));

        StringValue prepend
          = quercus.getIniValue("auto_prepend_file").toStringValue(env);
        if (prepend.length() > 0) {
          Path prependPath = env.lookup(prepend);
         
          if (prependPath == null)
            env.error(L.l("auto_prepend_file '{0}' not found.", prepend));
          else {
            QuercusPage prependPage = getQuercus().parse(prependPath);
            prependPage.executeTop(env);
          }
        }

        env.executeTop();

        StringValue append
          = quercus.getIniValue("auto_append_file").toStringValue(env);
        if (append.length() > 0) {
          Path appendPath = env.lookup(append);
         
          if (appendPath == null)
            env.error(L.l("auto_append_file '{0}' not found.", append));
          else {
            QuercusPage appendPage = getQuercus().parse(appendPath);
            appendPage.executeTop(env);
          }
        }
        //   return;
      }
      catch (QuercusExitException e) {
View Full Code Here

    WriteStream ws = null;
   
    try {
      Path path = getPath(request);

      QuercusPage page;

      try {
        page = getQuercus().parse(path);
      }
      catch (FileNotFoundException ex) {
        // php/2001
        log.log(Level.FINER, ex.toString(), ex);

        response.sendError(HttpServletResponse.SC_NOT_FOUND);

        return;
      }


      ws = openWrite(response);
     
      // php/6006
      ws.setNewlineString("\n");

      QuercusContext quercus = getQuercus();
     
      env = quercus.createEnv(page, ws, request, response);
      quercus.setServletContext(_servletContext);
     
      try {
        env.start();
       
        // php/2030, php/2032, php/2033
        // Jetty hides server classes from web-app
        // http://docs.codehaus.org/display/JETTY/Classloading
        //
        // env.setGlobalValue("request", env.wrapJava(request));
        // env.setGlobalValue("response", env.wrapJava(response));
        // env.setGlobalValue("servletContext", env.wrapJava(_servletContext));

        StringValue prepend
          = quercus.getIniValue("auto_prepend_file").toStringValue(env);
        if (prepend.length() > 0) {
          Path prependPath = env.lookup(prepend);
         
          if (prependPath == null)
            env.error(L.l("auto_prepend_file '{0}' not found.", prepend));
          else {
            QuercusPage prependPage = getQuercus().parse(prependPath);
            prependPage.executeTop(env);
          }
        }

        env.executeTop();

        StringValue append
          = quercus.getIniValue("auto_append_file").toStringValue(env);
        if (append.length() > 0) {
          Path appendPath = env.lookup(append);
         
          if (appendPath == null)
            env.error(L.l("auto_append_file '{0}' not found.", append));
          else {
            QuercusPage appendPage = getQuercus().parse(appendPath);
            appendPage.executeTop(env);
          }
        }
        //   return;
      }
      catch (QuercusExitException e) {
View Full Code Here

  }

  public void execute(Path path)
    throws IOException
  {
    QuercusPage page = parse(path);

    WriteStream os = new WriteStream(StdoutStream.create());

    os.setNewlineString("\n");
    os.setEncoding("iso-8859-1");
View Full Code Here

  public void execute()
    throws IOException
  {
    Path path = getPwd().lookup(getFileName());
   
    QuercusPage page = parse(path);
   
    WriteStream os = new WriteStream(StdoutStream.create());
     
    os.setNewlineString("\n");
    os.setEncoding("iso-8859-1");
View Full Code Here

      out = ws;
    }
    else
      out = new WriteStream(StdoutStream.create());
   
    QuercusPage page = new InterpretedPage(program);

    Env env = new Env(_quercus, page, out, null, null);
   
    Value value = NullValue.NULL;
   
View Full Code Here

  out = os;
      }
      else
  out = new NullWriteStream();

      QuercusPage page = new InterpretedPage(_program);

      env = new Env(_engine.getQuercus(), page, out, null, null);

      env.setScriptContext(cxt);
View Full Code Here

        out = os;
      }
      else
        out = new NullWriteStream();

      QuercusPage page = new InterpretedPage(program);

      env = new Env(_quercus, page, out, null, null);

      env.setScriptContext(cxt);
View Full Code Here

TOP

Related Classes of com.caucho.quercus.page.QuercusPage

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.