org.eclipse.jetty.util.Loader.getResource()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(16.3k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中org.eclipse.jetty.util.Loader.getResource()方法的一些代码示例,展示了Loader.getResource()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Loader.getResource()方法的具体详情如下:
包路径:org.eclipse.jetty.util.Loader
类名称:Loader
方法名:getResource

Loader.getResource介绍

暂无

代码示例

代码示例来源:origin: org.eclipse.jetty/jetty-webapp

URL dtd22=Loader.getResource("javax/servlet/resources/web-app_2_2.dtd");
URL dtd23=Loader.getResource("javax/servlet/resources/web-app_2_3.dtd");
URL j2ee14xsd=Loader.getResource("javax/servlet/resources/j2ee_1_4.xsd");
URL javaee5=Loader.getResource("javax/servlet/resources/javaee_5.xsd");
URL javaee6=Loader.getResource("javax/servlet/resources/javaee_6.xsd");
URL javaee7=Loader.getResource("javax/servlet/resources/javaee_7.xsd");
URL webapp24xsd=Loader.getResource("javax/servlet/resources/web-app_2_4.xsd");
URL webapp25xsd=Loader.getResource("javax/servlet/resources/web-app_2_5.xsd");
URL webapp30xsd=Loader.getResource("javax/servlet/resources/web-app_3_0.xsd");
URL webapp31xsd=Loader.getResource("javax/servlet/resources/web-app_3_1.xsd");
URL webcommon30xsd=Loader.getResource("javax/servlet/resources/web-common_3_0.xsd");
URL webcommon31xsd=Loader.getResource("javax/servlet/resources/web-common_3_1.xsd");
URL webfragment30xsd=Loader.getResource("javax/servlet/resources/web-fragment_3_0.xsd");
URL webfragment31xsd=Loader.getResource("javax/servlet/resources/web-fragment_3_1.xsd");
URL schemadtd=Loader.getResource("javax/servlet/resources/XMLSchema.dtd");
URL xmlxsd=Loader.getResource("javax/servlet/resources/xml.xsd");
URL webservice11xsd=Loader.getResource("javax/servlet/resources/j2ee_web_services_client_1_1.xsd");
URL webservice12xsd=Loader.getResource("javax/servlet/resources/javaee_web_services_client_1_2.xsd");
URL webservice13xsd=Loader.getResource("javax/servlet/resources/javaee_web_services_client_1_3.xsd");
URL webservice14xsd=Loader.getResource("javax/servlet/resources/javaee_web_services_client_1_4.xsd");
URL datatypesdtd=Loader.getResource("javax/servlet/resources/datatypes.dtd");
  jsp20xsd = Loader.getResource("javax/servlet/resources/jsp_2_0.xsd");
  jsp21xsd = Loader.getResource("javax/servlet/resources/jsp_2_1.xsd");
  jsp22xsd = Loader.getResource("javax/servlet/resources/jsp_2_2.xsd");

代码示例来源:origin: org.eclipse.jetty/jetty-util

@Override
  public Object run()
  {
    try
    {
      URL props = Loader.getResource(properties);
      if (props != null)
        LogManager.getLogManager().readConfiguration(props.openStream());
    }
    catch(Throwable e)
    {
      System.err.println("[WARN] Error loading logging config: " + properties);
      e.printStackTrace(System.err);
    }
    
    return null;
  }
});

代码示例来源:origin: org.eclipse.jetty/jetty-util

static void loadProperties(String resourceName, Properties props)
{
  URL testProps = Loader.getResource(resourceName);
  if (testProps != null)
  {
    try (InputStream in = testProps.openStream())
    {
      Properties p = new Properties();
      p.load(in);
      for (Object key : p.keySet())
      {
        Object value = p.get(key);
        if (value != null)
        {
          props.put(key,value);
        }
      }
    }
    catch (IOException e)
    {
      System.err.println("[WARN] Error loading logging config: " + testProps);
      e.printStackTrace(System.err);
    }
  }
}

代码示例来源:origin: org.eclipse.jetty/jetty-util

/** Find a classpath resource.
 * The {@link java.lang.Class#getResource(String)} method is used to lookup the resource. If it is not
 * found, then the {@link Loader#getResource(String)} method is used.
 * If it is still not found, then {@link ClassLoader#getSystemResource(String)} is used.
 * Unlike {@link ClassLoader#getSystemResource(String)} this method does not check for normal resources.
 * @param name The relative name of the resource
 * @param useCaches True if URL caches are to be used.
 * @param checkParents True if forced searching of parent Classloaders is performed to work around 
 * loaders with inverted priorities
 * @return Resource or null
 */
