* Run the tool. Returns false if invalid options were given.
*/
public static boolean run(OpenJPAConfiguration conf, String[] args,
Flags flags, ClassLoader loader)
throws IOException, ClassNotFoundException {
MetaDataRepository repos = conf.newMetaDataRepositoryInstance();
repos.setValidate(repos.VALIDATE_NONE, true);
loadObjectIds(repos, flags.name == null && flags.suffix == null);
Log log = conf.getLog(OpenJPAConfiguration.LOG_TOOL);
Collection classes;
if (args.length == 0) {
log.info(_loc.get("running-all-classes"));
classes = repos.loadPersistentTypes(true, loader);
} 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])));
}
if (flags.name != null && classes.size() > 1)
throw new UserException(_loc.get("name-mult-args", classes));
ApplicationIdTool tool;
Class cls;
ClassMetaData meta;
BCClassLoader bc = AccessController
.doPrivileged(J2DoPrivHelper.newBCClassLoaderAction(new Project()));
for (Iterator itr = classes.iterator(); itr.hasNext();) {
cls = (Class) itr.next();
log.info(_loc.get("appid-running", cls));
meta = repos.getMetaData(cls, null, false);
setObjectIdType(meta, flags, bc);
tool = new ApplicationIdTool(conf, cls, meta);
tool.setDirectory(flags.directory);
tool.setIgnoreErrors(flags.ignoreErrors);