package es.internna.framework.spring.mvc;
import es.internna.framework.annotations.UrlMapping;
import es.internna.framework.annotations.UrlMappings;
import es.internna.framework.utils.ClassUtils;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
public abstract class AbstractRequestHandler implements RequestHandler
{
private Set<String> urlMappings = new HashSet<String>();
public final void setMappings(Set<String> urlMappings)
{
this.urlMappings = urlMappings;
}
public final Set<String> getUrlMappings()
{
Set<String> combinedMappings = new HashSet<String>(urlMappings);
UrlMapping urlMapping = ClassUtils.getAnnotation(UrlMapping.class, this);
if ((urlMapping != null) && (urlMapping.value() != null)) combinedMappings.add(urlMapping.value());
UrlMappings mappings = ClassUtils.getAnnotation(UrlMappings.class, this);
if (mappings != null)
for (UrlMapping map : mappings.value())
if ((map != null) && (map.value() != null)) combinedMappings.add(map.value());
return combinedMappings;
}
public final void addMapping(String urlMapping)
{
if (urlMapping != null) this.urlMappings.add(urlMapping);
}
public final void addMappings(Collection<String> urlMappings)
{
if (urlMappings != null) {
for (String urlMapping : urlMappings) {
if (urlMapping != null) this.urlMappings.add(urlMapping);
}
}
}
}