public URL normalizeToFileProtocol(URL url) { return fileManager.normalizeToFileProtocol(url); } });
/** * Tells whether the ConfigurationProvider should reload its configuration. This method should only be called * if ConfigurationManager.isReloadingConfigs() is true. * * @return true if the file has been changed since the last time we read it */ public boolean needsReload() { for (String url : loadedFileUrls) { if (fileManager.fileNeedsReloading(url)) { return true; } } return false; }
private List<ValidatorConfig> loadFile(String fileName, Class clazz, boolean checkFile) { List<ValidatorConfig> retList = Collections.emptyList(); URL fileUrl = ClassLoaderUtil.getResource(fileName, clazz); if ((checkFile && fileManager.fileNeedsReloading(fileUrl)) || !validatorFileCache.containsKey(fileName)) { InputStream is = null; try { is = fileManager.loadFile(fileUrl); if (is != null) { retList = new ArrayList<ValidatorConfig>(validatorFileParser.parseActionValidatorConfigs(validatorFactory, is, fileName)); } } finally { if (is != null) { try { is.close(); } catch (IOException e) { LOG.error("Unable to close input stream for " + fileName, e); } } } validatorFileCache.put(fileName, retList); } else { retList = validatorFileCache.get(fileName); } return retList; } }
private List<URL> readUrls() throws IOException { List<URL> resourceUrls = new ArrayList<>(); // Usually the "classes" dir. ArrayList<URL> classesList = Collections.list(getClassLoaderInterface().getResources("")); for (URL url : classesList) { resourceUrls.addAll(fileManager.getAllPhysicalUrls(url)); } return buildUrlSet(resourceUrls).getUrls(); }
for (String fmName : names) { FileManager fm = container.getInstance(FileManager.class, fmName); if (fm.internal()) { internals.add(fm); } else { if (fm.support()) { if (LOG.isDebugEnabled()) { LOG.debug("Using FileManager implementation [#0]", fm.getClass().getSimpleName()); if (fm.support()) { return fm;
public void process(Map<String, Object> mapping, Class clazz, String converterFilename) { try { InputStream is = fileManager.loadFile(ClassLoaderUtil.getResource(converterFilename, clazz));
public FileManager getFileManager() { FileManager fileManager = lookupFileManager(); if (fileManager != null) { if (LOG.isDebugEnabled()) { LOG.debug("Using FileManager implementation [#0]", fileManager.getClass().getSimpleName()); } fileManager.setReloadingConfigs(reloadingConfigs); return fileManager; } if (LOG.isDebugEnabled()) { LOG.debug("Using default implementation of FileManager provided under name [system]: #0", systemFileManager.getClass().getSimpleName()); } systemFileManager.setReloadingConfigs(reloadingConfigs); return systemFileManager; }
fileManager.monitorFile(classFile); loadedFileUrls.add(classFile.toString());
if ((checkFile && fileManager.fileNeedsReloading(fileUrl)) || !validatorFileCache.containsKey(fileName)) { InputStream is = null; is = fileManager.loadFile(fileUrl);
private List<URL> readUrls() throws IOException { List<URL> resourceUrls = new ArrayList<URL>(); // Usually the "classes" dir. ArrayList<URL> classesList = Collections.list(getClassLoaderInterface().getResources("")); for (URL url : classesList) { resourceUrls.addAll(fileManager.getAllPhysicalUrls(url)); } return buildUrlSet(resourceUrls).getUrls(); }
try { url = urls.next(); is = fileManager.loadFile(url);
public URL normalizeToFileProtocol(URL url) { return fileManager.normalizeToFileProtocol(url); } });
public boolean needsReload() { if (devMode && reload) { for (String url : loadedFileUrls) { if (fileManager.fileNeedsReloading(url)) { LOG.debug("File [{}] changed, configuration will be reloaded", url); return true; } } return false; } else { return false; } }
private List<String> jar(URL location) throws IOException { URL url = fileManager.normalizeToFileProtocol(location); if (url != null) { InputStream in = url.openStream(); try { JarInputStream jarStream = new JarInputStream(in); return jar(jarStream); } finally { in.close(); } } else { LOG.debug("Unable to read [{}]", location.toExternalForm()); } return Collections.emptyList(); }
private Map<String, Object> conditionalReload(Class clazz, Map<String, Object> oldValues) throws Exception { Map<String, Object> mapping = oldValues; if (reloadingConfigs) { URL fileUrl = ClassLoaderUtil.getResource(buildConverterFilename(clazz), clazz); if (fileManager.fileNeedsReloading(fileUrl)) { mapping = buildConverterMapping(clazz); } } return mapping; }
private List<String> jar(URL location) throws IOException { URL url = fileManager.normalizeToFileProtocol(location); if (url != null) { InputStream in = url.openStream(); try { JarInputStream jarStream = new JarInputStream(in); return jar(jarStream); } finally { in.close(); } } else if (LOG.isDebugEnabled()) LOG.debug("Unable to read [#0]", location.toExternalForm()); return Collections.emptyList(); }
String fileNameInJar = fileName.substring(index).replaceAll("%20", " "); URL url = fileManager.normalizeToFileProtocol(fileUrl); if (url != null) { JarFile jarFile = new JarFile(FileUtils.toFile(url));
public ReloadingClassLoader(final ClassLoader pParent) { super(pParent); parent = pParent; URL parentRoot = pParent.getResource(""); FileManager fileManager = ActionContext.getContext().getInstance(FileManagerFactory.class).getFileManager(); URL root = fileManager.normalizeToFileProtocol(parentRoot); root = ObjectUtils.defaultIfNull(root, parentRoot); try { if (root != null) { stores = new ResourceStore[]{new FileResourceStore(new File(root.toURI()))}; } else { throw new XWorkException("Unable to start the reloadable class loader, consider setting 'struts.convention.classes.reload' to false"); } } catch (URISyntaxException e) { throw new XWorkException("Unable to start the reloadable class loader, consider setting 'struts.convention.classes.reload' to false", e); } catch (RuntimeException e) { // see WW-3121 // TODO: Fix this for a reloading mechanism to be marked as stable if (root != null) LOG.error("Exception while trying to build the ResourceStore for URL [#0]", e, root.toString()); else LOG.error("Exception while trying to get root resource from class loader", e); LOG.error("Consider setting struts.convention.classes.reload=false"); throw e; } delegate = new ResourceStoreClassLoader(parent, stores); }