uncoupling java applications o’reilly conference on java brett mclaughlin
TRANSCRIPT
![Page 1: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/1.jpg)
Uncoupling Java Applications
O’Reilly Conference on JavaBrett McLaughlin
![Page 2: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/2.jpg)
Roadmap – the Meat Introduction Engines User Store Validators Actions Screens
![Page 3: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/3.jpg)
Introduction
JSP + Servlets + EJB + XML + JDBC + JNDI = !@$!%
![Page 4: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/4.jpg)
Hype, Hype, and More Hype
When do I use JDBC and when do I use EJB?Does JSP truly provide a separation of content and logic?Is XML right for my application?One engine? Two engines? (Red engine? Blue engine?)
Am I asking the right Questions?
The Grab Bag of APIs The “Use It or Lost It” Mentality Your Responsibility
![Page 5: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/5.jpg)
All the Abbreviations != Solid Application
The truth about: JSP XML (XSL, XSLT, XSP, and all the rest…) JDBC EJB
You dictate technology; Technology does not dictate you! Management doesn’t know or care about how “cool” your use of
technology is.
![Page 6: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/6.jpg)
Management, Maintenance, and Modularity
Management: Delivery Focused Maintenance: Stability Focused Modularity: A Marriage of the Two
Maintenance Management
Functionality “Graph”Less More
![Page 7: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/7.jpg)
Engines
Request Engine Response
![Page 8: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/8.jpg)
Building a Generic Engine HTTP and the Request/Response Model The Servlet API
Abstracts Details of Network Communication Access to Session Variables and Objects Responsiveness to a Variety of Responses
Easy Interface with other Java Specifications (EJB, JDBC, RMI) Why JSP Doesn’t Work
![Page 9: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/9.jpg)
Using a Central Controller Single Point for all Requests Request Parameters and POST
Disguises Request Information Allows use of Hidden Fields and Variables Additional Security Mechanism
Provides Continuity in Application Requests Request generates Response, which generates Request… and on…
![Page 10: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/10.jpg)
User Store
userData = UserData(req);
userData.setParam(“myParam”, myValue);
...
userData.clearVolatile();
![Page 11: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/11.jpg)
A Flexible Data “Connector”
How to handle data across contractual objects Code Tying Objects Together (tight coupling) Specific Object Types for Specific Implementations (semi-tight
coupling) Generic Data “Connector” Across All Implementations (loose
coupling) Also Adds Persistence of Data Across Requests
![Page 12: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/12.jpg)
Loading at Request Time The User Store is Always Created/Loaded
Load From the Session, Update from the Request Create from the Request
Request Parameters Available No Differentiation Between Original and Added Request Parameters Generic Object Allows Generic Contracts Results in Logical Groupings, Not Code-Based Ones.
![Page 13: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/13.jpg)
Storing at Response Time The User Store is Always Stored
Purge Request and Volatile Data Store in the Session Object
Allows Process Lifecycle Continuity Preserves Persistent Data
Authentication Credentials Application Preferences Complex Derived Data Remote References (Persistence Load-Balancing)
![Page 14: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/14.jpg)
Validators
<field name=“firstName” type=“text”>
<minLength>4</minLength>
<maxLength>20</maxLength>
</field>
![Page 15: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/15.jpg)
Balancing the Teeter Totter
Coarse Grained Validation (+) Allows Generic Interfaces and Implementations (-) Never Provides Sufficient Validation for Business Rules
Fine Grained Validation (+) Very Specific and Ensures Correct Business Information is Present (-) Requires Specific Implementation for Every Possible Request
![Page 16: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/16.jpg)
Coarse Grained Validation Configuration File Based
Properties Files, ala Java Hierarchical Files, ala XML
Single Implementation Set Handles All Requests Provides “first-run” Error and Mistake Catching Allows Short-Circuit of Complex Business Logic if General Rules Not
Followed
![Page 17: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/17.jpg)
Fine-Grained Validation Code Based
Sometimes Within Java Code Sometimes Within Configuration Files
Tied to a Specific Business Process (Action) 1:1 Mapping Between Implementation and Task
Provides Complex Error Handling Business Logic Inherent to Process, so no Short-Circuiting Occurs
![Page 18: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/18.jpg)
Actions
action = ActionLoader.getInstance().load(actionName);
action.init(userData);
action.execute();
![Page 19: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/19.jpg)
What are Actions? Contract Based Request Handlers Business Logic Assemblers
Do Not Replace EJB, JDBC, etc. Do Replace Spaghetti Code
Abstraction of Interface to Business Components Engine has no Information about Communication Mechanisms (JNDI, RMI, etc.) Logic Changes without Engine Calls Changing
![Page 20: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/20.jpg)
Use of Actions Loading
Generic Loader from Action Name Name Action Mapping in Files or Database
Initializing One Application Engine always uses Same Initializing Object Type (UserData) Isolates Execution from Application Logic
Execution Return Result Based on Application Logic, not Business Logic Loads any Screen-relevant Information to UserData
![Page 21: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/21.jpg)
Screens
screen = ScreenLoader.getInstance().load(screenName);
screen.init(userData);
screen.output();
![Page 22: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/22.jpg)
What are Screens? Contract Based Response Handlers Display Logic Assemblers
Do Not Replace XML, HTML, etc. Do Replace Hard-Coded Markup Language
Abstraction of Interface to Visual Components Engine has no Information about Markup Language(s) (HTML, XML, WML, etc.) Output Changes without Engine Calls Changing
![Page 23: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/23.jpg)
Use of Screens Loading
Generic Loader from Screen Name Name Action Mapping in Files or Database
Initializing One Application Engine always uses Same Initializing Object Type (UserData) Isolates Output from Application Logic
Display/Output Return Based on Use of Output (e.g. Cocoon) Retrieves Needed Information from UserData
![Page 24: Uncoupling Java Applications O’Reilly Conference on Java Brett McLaughlin](https://reader034.vdocuments.site/reader034/viewer/2022051314/551a77f9550346761a8b4c42/html5/thumbnails/24.jpg)
Q & A