praktikum1/aufgabe1

This commit is contained in:
2026-04-17 10:23:25 +02:00
parent 32f7cd07d9
commit b6de6840d3
9 changed files with 62 additions and 5 deletions

View File

@@ -13,7 +13,7 @@
<!-- Abhängigkeit zu den EJB-Interfaces des Server-Moduls -->
<dependency>
<groupId>de.componentware</groupId>
<artifactId>ejb-uebung</artifactId>
<artifactId>ejb-server</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- BOM für alle WildFly EJB-Client Abhängigkeiten -->

View File

@@ -0,0 +1,22 @@
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));
}
}

View File

@@ -11,7 +11,7 @@ public class Client {
props.setProperty(Context.PROVIDER_URL, "http-remoting://localhost:8080");
InitialContext ctx = new InitialContext(props);
String jndiName = "ejb:/ejb-uebung-1.0-SNAPSHOT/Encryptor!org.example.demo.uebung1.aufgabe16.EncryptorRemote";
String jndiName = "ejb:/ejb-server-1.0-SNAPSHOT/Encryptor!org.example.demo.uebung1.aufgabe16.EncryptorRemote";
EncryptorRemote encryptor = (EncryptorRemote) ctx.lookup(jndiName);
String original = "Hallo Welt";

View File

@@ -11,7 +11,7 @@ public class Client {
props.setProperty(Context.PROVIDER_URL, "http-remoting://localhost:8080");
InitialContext ctx = new InitialContext(props);
String jndiName = "ejb:/ejb-uebung-1.0-SNAPSHOT/Counter!org.example.demo.uebung1.aufgabe17.CounterRemote?stateful";
String jndiName = "ejb:/ejb-server-1.0-SNAPSHOT/Counter!org.example.demo.uebung1.aufgabe17.CounterRemote?stateful";
CounterRemote counter = (CounterRemote) ctx.lookup(jndiName);
System.out.println(counter.getAndIncrement());