mActiveThreadCount++;
boolean isFinished = false;
do {
// Get the next job
PrimaryDataService pds = null;
synchronized (mPDSList) {
if (mPDSList.isEmpty()) {
isFinished = true;
} else {
pds = mPDSList.removeFirst();
}
}
if (pds != null) {
String dir = mRawDir.getAbsolutePath();
File logFile=new File(mLogDir,pds.getClass().getName()+".txt");
try {
FileOutputStream out=new FileOutputStream(logFile);
PrintStream errOut=new PrintStream(out);
if (mProperties != null) {
pds.setParameters(mProperties);
}
boolean thereWereErrors = pds.execute(dir, errOut);
if (thereWereErrors) {
mLog.warning("There were errors during the execution of primary "
+ "data service " + pds.getClass().getName() + ". See log file: "
+ logFile.getAbsolutePath());
}else{
mLog.fine(pds.getClass().getName()+ " terminated normally");
logFile.delete();
}
errOut.close();
}catch(Exception exc) {
mLog.log(Level.SEVERE, "Error executing primary data service "+pds.getClass().getName(), exc);
}
}
} while (! isFinished);
mActiveThreadCount--;