@Override
    public LoadedResource<Templates> loadResource(Resource resource) throws IOException {
        final TransformerFactory transformerFactory = TransformerFactory.newInstance();

        if (this.transformerAttributes != null) {
            for (final Map.Entry<String, Object> attributeEntry :
                    this.transformerAttributes.entrySet()) {
                transformerFactory.setAttribute(attributeEntry.getKey(), attributeEntry.getValue());
            }
        }

        final ResourceTrackingURIResolver uriResolver =
                new ResourceTrackingURIResolver(this.resourceLoader);
        transformerFactory.setURIResolver(uriResolver);

        final URI uri = resource.getURI();
        final String systemId = uri.toString();

        final InputStream stream = resource.getInputStream();
        final Templates templates;
        try {
            final StreamSource source = new StreamSource(stream, systemId);
            templates = transformerFactory.newTemplates(source);
        } catch (TransformerConfigurationException e) {
            throw new IOException("Failed to parse stream into Templates", e);
        } finally {
            IOUtils.closeQuietly(stream);
        }

        final Map<Resource, Long> resolvedResources = uriResolver.getResolvedResources();

        return new LoadedResourceImpl<Templates>(templates, resolvedResources);
    }
@ Override public LoadedResource < Templates > loadResource ( Resource resource ) throws IOException { final TransformerFactory transformerFactory = TransformerFactory . newInstance ( ) ; if ( this . transformerAttributes != null ) { for ( final Map . Entry < String , Object > attributeEntry : this . transformerAttributes . entrySet ( ) ) { transformerFactory . setAttribute ( attributeEntry . getKey ( ) , attributeEntry . getValue ( ) ) ; } } final ResourceTrackingURIResolver uriResolver = new ResourceTrackingURIResolver ( this . resourceLoader ) ; transformerFactory . setURIResolver ( uriResolver ) ; final URI uri = resource . getURI ( ) ; final String systemId = uri . toString ( ) ; final InputStream stream = resource . getInputStream ( ) ; final Templates templates ; try { final StreamSource source = new StreamSource ( stream , systemId ) ; templates = transformerFactory . newTemplates ( source ) ; } catch ( TransformerConfigurationException e ) { throw new IOException ( "Failed to parse stream into Templates" , e ) ; } finally { IOUtils . closeQuietly ( stream ) ; } final Map < Resource , Long > resolvedResources = uriResolver . getResolvedResources ( ) ; return new LoadedResourceImpl < Templates > ( templates , resolvedResources ) ; }
/* (non-Javadoc)
@see org.apereo.portal.utils.cache.resource.ResourceBuilder#buildResource(org.springframework.core.io.Resource, java.io.InputStream)