//engage the pre-extensions
for (int i = 0; i < preExtensions.size(); i++) {
((CodeGenExtension)preExtensions.get(i)).engage(configuration);
}
Emitter emitter;
TypeMapper mapper = configuration.getTypeMapper();
if (mapper == null) {
// this check is redundant here. The default databinding extension should
// have already figured this out and thrown an error message. However in case the
// users decides to mess with the config it is safe to keep this check in order to throw
// a meaningful error message
throw new CodeGenerationException(
CodegenMessages.getMessage("engine.noProperDatabindingException"));
}
//Find and invoke the emitter by reflection
Map emitterMap = ConfigPropertyFileLoader.getLanguageEmitterMap();
String className = (String)emitterMap.get(configuration.getOutputLanguage());
if (className != null) {
emitter = (Emitter)getObjectFromClassName(className);
emitter.setCodeGenConfiguration(configuration);
emitter.setMapper(mapper);
} else {
throw new Exception(CodegenMessages.getMessage("engine.emitterMissing"));
}
//invoke the necessary methods in the emitter
if (configuration.isServerSide()) {
emitter.emitSkeleton();
// if the users want both client and server, it would be in the
// generate all option
if (configuration.isGenerateAll()) {
emitter.emitStub();
}
} else {
emitter.emitStub();
}
//engage the post-extensions
for (int i = 0; i < postExtensions.size(); i++) {
((CodeGenExtension)postExtensions.get(i)).engage(configuration);