@Override public URL resourceToUrl(String resourceName) { URL url = receivePluginDirUrl(resourceName); if (url != null) { return url; } return getResourceUrl(resourceName); } }
@Provides @Singleton PluginResourceService providePluginResourceService() { return new PluginResourceService(pluginDirectory); }
@Override public URL resourceToUrl(String resourceName) { try { URL url = null; if (resourceName.startsWith(PLUGIN_FILE_PREFIX)) { url = pluginResourceService.resourceToUrl(resourceName.substring(PLUGIN_FILE_PREFIX.length())); } else if (resourceName.startsWith("file:") || resourceName.startsWith("http://") || resourceName.startsWith("https://")) { url = new URL(resourceName); } else { //url = new File(resourceName).toURI().toURL(); url = pluginResourceService.resourceToUrl(resourceName); } return url; } catch (MalformedURLException e) { throw new RuntimeException("can't recive URL for resource: " + resourceName); } } }