So I was setting up a custom ApplicationEvent and ApplicationListener for my Spring batch program. I followed the instructions here at section 3.13.2
Here is the ApplicationEvent I created
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;
}
}
And my 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;
}
}
The problem I am having is that the ApplicationListener complains about me trying to do
ApplicationListener < DataReaderEvent >
it says,
“The type ApplicationListener is not generic; it cannot be parameterized with arguments DataEventReader”
I don’t understand why this would be the case because I think I followed the example pretty closely. If anyone has any ideas they would be greatly appreciated.
Are you sure you have the right (3.0.x+) version of Spring included in your project? I think in 2.5.x ApplicationListener was not generic, so if you’re accidentally using that older version then that would cause the problem you’re having.
http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/context/ApplicationListener.html