[wip] praktikum2
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package org.example.demo.praktikum2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
|
||||
public class Client {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
|
||||
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);
|
||||
AdresseServiceRemote adresseService = (AdresseServiceRemote) ctx.lookup( "ejb:/ejb-server-1.0-SNAPSHOT/AdresseService!org.example.demo.praktikum2.AdresseServiceRemote");
|
||||
PersonServiceRemote personService = (PersonServiceRemote) ctx.lookup("ejb:/ejb-server-1.0-SNAPSHOT/PersonService!org.example.demo.praktikum2.PersonServiceRemote");
|
||||
|
||||
var adresse = Adresse.builder().strasse("strasse").plz("plz").ort("ort").build();
|
||||
int adresseId = adresseService.speichereAdresse(adresse);
|
||||
System.out.println("Adresse gespeichert mit ID: " + adresseId);
|
||||
System.out.println("Adresse nach dem Speichern: " + adresse);
|
||||
|
||||
var person = Person.builder().name("max").adresse(List.of(adresse)).build();
|
||||
int personId = personService.speicherePerson(person);
|
||||
System.out.println("Person gespeichert mit ID: " + personId);
|
||||
System.out.println("Person nach dem Speichern: " + person);
|
||||
|
||||
} catch (NamingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user