Ejemplo n.º 1
0
 /**
  * Create a new ClassPathResource for ClassLoader usage. A leading slash will be removed, as the
  * ClassLoader resource access methods will not accept it.
  *
  * @param path the absolute path within the classpath
  * @param classLoader the class loader to load the resource with, or <code>null</code> for the
  *     thread context class loader
  * @see java.lang.ClassLoader#getResourceAsStream(String)
  */
 public ClassPathResource(String path, ClassLoader classLoader) {
   Assert.notNull(path, "Path must not be null");
   String pathToUse = StringUtils.cleanPath(path);
   if (pathToUse.startsWith("/")) {
     pathToUse = pathToUse.substring(1);
   }
   this.path = pathToUse;
   this.classLoader = (classLoader != null ? classLoader : ClassUtils.getDefaultClassLoader());
 }
Ejemplo n.º 2
0
 /**
  * Create a new ClassPathResource for Class usage. The path can be relative to the given class, or
  * absolute within the classpath via a leading slash.
  *
  * @param path relative or absolute path within the class path
  * @param clazz the class to load resources with
  * @see java.lang.Class#getResourceAsStream
  */
 public ClassPathResource(String path, Class<?> clazz) {
   Assert.notNull(path, "Path must not be null");
   this.path = StringUtils.cleanPath(path);
   this.clazz = clazz;
 }
Ejemplo n.º 3
0
 /**
  * Set the request factory that this accessor uses for obtaining {@link ClientHttpRequest
  * HttpRequests}.
  */
 public void setRequestFactory(ClientHttpRequestFactory requestFactory) {
   Assert.notNull(requestFactory, "'requestFactory' must not be null");
   this.requestFactory = requestFactory;
 }