package org.example.demo.praktikum1.aufgabe1;
import javax.naming.InitialContext;
import javax.naming.Context;
import java.util.Properties;

public class Client {
    public static void main(String[] args) throws Exception {
        Properties props = new Properties();
        props.setProperty(Context.INITIAL_CONTEXT_FACTORY,
                          "org.wildfly.naming.client.WildFlyInitialContextFactory");
        props.setProperty(Context.PROVIDER_URL, "http-remoting://localhost:8080");

        InitialContext ctx = new InitialContext(props);
        String jndiName = "ejb:/ejb-server-1.0-SNAPSHOT/Calculator!org.example.demo.praktikum1.aufgabe1.CalculatorRemote";
        var calc = (CalculatorRemote) ctx.lookup(jndiName);

        System.out.println("6 + 7 = " + calc.addiere(6, 7));
        System.out.println("6 - 7 = " + calc.subtrahiere(6, 7));
        System.out.println("6 * 7 = " + calc.multipliziere(6, 7));
        System.out.println("6 / 7 = " + calc.dividiere(6, 7));
    }
}
