WA1104 J2EE Best Practices and Patterns with WebSphere V5
Course Outline |
|
| 1. Introduction |
|
- Java Web Application Architecture
- J2EE Architecture
- Web Application Programming Model – MVC
- Patterns
- Factory Method
- Singleton
- Command
- Modeling the Structure Aspect of Command Pattern
- Modeling the Behavior Aspect of Command Pattern
- Facade
- Adapter
- Proxy
- Publish-Subscribe
- Modeling the Structural Aspect of the Publish-Subscribe Pattern
- Modeling the Behavioral Aspect of the Publish-Subscribe Pattern
|
|
| 2. Presentation Tier Patterns |
|
- Why use the intercepting filter pattern?
- Uses for Filtering
- What is a filter?
- Features of filters
- The Filter interface
- How a filter works
- In what order?
- A simple logging filter
- Configuring the filter
- Mapping the filter
- The Web Deployment Descriptor
- Common filter tasks
- Request and Response Wrappers
- How Struts uses this design pattern?
- Front Controller Pattern
- Command and Controller Strategy
- Advantages of command and controller strategy
- How Struts uses this strategy?
- View Helper Pattern
- Use JavaBean as result bean helper
- Use custom tag for display logic written in Java
- Components of a Tag library
- JSTL Overview
- Use Access Beans as business delegates
- How Struts uses this pattern
- Problem
- Solution 1 – use jsp:include
- Solution 2 – use Struts templates
- Transform View Pattern
- The Music Collection Example – Sample XML file
- The Music Collection Example – Retrieving owner details
- The Music Collection Example – Retrieving the core data
- The Music Collection Example – Current Output
- Transformation with Java
- Reading an XML
- Transforming to HTML
- Transforming to System.out
|
|
| 3. Presentation Tier Design Considerations |
|
- HttpSession
- Why on the server?
- WebSphere V5 Session Management
- URL Rewriting
- Do not store large Object Graphs in HttpSession
- The problem
- The design pattern that fixes it
- A client side fix
- Struts implementation
- Typical validation rules
- Client-side validations
- Jakarta commons validation framework features
- Not resetting JavaBeans between requests
- Passing HttpServletRequest to business tier
- Best Practice 1: Dynamic caching
- Dynamic caching - continued
- Best Practice 2: Disable the HTTP access logs
- Best Practice 3: Tune the number of client threads
|
|
| 4. Business and Integration Tier Patterns |
|
- Business Delegate Pattern
- How it works
- Data Transfer Object Pattern
- DTO Example (Output)
- DTO Example (Input)
- Role of DTO in MVC
- Access Beans
- Types of Access Beans
- Data Class Access Bean
- Data Class Programming Model
- Access Bean Constructor
- Generating Access Beans
- Generating a Data Class
- Generating an EJB Factory
- Using EJB Factory and Data Class
- Deleting the Access Bean
- Value Object Pattern
- Multiple Value Objects
- Best Practice – derive EJB from the Value Object
- Composite Entity Pattern
- An example
- Class Diagram
- How the client interacts
- Value Object Assembler
- Value List Handler
- How does it work?
- Design Considerations
- Service Locator
- Data Access Object (DAO)
- DAO Implementation Guidelines
- Service Activator
- MDB- Integrating JMS and EJB
- Message-Driven Beans Are Different From Other EJBs
- Message-Driven Beans are Stateless
- Message-Driven Bean Interfaces
- Example: Message Counter
- Class MessageCounter
- Class MessageCounter
- Processing the Message
- Deployment Descriptor Entry
|
|
| 5. Business and Integration Tier Best Practices |
|
- Exception Handling
- Use java:comp to locate resources
- Use Container Authentication
- Use JDBC Connection Pooling
- Prepared Statement Cache
- Release JDBC Resources
- Optimize database first
- DB2 Tuning - MaxAppls
- DB2 Tuning - MaxAgents
- DB2 Tuning - Buffer Pool Tuning
- DB2 Tuning - Configuring buffpage
- DB2 Tuning - Evaluating the buffer pool size
- DB2 Tuning - Monitoring the database buffer pool
- DB2 Tuning - reorgchk
- Set CMP EJB Method Access Intent Carefully
- Class Loader
- Class Loader Hierarchy
- WebSphere Class Loaders
- WebSphere Class Loaders Hierarchy
- Class Loading Isolation Options
- Complete Isolation
- Medium Isolation
- Minimal Isolation
- Which option to use?
- Configuring the Class Loading Policy
- Configuring Application Server Policy
- Configuring Applications WAR Class Loader Policy
- Configuring the Options
- WSAD Project Structure
- Using log4j from an WebSphere application
- Using Log4J
- Example servlet using log4j
|
|
| 6. Other EJB Patterns |
|
- Session Façade
- Session Façade Pattern
- Session Façade
- Miscellaneous Details
- Message Façade Pattern
- Message Façade
- Message façade pattern shortcomings
- Version Number pattern
- Sequence Blocks
- Stored Procedures for Autogenerated Keys
- Fast Lane Pattern
|
| 7.
Transaction Management
|
|
- What is a transaction?
- ACID properties
- Transaction demarcation
- Resource managers
- Isolation levels
- WebSphere - Setting Isolation Level for EJB
- WebSphere - CMP EJB Access Intent
- WSAD - Setting Access Intent
- WSAD - Setting Data Source Isolation Level
- Basics
- Manage your own transactions
- Change isolation level
- EJB Transaction Basics
- Transaction Propagation
- Client Managed Transaction
- Bean Managed Transaction
- Container Managed Transaction
- Transaction Outcome
- Vetoing Transaction
- Let the container manage transactions
- CMT and the Session Façade
- CMT and other EJBs
- Transactions and Message Driven Beans
- Distributed transaction
- Two-phase commit
- Aborting a global transaction
- Optimizations
- Window of doubt
- JMS, EJB, XA
- Using XA-enabled data source
- Increase concurrency by reducing transaction isolation level
- Keep transactions short
- Multi-step wizard “the wrong way”
- What’s wrong?
- Multi-step wizard “the right way”
|
|
|
| 8. Performance |
|
- Overview
- Visitor, hit, user
- Load, throughput, response time
- Response time
- Effect of load on the system
- Saturation and buckle points
- Scaling
- Performance and scalability are different!
- Problem Areas
- CPU utilization
- Measure CPU utilization everywhere
- Symptoms of underutilization
- What causes underutilization?
- Network capacity problem?
- Synchronization problem?
- Slow external resource?
- Is the test pushing the system hard enough?
- Does your system scale?
- Symptoms of burstiness
- Infrequent synchronization problem?
- Test driver synchronization problem?
- Slow back-end systems?
- Slow garbage collection?
- Timeout problems?
- Erratic network traffic?
- Symptoms of overutilization
- The components of CPU usage
- High User CPU
- High System CPU
- High Wait CPU
- Server hanging
- Thread dump in WebSphere v5
- Thread dump file
- Uneven cluster loading
- Load balancer configured correctly?
- Plan of attack
- WebSphere routing mechanism
- WebSphere routing policies
- Overview
- What is WPT?
- Download and install
- record
- Configure your system to use record
- Record a session
- Output from record
- Details of running a stress test
- Best Practices
|
|
|
| 9. Messaging Tier Patterns |
|
- Java Message Service
- JMS Programming: Overview
- The JMS Interfaces
- JMS PTP Programming: Example
- JMS PTP Programming: Example
- One-to-one (Local)
- One-to-one (Remote)
- Request-Reply
- One-to-Many
- Many-to-one
- Many-to-one With Reply
- Many to Many
- Hub and Spoke
- Route to different queues based on message content
- Break a composite message and process separately
- Combine related messages to a single message
- Send Large Messages Using the Memento Pattern
|
|
|
| 10. Architecting Security |
|
- Security Functionality
- Challenge Mechanism
- Basic Challenge
- Client Certificates
- Form-based Authentication
- Form-based Authentication WebSphere
- Authentication Mechanism
- SWAM Authentication Mechanism
- LTPA Authentication Mechanism
- User Registry
- LDAP User Registry
- Custom User Registry
- HTTP Single Sign On (SSO
- J2EE Authorization Model
- WebSphere Authorization Model
- EJB Delegation Policies
- Delegation Scenario
- Form Based Logout
- Architecture Guidelines
|
|
|
| 11. Build and Deployment |
|
- What is Ant?
- Writing a Build Script
- How to run Ant?
- Using ant from WSAD
- Running Ant
- Advanced Task
- Automating Deployment
- Deployment Tasks
- Scripting Environment
- Central Scripting Objects
- Launching wsadmin
- JACL
- Scripting Patterns
- Examples
- Example Script
- Common Tasks for Applications
- Common Tasks for Applications
- Common Configuration Tasks
- Installing an Application
- What can I do?
- What next?
|
|
|
| 12. JUnit and WSAD |
|
- What is JUnit?
- Who uses JUnit?
- Why JUnit?
- The xUnit Philosophy
- A JUnit Test
- Running the tests
- Swing-based Test Runner
- JUnit Basics
- assertTrue
- assertEquals
- assertSame
- assertNull
- The failure message
- The Test Class
- The Test Method
- The Test Suite
- JUnit Design
- JUnit with Ant
- JUnit with WSAD
- Change JUnit version in WSAD
- Running Tests
- WSAD Test Runner Icons
- Rerun an individual test
- Debug with JUnit
- Testing Strategies
- Specific Techniques
- Testing simple Java classes
- Testing with databases
- Testing web applications
- Test-Driven Design
- Parting Thoughts
|
|
|
| 13. Struts Architecture and Overview |
|
- Review: MVC Model
- Review: Request, Session and Application
- What is Struts?
- Struts Flow
- Components in Struts
- The Model
- The View
- The Controller
- Struts Flow
- struts-config.xml
- struts-config.xml Content
- The data-sources element in the struts-config.xml
- The form-beans element in the struts-config.xml
- The global-forwards element in the struts-config.xml
- The action-mappings element in the struts-config.xml
- Sample struts-config.xml
- The Role of web.xml for the Application
- Configuring Struts in the web.xml
- web.xml Content
- Steps to Configuring Struts in the web.xml
- Step 1. Configuring the Action Servlet Instance in the web.xml
- Action Servlet Config Example
- Step 2. Configuring the Action Servlet Mapping in web.xml
- Prefix Mapping Example
- Extension Mapping Example
- Step 3. Configuring the Struts Tag Libraries in the web.xml
- Sample web.xml
|
|
|