Skip to content

Instantly share code, notes, and snippets.

@nschlimm
Created September 9, 2011 13:34
Show Gist options
  • Save nschlimm/1206220 to your computer and use it in GitHub Desktop.
Save nschlimm/1206220 to your computer and use it in GitHub Desktop.
HTMLDocumentGenerator
public class HTMLDocumentGenerator implements DocumentGenerator, Initialisierbar, Reinitialisierbar, HTMLDocumentGeneratorMBean {
private final ConcurrentHashMap<String, ConcurrentTransformer> transformerCache =
new ConcurrentHashMap<String, ConcurrentTransformer>();
private int concurrentParserThreadCount = 10;
protected Semaphore bouncer;
...
public void createDocument(OutputStream document, Map<String, ?> inputData) throws DocumentGeneratorAusnahme {
...
ConcurrentTransformer newTransformer;
ConcurrentTransformer transformer =
transformerCache.putIfAbsent(xslDocumentName, newTransformer = new ConcurrentTransformer(xslDocumentName));
if (transformer == null) {
transformer = newTransformer;
}
template = transformer.generateTemplate(loadTimeApplication);
...
}
...
public void initialize() throws InitialisierungsAusnahme {
transformerCache.clear();
if (concurrentParserThreadCount <= 0) {
concurrentParserThreadCount = 10;
}
bouncer = new Semaphore(concurrentParserThreadCount);
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment