我有一个接口定义为:
public interface DocExporter{
public void exportDoc();
}有两个实现类定义为:
@Service(value="docExporter")
@Scope(value="BeanDefinition.SCOPE_PROTOTYPE)
public class PdfDocExporter implements DocExporter{
public void exportDoc(){
// do Pdf Export stuff
}
}和
@Service(value="docExporter")
@Scope(value="BeanDefinition.SCOPE_PROTOTYPE)
public class ExcelDocExporter implements DocExporter{
public void exportDoc(){
// do Excel Export stuff
}
}所以我可以这样说吗:
@Name("docExportReporter")
@Scope(ScopeType.EVENT)
public class DocExportReporter {
@In("#{docExporter}")
private DocExporter pdfDocExporter;
@In("#{docExporter}")
private DocExporter excelDocExporter;
@Asynchronous
public void reportGen(){
**excelDocExporter.exportDoc()** // THIS THROWS Seam Exception @In attribute requires a not null value
}
}我是Spring的Seam新手,我想知道在两个impl类中@Service值是"docExporter“(接口名称)还是"pdfDocExporter”"excelDocExporter“?
如上所述,当在reportGen异步方法中使用pdfDocExporter或excelDocExporter对象时,我的get @In属性需要一个非空值异常。一个接口的两个实现是否可以在第三个类中声明,并与Seam @Asynchronous注解配合使用?
发布于 2012-10-04 21:12:23
您不能有两个同名的组件,否则Seam将不知道要注入哪个组件。使用两个不同的名称。
https://stackoverflow.com/questions/12712180
复制相似问题