Is it possible to initialize Map by using only annotations? I want to have my package and its sub-packages independent, so I don't want to define anything in the context.xml.
@Configuration did the job. This is the configuration class
@org.springframework.context.annotation.Configuration
public class Configuration {
@Autowired
private ImportHandler monographImportHandler;
@Autowired
private ImportHandler periodicalImportHandler;
@Bean(name = "importHandlerCatalog")
@Scope("prototype")
public Map<MetsFileType, ImportHandler> sipPackageProcessorCatalog() {
Map<MetsFileType, ImportHandler> catalog = new HashMap<>();
catalog.put(MetsFileType.MONOGRAPH, monographImportHandler);
catalog.put(MetsFileType.PERIODICAL, periodicalImportHandler);
return catalog;
}
}
And this is how I access it:
@Resource(name = "importHandlerCatalog")
public Map<MetsFileType, ImportHandler> importHandlerCatalog;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With