From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- .../single_table/client/RoadVehicleClient.java | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Micah Examples/src/examples/entity/single_table/client/RoadVehicleClient.java (limited to 'Master/Reference Architectures and Patterns/EJB 3.0 Code/Micah Examples/src/examples/entity/single_table/client') diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Micah Examples/src/examples/entity/single_table/client/RoadVehicleClient.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Micah Examples/src/examples/entity/single_table/client/RoadVehicleClient.java new file mode 100644 index 0000000..6ef6ea6 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Micah Examples/src/examples/entity/single_table/client/RoadVehicleClient.java @@ -0,0 +1,54 @@ +package examples.entity.single_table.client; + +import javax.naming.InitialContext; +import javax.naming.NamingException; + +import examples.entity.single_table.interfaces.RoadVehicleStateless; + + +public class RoadVehicleClient { + public static void main(String[] args) { + String action = "insert"; + String type = "RoadVehicleSingle"; + + if (args.length>0) { + if (args[0].startsWith("update")) { + action="update"; + } + else if (args[0].startsWith("delete")) { + action="delete"; + } + + if (args.length == 2) { + type = args[1]; + } + } + + InitialContext ic; + try { + ic = new InitialContext(); + RoadVehicleStateless rvs = (RoadVehicleStateless)ic.lookup(RoadVehicleStateless.class.getName()); + + if (action.equals("insert")) { + System.out.println("Inserting..."); + rvs.doSomeStuff(); + } + else if (action.equals("update")) { + System.out.println("Updating "+type+"..."); + rvs.updateAll(type); + } + else if (action.equals("delete")) { + System.out.println("Deleting "+type+"..."); + rvs.deleteAll(type); + } + + System.out.println("Here is the list of all RoadVehicles:\n"); + for (Object o : rvs.getAllRoadVehicles()) { + System.out.println("RoadVehicle: "+o); + } + } + catch (NamingException e) { + e.printStackTrace(); + } + } +} -- cgit v1.2.3