Example: The Advice Guy bean

Before we get into the guts of EJB, let’s look at how to develop, deploy, and test a bean from start to finish. If you’re not already familiar with EJB, you won’t understand everything here. Don’t worry about it now; we’ll figure it all out in later chapters. This is just to give you a feeling for what it’s like to get a bean up and running.

Our first bean is for the Advice Guy service—a remote service that gives back an advice String each time the client makes a request. We’ll spend the next several pages looking at the process, and then we’ll actually make this bean, as a tutorial.

image with no caption

The Advice Guy[1]

Our first bean is for the Advice Guy service. Each time the client makes a request, the Advice Guy service (an enterprise javabean) gives back a piece of stunningly helpful (and preternaturally appropriate) advice.



[1] In Head First Java, we deployed the Advice Guy service using straight TCP sockets. Now, for only five times the amount of code and effort, we get to have the same service in EJB. Of course, if one felt like it, one could argue that the Advice Guy doesn’t really need all those EJB services, but we disagree. We’re already planning the IPO for this baby.

Get Head First EJB now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.