Package railo.runtime

Examples of railo.runtime.PageContextImpl


    }
  }

  public static boolean execute(PageContext pc, PreparedStatement stat, String sql) throws SQLException {
    if(pc==null) return stat.execute();
    PageContextImpl pci = (PageContextImpl) pc;
    try {
      setActiveStatement(pci,stat,sql);
      return stat.execute();
    }
    finally {
      pci.releaseActiveQuery();
    }
  }
View Full Code Here


    }
  }

  public static ResultSet executeQuery(PageContext pc, PreparedStatement stat, String sql) throws SQLException {
    if(pc==null) return stat.executeQuery();
    PageContextImpl pci = (PageContextImpl) pc;
    try {
      setActiveStatement(pci,stat,sql);
      return stat.executeQuery();
    }
    finally {
      pci.releaseActiveQuery();
    }
  }
View Full Code Here

    }
  }

  public static int executeUpdate(PageContext pc, PreparedStatement stat, String sql) throws SQLException {
    if(pc==null) return stat.executeUpdate();
    PageContextImpl pci = (PageContextImpl) pc;
    try {
      setActiveStatement(pci,stat,sql);
       return stat.executeUpdate();
    }
    finally {
      pci.releaseActiveQuery();
    }
  }
View Full Code Here

            }
      }
     
      // Undefined Scope
      else if(scope instanceof Undefined) {
        PageContextImpl pci=(PageContextImpl) pc;
        Undefined undefined=(Undefined) scope;
       
        boolean check=undefined.getCheckArguments();
        Variables orgVar=pc.variablesScope();
        Argument orgArgs=pc.argumentsScope();
            Local orgLocal=pc.localScope();
       
        pci.setVariablesScope(undefined.variablesScope());
        if(check)pci.setFunctionScopes(undefined.localScope(), undefined.argumentsScope());
            try{
              if(value!=NULL) return setVariable(pc, str,value);
              return getVariable(pc, str);
            }
            finally{
              pc.setVariablesScope(orgVar);
              if(check)pci.setFunctionScopes(orgLocal,orgArgs);
            }
      }
    }
    if(value!=NULL) return setVariable(pc, str,value);
    return getVariable(pc, str);
