Presentation is loading. Please wait.

Presentation is loading. Please wait.

Notes of J2EE Tutorial Matt Tsai. 2 Outline Chapter 1: Overview Chapter 1: Overview Chapter 2: Understanding XML Chapter 2: Understanding XML Chapter.

Similar presentations


Presentation on theme: "Notes of J2EE Tutorial Matt Tsai. 2 Outline Chapter 1: Overview Chapter 1: Overview Chapter 2: Understanding XML Chapter 2: Understanding XML Chapter."— Presentation transcript:

1 Notes of J2EE Tutorial Matt Tsai

2 2 Outline Chapter 1: Overview Chapter 1: Overview Chapter 2: Understanding XML Chapter 2: Understanding XML Chapter 3: Getting Started with Web Applications Chapter 3: Getting Started with Web Applications Chapter 4: Java API for XML Processing Chapter 4: Java API for XML Processing Chapter 5: Simple API for XML Chapter 5: Simple API for XML Chapter 6: Document Object Model Chapter 6: Document Object Model Chapter 7: Extensible Stylesheet Language Transformations Chapter 7: Extensible Stylesheet Language Transformations Chapter 8: Building Web Services with JAX- RPC Chapter 8: Building Web Services with JAX- RPC Chapter 9: SOAP with Attachments API for Java Chapter 9: SOAP with Attachments API for Java Chapter 10: Java API for XML Registries Chapter 10: Java API for XML Registries Chapter 11: Java Servlet Technology Chapter 11: Java Servlet Technology Chapter 12: JavaServer Pages Technology Chapter 12: JavaServer Pages Technology Chapter 13: JavaServer Pages Documents Chapter 13: JavaServer Pages Documents Chapter 14: JavaServer Pages Standard Tag Library Chapter 14: JavaServer Pages Standard Tag Library Chapter 15: Custom Tags in JSP Pages Chapter 15: Custom Tags in JSP Pages Chapter 16: Scripting in JSP Pages Chapter 16: Scripting in JSP Pages Chapter 17: JavaServer Faces Technology Chapter 17: JavaServer Faces Technology Chapter 18: Using JavaServer Faces Technology in JSP Pages Chapter 18: Using JavaServer Faces Technology in JSP Pages Chapter 19: Developing with JavaServer Faces Technology Chapter 19: Developing with JavaServer Faces Technology Chapter 20: Creating Custom UI Components Chapter 20: Creating Custom UI Components Chapter 21: Configuring JavaServer Faces Applications Chapter 21: Configuring JavaServer Faces Applications Chapter 22: Internationalizing and Localizing Web Applications Chapter 22: Internationalizing and Localizing Web Applications Chapter 23: Enterprise Beans Chapter 23: Enterprise Beans Chapter 24: Getting Started with Enterprise Beans Chapter 24: Getting Started with Enterprise Beans Chapter 25: Session Bean Examples Chapter 25: Session Bean Examples Chapter 26: Bean-Managed Persistence Examples Chapter 26: Bean-Managed Persistence Examples Chapter 27: Container-Managed Persistence Examples Chapter 27: Container-Managed Persistence Examples Chapter 28: A Message-Driven Bean Example Chapter 28: A Message-Driven Bean Example Chapter 29: Enterprise JavaBeans Query Language Chapter 29: Enterprise JavaBeans Query Language Chapter 30: Transactions Chapter 30: Transactions Chapter 31: Resource Connections Chapter 31: Resource Connections Chapter 32: Security Chapter 32: Security Chapter 33: The Java Message Service API Chapter 33: The Java Message Service API Chapter 34: J2EE Examples Using the JMS API Chapter 34: J2EE Examples Using the JMS API Chapter 35: The Coffee Break Application Chapter 35: The Coffee Break Application Chapter 36: The Duke's Bank Application Chapter 36: The Duke's Bank Application

