Lots of code cleanup, proper documentation and removal of unneccessary methods.

This commit is contained in:
2012-04-23 15:25:57 +00:00
parent 17061b1475
commit 20c0c21c02
10 changed files with 219 additions and 289 deletions

View File

@@ -1,13 +1,9 @@
package eva2.client; package eva2.client;
import javax.swing.*;
import eva2.gui.ExtAction; import eva2.gui.ExtAction;
import java.awt.event.WindowListener;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
/** /**
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.
@@ -20,7 +16,7 @@ import java.awt.event.WindowEvent;
* *
*/ */
class AppExitAction extends ExtAction implements WindowListener{ class AppExitAction extends ExtAction implements WindowListener{
public AppExitAction(String s, String toolTip, KeyStroke key){ public AppExitAction(String s, String toolTip, javax.swing.KeyStroke key) {
super(s, toolTip, key); super(s, toolTip, key);
} }
private void exit(){ private void exit(){

View File

@@ -11,22 +11,27 @@ import eva2.gui.GenericObjectEditor;
* *
*/ */
public class ClassPreloader implements Runnable { public class ClassPreloader implements Runnable {
String[] clsNames = null; /**
private static boolean TRACE=false; * List of classes to load when ClassPreloader is started.
*/
private String[] classNames = null;
public ClassPreloader(String ... strs) { /* Creates a new ClassPreloader and sets the
setClassNames(strs); * list of classes to load.
} *
* @param classes List of classes to load
private void setClassNames(String[] strs) { */
clsNames = strs; public ClassPreloader(final String ... classes) {
this.classNames = classes;
} }
/**
* Load classes via GenericObjectEditor in a thread.
*/
public void run() { public void run() {
if (clsNames !=null) { if (classNames != null) {
for (int i = 0; i < clsNames.length; i++) { for (int i = 0; i < classNames.length; i++) {
if (TRACE) System.out.println("Preloading " + clsNames[i]); GenericObjectEditor.getClassesFromClassPath(classNames[i], null);
GenericObjectEditor.getClassesFromClassPath(clsNames[i], null);
} }
} }
} }

View File

@@ -10,27 +10,15 @@ package eva2.client;
* $Date: 2007-12-06 16:05:11 +0100 (Thu, 06 Dec 2007) $ * $Date: 2007-12-06 16:05:11 +0100 (Thu, 06 Dec 2007) $
* $Author: mkron $ * $Author: mkron $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.rmi.RemoteException;
import eva2.EvAInfo; import eva2.EvAInfo;
import eva2.gui.LoggingPanel; import eva2.gui.LoggingPanel;
import eva2.server.EvAMainAdapter; import eva2.server.EvAMainAdapter;
import eva2.server.EvAMainAdapterImpl; import eva2.server.EvAMainAdapterImpl;
import eva2.server.go.InterfaceGOParameters; import eva2.server.go.InterfaceGOParameters;
import eva2.server.modules.ModuleAdapter; import eva2.server.modules.ModuleAdapter;
import eva2.tools.jproxy.ComAdapter; import eva2.tools.jproxy.*;
import eva2.tools.jproxy.MainAdapter; import java.rmi.RemoteException;
import eva2.tools.jproxy.MainAdapterClient;
import eva2.tools.jproxy.RMIConnection;
import eva2.tools.jproxy.RMIInvocationHandler;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/** /**
* *
*/ */
@@ -134,5 +122,3 @@ public class EvAComAdapter extends ComAdapter {
this.runLocally = runLocally; this.runLocally = runLocally;
} }
} }
//

View File

@@ -54,14 +54,18 @@ public class JEFrame extends JFrame {
public void windowClosed(WindowEvent e) { public void windowClosed(WindowEvent e) {
super.windowClosed(e); super.windowClosed(e);
JEFrameRegister.unregister((JEFrame) e.getWindow()); JEFrameRegister.unregister((JEFrame) e.getWindow());
if (closeAllOnClose) JEFrameRegister.closeAll(); if (closeAllOnClose) {
JEFrameRegister.closeAll();
}
// ((JFrame) e.getWindow()).dispose(); // ((JFrame) e.getWindow()).dispose();
} }
@Override @Override
public void windowOpened(WindowEvent e) { public void windowOpened(WindowEvent e) {
super.windowOpened(e); super.windowOpened(e);
JEFrameRegister.register((JEFrame) e.getWindow()); JEFrameRegister.register((JEFrame) e.getWindow());
} }
@Override @Override
public void windowActivated(WindowEvent e) { public void windowActivated(WindowEvent e) {
JEFrameRegister.register((JEFrame) e.getWindow()); JEFrameRegister.register((JEFrame) e.getWindow());

View File

@@ -21,32 +21,37 @@ public class EvAServer {
* MainAdapterImp object. This is need for the first connection between the * MainAdapterImp object. This is need for the first connection between the
* server and the client program. * server and the client program.
*/ */
public EvAMainAdapter m_MainRemoteObject; private EvAMainAdapter mainRemoteObject;
//private EvAComAdapter m_ComAdapter; //private EvAComAdapter m_ComAdapter;
public static String m_UserName; private static String userName;
public static int m_NumberOfVM = 0; private RMIServerEvA rmiServer;
private RMIServerEvA m_RMIServer; private static final Logger LOGGER = Logger.getLogger(EvAInfo.defaultLogger);
private static final Logger logger = Logger.getLogger(EvAInfo.defaultLogger);
/** /**
* Constructor of EvAServer. Calls RMIConnection(). * Constructor of EvAServer. Calls RMIConnection().
*/ */
public EvAServer(boolean insideClient, boolean Restart) { public EvAServer(boolean insideClient, boolean restart) {
logger.log(Level.INFO, "Number of CPUs :" + Runtime.getRuntime().availableProcessors()); LOGGER.log(Level.INFO, "Number of CPUs :{0}", Runtime.getRuntime().availableProcessors());
logger.log(Level.INFO, "This is EvA Server Version: " + EvAInfo.getVersion()); LOGGER.log(Level.INFO, "This is EvA Server Version: {0}", EvAInfo.getVersion());
logger.log(Level.INFO, "Java Version: " + System.getProperty("java.version")); LOGGER.log(Level.INFO, "Java Version: {0}", System.getProperty("java.version"));
m_UserName = System.getProperty("user.name"); try {
// RMIConnection(); userName = System.getProperty("user.name");
// m_ComAdapter = new EvAComAdapter(); } catch (SecurityException ex) {
// RMIProxyRemote.setComAdaper(m_ComAdapter); /*
m_RMIServer = RMIServerEvA.getInstance(); * This exception is expected to happen in Java WebStart
*/
LOGGER.log(Level.WARNING, "Could not fetch username property. Setting username to 'WebStart'", ex);
userName = "WebStart";
}
rmiServer = RMIServerEvA.getInstance();
} }
/** /**
* Main method of this class. Is the starting point of the server * Main method of this class. Is the starting point of the server
* application. * application.
*/ */
static public void main(String[] args) { public static void main(String[] args) {
boolean restart = false; boolean restart = false;
boolean noMulti = false; boolean noMulti = false;
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
@@ -121,7 +126,7 @@ public class EvAServer {
* *
*/ */
public RMIServerEvA getRMIServer() { public RMIServerEvA getRMIServer() {
return m_RMIServer; return rmiServer;
} }
/** /**

View File

@@ -33,6 +33,8 @@ import eva2.tools.Pair;
import eva2.tools.jproxy.MainAdapterClient; import eva2.tools.jproxy.MainAdapterClient;
import eva2.tools.jproxy.RMIProxyLocal; import eva2.tools.jproxy.RMIProxyLocal;
import eva2.tools.jproxy.RMIProxyRemote; import eva2.tools.jproxy.RMIProxyRemote;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* A statistics class to plot fitness curves in client-server mode. Mainly, arrays of GraphWindows * A statistics class to plot fitness curves in client-server mode. Mainly, arrays of GraphWindows
@@ -42,58 +44,58 @@ import eva2.tools.jproxy.RMIProxyRemote;
*/ */
public class StatisticsWithGUI extends AbstractStatistics implements Serializable, InterfaceStatistics { public class StatisticsWithGUI extends AbstractStatistics implements Serializable, InterfaceStatistics {
private static final long serialVersionUID = 3213603978877954103L; private static final long serialVersionUID = 3213603978877954103L;
private static final Logger LOGGER = Logger.getLogger(eva2.EvAInfo.defaultLogger);
// Plot frames: // Plot frames:
private GraphWindow[] m_FitnessFrame; // frame for the fitness plots private GraphWindow[] fitnessFrame; // frame for the fitness plots
private Graph[][] m_FitnessGraph; private Graph[][] fitnessGraph;
private Graph[][] m_StatGraph; private Graph[][] statGraph;
private String m_GraphInfoString; private String graphInfoString;
protected int m_PlotCounter; protected int plotCounter;
private MainAdapterClient m_MainAdapterClient; // the connection to the client MainAdapter private MainAdapterClient mainAdapterClient; // the connection to the client MainAdapter
private JTextoutputFrameInterface m_ProxyPrinter; private JTextoutputFrameInterface proxyPrinter;
private transient List<Pair<String, Integer>> graphDesc=null; // list of descriptor strings and optional indices. strictly its redundant since super.lastGraphSelection is always available. However it spares some time.
////////////// /* List of descriptor strings and optional indices. strictly its
protected static String m_MyHostName = null; * redundant since super.lastGraphSelection is always available.
* However it spares some time.
*/
private transient List<Pair<String, Integer>> graphDesc = null;
protected static String hostName = null;
/** /**
* *
*/ */
public MainAdapterClient getMainAdapterClient() { public MainAdapterClient getMainAdapterClient() {
return m_MainAdapterClient; return mainAdapterClient;
} }
/** /**
* *
*/ */
public StatisticsWithGUI(MainAdapterClient Client) { public StatisticsWithGUI(MainAdapterClient client) {
if (TRACE) mainAdapterClient = client;
System.out.println("Constructor RMIStatistics"); if (client != null) { // We are probably in rmi mode
m_MainAdapterClient = Client;
if (Client != null) { // were probably in rmi mode
try { try {
m_MyHostName = InetAddress.getLocalHost().getHostName(); hostName = InetAddress.getLocalHost().getHostName();
} catch (Exception e) { } catch (Exception ex) {
System.err.println( LOGGER.log(Level.WARNING, "Could not retrieve hostname.", ex);
"InetAddress.getLocalHost().getHostAddress() --> ERROR" +
e.getMessage());
} }
} else m_MyHostName = "localhost"; } else hostName = "localhost";
if ((Client == null) || Client.getHostName().equals(m_MyHostName)) { if ((client == null) || client.getHostName().equals(hostName)) {
m_StatsParams = StatsParameter.getInstance(true); m_StatsParams = StatsParameter.getInstance(true);
m_ProxyPrinter = new JTextoutputFrame("TextOutput of " + m_MyHostName); proxyPrinter = new JTextoutputFrame("TextOutput of " + hostName);
} else { // we use RMI } else { // we use RMI
m_StatsParams = (InterfaceStatisticsParameter)RMIProxyLocal.newInstance( m_StatsParams = (InterfaceStatisticsParameter)RMIProxyLocal.newInstance(
StatsParameter.getInstance(true)); StatsParameter.getInstance(true));
m_ProxyPrinter = (JTextoutputFrameInterface) RMIProxyRemote.newInstance(new proxyPrinter = (JTextoutputFrameInterface) RMIProxyRemote.newInstance(new
JTextoutputFrame("TextOutput " + m_MyHostName), JTextoutputFrame("TextOutput " + hostName),
m_MainAdapterClient); mainAdapterClient);
} }
addTextListener(m_ProxyPrinter); addTextListener(proxyPrinter);
if (TRACE) System.out.println("Constructor RMIStatistics --> end");
} }
/** /**
@@ -101,12 +103,12 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
*/ */
public synchronized void startOptPerformed(String infoString, int runNumber, Object goParams, List<InterfaceAdditionalPopulationInformer> informerList) { public synchronized void startOptPerformed(String infoString, int runNumber, Object goParams, List<InterfaceAdditionalPopulationInformer> informerList) {
super.startOptPerformed(infoString, runNumber, goParams, informerList); super.startOptPerformed(infoString, runNumber, goParams, informerList);
m_GraphInfoString = infoString; graphInfoString = infoString;
// m_TextCounter = m_StatisticsParameter.GetTextoutput(); // m_TextCounter = m_StatisticsParameter.GetTextoutput();
// m_PlotCounter = m_StatsParams.GetPlotoutput(); // m_PlotCounter = m_StatsParams.GetPlotoutput();
if ((m_FitnessFrame!=null) && (m_FitnessFrame[0]!=null)) { if ((fitnessFrame!=null) && (fitnessFrame[0]!=null)) {
PlotInterface p = m_FitnessFrame[0].getPlotter(); PlotInterface p = fitnessFrame[0].getPlotter();
if ((p!=null) && p.isValid()) ((Plot)p).getFunctionArea().clearLegend(); if ((p!=null) && p.isValid()) ((Plot)p).getFunctionArea().clearLegend();
} }
} }
@@ -123,24 +125,22 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
if (!normal) fullRuns--; if (!normal) fullRuns--;
// unite the graphs only if the break was "normal" // unite the graphs only if the break was "normal"
if ((m_StatsParams.getMultiRuns() > 1) && (m_StatGraph != null)) { if ((m_StatsParams.getMultiRuns() > 1) && (statGraph != null)) {
// unite the point sets for a multirun // unite the point sets for a multirun
for (int i = 0; i < m_FitnessGraph.length; i++) { for (int i = 0; i < fitnessGraph.length; i++) {
for (int j = 0; j < m_FitnessGraph[i].length; j++) { for (int j = 0; j < fitnessGraph[i].length; j++) {
m_StatGraph[i][j].setInfoString( statGraph[i][j].setInfoString(
(m_FitnessGraph[i][j].getInfo().length() > 0 ? (m_FitnessGraph[i][j].getInfo() + "_") : "" ) (fitnessGraph[i][j].getInfo().length() > 0 ? (fitnessGraph[i][j].getInfo() + "_") : "" )
// + (m_StatsParams.GetInfoString().length() > 0 ? (m_StatsParams.GetInfoString() + "_") : "" )
// + m_StatsParams.GetInfoString()
+ "Mean_of_" + fullRuns + " ", + "Mean_of_" + fullRuns + " ",
(float) 2.0); (float) 2.0);
if (normal && m_FitnessFrame[i].isValid() && (m_FitnessGraph[i][j].getPointCount()>0)) { if (normal && fitnessFrame[i].isValid() && (fitnessGraph[i][j].getPointCount()>0)) {
m_StatGraph[i][j].addGraph(m_FitnessGraph[i][j]); statGraph[i][j].addGraph(fitnessGraph[i][j]);
m_FitnessGraph[i][j].clear(); fitnessGraph[i][j].clear();
} }
} }
} }
} }
PlotInterface p = m_FitnessFrame[0].getPlotter(); PlotInterface p = fitnessFrame[0].getPlotter();
if ((optRunsPerformed >= m_StatsParams.getMultiRuns()) || !normal) { if ((optRunsPerformed >= m_StatsParams.getMultiRuns()) || !normal) {
// update the legend after the last multirun or after a user break // update the legend after the last multirun or after a user break
if ((p!=null) && p.isValid()) { if ((p!=null) && p.isValid()) {
@@ -150,7 +150,7 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
} }
public void maybeShowProxyPrinter() { public void maybeShowProxyPrinter() {
if (m_ProxyPrinter != null) m_ProxyPrinter.setShow(m_StatsParams.isShowTextOutput()); if (proxyPrinter != null) proxyPrinter.setShow(m_StatsParams.isShowTextOutput());
} }
protected void initPlots(PopulationInterface pop, List<InterfaceAdditionalPopulationInformer> informerList) { protected void initPlots(PopulationInterface pop, List<InterfaceAdditionalPopulationInformer> informerList) {
@@ -168,63 +168,59 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
int windowCount = 1; // TODO this was earlier description.length for the 2-D String-Array returned by m_StatsParams.getPlotDescriptions, which however always returned an array of length 1 (in the first dim). int windowCount = 1; // TODO this was earlier description.length for the 2-D String-Array returned by m_StatsParams.getPlotDescriptions, which however always returned an array of length 1 (in the first dim).
int graphCount = graphDesc.size(); int graphCount = graphDesc.size();
// System.out.println("Initializing " + graphCount + " plots (StatisticsWithGUI)"); // System.out.println("Initializing " + graphCount + " plots (StatisticsWithGUI)");
m_FitnessFrame = new GraphWindow[windowCount]; fitnessFrame = new GraphWindow[windowCount];
for (int i = 0; i < m_FitnessFrame.length; i++) { for (int i = 0; i < fitnessFrame.length; i++) {
// m_FitnessFrame[i] = GraphWindow.getInstance(m_MainAdapterClient, m_GraphInfoString + " " + i + " " + " on " + m_MyHostName + ", VM " + EvAServer.m_NumberOfVM, "function calls", "fitness"); fitnessFrame[i] = GraphWindow.getInstance(mainAdapterClient, "Optimization " + i + " " + " on " + hostName, "function calls", "fitness");
m_FitnessFrame[i] = GraphWindow.getInstance(m_MainAdapterClient, "Optimization " + i + " " + " on " + m_MyHostName + ", VM " + EvAServer.m_NumberOfVM, "function calls", "fitness");
} }
m_FitnessGraph = new Graph[windowCount][]; fitnessGraph = new Graph[windowCount][];
// contains one graph for every value to be plotted (best / worst / best+worst) // contains one graph for every value to be plotted (best / worst / best+worst)
// TODO Im really not sure why this is a 2-dimensional array. shouldnt one be enough? // TODO Im really not sure why this is a 2-dimensional array. shouldnt one be enough?
for (int i = 0; i < m_FitnessGraph.length; i++) { for (int i = 0; i < fitnessGraph.length; i++) {
m_FitnessGraph[i] = new Graph[graphCount]; fitnessGraph[i] = new Graph[graphCount];
for (int j = 0; j < m_FitnessGraph[i].length; j++) { for (int j = 0; j < fitnessGraph[i].length; j++) {
// String[] d = (String[]) description.get(i); // String[] d = (String[]) description.get(i);
// this is where the column string for ascii export is created! Uah! // this is where the column string for ascii export is created! Uah!
m_FitnessGraph[i][j] = fitnessGraph[i][j] =
m_FitnessFrame[i].getNewGraph(graphDesc.get(j).head + "_" + fitnessFrame[i].getNewGraph(graphDesc.get(j).head + "_"
// m_StatsParams.GetInfoString() + + graphInfoString);
m_GraphInfoString); fitnessGraph[i][j].jump();
// m_FitnessGraph[i][j] =
// m_FitnessFrame[i].getNewGraph(d[j] + "_" +
// m_StatsParams.GetInfoString() +
// m_GraphInfoString);
m_FitnessGraph[i][j].jump();
} }
} }
if (m_StatsParams.getMultiRuns() > 1 && if (m_StatsParams.getMultiRuns() > 1 &&
m_StatsParams.GetUseStatPlot() == true) { m_StatsParams.GetUseStatPlot() == true) {
// String Info = m_StatsParams.GetInfoString(); // String Info = m_StatsParams.GetInfoString();
m_StatGraph = new Graph[windowCount][]; statGraph = new Graph[windowCount][];
for (int i = 0; i < m_StatGraph.length; i++) { for (int i = 0; i < statGraph.length; i++) {
m_StatGraph[i] = new Graph[graphCount]; statGraph[i] = new Graph[graphCount];
for (int j = 0; j < m_StatGraph[i].length; j++) { for (int j = 0; j < statGraph[i].length; j++) {
// String[] d = (String[]) description.get(i); // String[] d = (String[]) description.get(i);
m_StatGraph[i][j] = m_FitnessFrame[i].getNewGraph(graphDesc.get(j).head + "_" + //Info + statGraph[i][j] = fitnessFrame[i].getNewGraph(graphDesc.get(j).head + "_" + //Info +
m_GraphInfoString); graphInfoString);
} }
} }
} }
} }
private void plotFitnessPoint(int graph, int subGraph, int x, double y) { private void plotFitnessPoint(int graph, int subGraph, int x, double y) {
if (m_FitnessGraph == null) { if (fitnessGraph == null) {
EVAERROR.WARNING("fitness graph is null! (StatisticsWithGUI)"); EVAERROR.WARNING("fitness graph is null! (StatisticsWithGUI)");
return; return;
} }
if (graph >= m_FitnessGraph.length || subGraph >= m_FitnessGraph[graph].length) { if (graph >= fitnessGraph.length || subGraph >= fitnessGraph[graph].length) {
EVAERROR.WARNING("tried to plot to invalid graph! (StatisticsWithGUI)"); EVAERROR.WARNING("tried to plot to invalid graph! (StatisticsWithGUI)");
return; return;
} }
boolean isValidGraph = m_FitnessFrame[graph].isValid(); boolean isValidGraph = fitnessFrame[graph].isValid();
if (!isValidGraph) { if (!isValidGraph) {
// this happens if the user closed the plot window. // this happens if the user closed the plot window.
// if the plots are reinitialized immediately, the user might get angry, so wait (till next opt start) // if the plots are reinitialized immediately, the user might get angry, so wait (till next opt start)
// EVAERROR.WARNING("fitness graph is invalid, trying to reinitialize..."); // EVAERROR.WARNING("fitness graph is invalid, trying to reinitialize...");
// initPlots(getDescription()); // initPlots(getDescription());
} }
if (isValidGraph) m_FitnessGraph[graph][subGraph].setConnectedPoint(x, y); if (isValidGraph) {
fitnessGraph[graph][subGraph].setConnectedPoint(x, y);
}
} }
/** /**
@@ -290,8 +286,8 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
// if (m_PlotCounter == 0) { // if (m_PlotCounter == 0) {
// m_PlotCounter = m_StatsParams.GetPlotoutput(); // m_PlotCounter = m_StatsParams.GetPlotoutput();
int index = 0; int index = 0;
for (int i = 0; i < m_FitnessGraph.length; i++) { for (int i = 0; i < fitnessGraph.length; i++) {
for (int j = 0; j < m_FitnessGraph[i].length; j++) { for (int j = 0; j < fitnessGraph[i].length; j++) {
plotFitnessPoint(i, j, calls, specificData[index]); plotFitnessPoint(i, j, calls, specificData[index]);
index++; index++;
} }
@@ -300,6 +296,6 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
} }
public String getHostName() { public String getHostName() {
return m_MyHostName; return hostName;
} }
} }

View File

@@ -44,6 +44,8 @@ import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
import eva2.EvAInfo; import eva2.EvAInfo;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
@@ -64,8 +66,7 @@ public class BasicResourceLoader implements ResourceLoader
/** /**
* Obtain a suitable logger. * Obtain a suitable logger.
*/ */
private static DummyCategory logger = DummyCategory.getInstance( private static Logger logger = Logger.getLogger(eva2.EvAInfo.defaultLogger);
BasicResourceLoader.class.getName());
private static BasicResourceLoader resourceLoader; private static BasicResourceLoader resourceLoader;
//~ Constructors /////////////////////////////////////////////////////////// //~ Constructors ///////////////////////////////////////////////////////////
@@ -158,21 +159,19 @@ public class BasicResourceLoader implements ResourceLoader
{ {
line = line.trim(); line = line.trim();
if (strStartsWithPrefix(line, ignorePrefix) < 0) { if (strStartsWithPrefix(line, ignorePrefix) < 0) {
if (lineCnt >= lOffset) lineData.add(line); if (lineCnt >= lOffset) {
lineCnt++; lineData.add(line);
if ((lCnt > 0) && (lineData.size() == lCnt)) break; }
lineCnt++;
if ((lCnt > 0) && (lineData.size() == lCnt)) {
break;
}
} }
// if (line.trim().length() > 0) {
// if ((ignorePrefix == null) || (strStartsWithPrefix(line, ignorePrefix) < 0)) {
// // if there are no prefixes given or none of them fits, add the line
// lineData.add(line);
// }
// }
} }
} }
catch (IOException ex) catch (IOException ex)
{ {
logger.error(ex.getMessage()); logger.log(Level.SEVERE, ex.getMessage(), ex);
} }
return lineData; return lineData;
@@ -363,10 +362,11 @@ public class BasicResourceLoader implements ResourceLoader
// in = getStreamFromClassPath(resourceLocation); // in = getStreamFromClassPath(resourceLocation);
} }
if (logger.isDebugEnabled()) if (in == null) {
{ logger.log(Level.FINER, "Unable to open stream for " + resourceLocation);
if (in == null) logger.debug("Unable to open stream for " + resourceLocation); }
else logger.debug("Stream opened for " + resourceLocation); else {
logger.log(Level.FINER, "Stream opened for " + resourceLocation);
} }
return in; return in;
} }
@@ -499,10 +499,9 @@ public class BasicResourceLoader implements ResourceLoader
} }
} }
} }
catch (Exception e) catch (Exception ex)
{ {
logger.error(e.getMessage()); logger.log(Level.SEVERE, ex.getMessage(), ex);
return null; return null;
} }
@@ -524,10 +523,7 @@ public class BasicResourceLoader implements ResourceLoader
fileName.substring(length + 1); fileName.substring(length + 1);
} }
if (logger.isDebugEnabled()) logger.log(Level.FINER, "Trying to get file from " + fileName);
{
logger.debug("Trying to get file from " + fileName);
}
File file = new File(fileName); File file = new File(fileName);
FileInputStream fis = null; FileInputStream fis = null;
@@ -537,10 +533,9 @@ public class BasicResourceLoader implements ResourceLoader
fis = new FileInputStream(file); fis = new FileInputStream(file);
return fis; return fis;
} }
catch (Exception e) catch (Exception ex)
{ {
if (logger.isDebugEnabled()) logger.error(e.getMessage()); logger.log(Level.SEVERE, ex.getMessage(), ex);
return null; return null;
} }
@@ -581,9 +576,9 @@ public class BasicResourceLoader implements ResourceLoader
rb += chunk; rb += chunk;
} }
} }
catch (Exception e) catch (Exception ex)
{ {
logger.error(e.getMessage()); logger.log(Level.SEVERE, ex.getMessage(), ex);
return null; return null;
} }
@@ -604,11 +599,6 @@ public class BasicResourceLoader implements ResourceLoader
return null; return null;
} }
if (logger.isDebugEnabled())
{
logger.debug("Trying to get file from stream.");
}
BufferedInputStream bis = new BufferedInputStream(stream); BufferedInputStream bis = new BufferedInputStream(stream);
try try
@@ -632,10 +622,9 @@ public class BasicResourceLoader implements ResourceLoader
return b; return b;
} }
catch (Exception e) catch (Exception ex)
{ {
logger.error(e.getMessage()); logger.log(Level.SEVERE, ex.getMessage(), ex);
return null; return null;
} }
} }

