final BlockBuilder<?> blockBuilder =
classStructureBuilder.publicMethod(BootstrapperInjectionContext.class, "bootstrapContainer")
.methodComment("The main IOC bootstrap method.");
final SourceWriter sourceWriter = new StringSourceWriter();
final IOCProcessingContext.Builder iocProcContextBuilder
= IOCProcessingContext.Builder.create();
iocProcContextBuilder.blockBuilder(blockBuilder);
iocProcContextBuilder.generatorContext(context);
iocProcContextBuilder.context(buildContext);
iocProcContextBuilder.bootstrapClassInstance(bootStrapClass);
iocProcContextBuilder.bootstrapBuilder(classStructureBuilder);
iocProcContextBuilder.logger(logger);
iocProcContextBuilder.sourceWriter(sourceWriter);
final InjectionContext.Builder injectionContextBuilder
= InjectionContext.Builder.create();
final MetaDataScanner scanner = ScannerSingleton.getOrCreateInstance();
final Properties props = scanner.getProperties("ErraiApp.properties");
if (props != null) {
logger.log(TreeLogger.Type.INFO, "Checking ErraiApp.properties for configured types ...");
for (final Object o : props.keySet()) {
final String key = (String) o;
if (key.equals(QUALIFYING_METADATA_FACTORY_PROPERTY)) {
final String fqcnQualifyingMetadataFactory = String.valueOf(props.get(key));
try {
final QualifyingMetadataFactory factory = (QualifyingMetadataFactory)
Class.forName
(fqcnQualifyingMetadataFactory).newInstance();
iocProcContextBuilder.qualifyingMetadata(factory);
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
catch (InstantiationException e) {
e.printStackTrace();
}
catch (IllegalAccessException e) {
e.printStackTrace();
}
}
else if (key.equals(ENABLED_ALTERNATIVES_PROPERTY)) {
final String[] alternatives = String.valueOf(props.get(ENABLED_ALTERNATIVES_PROPERTY)).split("\\s");
for (final String alternative : alternatives) {
injectionContextBuilder.enabledAlternative(alternative.trim());
}
}
}
}
iocProcContextBuilder.packages(packages);
final IOCProcessingContext procContext = iocProcContextBuilder.build();
injectionContextBuilder.processingContext(procContext);
injectionContextBuilder.reachableTypes(allDeps);
final InjectionContext injectionContext = injectionContextBuilder.build();
defaultConfigureProcessor(context, injectionContext);
// generator constructor source code
final IOCProcessorFactory procFactory = new IOCProcessorFactory(injectionContext);
processExtensions(context, procContext, injectionContext, procFactory, beforeTasks, afterTasks);
generateExtensions(procContext, procFactory, injectionContext, sourceWriter, classStructureBuilder, blockBuilder);
// close generated class
return sourceWriter.toString();
}