3 3 Overview The J2EE platform uses a distributed multitiered application model for enterprise applications. The J2EE platform uses a distributed multitiered application model for enterprise applications. The J2EE application parts shown in Figure 1-1 are presented in J2EE Components. The J2EE application parts shown in Figure 1-1 are presented in J2EE Components.Figure 1-1J2EE ComponentsFigure 1-1J2EE Components Client-tier components run on the client machine.Client-tier components run on the client machine. Web-tier components run on the J2EE server.Web-tier components run on the J2EE server. Business-tier components run on the J2EE server.Business-tier components run on the J2EE server. Enterprise information system (EIS)-tier software runs on the EIS server.Enterprise information system (EIS)-tier software runs on the EIS server.

4 4 Overview J2EE applications are made up of components. J2EE applications are made up of components. A J2EE component is a self-contained functional software unit that is assembled into a J2EE application with its related classes and files and that communicates with other components. A J2EE component is a self-contained functional software unit that is assembled into a J2EE application with its related classes and files and that communicates with other components. The J2EE specification defines the following J2EE components. The J2EE specification defines the following J2EE components. Application clients and applets are components that run on the client.Application clients and applets are components that run on the client. Java Servlet and JavaServer Pages (JSP ) technology components are Web components that run on the server.Java Servlet and JavaServer Pages (JSP ) technology components are Web components that run on the server. Enterprise JavaBeans (EJB ) components (enterprise beans) are business components that run on the server.Enterprise JavaBeans (EJB ) components (enterprise beans) are business components that run on the server. J2EE components are written in the Java programming language and are compiled in the same way as any program in the language. J2EE components are written in the Java programming language and are compiled in the same way as any program in the language.

5 5 Overview J2EE Clients J2EE Clients Web ClientsWeb Clients AppletsApplets Application ClientsApplication Clients J2EE Server Communications J2EE Server Communications

6 6 Overview Web Components Web Components Business Components Business Components

7 7 Overview J2EE Containers J2EE Containers Container ServicesContainer Services Containers are the interface between a component and the low-level platform- specific functionality that supports the component. Before a Web, enterprise bean, or application client component can be executed, it must be assembled into a J2EE module and deployed into its container. Containers are the interface between a component and the low-level platform- specific functionality that supports the component. Before a Web, enterprise bean, or application client component can be executed, it must be assembled into a J2EE module and deployed into its container. The assembly process involves specifying container settings for each component in the J2EE application and for the J2EE application itself. The assembly process involves specifying container settings for each component in the J2EE application and for the J2EE application itself. Container settings customize the underlying support provided by the J2EE server, including services such as security, transaction management, Java Naming and Directory Interface (JNDI) lookups, and remote connectivity. Container settings customize the underlying support provided by the J2EE server, including services such as security, transaction management, Java Naming and Directory Interface (JNDI) lookups, and remote connectivity. Container TypesContainer Types

8 8 Overview Web service support Web service support Web services are Web-based enterprise applications that use open, XML-based standards and transport protocols to exchange data with calling clients.Web services are Web-based enterprise applications that use open, XML-based standards and transport protocols to exchange data with calling clients. The J2EE platform provides the XML APIs and tools you need to quickly design, develop, test, and deploy Web services and clients that fully interoperate with other Web services and clients running on Java-based or non-Java-based platforms.The J2EE platform provides the XML APIs and tools you need to quickly design, develop, test, and deploy Web services and clients that fully interoperate with other Web services and clients running on Java-based or non-Java-based platforms.

9 9 Overview A J2EE application is delivered in an Enterprise Archive (EAR) file, a standard Java Archive (JAR) file with an.ear extension. A J2EE application is delivered in an Enterprise Archive (EAR) file, a standard Java Archive (JAR) file with an.ear extension. Using EAR files and modules makes it possible to assemble a number of different J2EE applications using some of the same components. Using EAR files and modules makes it possible to assemble a number of different J2EE applications using some of the same components. EAR File Structure EAR File Structure

