当前位置: 首页>>代码示例>>Java>>正文


Java Resource.getFile方法代码示例

本文整理汇总了Java中org.eclipse.jetty.util.resource.Resource.getFile方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.getFile方法的具体用法?Java Resource.getFile怎么用?Java Resource.getFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jetty.util.resource.Resource的用法示例。


在下文中一共展示了Resource.getFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getResource

import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的package包/类
@Override
public Resource getResource(String path) {
    try {
        Resource resource = super.getResource(path);
        if (resource == null) return null;
        if (!(resource instanceof PathResource) || !resource.exists()) return resource;
        File f = resource.getFile();
        if (f.isDirectory() && !path.equals("/")) return resource;
        CacheResource cache = resourceCache.get(f);
        if (cache != null) return cache;
        if (f.length() < CACHE_LIMIT || f.getName().endsWith(".html") || path.equals("/")) {
            cache = new CacheResource((PathResource) resource);
            resourceCache.put(f, cache);
            return cache;
        }
        return resource;
    } catch (IOException e) {
        Data.logger.warn("", e);
    }
    return null;
}
 
开发者ID:yacy,项目名称:yacy_grid_mcp,代码行数:22,代码来源:FileHandler.java

示例2: getClassPath

import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的package包/类
/**
 * Generate the classpath (as a string) of all classloaders
 * above the given classloader.
 * 
 * This is primarily used for jasper.
 * @return the system class path
 */
public static String getClassPath(ClassLoader loader) throws Exception
{
    StringBuilder classpath=new StringBuilder();
    while (loader != null && (loader instanceof URLClassLoader))
    {
        URL[] urls = ((URLClassLoader)loader).getURLs();
        if (urls != null)
        {     
            for (int i=0;i<urls.length;i++)
            {
                Resource resource = Resource.newResource(urls[i]);
                File file=resource.getFile();
                if (file!=null && file.exists())
                {
                    if (classpath.length()>0)
                        classpath.append(File.pathSeparatorChar);
                    classpath.append(file.getAbsolutePath());
                }
            }
        }
        loader = loader.getParent();
    }
    return classpath.toString();
}
 
开发者ID:itead,项目名称:IoTgo_Android_App,代码行数:32,代码来源:Loader.java

示例3: addClassPath

import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的package包/类
/**
 * @param classPath Comma or semicolon separated path of filenames or URLs
 *                  pointing to directories or jar files. Directories should end
 *                  with '/'.
 */
public void addClassPath(String classPath)
        throws IOException {
    if (classPath == null) {
        return;
    }

    StringTokenizer tokenizer = new StringTokenizer(classPath, ",;");

    while (tokenizer.hasMoreTokens()) {
        Resource resource = Resource.newResource(tokenizer.nextToken().trim());
        // Add the resource
        if (resource.isDirectory() && resource instanceof ResourceCollection) {
            addClassPath(resource);
        }
        else {
            // Resolve file path if possible
            File file = resource.getFile();
            if (file != null) {
                URL url = resource.getURL();
                addURL(url);
            } else if (resource.isDirectory()) {
                addURL(resource.getURL());
            } else {
                LOG.error("Check file exists and is not nested jar: " + resource);
                throw new IllegalArgumentException("File not resolvable or incompatible with URLClassloader: " + resource);
            }
        }
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:35,代码来源:BeyondJWebAppClassLoader.java

示例4: addClassPath

import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的package包/类
/**
 * @param classPath Comma or semicolon separated path of filenames or URLs
 *                  pointing to directories or jar files. Directories should end
 *                  with '/'.
 */
public void addClassPath(String classPath)
        throws IOException {
    if (classPath == null) {
        return;
    }

    StringTokenizer tokenizer = new StringTokenizer(classPath, ",;");
    while (tokenizer.hasMoreTokens()) {
        Resource resource = Resource.newResource(tokenizer.nextToken().trim());
        // Add the resource
        if (resource.isDirectory() && resource instanceof ResourceCollection)
            addClassPath(resource);
        else {
            // Resolve file path if possible
            File file = resource.getFile();
            if (file != null) {
                URL url = resource.getURL();
                addURL(url);
            } else if (resource.isDirectory()) {
                addURL(resource.getURL());
            } else {
                LOG.error("Check file exists and is not nested jar: " + resource);
                throw new IllegalArgumentException("File not resolvable or incompatible with URLClassloader: " + resource);
            }
        }
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:33,代码来源:BeyondJTomcatWebAppClassLoader.java

示例5: doStart

import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的package包/类
@Override
protected void doStart() throws Exception {
  
  Resource resource = Resource.newResource(webapp);
  File file = resource.getFile();
  if (!resource.exists())
      throw new IllegalStateException("WebApp resouce does not exist "+resource);

  String lcName=file.getName().toLowerCase(Locale.ENGLISH);

  if (lcName.endsWith(".xml")) {
      XmlConfiguration xmlc = new XmlConfiguration(resource.getURI().toURL());
      xmlc.getIdMap().put("Server", contexts.getServer());
      xmlc.getProperties().put("jetty.home",System.getProperty("jetty.home","."));
      xmlc.getProperties().put("jetty.base",System.getProperty("jetty.base","."));
      xmlc.getProperties().put("jetty.webapp",file.getCanonicalPath());
      xmlc.getProperties().put("jetty.webapps",file.getParentFile().getCanonicalPath());
      xmlc.getProperties().putAll(properties);
      handler = (ContextHandler)xmlc.configure();
  } else {
    WebAppContext wac=new WebAppContext();
    wac.setWar(webapp);
    wac.setContextPath("/");
  }
  
  contexts.addHandler(handler);
  if (contexts.isRunning())
    handler.start();
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-java-vm-runtime,代码行数:30,代码来源:VmRuntimeWebAppDeployer.java


注:本文中的org.eclipse.jetty.util.resource.Resource.getFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。