public void integrate(Loader loader, Location location, ConfigurationAtom atom, Object focus) { if (focus != null && focus instanceof StreamableResourceSource) { if ("public-resource".equals(atom.getType()) || "classpath-public-resource".equals(atom.getType())) { StreamableResourcesHandler handler = new StreamableResourcesHandler((StreamableResourceSource) focus); if (atom instanceof PropertiesAtom) { PropertiesAtom propAtom = (PropertiesAtom) atom; handler.setShowDirectoryContents( BooleanUtils.toBoolean(propAtom.getProperties().get(SHOW_DIRECTORY_CONTENTS))); String cacheTime = propAtom.getProperties().get(CACHE_TIME); if (StringUtils.isNotBlank(cacheTime)) { handler.setCacheTime(Integer.parseInt(cacheTime)); } } handlerInvestigator.analyzeObject(handler); } } }
public Object create(Loader loader, Location location, ConfigurationAtom atom) { WebAppLocation webApp = new WebAppLocation(location); String appLocation = (String) webApp.getServiceByName(APPLICATION_ON_DISK_LOCATION); if (appLocation == null) { return null; } String resourceLocation; if (atom instanceof FocusAndPropertiesAtom) { resourceLocation = ((FocusAndPropertiesAtom) atom).getFocus(); } else { resourceLocation = atom.getValue(); } if ("public-resource".equals(atom.getType())) { File root = new File(new File(appLocation), resourceLocation); return new FileStreamableResourceSource(root); } if ("classpath-public-resource".equals(atom.getType())) { return new ClasspathFileStreamableResourceSource(resourceLocation); } if ("resource-sink".equals(atom.getType())) { File root = new File(new File(appLocation), ((FocusAndPropertiesConfigurationAtom) atom).getFocus()); Object o = new FileStreamableResourceSink(root); Map<String, String> props = ((PropertiesConfigurationAtom) atom).getProperties(); if (props.containsKey("name")) { webApp.setServiceByName(props.get("name"), o); } return o; } return null; }