2012-04-25 115 views
1

所以我爲我的Spring批處理程序設置了一個自定義的ApplicationEvent和ApplicationListener。我跟在部分3.13.2ApplicationListener不能用參數參數化?

這裏說明here是我創建

import org.springframework.context.ApplicationEvent; 

public class DataReaderEvent extends ApplicationEvent { 

    private final String progress; 
    private final String text; 

    public DataReaderEvent(Object source, String progress, String text) { 
     super(source); 
     this.progress = progress; 
     this.text = text; 
    } 

    public String getProgress() { 
     return progress; 
    } 

    public String getText() { 
     return text; 
    } 

} 

的了ApplicationEvent而我ApplicationListener

import org.springframework.context.ApplicationListener; 

public class DataReaderNotifier implements ApplicationListener<DataReaderEvent> { 

    private String progress; 
    private String text; 


    @Override 
    public void onApplicationEvent(DataReaderEvent event) { 
     this.progress = event.getProgress(); 
     this.text = event.getText(); 
    } 

    public String getProgress() { 
     return progress; 
    } 

    public String getText() { 
     return text; 
    } 
} 

我遇到的問題是了ApplicationListener抱怨我嘗試要做 ApplicationListener < DataReaderEvent>

它說, 「ApplicationListener類型不是通用的;它不能與參數進行參數DataEventReader」

我不明白爲什麼會是這樣,因爲我覺得我跟着例子非常密切,如果任何人有他們將不勝感激的任何想法。

回答