Again Thanks for ur kind replies .
so far i am good after implementing your suggestions .
We create the Hibernate Session factory where we pass more than 500 Domain classes , it occupies many lines which i would liek to avoid instaed of that i am following the below approach
- Since all our domain classes were already annotated with @Entity Annotation ,I would like to know all fully qualifies list of class annotated with @Entity by scanning all classes in classptah .This class should be called much before spring instantiates Hibernate Session factory
Storing this list of bean class in spring context ,so that hibernate session factory will refer the list of class which i created in spring contet and i will delete those 500 lines of domain classes hard coded in xml.
Code i am using to find the list of fully qualified class by scanning classes in classpth
Code:
List<String> beansList = new ArrayList<String>();
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(
true);
Long startDate = System.currentTimeMillis();
String basePackage = "com.firm.xx.yy.model";
provider.addExcludeFilter(new AnnotationTypeFilter(RemoteBinding.class, false));
provider.addIncludeFilter(new AnnotationTypeFilter(Entity.class, false));
Set<BeanDefinition> filteredComponents = provider
.findCandidateComponents(basePackage);
System.out.println("No of components :" + filteredComponents.size());
for (BeanDefinition component : filteredComponents) {
System.out.println("Component:" + component.getBeanClassName());
}
provider.resetFilters(true);
provider.addIncludeFilter(new AnnotationTypeFilter(Repository.class,
true));
filteredComponents = provider.findCandidateComponents(basePackage);
System.out.println("No of components :" + filteredComponents.size());
Long endDate = System.currentTimeMillis();
for (BeanDefinition component : filteredComponents) {
beansList.add(component.getBeanClassName());
}
some cases above code gives Annotation Error .
on side note , i think even we can configure <component-scan ../> to scan our custom annotaions , i really dont know who to get the list bean class from that
Any help would be highly appreciated .
Thanks in advance
Gowtham