* @return the output stream packed into a byte array
* @throws Exception
*/
public byte[] resolve(HTMLSessionVariable sessionVariable, DataModel model, InputStream in, boolean isEditor)
throws Exception {
Semaphore semaphore = new Semaphore();
PipedInputStream in1 = new PipedInputStream();
PipedOutputStream out1 = new PipedOutputStream(in1);
PipedInputStream in2 = new PipedInputStream();
PipedOutputStream out2 = new PipedOutputStream(in2);
ByteArrayOutputStream out = new ByteArrayOutputStream();
VariableStore oldValues = null;
PushbackInputStream inParser = null;
if (observerStream == null) {
inParser = new PushbackInputStream(in2);
} else {
inParser = new PushbackInputStream(new InObserver(in2));
}
if (model != null) {
oldValues = new VariableStore();
variableStore.setVariable(VariableStore.FULLNAME, getModelStackAsString(model));
DataModelVariableHandler.setVariablesFor(model, variableStore, oldValues, translator);
}
// replace variables first
new PrecompilerThread(in, out1);
VariableResolverThread vr = new VariableResolverThread(new PushbackInputStream(in1), out2);
HTMLParserThread parser = new HTMLParserThread(sessionVariable, model, isEditor, inParser, out, semaphore);
semaphore.waitFor();
if (vr.getException() != null) {
throw vr.getException();
}