Download presentation
Presentation is loading. Please wait.
1
© Copyright 2005 Chris Ling Monash University Introducing J2EE
2
© Copyright 2005 Chris Ling, Monash University Enterprise Software Enterprise - an organization of individuals or entities, working together to achieve some common goals. Have common needs: info sharing and processing, asset management, resource planning, customer/client management etc. Enterprise software refers to all the software involved in supporting these needs.
3
© Copyright 2005 Chris Ling, Monash University Enterprise Example CustomerPartners Customer Support Inventory Management Sales Employees HR Other Shared Resources Data
4
© Copyright 2005 Chris Ling, Monash University Evolution of Enterprise Software Single-tier applications: Dumb terminals to mainframe Two-tier applications: Client-server The n-tier approach: A better balance by separating business logic from presentation logic. Different tiers not necessary different pieces of hardware. Benefits: Faster and lower cost development, isolated impact of changes and changes are more manageable.
5
© Copyright 2005 Chris Ling, Monash University Two-Tier Architecture Early 90’s, most enterprise applications follow a two-tier architecture (client/server) Business logic and presentation logic on the same machine (eg. CSE5910 Assignment) Easier to deal with because it is non-distributed. PCs Database Server Presentation Logic Business Logic
6
© Copyright 2005 Chris Ling, Monash University Disadvantages Easy to compromise database integrity. Difficult to administer in a large enterprise. Security violations. Limited scalability – limited database access. Homogeneous client architecture Ties the application to one particular presentation type. Incompatible with the onset of Web.
7
© Copyright 2005 Chris Ling, Monash University Three-Tier Architecture Split the presentation logic (client computer) from the business logic (middle-tier server). Presentation Logic Business Logic PC Middle-Tier Server Database Server
8
© Copyright 2005 Chris Ling, Monash University Another Three-tier Architecture A standard architecture for developing and deploying enterprise Web-oriented applications and applets using Java. Example: CSE3420 Practical Assignment. Browser Servlet Container (Presentation And Logic) Desktop ClientWeb Container Database
9
© Copyright 2005 Chris Ling, Monash University Disadvantages Some improvements, such as improved scalability and security, but Complexity – multithreading, security, distribution, deployment and admin support. Lack of application portability – different vendor software Incompatibility with the web – more suitable for intranet.
10
© Copyright 2005 Chris Ling, Monash University Early Web-based Architecture Web application developers used various plug-in extensions to Web servers CGI applications or cgi-bin scripts, but Do not provide well-structured encapsulation Intertwine the implementation of the business processes with the implementation of the presentation logic. Difficult to foster the maintenance of the integrity of the business rules - scattered across web-servers.
11
© Copyright 2005 Chris Ling, Monash University Component-based Software Object-oriented software development Adopted for reusability. Too fine-grained to achieve large-scale reusability. Software components Much higher level of abstractions. More loosely coupled - using interfaces Compatibility issues. Distributed component models: DCOM, Microsoft.NET and Enterprise Java Beans (EJB) which is part of Java 2 Enterprise Edition (J2EE).
12
© Copyright 2005 Chris Ling, Monash University J2EE History Java (originally called Oak) evolved for client-side developments - applets, JDBC API. Problems with browser-based system environment - latency over the internet before application startup. Web-based applications through Java servlets. However, servlets not designed to handle complex computations. EJB initially released separately to handle services and functions for the enterprise. J2EE is the result of aligning the disparate Java technologies and APIs into a development platform for specific web-based enterprise software. J2EE specification - specifies how a number of Java technologies are to interoperate.
13
© Copyright 2005 Chris Ling, Monash University Container Service API Service API Service API Service API Service API Service API Component CONTAINER SERVER
14
© Copyright 2005 Chris Ling, Monash University Container Concepts Container: a software entity that runs within the server. Provides execution environment for the components. Provides independence between development and deployment - portability. Manages life cycle of components. Enforces security, eg. Intercepting external requests.
15
© Copyright 2005 Chris Ling, Monash University J2EE Containers 1. The EJB Container – the environment for enterprise beans, components that implements the business processes and entities. 2. The Web Container – the environment for servlets and JSPs, grouped into deployable units called Web applications (for presentation logic of an enterprise application). 3. The Application Client Container – environment for executing J2EE application clients, essentailly J2SE. 4. The Applet Container – the environment for executing applets. Environment is embedded in a web browser.
16
© Copyright 2005 Chris Ling, Monash University J2EE Architecture A standard architecture for developing and deploying enterprise Web-oriented applications and applets using Java. Not only for intranet applications (replacing two-tier and three-tier models), but also for internet applications (replacing cgi-bin- based approach).
17
© Copyright 2005 Chris Ling, Monash University J2EE Architecture J2EE Application Programming Model for Three-Tier Applications: Application-Client Container Presentation Components EJB Container Enterprise Bean Desktop ClientBusiness Logic Database JDBC
18
© Copyright 2005 Chris Ling, Monash University J2EE Architecture J2EE Application Programming Model Applet Container Applets Web Container Web Application (Servlets, JSPs …) EJB Container Enterprise Beans Browser Web ServiceBusiness Logic Database Internet Application Client Container Internet
19
© Copyright 2005 Chris Ling, Monash University Why J2EE? Separating development efforts from interprocess communication issues: security, database specific accesses. Cleaner partition between development, deployment and execution. Support for hardware and OS independence by providing access via Java and J2EE APIs. Support for products by third party vendors. Component-based: higher productivity, rapid development, easier maintenance.
20
© Copyright 2005 Chris Ling, Monash University Multitiered Applications
21
© Copyright 2005 Chris Ling, Monash University J2EE Components J2EE Clients or Client tier. Two types: Web client - consists of: 1. Dynamic web pages consisting of various types of markup language (HTML, XML etc) 2. A Web browser Application client Run on client’s machine with a richer GUI than a markup language GUI programs using AWT and SWING Directly access enterprise beans running on the business tier. Can open an HTTP connection to communicate with servlets. A web page received from the Web tier can include embedded applets and JavaBeans components.
22
© Copyright 2005 Chris Ling, Monash University J2EE Components (cont) Web components: JSPs and servlets in the web tier. Business components: Enterprise Beans running in the business tier. EIS (Enterprise Information System) tier handles enterprise resource planning (ERP), mainframe transaction processing, database systems etc.
23
© Copyright 2005 Chris Ling Monash University J2EE Architecture and Technologies
24
© Copyright 2005 Chris Ling, Monash University Container Services Containers are the interfaces between a component and the low-level platform-specific functionality. Before the web, enterprise bean or application- client component can be executed, it must be assembled into a J2EE module and deployed into its container. Assembly/Deployment process involves specifying container settings which customise the underlying support, including services such as security, transaction management, Java Naming and Directory Interface (JNDI) lookups and remote connectivity.
25
© Copyright 2005 Chris Ling, Monash University J2EE Server and Containers
26
© Copyright 2005 Chris Ling, Monash University Web Services Support Web services are Web-based enterprise applications that use open, XML-based standards and transport protocols to exchange data with calling clients J2EE provides XML APIs and tools to design, develop, test and deploy web services and clients that interoperate with other web services and clients running on Java-based or non-Java-based platforms. XML, SOAP Transport Protocol, WSDL Standard Format, UDDI and ebXML standard formats
27
© Copyright 2005 Chris Ling, Monash University Wow! XML API SOAP – Simple Object Access Protocol WSDL web services description language: a XML based format for describing web services UDDI -- Universal Description, Discovery, and Integration, a platform-independent, XML-based registry for businesses worldwide to list themselves on the Internet.XMLInternet ebXML standard formats: electronic business formats for specific business XML-based interactions
28
© Copyright 2005 Chris Ling, Monash University J2EE Technologies and APIs J2EE Technologies: Servlets JSP – Java server pages EJB J2EE APIs: JDBC – Java Database connectivity Java Naming and Directory Interface (JNDI) JMS – Java message service Remote Method Invocation (RMI) Others: J2EE Connectors, Java Transaction API (JTA), Java IDL, RMI-IIOP, Java Transaction Service (JTS) and JavaMail
29
© Copyright 2005 Chris Ling, Monash University JDBC API A pure Java API for SQL access to relational databases. Majority of the API is in J2SE. A vendor independent interface to databases. Depending on the type of EJBs you implement, you may or may not use the JDBC API. Can also use JDBC from a servlet or JSP or from normal Java application.
30
© Copyright 2005 Chris Ling, Monash University Servlets Web components capable of generating dynamic content. Possible to use them (with JSPs) and bypass the EJB Container. Used to handle simpler tasks, such as gathering and checking for valid input fields on a web page. Run inside the servlet container hosted on the web server.
31
© Copyright 2005 Chris Ling, Monash University Servlets (cont) A client requests a web page by issuing an HTTP request which specifies a servlet. A servlet runs in response to the request and outputs an HTML page to the client. A servlet is a Java program and is not contained in HTML pages! A servlet is a class that resides in a servlet folder of the web folder and implements certain methods.
32
© Copyright 2005 Chris Ling, Monash University A Servlet Example import java.io.*; // From Wigglesworth 2001 import java.util.Date; import javax.servlet.*; import javax.servlet.http.*; public class TodayServlet extends HttpServlet { public void doGet( HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType( "text/HTML" ); response.setHeader( "Pragma", "no cache" ); response.setHeader( "Cache-Control", "no cache" ); response.setHeader( "Expires", "0" ); PrintWriter out = response.getWriter(); // or ServletOutputStream out = response.getOutputStream(); out.println( " " ); out.println( " Today " ); out.println( " " ); out.println(" The current date and Time is: " ); Date today = new Date(); out.println( " " + today + " " ); out.flush(); out.println( " " ); }
33
© Copyright 2005 Chris Ling, Monash University Java ServerPages (JSPs) Another J2EE Web component which evolved from the servlet technology. Provide a way to write dynamic web pages as HTML documents, rather than as output from a servlet. For web page presentation without being a traditional programmer. Permits Java code to be embedded within HTML Generally good practice to keep the Java code simple. Serves the same purpose as a servlet: to produce HTML page with dynamic content.
34
© Copyright 2005 Chris Ling, Monash University A JSP Example The previous servlet example in JSP (today.jsp): Today The current date and time is: In short, JSPs let you write your HTML in HTML rather than in Java, but you still need to know Java.
35
© Copyright 2005 Chris Ling, Monash University Enterprise Java Bean (EJB) The core of J2EE platform Three types: Session beans - for transient activities Non-persistent and encapsulate mainly business logic. Can be stateless or stateful Entity beans - encapsulate persistent data in a data store. Assist business logic or to prepare data for web display. Two types: CMP and BMP Message-driven beans - for Java Messaging Service (JMS) messages.
36
© Copyright 2005 Chris Ling, Monash University Classes and Interfaces To implement an EJB, we need to define 2 interfaces and 1 bean class: Remote Interface: presents the business methods that can be accessed outside the EJB container Used together with Remote Home Interface. Remote Home Interface: Defines the life cycle methods of the bean: create(), find() and remove(). Used together with Remote Interface.
37
© Copyright 2005 Chris Ling, Monash University Classes and Interfaces Local Interface (EJB 2.0) Defines the bean’s methods used by other beans in the same EJB container. Used together with Local Home Interface. Local Home Interface (EJB 2.0) Defines the bean’s lifecycle methods used by other beans in the same EJB container. Used together with Local Interface. The Enterprise Bean class Implements the bean’s business methods An entity bean must implement javax.ejb.EntityBean A session bean must implement javax.ejb.SessionBean Both beans extend javax.ejb.EnterpriseBean.
38
© Copyright 2005 Chris Ling, Monash University EJB Roles Roles as specified in the EJB Specification: Component Provider: Software developer who authors EJBs. Application assembler: Someone who builds an application out of existing EJBs. Deployer: Someone who deploys the application. Server vendor: Supplies EJB server products. Administrator: In charge of maintenance and performance tuning of an application. Tool provider: Someone who authors EJB packaging and deployment tools.
39
© Copyright 2005 Chris Ling, Monash University References 1. K. Boone (2003). Applied Enterprise JavaBeans Technology. Sun Microsystems. 2. V. Matena and B. Stearns (2003). Applying Enterprise JavaBeans. Component-Based Development for the J2EE Platform. Wnd Edition. Addison-Wesley. 3. K. Z. Ahmed and C. E. Umrysh (2002). Developing Enterprise Java Applications with J2EE and UML. Addison-Wesley. 4. E. Armstrong, J. Ball, S. Bodoff, D. B. Carson, I. Evans, D. Green, K. Haase and E. Jendrock (2004). The J2EE 1.4 Tutorial. Sun Microsystems.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.