use of org.qi4j.library.rest.server.spi.ResponseWriter in project qi4j-sdk by Qi4j.
the class ResponseWriterDelegator method init.
public void init(@Service Iterable<ServiceReference<ResponseWriter>> resultWriters) throws InitializationException {
Logger logger = LoggerFactory.getLogger(getClass());
// Add custom writers first
for (ServiceReference<ResponseWriter> resultWriter : resultWriters) {
if (!resultWriter.identity().equals("responsewriterdelegator")) {
logger.info("Registered result writer:" + resultWriter.identity());
registerResultWriter(resultWriter.get());
}
}
// Add defaults
ResourceBundle defaultResultWriters = ResourceBundle.getBundle("org.qi4j.library.rest.server.rest-server");
String resultWriterClasses = defaultResultWriters.getString("responsewriters");
logger.info("Using response writers:" + resultWriterClasses);
for (String className : resultWriterClasses.split(",")) {
try {
Class writerClass = module.classLoader().loadClass(className.trim());
ResponseWriter writer = (ResponseWriter) module.newObject(writerClass);
registerResultWriter(writer);
} catch (ClassNotFoundException e) {
logger.warn("Could not register response writer " + className, e);
}
}
}
Aggregations