Search in sources :

Example 1 with RequestReader

use of org.qi4j.library.rest.server.spi.RequestReader in project qi4j-sdk by Qi4j.

the class RequestReaderDelegator method init.

public void init(@Service Iterable<ServiceReference<RequestReader>> requestReaderReferences) throws InitializationException {
    Logger logger = LoggerFactory.getLogger(getClass());
    // Add custom readers first
    for (ServiceReference<RequestReader> requestReader : requestReaderReferences) {
        if (!requestReader.identity().equals("requestreaderdelegator")) {
            logger.info("Registered request reader:" + requestReader.identity());
            registerRequestReader(requestReader.get());
        }
    }
    // Add defaults
    ResourceBundle defaultRequestReaders = ResourceBundle.getBundle("org.qi4j.library.rest.server.rest-server");
    String requestReaderClasses = defaultRequestReaders.getString("requestreaders");
    logger.info("Using request readers:" + requestReaderClasses);
    for (String className : requestReaderClasses.split(",")) {
        try {
            Class readerClass = module.classLoader().loadClass(className.trim());
            RequestReader writer = (RequestReader) module.newObject(readerClass);
            registerRequestReader(writer);
        } catch (ClassNotFoundException e) {
            logger.warn("Could not register request reader " + className, e);
        }
    }
}
Also used : RequestReader(org.qi4j.library.rest.server.spi.RequestReader) ResourceBundle(java.util.ResourceBundle) Logger(org.slf4j.Logger)

Aggregations

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