Books & Videos

Table of Contents

  1. Chapter 1 Intro to EJB: Welcome to EJB

    1. What is EJB all about?

    2. What does EJB really give me?

    3. No more vendor lock-in!

    4. How does it all work?

    5. Behind the scenes...

    6. Beans come in three flavors

    7. Session beans can be stateless or stateful

    8. Example: The Advice Guy bean

    9. Five things you do to build a bean:

    10. EJB Roles and Responsibilities

    11. Tutorial:

    12. Organize your project directory

    13. Compile the two interfaces and the bean class

    14. Start the server

    15. You’ll see something like this

    16. Start deploytool

    17. you’ll see something like this

    18. Make a new Application

    19. Name and save the new application

    20. What you’ll see after you create and name the application

    21. Now let’s make the new enterprise bean (the ejb-jar and the DD)

    22. Now we’re in the really cool New Enterprise Bean Wizard

    23. Create the new ejb-jar

    24. Add the three class files (including their package directory) to the JAR

    25. Confirm that you added ONLY the package directory and the class files

    26. Make it a Stateless Session bean

    27. Tell it which of the three class files in the JAR is the actual BEAN class

    28. Tell it which is the Home interface, and which is the Component interface

    29. Verify everything on this screen!

    30. You’re done, click Finish

    31. Meanwhile back on the main deploytool screen...

    32. Run your bean through the deploytool verifier

    33. Close your eyes and click OK

    34. Whew! No failed tests

    35. Time to Deploy

    36. Make it Return a Client Jar

    37. Give it a name, so clients can look it Up

    38. Watch the progress bars go up, then celebrate

    39. Now you’ll see the AdviceApp inside the server

    40. Now all we need is a client...

    41. Organizing your project directory for the client

    42. Coffee Cram: Mock Exam

    43. Coffee Cram: Mock Exam Answers

  2. Chapter 2 Architectural Overview: EJB Architecture

    1. You remember this picture...

    2. Making a remote method call

    3. There’s a “helper” on the server as well...

    4. What about arguments and return values?

    5. What really gets passed when you pass an object to a remote method?

    6. Passing a Remote object through a remote method call

    7. What must the Remote object and the stub have in common?

    8. The client calls business methods on the stub through the Remote business interface

    9. How EJB uses RMI

    10. The Remote object is not the bean, it’s the bean’s bodyguard—the EJBObject

    11. The Component interface

    12. Who writes the class that really DOES implement the component interface? In other words, who makes the EJBObject class?

    13. Who creates what?

    14. The bean Home

    15. Architectural overview: Session beans

    16. Architectural overview: Entity beans

    17. Architectural overview: Creating a Stateful Session bean

    18. Architectural overview: Creating a Stateless Session bean

    19. Who creates the stateless session bean, and when?

    20. Stateless session beans are more scalable

    21. Architectural overview: Message-driven beans

  3. Chapter 3 The Client View: Exposing Yourself

    1. What the client really wants

    2. It all starts with the home interface

    3. How a client uses a session bean: create, use, and remove

    4. But first, we have to get a home interface reference

    5. Let’s take another look at the complete client code

    6. Just when you thought a simple cast would be enough...

    7. But NO. You have to narrow the object as well!

    8. OK, I’ll bite. Why can’t you just do a plain old cast?

    9. PortableRemoteObject.narrow()

    10. Writing the Remote home interface for a session bean

    11. Remote home interface examples for session beans

    12. But enough about the home... let’s talk about the EJB object. The component interface. The thing you REALLY want.

    13. Imagine what else you might want to do with your EJB object reference...

    14. Thankfully, we’ve got handles

    15. isIdentical?

    16. A bean’s client interfaces can be local

    17. Which methods make sense for the local client interfaces?

    18. When you think handle, think Remote

    19. Who needs EJBMetaData when you’ve got reflection?

    20. Do you need isIdentical() when there’s equals()?

    21. Why so many remove methods?

    22. Comparing Remote vs. Local interfaces

    23. Writing the local client interfaces

    24. You can have both a Remote and local client view for a bean, but you probably won’t.

    25. Exceptions in client interfaces: what the client might get

    26. Local client code

    27. What has to change inside the bean class?

    28. Arguments to Remote vs. local methods

    29. Coffee Cram: Mock Exam

    30. Coffee Cram: Mock Exam Answers

  4. Chapter 4 Session Bean Lifecycle: Being a Session Bean

    1. Exploring the session bean lifecycle

    2. You remember how it all works, right?

    3. There’s obviously more to the bean’s lifecycle than just creation and business methods...

    4. Container Callbacks, for the special moments in a bean’s life...

    5. Container Callbacks come from TWO places

    6. Implementing the container callbacks

    7. We have to look at the transitions

    8. Bean Creation: when an object becomes a bean

    9. Bean things you can do during creation

    10. Bean Use: what happens AFTER creation...

    11. Bean things you can do within business methods

    12. Passivation: a stateful bean’s chance at scalability...

    13. Your job for passivation: make your state passivatable!

    14. Bean things you can do in ejbActivate() and ejbPassivate()

    15. Bean Removal: when beans die

    16. Complaints about bean removal

    17. Bean things you can do in ejbRemove()

    18. Implementing the AdviceBean as a stateFUL bean

    19. AdviceStatefulBean code

    20. AdviceStatefulBean CLIENT code

    21. Deploying a stateful bean

    22. Compared to stateful beans, stateless beans have a simple life

    23. Bean things you can do from stateless bean methods

    24. Writing a Session Bean: your job as Bean Provider

    25. SessionContext

    26. Coffee Cram: Mock Exam

    27. Coffee Cram: Mock Exam Answers

  5. Chapter 5 Entity Bean Intro: Entities are Persistent

    1. What’s an entity bean?

    2. Entities vs. Entity Beans

    3. Entity beans from the client’s point of view

    4. A very simple Customer entity bean

    5. An entity bean’s client view

    6. Entity bean Remote component interface

    7. Entity bean Remote component interface

    8. Entity bean Remote home interface

    9. What does the client really want from an entity bean home?

    10. Entity bean Remote home interface

    11. When finders have a dark side...

    12. Home business methods to the rescue

    13. Session bean create() vs. entity bean create()

    14. Session bean remove() vs. entity bean remove()

    15. Entity/bean/instance death

    16. Entity bean client view

    17. Coffee Cram: Mock Exam

    18. Coffee Cram: Mock Exam Answers

  6. Chapter 6 Bean/Entity Synchronization: Being an Entity Bean

    1. The real power of entity beans is synchronization

    2. The only question is WHO does the work when it’s time to synchronize

    3. Container-managed vs. bean-managed persistence

    4. A brief history on the evolution of CMP 2.0

    5. The EntityBean interface adds three new container callbacks (including two just for synchronization)

    6. Even the methods that are the same, don’t behave the same

    7. But wait... there’s more! Entity beans have new home container callbacks, too

    8. Writing a CMP entity bean: make it abstract

    9. You put three kinds of things in your bean class:

    10. PLUS... (ok, that’s four things...)

    11. Virtual fields are NOT instance variables!

    12. Complete code for the CustomerBeanCMP class

    13. So how DID the client get a reference to the EJB object for #28?

    14. Bean things you can do during entity construction:

    15. Object identity: the primary key

    16. Bean things you can do during entity creation:

    17. Bean things you can do in home business methods

    18. Bean things you can do during activation and loading

    19. Bean things you can do during passivation and storing

    20. Coffee Cram: Mock Exam

    21. Coffee Cram: Mock Exam Answers

  7. Chapter 7 Entity Relationships: When Beans Relate

    1. Beanifying your movie database

    2. But we don’t want to think in TABLES We want to think in CLASSES

    3. We need relationships between the Movie bean and the Director bean

    4. Why should the Director be a bean? Why can’t it just be data?

    5. Relationships and multiplicity

    6. Multiplicity in Bean Classes

    7. Multiplicity affects return type!

    8. Defining virtual fields for persistent data fields and relationship fields

    9. Defining your “abstract persistence schema” (virtual fields aren’t enough)

    10. Persistent CMP fields in the DD

    11. Using relationships in your code

    12. Defining relationships in your abstract persistence schema (in the DD)

    13. Mapping from abstract schema to a real database

    14. Coffee Cram: Mock Exam

    15. Coffee Cram: Mock Exam Answers

  8. Chapter 8 Message-Driven Beans: Getting the Message

    1. Imagine this scenario...

    2. Too bad these guys aren’t message-driven beans

    3. Message-driven bean class

    4. Writing a message-driven bean: your job as Bean Provider

    5. Notice something missing from the code?

    6. Topics and Queues

    7. Only ONE bean per pool gets a copy of a topic message

    8. With a queue, only one bean gets the message. Period.

    9. MessageDrivenContext

    10. MessageDrivenContext

    11. What if something goes wrong?

    12. Message acknowledgement

    13. That’s all well and good, but let’s go back and see how our earlier scenario ended...

    14. Think about it.

    15. Coffee Cram: Mock Exam

    16. Coffee Cram: Mock Exam Answers

  9. Chapter 9 EJB Transactions: The Atomic Age

    1. The ACID test

    2. Distributed transactions: two-phase commit

    3. How it works in EJB

    4. Some transactions don’t propagate

    5. How do I make (or get) a transaction?

    6. Transaction-related methods are in two interfaces

    7. Making a BMT transaction

    8. Call stack of the checkOut() method

    9. Things you must NOT do with BMT

    10. What does it mean to suspend a transaction?

    11. The UserTransaction interface

    12. setRollbackOnly()

    13. setRollbackOnly() lives in TWO interfaces

    14. getRollbackOnly()

    15. BMT beans use getStatus() instead of getRollbackOnly()

    16. BMT can be a really BAD idea. BMT hurts bean reuse

    17. Container-managed transactions

    18. How attributes work

    19. Transaction attributes that require a transaction

    20. Transaction attributes that do not require a transaction

    21. These are the methods you MUST mark with an attribute (for a CMT bean)

    22. “Unspecified Transaction Context”

    23. Burn these in

    24. Marking transactions in the DD

    25. DD example for CMT

    26. More DD examples for CMT

    27. Summary of Bean-managed demarcation

    28. Entity beans have ejbLoad() to stay synchronized, even if the transaction rolls back.

    29. Session Synchronization

    30. SessionSynchronization “special moments”

    31. Coffee Cram: Mock Exam

    32. Coffee Cram: Mock Exam Answers

  10. Chapter 10 Exceptions in EJB: When beans go bad

    1. What can go wrong?

    2. Remember, Java exceptions can be checked or unchecked

    3. It’s all about expectations...

    4. In EJB, exceptions come in two flavors: application and system

    5. With an Application Exception, the Container will...

    6. With a System Exception, the Container will...

    7. Warning! RemoteException is checked, but not expected!

    8. RemoteException goes to remote clients EJBException goes to local clients

    9. Bean Provider’s responsibilities

    10. The Container’s responsibilities

    11. The five standard EJB application exceptions

    12. The five standard application exceptions from the client’s point of view

    13. Common system exceptions

    14. Common system exceptions

    15. Scenarios: what do you think happens?

    16. Scenario Summary

    17. Coffee Cram: Mock Exam

    18. Coffee Cram: Mock Exam Answers

  11. Chapter 11 Security in EJB: Protect Your Secrets

    1. Imagine you’re writing a payroll application...

    2. What can you do?

    3. How to do security in EJB

    4. The Application Assembler’s job: access control

    5. Defining the roles

    6. Defining the roles... a better way

    7. Defining the method permissions

    8. Defining the method permissions

    9. Method permissions interact with one another as a union!

    10. Watch out for <unchecked/>

    11. The Deployer’s job: mapping actual humans to abstract roles

    12. Principals and Roles, Users and Groups

    13. Class-level vs. instance-level security

    14. Using programmatic security to custom-tailor a method

    15. The problem with isCallerInRole()...

    16. Map declarative security roles to the programmer’s hard-coded (fake) roles

    17. Use <run-as> security identity to pretend someone else is calling...

    18. Security context propagation with <run-as>

    19. Coffee Cram: Mock Exam

    20. Coffee Cram: Mock Exam Answers

  12. Chapter 12 A Bean’s Environment: The Joy of Deployment

    1. A bean’s special place- java:comp/env

    2. But it’s not per bean instance... It’s per bean home

    3. It’s simple... if the programmer puts a made-up JNDI name in code, he has to announce that to the deployer in the DD.

    4. Bean Provider and Application Assembler responsibility for the Deployment Descriptor

    5. Deployer responsibility for the Deployment Descriptor

    6. Remembering who does what

    7. Now let’s look at the bean’s runtime environment

    8. Which APIs does EJB 2.0 guarantee?

    9. What MUST be in an ejb-jar?

    10. Structure of an ejb-jar

    11. Programming restrictions

    12. Coffee Cram: Mock Exam

    13. Coffee Cram: Mock Exam Answers

  1. Appendix Final Mock Exam

    1. Coffee Cram

    2. Coffee Cram: Master Mock Exam

    3. Coffee Cram: Master Mock Exam Answers

    4. This isn’t goodbye

    5. Cover Rough Drafts for the series

  2. Appendix Interface summary