Added exception handling in the main loop for the web server to avoid the main loop thread getting killed off due to an unexpected/unhandled exception.

Moved code for JSON handling and metadata/metadata container into the Common project from the Foundation project.
This commit is contained in:
wcrisman
2014-09-16 14:01:31 -07:00
parent 1a8fd62dd8
commit b48e81bfe0
39 changed files with 930 additions and 994 deletions

View File

@@ -31,12 +31,17 @@ public ResourceRequestHandler() {
try {
InputStream in = getClass().getClassLoader().getResourceAsStream("framework.js");
try {
frameworkJavascript = StreamSupport.readText(in, "UTF8");
}//try//
finally {
try {in.close();} catch(Throwable e) {}
}//finally//
if(in != null) {
try {
frameworkJavascript = StreamSupport.readText(in, "UTF8");
}//try//
finally {
try {in.close();} catch(Throwable e) {}
}//finally//
}//if//
else {
Debug.log("Warning: framework.js not found!");
}//else//
}//try//
catch(Throwable e) {
Debug.log("Failed to read the framework.js file from the framework jar.", e);

View File

@@ -486,12 +486,15 @@ public WebApplication(String name, WebOptions options, Application application)
}//if//
}//while//
SessionStore query = new SessionStore(WebApplication.this.application);
DeleteTransactionDefinition definition = new DeleteTransactionDefinition(query, null);
definition.addRequirement(query, query.UPDATE_TIMESTAMP, Operator.LESS_THAN, new Date(currentTime - sessionRepositoryTimeout));
DeleteTransaction transaction = new DeleteTransaction(definition, query);
transaction.setDebugLevel(Transaction.DEBUG_ERRORS);
query.getTransactionService().delete(transaction);
//If a transaction service is setup (it usually is) then remove the session store from the repository.//
if(WebApplication.this.application.getTransactionService() != null) {
SessionStore query = new SessionStore(WebApplication.this.application);
DeleteTransactionDefinition definition = new DeleteTransactionDefinition(query, null);
definition.addRequirement(query, query.UPDATE_TIMESTAMP, Operator.LESS_THAN, new Date(currentTime - sessionRepositoryTimeout));
DeleteTransaction transaction = new DeleteTransaction(definition, query);
transaction.setDebugLevel(Transaction.DEBUG_ERRORS);
query.getTransactionService().delete(transaction);
}//if//
}//try//
catch(Throwable e) {
Debug.log(e);