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

org.enodeframework.messaging.impl.SingleMessageDispatching.kt Maven / Gradle / Ivy

package org.enodeframework.messaging.impl

import org.enodeframework.infrastructure.ObjectProxy
import org.enodeframework.infrastructure.TypeNameProvider
import org.enodeframework.messaging.Message
import java.util.concurrent.ConcurrentHashMap

class SingleMessageDispatching(
    val message: Message,
    private val queueMessageDispatching: QueueMessageDispatching,
    handlers: List,
    typeNameProvider: TypeNameProvider
) {
    private val handlerDict: ConcurrentHashMap = ConcurrentHashMap()

    init {
        handlers.forEach { objectProxy ->
            handlerDict.putIfAbsent(
                typeNameProvider.getTypeName(objectProxy.getInnerObject().javaClass),
                objectProxy
            )
        }
    }

    fun removeHandledHandler(handlerTypeName: String) {
        if (handlerDict.remove(handlerTypeName) != null) {
            if (handlerDict.isEmpty()) {
                queueMessageDispatching.onMessageHandled(message)
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy