I found a solution but i need help ... Please somebody help me ?
In AlpTimerTask's run method servlet.activeSipCallSessions is null.
But actually activeSipCallSessions can't be null.
Why i see it null in my TimerTask's run method ?
What will i do ?
Here is some part of my code :
AlpSipServlet
public class AlpSipServlet extends SipServlet implements Servlet {
..
public static HashMap activeSipCallSessions = new HashMap();
..
public void init(ServletConfig sc) throws ServletException {
..
timer = new Timer();
timer.schedule(
new AlpTimerTask("Listen Remaning Call Count",this), 10000, 50000);
..
}
public void doAckReceived(SipServletRequest request)
{
..
AlpSipServlet.activeSipCallSessions.put(sipAppSession.getId(), sipAppSession);
..
}
public void byeReceived(SipServletRequest request)
{
..
AlpSipServlet.activeSipCallSessions.remove(sipAppSession.getId());
..
}
In my AlpTimerTask.java :
public class AlpTimerTask extends TimerTask {
..
private AlpSipServlet servlet = null;
..
public AlpTimerTask(
String name,
AlpSipServlet servlet) {
this.name = name;
this.servlet =servlet; }
public void run() {
logger.debug("<AlpTimerTask.run>Do something!!!");
Collection activeCalls = null;
if (
servlet.activeSipCallSessions != null)
activeCalls = servlet.activeSipCallSessions.values();
if (activeCalls != null)
for (Iterator iterator = activeCalls.iterator(); iterator.hasNext()
{
SipApplicationSession sipAppSession = (SipApplicationSession) iterator.next();
logger.debug(" Active call session id : " + sipAppSession.getId());
}
if (activeCalls == null || activeCalls.size() == 0)
logger.debug("No active calls.");
}
}