* Set the command line arguments.
* @param args The args
*/
public void setCommandLineArgs(String[] args)
{
CommandLine cmd = new CommandLine();
cmd.addOption("d", "dest", "<directory>", "output directory");
cmd.addOption("api", "api", "<adapter-name>", "API Adapter (JDO, JPA, etc)");
cmd.addOption("enhancerName", "enhancerName", "<enhancer-name>", "Class Enhancer name (ASM, BCEL, etc)");
cmd.addOption("v", "verbose", null, "verbose output");
cmd.addOption("verify", "verify", null, "verify the enhancement");
cmd.addOption("checkonly", "checkonly", null, "only check if the class is enhanced");
cmd.addOption("check", "check", null, "after enhancement, check if the class was enhanced");
cmd.addOption("persistenceUnit", "persistenceUnit", "<name-of-persistence-unit>", "name of the persistence unit to enhance");
cmd.parse(args);
if (cmd.hasOption("api"))
{
api = cmd.getOptionArg("api");
omfContext.setApi(api);
}
if (cmd.hasOption("enhancerName"))
{
setEnhancerName(cmd.getOptionArg("enhancerName"));
}
if (cmd.hasOption("d"))
{
String destination = cmd.getOptionArg("d");
File tmp = new File(destination);
if (tmp.exists())
{
if (!tmp.isDirectory())
{
System.out.println(destination + " is not directory. please set directory.");
System.exit(1);
}
}
else
{
tmp.mkdirs();
}
setDestination(destination);
}
defaultArgs = cmd.getDefaultArgs();
// populate options
ApiAdapter adapter = omfContext.getApiAdapter();
Map map = adapter.getDefaultFactoryProperties();
setOptions(map);
if (cmd.hasOption("persistenceUnit"))
{
setProperty("org.jpox.PersistenceUnitName", cmd.getOptionArg("persistenceUnit"));
}
if (cmd.hasOption("api"))
{
setProperty("org.jpox.persistenceApiName", cmd.getOptionArg("api"));
}
if (cmd.hasOption("verify"))
{
setProperty(ENHANCER_OPTION_VERIFY, "true");
}
if (cmd.hasOption("v"))
{
setProperty(ENHANCER_OPTION_VERBOSE, "true");
}
if (cmd.hasOption("checkonly"))
{
setProperty(ENHANCER_OPTION_CHECKONLY, "true");
}
}