This commit is contained in:
2026-06-11 19:31:22 +02:00
parent e7d80a1fbc
commit a4a4913958
24 changed files with 1636 additions and 0 deletions
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>de.hadrys</groupId>
<artifactId>Componentware_Kapitel6_Transaktionen_Uebung_TestClient</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>25</maven.compiler.source>
<maven.compiler.target>25</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
@@ -0,0 +1,11 @@
package aufgabe8;
public class HelloException1 extends Exception{
public HelloException1() {
super();
}
public HelloException1(String text){
super(text);
}
}
@@ -0,0 +1,14 @@
package aufgabe8;
import jakarta.ejb.ApplicationException;
@ApplicationException
public class HelloException2 extends Exception{
public HelloException2() {
super();
}
public HelloException2(String text){
super(text);
}
}
@@ -0,0 +1,11 @@
package aufgabe8;
import jakarta.ejb.Remote;
@Remote
public interface HelloWorldRemote {
public void sayHello1() throws HelloException1;
public void sayHello2() throws HelloException2;
public void sayHello3();
public void sayHello4();
}
@@ -0,0 +1,63 @@
package clients;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import aufgabe8.HelloWorldRemote;
public class HelloClient {
public static void main(String[] args) {
Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
properties.setProperty(Context.PROVIDER_URL, "http-remoting://127.0.0.1:8080");
try {
InitialContext context = new InitialContext(properties);
HelloWorldRemote hello = (HelloWorldRemote)context.lookup("ejb:/Componentware_Kapitel6_Transaktionen_Uebung/HelloWorld!aufgabe8.HelloWorldRemote?stateful");
try{
System.out.println("vor sayHello1()");
hello.sayHello1();
System.out.println("nach sayHello1()");
}
catch(Exception e){
e.printStackTrace();
}
try{
System.out.println("vor sayHello2()");
hello.sayHello2();
System.out.println("nach sayHello2()");
}
catch(Exception e){
e.printStackTrace();
}
try{
System.out.println("vor sayHello3()");
hello.sayHello3();
System.out.println("nach sayHello3()");
}
catch(Exception e){
e.printStackTrace();
}
try{
System.out.println("vor sayHello4()");
hello.sayHello4();
System.out.println("nach sayHello4()");
}
catch(Exception e){
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}