J2EE Architecture: J2EE Design Patterns: Related Concepts #Java Short Notes

  • Design Patterns
    • What are design patterns? Design patterns are specific/(context-based) solutions/approaches to address specific problems/situations. Some problems are general/open problems and very common problems in a particular type of applications. Design patterns can be created to solve such problems in a specific context and that can be re-used every time that type of situations arise. Design patterns help designers to easily communicate their ideas (in a common concept).
    • Benefits: Proven solution to a specific problem, saves time as you don't have to come up with an original solution each time you encounter a particular problem
    • Design patterns can be applied at different levels of abstractions such as, Analysis, Architectural, Behavioral, Creational, Design, and Structural
    • J2EE patterns are mostly for design and architecture purpose and for three architectural tiers: Presentation, Business, and Integration
  • J2EE Applications: Client Tier (Clients for J2EE Applications): Design Issues
    • J2EE supports many types of clients. Hence, you need to decide which types of clients you want to make use of. Also, based on the clients you need to decide how to solve a specific problem. Design patterns can be client-specific and problem-specific
    • J2EE clients: laptops, desktops, palmtops, and cell phones.
    • Connection Mechanisms (to J2EE Applications): an intranet, the Internet, a wireless network, a wired network, and a combination of wired and wireless networks
    • Clients can be thin, server dependent, browser based, rich, and stand-alone
    • Client design issues: Concerns: which types of clients to use, should more than one type of clients be supported?, network types to support, security considerations, platform considerations, and unreliability of networks
    • Clients should: Connect to the network on an ad-hoc basis, transmit minimum amount of data, should consider situations when firewalls may block particular protocols, mobile clients should consider that they have small display screens and limited resources
    • More design issues for J2EE clients: Logic for user interface presentation, validate user inputs, communicate with the server using a common protocol, maintain the conversational state
    • Browser clients - design issues: can not function independently of the server, easy to design and implement, widely available, well-familiar to the users, provide limited functionality, can perform user input validation, servers can also do the validation, uses HTTP protocol, needs to maintain conversational states using Cookies, URL rewriting, or server side session
    • Java clients - design issues:
    • Client types: applications, applets, MIDlets are the Java client options
    • Applications like usual desktop applications - can run offline, use JFC/Swing for user interface, provide richer user experience, more responsive than thin clients, use less bandwidth than browser clients, and can create fewer connections than browser clients
    • Applets run mostly under browsers, use JFC/Swing for user interface
    • MIDlets are mostly for small applications for cell phones, two-way pagers, and palmtops - use MIDP user interface APIs
    • Java clients (Applications, applets, MIDlets) can handle most user input validation and hence, reduce network overhead, can connect to J2EE applications, directly to the web tier (using HTTP though face some complexity of translation), EJBs, EISs,
    • Applets and applications can connect to EJBs directly,
    • Java clients can access EIS tier directly (not recommended as it would bypass J2EE server and transaction management)
    • Java clients have the facility to cache and manipulate large amounts of state in memory and manage session effectively
  • Web Tier
    • Servlets, and JSPs are web-tier component
    • Manage the interaction between web-clients and the application's business logic.
    • Output from this tier: mostly HTML and XML content
    • Business logic can be implemented entirely here, though, enterprise beans are recommended
    • Servlets should be used to: implement web-application logic, generate binary content, act as a web-tier controller
    • JSPs are better suited to generate static HTML text
    • JSP Purpose: produce structured textual content, generate XML messages, act as templates
    • In JSP, custom tags are more desirable than scriptlets. Why? scriplets - not reusable, mix logic with content, make JSP pages difficult to read and update, errors can be difficult to interpret, difficult to test (including unit testing)
    • Web-Tier Application Framework
      • Many web-tier application requirements are not met by the actual J2EE platform. A framework working on top of J2EE can meet these requirements such as, dispatching requests, invoking model methods, and compiling views.
      • Making use of existing ready-built and proven application framework is recommended than creating your own [it takes time and may be all your designs will not be the best]
      • Some frameworks: J2EE blueprints Web Application Framework, Apache Struts, JavaServer Faces
    • Model View Controller (MVC)
      • Well-suited for interactive applications such as web-applications.
      • Divides applications into three modules - model, view, controller
      • model: data representation and business logic, view: data presentation and user input, controller: controls information flow
      • Benefits: separation of design and implement, decreased code duplication, centralized control
      • Servlets are ideal as controllers
      • Controllers receive all incoming client requests and direct them to the appropriate business logic component, after processing the requests, the controller selects the right view to return to the client.
    • Model 1 and Model 2
      • Model 1: No controller, direct access to the JSP pages, decentralized application, simpler and hence suited for small and static applications
      • Model 2: Uses a controller, are favored as they are easy to maintain and extend, provide a single point for security and logging
  • EJB Tier
    • Hosts business logic of a J2EE application
    • Provides system level services to the business components
    • Developers can focus on business-logic problems
    • J2EE platform handles the system related problems (complex many times) such as, state maintenance, transaction management, and availability to local and remote clients
    • EJBs provide a good interface between presentation components in the web-tier and business data and systems in the EIS tier
    • EJBs - entity, session, message driven
    • EJBs can provide remote or local access by providing remote or local interfaces. EJBs are mostly designed for distributed environments and hence typically provide remote interfaces
    • When to use entity beans: for business objects when it represents persistent data and requires persistent storage, multiple client access, data access in portable manners, server managed transaction handling is preferable
    • Entity beans: Persistence can be managed by yourself or by the EJB container
    • When to use Stateful Session-beans: for client centric business logic, business objects are short-lived, and non-persistent. Works for the client to maintain conversational state
    • When to use Stateless session beans: Provide server side behavior, do not maintain states for a specific client, good for reusable service objects, to minimize resources and support a large number of clients, when the business object does not operate on instance variables.
  • EIS Tier
    • J2EE EIS technologies: J2EE Connectors to integrate J2EE applications with existing EISs using resource adapters - synchronous
    • Java Message Service: To be used with enterprise messaging systems - asynchronous
    • JDBC - integrates J2EE applications with relational database systems
    • asynchronous: high quality and reliable message-delivery service, provide higher volume of messaging, more work for the developers
    • synchronous - suitable to handle two or more EISs synchronously.

From: http://sitestree.com/?p=4981
Categories:Java Short Notes
Tags:
Post Data:2009-07-13 18:40:32

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

Leave a Reply