Search in sources :

Example 1 with DocumentTypeFactoryCustomizer

use of io.openk9.plugin.driver.manager.api.DocumentTypeFactoryCustomizer in project openk9 by smclab.

the class DocumentTypeFactoryCustomizerHandle method activate.

@Activate
public void activate(BundleContext bundleContext) {
    _serviceTracker = new ServiceTracker<>(bundleContext, DocumentTypeFactoryCustomizer.class, new ServiceTrackerCustomizer<>() {

        @Override
        public DocumentTypeFactoryCustomizer addingService(ServiceReference<DocumentTypeFactoryCustomizer> reference) {
            DocumentTypeFactoryCustomizer service = bundleContext.getService(reference);
            List<Mono<Void>> collect = _documentTypeProvider.getDocumentTypeMap().entrySet().stream().map(service).collect(Collectors.toList());
            Flux.concat(collect).blockLast(Duration.ofSeconds(10));
            return service;
        }

        @Override
        public void modifiedService(ServiceReference<DocumentTypeFactoryCustomizer> reference, DocumentTypeFactoryCustomizer service) {
            removedService(reference, service);
            addingService(reference);
        }

        @Override
        public void removedService(ServiceReference<DocumentTypeFactoryCustomizer> reference, DocumentTypeFactoryCustomizer service) {
            bundleContext.ungetService(reference);
        }
    });
    _serviceTracker.open(true);
}
Also used : ServiceTrackerCustomizer(org.osgi.util.tracker.ServiceTrackerCustomizer) Mono(reactor.core.publisher.Mono) DocumentTypeFactoryCustomizer(io.openk9.plugin.driver.manager.api.DocumentTypeFactoryCustomizer) ServiceReference(org.osgi.framework.ServiceReference) Activate(org.osgi.service.component.annotations.Activate)

Aggregations

DocumentTypeFactoryCustomizer (io.openk9.plugin.driver.manager.api.DocumentTypeFactoryCustomizer)1 ServiceReference (org.osgi.framework.ServiceReference)1 Activate (org.osgi.service.component.annotations.Activate)1 ServiceTrackerCustomizer (org.osgi.util.tracker.ServiceTrackerCustomizer)1 Mono (reactor.core.publisher.Mono)1