10 10 Overview A J2EE module consists of one or more J2EE components for the same container type and one component deployment descriptor of that type. A J2EE module consists of one or more J2EE components for the same container type and one component deployment descriptor of that type. An enterprise bean module deployment descriptor, for example, declares transaction attributes and security authorizations for an enterprise bean. A J2EE module without an application deployment descriptor can be deployed as a stand- alone module. An enterprise bean module deployment descriptor, for example, declares transaction attributes and security authorizations for an enterprise bean. A J2EE module without an application deployment descriptor can be deployed as a stand- alone module. The four types of J2EE modules are as follows: The four types of J2EE modules are as follows: EJB modules, which contain class files for enterprise beans and an EJB deployment descriptor. EJB modules are packaged as JAR files with a.jar extension.EJB modules, which contain class files for enterprise beans and an EJB deployment descriptor. EJB modules are packaged as JAR files with a.jar extension. Web modules, which contain servlet class files, JSP files, supporting class files, GIF and HTML files, and a Web application deployment descriptor. Web modules are packaged as JAR files with a.war (Web archive) extension.Web modules, which contain servlet class files, JSP files, supporting class files, GIF and HTML files, and a Web application deployment descriptor. Web modules are packaged as JAR files with a.war (Web archive) extension. Application client modules, which contain class files and an application client deployment descriptor. Application client modules are packaged as JAR files with a.jar extension.Application client modules, which contain class files and an application client deployment descriptor. Application client modules are packaged as JAR files with a.jar extension. Resource adapter modules, which contain all Java interfaces, classes, native libraries, and other documentation, along with the resource adapter deployment descriptor. Together, these implement the Connector architecture (see J2EE Connector Architecture) for a particular EIS. Resource adapter modules are packaged as JAR files with an.rar (resource adapter archive) extension.Resource adapter modules, which contain all Java interfaces, classes, native libraries, and other documentation, along with the resource adapter deployment descriptor. Together, these implement the Connector architecture (see J2EE Connector Architecture) for a particular EIS. Resource adapter modules are packaged as JAR files with an.rar (resource adapter archive) extension.J2EE Connector ArchitectureJ2EE Connector Architecture

11 11 Overview Development Roles Development Roles J2EE Product ProviderJ2EE Product Provider Tool ProviderTool Provider Application Component ProviderApplication Component Provider Enterprise Bean Developer Enterprise Bean Developer Web Component Developer Web Component Developer Application Client Developer Application Client Developer Application AssemblerApplication Assembler Application Deployer and AdministratorApplication Deployer and Administrator

12 12 Overview J2EE Platform APIs J2EE Platform APIs

13 13 Overview The Sun Java System Application Server Platform Edition 8 is a fully compliant implementation of the J2EE 1.4 platform. The Sun Java System Application Server Platform Edition 8 is a fully compliant implementation of the J2EE 1.4 platform. The Application Server includes a number of J2EE technologies and tools that are not part of the J2EE 1.4 platform but are provided as a convenience to the developer. The Application Server includes a number of J2EE technologies and tools that are not part of the J2EE 1.4 platform but are provided as a convenience to the developer. The Application Server includes two user interface technologies The Application Server includes two user interface technologies JavaServer Pages Standard Tag LibraryJavaServer Pages Standard Tag Library JavaServer FacesJavaServer Faces

14 14 Overview Application Server Tools Application Server Tools

15 15 Overview Starting and Stopping the Application Server Starting and Stopping the Application Server To start and stop the Application ServerTo start and stop the Application Server asadmin start-domain --verbose domain1 asadmin start-domain --verbose domain1 To stop the Application Server, open a terminal window or command prompt and executeTo stop the Application Server, open a terminal window or command prompt and execute asadmin stop-domain domain1 asadmin stop-domain domain1 Starting the Admin Console Starting the Admin Console To administer the Application Server and manage users, resources, and J2EE applications, you use the Admin Console toolTo administer the Application Server and manage users, resources, and J2EE applications, you use the Admin Console tool http://localhost:4848/asadmin/ http://localhost:4848/asadmin/

16 16 Understanding XML XML is a text-based markup language that is fast becoming the standard for data interchange on the Web. XML is a text-based markup language that is fast becoming the standard for data interchange on the Web. After the XML declaration, the document prolog can include a DTD, which lets you specify the kinds of tags that can be included in your XML document. In addition to telling a validating parser which tags are valid and in what arrangements, a DTD tells both validating and nonvalidating parsers where text is expected, which lets the parser determine whether the whitespace it sees is significant or ignorable. After the XML declaration, the document prolog can include a DTD, which lets you specify the kinds of tags that can be included in your XML document. In addition to telling a validating parser which tags are valid and in what arrangements, a DTD tells both validating and nonvalidating parsers where text is expected, which lets the parser determine whether the whitespace it sees is significant or ignorable.

17 17 Getting Started with Web Applications A Web application is a dynamic extension of a Web or application server. There are two types of Web applications: A Web application is a dynamic extension of a Web or application server. There are two types of Web applications: Presentation-oriented:Presentation-oriented: Service-oriented:Service-oriented: Java Web Application Technologies Java Web Application Technologies

18 18 Getting Started with Web Applications Web Application Life Cycle Web Application Life Cycle Develop the Web component code.Develop the Web component code. Develop the Web application deployment descriptor.Develop the Web application deployment descriptor. Compile the Web application components and helper classes referenced by the components.Compile the Web application components and helper classes referenced by the components. Optionally package the application into a deployable unit.Optionally package the application into a deployable unit. Deploy the application into a Web container.Deploy the application into a Web container. Access a URL that references the Web application.Access a URL that references the Web application.

19 19 Getting Started with Web Applications In the J2EE architecture, Web components and static Web content files such as images are called Web resources. A Web module is the smallest deployable and usable unit of Web resources. A J2EE Web module corresponds to a Web application as defined in the Java Servlet specification. In the J2EE architecture, Web components and static Web content files such as images are called Web resources. A Web module is the smallest deployable and usable unit of Web resources. A J2EE Web module corresponds to a Web application as defined in the Java Servlet specification. The document root contains a subdirectory named /WEB-INF/, which contains the following files and directories: The document root contains a subdirectory named /WEB-INF/, which contains the following files and directories: web.xml: The Web application deployment descriptorweb.xml: The Web application deployment descriptor Tag library descriptor files (see Tag Library Descriptors)Tag library descriptor files (see Tag Library Descriptors)Tag Library DescriptorsTag Library Descriptors classes: A directory that contains server-side classes: servlets, utility classes, and JavaBeans componentsclasses: A directory that contains server-side classes: servlets, utility classes, and JavaBeans components tags: A directory that contains tag files, which are implementations of tag libraries (see Tag File Location)tags: A directory that contains tag files, which are implementations of tag libraries (see Tag File Location)Tag File LocationTag File Location lib: A directory that contains JAR archives of libraries called by server-side classeslib: A directory that contains JAR archives of libraries called by server-side classes

20 20 Java API for XML Processing SAX APIs SAX APIs The SAX Packages The SAX Packages

21 21 Java API for XML Processing DOM APIs DOM APIs The DOM Packages The DOM Packages

22 22 Java API for XML Processing XSLT APIs XSLT APIs The XSLT Packages The XSLT Packages

23 23 Building Web Services with JAX-RPC JAX-RPC stands for Java API for XML-based RPC. JAX-RPC is a technology for building Web services and clients that use remote procedure calls (RPC) and XML. Often used in a distributed client- server model, an RPC mechanism enables clients to execute procedures on other systems. JAX-RPC stands for Java API for XML-based RPC. JAX-RPC is a technology for building Web services and clients that use remote procedure calls (RPC) and XML. Often used in a distributed client- server model, an RPC mechanism enables clients to execute procedures on other systems. In JAX-RPC, a remote procedure call is represented by an XML- based protocol such as SOAP. The SOAP specification defines the envelope structure, encoding rules, and conventions for representing remote procedure calls and responses. These calls and responses are transmitted as SOAP messages (XML files) over HTTP. In JAX-RPC, a remote procedure call is represented by an XML- based protocol such as SOAP. The SOAP specification defines the envelope structure, encoding rules, and conventions for representing remote procedure calls and responses. These calls and responses are transmitted as SOAP messages (XML files) over HTTP. Although SOAP messages are complex, the JAX-RPC API hides this complexity from the application developer. Although SOAP messages are complex, the JAX-RPC API hides this complexity from the application developer.

