/* Copyright 1999-2008 Acelet.org. All rights reserved. GPL v2 license */
/** @author Wei Jiang */
package com.acelet.s.watchdog;
import java.io.*;
import java.net.*;
import java.sql.*;
import java.util.*;
import javax.naming.*;
import com.acelet.lib.Common;
import com.acelet.lib.Externals;
import com.acelet.lib.Kit;
import com.acelet.lib.LogAgent;
import com.acelet.lib.LoggingConstants;
import com.acelet.lib.NotSupportedException;
import com.acelet.lib.Phrase;
import com.acelet.lib.SendEmail;
import com.acelet.lib.SuperProperties;
import com.acelet.s.MailServerData;
import com.acelet.s.chore.CandidateChore;
import com.acelet.s.chore.Chore;
import com.acelet.s.chore.ChoreProcess;
import com.acelet.s.chore.WatchdogDoerTalker;
import com.acelet.s.chore.WorkingChore;
import com.acelet.s.scheduler.DirectTaskDatabaseConnection;
/**
* The <code>ApiBase</code> is a utility class for SuperWatchdog.
* It is the API to SuperWatchdog.
* <br>
* @see com.acelet.s.job.AbstractTaskConstants
* @see com.acelet.s.chore.Chore
* @see com.acelet.s.chore.ChoreConstants
* @see com.acelet.s.chore.WorkingChore
* <br>
*/
public class ApiBase {
static boolean initialized = false;
static LogAgent logAgent;
protected ApiBase() throws Exception {
}
public static int deleteDoerTalker(String name) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new ChoreProcess(connection).deleteDoerTalker(name);
} finally {
if (connection != null)
connection.close();
}
}
public static int insertWatchdogPreference(Connection conn, String key, String value)
throws Exception {
return new ChoreProcess(conn).insertWatchdogPreference(key, value);
}
public static Vector selectAllDoerTalkers() throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new ChoreProcess(connection).selectAllDoerTalkers();
} finally {
if (connection != null)
connection.close();
}
}
public static Properties selectSettings() throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new ChoreProcess(connection).selectSettings();
} finally {
if (connection != null)
connection.close();
}
}
public static int updateSettings(Properties settings) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new ChoreProcess(connection).updateSettings(settings);
} finally {
if (connection != null)
connection.close();
}
}
public static Properties selectWatchdogPreference() throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new ChoreProcess(connection).selectWatchdogPreference();
} finally {
if (connection != null)
connection.close();
}
}
public static int updateWatchdogPreference(Properties properties) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new ChoreProcess(connection).updateWatchdogPreference(properties);
} finally {
if (connection != null)
connection.close();
}
}
public static int updateWorkingChoreMarkedAsLost(WorkingChore workingChore) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new ChoreProcess(connection).updateWorkingChoreMarkedAsLost(workingChore);
} finally {
if (connection != null)
connection.close();
}
}
}