From 7dbe38ba0522b346a0fcd9851e797f0fd71ecd5e Mon Sep 17 00:00:00 2001 From: Michael Dürre Date: Thu, 16 Jul 2020 05:55:07 +0200 Subject: switch to rfc8040 restconf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit change rest interface and some small code cleanups Issue-ID: CCSDK-2572 Signed-off-by: Michael Dürre Change-Id: I3475bd2574b32950c4bf84fbd1c2a9dac9af208a --- .../opensymphony/xwork2/util/ClassLoaderUtil.java | 125 +++++++++++---------- 1 file changed, 63 insertions(+), 62 deletions(-) (limited to 'sdnr/wt/odlux/core/model/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java') diff --git a/sdnr/wt/odlux/core/model/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java b/sdnr/wt/odlux/core/model/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java index 133b08494..636c9db29 100644 --- a/sdnr/wt/odlux/core/model/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java +++ b/sdnr/wt/odlux/core/model/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java @@ -22,11 +22,11 @@ import java.util.*; /** - * This class is extremely useful for loading resources and classes in a fault tolerant manner - * that works across different applications servers. + * This class is extremely useful for loading resources and classes in a fault tolerant manner that works across + * different applications servers. * - * It has come out of many months of frustrating use of multiple application servers at Atlassian, - * please don't change things unless you're sure they're not going to break in one server or another! + * It has come out of many months of frustrating use of multiple application servers at Atlassian, please don't change + * things unless you're sure they're not going to break in one server or another! * * It was brought in from oscore trunk revision 147. * @@ -37,58 +37,59 @@ public class ClassLoaderUtil { //~ Methods //////////////////////////////////////////////////////////////// /** - * Load all resources with a given name, potentially aggregating all results - * from the searched classloaders. If no results are found, the resource name - * is prepended by '/' and tried again. + * Load all resources with a given name, potentially aggregating all results from the searched classloaders. If no + * results are found, the resource name is prepended by '/' and tried again. * * This method will try to load the resources using the following methods (in order): * * * @param resourceName The name of the resources to load * @param callingClass The Class object of the calling object */ - public static Iterator getResources(String resourceName, Class callingClass, boolean aggregate) throws IOException { + public static Iterator getResources(String resourceName, Class callingClass, boolean aggregate) + throws IOException { - AggregateIterator iterator = new AggregateIterator<>(); + AggregateIterator iterator = new AggregateIterator<>(); - iterator.addEnumeration(Thread.currentThread().getContextClassLoader().getResources(resourceName)); + iterator.addEnumeration(Thread.currentThread().getContextClassLoader().getResources(resourceName)); - if (!iterator.hasNext() || aggregate) { - iterator.addEnumeration(ClassLoaderUtil.class.getClassLoader().getResources(resourceName)); - } + if (!iterator.hasNext() || aggregate) { + iterator.addEnumeration(ClassLoaderUtil.class.getClassLoader().getResources(resourceName)); + } - if (!iterator.hasNext() || aggregate) { - ClassLoader cl = callingClass.getClassLoader(); + if (!iterator.hasNext() || aggregate) { + ClassLoader cl = callingClass.getClassLoader(); - if (cl != null) { - iterator.addEnumeration(cl.getResources(resourceName)); - } - } + if (cl != null) { + iterator.addEnumeration(cl.getResources(resourceName)); + } + } - if (!iterator.hasNext() && resourceName != null && (resourceName.length() == 0 || resourceName.charAt(0) != '/')) { - return getResources('/' + resourceName, callingClass, aggregate); - } + if (!iterator.hasNext() && resourceName != null + && (resourceName.length() == 0 || resourceName.charAt(0) != '/')) { + return getResources('/' + resourceName, callingClass, aggregate); + } - return iterator; - } + return iterator; + } /** - * Load a given resource. - * - * This method will try to load the resource using the following methods (in order): - *
    - *
  • From Thread.currentThread().getContextClassLoader() - *
  • From ClassLoaderUtil.class.getClassLoader() - *
  • callingClass.getClassLoader() - *
- * - * @param resourceName The name IllegalStateException("Unable to call ")of the resource to load - * @param callingClass The Class object of the calling object - */ + * Load a given resource. + * + * This method will try to load the resource using the following methods (in order): + *
    + *
  • From Thread.currentThread().getContextClassLoader() + *
  • From ClassLoaderUtil.class.getClassLoader() + *
  • callingClass.getClassLoader() + *
+ * + * @param resourceName The name IllegalStateException("Unable to call ")of the resource to load + * @param callingClass The Class object of the calling object + */ public static URL getResource(String resourceName, Class callingClass) { URL url = Thread.currentThread().getContextClassLoader().getResource(resourceName); @@ -112,13 +113,13 @@ public class ClassLoaderUtil { } /** - * This is a convenience method to load a resource as a stream. - * - * The algorithm used to find the resource is given in getResource() - * - * @param resourceName The name of the resource to load - * @param callingClass The Class object of the calling object - */ + * This is a convenience method to load a resource as a stream. + * + * The algorithm used to find the resource is given in getResource() + * + * @param resourceName The name of the resource to load + * @param callingClass The Class object of the calling object + */ public static InputStream getResourceAsStream(String resourceName, Class callingClass) { URL url = getResource(resourceName, callingClass); @@ -130,20 +131,20 @@ public class ClassLoaderUtil { } /** - * Load a class with a given name. - * - * It will try to load the class in the following order: - *
    - *
  • From Thread.currentThread().getContextClassLoader() - *
  • Using the basic Class.forName() - *
  • From ClassLoaderUtil.class.getClassLoader() - *
  • From the callingClass.getClassLoader() - *
- * - * @param className The name of the class to load - * @param callingClass The Class object of the calling object - * @throws ClassNotFoundException If the class cannot be found anywhere. - */ + * Load a class with a given name. + * + * It will try to load the class in the following order: + *
    + *
  • From Thread.currentThread().getContextClassLoader() + *
  • Using the basic Class.forName() + *
  • From ClassLoaderUtil.class.getClassLoader() + *
  • From the callingClass.getClassLoader() + *
+ * + * @param className The name of the class to load + * @param callingClass The Class object of the calling object + * @throws ClassNotFoundException If the class cannot be found anywhere. + */ public static Class loadClass(String className, Class callingClass) throws ClassNotFoundException { try { return Thread.currentThread().getContextClassLoader().loadClass(className); @@ -161,8 +162,8 @@ public class ClassLoaderUtil { } /** - * Aggregates Enumeration instances into one iterator and filters out duplicates. Always keeps one - * ahead of the enumerator to protect against returning duplicates. + * Aggregates Enumeration instances into one iterator and filters out duplicates. Always keeps one ahead of the + * enumerator to protect against returning duplicates. */ static class AggregateIterator implements Iterator { -- cgit 1.2.3-korg