use of org.qi4j.library.rest.server.restlet.RequestReaderDelegator in project qi4j-sdk by Qi4j.
the class RestServerAssembler method assemble.
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
Properties props = new Properties();
try {
props.load(getClass().getResourceAsStream("/velocity.properties"));
VelocityEngine velocity = new VelocityEngine(props);
module.importedServices(VelocityEngine.class).importedBy(INSTANCE).setMetaInfo(velocity);
} catch (Exception e) {
throw new AssemblyException("Could not load velocity properties", e);
}
freemarker.template.Configuration cfg = new freemarker.template.Configuration();
cfg.setClassForTemplateLoading(AbstractResponseWriter.class, "");
cfg.setObjectWrapper(new ValueCompositeObjectWrapper());
module.importedServices(freemarker.template.Configuration.class).setMetaInfo(cfg);
module.importedServices(MetadataService.class);
module.importedServices(ResponseWriterDelegator.class).identifiedBy("responsewriterdelegator").importedBy(NEW_OBJECT).visibleIn(Visibility.layer);
module.objects(ResponseWriterDelegator.class);
module.importedServices(RequestReaderDelegator.class).identifiedBy("requestreaderdelegator").importedBy(NEW_OBJECT).visibleIn(Visibility.layer);
module.objects(RequestReaderDelegator.class);
module.importedServices(InteractionConstraintsService.class).importedBy(NewObjectImporter.class).visibleIn(Visibility.application);
module.objects(InteractionConstraintsService.class);
// Standard response writers
Iterable<Class<?>> writers = ClassScanner.findClasses(DefaultResponseWriter.class);
Specification<Class<?>> responseWriterClass = isAssignableFrom(ResponseWriter.class);
Specification<Class<?>> isNotAnAbstract = not(hasModifier(Modifier.ABSTRACT));
Iterable<Class<?>> candidates = filter(and(isNotAnAbstract, responseWriterClass), writers);
for (Class<?> responseWriter : candidates) {
module.objects(responseWriter);
}
// Standard request readers
module.objects(DefaultRequestReader.class);
}
Aggregations