public static Resource newClassPathResource(String name,boolean useCaches,boolean checkParents)
{
  URL url=Resource.class.getResource(name);
  
  if (url==null)
    url=Loader.getResource(name);
  if (url==null)
    return null;
  return newResource(url,useCaches);
}

代码示例来源:origin: i2p/i2p.i2p

private static XmlParser initParser()
{
  XmlParser parser = new XmlParser();
  URL config60 = Loader.getResource(XmlConfiguration.class, "org/eclipse/jetty/xml/configure_6_0.dtd");
  URL config76 = Loader.getResource(XmlConfiguration.class,"org/eclipse/jetty/xml/configure_7_6.dtd");
  URL config90 = Loader.getResource(XmlConfiguration.class,"org/eclipse/jetty/xml/configure_9_0.dtd");
  parser.redirectEntity("configure.dtd",config90);
  parser.redirectEntity("configure_1_0.dtd",config60);
  parser.redirectEntity("configure_1_1.dtd",config60);
  parser.redirectEntity("configure_1_2.dtd",config60);
  parser.redirectEntity("configure_1_3.dtd",config60);
  parser.redirectEntity("configure_6_0.dtd",config60);
  parser.redirectEntity("configure_7_6.dtd",config76);
  parser.redirectEntity("configure_9_0.dtd",config90);
  parser.redirectEntity("http://jetty.mortbay.org/configure.dtd",config90);
  parser.redirectEntity("http://jetty.eclipse.org/configure.dtd",config90);
  parser.redirectEntity("http://www.eclipse.org/jetty/configure.dtd",config90);
  parser.redirectEntity("-//Mort Bay Consulting//DTD Configure//EN",config90);
  parser.redirectEntity("-//Jetty//Configure//EN",config90);
  return parser;
}

代码示例来源:origin: jenkinsci/winstone

@Override
  public Object run()
  {
    try
    {
      URL props = Loader.getResource(properties);
      if (props != null)
        LogManager.getLogManager().readConfiguration(props.openStream());
    }
    catch(Throwable e)
    {
      System.err.println("[WARN] Error loading logging config: " + properties);
      e.printStackTrace(System.err);
    }
    
    return null;
  }
});

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-webapp

public static URL jarFor(String className)
{
  try
  {
    className=className.replace('.','/')+".class";
    // hack to discover jstl libraries
    URL url = Loader.getResource(null,className,false);
    String s=url.toString();
    if (s.startsWith("jar:file:"))
      return new URL(s.substring(4,s.indexOf("!/")));
  }
  catch(Exception e)
  {
    LOG.ignore(e);
  }
  return null;
}

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server

public static URL jarFor(String className)
{
  try
  {
    className=className.replace('.','/')+".class";
    // hack to discover jstl libraries
    URL url = Loader.getResource(null,className,false);
    String s=url.toString();
    if (s.startsWith("jar:file:"))
      return new URL(s.substring(4,s.indexOf("!/")));
  }
  catch(Exception e)
  {
    LOG.ignore(e);
  }
  return null;
}

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server

/** Find a classpath resource.
 * The {@link java.lang.Class#getResource(String)} method is used to lookup the resource. If it is not
 * found, then the {@link Loader#getResource(Class, String, boolean)} method is used.
 * If it is still not found, then {@link ClassLoader#getSystemResource(String)} is used.
 * Unlike {@link ClassLoader#getSystemResource(String)} this method does not check for normal resources.
 * @param name The relative name of the resource
 * @param useCaches True if URL caches are to be used.
 * @param checkParents True if forced searching of parent Classloaders is performed to work around 
 * loaders with inverted priorities
 * @return Resource or null
 */
public static Resource newClassPathResource(String name,boolean useCaches,boolean checkParents)
{
  URL url=Resource.class.getResource(name);
  
  if (url==null)
    url=Loader.getResource(Resource.class,name,checkParents);
  if (url==null)
    return null;
  return newResource(url,useCaches);
}

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-webapp

/** Find a classpath resource.
 * The {@link java.lang.Class#getResource(String)} method is used to lookup the resource. If it is not
 * found, then the {@link Loader#getResource(Class, String, boolean)} method is used.
 * If it is still not found, then {@link ClassLoader#getSystemResource(String)} is used.
 * Unlike {@link ClassLoader#getSystemResource(String)} this method does not check for normal resources.
 * @param name The relative name of the resource
 * @param useCaches True if URL caches are to be used.
 * @param checkParents True if forced searching of parent Classloaders is performed to work around 
 * loaders with inverted priorities
 * @return Resource or null
 */
