congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
ClassLoaderUtils
Code IndexAdd Tabnine to your IDE (free)

How to use
ClassLoaderUtils
in
com.atlassian.plugin.util

Best Java code snippets using com.atlassian.plugin.util.ClassLoaderUtils (Showing top 20 results out of 315)

origin: com.atlassian.plugins/atlassian-plugins-core

  public InputStream getResourceAsStream(final String name) {
    return ClassLoaderUtils.getResourceAsStream(name, getClass());
  }
}
origin: com.atlassian.plugins/atlassian-plugins-core

public URL getResource(final String name) {
  return ClassLoaderUtils.getResource(name, getClass());
}
origin: com.atlassian.plugins/atlassian-plugins-core

public <T> Class<T> loadClass(final String clazz, final Class<?> callingClass) throws ClassNotFoundException {
  return ClassLoaderUtils.loadClass(clazz, callingClass);
}
origin: com.atlassian.plugins/atlassian-plugins-core

  /**
   * Prints the classloader hierarchy from a given classloader - useful for debugging.
   */
  public static void printClassLoader(final ClassLoader cl) {
    System.out.println("ClassLoaderUtils.printClassLoader(cl = " + cl + ")");
    if (cl != null) {
      printClassLoader(cl.getParent());
    }
  }
}
origin: com.atlassian.plugins/atlassian-plugins-core

