Java Reference
In-Depth Information
ticket-agency-ejb//TheatreInfo!com.packtpub.wflydevelopment.chapter3.boundary.TheatreInfoRemote");
}
private TheatreBookerRemote lookupTheatreBookerEJB()
throws NamingException {
return (TheatreBookerRemote) context.lookup("ejb:/
ticket-agency-ejb//TheatreBooker!com.packtpub.wflydevelopment.chapter3.boundary.TheatreBookerRemote?stateful");
}
private void showWelcomeMessage() {
System.out.println("Theatre booking system");
System.out.println("=====================================");
System.out.println("Commands: book, list,money,
quit");
}
}
Let's see the most interesting points. First, in the main function, we set some logging rules
[1]
in order to avoid mixing the JBoss remoting log messages with the console applica-
tion information.
Next, we create the
TicketAgencyClient
object and execute its
run
method. Dur-
ing object creation, we prepare the
InitialContext
object (further used to lookup re-
mote objects). To do this, we will need a set of
[2]
properties, which specify what type
of
ejb-client
is used.
In
[3]
, we define a
Command
enum, which represents console commands that users can
send to this application. The
run()
method first performs the lookup of the SLSB and
SFSB (
[4]
and
[5]
) remote EJBs, and then shows the welcome message (
[6]
). In the
infinite loop, we wait for the user to enter a command and parse it (
[7]
). Depending on
the user's choice we can book a seat, list seats' information, get available money, or quit
the application.
Adding the EJB client configuration
As you can see from the preceding code snippet, there is no indication about the location
of the server where the EJBs are running. It is possible to specify this by code, but in this