blob: 5762ab0b9cb8ce86ea362503bccb9cb37a43db16 (
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
36
|
package examples.stateless.client;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import examples.stateless.interfaces.PricerInjection;
import examples.stateless.interfaces.PricerLookup;
public class PricerClient {
public static void main(String[] args) {
try {
InitialContext ic = new InitialContext();
// Prefixing the name with the pound sign (#) is a convention of Glassfish
// when using multiple interfaces to make up the business interface. The
// specification is unclear on how clients should lookup beans that implement
// more than one interface.
PricerLookup pricerLookup = (PricerLookup)ic.lookup("#"+PricerLookup.class.getName());
PricerInjection pricerInjection = (PricerInjection)ic.lookup("#"+PricerInjection.class.getName());
//PricerLookup pricerLookup = (PricerLookup)ic.lookup(PricerLookup.class.getName());
//PricerInjection pricerInjection = (PricerInjection)ic.lookup(PricerInjection.class.getName());
//Pricer pricerLookup = (Pricer)ic.lookup(Pricer.class.getName());
//Pricer pricerInjection = pricerLookup;
System.out.println("Tax (using lookup) on: 8.5 for State: ny is: "+
pricerLookup.getTaxLookup(8.5,"ny"));
System.out.println("Tax (using injection) on: 8.5 for State: ny is: "+
pricerInjection.getTaxInjection(8.5,"ny"));
}
catch (NamingException e) {
e.printStackTrace();
}
}
}
|