List of usage examples for org.springframework.web.servlet.resource ResourceHttpRequestHandler setLocations
public void setLocations(List<Resource> locations)
From source file:com.javaetmoi.core.spring.vfs.Vfs2ResourceHandlerRegistration.java
@Override protected ResourceHttpRequestHandler getRequestHandler() { Field locationsField = ReflectionUtils.findField(ResourceHandlerRegistration.class, "locations"); ReflectionUtils.makeAccessible(locationsField); @SuppressWarnings("unchecked") List<Resource> locations = (List<Resource>) ReflectionUtils.getField(locationsField, this); Field cachePeriodField = ReflectionUtils.findField(ResourceHandlerRegistration.class, "cachePeriod"); ReflectionUtils.makeAccessible(cachePeriodField); Integer cachePeriod = (Integer) ReflectionUtils.getField(cachePeriodField, this); // Initial code is replace by a new Vfs2ResourceHttpRequestHandler() Assert.isTrue(!CollectionUtils.isEmpty(locations), "At least one location is required for resource handling."); ResourceHttpRequestHandler requestHandler = new Vfs2ResourceHttpRequestHandler(); requestHandler.setLocations(locations); if (cachePeriod != null) { requestHandler.setCacheSeconds(cachePeriod); }//from ww w .ja v a2 s . c om return requestHandler; }