use of com.sun.identity.cli.annotation.DefinitionClassInfo in project OpenAM by OpenRock.
the class CLIDefinitionGenerator method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
for (String className : definitions) {
try {
Class clazz = Class.forName(className);
Field pdtField = clazz.getDeclaredField("product");
if (pdtField != null) {
DefinitionClassInfo classInfo = pdtField.getAnnotation(DefinitionClassInfo.class);
PrintStream rbOut = createResourcePrintStream(outputDir, classInfo);
getCommonResourceStrings(rbOut, clazz);
rbOut.println("product-name=" + classInfo.productName());
getCommands(className, clazz, rbOut);
rbOut.close();
} else {
throw new Exception("Incorrect Definiton, class=" + className + " missing product field");
}
} catch (Exception ex) {
throw new MojoFailureException("An error occured while generating CLI resources", ex);
}
}
Resource resource = new Resource();
resource.setDirectory(outputDir);
project.addResource(resource);
}
use of com.sun.identity.cli.annotation.DefinitionClassInfo in project OpenAM by OpenRock.
the class CLIDefinitionBase method getProductName.
private void getProductName(Class clazz) throws CLIException {
try {
Field pdtField = clazz.getDeclaredField(CLIConstants.FLD_PRODUCT_NAME);
if (pdtField != null) {
DefinitionClassInfo classInfo = pdtField.getAnnotation(DefinitionClassInfo.class);
rb = ResourceBundle.getBundle(classInfo.resourceBundle());
logName = classInfo.logName();
} else {
throw new CLIException("Incorrect Definiton, class" + definitionClass + " missing product field", ExitCodes.INCORRECT_DEFINITION_CLASS);
}
} catch (NoSuchFieldException e) {
throw new CLIException(e, ExitCodes.INCORRECT_DEFINITION_CLASS);
}
}
Aggregations