First Commit - Source Code from Reply

This commit is contained in:
vincenzofariello
2024-05-13 12:54:14 +02:00
parent 73e32a5020
commit a15aee1f08
11184 changed files with 1065913 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
#Fri Feb 13 10:34:24 CET 2009
activeProfiles=
eclipse.preferences.version=1
fullBuildGoals=process-test-resources
includeModules=false
resolveWorkspaceProjects=true
resourceFilterGoals=process-resources resources\:testResources
version=1

View File

@@ -0,0 +1,25 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>logging</groupId>
<artifactId>logging</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<name>Maven logging</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>biz</groupId>
<artifactId>datedFileAppender</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.6</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,41 @@
package it.valueteam.logging;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
public class Azione implements Serializable {
private static final long serialVersionUID = 1L;
private static MappaCodici azioni;
private static MappaCodici esiti;
private StringBuffer buffer;
public static void setMappe(Hashtable hashtable, Hashtable hashtable1){
azioni = new MappaCodici(hashtable);
esiti = new MappaCodici(hashtable1);
}
public Azione(int i, Map map, int j, String s, String s1){
azioni.getDescription(i);
esiti.getDescription(j);
buffer = new StringBuffer();
buffer.append("OPERAZIONE RICHIESTA: ").append(Tracer.aCapo).append(" ").append("CODICE_AZIONE: ").append(i).append(Tracer.aCapo).append(" ").append("PARAMETRI: ").append(map != null ? ((Object) (map)) : ((Object) (new HashMap()))).append(Tracer.aCapo).append(" ").append("OGGETTO: ").append(s == null ? "*" : s).append(Tracer.aCapo).append(" ").append("RETCODE: ").append(j).append(Tracer.aCapo).append(" ").append("ESITO: ").append(s1 == null ? "*" : s1).append(Tracer.aCapo);
}
public Azione(String s, Map map, String s1, String s2, String s3){
buffer = new StringBuffer();
buffer.append("AZIONE: ").append(Tracer.aCapo).append(" ").append("CODICE_AZIONE: ").append(azioni.getCode(s)).append(Tracer.aCapo).append(" ").append("PARAMETRI: ").append(map != null ? ((Object) (map)) : ((Object) (new HashMap()))).append(Tracer.aCapo).append(" ").append("OGGETTO: ").append(s2 == null ? "*" : s2).append(Tracer.aCapo).append(" ").append("RETCODE: ").append(esiti.getCode(s1)).append(Tracer.aCapo).append(" ").append("ESITO: ").append(s3 == null ? "*" : s3).append(Tracer.aCapo);
}
public StringBuffer getBuffer(){
return buffer;
}
public String toString(){
return buffer.toString();
}
}

View File

@@ -0,0 +1,41 @@
package it.valueteam.logging;
import java.io.Serializable;
import java.util.Enumeration;
import java.util.Hashtable;
public class MappaCodici implements Serializable {
private static final long serialVersionUID = 1L;
private Hashtable mappa;
private Hashtable mappaDesc;
public MappaCodici(Hashtable hashtable){
mappa = hashtable;
mappaDesc = new Hashtable(hashtable.size());
Enumeration enumeration = mappa.keys();
Integer integer;
for(; enumeration.hasMoreElements(); mappaDesc.put(mappa.get(integer), integer))
integer = (Integer)enumeration.nextElement();
}
public String getDescription(int i){
Integer integer = new Integer(i);
if(mappa.containsKey(integer)){
return (String)mappa.get(integer);
} else {
System.out.println("Codice mappatura azioni inesistente: " + i);
return null;
}
}
public int getCode(String s){
if(mappaDesc.containsKey(s)){
return ((Integer)mappaDesc.get(s)).intValue();
} else {
System.out.println("Descrizione mappatura esiti inesistente: " + s);
return -1;
}
}
}

View File

@@ -0,0 +1,33 @@
package it.valueteam.logging;
import java.io.Serializable;
public class SessionInfo implements Serializable {
private static final long serialVersionUID = 1L;
private StringBuffer buffer;
public SessionInfo(String s, String s1, String s2, String s3, String s4){
buffer = new StringBuffer();
buffer.append("IP GENERATORE: ").append(s == null ? "*" : s).append(" , ").append("HOSTNAME GENERATORE: ").append(s1 == null ? "*" : s1).append(" , ").append("UTENZA APPLICATIVA: ").append(s2 == null ? "*" : s2).append(" , ").append("APPLICATIVO CLIENT: ").append(s3 == null ? "*" : s3).append(" , ").append("PROFILO UTENTE: ").append(s4 == null ? "*" : s4).append(Tracer.aCapo);
}
public SessionInfo(String s, String s1, String s2, String s3, String s4, String s5, String s6, String s7, String s8){
this(s, s1, s2, s3, s4);
buffer.append("IP CLIENT: ").append(s5 == null ? "*" : s5).append(" , ");
buffer.append("HOSTNAME CLIENT: ").append(s6 == null ? "*" : s6).append(" , ");
buffer.append("IP SORGENTE: ").append(s8 == null ? "*" : s8).append(" , ");
buffer.append("UTENZA CLIENT: ").append(s7 == null ? "*" : s7).append(Tracer.aCapo);
}
public StringBuffer getBuffer(){
return buffer;
}
public String toString(){
return buffer.toString();
}
}

View File

@@ -0,0 +1,74 @@
package it.valueteam.logging;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Properties;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.PropertyConfigurator;
import biz.minaret.log4j.DatedFileAppender;
public class Tracer {
private static Logger log;
public static String aCapo = System.getProperty("line.separator");
public static void configure(Properties properties, Properties properties1, Hashtable hashtable, Hashtable hashtable1){
if(properties1 != null)
PropertyConfigurator.configure(properties1);
DatedFileAppender datedfileappender = new DatedFileAppender(properties.getProperty("tracciamento.dir"), properties.getProperty("tracciamento.fileName"), ".log");
datedfileappender.setLayout(new PatternLayout(properties.getProperty("tracciamento.pattern")));
log = Logger.getLogger(properties.getProperty("tracciamento.fileName"));
log.addAppender(datedfileappender);
log.setLevel(Level.ALL);
log.setAdditivity(false);
Azione.setMappe(hashtable, hashtable1);
log.info("STARTED!");
}
public static void log(String s){
log.info(s);
}
public static void log(SessionInfo sessioninfo, Azione azione){
StringBuffer stringbuffer = new StringBuffer();
stringbuffer.append(" ").append(aCapo).append(sessioninfo).append(azione).append("END INFO").append(aCapo);
log.info(stringbuffer.toString());
}
private Tracer(){}
public static void main(String args[]){
Properties properties = new Properties();
Properties properties1 = new Properties();
FileInputStream fileinputstream = null;
try{
fileinputstream = new FileInputStream("C:/base.properties");
properties.load(fileinputstream);
fileinputstream.close();
fileinputstream = new FileInputStream("C:/config.properties");
properties1.load(fileinputstream);
configure(properties1, properties, null, null);
Azione azione = new Azione(10, new HashMap(), 11, "TEST", "OK");
SessionInfo sessioninfo = new SessionInfo("pippo", "pippo", "pippo", "pippo", "pippo");
log(sessioninfo, azione);
log(sessioninfo, azione);
}catch(Exception exception){
exception.printStackTrace();
}
finally{
if(fileinputstream != null)
try {
fileinputstream.close();
} catch(IOException ioexception) { }
}
}
}