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

com.javonet.core.generator.TransmitterOptimizer 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.generator;

import com.javonet.core.generator.handler.GeneratorHandler;
import com.javonet.core.handler.Handler;
import com.javonet.core.interpreter.Interpreter;
import com.javonet.utils.Command;
import com.javonet.utils.CommandType;
import com.javonet.utils.RuntimeName;
import com.javonet.utils.ConnectionType;
import com.javonet.utils.TcpConnectionData;

import java.io.File;
import java.util.Locale;

public class TransmitterOptimizer {
    public static void optimize(Command command, Handler handler, Interpreter interpreter, ConnectionType connectionType, TcpConnectionData tcpConnectionData) {
        Command optimizedCommand = new Command(command.getRuntimeName(), CommandType.OPTIMIZE, new Object[]{command});

        Command optimizedResponse;
        if (RuntimeName.Jvm == command.getRuntimeName()) {
            optimizedResponse = handler.handleCommand(optimizedCommand);
        } else {
            optimizedResponse = interpreter.execute(optimizedCommand, connectionType, tcpConnectionData);
        }
        String dir = System.getProperty("user.dir");
        String classPath;
        if (System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("win")) {
            classPath = dir + "\\Binaries\\Native\\Windows\\X64";
        } else if (System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("mac")) {
            classPath = dir + "/Binaries/Native/MacOs/X64";
        } else {
            classPath = dir + "/Binaries/Native/Linux/X64";
        }

        GeneratorHandler generatorHandler = new GeneratorHandler();
        File generatedClassFile = generatorHandler.generateOptimizedTransmitter(optimizedResponse, classPath);
        generatorHandler.compileClass(generatedClassFile);
        Class clazz = generatorHandler.getClassFromUrl("JvmOptimizedTransmitter", new File(classPath));
        IOptimizedTransmitter.optimizedClasses.put(command.hashCode(), generatorHandler.getClassObject(clazz));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy