timer.schedule有些问题

时间:2011-04-25 10:36:20

标签: java multithreading jsf timer

请查看下面的JSF代码。我得到一个nullpointerexception (Exception in thread "Timer-1" |#] ) at SearchHomeRegistry.getCurrentInstance(). 一定有问题。我们需要弄清楚的是什么。

==========================================

public void startSchedule() {
    wpd = null;
    Timer timer = new Timer();

    timer.schedule (new TimerTask(){
        public void run(){
            refreshUser();
        }
      },500, 500);

}

public void refreshUser() {

    System.out.println("refreshUser start :" + wupromoDetails);
    if (!wupromoDetails.isEmpty()) {
        wpd = SearchHomeRegistry.getCurrentInstance().latestWPD();
                   .........

==========================================

@ApplicationScoped
public class SearchHomeRegistry extends AbstractEntityAccessor implements
        Serializable {

    public static SearchHomeRegistry getCurrentInstance() {
        SearchHomeRegistry result = null;
        FacesContext context = FacesContext.getCurrentInstance();

        Map<String, Object> appMap = context.getExternalContext()
                .getApplicationMap();

        result = (SearchHomeRegistry) appMap.get("searchHomeRegistry");

        assert (null != result);

        return result;
    }
    ..............

0 个答案:

没有答案