if (repos == null) {
repos = conf.newMetaDataRepositoryInstance();
repos.setSourceMode(MetaDataRepository.MODE_META);
}
Log log = conf.getLog(OpenJPAConfiguration.LOG_TOOL);
Collection classes;
if (args == null || args.length == 0) {
classes = repos.getPersistentTypeNames(true, loader);
if (classes == null) {
log.warn(_loc.get("no-class-to-enhance"));
return false;
}
} else {
ClassArgParser cap = conf.getMetaDataRepositoryInstance().
getMetaDataFactory().newClassArgParser();
cap.setClassLoader(loader);
classes = new HashSet();
for (int i = 0; i < args.length; i++)
classes.addAll(Arrays.asList(cap.parseTypes(args[i])));
}
Project project = new Project();
BCClass bc;
PCEnhancer enhancer;
Collection persAwareClasses = new HashSet();
int status;
for (Iterator itr = classes.iterator(); itr.hasNext();) {
Object o = itr.next();
if (log.isInfoEnabled())
log.info(_loc.get("enhance-running", o));
if (o instanceof String)
bc = project.loadClass((String) o, loader);
else
bc = project.loadClass((Class) o);
enhancer = new PCEnhancer(conf, bc, repos, loader);
if (writer != null)
enhancer.setBytecodeWriter(writer);
enhancer.setDirectory(flags.directory);
enhancer.setAddDefaultConstructor(flags.addDefaultConstructor);
status = enhancer.run();
if (status == ENHANCE_NONE) {
if (log.isTraceEnabled())
log.trace(_loc.get("enhance-norun"));
} else if (status == ENHANCE_INTERFACE) {
if (log.isTraceEnabled())
log.trace(_loc.get("enhance-interface"));
} else if (status == ENHANCE_AWARE) {
persAwareClasses.add(o);
enhancer.record();
} else {
enhancer.record();
}
project.clear();
}
if(log.isInfoEnabled() && !persAwareClasses.isEmpty()){
log.info(_loc.get("pers-aware-classes", persAwareClasses.size(), persAwareClasses));
}
return true;
}