24 24 Building Web Services with JAX-RPC Communication Between a JAX-RPC Web Service and a Client Communication Between a JAX-RPC Web Service and a Client These are the basic steps for creating the Web service and client: These are the basic steps for creating the Web service and client: Code the SEI and implementation class and interface configuration file.Code the SEI and implementation class and interface configuration file. Compile the SEI and implementation class.Compile the SEI and implementation class. Use wscompile to generate the files required to deploy the service.Use wscompile to generate the files required to deploy the service. Use deploytool to package the files into a WAR file.Use deploytool to package the files into a WAR file. Deploy the WAR file. The tie classes (which are used to communicate with clients) are generated by the Application Server during deployment.Deploy the WAR file. The tie classes (which are used to communicate with clients) are generated by the Application Server during deployment. Code the client class and WSDL configuration file.Code the client class and WSDL configuration file. Use wscompile to generate and compile the stub files.Use wscompile to generate and compile the stub files. Compile the client class.Compile the client class. Run the client.Run the client.

25 25 Building Web Services with JAX-RPC Coding the Service Endpoint Interface and Implementation Class Coding the Service Endpoint Interface and Implementation Class

26 26 SOAP with Attachments API for Java

27 27 Java API for XML Registries

28 28 Java Servlet Technology A servlet is a Java programming language class that is used to extend the capabilities of servers that host applications access via a request-response programming model. Although servlets can respond to any type of request, they are commonly used to extend the applications hosted by Web servers. For such applications, Java Servlet technology defines HTTP-specific servlet classes. A servlet is a Java programming language class that is used to extend the capabilities of servers that host applications access via a request-response programming model. Although servlets can respond to any type of request, they are commonly used to extend the applications hosted by Web servers. For such applications, Java Servlet technology defines HTTP-specific servlet classes. The javax.servlet and javax.servlet.http packages provide interfaces and classes for writing servlets. All servlets must implement the Servlet interface, which defines life-cycle methods. When implementing a generic service, you can use or extend the GenericServlet class provided with the Java Servlet API. The HttpServlet class provides methods, such as doGet and doPost, for handling HTTP-specific services. The javax.servlet and javax.servlet.http packages provide interfaces and classes for writing servlets. All servlets must implement the Servlet interface, which defines life-cycle methods. When implementing a generic service, you can use or extend the GenericServlet class provided with the Java Servlet API. The HttpServlet class provides methods, such as doGet and doPost, for handling HTTP-specific services.javax.servletjavax.servlet.http Servlet GenericServlet HttpServletjavax.servletjavax.servlet.http Servlet GenericServlet HttpServlet

29 29 JavaServer Pages Technology JavaServer Pages (JSP) technology allows you to easily create Web content that has both static and dynamic components. JSP technology makes available all the dynamic capabilities of Java Servlet technology but provides a more natural approach to creating static content. The JavaServer Pages (JSP) technology allows you to easily create Web content that has both static and dynamic components. JSP technology makes available all the dynamic capabilities of Java Servlet technology but provides a more natural approach to creating static content. The

30 30 JSF JavaServer Faces Standard Request-Response Life Cycle JavaServer Faces Standard Request-Response Life Cycle

31 31 Enterprise Bean Structure of an Enterprise Bean JAR Structure of an Enterprise Bean JAR

32 32 Enterprise Bean Life Cycle of a Stateful Session Bean Life Cycle of a Stateful Session Bean Life Cycle of a Stateless Session Bean Life Cycle of a Stateless Session Bean

33 33 Enterprise Bean Life Cycle of an Entity Bean Life Cycle of an Entity Bean Life Cycle of a Message-Driven Bean Life Cycle of a Message-Driven Bean

34 34 J2EE Connector Architecture Resource Adapter Contracts Resource Adapter Contracts Resource Adapter Module Structure Resource Adapter Module Structure

35 35 The Coffee Break Application Coffee Break Application Flow Coffee Break Application Flow

36 36 The Duke's Bank Application Duke's Bank Application Duke's Bank Application


Download ppt "Notes of J2EE Tutorial Matt Tsai. 2 Outline Chapter 1: Overview Chapter 1: Overview Chapter 2: Understanding XML Chapter 2: Understanding XML Chapter."

Similar presentations


Ads by Google