notNull(environment, "The application's environment is required.");
notNull(mode, "The application's descriptor is required.");
notNull(processorsFactory, "The processor's factory is required.");
notNull(uriLocatorFactory, "The uri locator factory is required.");
final BaseWroManagerFactory wroManagerFactory = new BaseWroManagerFactory();
wroManagerFactory
.setUriLocatorFactory(uriLocatorFactory)
.setModelFactory(new WildcardModelFactory(
applicationContext, wroModelFactory));
List<Transformer> transformers =
Beans.lookFor(applicationContext, Transformer.class);
GroupExtractor groupExtractor =
Beans.get(applicationContext, GroupExtractor.class);
boolean useDefaults =
transformers.size() == 0 && groupExtractor == null;
if (useDefaults) {
mode.execute(new ModeCallback<Object>() {
@Override
public Object onDev() {
GroupPerFileModel groupPerFileModel = new GroupPerFileModel();
wroManagerFactory.addModelTransformer(groupPerFileModel);
wroManagerFactory.setGroupExtractor(groupPerFileModel);
return null;
}
@Override
public Object on(final Mode mode) {
return null;
}
});
} else {
for (Transformer transformer : transformers) {
wroManagerFactory.addModelTransformer(transformer);
}
if (groupExtractor != null) {
wroManagerFactory.setGroupExtractor(groupExtractor);
}
}
wroManagerFactory.setProcessorsFactory(
processorsFactory(mode, processorsFactory, uriLocatorFactory,
environment));
return wroManagerFactory;
}