160 likes | 270 Views
EJB Concerns and AOP. by Neeraj Sangal. Motivation. Learn Aspect Oriented Programming and see how it can be applied to current problems. Aspect Oriented Programming. Language mechanisms to deal with cross cutting concerns
E N D
EJB Concerns and AOP by Neeraj Sangal
Motivation • Learn Aspect Oriented Programming and see how it can be applied to current problems
Aspect Oriented Programming • Language mechanisms to deal with cross cutting concerns • The hard question for me – which concerns are best expressed as “aspects”
Java – assert facility • assert ‘boolean-condition’ • Language mechanism uses assert keyword • Verify integrity of program structures • Test pre and post conditions to methods • AOP helpful in many cases not all
EJB Model • Component architecture for web based applications
Types of EJBs • Session • Stateless/Stateful • Entity • Bean Managed/Container Managed • Message Based
AOP and EJBs • Two approaches to think about • How can the EJB operating environment benefit from AOP? • How can EJB implementers benefit from AOP? • This talk will examine the first approach • This talk won’t answer either question (sorry!)
Using EJBs • Client View • Component View
EJB Concerns • Database connection pooling • Persistence – automatic and programmer controlled • Transaction management • Security • Management of multiple instances of multiple components
Working Set Management • Callback methods: • ejbActivate() • ejbPassivate() • Serializes current state using standard java methods
Security • Define roles • Define which roles are allowed to access an ejb’s methods • What is the best way to implement this?
Container Managed Transactions • The bean developer does not have to worry about transactions (is it true?) • Callbacks • afterBegin() • beforeCompletion() • afterCompletion()
EntityBean • Each entity bean represents a row of data in a table • Two types • Bean Managed Persistence • Container Managed Persistence
Home Interface Methods • Create Methods • Find Methods
Managing Bean Instances • Callbacks • ejbActivate() • ejbPassivate() • ejbLoad() • ejbStore()
Deployment Descriptor • Deployer’s responsibility – relatively independent of Bean Developer • Based on XML • Example of method permission