RefreshManagerpublic class RefreshManager extends Object
Fields Summary |
---|
private static RefreshManager | instanceThe unique instance of this class. | private Hashtable | refreshTableThe hashtable keeping a mapping between the refreshID and
the refresh Tasks. | private int | idGeneratorgenerator of task id . |
Constructors Summary |
---|
private RefreshManager()Creates a new instance of the RefreshManager.
refreshTable = new Hashtable();
|
Methods Summary |
---|
public int | createRefreshTask(gov.nist.siplite.message.Request request, javax.microedition.sip.SipConnectionNotifier sipConnectionNotifier, javax.microedition.sip.SipRefreshListener sipRefreshListener, javax.microedition.sip.SipClientConnection sipClientConnection)Creates a new RefreshTask with a specific id, schedules it and
keep the mapping between this newly created task and the id.
int taskId = ++idGenerator;
RefreshTask refreshTask = new RefreshTask(
String.valueOf(taskId),
request,
sipConnectionNotifier,
sipRefreshListener,
sipClientConnection);
refreshTable.put(String.valueOf(taskId), refreshTask);
return taskId;
| public static synchronized gov.nist.microedition.sip.RefreshManager | getInstance()Returns the instance of RefreshManager.
if (instance == null)
instance = new RefreshManager();
return instance;
| public RefreshTask | getTask(java.lang.String taskId)Return the task mapping the taskId
return (RefreshTask)refreshTable.get(taskId);
| public void | removeTask(java.lang.String taskId)Removes a task
refreshTable.remove(taskId);
| public void | scheduleTask(java.lang.String taskId, int expires)Schedules the task whose id is given in parameter for the expires
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_JSR180,
"schedule the next register in " + expires + " sec");
}
RefreshTask refreshTask = (RefreshTask)refreshTable.get(taskId);
if (refreshTask == null)
return;
if (expires == -1)
return;
if (expires >= 0) {
// The timer to shcedule the tasks
Timer timer = new Timer();
// Once the task has been processed, it can be scheduled again
// so a new one is created
refreshTask = new RefreshTask(
refreshTask.getTaskId(),
refreshTask.getRequest(),
refreshTask.getSipConnectionNotifier(),
refreshTask.getSipRefreshListener(),
refreshTask.getSipClientConnection());
refreshTable.put(taskId, refreshTask);
timer.schedule(refreshTask, expires * 1000);
}
|
|