Package railo.runtime.type

Examples of railo.runtime.type.StructImpl


            "you can define a default datasource as attribute [defaultdatasource] of the tag "+Constants.CFAPP_NAME+" or as data member of the "+Constants.APP_CFC+" (this.defaultdatasource=\"mydatasource\";)");
    }
   
   
   
      Struct res=new StructImpl();
    DataSourceManager manager = pageContext.getDataSourceManager();
    DatasourceConnection dc = ds instanceof DataSource?
        manager.getConnection(pageContext,(DataSource)ds,username,password):
        manager.getConnection(pageContext,Caster.toString(ds),username,password);
   
    // create returnValue
    returnValue(dc);
   
    // create SQL
    StringBuilder sql=createSQL();
   

    // add returnValue to params
    if(returnValue!=null){
      params.add(0,returnValue);
    }
   
    SQLImpl _sql=new SQLImpl(sql.toString());
    CallableStatement callStat=null;
    try {
        callStat = dc.getConnection().prepareCall(sql.toString());
            //ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
            //ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
       
        if(blockfactor>0)callStat.setFetchSize(blockfactor);
        if(timeout>0)callStat.setQueryTimeout(timeout);
       
  // set IN register OUT
        Iterator<ProcParamBean> it = params.iterator();
      ProcParamBean param;
      int index=1;
        while(it.hasNext()) {
          param= it.next();
          param.setIndex(index);
          _sql.addItems(new SQLItemImpl(param.getValue()));
          if(param.getDirection()!=ProcParamBean.DIRECTION_OUT) {
            SQLCaster.setValue(pageContext.getTimeZone(),callStat, index, param);
          }
          if(param.getDirection()!=ProcParamBean.DIRECTION_IN) {
            registerOutParameter(callStat,param);
          }
          index++;
      }
       
  // cache
        boolean isFromCache=false;
        boolean hasCached=cachedbefore!=null || cachedafter!=null;
        Object cacheValue=null;
        String dsn = ds instanceof DataSource?((DataSource)ds).getName():Caster.toString(ds);
      if(clearCache) {
        hasCached=false;
        pageContext.getQueryCache().remove(pageContext,_sql,dsn,username,password);
      }
      else if(hasCached) {
        cacheValue = pageContext.getQueryCache().get(pageContext,_sql,dsn,username,password,cachedafter);
      }
      int count=0;
      if(cacheValue==null){
        // execute
        boolean isResult=callStat.execute();
       
          Struct cache=hasCached?new StructImpl():null;
 
          // resultsets
          ProcResultBean result;
         
          index=1;
        do {
            if(isResult){
              ResultSet rs=callStat.getResultSet();
              if(rs!=null) {
              try{
                result=(ProcResultBean) results.get(index++,null);
                if(result!=null) {
                  railo.runtime.type.Query q = new QueryImpl(rs,result.getMaxrows(),result.getName(),pageContext.getTimeZone())
                  count+=q.getRecordcount();
                  setVariable(result.getName(), q);
                  if(hasCached)cache.set(KeyImpl.getInstance(result.getName()), q);
                }
              }
              finally{
                IOUtil.closeEL(rs);
              }
            }
            }
          }
          while((isResult=callStat.getMoreResults()) || (callStat.getUpdateCount() != -1));

          // params
          it = params.iterator();
          while(it.hasNext()) {
            param= it.next();
            if(param.getDirection()!=ProcParamBean.DIRECTION_IN){
              Object value=null;
              if(!StringUtil.isEmpty(param.getVariable())){
                try{
                  value=SQLCaster.toCFType(callStat.getObject(param.getIndex()));
                }
                catch(Throwable t){}
                value=emptyIfNull(value);
               
                if(param==STATUS_CODE) res.set(STATUSCODE, value);
                else setVariable(param.getVariable(), value);
                if(hasCached)cache.set(KeyImpl.getInstance(param.getVariable()), value);
              }
            }
        }
          if(hasCached){
            cache.set(COUNT, Caster.toDouble(count));
            pageContext.getQueryCache().set(pageContext,_sql,dsn,username,password,cache,cachedbefore);
          }
         
      }
      else if(cacheValue instanceof Struct) {
        Struct sctCache = (Struct) cacheValue;
        count=Caster.toIntValue(sctCache.removeEL(COUNT),0);
       
        Iterator<Entry<Key, Object>> cit = sctCache.entryIterator();
        Entry<Key, Object> ce;
        while(cit.hasNext()){
          ce = cit.next();
          if(STATUS_CODE.getVariable().equals(ce.getKey().getString()))
            res.set(KEY_SC, ce.getValue());
          else setVariable(ce.getKey().getString(), ce.getValue());
        }
        isFromCache=true;
      }
     
        // result
        long exe;
       
        setVariable(this.result, res);
        res.set(KeyConstants._executionTime,Caster.toDouble(exe=(System.nanoTime()-startNS)));
        res.set(KeyConstants._cached,Caster.toBoolean(isFromCache));
       
        if(pageContext.getConfig().debug() && debug) {
          boolean logdb=((ConfigImpl)pageContext.getConfig()).hasDebugOptions(ConfigImpl.DEBUG_DATABASE);
        if(logdb)
          pageContext.getDebugger().addQuery(null,dsn,procedure,_sql,count,pageContext.getCurrentPageSource(),(int)exe);
View Full Code Here


     */
    private void setCFLogin(Object username, Object password) {
        if(username==null) return;
        if(password==null) password="";
       
        Struct sct=new StructImpl();
        sct.setEL(KeyConstants._name,username);
        sct.setEL(KeyConstants._password,password);
        pageContext.undefinedScope().setEL(CFLOGIN,sct);
    }
View Full Code Here

 
    /**
    * constructor for the tag class
    **/
    public CFTag() {
      attributesScope = new StructImpl();
        callerScope = new CallerImpl();
        //thistagScope = new StructImpl();
    }
View Full Code Here

        super.release();

        hasBody=false;
        //filename=null;     

        attributesScope=new StructImpl();//.clear();
        callerScope = new CallerImpl();
        if(thistagScope!=null)thistagScope=null;
        if(ctVariablesScope!=null)ctVariablesScope=null
       
View Full Code Here

   
  private int cfmlStartTag() throws PageException {
    callerScope.initialize(pageContext);
       
    // thistag
    if(thistagScope==null)thistagScope=new StructImpl(StructImpl.TYPE_LINKED);
        thistagScope.set(GENERATED_CONTENT,"");
        thistagScope.set(EXECUTION_MODE,"start");     
        thistagScope.set(EXECUTE_BODY,Boolean.TRUE);
        thistagScope.set(KeyConstants._HASENDTAG,Caster.toBoolean(hasBody));
       
View Full Code Here

      if(cfc.contains(pageContext, KeyConstants._init)){
            Tag parent=getParent();
            while(parent!=null && !(parent instanceof CFTag && ((CFTag)parent).isCFCBasedCustomTag())) {
            parent=parent.getParent();
          }
        Struct args=new StructImpl(StructImpl.TYPE_LINKED);
        args.set(KeyConstants._HASENDTAG, Caster.toBoolean(hasBody));
          if(parent instanceof CFTag) {
            args.set(PARENT, ((CFTag)parent).getComponent());
          }
            rtn=cfc.callWithNamedValues(pageContext, KeyConstants._init, args);
          }
     
          if(cfc.contains(pageContext, ON_START_TAG)){
            Struct args=new StructImpl();
            args.set(KeyConstants._ATTRIBUTES, attributesScope);
            setCaller(pageContext,args);
           
            rtn=cfc.callWithNamedValues(pageContext, ON_START_TAG, args)
        }
          exeBody=Caster.toBooleanValue(rtn,true);
View Full Code Here

          try {
              output=bodyContent.getString();
                bodyContent.clearBody();
                //rtn=cfc.call(pageContext, ON_END_TAG, new Object[]{attributesScope,pageContext.variablesScope(),output});
               
                Struct args=new StructImpl(StructImpl.TYPE_LINKED);
              args.set(KeyConstants._ATTRIBUTES, attributesScope);
              setCaller(pageContext, args);
              args.set(GENERATED_CONTENT, output);
              rtn=cfc.callWithNamedValues(pageContext, ON_END_TAG, args)
         
               
               
            }
View Full Code Here

      try {
      if(cfc.contains(pageContext, ON_ERROR)){
            PageException pe = Caster.toPageException(t);
            //Object rtn=cfc.call(pageContext, ON_ERROR, new Object[]{pe.getCatchBlock(pageContext),source});
         
            Struct args=new StructImpl(StructImpl.TYPE_LINKED);
            args.set(CFCATCH, pe.getCatchBlock(ThreadLocalPageContext.getConfig(pageContext)));
            args.set(SOURCE, source);
            Object rtn=cfc.callWithNamedValues(pageContext, ON_ERROR, args)
       
            if(Caster.toBooleanValue(rtn,false))
          throw t;
          }
View Full Code Here

      Page page=MetadataUtil.getPageWhenMetaDataStillValid(pc, comp, ignoreCache);
      if(page!=null && page.metaData!=null && page.metaData.get()!=null){
        return page.metaData.get();
      }
      long creationTime=System.currentTimeMillis();
      StructImpl sct=new StructImpl();
     
        // fill udfs
        metaUDFs(pc, comp, sct,access);
       
        // meta
        if(comp.properties.meta!=null)
          StructUtil.copy(comp.properties.meta, sct, true);
           
        String hint=comp.properties.hint;
        String displayname=comp.properties.dspName;
        if(!StringUtil.isEmpty(hint))sct.set(KeyConstants._hint,hint);
        if(!StringUtil.isEmpty(displayname))sct.set(KeyConstants._displayname,displayname);
       
        sct.set(KeyConstants._persistent,comp.properties.persistent);
        sct.set(KeyConstants._hashCode,comp.hashCode());
        sct.set(KeyConstants._accessors,comp.properties.accessors);
        sct.set(KeyConstants._synchronized,comp.properties._synchronized);
        if(comp.properties.output!=null)
        sct.set(KeyConstants._output,comp.properties.output);
           
        // extends
        Struct ex=null;
        if(comp.base!=null) ex=getMetaData(access,pc,comp.base,true);
        if(ex!=null)sct.set(KeyConstants._extends,ex);
       
        // implements
        InterfaceCollection ic = comp.interfaceCollection;
        if(ic!=null){
          Set<String> set = ListUtil.listToSet(comp.properties.implement, ",",true);
            InterfaceImpl[] interfaces = comp.interfaceCollection.getInterfaces();
            if(!ArrayUtil.isEmpty(interfaces)){
              Struct imp=new StructImpl();
              for(int i=0;i<interfaces.length;i++){
                if(!set.contains(interfaces[i].getCallPath())) continue;
                //print.e("-"+interfaces[i].getCallPath());
                imp.setEL(KeyImpl.init(interfaces[i].getCallPath()), interfaces[i].getMetaData(pc,true));
              }
              sct.set(KeyConstants._implements,imp);
            }
        }
        
View Full Code Here

    // MUST this is just a workaround
    if(pc==null){
      pcCreated=true;
      ConfigWeb config = (ConfigWeb) ThreadLocalPageContext.getConfig();
      Pair[] parr = new Pair[0];
      pc=ThreadUtil.createPageContext(config, DevNullOutputStream.DEV_NULL_OUTPUT_STREAM, "localhost", "/","", new Cookie[0], parr, parr, new StructImpl());
    }
   
    // reading fails for serialized data from Railo version 4.1.2.002
    String name = in.readUTF();
   
View Full Code Here

TOP

Related Classes of railo.runtime.type.StructImpl

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.