Scan annotated classes for eclipselink
hi all!
first, sorry about my english!
i have a class that scan a defined package and reads all classes, and then, add this classes to the hibernate. something like this:
Code:
public class AthusFactoryBean extends AnnotationSessionFactoryBean {
//Lista dos pacotes que devem ser escaneados
public static final String[] PACKAGES_SCAN = new String[]{
"br.com.athus.modelos",
"br.com.athus.modelos.movimentacao"};
@Override
protected SessionFactory buildSessionFactory() throws Exception {
ArrayList<Class<?>> classes = new ArrayList<Class<?>>();
ClassPathScanningCandidateComponentProvider scanner =
new ClassPathScanningCandidateComponentProvider(false);
scanner.addIncludeFilter(new AnnotationTypeFilter(Entity.class));
scanner.addIncludeFilter(new AnnotationTypeFilter(Embeddable.class));
for(String pacote : PACOTES_SCAN)
{
for (BeanDefinition bd : scanner.findCandidateComponents(pacote)) {
try {
String name = bd.getBeanClassName();
classes.add(Class.forName(name));
} catch (Exception e) {
System.err.println(e);
}
}
}
//Registering found classess
setAnnotatedClasses(classes.toArray(new Class[classes.size()]));
return super.buildSessionFactory();
}
so, now i need to do the same on eclipselink.
there's a way to do this?
thanks