protected abstract GenStrutsApp createStrutsApp( ClassDeclaration cl )
throws XmlException, IOException, FatalCompileTimeException;
public void generate( ClassDeclaration publicClass )
{
GenStrutsApp app = null;
getFCSourceFileInfo().startBuild( getEnv(), publicClass );
try
{
// Write the Struts config XML, and the Validator config XML if appropriate.
app = createStrutsApp( publicClass );
GenValidationModel validationModel = new GenValidationModel( publicClass, app, getEnv() );
if ( ! validationModel.isEmpty() )
{
app.setValidationModel( validationModel );
validationModel.writeToFile();
}
generateStrutsConfig( app, publicClass );
// First, write out XML for any fields annotated with @Jpf.SharedFlowField or @Control.
writeFieldAnnotations( publicClass, app );
}
catch ( FatalCompileTimeException e )
{
e.printDiagnostic( getDiagnostics() );
}
catch ( Exception e )
{
e.printStackTrace(); // @TODO log
assert e instanceof XmlException || e instanceof IOException || e instanceof FileNotFoundException
: e.getClass().getName();
getDiagnostics().addError( publicClass, "error.could-not-generate",
app != null ? app.getStrutsConfigFile() : null, e.getMessage() );
}
finally
{
getFCSourceFileInfo().endBuild();
}