refactoring

This commit is contained in:
2026-04-17 10:04:51 +02:00
parent 2c5feb25f6
commit 32f7cd07d9
20 changed files with 113 additions and 90 deletions

37
client/pom.xml Normal file
View File

@@ -0,0 +1,37 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.componentware</groupId>
<artifactId>componentware-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>ejb-client</artifactId>
<packaging>jar</packaging>
<dependencies>
<!-- Abhängigkeit zu den EJB-Interfaces des Server-Moduls -->
<dependency>
<groupId>de.componentware</groupId>
<artifactId>ejb-uebung</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- BOM für alle WildFly EJB-Client Abhängigkeiten -->
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-ejb-client-bom</artifactId>
<version>39.0.0.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,22 @@
package org.example.demo.uebung1.aufgabe16;
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-uebung-1.0-SNAPSHOT/Encryptor!org.example.demo.uebung1.aufgabe16.EncryptorRemote";
EncryptorRemote encryptor = (EncryptorRemote) ctx.lookup(jndiName);
String original = "Hallo Welt";
String encrypted = encryptor.encrypt(original);
System.out.println("Original: " + original);
System.out.println("Verschlüsselt: " + encrypted);
}
}

View File

@@ -0,0 +1,21 @@
package org.example.demo.uebung1.aufgabe17;
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-uebung-1.0-SNAPSHOT/Counter!org.example.demo.uebung1.aufgabe17.CounterRemote?stateful";
CounterRemote counter = (CounterRemote) ctx.lookup(jndiName);
System.out.println(counter.getAndIncrement());
System.out.println(counter.getAndIncrement());
System.out.println(counter.getAndIncrement());
}
}