I am using spring batch in that I am passing class name as parameter to reader in that I want set that as my target class name.is there a way that we can get class name from a String.I tried with using reflection in that I am getting that class successfully.but I not able to set as my target type class below is my code.
@Bean(name = "jMongoReader")
@StepScope
public MongoItemReader<Object> jsonDataReader(@Value("#{jobParameters[name]}") String className) {
try {
Class cls= Class.forName(className);
reader.setTemplate(mongoConfig.getMongoTemplate());
reader.setCollection("employeeInfo");
reader.setTargetType((Class<? extends className>) className.class);
reader.setQuery("{}");
Map<String, Direction> sorts = new HashMap<String, Sort.Direction>(1);
sorts.put("_id", Sort.Direction.ASC);
reader.setSort(sorts);
reader.setFields(keys);
}
className.classis alwaysStringin your case