ProgressMonitor.setTaskDescription("Loading " + dynamicContent.getContentDescription());
DebugInfo debugInfo = preLoadContent(dynamicContent);
dynamicContent.checkDisposed();
ConnectionHandler connectionHandler = dynamicContent.getConnectionHandler();
LoaderCache loaderCache = new LoaderCache();
Connection connection = null;
ResultSet resultSet = null;
int count = 0;
try {
connectionHandler.getLoadMonitor().incrementLoaderCount();
connection = connectionHandler.getPoolConnection();
dynamicContent.checkDisposed();
resultSet = createResultSet(dynamicContent, connection);
if (addDelay) Thread.sleep(500);
List<T> list = null;
while (resultSet != null && resultSet.next()) {
if (addDelay) Thread.sleep(10);
dynamicContent.checkDisposed();
T element = null;
try {
element = createElement(dynamicContent, resultSet, loaderCache);
} catch (RuntimeException e){
System.out.println("RuntimeException: " + e.getMessage());
}
dynamicContent.checkDisposed();
if (element != null && dynamicContent.accepts(element)) {
if (list == null) list = new ArrayList<T>();
list.add(element);
if (count%10 == 0) {
String description = element.getDescription();
if (description != null)
ProgressMonitor.setSubtaskDescription(description);
}
count++;
}
}
dynamicContent.checkDisposed();
dynamicContent.setElements(list);
postLoadContent(dynamicContent, debugInfo);
} catch (Exception e) {
if (e instanceof InterruptedException) throw (InterruptedException) e;
if (e == DynamicContentLoader.DBN_INTERRUPTED_EXCEPTION) throw new InterruptedException();
String message = StringUtil.trim(e.getMessage()).replace("\n", " ");
LOGGER.warn("Error loading database content (" + dynamicContent.getContentDescription() + "): " + message);
boolean modelException = false;
if (e instanceof SQLException) {
SQLException sqlException = (SQLException) e;
DatabaseInterfaceProvider interfaceProvider = dynamicContent.getConnectionHandler().getInterfaceProvider();
modelException = interfaceProvider.getMessageParserInterface().isModelException(sqlException);
}
throw new DynamicContentLoadException(e, modelException);
} finally {
connectionHandler.getLoadMonitor().decrementLoaderCount();
ConnectionUtil.closeResultSet(resultSet);
connectionHandler.freePoolConnection(connection);
}
}