uebung2
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package org.example.demo.uebung2.aufgabe22;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
|
||||
import org.example.demo.uebung2.aufgabe21.Mitarbeiter;
|
||||
|
||||
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);
|
||||
String jndiName = "ejb:/ejb-server-1.0-SNAPSHOT/MitarbeiterService!org.example.demo.uebung2.aufgabe22.MitarbeiterServiceRemote";
|
||||
MitarbeiterServiceRemote service = (MitarbeiterServiceRemote) ctx.lookup(jndiName);
|
||||
|
||||
Mitarbeiter m = new Mitarbeiter("Max Mustermann", 12345);
|
||||
int generierteId = service.speichereMitarbeiter(m);
|
||||
System.out.println("Mitarbeiter gespeichert mit ID: " + generierteId);
|
||||
System.out.println("Entity nach dem Speichern: " + m);
|
||||
|
||||
} catch (NamingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user