diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/session/stateless/HelloClient.java | |
| download | Studium-master.tar.gz Studium-master.tar.bz2 | |
Diffstat (limited to 'Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/session/stateless/HelloClient.java')
| -rw-r--r-- | Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/session/stateless/HelloClient.java | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/session/stateless/HelloClient.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/session/stateless/HelloClient.java new file mode 100644 index 0000000..9becd53 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/session/stateless/HelloClient.java @@ -0,0 +1,59 @@ +package examples.session.stateless;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Hashtable;
+
+// The following import should be removed.
+
+import examples.session.stateless.*;
+import javax.naming.*;
+
+/**
+ * This class is an example of client code which invokes
+ * methods on a simple, remote stateless session bean.
+ */
+public class HelloClient {
+
+ public static void main(String[] args) throws Exception {
+ /*
+ * Obtain the JNDI initial context.
+ *
+ * The initial context is a starting point for
+ * connecting to a JNDI tree. We choose our JNDI
+ * driver, the network location of the server, etc
+ * by passing in the environment properties.
+ */
+
+ System.out.println("about to create initialcontext");
+
+ Hashtable env = new Hashtable();
+ env.put("java.naming.factory.initial","com.sun.enterprise.naming.SerialInitContextFactory");
+ env.put("java.naming.factory.url.pkgs","com.sun.enterprise.naming");
+ env.put("java.naming.provider.url","localhost:3700");
+ Context ctx = new InitialContext();
+
+ //System.out.println ("Trying to get the name of this context: " + ctx.getNameInNamespace());
+
+ System.out.println("Got initial context ... yeah ");
+
+ /*
+ * Get a reference to a bean instance, looked up by class name
+ */
+ NamingEnumeration ne = ctx.list("");
+ System.out.println("Got list... ");
+ while(ne.hasMore())
+ {
+ NameClassPair nc = (NameClassPair)ne.next();
+ System.out.println("Entry is ... "+nc.getName()+" -- "+nc.getClassName());
+ }
+
+ Hello hello = (Hello) ctx.lookup("examples.session.stateless.Hello");
+
+ /*
+ * Call the hello() method on the bean.
+ * We then print the result to the screen.
+ */
+ System.out.println(hello.hello());
+ }
+}
|
