} else if (o instanceof String) {
scriptSourceCode = (String) o;
scriptEngine.eval(scriptSourceCode);
} else if (o instanceof OMText) {
DataHandler dataHandler = (DataHandler) ((OMText) o).getDataHandler();
if (dataHandler != null) {
BufferedReader reader = null;
try {
reader = new BufferedReader(
new InputStreamReader(dataHandler.getInputStream()));
scriptEngine.eval(reader);
} catch (IOException e) {
handleException("Error in reading script as a stream ", e, synCtx);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
handleException("Error in closing input stream ", e, synCtx);
}
}
}
}
}
}
}
// load <include /> scripts; reload each script if needed
for (Value includeKey : includes.keySet()) {
String includeSourceCode = (String) includes.get(includeKey);
String generatedKey = includeKey.evaluateValue(synCtx);
Entry includeEntry = synCtx.getConfiguration().getEntryDefinition(generatedKey);
boolean includeEntryNeedsReload = (includeEntry != null) && includeEntry.isDynamic()
&& (!includeEntry.isCached() || includeEntry.isExpired());
synchronized (resourceLock) {
if (includeSourceCode == null || includeEntryNeedsReload) {
log.debug("Re-/Loading the include script with key " + includeKey);
Object o = synCtx.getEntry(generatedKey);
if (o instanceof OMElement) {
includeSourceCode = ((OMElement) (o)).getText();
scriptEngine.eval(includeSourceCode);
} else if (o instanceof String) {
includeSourceCode = (String) o;
scriptEngine.eval(includeSourceCode);
} else if (o instanceof OMText) {
DataHandler dataHandler = (DataHandler) ((OMText) o).getDataHandler();
if (dataHandler != null) {
BufferedReader reader = null;
try {
reader = new BufferedReader(
new InputStreamReader(dataHandler.getInputStream()));
scriptEngine.eval(reader);
} catch (IOException e) {
handleException("Error in reading script as a stream ", e, synCtx);
} finally {