Package railo.runtime.type.cfc

Examples of railo.runtime.type.cfc.ComponentAccess


          //Page p = ps.loadPage(pc.getConfig());
          String name=res.getName();
          name=name.substring(0,name.length()-4);
          Page p = ComponentLoader.loadPage(pc, ps,true);
          if(!(p instanceof InterfacePage)){
            ComponentAccess cfc = ComponentLoader.loadComponent(pc, p, ps, name, true,true);
            if(cfc.isPersistent()){
              components.add(cfc);
            }
          }
        }
        catch (PageException e) {
View Full Code Here


      return ((ComponentPro)c).getProperties(onlyPeristent, includeBaseProperties,preferBaseProperties,preferBaseProperties);
    return c.getProperties(onlyPeristent);
  }

  public static ComponentAccess toComponentAccess(Component comp) throws ExpressionException {
    ComponentAccess ca = toComponentAccess(comp, null);
    if(ca!=null) return ca;
    throw new ExpressionException("can't cast class ["+Caster.toClassName(comp)+"] to a class of type ComponentAccess");
  }
View Full Code Here

     * @param done
     * @throws ConverterException
     */
    private void _serializeComponent(Component c, StringBuffer sb, Set<Object> done) throws ConverterException {
     
      ComponentAccess ci;
    try {
      ci = ComponentUtil.toComponentAccess(c);
    } catch (ExpressionException ee) {
      throw new ConverterException(ee.getMessage());
    }
    ComponentWrap cw = new ComponentWrap(Component.ACCESS_PRIVATE,ci)
       
     
      sb.append(goIn());
        try {
          sb.append("evaluateComponent('"+c.getAbsName()+"','"+ComponentUtil.md5(ci)+"',{");
    } catch (Exception e) {
      throw toConverterException(e);
    }
   
    boolean doIt=false;
    Object member;
      {
     
      Iterator<Entry<Key, Object>> it = cw.entryIterator();
          deep++;
          Entry<Key, Object> e;
          while(it.hasNext()) {
              e = it.next();
              member = e.getValue();
              if(member instanceof UDF)continue;
              if(doIt)sb.append(',');
              doIt=true;
              sb.append('\'');
              sb.append(escape(e.getKey().getString()));
              sb.append('\'');
              sb.append(':');
              _serialize(member,sb,done);
          }
          sb.append("}");
          deep--;
    }
        {
          boolean isPeristent=ci.isPersistent();
       
          ComponentScope scope = ci.getComponentScope();
          Iterator<Entry<Key, Object>> it = scope.entryIterator();
            sb.append(",{");
          deep++;
          doIt=false;
          Property p;
View Full Code Here

   * @return serialized component
   * @throws ConverterException
   */
  private String _serializeComponent(Component component, Map<Object,String> done) throws ConverterException {
    StringBuffer sb=new StringBuffer();
    ComponentAccess ca;
    try {
      component=new ComponentWrap(Component.ACCESS_PRIVATE, ca=ComponentUtil.toComponentAccess(component));
    } catch (ExpressionException e1) {
      throw toConverterException(e1);
    }
    boolean isPeristent=ca.isPersistent();
   
   
        deep++;
        Object member;
        Iterator<Key> it = component.keyIterator();
        Collection.Key key;
        while(it.hasNext()) {
          key=it.next();
          member = component.get(key,null);
          if(member instanceof UDF) continue;
          sb.append(goIn()+"<var scope=\"this\" name="+_+key.toString()+_+">");
            sb.append(_serialize(member,done));
            sb.append(goIn()+"</var>");
        }

        Property p;
        Boolean remotingFetch;
      Struct props = ignoreRemotingFetch?null:ComponentUtil.getPropertiesAsStruct(ca,false);
        ComponentScope scope = ca.getComponentScope();
        it=scope.keyIterator();
        while(it.hasNext()) {
          key=Caster.toKey(it.next(),null);
          if(!ignoreRemotingFetch) {
            p=(Property) props.get(key,null);
View Full Code Here

   
    // TLPC
    PageContext pc = ThreadLocalPageContext.get();
   
    // Load comp
    ComponentAccess comp=null;
    try {
      comp = ComponentUtil.toComponentAccess(pc.loadComponent(name));
      if(!ComponentUtil.md5(comp).equals(md5)){
        throw new ConverterException("component ["+name+"] in this enviroment has not the same interface as the component to load, it is possible that one off the components has Functions added dynamicly.");
      }
    }
    catch (ConverterException e) {
      throw e;
    }
    catch (Exception e) {
      throw new ConverterException(e.getMessage());
    }
   
   
    NodeList list=elComp.getChildNodes();
    ComponentScope scope = comp.getComponentScope();
    int len=list.getLength();
    String scopeName;
    Element var,value;
    Collection.Key key;
    for(int i=0;i<len;i++) {
            Node node=list.item(i);
      if(node instanceof Element) {
        var=(Element)node;
        value=getChildElement((Element)node);
        scopeName=var.getAttribute("scope");
        if(value!=null) {
          key=Caster.toKey(var.getAttribute("name"),null);
          if(key==null) continue;
          if("variables".equalsIgnoreCase(scopeName))
            scope.setEL(key,_deserialize(value));
          else
            comp.setEL(key,_deserialize(value));
        }
            }
    }
        return comp;
  }
View Full Code Here

        if(struct instanceof Component){
          Boolean remotingFetch;
          Component cp = (Component)struct;
          boolean isPeristent=false;
          try {
        ComponentAccess ca = ComponentUtil.toComponentAccess(cp);
        isPeristent=ca.isPersistent();
      } catch (ExpressionException ee) {}
     
          Property[] props = cp.getProperties(false);
          ComponentScope scope = cp.getComponentScope();
          for(int i=0;i<props.length;i++) {
View Full Code Here

   * @return serialized component
   * @throws ConverterException
   */
  private String _serializeComponent(Component component, Set<Object> done) throws ConverterException {
    StringBuffer sb=new StringBuffer();
    ComponentAccess ca;
    try {
      component=new ComponentWrap(Component.ACCESS_PRIVATE, ca=ComponentUtil.toComponentAccess(component));
    } catch (ExpressionException e1) {
      throw toConverterException(e1);
    }
    boolean isPeristent=ca.isPersistent();
   
   
        deep++;
        Object member;
        Iterator<Key> it = component.keyIterator();
        Collection.Key key;
        while(it.hasNext()) {
          key=Caster.toKey(it.next(),null);
          member = component.get(key,null);
          if(member instanceof UDF) continue;
          sb.append(goIn()+"<var scope=\"this\" name="+_+key.toString()+_+">");
            sb.append(_serialize(member,done));
            sb.append(goIn()+"</var>");
        }

        Property p;
        Boolean remotingFetch;
      Struct props = ignoreRemotingFetch?null:ComponentUtil.getPropertiesAsStruct(ca,false);
        ComponentScope scope = ca.getComponentScope();
        it=scope.keyIterator();
        while(it.hasNext()) {
          key=Caster.toKey(it.next(),null);
          if(!ignoreRemotingFetch) {
            p=(Property) props.get(key,null);
View Full Code Here

   
    // TLPC
    PageContext pc = ThreadLocalPageContext.get();
   
    // Load comp
    ComponentAccess comp=null;
    try {
      comp = ComponentUtil.toComponentAccess(pc.loadComponent(name));
      if(!ComponentUtil.md5(comp).equals(md5)){
        throw new ConverterException("component ["+name+"] in this enviroment has not the same interface as the component to load, it is possible that one off the components has Functions added dynamicly.");
      }
    }
    catch (ConverterException e) {
      throw e;
    }
    catch (Exception e) {
      throw new ConverterException(e.getMessage());
    }
   
   
    NodeList list=elComp.getChildNodes();
    ComponentScope scope = comp.getComponentScope();
    int len=list.getLength();
    String scopeName;
    Element var,value;
    Collection.Key key;
    for(int i=0;i<len;i++) {
            Node node=list.item(i);
      if(node instanceof Element) {
        var=(Element)node;
        value=getChildElement((Element)node);
        scopeName=var.getAttribute("scope");
        if(value!=null) {
          key=Caster.toKey(var.getAttribute("name"),null);
          if(key==null) continue;
          if("variables".equalsIgnoreCase(scopeName))
            scope.setEL(key,_deserialize(value));
          else
            comp.setEL(key,_deserialize(value));
        }
            }
    }
        return comp;
  }
View Full Code Here

    if(o instanceof UDF) return ((UDF) o).getFunctionArguments();
    return null;
  }
 
  private void callCFCMetaData(PageContext pc, Component cfc, int format) throws IOException, PageException, ConverterException {
    ComponentAccess ca = ComponentUtil.toComponentAccess(cfc);
    ComponentWrap cw = new ComponentWrap(Component.ACCESS_REMOTE,ca)
    ComponentScope scope = cw.getComponentScope();
    Struct udfs=new StructImpl(),sctUDF,sctArg;
    Array arrArg;
    Iterator<Object> it = scope.valueIterator();
View Full Code Here

    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;
        }
      }
      }
      // onRequestEnd
      if(goon.toBooleanValue() && app.contains(pc,ON_REQUEST_END)) {
        try {
          call(app,pci, ON_REQUEST_END, new Object[]{targetPage},false);
        }
        catch(PageException pe){
          pe=handlePageException(pci,app,pe,requestedPage,targetPage,goon);
View Full Code Here

TOP

Related Classes of railo.runtime.type.cfc.ComponentAccess

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.