blob: 29ebd03703c5812aa22799beec8e9f6324763939 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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());
}
}
|