Search in sources :

Example 1 with ApioLogger

use of com.liferay.apio.architect.logger.ApioLogger in project com-liferay-apio-architect by liferay.

the class MessageMapperBaseManager method computeMessageMappers.

/**
 * Computes the list of managed message mappers and uses the provided
 * consumer to store them.
 */
protected void computeMessageMappers() {
    Stream<String> stream = getKeyStream();
    stream.forEach(key -> {
        T formMessageMapper = serviceTrackerMap.getService(key);
        try {
            MediaType mediaType = MediaType.valueOf(key);
            _storeBiConsumer.accept(mediaType, formMessageMapper);
        } catch (IllegalArgumentException iae) {
            Optional<ApioLogger> optional = getLoggerOptional();
            optional.ifPresent(apioLogger -> apioLogger.warning("Message mapper has invalid media type: " + key));
        }
    });
}
Also used : MediaType(javax.ws.rs.core.MediaType) Stream(java.util.stream.Stream) MessageMapper(com.liferay.apio.architect.message.json.MessageMapper) BiConsumer(java.util.function.BiConsumer) Optional(java.util.Optional) ApioLogger(com.liferay.apio.architect.logger.ApioLogger) ServiceReferenceMapper(com.liferay.osgi.service.tracker.collections.map.ServiceReferenceMapper) ServiceReference(org.osgi.framework.ServiceReference) Optional(java.util.Optional) MediaType(javax.ws.rs.core.MediaType)

Aggregations

ApioLogger (com.liferay.apio.architect.logger.ApioLogger)1 MessageMapper (com.liferay.apio.architect.message.json.MessageMapper)1 ServiceReferenceMapper (com.liferay.osgi.service.tracker.collections.map.ServiceReferenceMapper)1 Optional (java.util.Optional)1 BiConsumer (java.util.function.BiConsumer)1 Stream (java.util.stream.Stream)1 MediaType (javax.ws.rs.core.MediaType)1 ServiceReference (org.osgi.framework.ServiceReference)1