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);
iocProcContextBuilder.gwtTarget(!useReflectionStubs);
final InjectionContext.Builder injectionContextBuilder
= InjectionContext.Builder.create();
final MetaDataScanner scanner = ScannerSingleton.getOrCreateInstance();
final Multimap<String, String> props = scanner.getErraiProperties();
if (props != null) {
logger.log(TreeLogger.Type.INFO, "Checking ErraiApp.properties for configured types ...");
final Collection<String> qualifyingMetadataFactoryProperties = props.get(QUALIFYING_METADATA_FACTORY_PROPERTY);
if (qualifyingMetadataFactoryProperties.size() > 1) {
throw new RuntimeException("the property '" + QUALIFYING_METADATA_FACTORY_PROPERTY + "' is set in more than one place");
}
else if (qualifyingMetadataFactoryProperties.size() == 1) {
final String fqcnQualifyingMetadataFactory = qualifyingMetadataFactoryProperties.iterator().next().trim();
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();
}
}
final Collection<String> enabledAlternativesProperties = props.get(ENABLED_ALTERNATIVES_PROPERTY);
for (final String prop : enabledAlternativesProperties) {
final String[] alternatives = prop.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(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();
}