Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,8 @@ public void trace(String msg, Throwable ex) {
public boolean isDebugEnabled() {
return true;
}

public boolean isErrorEnabled() {
return true;
};
}
18 changes: 9 additions & 9 deletions common/src/main/java/com/genexus/GXJarClassLoader.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

package com.genexus;
import com.genexus.diagnostics.core.ILogger;
import com.genexus.diagnostics.core.LogManager;

import java.io.*;
import java.util.*;
import java.util.zip.*;

public class GXJarClassLoader extends ClassLoader
{
private static final boolean DEBUG = DebugFlag.DEBUG;
private String source;
private ZipFile zipFile = null;
private boolean sourceIsJAR;
Expand All @@ -15,6 +17,8 @@ public class GXJarClassLoader extends ClassLoader
private long jarTimeStamp = 0;
private boolean autoReload;
private int loadDepth; // Esta variable mantiene un depth de intentos de lectura del Zip

private static final ILogger logger = LogManager.getLogger(GXJarClassLoader.class);

/** El Nombre esta medio mal, porque el GXJarClassLoader obtiene las clases de un JAR o
* de una directorio base
Expand All @@ -30,8 +34,7 @@ public GXJarClassLoader(String location, boolean autoReload)
sourceIsJAR = new File(source).isFile();
loadDepth = 0;
if(!autoReload)openJar();
if(DEBUG)
System.out.println("## GXJarClassLoader: Initialized (autoReloading: " + autoReload + ")");
logger.debug("## GXJarClassLoader: Initialized (autoReloading: " + autoReload + ")");
}

/** Obtiene el ClassLoader asociado. En efecto lo que hace es retornarse a s� mismo en el
Expand All @@ -45,8 +48,7 @@ public GXJarClassLoader getClassLoaderInstance()
return this;
else
{
if (DEBUG)
System.out.println("## GXJarClassLoader: Changed classes detected ..." );
logger.debug("## GXJarClassLoader: Changed classes detected ..." );
return new GXJarClassLoader(source, autoReload);
}
}
Expand Down Expand Up @@ -134,8 +136,7 @@ public synchronized Class loadClass(String className, boolean resolveIt) throws
try
{
result = this.getClass().getClassLoader().loadClass(className);
if(DEBUG)
System.out.println("## GXJarClassLoader: Loading ParentClass: " + className);
logger.debug("## GXJarClassLoader: Loading ParentClass: " + className);
return result;
}catch(Throwable e) { ; }
throw new ClassNotFoundException(className);
Expand Down Expand Up @@ -168,8 +169,7 @@ private byte[] loadBytes(String className)
byte[] result = null;
className = className.replace('.', '/') + ".class";

if(DEBUG)
System.out.println("## GXJarClassLoader: Loading class: " + className + " [" + source + "]");
logger.debug("## GXJarClassLoader: Loading class: " + className + " [" + source + "]");
try
{
if(sourceIsJAR)
Expand Down
14 changes: 7 additions & 7 deletions common/src/main/java/com/genexus/ModelContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import com.genexus.common.interfaces.IClientPreferences;
import com.genexus.common.interfaces.IPreferences;
import com.genexus.common.interfaces.SpecificImplementation;
import com.genexus.diagnostics.core.ILogger;
import com.genexus.diagnostics.core.LogManager;
import com.genexus.util.GUIContextNull;
import com.genexus.util.GXThreadLocal;
import com.genexus.util.IGUIContext;
Expand All @@ -34,17 +36,15 @@ public final class ModelContext extends AbstractModelContext
public boolean inErrorHandler = false;

public static IThreadLocal threadModelContext = GXThreadLocal.newThreadLocal();
private static final ILogger logger = LogManager.getLogger(ModelContext.class);

public static ModelContext getModelContext()
{
ModelContext context = (ModelContext)threadModelContext.get();
if(DebugFlag.DEBUG)
{
if(context == null)
{
System.err.println(new Date() + " - Cannot find ModelContext for thread " + Thread.currentThread() );
}
}
if(context == null)
{
logger.error(new Date() + " - Cannot find ModelContext for thread " + Thread.currentThread() );
}
return context;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public interface ILogger {

boolean isDebugEnabled();

boolean isErrorEnabled();

// Lambda Functions not supported JAVA 7. Only Java 8.
/*
* public static void debug(Logger log, String startMsg, Func<String> buildMsg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

public interface GXInternetConstants
{
static boolean DEBUG = com.genexus.DebugFlag.DEBUG;

static String CRLFString = System.getProperty("line.separator");

static String BASE64 = "base64";
Expand Down
23 changes: 8 additions & 15 deletions common/src/main/java/com/genexus/internet/RFC822EndReader.java
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
package com.genexus.internet;

import com.genexus.diagnostics.core.ILogger;
import com.genexus.diagnostics.core.LogManager;

import java.io.*;

class RFC822EndReader extends BufferedReader implements GXInternetConstants
public class RFC822EndReader extends BufferedReader implements GXInternetConstants
{
private String lastLine;
private boolean isEndOfMessage = false;
private PrintStream logOutput;
private static final ILogger logger = LogManager.getLogger(RFC822EndReader.class);

public RFC822EndReader(Reader reader, PrintStream logOutput)
public RFC822EndReader(Reader reader)
{
super(reader);
this.logOutput = logOutput;
}

private int log(int line)
{
if (DEBUG)
{
if (logOutput != null)
logOutput.println("byte: " + line);
}

logger.debug("byte: " + line);
return line;
}

private String log(String line)
{
if (DEBUG)
{
if (logOutput != null)
logOutput.println("Line: " + line);
}
logger.debug("Line: " + line);

return line;
}
Expand Down
61 changes: 22 additions & 39 deletions common/src/main/java/com/genexus/util/DelimitedFilesSafe.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import java.io.*;

import com.genexus.*;
import com.genexus.diagnostics.core.ILogger;
import com.genexus.diagnostics.core.LogManager;
import com.genexus.platform.INativeFunctions;
import com.genexus.common.interfaces.SpecificImplementation;

Expand All @@ -15,6 +17,7 @@
public class DelimitedFilesSafe implements IDelimitedFilesSafe
{
// variables
private static final ILogger logger = LogManager.getLogger(DelimitedFilesSafe.class);

private static final byte GX_ASCDEL_SUCCESS = 0;
private static final byte GX_ASCDEL_INVALIDSEQUENCE = -1;
Expand All @@ -36,7 +39,6 @@ public class DelimitedFilesSafe implements IDelimitedFilesSafe
private String sdel;
protected boolean dfropen_in_use = false;
protected boolean dfwopen_in_use = false;
protected boolean trace_on = DebugFlag.DEBUG;
protected BufferedReader bufread;
protected BufferedWriter bufwrite;
private StringTokenizer actline;
Expand All @@ -59,8 +61,7 @@ public String getEncoding()

public byte dftrace(int trace)
{
byte lastTrace = (byte)(trace_on ? 1 : 0);
this.trace_on = (trace != 0);
byte lastTrace = 1;
return lastTrace;
}

Expand Down Expand Up @@ -143,16 +144,14 @@ public Object run() throws Exception
{
retval = GX_ASCDEL_OPENERROR;
dfropen_in_use = false;
if (trace_on)
System.err.println("Error ADF0001: " + e);
logger.error("Error ADF0001: " + e);
}

}
else
{
retval = GX_ASCDEL_INVALIDSEQUENCE;
if (trace_on)
System.err.println("Error ADF0005: open function in use");
logger.error("Error ADF0005: open function in use");
}

return retval;
Expand Down Expand Up @@ -181,8 +180,7 @@ public byte dfrnext()
catch (IOException e)
{
retval = GX_ASCDEL_READERROR;
if (trace_on)
System.err.println("Error ADF0002: " + e);
logger.error("Error ADF0002: " + e);
}

}else{
Expand Down Expand Up @@ -214,15 +212,13 @@ public byte dfrgnum(double[] num)
catch (Exception e)
{
retval = GX_ASCDEL_INVALIDFORMAT;
if (trace_on)
System.err.println("Error ADF0008: " + e);
logger.error("Error ADF0008: " + e);
}
}
else
{
retval = GX_ASCDEL_INVALIDSEQUENCE;
if (trace_on)
System.err.println("Error ADF0004 o ADF0006");
logger.error("Error ADF0004 o ADF0006");
}

num[0] = retnum.doubleValue();
Expand Down Expand Up @@ -258,15 +254,13 @@ public byte dfrgnum(BigDecimal[] num)
catch (Exception e)
{
retval = GX_ASCDEL_INVALIDFORMAT;
if (trace_on)
System.err.println("Error ADF0008: " + e);
logger.error("Error ADF0008: " + e);
}
}
else
{
retval = GX_ASCDEL_INVALIDSEQUENCE;
if (trace_on)
System.err.println("Error ADF0004 o ADF0006");
logger.error("Error ADF0004 o ADF0006");
}

num[0] = retnum;
Expand Down Expand Up @@ -360,15 +354,13 @@ public byte dfrgtxt(String[] str, int len)
catch (Exception e)
{
retval = GX_ASCDEL_INVALIDFORMAT;
if (trace_on)
System.err.println("Error ADF0009: " + e);
logger.error("Error ADF0009: " + e);
}
}
else
{
retval = GX_ASCDEL_INVALIDSEQUENCE;
if (trace_on)
System.err.println("Error ADF0004 o ADF0006");
logger.error("Error ADF0004 o ADF0006");
}

if (isCsv && ((sdel.equals("") || sdel.equals("\"")) && (retstr.contains("\"\"") || (!fdel.equals("") && retstr.contains(fdel)))))
Expand Down Expand Up @@ -534,8 +526,7 @@ public byte dfrgdate(java.util.Date[] date, String fmt, String sep)
else if (month < 1 || month > 12 || day < 1 || day > 31)
{
retval = GX_ASCDEL_INVALIDDATE;
if (trace_on)
System.err.println("Error ADF0010");
logger.error("Error ADF0010");
}
else
{
Expand All @@ -553,8 +544,7 @@ else if (month < 1 || month > 12 || day < 1 || day > 31)
else
{
retval = GX_ASCDEL_INVALIDSEQUENCE;
if (trace_on)
System.err.println("Error ADF0004 o ADF0006");
logger.error("Error ADF0004 o ADF0006");
}

date[0] = retdate;
Expand Down Expand Up @@ -666,16 +656,14 @@ public Object run() throws Exception
{
retval = GX_ASCDEL_OPENERROR;
dfwopen_in_use = false;
if (trace_on)
System.err.println("Error ADF0001: " + e);
logger.error("Error ADF0001: " + e);
}

}
else
{
retval = GX_ASCDEL_INVALIDSEQUENCE;
if (trace_on)
System.err.println("Error ADF0005: open function in use");
logger.error("Error ADF0005: open function in use");
}

return retval;
Expand Down Expand Up @@ -737,8 +725,7 @@ public byte dfwnext()
catch (IOException e)
{
retval = GX_ASCDEL_WRITEERROR;
if (trace_on)
System.err.println("Error ADF0003: " + e);
logger.error("Error ADF0003: " + e);
}
}
else
Expand Down Expand Up @@ -795,8 +782,7 @@ public byte dfwpnum(double num, int dec)
else
{
retval = GX_ASCDEL_INVALIDSEQUENCE;
if (trace_on)
System.err.println("ADF0004");
logger.error("ADF0004");
}
return retval;
}
Expand Down Expand Up @@ -829,8 +815,7 @@ public byte dfwptxt(String txt, int len)
else
{
retval = GX_ASCDEL_INVALIDSEQUENCE;
if (trace_on)
System.err.println("ADF0004");
logger.error("ADF0004");
}
return retval;
}
Expand Down Expand Up @@ -888,8 +873,7 @@ public byte dfwpdate(Date date, String fmt, String sep)
toWrite += day + (i == 2?"":sep);
break;
default:
if (trace_on)
System.err.println("ADF0012");
logger.error("ADF0012");

return GX_ASCDEL_BADFMTSTR;
}
Expand All @@ -898,8 +882,7 @@ public byte dfwpdate(Date date, String fmt, String sep)
else
{
retval = GX_ASCDEL_INVALIDSEQUENCE;
if (trace_on)
System.err.println("ADF0004");
logger.error("ADF0004");
}
return retval;
}
Expand Down
Loading