if (contextClassLoader != null) {
  try {
    return coerce(contextClassLoader.loadClass(className));
  } catch (final ClassNotFoundException e) {
  return coerce(Class.forName(className));
} catch (final ClassNotFoundException ex) {
  try {
    return coerce(ClassLoaderUtils.class.getClassLoader().loadClass(className));
  } catch (final ClassNotFoundException exc) {
    if ((callingClass != null) && (callingClass.getClassLoader() != null)) {
      return coerce(callingClass.getClassLoader().loadClass(className));
    } else {
      throw exc;
origin: com.atlassian.plugins/atlassian-plugins-core

private void loadClassPathPlugins(final ModuleDescriptorFactory moduleDescriptorFactory) throws PluginParseException {
  final Enumeration<URL> pluginDescriptorFiles;
  try {
    pluginDescriptorFiles = ClassLoaderUtils.getResources(fileNameToLoad, this.getClass());
  } catch (final IOException e) {
    log.error("Could not load classpath plugins: " + e, e);
    return;
  }
  pluginLoaderMap = new LinkedHashMap<>();
  while (pluginDescriptorFiles.hasMoreElements()) {
    final URL url = pluginDescriptorFiles.nextElement();
    final SinglePluginLoader singlePluginLoader = new SinglePluginLoader(url);
    for (final Plugin plugin : singlePluginLoader.loadAllPlugins(moduleDescriptorFactory)) {
      pluginLoaderMap.put(plugin, singlePluginLoader);
    }
  }
}
origin: com.atlassian.plugins/atlassian-plugins-core

/**
 * Prints the current classloader hierarchy - useful for debugging.
 */
public static void printClassLoader() {
  System.out.println("ClassLoaderUtils.printClassLoader");
  printClassLoader(Thread.currentThread().getContextClassLoader());
}
origin: com.atlassian.jira/jira-core

InputStream getLegacyPropertiesStream()
{
  return ClassLoaderUtils.getResourceAsStream(LEGACY_PROPERTIES_FILE, this.getClass());
}
origin: com.atlassian.plugins/atlassian-plugins-core

public <M> Class<M> loadClass(final String clazz, final Class<?> callingClass) throws ClassNotFoundException {
  return ClassLoaderUtils.loadClass(clazz, callingClass);
}
origin: com.atlassian.plugins/atlassian-plugins-core

public URL getResource(final String name) {
  return ClassLoaderUtils.getResource(name, getClass());
}
origin: com.atlassian.plugins/atlassian-plugins-core

public InputStream getResourceAsStream(final String name) {
  return ClassLoaderUtils.getResourceAsStream(name, getClass());
}
origin: com.atlassian.plugins/atlassian-plugins-core

private <D extends ModuleDescriptor<?>> Class<D> getClassFromEntry(final Map.Entry<String, String> entry) {
  if (shouldSkipModuleOfType(entry.getKey())) {
    return null;
  }
  try {
    final Class<D> descriptorClass = ClassLoaderUtils.loadClass(entry.getValue(), getClass());
    if (!ModuleDescriptor.class.isAssignableFrom(descriptorClass)) {
      log.error("Configured plugin module descriptor class " + entry.getValue() + " does not inherit from ModuleDescriptor");
      return null;
    }
    return descriptorClass;
  } catch (final ClassNotFoundException e) {
    log.error("Unable to add configured plugin module descriptor " + entry.getKey() + ". Class not found: " + entry.getValue());
    return null;
  }
}
origin: com.atlassian.plugins/atlassian-plugins-core

/**
 * 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(final String resourceName, final Class<?> callingClass) {
  final URL url = getResource(resourceName, callingClass);
  try {
    return url != null ? url.openStream() : null;
  } catch (final IOException e) {
    return null;
  }
}
origin: com.atlassian.jira.plugins/jira-fisheye-plugin

/**
 * {@link ClassLoaderUtils} throws {@link IllegalArgumentException} in the case of malformed resource URIs, so let's
 * use the plugins2 class defensively (FISH-352)
 * @param resource resource to load
 * @param clazz reference class
 * @return an InputStream from the resource, or null if the resource could not be found or there was a problem
 * reading from the resource
 */
public static InputStream getResourceAsStream(String resource, Class clazz) {
  try {
    return ClassLoaderUtils.getResourceAsStream(resource, clazz);
  } catch (Exception e) {
    log.debug("Failed to retrieve resource '" + resource + "'", e);
    return null;
  }
}
origin: com.atlassian.plugins/atlassian-plugins-osgi

Class spr;
try {
  spr = ClassLoaderUtils.loadClass(cls, this.getClass());
origin: com.atlassian.config/atlassian-config

URL url = ClassLoaderUtils.getResource(getPropertiesFile(), DefaultHomeLocator.class);
if (url != null)
origin: com.atlassian.refapp/platform-ctk-plugin

static Document readPlatformVersionDocument() throws RuntimeException {
  InputStream in = ClassLoaderUtils.getResourceAsStream(PLATFORM_VERSION_PATH, PlatformVersionSpecReader.class);
  try {
    SAXReader reader = new SAXReader();
    return reader.read(in);
  } catch (DocumentException e) {
    throw new RuntimeException("Cannot read the platform version definition", e);
  } finally {
    IOUtils.closeQuietly(in);
  }
}
origin: com.atlassian.plugins/atlassian-plugins-osgi

  cls = ClassLoaderUtils.loadClass(className, getClass());
} catch (ClassNotFoundException e) {
origin: com.atlassian.plugins/atlassian-plugins-core

  protected InputStream getSource() {
    if (resource != null) {
      return ClassLoaderUtils.getResourceAsStream(resource, this.getClass());
    }

    if (url != null) {
      try {
        return url.openConnection().getInputStream();
      } catch (IOException e) {
        throw new PluginParseException(e);
      }
    }

    throw new IllegalStateException("No defined method for getting an input stream.");
  }
}
origin: com.atlassian.plugins/atlassian-plugins-core

  private static String getPluginFrameworkVersionInternal() {
    Properties props = new Properties();
    InputStream in = null;

    try {
      in = ClassLoaderUtils.getResourceAsStream(BUILD_PROPERTY_PATH, PluginFrameworkUtils.class);
      if (in != null) {
        // this should automatically get rid of comment lines.
        props.load(in);
        return props.getProperty("version");
      } else {
        // probably ran via IDEA where pom.properties won't exist
        return "2.7.0";
      }

    } catch (IOException e) {
      LOG.error("cannot determine the plugin framework version", e);
      throw new IllegalStateException("cannot determine the plugin framework version", e);
    } finally {
      IOUtils.closeQuietly(in);
    }
  }
}
com.atlassian.plugin.utilClassLoaderUtils

Javadoc

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!

Most used methods

  • getResourceAsStream
    This is a convenience method to load a resource as a stream. The algorithm used to find the resource
  • getResource
    Load a given resource. This method will try to load the resource using the following methods (in ord
  • loadClass
    Load a class with a given name. It will try to load the class in the following order: * From Thread#
  • coerce
  • getResources
    returns all found resources as java.net.URLs. This method will try to load the resource using the fo
  • printClassLoader
    Prints the classloader hierarchy from a given classloader - useful for debugging.

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSupportFragmentManager (FragmentActivity)
  • runOnUiThread (Activity)
  • onRequestPermissionsResult (Fragment)
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now