View File

@@ -1,41 +0,0 @@
package eva2.tools;
/**
* Dummy class replacing the log4j Category because log4j couldnt be included in a clean
* way and seemingly wasnt used in the main classes anyways.
*
* @author mkron, mpaly
*
*/
public class DummyCategory {
static DummyCategory dummy = new DummyCategory();
static boolean bDebugEnabled = false;
public void error() {
System.err.println("Error");
}
public void error(String msg) {
System.err.println(msg);
}
public static DummyCategory getInstance(String str) {
return dummy;
}
public boolean isDebugEnabled() {
return bDebugEnabled;
}
public void debug(String str) {
System.err.println(str);
}
public void info(String str) {
System.err.println(str);
}
public void warn(String str) {
System.err.println(str);
}
}

View File

@@ -1,6 +1,8 @@
package eva2.tools; package eva2.tools;
import java.util.HashMap; import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* Title: EvA2 * Title: EvA2
* Description: * Description:
@@ -16,66 +18,54 @@ import java.util.HashMap;
* *
*/ */
public class EVAERROR { public class EVAERROR {
static boolean MAIL_ON_ERROR = false; private static final Logger logger = Logger.getLogger(eva2.EvAInfo.defaultLogger);
static boolean MAIL_ON_WARNING = false; private static transient HashMap<String, Boolean> errorMap = null;
transient static HashMap<String, Boolean> errMap = null;
/** /**
* *
*/ */
static public void EXIT(String Message) { public static void EXIT(String message) {
// if (MAIL_ON_ERROR) logger.log(Level.SEVERE, message);
// EVAMail.SendMail("EvA EXIT on ERROR !! ",Message,"ulmerh@informatik.uni-tuebingen.de");
System.err.println("ERROR: "+Message);
System.out.flush();
System.err.flush();
System.exit(-1); System.exit(-1);
} }
/** /**
* *
*/ */
static public void EXIT(String Message, Exception e) { public static void EXIT(String message, Exception ex) {
logger.log(Level.SEVERE, message, ex);
System.out.println("ERROR: "+Message);
System.out.println("Exception: ");
e.printStackTrace();
// if (MAIL_ON_ERROR)
// EVAMail.SendMail("EvA EXIT on ERROR !! ",Message+e.toString(),"ulmerh@informatik.uni-tuebingen.de");
System.out.flush();
System.err.flush();
System.exit(-1); System.exit(-1);
} }
/** /**
* *
*/ */
static public void WARNING(String Message) { public static void WARNING(String message) {
// if (MAIL_ON_WARNING) logger.log(Level.WARNING, message);
// EVAMail.SendMail("EvA EXIT on ERROR !! ",Message,"ulmerh@informatik.uni-tuebingen.de");
System.err.println("WARNING: "+Message);
System.out.flush();
System.err.flush();
} }
/** /**
* Send a message only once to System.err. Once means that the msg is * Send a message only once to System.err. Once means that the msg is stored for the lifetime of
* stored for the lifetime of the VM or until clearMsgCache() is called. * the VM or until clearMsgCache() is called.
* *
* @param msg * @param msg
*/ */
static public void errorMsgOnce(String msg) { public static void errorMsgOnce(String message) {
if (errMap == null) errMap = new HashMap<String, Boolean>(); if (errorMap == null) {
errorMap = new HashMap<String, Boolean>();
}
if (!errMap.containsKey(msg)) { if (!errorMap.containsKey(message)) {
System.err.println(msg); logger.log(Level.SEVERE, message);
errMap.put(msg, true); errorMap.put(message, true);
} }
} }
/** /**
* Clear the error message cache, so that any error messages are * Clear the error message cache, so that any error messages are displayed at least once.
* displayed at least once.
*/ */
static public void clearMsgCache() { public static void clearMsgCache() {
if (errMap != null) errMap.clear(); if (errorMap != null) {
errorMap.clear();
}
} }
} }

View File

@@ -68,7 +68,7 @@ public class RMIServer {
/** /**
* Launchs the RMIRegistry and makes the registration * Launches the RMIRegistry and makes the registration
* of the MainAdapterImpl class at the rmiregistry. * of the MainAdapterImpl class at the rmiregistry.
* @param * @param
*/ */