1 package de.juplo.httpresources; 2 3 import org.slf4j.Logger; 4 import org.slf4j.LoggerFactory; 5 import org.springframework.core.io.ProtocolResolver; 6 import org.springframework.core.io.ResourceLoader; 7 import org.springframework.util.Assert; 8 9 10 public class HttpResourceProtocolResolver implements ProtocolResolver 11 { 12 private final static Logger LOG = 13 LoggerFactory.getLogger(HttpResourceProtocolResolver.class); 14 15 16 private final HttpResources resources; 17 18 19 public HttpResourceProtocolResolver(HttpResources resources) 20 { 21 Assert.notNull(resources, "The HttpResources must not be null"); 22 this.resources = resources; 23 } 24 25 26 @Override 27 public HttpResource resolve(String location, ResourceLoader resourceLoader) 28 { 29 if (HttpResources.isHttpResource(location)) 30 { 31 LOG.debug("Loading HTTP-resource {}", location); 32 return resources.getResource(location); 33 } 34 35 return null; 36 } 37 }