
Head First EJB
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
More details
Other editions
Additional editions

Content
- Intro
- Table of Contents
- Intro: How to use this book
- Who is this book for?
- We know what you're thinking.
- And we know what your brain is thinking.
- Metacognition: thinking about thinking
- Here's what WE did:
- Here's what YOU can do to bend your brain into submission
- What you need for this book:
- Last-minute things you need to know:
- About the SCBCD exam
- Technical Reviewers
- Other people to credit:
- Chapter 1. Intro to EJB: Welcome to EJB.
- What is EJB all about?
- What does EJB really give me?
- No more vendor lock-in!
- How does it all work?
- Behind the scenes...
- Beans come in three flavors
- Session beans can be stateless or stateful
- Example: The Advice Guy bean
- Five things you do to build a bean:
- EJB Roles and Responsibilities
- Tutorial
- Organize your project directory
- Compile the two interfaces and the bean class
- Start the server
- You'll see something like this
- Start deploytool
- you'll see something like this
- Make a new Application
- Name and save the new application
- What you'll see after you create and name the application
- Now let's make the new enterprise bean (the ejb-jar and the DD)
- Now we're in the really cool New Enterprise Bean Wizard
- Create the new ejb-jar
- Add the three class files (including their package directory) to the JAR
- Confirm that you added ONLY the package directory and the class files
- Make it a Stateless Session bean
- Tell it which of the three class files in the JAR is the actual BEAN class
- Tell it which is the Home interface, and which is the Component interface
- Verif y everything on this screen!
- You're done, click Finish
- Meanwhile back on the main deploytool screen...
- Run your bean through the deploytool verifier
- Close your eyes and click OK
- Whew! No failed tests.
- Time to Deploy
- Make it Return a Client Jar
- Give it a name, so clients can look it up
- Watch the progress bars go up, then celebrate
- Now you'll see the AdviceApp inside the ser ver
- Now all we need is a client...
- Organizing your project directory for the client
- Chapter 2. Architectural Overview: EJB Architecture
- You remember this picture...
- Making a remote method call
- There's a "helper" on the ser ver as well...
- What must the Remote object and the stub have in common?
- The client calls business methods on the stub through the Remote business interface
- How EJB uses RMI
- The Remote object is not the bean, it's the bean's bodyguard-the EJBObject
- The Component interface
- Who writes the class that really DOES implement the component interface? In other words, who makes the EJBObject class?
- Who creates what?
- The bean Home
- Architectural over view: Session beans
- Architectural over view: Entity beans
- Architectural over view: Creating a Stateful Session bean
- Architectural over view: Creating a Stateless Session bean
- Who creates the stateless session bean, and when?
- Stateless session beans are more scalable
- Architectural over view: Message-driven beans
- What goes where?
- Organize your beans
- What goes where?
- Chapter 3. The Client View: Exposing Yourself
- What the client really wants
- It all starts with the home interface
- How a client uses a session bean: create, use, and remove
- Just when you thought a simple cast would be enough...
- But NO. You have to narrow the object as well!
- OK, I'll bite. Why can't you just do a plain old cast ?
- Writing the Remote home interface for a session bean
- Remote home interface examples for session beans
- But enough about the home... let's talk about the EJB object. The component interface. The thing you REALLY want.
- Imagine what else you might want to do with your EJB object reference...
- Thankfully, we've got handles
- isIdentical?
- A bean's client interfaces can be local
- Which methods make sense for the local client interfaces?
- When you think handle, think Remote Local clients don't need handles!
- Who needs EJBMetaData when you've got reflection?
- Do you need isIdentical() when there's equals() ?
- Why so many remove methods?
- Comparing Remote vs. Local interfaces
- Writing the local client interfaces
- You can have both a Remote and local client view for a bean, but you probably won't.
- Exceptions in client interfaces: what the client might get
- Local client code
- What has to change inside the bean class?
- Arguments to Remote vs. local methods
- Chapter 4. Session Bean Lifecycle: Being a Session Bean
- Exploring the session bean lifecycle
- You remember how it all works, right ?
- There's obviously more to the bean's lifecycle than just creation and business methods...
- Container Callbacks come from TWO places:
- Implementing the container callbacks
- Bean Creation: when an object becomes a bean
- Bean Use: what happens AFTER creation...
- Bean things you can do within business methods:
- Passivation: a stateful bean's chance at scalability...
- Your job for passivation: make your state passivatable!
- Bean things you can do in ejbActivate() and ejbPassivate()
- Bean Removal: when beans die
- Complaints about bean removal
- Bean things you can do in ejbRemove()
- Implementing the AdviceBean as a stateFUL bean
- AdviceStatefulBean code
- AdviceStatefulBean CLIENT code
- Deploying a stateful bean
- Compared to stateful beans, stateless beans have a simple life
- Bean things you can do from stateless bean methods
- Writing a Session Bean: your job as Bean Provider
- SessionContext: You need it more than it needs you
- Chapter 5. Entity Bean Intro: Entities are Persistent
- What's an entity bean?
- Entities vs. Entity Beans
- Entity beans from the client's point of view
- A very simple Customer entity bean
- An entity bean's client view
- Entity bean Remote component interface
- Entity bean Remote component interface
- Entity bean Remote home interface
- What does the client really want from an entity bean home ?
- Entity bean Remote home interface
- When finders have a dark side...
- Home business methods to the rescue
- Session bean create() vs. entity bean create()
- Session bean remove() vs. entity bean remove()
- Entity/bean/instance death
- Entity bean client view
- Chapter 6. Bean/Entity Synchronization: Being an Entity Bean
- The real power of entity beans is synchronization
- The only question is WHO does the work when it's time to synchronize
- Container-managed vs. bean-managed persistence
- A brief history on the evolution of CMP 2.0
- The EntityBean interface adds three new container callbacks (including two just for synchronization)
- Even the methods that are the same, don't behave the same
- But wait... there's more! Entity beans have new home container callbacks, too
- Writing a CMP entity bean: make it abstract
- You put three kinds of things in your bean class:
- PLUS... (ok, that's four things...)
- Virtual fields are NOT instance variables!
- Complete code for the CustomerBeanCMP class
- So how DID the client get a reference to the EJB object for #28?
- Bean things you can do during entity construction:
- Object identity: the primary key
- Bean things you can do during entity creation:
- Bean things you can do in home business methods
- Bean things you can do during activation and loading
- Bean things you can do during passivation and storing
- Chapter 7. Entity Relationships: When Beans Relate
- Beanifying your movie database
- But we don't want to think in TABLES. We want to think in CLASSES
- We need relationships between the Movie bean and the Director bean
- Why should the Director be a bean? Why can't it just be data?
- Relationships and multiplicit y
- Multiplicity in Bean Classes
- Multiplicity affects return type!
- Defining virtual fields for persistent data fields and relationship fields
- Defining your "abstract persistence schema" (virtual fields aren't enough)
- Persistent CMP fields in the DD
- Using relationships in your code
- Defining relationships in your abstract persistence schema (in the DD)
- The abstract schema is in the &entity& element and the &ejb-relation& is in the &relationships& element
- MovieBean code with a CMR field
- The MovieBean's home interface
- Mapping from abstract schema to a real database
- Writing your portable queries, for select and finder methods
- EJB-QL for the MovieBean
- Using an optional WHERE clause
- Navigating to another related bean
- Selecting a value rather than the whole bean
- EJB-QL SELECT
- EJB-QL SELECT - when to use Object ( )
- What does it MEAN to return an abstract schema type?
- SELECT and FROM are mandatory !
- Identifiers
- The WHERE clause
- The WHERE clause
- The problem with using Collection types
- Collections don't bark()!
- The IN operator lets you say "For an individual element IN the Collection..."
- The BETWEEN expression
- The other "IN"
- The IS EMPTY comparison expression
- The IS NOT EMPTY comparison expression
- The LIKE expression
- The NOT LIKE expression
- Relationship assignments
- If the multiplicit y of the relationship field is ONE, it's a MOVE If the multiplicit y is MANY, it's a COPY
- Chapter 8. Message-Driven Beans: Getting the Message
- Imagine this scenario...
- Too bad these guys aren't message-driven beans
- Message-driven bean class
- Writing a message-driven bean: your job as Bean Provider
- Notice something missing from the code?
- Topics and Queues
- Only ONE bean per pool gets a copy of a topic message
- With a queue, only one bean gets the message. Period.
- MessageDrivenContext
- What if something goes wrong?
- Message acknowledgement
- That's all well and good, but let's go back and see how our earlier scenario ended...
- Think about it.
- Chapter 9. EJB Transactions: The Atomic Age
- The ACID test
- Distributed transactions: two-phase commit
- How it works in EJB
- Some transactions don't propagate
- How do I make (or get) a transaction?
- Transaction-related methods are in two interfaces
- Making a BMT transaction
- Call stack of the checkOut() method
- Things you must NOT do with BMT
- BMT transactions are one way: they can propagate out to a CMT bean, but no other transaction can propagate in to a BMT bean
- What does it mean to suspend a transaction?
- The UserTransaction interface
- setRollbackOnly( )
- setRollbackOnly() lives in TWO interfaces
- getRollbackOnly( )
- BMT beans use getStatus() instead of getRollbackOnly()
- BMT can be a really BAD idea. BMT hurts bean reuse
- Container-managed transactions
- How attributes work
- Know your attributes
- These are the methods you MUST mark with an attribute (for a CMT bean)
- "Unspecified Transaction Context"
- Burn these in
- Marking transactions in the DD
- DD example for CMT
- More DD examples for CMT
- Summary of Bean-managed demarcation
- Entity beans have ejbLoad() to stay synchronized, even if the transaction rolls back.
- Session Synchronization
- SessionSynchronization "special moments"
- Chapter 10. Exceptions in EJB: When beans go bad
- What can go wrong?
- Remember, Java exceptions can be checked or unchecked
- It's all about expectations...
- In EJB, exceptions come in two flavors: application and system
- With an Application Exception, the Container will...
- With a System Exception, the Container will...
- Warning! RemoteException is checked, but not expected!
- RemoteException goes to remote clients EJBException goes to local clients
- Bean Provider's responsibilities
- The Container's responsibilities
- The five standard EJB application exceptions
- The five standard application exceptions from the client's point of view
- Common system exceptions
- Scenarios: what do you think happens?
- Scenario Summary
- Chapter 11. Security in EJB: Protect Your Secrets.
- Imagine you're writing a payroll application...
- What can you do?
- How to do securit y in EJB
- The Application Assembler's job: access control
- Defining the roles
- Defining the roles... a better way
- Defining the method permissions
- The Deployer's job: mapping actual humans to abstract roles
- Principals and Roles, Users and Groups
- Class-level vs. instance-level security
- Using programmatic security to custom-tailor a method
- The problem with isCallerInRole()...
- Use &run-as& security identity to pretend someone else is calling...
- Security context propagation with &run-as&
- Chapter 12. A Bean's Environment: The Joy of Deployment
- A bean's special place- java:comp/env
- But it's not per bean instance... It's per bean home
- It's simple...
- Bean Provider and Application Assembler responsibility for the Deployment Descriptor
- Deployer responsibility for the Deployment Descriptor
- Remembering who does what
- Now let's look at the bean's runtime environment
- Which APIs does EJB 2.0 guarantee?
- What MUST be in an ejb-jar?
- Programming restrictions
- Appendix A: Final Mock Exam
- Master Mock Exam Answers
- This isn't goodbye
- Index
- Symbols
- A
- B
- C
- D
- E
- F
- G
- H
- I
- J
- L
- M
- N
- O
- P
- Q
- R
- S
- T
- U
- V
- W
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.