// the content expires, so remove it
cache.remove(cacheKey);
source = this.resolver.resolveURI(this.uri);
XMLSerializer serializer = null;
SAXParser parser = null;
byte[] cachedResponse;
byte[] content = null;
try {
serializer = (XMLSerializer)this.manager.lookup(XMLSerializer.ROLE);
if ( source instanceof XMLizable ) {
((XMLizable)source).toSAX(serializer);
} else {
// resd the content
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final byte[] buffer = new byte[2048];
final InputStream inputStream = source.getInputStream();
int length;
while ((length = inputStream.read(buffer)) > -1) {
baos.write(buffer, 0, length);
}
baos.flush();
inputStream.close();
content = baos.toByteArray();
parser = (SAXParser)this.manager.lookup(SAXParser.ROLE);
final InputSource inputSource = new InputSource(new ByteArrayInputStream(content));
inputSource.setSystemId(source.getURI());
parser.parse( inputSource, serializer );
}
cachedResponse = (byte[])serializer.getSAXFragment();
} finally {
this.manager.release(parser);
this.manager.release(serializer);
}