Part III: Component Architectures Natividad Martínez Madrid y Simon Pickin Departamento de Ingeniería Telemática Universidad Carlos III de Madrid {nati, spickin}@it.uc3m.es Introduction Contents Client-server and multi-tier architectures presentation layer data layer business layer The Java 2 Enterprise Edition (J2EE) platform comparison with Microsoft.NET 2 1
Introduction Heterogeneity and decentralisation different platforms, operating systems, network protocols etc. Java 2 Enterprise Edition (J2EE) platform (Sun Microsystems) platform independence, portability and interoperability between applications Basic objectives: 1. Abstraction of critical and repetitive tasks via services with a uniform interface 2. Preparation of a uniform infrastructure and of a software architecture for enterprise applications based on this architecture 3 Requirements of enterprise applications Storage of, and access to, data (back-end integration): employment of database systems (DBMS), database connectivity, representation of data in the database Data mapping and persistence: representation of data in programs (classes) and correspondence (mapping) to its representation in the data base, update of the database by the program after changes Data integrity: control of concurrent access to data, transaction monitors User interaction: authentication, access control, coordination of concurrent access Access to shared data: isolation of different accesses, data caching 4 2
Requirements of enterprise applications Performance: good response time, efficient interaction between different components Scalability: possibility of incorporating new servers, load distribution Availability: security on application crashes (ideally 24 x 7 availability), fault tolerant systems, server and data clustering Software design: mantainability y portability modularity, design in levels, reduced external dependence (e.g., on the data base) 5 Component-based programming vs OObased programming Common objectives: information hiding, abstraction, low external coupling, high internal cohesion Objects have smaller granularity than components Components are elements that are more associated to the application 6 3
Relation between Components, Models and Execution Environments architecture model business model component model fundaments for the design of components and applications component software component development based on component models Componentbased application base application components working in suitable appliaction servers application component-development tools application server (container) 7 Architectures for Enterprise Applications Complex component-based applications are sub-divided into logical layers Each layer covers a certain task area and may be composed of one or various parts The division into layers is a logical abstraction 8 4
Classic Client/Server Architectures Application divided functionally and physically into two layers (two-tier) 1. client part (running on the user s computer): classic program elements: execution logic, preparation and presentation of information, interaction with the user 2. server part: business data (in a data base, or, in general an Enterprise Information System (EIS) ) Client and server are weakly coupled and communicate only via messages The service request (initiating the communication) always comes from the client; the server reacts with a reply A large part of the application executes on the client side ( fat client ) in a decentralised manner 9 Classic Client/Server Architectures client tier server tier client server fat client business logic data 10 5
Classic Client/Server Architecture: Cons In general, lack of scalability Database integrity problems Heavy load on the network: large number of communication steps necessary quantity of results returned by data base larger than necessary Distribution and update of software expensive (hundreds or thousands of clients) The application designer needs a profound knowledge of many critical areas transaction control security model efficient data access 11 Multi-Tiered Architectures In multi-tier architectures (3-tier / n-tier), additional software layers are added to deal with certain critical tasks fat clients become thin clients The intermediate tiers extend the responsibility of the server side though they may be situated in independent nodes or systems Each tier communicates only with the contiguous tiers via clearly defined interfaces 12 6
Multi-Tiered Architectures client tier middle tier EIS tier Thin client client business logic Server services data 13 Example: Multi-Tiered Architectures client tier front end (thin client) Windows Macintosh Unix Java Browser middle tier Presentation bank component business logic client account component movement component data base driver connector transaction service data tier back end SAP/R3 server DBMS server web server application server 14 7
J2EE Web Application Architecture web client web container servlets, JSP EJB container JCA data tier (EIS) HTTP RMI-IIOP JDBC JDBC 15 Client Tier This is the part of the application that executes on the client s computer It usually implements the following functions: present the information coming from the server collect input data Usually it is a web browser; it may include: applets to show graphic information Javascript to pre-process input Plug-ins (such as Flash) or it may be a Java application 16 8
Middle Tier Application server: principal part of the application application and business logic preparation of the information for the user Middleware: contains specialised software for implementing certain tasks: Monitors, naming systems, message queuing systems, etc. 17 Middle Tier: Presentation Receives the requests from the clients extracts the client data extracts additional information (request headers) Performs some pre-processing of the request decides what business-level services are necessary calls the required business-level services Prepares the client responses response headers contents of the response (typically HTML) 18 9
Middle Tier: Business Implements the business logic i.e. the functionality itself Application server may also integrate part of the presentation Application server contains: A container where the business components live session components (represent processes) entity components (represent data) The other middleware services transaction-based data processing secure access monitors naming system, etc. 19 Data Tier Data bases or Enterprise Information Systems Responsable for the administration of, rapid access to, and persistence of data Accessed by the business tier data mapping, from the business-tier data representation to the EIS representation, required Note: very simple web applications may have no business tier presentation layer includes the application logic presentation layer communicates directly with data layer 20 10
Model-View-Controller (MVC) 21 Advantages of Multi-Tier Architectures Critical parts of application are found in middle tier, closer to data more efficient access only the necessary data is transferred to the client less load on the network problem: an increase in the number of levels leads to an increase in the number of communication steps and longer response times Greater flexibility and scalability; moreover: lower installation costs easier to replace / update data base isolation of each part w.r.t. changes in the rest better security advantages of centralised resource management better fault detection 22 11
Application server Support system for server components development environment for components the server components use the services of the application server Infrastructure tasks: component instantiation communication synchronization of concurrent access preparation of a secure environment availability transaction security 23 Elements of an Application Server naming service directory service client/server (HTTP, IIOP, RMI, DCOM) communication messages (pub/sub, queues) events data streaming transaction service state management instance pooling load balancing connection pooling components security Servlets EJB CORBA COM web adapter Legacy Connectors 24 12
Introduction Contents Client-server and multi-tier architectures presentation Layer data Layer business Layer The Java 2 platform, Enterprise Edition (J2EE) comparison with Microsoft.NET 25 Java 2 Platform, Enterprise Edition (J2EE) Collection of specifications and programming directives to facilitate the development of internet-enabled multi-tier, distributed server applications. Some history 1996: Java Development Kit (JDK) 1.02: an ordered collection of class libraries and packages 1999: JDK 1.2 Java 2 Platform: in addition to the JDK, optional packages for messaging, dynamic web page generation and and e-mail programs in Java. Divided into 3 editions: Java 2 Platform, Standard Edition (J2SE): contains el current JDK and the standard APIs. Development of desktop applications and applets Java 2 Platform, Enterprise Edition (J2EE): based on J2SE, extends the server side. Version 1.3, late 2001, Version 1.4 (beta) Java 2 Platform, Micro Edition (J2ME): special edition for mobiles, pagers, palmtops (embedded systems) 26 13
Elements of the J2EE specification J2EE Platform: standard represented by a set of APIS and directives, supported by an application server (java.sun.com/j2ee/download.html) J2EE Blueprints: advice for the development of J2EE applications, design patterns and an sample application (java.sun.com/blueprints/) J2EE Server: reference implementation of an application server for J2EE, included in J2EE SDK (java.sun.com/j2ee/download.html) J2EE Testsuite: J2EE Compatibility Testsuite (CTS), compatibility tests (java.sun.com/j2ee/compatibility.html) 27 J2EE Application Architecture client tier application server tier(s) EIS tier web client web Container EJB container data bases client container legacy applications Java client servlets, JSP Enterprise JavaBeans services and APIs JNDI, RMI-IIOP, services and APIs JNDI, JMS, JTA, services y APIs JNDI, JMS, JTA, ERP systems J2EE J2EE J2EE 28 14
Types of components in J2EE client side server side applets client components JavaBeans servlets/ Java Server Pages JavaBeans Enterprise JavaBeans J2EE application 29 Containers They offer an execution environment for all the application components They provide a uniform view of the services specified as being required by the components in the descriptors They provide deployment tools for the installation and configuration of components (including at execution time) The principal tasks of server side components are resource and lifecycle managements Applet Container Applets Applic. Client Container (J2SE) Servlet/JSP Container JSP Tools Servlet Engine JSP: JSP: JSP: Servicios EJB Container Enterprise JavaBeans Gestión recursos Servicios 30 15
Servlets and JavaServer Pages Servlets and JavaServer Pages (JSP) are presentation-level components They perform dynamic generation of web pages Servlets: Java programs: easier to control the flow of actions JSP: mark-up language based on tags: easier to represent information Equivalent (a JSP translates to a servlet) 31 Enterprise JavaBeans Enterprise JavaBeans (EJB) is a complete servicecomponent architecture specification Objectives of the EJB component architecture: facilitate the development of applications, concentrating on the business logic: development, application and executiontime aspects achieve independence of the component provider through the specification of interfaces achieve platform-independence thanks to the : Write Once Run Anywhere (WORA) principle and its implementation in Java ensure compatibility with existing Java APIs, with third-party server systems and with CORBA protocols 32 16
What are Enterprise JavaBeans? EJBs: components are used as part of distributed enterprise applications Each bean encapsulates part of the business logic of the application EJBs communicate with resource managers and with other EJBs EJBs are accessed by different types of clients: EJBs, servlets, application clients, etc. At execution time, they live in an EJB container: security services, transactions, deployment, concurrency and life-cycle management An application may have one or several EJB containers each containing one or several EJBs 33 Entity Beans: Types of EJBs model business concepts such as persistent objects associated to data, e.g.bank account, product, order Session Beans: represent processes executed in response to a request from the client, e.g. bank transactions, calculations, ordering Message-Driven Beans: represent processes executed as a response to the reception of a message 34 17
J2EE Services Naming service: access to components and resources via logical names portability and maintainability Java Naming and Directory Interface (JNDI) Transaction service: execution of a series of steps in an atomic and isolated manner declarative transaction demarcation: define transaction boundaries via deployment descriptors programmatic transaction demarcation: also possibility of finer transaction control via an API Java Transaction Service (JTS) Security service :security directives for protected resources two-step access control: authentication y authorisation declarative o programmed implementation Java Authentication & Authorization Service (JAAS) 35 Servicios J2EE Persistence: persistent storage of objects and object states, normally implemented using relational data bases JDBC Communication: different communication techniques, provided by the container or application service provider web communications : TCP/IP, UDP/IP, HTTP 1.0 y HTTPS (also with SSL) distributed object processing: RMI (Remote Method Invocation), based on Java Remote Method Protocol (JRMP): extension of RMI that also supports CORBA-IIOP for interoperability between J2EE and CORBA systems. Configuration / administration services: packaging, installation and flexible configuration of components and administration of applications description of the characteristics of servers, containers, applications, components and services using XML schemas 36 18
The Microsoft.NET platform Common view: benefits from a framework that supports applications with aspects such as load balancing, interoperability, transactions Common provider a set of tools from a single provider rather than a standard that can be implemented by multiple providers 37 The.NET Platform 38 19
Logical Levels The presentation level ASP.NET instead of JSP. programmed in Visual Basic, C#, etc. compiled to native code via the Common Language Runtime (equivalent of the JRE) The business level composed of Managed Objects connection to data bases using Active Data Objects ADO.NET connection to existing systems using services provided by Microsoft Host Integration Server 2000, such as the COM Transaction Integrator (COM TI) 39 J2EE and.net Correspondences Aspect Type of technology Middleware vendors Interpreter Dynamic web pages Middle-tier components Database access SOAP, WSDL, UDDI Implicit middleware (load balancing, etc) J2EE Standard 30+ JRE JSP EJB JDBC SQL/J Sí Sí.NET Product Microsoft CLR ASP.NET.NET Managed Components ADO.NET Sí Sí J2EE vs. Microsoft.NET:http://www.theserverside.com/resources/article.jsp?l=J2EE-vs-DOTNET 40 20
Conclusiones.NET vs J2EE 41 21