Removed fancy debug logging from web server to prevent logging causing logging due to logging Monitor lock/unlock calls. Need to replace this logging code with a non-framework queue to allow remote management of the web server and log transfer.

This commit is contained in:
wcrisman
2014-07-12 15:49:35 -07:00
parent 0081ad43b9
commit 17e9c5a153

View File

@@ -16,6 +16,7 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import com.common.comparison.Comparator;
import com.common.debug.ConsoleLog;
import com.common.debug.Debug;
import com.common.debug.DefaultLog;
import com.common.debug.ILog;
@@ -99,6 +100,54 @@ public class WebServerApplication extends Application implements IWebServer {
/** The server application's metadata. Used currently to house the logging. */
private ServerApp serverApp = null;
private static class AppLog extends ConsoleLog implements IAppLog {
public void log(int type, String note, Throwable exception) {
log(note, exception, type, true);
}//log()//
/*
private boolean suspend = false;
public void log(int type, String note, Throwable exception) {
//Prevent the act of logging from generating logs since it would create an infinate loop.//
if(!suspend) {
suspend = true;
try {
IWebappLog log = metadata.getLog();
if(log != null) {
switch(type) {
case WebappLogEntry.TYPE_ERROR: {
metadata.setErrorCount(new Integer(metadata.getErrorCount().intValue() + 1));
break;
}//case//
case WebappLogEntry.TYPE_WARNING: {
metadata.setWarningCount(new Integer(metadata.getWarningCount().intValue() + 1));
break;
}//case//
case WebappLogEntry.TYPE_INFORMATION: {
metadata.setInfoCount(new Integer(metadata.getInfoCount().intValue() + 1));
break;
}//case//
default: {
break;
}//case//
}//switch//
((WebappLog) Orb.getLocal(log)).addEntry(new WebappLogEntry(type, note, exception));
}//if//
else {
new RuntimeException("ERROR: Failed to log for a web application due to a missing webapp log object.").printStackTrace();
}//else//
}//try//
finally {
suspend = false;
}//finally//
}//if//
}//log()//
*/
}//AppLog//
private static class AppMetadata {
public String className = null;
}//AppMetadata//
@@ -362,40 +411,7 @@ protected void startApplication(File serverXmlPath) {
try {
setServerApp(new ServerApp(serverXmlPath.getParentFile()));
getServerApp().getInfoChangeFlag();
Debug.setLog(new DefaultLog() {
private boolean suspend = false;
public void log(String note, Throwable exception, int type, boolean forceDisplay) {
//Prevent the act of logging from generating logs since it would create an infinate loop.//
if(!suspend) {
suspend = true;
try {
switch(type) {
case WebappLogEntry.TYPE_ERROR: {
getServerApp().setErrorCount(new Integer(getServerApp().getErrorCount().intValue() + 1));
break;
}//case//
case WebappLogEntry.TYPE_WARNING: {
getServerApp().setWarningCount(new Integer(getServerApp().getWarningCount().intValue() + 1));
break;
}//case//
case WebappLogEntry.TYPE_INFORMATION: {
getServerApp().setInfoCount(new Integer(getServerApp().getInfoCount().intValue() + 1));
break;
}//case//
default: {
break;
}//case//
}//switch//
((WebappLog) Orb.getLocal(getServerApp().getLog())).addEntry(new WebappLogEntry(type, note, exception));
}//try//
finally {
suspend = false;
}//finally//
}//if//
}//log()//
});
Debug.setLog(new AppLog());
}//try//
catch(Throwable e) {
Debug.log(e);
@@ -1111,47 +1127,7 @@ protected void loadWebApplications(final WebappBundle metadata) throws IOExcepti
try {
Class cls = classLoader.findClass(app.className);
IWebApplicationFactory webApplicationFactory = (IWebApplicationFactory) cls.newInstance();
IAppLog appLog = new IAppLog() {
private boolean suspend = false;
public void log(int type, String note, Throwable exception) {
//Prevent the act of logging from generating logs since it would create an infinate loop.//
if(!suspend) {
suspend = true;
try {
IWebappLog log = metadata.getLog();
if(log != null) {
switch(type) {
case WebappLogEntry.TYPE_ERROR: {
metadata.setErrorCount(new Integer(metadata.getErrorCount().intValue() + 1));
break;
}//case//
case WebappLogEntry.TYPE_WARNING: {
metadata.setWarningCount(new Integer(metadata.getWarningCount().intValue() + 1));
break;
}//case//
case WebappLogEntry.TYPE_INFORMATION: {
metadata.setInfoCount(new Integer(metadata.getInfoCount().intValue() + 1));
break;
}//case//
default: {
break;
}//case//
}//switch//
((WebappLog) Orb.getLocal(log)).addEntry(new WebappLogEntry(type, note, exception));
}//if//
else {
new RuntimeException("ERROR: Failed to log for a web application due to a missing webapp log object.").printStackTrace();
}//else//
}//try//
finally {
suspend = false;
}//finally//
}//if//
}//log()//
};
IAppLog appLog = new AppLog();
metadata.setWebApplications(webApplicationFactory.createWebApplications(metadata.getBaseDirectory(), externalApp == null || externalApp.externalBaseDirectory == null ? null : new File(externalApp.externalBaseDirectory), externalApp == null || externalApp.cacheBaseDirectory == null ? null : new File(externalApp.cacheBaseDirectory), appLog, externalApp == null ? new Properties(System.getProperties()) : externalApp.properties));
metadata.setWebApplicationFactory(webApplicationFactory);