@Override public ResourceBundle getBundle(final Locale targetLocale, final Plugin plugin, final ResourceDescriptor descriptor) { return ResourceBundle.getBundle( descriptor.getLocation(), targetLocale, plugin.getClassLoader(), NO_FALLBACK_CONTROL); }
private ChainingClassLoader getChainingClassLoader(final Plugin plugin) { return new ChainingClassLoader(getClass().getClassLoader(), plugin.getClassLoader()); } }
private ChainingClassLoader getChainingClassLoader(final Plugin plugin) { return new ChainingClassLoader(getClass().getClassLoader(), plugin.getClassLoader()); } }
protected ClassLoader getClassLoader() { return getPlugin().getClassLoader(); }
private ResourceBundle getBundle(String bundleName, Locale locale, Plugin plugin) { return resolver.getBundle(bundleName, locale, plugin.getClassLoader()); }
private ResourceBundle getBundle(String bundleName, Locale locale, Plugin plugin) { return resolver.getBundle(bundleName, locale, plugin.getClassLoader()); }
private ResourceBundle getBundle(String bundleName, Locale locale, Plugin plugin) { return resolver.getBundle(bundleName, locale, plugin.getClassLoader()); }
@Override protected URL findResource(final String name) { final Plugin indexedPlugin; synchronized (this) { indexedPlugin = pluginResourceIndex.get(name); } final URL result; if (isPluginEnabled(indexedPlugin)) { result = indexedPlugin.getClassLoader().getResource(name); } else { result = getResourceFromPlugins(name); } if (log.isDebugEnabled()) { log.debug("Find resource [ " + name + " ], found [ " + result + " ]"); } return result; }
private URL getResourceFromPlugins(final String name) { final boolean isMissedResource; synchronized (this) { isMissedResource = missedPluginResource.contains(name); } if (isMissedResource) { return null; } final Collection<Plugin> plugins = pluginAccessor.getEnabledPlugins(); for (final Plugin plugin : plugins) { final URL resource = plugin.getClassLoader().getResource(name); if (resource != null) { synchronized (this) { pluginResourceIndex.put(name, plugin); } return resource; } } synchronized (this) { missedPluginResource.add(name); } return null; }
@Override protected TemplateRenderer createRenderer(Plugin plugin) { return new VelocityTemplateRendererImpl(plugin.getClassLoader(), plugin.getKey(), Collections.<String, String>emptyMap(), templateContextFactory); } }
@Override protected TemplateRenderer createRenderer(Plugin plugin) { return new VelocityTemplateRendererImpl(plugin.getClassLoader(), plugin.getKey(), Collections.<String, String>emptyMap(), templateContextFactory); } }
private <T> Class<T> loadClassEvenIfNotEnabled(final String className) throws ClassNotFoundException { // Here we don't limit to only enabled plugins like in PluginsClassLoader for (final Plugin plugin : pluginAccessor.getPlugins()) { try { //noinspection unchecked return (Class<T>) plugin.getClassLoader().loadClass(className); } catch (final ClassNotFoundException ex) { // continue searching the other plugins } catch (final RuntimeException re) { // Probably a ClassCastException from the wrong plugin or an IllegalStateException // from a plugin that's in the middle of disabling // continue searching the other plugins } catch (final LinkageError le) { // Binary incompatibility or runtime exception in a static initializer // continue searching the other plugins } } throw new ClassNotFoundException("Class '" + className + "' not found."); }
@Override protected Class<?> findClass(final String className) throws ClassNotFoundException { final Plugin indexedPlugin; synchronized (this) { indexedPlugin = pluginClassIndex.get(className); } final Class<?> result; if (isPluginEnabled(indexedPlugin)) { result = indexedPlugin.getClassLoader().loadClass(className); } else { result = loadClassFromPlugins(className); } if (log.isDebugEnabled()) { log.debug("Find class [ " + className + " ], found [ " + result + " ]"); } if (result != null) { return result; } else { throw new ClassNotFoundException(className); } }
private void addPluginResourceBundles(Plugin plugin) { List<ResourceBundle> bundles = new LinkedList<ResourceBundle>(); Iterable<ResourceDescriptor> descriptors = plugin.getResourceDescriptors("i18n"); for (ResourceDescriptor descriptor : descriptors) { try { bundles.add(ResourceBundle.getBundle(descriptor.getLocation(), Locale.getDefault(), plugin.getClassLoader())); } catch (MissingResourceException e) { // ignore, move on to next one } } pluginResourceBundles.put(plugin.getKey(), bundles); }
private Object bruteForceWireInstance(String className) { for (final Plugin plugin : pluginAccessor.getEnabledPlugins()) { try { @SuppressWarnings("unchecked") final Class clazz = plugin.getClassLoader().loadClass(className); if (log.isDebugEnabled()) { log.debug("Class '" + className + "' loaded from plugin " + plugin.getKey() + " - attempting to instantiate with dependencies..."); } Object o = newInstanceFromPlugin(clazz, plugin); if (log.isDebugEnabled()) { log.debug("Wired Class '" + className + "' successfully from plugin " + plugin.getKey() + " ."); } return o; } catch (Exception autowireException) { // continue searching the other plugins } } throw new RuntimeException("Class '" + className + "' is loadable from OSGi but no enabled plugins could autowire an instance."); }
public static PluginResourceResolver getResourceResolver(Plugin plugin) { Preconditions.checkNotNull(plugin); if (plugin instanceof OsgiPlugin) { return new OsgiPluginResourceResolver((OsgiPlugin) plugin); } else if (plugin.getClassLoader() instanceof PluginClassLoader) { return new PluginClassLoaderResourceResolver(plugin); } else { return new NoOpPluginResouceResolver(plugin); } } }
@Override public ResourceBundle getBundle(final LanguageModuleDescriptor descriptor) { return ResourceBundle.getBundle(descriptor.getResourceBundleName(), descriptor.getModule().getLocale(), descriptor.getPlugin().getClassLoader(), NO_FALLBACK_CONTROL); } }
private URL getResourceUrl(String resourceName) { final URL resource = ((PluginClassLoader) plugin.getClassLoader()).getLocalResource(resourceName); if (resource == null) { throw new PluginResourceNotFoundException(plugin.getKey(), resourceName); } return resource; } }
/** * Clear internal {@link java.util.ResourceBundle#cacheList} from plugin bundles. All plugin related bundles are * cached in I18nHelper so keeping a copy in {@link java.util.ResourceBundle#cacheList} will only be duplication. */ public void cleanPluginBundlesFromResourceBundleCache() { if(!jiraProperties.isResourceBundleCacheCleaningDisabled()) { final List<Plugin> enabledPlugins = Lists.newArrayList(pluginAccessor.get().getEnabledPlugins()); for (final Plugin plugin : enabledPlugins) { final ClassLoader pluginClassLoader = plugin.getClassLoader(); if (isPluginClassLoader(pluginClassLoader)) { ResourceBundle.clearCache(pluginClassLoader); } } } }
if (!isEmpty(this.getLicensesLocation())) ClassLoader classLoader = plugin.getClassLoader();