13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

474Chapter 21Introducti<strong>on</strong> to Enterprise JavaBeansThat c<strong>on</strong>fessed, we still think our example is the best way to address ourtopic. Why? Because EJBs are a large topic, worthy of several books (and weencourage you to read some of them, such as Enterprise JavaBeans Comp<strong>on</strong>entArchitecture by Gail Anders<strong>on</strong> and Paul Anders<strong>on</strong> (ISBN 0-13-035571-2). Wesimply cannot teach you all about EJBs in our book. Our goal here is to introducethe c<strong>on</strong>cepts, provide a working example, and explain how to deploy andmaintain an EJB system <strong>on</strong> <strong>Linux</strong> using JBoss. Believe us, we’ll have enoughto cover to achieve that modest goal.21.2.1 EJB C<strong>on</strong>ceptsIn a way, the use of the term Enterprise JavaBean, with its echo of the olderterm JavaBean, is unfortunate. Apart from the similar intenti<strong>on</strong> of creatingreusable comp<strong>on</strong>ents, the two technologies have little in comm<strong>on</strong>.21.2.1.1 The Life Cycle of an Enterprise JavaBeanMost of the books <strong>on</strong> EJBs that we have seen start with the simplest type ofbean and work their way up in complexity. We’re going to dare to be different,because the most complex case isn’t that hard, and <strong>on</strong>ce you understand it, thefuncti<strong>on</strong>s of all the other types of EJBs become obvious. They simply d<strong>on</strong>’timplement what they do not need.For the moment, assume that an EJB is a simple class that provides a setof methods to clients. The methods represent business functi<strong>on</strong>s that clientswant the server to carry out.Implementing an Enterprise JavaBean requires implementing three Javasource files:• An object that represents the bean implementati<strong>on</strong>• An interface called the home interface that represents the interface betweenthe bean and the EJB c<strong>on</strong>tainer• An interface called the remote interface which represents the methods thata client may call <strong>on</strong> the beanWe’ll get into the details of these interfaces (and the sometimes obtusereas<strong>on</strong>s behind) a little later <strong>on</strong>. For now, we will c<strong>on</strong>centrate <strong>on</strong> theimplementati<strong>on</strong>.The implementati<strong>on</strong> class c<strong>on</strong>tains methods that are there <strong>on</strong>ly to allowthe c<strong>on</strong>tainer to c<strong>on</strong>trol the bean and to inform the bean of impending changes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!