Package railo.commons.io.res

Examples of railo.commons.io.res.Resource


    PageSource ps = pc.getCurrentPageSource();
   
    StackTraceElement[] traces = pc.getThread().getStackTrace();
    String template="";
    StackTraceElement trace=null;
    Resource res;
   
    for(int i=0;i<traces.length;i++) {
      trace=traces[i];
      if(trace.getLineNumber()<=0) continue;
      template=trace.getFileName();
View Full Code Here


    try {
      cl = (PhysicalClassLoader) pci.getRPCClassLoader(false);// mapping.getConfig().getRPCClassLoader(false)
    } catch (IOException e) {
      throw Caster.toPageException(e);
    }
    Resource classFile = cl.getDirectory().getRealResource(className.concat(".class"));
   
    // check if already exists, if yes return
    if(classFile.exists()) {
      //Object obj=newInstance(cl,className,cfc);
      // if(obj!=null) return obj;
    }
   
    /*
 
View Full Code Here

    return c;
 

  public static java.util.List<Resource> loadCFCLocation(Config config, ApplicationContext ac,Object obj, boolean onlyDir) {
   
    Resource res;
    if(!Decision.isArray(obj)){
      String list = Caster.toString(obj,null);
      if(!StringUtil.isEmpty(list)) {
        obj=ListUtil.listToArray(list, ',');
      }
View Full Code Here

  private static Resource toResourceExisting(Config config, ApplicationContext ac,Object obj, boolean onlyDir) {
    //Resource root = config.getRootDirectory();
    String path = Caster.toString(obj,null);
    if(StringUtil.isEmpty(path,true)) return null;
    path=path.trim();
    Resource res;
    PageContext pc = ThreadLocalPageContext.get();
   
    // first check relative to application.cfc
    if(pc!=null) {
      if(ac==null) ac= pc.getApplicationContext();
     
      // abs path
      if(path.startsWith("/")){
        ConfigWebImpl cwi=(ConfigWebImpl) config;
        PageSource ps = cwi.getPageSourceExisting(
            pc, ac==null?null:ac.getMappings(), path, false, false, true, false);
        //res=cwi.getPhysicalResourceExistingX(
        //    pc,
        //    ac==null?null:ac.getMappings(), path,
        //    false, false, true);
        if(ps!=null){
          res=ps.getResource();
          if(res!=null && (!onlyDir || res.isDirectory())) return res;
        }
       
      }
      // real path
      else {
        Resource src= ac!=null?ac.getSource():null;
        if(src!=null) {
          res=src.getParentResource().getRealResource(path);
          if(res!=null && (!onlyDir || res.isDirectory())) return res;
        }
        // happens when this is called from within the application.cfc (init)
        else {
          res=ResourceUtil.toResourceNotExisting(pc, path);
View Full Code Here

    catch (Throwable t) {}
  }
 
  protected static Resource _loadResource(ConfigWeb config, int type,String name, String cfid) {
    ConfigImpl ci = (ConfigImpl)config;
    Resource dir= type==SCOPE_CLIENT?ci.getClientScopeDir():ci.getSessionScopeDir();
    return   dir.getRealResource(getFolderName(name,cfid,true));
  }
View Full Code Here

   * @param log
   * @return
   */
  public static Client getInstance(String name, PageContext pc, Log log) {

    Resource res=_loadResource(pc.getConfig(),SCOPE_CLIENT,name,pc.getCFID());
    Struct data=_loadData(pc,res,log);
    return new ClientFile(pc,res,data);
  }
View Full Code Here

    try {
      cl = (PhysicalClassLoader) ((PageContextImpl)pc).getRPCClassLoader(false);
    } catch (IOException e) {
      throw Caster.toPageException(e);
    }
    Resource classFile = cl.getDirectory().getRealResource(real.concat(".class"));
    Resource classFileOriginal = mapping.getClassRootDirectory().getRealResource(realOriginal.concat(".class"));
   
  // LOAD CLASS
      //print.out(className);
    // check last Mod
    if(classFile.lastModified()>=classFileOriginal.lastModified()) {
      try {
        Class clazz=cl.loadClass(className);
        if(clazz!=null && !hasChangesOfChildren(classFile.lastModified(),clazz))return registerTypeMapping(clazz);
      }
      catch(Throwable t){}
View Full Code Here

    clazz=ClassUtil.toComponentType(clazz);
    java.lang.reflect.Method m = getComplexTypeMethod(clazz);
    if(m==null) return false;
    try {
      String path=Caster.toString(m.invoke(null, new Object[0]));
      Resource res = ResourceUtil.toResourceExisting(pc, path);
      if(last<res.lastModified()) {
        return true;
      }
    }
    catch (Exception e) {
      return true;
View Full Code Here

     
    PhysicalClassLoader cl;
      if(pc==null)cl = (PhysicalClassLoader)secondChanceConfig.getRPCClassLoader(false);
      else cl = (PhysicalClassLoader)((PageContextImpl)pc).getRPCClassLoader(false);
   
    Resource rootDir = cl.getDirectory();
    Resource classFile = rootDir.getRealResource(real.concat(".class"));
   
    if(classFile.exists()) {
      try {
        Class clazz = cl.loadClass(className);
        Field field = clazz.getField("_md5_");
        if(ASMUtil.createMD5(properties).equals(field.get(null))){
        //if(equalInterface(properties,clazz)) {
          return ClassUtil.loadInstance(clazz);
        }
      }
      catch(Exception e) {
       
      }
    }
    // create file
    byte[] barr = ASMUtil.createPojo(real, properties,Object.class,new Class[]{Pojo.class},null);
      boolean exist=classFile.exists();
    ResourceUtil.touch(classFile);
      IOUtil.copy(new ByteArrayInputStream(barr), classFile,true);
     
      if(pc==null)cl = (PhysicalClassLoader)secondChanceConfig.getRPCClassLoader(exist);
      else cl = (PhysicalClassLoader)((PageContextImpl)pc).getRPCClassLoader(exist);
View Full Code Here

      String real=className.replace('.','/');

      Mapping mapping = component.getPageSource().getMapping();
    PhysicalClassLoader cl = (PhysicalClassLoader)((PageContextImpl)pc).getRPCClassLoader(false);
   
    Resource classFile = cl.getDirectory().getRealResource(real.concat(".class"));
   
      String classNameOriginal=component.getPageSource().getFullClassName();
      String realOriginal=classNameOriginal.replace('.','/');
    Resource classFileOriginal = mapping.getClassRootDirectory().getRealResource(realOriginal.concat(".class"));

    // load existing class
    if(classFile.lastModified()>=classFileOriginal.lastModified()) {
      try {
        Class clazz=cl.loadClass(className);
        if(clazz!=null && !hasChangesOfChildren(classFile.lastModified(), clazz))return clazz;//ClassUtil.loadInstance(clazz);
      }
      catch(Throwable t){}
View Full Code Here

TOP

Related Classes of railo.commons.io.res.Resource

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.