All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dynamicextensionsalfresco.event.impl.DefaultEventBus.kt Maven / Gradle / Ivy

Go to download

Adds an OSGi container to alfresco repository supporting dynamic code reloading, classpath isolation and a bunch of other useful features

There is a newer version: 3.1.0
Show newest version
package com.github.dynamicextensionsalfresco.event.impl

import com.github.dynamicextensionsalfresco.event.Event
import com.github.dynamicextensionsalfresco.event.EventBus
import com.github.dynamicextensionsalfresco.event.EventListener
import org.osgi.framework.BundleContext

/**
 * Synchronous implementation that only notifies listeners based on their supported events.

 * @author Laurent Van der Linden
 */
public class DefaultEventBus(private val bundleContext: BundleContext) : EventBus {
    @Suppress("UNCHECKED_CAST")
    override fun publish(event: Event) {
        bundleContext.getAllServiceReferences(EventListener::class.java.name, null)
                .asSequence()
                .map { bundleContext.getService(it) }
                .filterIsInstance(EventListener::class.java)
                .filter { it.supportedEventTypes.any { it == event.javaClass } }
                .forEach { (it as EventListener).onEvent(event) }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy