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.

502Chapter 22Building an EJBIf you are using Ant (and why wouldn’t you be?) you will need to put thepath to the J2EE JAR in the classpath which Ant uses. Since Ant can define itsown classpath, you may want to define your compile task as something like this:Now it’s a simple matter to compile. The basic Java compile command:$ javac com/jadol/budgetpro/*.javawill compile all the various classes and interfaces that make up the EJB. Theremay be other classes in your source tree that need to be compiled as well. Withall that going <strong>on</strong>, you can see why so many people use Ant. With the compiletarget defined as in our example above, you would need <strong>on</strong>ly the command:$ ant compile22.3REVIEWThere are many pieces involved in the c<strong>on</strong>structi<strong>on</strong> of an EJB. Besides writingthe sessi<strong>on</strong> bean implementati<strong>on</strong>, there are the remote and home interfaces tobe written. The local and local home interfaces are opti<strong>on</strong>al, but useful, especiallyin cases where arguments cannot be serialized or where you know thatthe beans and the client will reside <strong>on</strong> the same host. Compiling an EJB is notdifferent from any other Java compile, but it requires a special JAR in yourclasspath, <strong>on</strong>e that c<strong>on</strong>tains the definiti<strong>on</strong>s of the J2EE objects and interfaces.22.4WHAT YOU STILL DON’T KNOWWe still haven’t shown you how to deploy the EJB, now that you have <strong>on</strong>ecompiled. In the next chapter we’ll show you how to assemble the pieces of theEJB into an Enterprise Archive and then deploy and run it.More importantly, though, we haven’t covered how to write the code forstateful sessi<strong>on</strong> beans or entity beans. Stateful sessi<strong>on</strong> beans are <strong>on</strong>e-to-a-clientsessi<strong>on</strong>,rather than taking all comers, so there is a little more to code, and a

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

Saved successfully!

Ooh no, something went wrong!