public static Resource newClassPathResource(String name,boolean useCaches,boolean checkParents)
{
  URL url=Resource.class.getResource(name);
  
  if (url==null)
    url=Loader.getResource(Resource.class,name,checkParents);
  if (url==null)
    return null;
  return newResource(url,useCaches);
}

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

/** Find a classpath resource.
 * The {@link java.lang.Class#getResource(String)} method is used to lookup the resource. If it is not
 * found, then the {@link Loader#getResource(Class, String, boolean)} method is used.
 * If it is still not found, then {@link ClassLoader#getSystemResource(String)} is used.
 * Unlike {@link ClassLoader#getSystemResource(String)} this method does not check for normal resources.
 * @param name The relative name of the resource
 * @param useCaches True if URL caches are to be used.
 * @param checkParents True if forced searching of parent Classloaders is performed to work around 
 * loaders with inverted priorities
 * @return Resource or null
 */
public static Resource newClassPathResource(String name,boolean useCaches,boolean checkParents)
{
  URL url=Resource.class.getResource(name);
  
  if (url==null)
    url=Loader.getResource(Resource.class,name,checkParents);
  if (url==null)
    return null;
  return newResource(url,useCaches);
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

/** Find a classpath resource.
 * The {@link java.lang.Class#getResource(String)} method is used to lookup the resource. If it is not
 * found, then the {@link Loader#getResource(Class, String, boolean)} method is used.
 * If it is still not found, then {@link ClassLoader#getSystemResource(String)} is used.
 * Unlike {@link ClassLoader#getSystemResource(String)} this method does not check for normal resources.
 * @param name The relative name of the resource
 * @param useCaches True if URL caches are to be used.
 * @param checkParents True if forced searching of parent Classloaders is performed to work around 
 * loaders with inverted priorities
 * @return Resource or null
 */
public static Resource newClassPathResource(String name,boolean useCaches,boolean checkParents)
{
  URL url=Resource.class.getResource(name);
  
  if (url==null)
    url=Loader.getResource(Resource.class,name,checkParents);
  if (url==null)
    return null;
  return newResource(url,useCaches);
}

代码示例来源:origin: Nextdoor/bender

/** Find a classpath resource.
 * The {@link java.lang.Class#getResource(String)} method is used to lookup the resource. If it is not
 * found, then the {@link Loader#getResource(Class, String)} method is used.
 * If it is still not found, then {@link ClassLoader#getSystemResource(String)} is used.
 * Unlike {@link ClassLoader#getSystemResource(String)} this method does not check for normal resources.
 * @param name The relative name of the resource
 * @param useCaches True if URL caches are to be used.
 * @param checkParents True if forced searching of parent Classloaders is performed to work around 
 * loaders with inverted priorities
 * @return Resource or null
 */
public static Resource newClassPathResource(String name,boolean useCaches,boolean checkParents)
{
  URL url=Resource.class.getResource(name);
  
  if (url==null)
    url=Loader.getResource(Resource.class,name);
  if (url==null)
    return null;
  return newResource(url,useCaches);
}

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-server

public static URL jarFor(String className)
{
  try
  {
    className=className.replace('.','/')+".class";
    // hack to discover jstl libraries
    URL url = Loader.getResource(null,className,false);
    String s=url.toString();
    if (s.startsWith("jar:file:"))
      return new URL(s.substring(4,s.indexOf("!/")));
  }
  catch(Exception e)
  {
    LOG.ignore(e);
  }
  return null;
}

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-plus

public static URL jarFor(String className)
{
  try
  {
    className=className.replace('.','/')+".class";
    // hack to discover jstl libraries
    URL url = Loader.getResource(null,className,false);
    String s=url.toString();
    if (s.startsWith("jar:file:"))
      return new URL(s.substring(4,s.indexOf("!/")));
  }
  catch(Exception e)
  {
    LOG.ignore(e);
  }
  return null;
}

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-plus

/** Find a classpath resource.
 * The {@link java.lang.Class#getResource(String)} method is used to lookup the resource. If it is not
 * found, then the {@link Loader#getResource(Class, String, boolean)} method is used.
 * If it is still not found, then {@link ClassLoader#getSystemResource(String)} is used.
 * Unlike {@link ClassLoader#getSystemResource(String)} this method does not check for normal resources.
 * @param name The relative name of the resource
 * @param useCaches True if URL caches are to be used.
 * @param checkParents True if forced searching of parent Classloaders is performed to work around 
 * loaders with inverted priorities
 * @return Resource or null
 */
public static Resource newClassPathResource(String name,boolean useCaches,boolean checkParents)
{
  URL url=Resource.class.getResource(name);
  
  if (url==null)
    url=Loader.getResource(Resource.class,name,checkParents);
  if (url==null)
    return null;
  return newResource(url,useCaches);
}

代码示例来源:origin: org.eclipse.jetty/jetty-annotations

/**
 * Parse a given class
 * 
 * @param handlers the set of handlers to find class
 * @param className the class name to parse
 * @throws Exception if unable to parse
 */
public void parse (Set<? extends Handler> handlers, String className) throws Exception
{
  if (className == null)
    return;
  String tmp = className;
  className = className.replace('.', '/')+".class";
  URL resource = Loader.getResource(className);
  if (resource!= null)
  {
    Resource r = Resource.newResource(resource);
    addParsedClass(tmp, r);
    try (InputStream is = r.getInputStream())
    {
      scanClass(handlers, null, is);
    }
  }
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

/**
 * Parse the given classes
 * 
 * @param classNames
 * @param resolver
 * @throws Exception
 */
public void parse (List<String> classNames, ClassNameResolver resolver)
throws Exception
{
  for (String s:classNames)
  {
    if ((resolver == null) || (!resolver.isExcluded(s) &&  (!isParsed(s) || resolver.shouldOverride(s))))
    {
      s = s.replace('.', '/')+".class";
      URL resource = Loader.getResource(this.getClass(), s, false);
      if (resource!= null)
      {
        Resource r = Resource.newResource(resource);
        scanClass(r.getInputStream());
      }
    }
  }
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

private synchronized static XmlParser initParser()
{
  XmlParser parser = new XmlParser();
  URL config60 = Loader.getResource(XmlConfiguration.class,"org/eclipse/jetty/xml/configure_6_0.dtd",true);
  URL config76 = Loader.getResource(XmlConfiguration.class,"org/eclipse/jetty/xml/configure_7_6.dtd",true);
  URL config90 = Loader.getResource(XmlConfiguration.class,"org/eclipse/jetty/xml/configure_9_0.dtd",true);
  parser.redirectEntity("configure.dtd",config90);
  parser.redirectEntity("configure_1_0.dtd",config60);
  parser.redirectEntity("configure_1_1.dtd",config60);
  parser.redirectEntity("configure_1_2.dtd",config60);
  parser.redirectEntity("configure_1_3.dtd",config60);
  parser.redirectEntity("configure_6_0.dtd",config60);
  parser.redirectEntity("configure_7_6.dtd",config76);
  parser.redirectEntity("configure_9_0.dtd",config90);
  parser.redirectEntity("http://jetty.mortbay.org/configure.dtd",config90);
  parser.redirectEntity("http://jetty.eclipse.org/configure.dtd",config90);
  parser.redirectEntity("http://www.eclipse.org/jetty/configure.dtd",config90);
  parser.redirectEntity("-//Mort Bay Consulting//DTD Configure//EN",config90);
  parser.redirectEntity("-//Jetty//Configure//EN",config90);
  return parser;
}

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server

private synchronized static XmlParser initParser()
{
  XmlParser parser = new XmlParser();
  URL config60 = Loader.getResource(XmlConfiguration.class,"org/eclipse/jetty/xml/configure_6_0.dtd",true);
  URL config76 = Loader.getResource(XmlConfiguration.class,"org/eclipse/jetty/xml/configure_7_6.dtd",true);
  parser.redirectEntity("configure.dtd",config76);
  parser.redirectEntity("configure_1_0.dtd",config60);
  parser.redirectEntity("configure_1_1.dtd",config60);
  parser.redirectEntity("configure_1_2.dtd",config60);
  parser.redirectEntity("configure_1_3.dtd",config60);
  parser.redirectEntity("configure_6_0.dtd",config60);
  parser.redirectEntity("configure_7_6.dtd",config76);
  parser.redirectEntity("http://jetty.mortbay.org/configure.dtd",config76);
  parser.redirectEntity("http://jetty.eclipse.org/configure.dtd",config76);
  parser.redirectEntity("http://www.eclipse.org/jetty/configure.dtd",config76);
  parser.redirectEntity("-//Mort Bay Consulting//DTD Configure//EN",config76);
  parser.redirectEntity("-//Jetty//Configure//EN",config76);
  return parser;
}

相关文章