summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/HelloClient.java
diff options
context:
space:
mode:
Diffstat (limited to 'Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/HelloClient.java')
-rw-r--r--Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/HelloClient.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/HelloClient.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/HelloClient.java
new file mode 100644
index 0000000..29ebd03
--- /dev/null
+++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/HelloClient.java
@@ -0,0 +1,35 @@
+package examples.session.stateless;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+/**
+ * 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.
+ */
+ Context ctx = new InitialContext(System.getProperties());
+
+ /*
+ * Get a reference to a bean instance, looked up by class name
+ */
+ Hello hello = (Hello) ctx.lookup(Hello.class.getName());
+
+ /*
+ * Call the hello() method on the bean.
+ * We then print the result to the screen.
+ */
+ System.out.println(hello.hello());
+
+ }
+}