Lecture 1.11 Developing the Tools Montreal 2004 Introduction to J2EE Development John J. Salama
Lecture 1.12 Today’s Talk Introduction Server Centric Applications Tiered Application Design Design Patterns Introduction to Development Practices Resources
Lecture 1.13 INTRODUCTION
Lecture 1.14 Prerequisites Java –Objects and classes –Fundamental types –Arrays –Decisions (conditional statements) –Iteration (iterative statements) –Interfaces and polymorphism –Inheritance
Lecture 1.15 What We’re Working Towards
Lecture 1.16 Web Servers A machine connected to a network (usually the Internet) Has web server software installed. i.e. Apache, IIS, WebSphere, Tomcat, SUN One Has web sites/web applications associated with the web server
Lecture 1.17 How Web Servers And Clients Talk “ is the protocol and indicates the default port (in this case 80) the browser should connect to. This can be overridden by ‘:port number’ “ is the server name and is translated by a name server to an IP address. The IP address is used to connect to the server “tools.php” is the resource and specifies what should be sent back from the server The HTML document sent back is interpreted by your web browser and displayed URL:
Lecture 1.18 Client Side Programming Code written that is interpreted by the client only Server does not process document Example languages include HTML, JavaScript, CSS
Lecture 1.19 Server Side Programming Code written that is processed by the server prior to interpretation by the client Example languages include JSP/J2EE, ASP, PHP Common Gateway Interface (CGI) provides a means for a program written in any language to dynamically produce HTML
Lecture A Few Flavours of Java J2SE –Standard Edition –Base language J2EE –Enterprise Edition –Designed for multi-tier server-centric applications J2ME –Micro Edition –Tailored for consumer and embedded electronics J2EE –Enterprise Edition –Designed for multi-tier server-centric applications
Lecture SERVER CENTRIC APPLICATIONS
Lecture Server Centric Applications An application typically running on a web server Accessible by many clients simultaneously Takes in a request (GET/POST) Returns a response
Lecture Server Side Languages CGI: Common Gateway Interface Note: Not a language. Can use any language to develop a CGI. JSP (Servlets): Java Server Pages ASP: Active Server Pages PHP: PHP Hypertext Preprocessor Mod_Perl: Perl modules for Apache
Lecture CGI
Lecture FastCGI
Lecture Moving Beyond CGIs Don’t have to spawn a new process Can take advantage of multiple thread execution Improved scalability and performance
Lecture JSP/Servlets
Lecture Java Web Servers Receives GET / POST requests via HTTP Sends a response via HTTP Runs a Java web application in an isolated virtual machine Maps Servlet requests to a Java class Also called the application container
Lecture Java Application Containers Apache Tomcat – Sun Java System Application Server – ppsrvr.html IBM WebSphere – 306.ibm.com/software/info1/websphere/index.jsp
Lecture Components of a Java Web Application LanguageLayer HTML, CSS, XSLTPresentation JavaScriptPresentation, Business Logic Servlets, JSP, Tag LibraryPresentation, Business Logic Java ClassesBusiness Logic SQL, JDBC, XMLData
Lecture A Server Centric Application
Lecture TIERED ARCHITECTURE
Lecture Tiered Applications Distinct division of function and logic within an application Can also refer to physical division of an application Extensively used in web application design and deployment A logical/functional tier doesn’t mean physical separation
Lecture Classical Three Tiered Applications Classically 3 component layers to an application –Data Layer Manages data used by the application –Business Logic Layer Contains various business rules performed on the data –Presentation Layer Interacts with the user (GUI)
Lecture Three Tiered Applications
Lecture Logical Versus Physical
Lecture The “Half Tier”
Lecture More Than Three Complex enterprise applications have lead to many distributed layers Referred to as multi-tier or N-tier applications Typically used for high performance, high availability applications
Lecture N-Tiered Applications
Lecture Advantages of Tiered Application Design 1.Manageability Each tier can be monitored, tuned, and upgraded independently. Different people can have clearly defined responsibilities. 2.Scalability More places within the application to add more hardware. Allows for clustering techniques 3.Maintainability Changes, upgrades, and maintenance can be performed without affecting other components
Lecture Advantages of Tiered Application Design 4.Reliability Each operation is clearly distinguished from the others Changes to one tier does not affect another tier 5.Availability Recovering from failures is faster due to lowered dependence on individual machines Clustering and load balancing can provide even better availability 6.Extensibility Additional features can be added without having to redesign the entire system
Lecture Physical Tier
Lecture DESIGN PATTERNS
Lecture What is a Design Pattern? “Each pattern describes a problem which occurs over and over again in our environment, and then describes the cord of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice” – Christopher Alexander
Lecture Why Use Design Patterns? Provides a flexible framework for building complex architectures Helps ease the burden of complexity Proven solutions to common problems Provides a lexicon to describe problems and their solutions
Lecture Model-View-Controller Popular design pattern used to develop user interfaces Decouples the graphical interface from the rest of the application that “does the work” Commonly referred to as MVC Not specific to one object-oriented language Many web applications employ MVC, or some variant thereof
Lecture Model-View-Controller
Lecture The Model The code that carries out some tasks Has no concern with “look and feel” Methods in the model include: –Query methods permitting user to get information on the state of the model –Mutator methods that permit the state to be modified –Methods to register views –Methods to notify registered views when the model state has changed java.util.Observable
Lecture Model-View-Controller
Lecture The View Can have several views Provides graphical user interface (GUI) components for the model Display is based on the state of the model Informs the controller of manipulations made by the user Can be built from AWT or SWING for standalone applications java.util.Observer
Lecture Model-View-Controller
Lecture The Controller Have associated views Can have several controllers typically one per view Updates the model state when necessary by calling a mutator method Event Listener
Lecture Model-View-Controller
Lecture MVC Example
Lecture Putting It All Together
Lecture Existing Frameworks Language specific architectural/deployment frameworks already exist Before trying to fit your existing code or designing new code within an architecture, determine if a framework already exists Java Architectural Framework Example – Java Deployment Framework Example –
Lecture INTRODUCTION TO DEVELOPMENT PRACTICES
Lecture Development Practices Concurrent Versioning System –I.e. CVS –Manages revisions to code in a multi-developer environment IDE: Integrated Development Environment –I.e Eclipse –A GUI development environment combining several development tools (i.e. CVS, ANT, debugging)
Lecture Development Practices Bug Tracking –I.e. bugzilla –Web based bug and feature request tracking application Automated Build Scripts –ANT –Platform independent build tool used for java compilation
Lecture RESOURCES
Lecture Web Sites SUN Java – Apache Jakarta Project – SUN Design Patterns – Google –
Lecture Books Design Patterns, Elements of Reusable Object-Oriented Software (Addison-Wesley) [ISBN: ] Developing Software for the User Interface (Addison-Wesley) [ISBN: ] The Pragmatic Programmer (Addison-Wesley) [ISBN: ] Java Enterprise in a Nutshell, 2 nd Edition (O’Reilly) [ISBN: ] Building Java Enterprise Applications Volume 1: Architecture (O’Reilly) [ISBN: ]