@Override @Nullable public ApplicationResource getResource(ApplicationResource base, Locale locale) { Collection<ApplicationResource> urlSet = getResources(base.getLocalePath(locale)); if (!CollectionUtils.isEmpty(urlSet)) { return urlSet.iterator().next(); } return null; }
lastModifiedDates.put(resource.getLocalePath(), resource .getLastModified()); stream = resource.getInputStream(); defsMap = reader.read(stream); } catch (FileNotFoundException e) {
/** {@inheritDoc} */ public ApplicationResource getResource(ApplicationResource base, Locale locale) { try { URL url = servletContext.getResource(base.getLocalePath(locale)); if (url != null) { return new URLApplicationResource(base.getPath(), locale, url); } else { return null; } } catch (MalformedURLException e) { return null; } }
public void setSources(List<ApplicationResource> sources) { // filter out any sources that are already localized ArrayList<ApplicationResource> defaultSources = new ArrayList<ApplicationResource>(); for(ApplicationResource source: sources) { if(Locale.ROOT.equals(source.getLocale())) { defaultSources.add(source); } } this.sources = defaultSources; }
InputStream stream = resource.getInputStream(); try { Manifest manifest = new Manifest(stream);
/** {@inheritDoc} */ public boolean refreshRequired() { boolean status = false; Set<String> paths = lastModifiedDates.keySet(); try { for (String path : paths) { Long lastModifiedDate = lastModifiedDates.get(path); ApplicationResource resource = applicationContext.getResource(path); long newModDate = resource.getLastModified(); if (newModDate != lastModifiedDate) { status = true; break; } } } catch (IOException e) { log.warn("Exception while monitoring update times.", e); return true; } return status; }
/** {@inheritDoc} */ public ApplicationResource getResource(ApplicationResource base, Locale locale) { try { URL url = context.getResource(base.getLocalePath(locale)); if (url != null) { return new URLApplicationResource(base.getPath(), locale, url); } else { return null; } } catch (MalformedURLException e) { return null; } }
/** {@inheritDoc} */ @Override protected List<ApplicationResource> getSources(ApplicationContext applicationContext) { Collection<ApplicationResource> webINFSet = applicationContext.getResources("/WEB-INF/**/tiles*.xml"); Collection<ApplicationResource> metaINFSet = applicationContext .getResources("classpath*:META-INF/**/tiles*.xml"); List<ApplicationResource> filteredResources = new ArrayList<ApplicationResource>(); if (webINFSet != null) { for (ApplicationResource resource : webINFSet) { if (Locale.ROOT.equals(resource.getLocale())) { filteredResources.add(resource); } } } if (metaINFSet != null) { for (ApplicationResource resource : metaINFSet) { if (Locale.ROOT.equals(resource.getLocale())) { filteredResources.add(resource); } } } return filteredResources; }
@Override @Nullable public ApplicationResource getResource(ApplicationResource base, Locale locale) { Collection<ApplicationResource> urlSet = getResources(base.getLocalePath(locale)); if (!CollectionUtils.isEmpty(urlSet)) { return urlSet.iterator().next(); } return null; }
@Override protected List<ApplicationResource> getSources(ApplicationContext applicationContext) { Collection<ApplicationResource> resources = new ArrayList<>(); Set<String> definitions = getTilesDefinitions(applicationContext.getInitParams()); for (String definition : definitions) { resources.addAll(applicationContext.getResources(definition)); } if (resources.contains(null)) { LOG.warn("Some resources were not found. Definitions: {}. Found resources: {}", definitions, resources); } List<ApplicationResource> filteredResources = new ArrayList<>(); for (ApplicationResource resource : resources) { if (resource != null && Locale.ROOT.equals(resource.getLocale())) { filteredResources.add(resource); } } return filteredResources; }
public ApplicationResource getResource(ApplicationResource base, Locale locale) { String localePath = base.getLocalePath(locale); File localFile = new File(localePath); if (localFile.exists()) { try { return new StrutsApplicationResource(localFile.toURI().toURL()); } catch (MalformedURLException e) { LOG.warn("Cannot access [{}]", localePath, e); return null; } } return null; }
@Override public ApplicationResource getResource(ApplicationResource base, Locale locale) { Collection<ApplicationResource> urlSet = getResources(base.getLocalePath(locale)); if (!CollectionUtils.isEmpty(urlSet)) { return urlSet.iterator().next(); } return null; }