&& (renderer instanceof HeaderResourceProducer2 || renderer instanceof HeaderResourceProducer)) {
context.setResponseWriter(componentWriter);
if (renderer instanceof HeaderResourceProducer2) {
HeaderResourceProducer2 producer = (HeaderResourceProducer2) renderer;
if (producerContext == null) {
producerContext = new ProducerContextImpl(processScripts, processStyles);
}
producer.encodeToHead(context, component, producerContext);
} else if (renderer instanceof HeaderResourceProducer) {
HeaderResourceProducer producer = (HeaderResourceProducer) renderer;
if (processScripts) {
encodeResources(context, resourceBuilder.getScriptRenderer(), producer.getHeaderScripts(context,
component));
}
if (processStyles) {
encodeResources(context, resourceBuilder.getStyleRenderer(), producer.getHeaderStyles(context,
component));
}
}
} else if (renderer instanceof UserResourceRenderer2) {
context.setResponseWriter(userWriter);
UserResourceRenderer2 producer = (UserResourceRenderer2) renderer;
producer.encodeToHead(context, component);
} else if (renderer instanceof UserResourceRenderer) {
context.setResponseWriter(userWriter);
UserResourceRenderer producer = (UserResourceRenderer) renderer;
encodeResources(context, resourceBuilder.getScriptRenderer(), producer.getHeaderScripts(context,
component));
encodeResources(context, resourceBuilder.getStyleRenderer(), producer.getHeaderStyles(context,
component));
}
} finally {
context.setResponseWriter(oldResponseWriter);
}