當前位置: 首頁>>代碼示例>>Java>>正文


Java Resource.isDirectory方法代碼示例

本文整理匯總了Java中org.eclipse.jetty.util.resource.Resource.isDirectory方法的典型用法代碼示例。如果您正苦於以下問題:Java Resource.isDirectory方法的具體用法?Java Resource.isDirectory怎麽用?Java Resource.isDirectory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jetty.util.resource.Resource的用法示例。


在下文中一共展示了Resource.isDirectory方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addJars

import org.eclipse.jetty.util.resource.Resource; //導入方法依賴的package包/類
/**
 * Add elements to the class path for the context from the jar and zip files found
 * in the specified resource.
 *
 * @param resource the resource that contains the jar and/or zip files.
 */
public void addJars(Resource resource) {
    if (resource.exists() && resource.isDirectory()) {
        String[] files = resource.list();
        for (int f = 0; files != null && f < files.length; f++) {
            try {
                Resource fn = resource.addPath(files[f]);
                String fnlc = fn.getName().toLowerCase(Locale.ENGLISH);
                // don't check if this is a directory, see Bug 353165
                if (isFileSupported(fnlc)) {
                    String name = fn.toString();
                    name = StringUtil.replace(name, ",", "%2C");
                    name = StringUtil.replace(name, ";", "%3B");
                    addClassPath(name);
                    List<Class<?>> classes = getClassesInJar(name);
                    for (Class<?> clazz : classes) {
                        knownClasses.put(clazz.getName(), clazz);
                    }
                }
            } catch (Exception ex) {
                LOG.error(String.format("Exception adding classpath entry from resource %s", resource.getName()), ex);
            }
        }
    }
}
 
開發者ID:nkasvosve,項目名稱:beyondj,代碼行數:31,代碼來源:BeyondJWebAppClassLoader.java

示例2: preConfigure

import org.eclipse.jetty.util.resource.Resource; //導入方法依賴的package包/類
@Override
public void preConfigure(final WebAppContext context) throws Exception {
	super.preConfigure(context); // let original MetaInfConfiguration do
									// it's thing first
	
	// Now add directory classpath resources
	final ArrayList<Resource> resources = new ArrayList<Resource>();
	ClassLoader cl = ClassLoader.getSystemClassLoader();
       URL[] urls = ((URLClassLoader)cl).getURLs();
       for(URL url: urls){
       	Resource r= new FileResource(url);
       	if (r.isDirectory()) {
       		resources.add(r);
       	}
       }
	scanJars(context, resources, false);
}
 
開發者ID:logsniffer,項目名稱:logsniffer,代碼行數:18,代碼來源:MetaInfFolderConfiguration.java

示例3: doStart

import org.eclipse.jetty.util.resource.Resource; //導入方法依賴的package包/類
@Override
protected void doStart() throws Exception {
  // unpack and Adjust paths.
  Resource base = getBaseResource();
  if (base == null) {
    base = Resource.newResource(getWar());
  }
  Resource dir;
  if (base.isDirectory()) {
    dir = base;
  } else {
    throw new IllegalArgumentException();
  }
  Resource qswebxml = dir.addPath("/WEB-INF/quickstart-web.xml");
  if (qswebxml.exists()) {
    setConfigurationClasses(quickstartConfigurationClasses);
  }
  super.doStart();
}
 
開發者ID:GoogleCloudPlatform,項目名稱:appengine-java-vm-runtime,代碼行數:20,代碼來源:VmRuntimeWebAppContext.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,代碼行數:35,代碼來源:BeyondJWebAppClassLoader.java

示例5: 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

示例6: WebAppContextBuilder

import org.eclipse.jetty.util.resource.Resource; //導入方法依賴的package包/類
public WebAppContextBuilder(WebAppContext handler, Resource baseResource) {
    super(handler);
    if (baseResource.isDirectory()) {
        handler.setBaseResource(baseResource);
        Logger.debug(EmbeddedJettyBuilder.class, "Using directory [" + baseResource + "] as web application context.");
    } else {
        try {
            handler.setWar(baseResource.getFile().getAbsolutePath());
            Logger.debug(EmbeddedJettyBuilder.class, "Using file [" + baseResource + "] as web application context.");
        } catch (IOException e) {
            throw new RuntimeException("Unable to set [" + baseResource + "] as WAR.", e);
        }
    }
}
 
開發者ID:NetsOSS,項目名稱:embedded-jetty,代碼行數:15,代碼來源:EmbeddedJettyBuilder.java

示例7: service

import org.eclipse.jetty.util.resource.Resource; //導入方法依賴的package包/類
@Override
public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    HttpServletRequest request = null;
    if (req instanceof HttpServletRequest)
        request = (HttpServletRequest) req;
    else
        throw new ServletException("Request not HttpServletRequest");

    String servletPath = null;
    String pathInfo = null;
    if (request.getAttribute("javax.servlet.include.request_uri") != null) {
        servletPath = (String) request.getAttribute("javax.servlet.include.servlet_path");
        pathInfo = (String) request.getAttribute("javax.servlet.include.path_info");
        if (servletPath == null) {
            servletPath = request.getServletPath();
            pathInfo = request.getPathInfo();
        }
    } else {
        servletPath = request.getServletPath();
        pathInfo = request.getPathInfo();
    }

    String pathInContext = URIUtil.addPaths(servletPath, pathInfo);

    String jspFile = getInitParameter("jspFile");

    //if this is a forced-path from a jsp-file, we want the jsp servlet to handle it,
    //otherwise the default servlet might handle it
    if (jspFile == null) {
        if (pathInContext.endsWith("/")) {
            //dispatch via forward to the default servlet
            getServletContext().getNamedDispatcher("default").forward(req, resp);
            return;
        } else {
            //check if it resolves to a directory
            Resource resource = ((ContextHandler.Context) getServletContext()).getContextHandler().getResource(pathInContext);

            if (resource != null && resource.isDirectory()) {
                //dispatch via forward to the default servlet
                getServletContext().getNamedDispatcher("default").forward(req, resp);
                return;
            }
        }
    }

    //fall through to the normal jsp servlet handling
    super.service(req, resp);
}
 
開發者ID:nkasvosve,項目名稱:beyondj,代碼行數:49,代碼來源:JettyJspServlet.java


注:本文中的org.eclipse.jetty.util.resource.Resource.isDirectory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。