View Full Code Here

   
    _onRequest(pc, requestedPage, appPS,rl);
  }
 
  protected void _onRequest(PageContext pc, PageSource requestedPage,PageSource appPS, RequestListener rl) throws PageException {
    PageContextImpl pci = (PageContextImpl)pc;
    if(appPS!=null) {
      String callPath=appPS.getComponentName();
     
     
      ComponentAccess app = ComponentLoader.loadComponent(pci,null,appPS, callPath, false,false);
     
      // init
      initApplicationContext(pci,app);
       
     
      apps.put(pc.getApplicationContext().getName(), app);

      if(!pci.initApplicationContext(this)) return;
     
      if(rl!=null) {
        requestedPage=rl.execute(pc, requestedPage);
        if(requestedPage==null) return;
      }
     
      String targetPage=requestedPage.getFullRealpath();
      RefBoolean goon=new RefBooleanImpl(true);
     
      // onRequestStart
      if(app.contains(pc,ON_REQUEST_START)) {
        try {
          Object rtn=call(app,pci, ON_REQUEST_START, new Object[]{targetPage},false);
          if(!Caster.toBooleanValue(rtn,true))
            return;
        }
        catch(PageException pe){
          pe=handlePageException(pci,app,pe,requestedPage,targetPage,goon);
          if(pe!=null) throw pe;
        }
      }
       
      // onRequest
      if(goon.toBooleanValue()) {
      boolean isCFC=ResourceUtil.getExtension(targetPage,"").equalsIgnoreCase(pc.getConfig().getCFCExtension());
      Object method;
      if(isCFC && app.contains(pc,ON_CFCREQUEST) && (method=pc.urlFormScope().get(KeyConstants._method,null))!=null) {
       
        Struct url = (Struct)Duplicator.duplicate(pc.urlFormScope(),true);

        url.removeEL(KeyConstants._fieldnames);
        url.removeEL(KeyConstants._method);
       
        Object args=url.get(KeyConstants._argumentCollection,null);
       
        // url returnFormat
        Object oReturnFormat=url.removeEL(KeyConstants._returnFormat);
        int urlReturnFormat=-1;
        if(oReturnFormat!=null) urlReturnFormat=UDFUtil.toReturnFormat(Caster.toString(oReturnFormat,null),-1);
       
        // request header accept
        List<MimeType> accept = ReqRspUtil.getAccept(pc);
        int headerReturnFormat = MimeType.toFormat(accept, -1,-1);

            Object queryFormat=url.removeEL(KeyConstants._queryFormat);
           
            if(args==null){
              args=pc.getHttpServletRequest().getAttribute("argumentCollection");
            }
           
            if(args instanceof String){
              args=new JSONExpressionInterpreter().interpret(pc, (String)args);
            }
           
            if(args!=null) {
              if(Decision.isCastableToStruct(args)){
                Struct sct = Caster.toStruct(args,false);
                //Key[] keys = url.keys();
                Iterator<Entry<Key, Object>> it = url.entryIterator();
                Entry<Key, Object> e;
                while(it.hasNext()){
                  e = it.next();
                  sct.setEL(e.getKey(),e.getValue());
                }
                args=sct;
              }
              else if(Decision.isCastableToArray(args)){
                args = Caster.toArray(args);
              }
              else {
                Array arr = new ArrayImpl();
                arr.appendEL(args);
                args=arr;
              }
            }
            else
              args=url;

            Object rtn = call(app,pci, ON_CFCREQUEST, new Object[]{requestedPage.getComponentName(),method,args},true);
           
            if(rtn!=null){
              if(pc.getHttpServletRequest().getHeader("AMF-Forward")!=null) {
                pc.variablesScope().setEL("AMF-Forward", rtn);
                //ThreadLocalWDDXResult.set(rtn);
              }
              else {
                try {
              ComponentPage.writeToResponseStream(pc,app,method.toString(),urlReturnFormat,headerReturnFormat,queryFormat,rtn);
            } catch (Exception e) {
              throw Caster.toPageException(e);
            }
              }
            }
       
       
      }
      //else if(!isCFC && app.contains(pc,ON_REQUEST)) {}
      else {
        // TODO impl die nicht so generisch ist
        try{

          if(!isCFC && app.contains(pc,ON_REQUEST))
            call(app,pci, ON_REQUEST, new Object[]{targetPage},false);
          else
            pci.doInclude(requestedPage);
        }
        catch(PageException pe){
          pe=handlePageException(pci,app,pe,requestedPage,targetPage,goon);
          if(pe!=null) throw pe;
        }
View Full Code Here

  @Override
  public void onApplicationEnd(CFMLFactory factory, String applicationName) throws PageException {
    ComponentAccess app = apps.get(applicationName);
    if(app==null || !app.containsKey(ON_APPLICATION_END)) return;
   
    PageContextImpl pc=(PageContextImpl) ThreadLocalPageContext.get();
    boolean createPc=pc==null;
    try {
      if(createPc)pc =  createPageContext(factory,app,applicationName,null,ON_APPLICATION_END);
      call(app,pc, ON_APPLICATION_END, new Object[]{pc.applicationScope()},true);
    }
    finally {
      if(createPc && pc!=null){
        factory.releasePageContext(pc);
      }
View Full Code Here

  @Override
  public void onSessionEnd(CFMLFactory factory, String applicationName, String cfid) throws PageException {
    ComponentAccess app = apps.get(applicationName);
    if(app==null || !app.containsKey(ON_SESSION_END)) return;
   
    PageContextImpl pc=null;
    try {
      pc = createPageContext(factory,app,applicationName,cfid,ON_SESSION_END);
      call(app,pc, ON_SESSION_END, new Object[]{pc.sessionScope(false),pc.applicationScope()},true);
    }
    finally {
      if(pc!=null){
        factory.releasePageContext(pc);
      }
View Full Code Here

      // TODO was passiert hier
    }
    HttpServletResponseDummy rsp = new HttpServletResponseDummy(os);
   
    // PageContext
    PageContextImpl pc = (PageContextImpl) factory.getRailoPageContext(factory.getServlet(), req, rsp, null, false, -1, false);
    // ApplicationContext
    ClassicApplicationContext ap = new ClassicApplicationContext(factory.getConfig(),applicationName,false,app==null?null:ResourceUtil.getResource(pc,app.getPageSource(),null));
    initApplicationContext(pc, app);
    ap.setName(applicationName);
    ap.setSetSessionManagement(true);
    //if(!ap.hasName())ap.setName("Controler")
    // Base
    pc.setBase(app.getPageSource());
   
    return pc;
  }
View Full Code Here

    }
    return arr;
  }
 
  private static Set<String> _call(PageContext pc , String packageName) throws IOException, ApplicationException {
    PageContextImpl pci=(PageContextImpl) pc;
    ConfigWebImpl config = (ConfigWebImpl) pc.getConfig();
    Set<String> rtn=null;
    //var SEP=server.separator.file;
   
    // get enviroment configuration
    boolean searchLocal = config.getComponentLocalSearch();
    boolean searchRoot=config.getComponentRootSearch();
   
    String path=StringUtil.replace(packageName, ".", File.separator, false);
       
    // search local
    if(searchLocal) {
      //Resource dir=pc.getCurrentTemplatePageSource().getResourceTranslated(pc).getParentResource();
      //dir=dir.getRealResource(path);
      PageSource ps= pci.getRelativePageSourceExisting(path);
      if(ps!=null){
        Mapping mapping = ps.getMapping();
        String _path=ps.getRealpath();
        _path=ListUtil.trim(_path,"\\/");
        String[] list = _listMapping(pc,mapping,_path);
View Full Code Here

   
    private static void fillGetRunningThreads(railo.runtime.type.Query qry, ConfigWeb configWeb) throws PageException {
      CFMLFactoryImpl factory = ((CFMLFactoryImpl)configWeb.getFactory());
      Struct pcs =factory.getRunningPageContexts();
      Iterator it = pcs.keyIterator();
        PageContextImpl pc;
        Collection.Key key;
        int row=0;
        while(it.hasNext()) {
          key=KeyImpl.toKey(it.next(),null);
            pc=(PageContextImpl) pcs.get(key,null);
            qry.addRow();
            row++;
            StackTraceElement[] st = pc.getThread().getStackTrace();
            configWeb.getConfigDir();
            configWeb.getId();
            configWeb.getConfigDir();
            qry.setAt("Id",row,new Double(pc.getId()));
            qry.setAt("Start",row,new DateTimeImpl(pc.getStartTime(),false));
            qry.setAt("Timeout",row,new Double(pc.getRequestTimeout()/1000));
            qry.setAt("ThreadType",row,pc.getParentPageContext()==null?"main":"child");
            qry.setAt("StackTrace",row,toString(st));
            qry.setAt("TagContext",row,PageExceptionImpl.getTagContext(pc.getConfig(), st));
           
            qry.setAt("label",row,factory.getLabel());
            qry.setAt("RootPath",row,ReqRspUtil.getRootPath(((ConfigWebImpl)configWeb).getServletContext()));
            qry.setAt("ConfigFile",row,configWeb.getConfigFile().getAbsolutePath());
            if(factory.getURL()!=null)qry.setAt("url",row,factory.getURL().toExternalForm());
View Full Code Here

TOP

Related Classes of railo.runtime.PageContextImpl

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.