/**
 * Axelor Business Solutions
 *
 * Copyright (C) 2005-2017 Axelor (<http://axelor.com>).
 *
 * This program is free software: you can redistribute it and/or  modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.axelor.common;

import java.io.InputStream;
import java.net.URL;

/**
 * The class provides static helper methods to work with resources. It uses
 * current thread's context {@link ClassLoader} to locate resources.
 * 
 */
public final class ResourceUtils {

	/**
	 * Finds the resource with the given name.
	 * 
	 * @param name
	 *            The resource name
	 * @return resource an {@link URL} for reading the resource or null
	 * @see ClassLoader#getResource(String)
	 */
	public static URL getResource(String name) {
		return Thread.currentThread().getContextClassLoader().getResource(name);
	}

	/**
	 * Returns an input stream for reading the specified resource.
	 * 
	 * @param name
	 *            The resource name
	 * @return An input stream for reading the resource or null
	 * @see ClassLoader#getResourceAsStream(String)
	 */
	public static InputStream getResourceStream(String name) {
		return Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
	}
}

@@ -726,16 +726,44 @@
 ommon;%0A%0A
+import java.io.IOException;%0A
 import j
@@ -879,177 +879,154 @@
 ces.
- It uses%0A * current thread's context %7B@link ClassLoader%7D to locate resources.%0A * %0A */%0Apublic final class ResourceUtils %7B%0A%0A%09/**%0A%09 * Finds the resource with the given name
+%0A * %0A */%0Apublic final class ResourceUtils %7B%0A%0A%09/**%0A%09 * Finds the resource from the class path with the given location using%0A%09 * default ClassLoader
 .%0A%09 
@@ -1031,36 +1031,40 @@
 %09 * %0A%09 * @param 
-name
+location
 %0A%09 *            
@@ -1068,36 +1068,40 @@
    The resource 
-name
+location
 %0A%09 * @return res
@@ -1097,25 +1097,16 @@
 @return 
-resource 
 an %7B@lin
@@ -1137,32 +1137,76 @@
 esource or null%0A
+%09 * @see ClassUtils#getDefaultClassLoader()%0A
 %09 * @see ClassLo
@@ -1265,36 +1265,40 @@
 Resource(String 
-name
+location
 ) %7B%0A%09%09return Thr
@@ -1298,54 +1298,18 @@
 urn 
-Thread.currentThread().getContextClassLoader()
+ClassUtils
 .get
@@ -1317,20 +1317,24 @@
 esource(
-name
+location
 );%0A%09%7D%0A%0A%09
@@ -1417,20 +1417,24 @@
  @param 
-name
+location
 %0A%09 *    
@@ -1454,20 +1454,24 @@
 esource 
-name
+location
 %0A%09 * @re
@@ -1516,32 +1516,75 @@
 esource or null%0A
+%09 * @see ResourceUtils#getResource(String)%0A
 %09 * @see ClassLo
@@ -1677,98 +1677,165 @@
 ing 
-name) %7B%0A%09%09return Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
+location) %7B%0A%09%09final URL url = getResource(location);%0A%09%09try %7B%0A%09%09%09return url != null ? url.openStream() : null;%0A%09%09%7D catch (IOException e) %7B%0A%09%09%09return null;%0A%09%09%7D
 %0A%09%7D%0A

Refactor resource utilities to use new class utilities