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

com.javonet.core.transmitter.Transmitter Maven / Gradle / Ivy

Go to download

Javonet allows you to reference and use modules or packages written in (Java/Kotlin/Groovy/Clojure, C#/VB.NET, Ruby, Perl, Python, JavaScript/TypeScript) like they were created in your technology. It works on Linux/Windows and MacOS for applications created in JVM, CLR/Netcore, Perl, Python, Ruby, NodeJS, C++ or GoLang and gives you unparalleled freedom and flexibility with native performance in building your mixed-technologies products. Let it be accessing best AI or cryptography libraries, devices SDKs, legacy client modules, internal custom packages or anything from public repositories available on NPM, Nuget, PyPI, Maven/Gradle, RubyGems or GitHub. Get free from programming languages barriers today! For more information check out our guides at https://www.javonet.com/guides/v2/

There is a newer version: 2.4.5
Show newest version
package com.javonet.core.transmitter;

import com.javonet.utils.RuntimeName;

public class Transmitter {


    public synchronized static byte[] sendCommand(byte[] messageByteArray) {
        int responseByteArrayLen = TransmitterWrapper.sendCommand(messageByteArray);
        if (responseByteArrayLen > 0) {
            byte[] responseByteArray = new byte[responseByteArrayLen];
            TransmitterWrapper.readResponse(responseByteArray);
            return responseByteArray;
        }
        else if (responseByteArrayLen == 0) {
            String errorMessage = "Response is empty";
            throw new RuntimeException(errorMessage);
        }
        else {
            String errorMessage = TransmitterWrapper.getNativeError();
            throw new RuntimeException("Javonet native error code: " + responseByteArrayLen + ". " + errorMessage);
        }

    }

    public static boolean deployRuntime(byte[] byteArray, String path, byte channel) {
        return TransmitterWrapper.deployRuntime(byteArray, path, channel);
    }

    public static boolean setEmbeddedRuntime(byte calledRuntimeNumber, byte calledRuntimeVersion, String path) {
        return TransmitterWrapper.setEmbeddedRuntime((byte) RuntimeName.Jvm.ordinal(), calledRuntimeNumber, calledRuntimeVersion, path);
    }

    public static int activateWithLicenseFile() {
        return activate("", "", "", "");
    }

    public static int activateWithCredentials(String licenseKey) {
        return activate(licenseKey, "", "", "");
    }

    public static int activateWithCredentialsAndProxy(String licenseKey, String proxyHost, String proxyUserName, String proxyPassword) {
        return activate(licenseKey, proxyHost, proxyUserName, proxyPassword);
    }

    private static int activate(String licenseKey, String proxyHost, String proxyUserName, String proxyPassword) {
        int activationResult = TransmitterWrapper.activate(licenseKey, proxyHost, proxyUserName, proxyPassword);
        if (activationResult < 0) {
            String errorMessage = TransmitterWrapper.getNativeError();
            throw new RuntimeException("Javonet activation result: " + activationResult + ". Native error message: " + errorMessage);
        } else  {
            return activationResult;
        }
    }

    public static int setConfigSource(String configSource) {
        int setConfigResult = TransmitterWrapper.setConfigSource(configSource);
        if (setConfigResult < 0) {
            String errorMessage = TransmitterWrapper.getNativeError();
            throw new RuntimeException("Javonet set config source result: " + setConfigResult + ". Native error message: " + errorMessage);
        }
        else {
            return setConfigResult;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy