}
@SuppressWarnings("unchecked")
public MarkupTemplateMaker(final URL resource, Map<String, String> modelTypes) throws IOException {
boolean cache = templateConfiguration.isCacheTemplates();
GroovyCodeSource codeSource;
if (cache) {
// we use a map in addition to the internal caching mechanism of Groovy because the latter
// will always read from the URL even if it's cached
String key = resource.toExternalForm();
codeSource = codeSourceCache.get(key);
if (codeSource == null) {
codeSource = new GroovyCodeSource(resource);
codeSourceCache.put(key, codeSource);
}
} else {
codeSource = new GroovyCodeSource(resource);
}
codeSource.setCachable(cache);
templateClass = groovyClassLoader.parseClass(codeSource, modelTypes);
this.modeltypes = modelTypes;
}