// TODO: only need this synchronized method for dynamic registry entries. If there was a way
// to access the registry entry during mediator initialization then for non-dynamic entries
// this could be done just the once during mediator initialization.
Entry entry = synCtx.getConfiguration().getEntryDefinition(key);
boolean needsReload = (entry != null) && entry.isDynamic() &&
(!entry.isCached() || entry.isExpired());
synchronized (resourceLock) {
if (scriptSourceCode == null || needsReload) {
Object o = synCtx.getEntry(key);
if (o instanceof OMElement) {
scriptSourceCode = ((OMElement) (o)).getText();
scriptEngine.eval(scriptSourceCode);
} 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 (String includeKey : includes.keySet()) {
String includeSourceCode = (String) includes.get(includeKey);
Entry includeEntry = synCtx.getConfiguration().getEntryDefinition(includeKey);
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(includeKey);
if (o instanceof OMElement) {