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

org.bdware.doip.cluster.entity.BDOEntity Maven / Gradle / Ivy

The newest version!
package org.bdware.doip.cluster.entity;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bdware.doip.audit.EndpointConfig;
import org.bdware.doip.cluster.callback.BDODelegateDoipMessageCallback;
import org.bdware.doip.cluster.client.DoaClusterClient;
import org.bdware.doip.cluster.util.DoipClientCacheUtil;
import org.bdware.doip.codec.doipMessage.DoipMessage;
import org.bdware.doip.endpoint.client.DoipMessageCallback;

public class BDOEntity implements DOEntity {
    static Logger LOGGER = LogManager.getLogger(BDOEntity.class);
    private final String address;
    private final String version;
    private final DoipClientCacheUtil connectionCache;

    public BDOEntity(String address, String version, DoipClientCacheUtil connectionCache) {
        this.address = address;
        this.version = version;
        this.connectionCache = connectionCache;
    }

    public String getAddress() {
        return address;
    }


    public String getVersion() {
        return version;
    }

    @Override
    public BDWType getType() {
        return BDWType.BDO;
    }

    @Override
    public void sendMessage(DoaClusterClient client, DoipMessage doipMessage, DoipMessageCallback doipMessageCallback ) {
        connectionCache.getClientByUrl(this, client.getAuditConfig(), doipClient -> {
            client.signMessage(doipMessage);
            BDODelegateDoipMessageCallback BDODelegateDoipMessageCallback = new BDODelegateDoipMessageCallback(doipClient, connectionCache,
                    doipMessageCallback, doipMessage);
            doipClient.sendMessage(doipMessage, BDODelegateDoipMessageCallback);
        });

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy