Я пытаюсь отменить таймер, но после этого у меня все еще есть его возврат через getTimers(). Это нормально или просто ошибка в каучо-смоле? Как правильно отменить программный таймер?java ejb TimerService: отменен таймер, возвращаемый getTimers (смола caucho)
@Singleton
@LocalBean
@Startup
public class TimerTest
{
@Resource
TimerService ts;
static TimerTest inst;
@PostConstruct
void init()
{ inst=this;
}
public synchronized static TimerTest getInstance()
{ return(inst);
}
public Collection<Timer> getTimers()
{ Collection <Timer> res=ts.getTimers();
return(res);
}
public void cancelAll()
{ for(Timer ot: ts.getTimers())
{ try
{ System.out.println("Found old timer "+ot.getInfo()+", cancelling it.");
ot.cancel();
}
catch(Exception e) {}
}
}
А потом (с JSP):
TimerTest tt=TimerTest.getInstance();
Collection <Timer> timers=tt.getTimers();
out.println("<br>Got "+timers.size()+" timer(s)<br>");
for(Timer t: timers)
{
try
{
out.println("<br>Got timer: "+t.getInfo());
}
catch(Exception e)
{
out.println("Error while cancelling timers "+e);
}
}
Ошибка при отменяя таймеров javax.ejb.NoSuchObjectLocalException: Этот таймер был отменен.
Спасибо!)