Java Reference
In-Depth Information
Coding the EJB client
We are done with the configuration. We will finally proceed with adding a new Java class
com.packtpub.wflydevelopment.chapter3.client.TicketAgencyClient ,
which will communicate with the ticket booking machine's EJB application. This is shown
in the following code snippet:
public class TicketAgencyClient {
private static final Logger logger =
Logger.getLogger(TicketAgencyClient.class.getName());
public static void main(String[] args) throws Exception {
Logger.getLogger("org.jboss").setLevel(Level.SEVERE); [1]
Logger.getLogger("org.xnio").setLevel(Level.SEVERE);
new TicketAgencyClient().run();
}
private final Context context;
private TheatreInfoRemote theatreInfo;
private TheatreBookerRemote theatreBooker;
public TicketAgencyClient() throws NamingException {
final Properties jndiProperties = new Properties();
[2]
jndiProperties.setProperty(Context.URL_PKG_PREFIXES,
"org.jboss.ejb.client.naming");
this.context = new InitialContext(jndiProperties);
}
private enum Command { [3]
BOOK, LIST, MONEY, QUIT, INVALID;
public static Command parseCommand(String
stringCommand) {
try {
return
Search WWH ::




Custom Search