Search in sources :

Example 1 with ResponseWriter

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);
        }
    }
}
Also used : ResponseWriter(org.qi4j.library.rest.server.spi.ResponseWriter) ResourceBundle(java.util.ResourceBundle) Logger(org.slf4j.Logger)

Aggregations

ResourceBundle (java.util.ResourceBundle)1 ResponseWriter (org.qi4j.library.rest.server.spi.ResponseWriter)1 Logger (org.slf4j.Logger)1