390 likes | 1.16k Views
J2EE Overview. Objectives. After completing this lesson, you should be able to do the following: Describe the Java™ 2, Enterprise Edition (J2EE) platform Define the various components of J2EE Describe the deployment options for a J2EE application
E N D
Objectives • After completing this lesson, you should be able to do the following: • Describe the Java™ 2, Enterprise Edition (J2EE) platform • Define the various components of J2EE • Describe the deployment options for a J2EE application • Describe the architecture of Oracle Application Server 10g Containers for J2EE (OC4J) • Describe the directory structure and the uses of the configuration files of OC4J
Java 2, Enterprise Edition Platform • The Java 2, Enterprise Edition (J2EE) platform is a standard for developing and implementing enterprisewide applications: • It provides multitier applications support. • It is designed to help improve the process of developing, deploying, and implementing enterprisewide applications.
J2EE Platform • Is a multitiered, distributed application model • Supports component-based J2EE applications Middle tier Web components Servlet Client tier Web clients JSP Page Browser EJB clients EJB components EnterpriseBeans Application EIS tier
Benefits of the J2EE Platform • “Write once, run anywhere” provides simplified component development. • Multiple server products and vendors support the J2EE standard, thus giving more deployment choices. • Integration with legacy systems through standard APIs is possible. • J2EE separates client requirements from business logic. • J2EE provides multiple development and design scenarios.
Benefits of the J2EE Platform • J2EE separates development tasks into specific skill areas. • Web designers can create JSP components. • Application behavior is created by Java programmers. • Business logic and rules are created by Java programmers and business experts. • Assembly and deployment can be assigned to production environment teams.
J2EE Components • J2EE is a component-based architecture for the development and deployment of enterprisewide applications. • A component is an application-level software unit. • Components can be easily updated as business needs change. • Components are reusable. • There are several types of components: • Client-side components • Web components • Business-tier components
J2EE 1.3 Components The J2EE 1.3 Specification lists the following components: • Servlet 2.3 • JavaServer Pages 1.2 • Enterprise JavaBeans 2.0 • JDBC 2.0 • RMI-IIOP • JNDI 1.2 • Web services 1.1 • Java Message Service 1.0.2 • Java Transaction API 1.0 • Java Authentication and Authorization Service 1.0 • J2EE Connector Architecture 1.0 • SOAP with Attachments API for Java 1.1
J2EE Architecture J2EE Server Client Machine Web Container Browser Java Servlet/JSP Application Client Container Application Client EJB EJB Business container APIs Database JNDI JTA JMS RMI JDBC JAF JavaMail
Client-Tier Components • A Web browser: • Is used for a Web-based J2EE application • Downloads static or dynamic Web pages from Web-tier components • Is a thin client • An application client: • Is used for a non-browser-based J2EE application • Executes on the client machine • Can contain a graphical or command-line interface • Is a thick client • Accesses business-tier components or a servlet on the Web tier
J2EE Web-Tier Components • A Web tier may consist of: • Java servlets • JSPs • Servlets and JSPs: • Work on a request-response model • Generate HTML dynamically • Access the database through JDBC • Access the business-tier components • Handle user-centric events, such as an HREF link or form submission • Usually generate visual interfaces such as a Web page
What Is a Servlet? Servlet Browser Client info (host name, form data) Success or failure Process results (access database) Format results and produce HTML Send page back to client Request Response
What Is a JavaServer Page (JSP)? • A JSP: • Is a text-based document that includes: • HTML • JSP tags • Java code (including calls to JavaBeansand servlets) • Cleanly separates content creation from presentation logic • Focuses on rapid development and easy modification of the user interface • Provides presentation-centric method of developing servlets
Web-Tier Components: Summary • Web-tier components generate dynamic content. • Servlets: • Extend Web server functionality • Are designed more for processing than for presentation • JSPs: • Combine HTML (or other markup) and Java • Are designed to separate content creation from presentation logic • Are precompiled and converted to servlets at run time
Business-Tier Components • Business-tier components: • Are EJBs • Handle business logic • Receive data from client programs • Retrieve data from database storage • Process the data and communicate with the database and the client program • Can be invoked by the Web-tier components
Enterprise JavaBeans (EJB) • Enterprise JavaBeans: • Are server-side components written in Java • Contain the business logic of an enterprise application • Are hosted in EJB containers • Are based on Remote Method Invocation (RMI) communication • Are platform independent • Provide remote services for clients • Can be exposed as Web services • Use JDBC to connect to a database
J2EE Communication APIs • J2EE provides component communication through APIs. • The APIs include: • RMI • JNDI • JDBC • These APIs facilitate communication between the J2EE components.
J2EE Server • The J2EE server provides: • Containers for each component type of a J2EE application • System-level services to components: • Naming and directory services (JNDI) • Security services for Web components and EJBs (JAAS) • Transaction architecture (JTA) • Remote client connectivity: • – Enterprise beans (RMI/IIOP, ORMI) • – Servlet/JSP (HTTP, HTTPS, FTP)
Oracle Application Server 10g Containers for J2EE (OC4J) • OC4J is the J2EE server implementation in Oracle Application Server 10g • Key features: • Implements J2EE 1.3 Specification • Runs on standard JVM • Provides high performance and scalability • Is productive for developers to use • Is simple to manage and deploy • Provides clustering for high availability and failover
J2EE Applications • J2EE applications consist of J2EE components and are deployed in the form of modules: • Web modules contain the user interface: HTML, JSP, and servlets. • EJB modules contain reusable EJB components. • Client modules provide access to remote application code. • Packaging information identifies dependencies between modules.
Packaging J2EE Application Components 1. ejb.jar Bean class, Home and Remote interfaces, other supported files, DD 2. webtier.war Java servlets, JSP files, HTML, GIF files,DD (references to EJBs) J2EEapplication.ear 3. J2EEappClient.jar J2EE application client (Java class), DD (references to EJBs) 4. DD for J2EE application (.xml) DD = XML Deployment Descriptor 5. Resource adapter (.rar)
JARs • Are simple Java Archive files • Are used to package application files together (for example, classes, images, and so on) • Can be included in Web Archives (WARs) and Enterprise Archives (EARs) • Can be included in library paths
WARs • Are specialized archives for packagingJ2EE-compliant Web applications • Have a fixed directory structure • Have a deployment descriptor for the Web application WEB-INF web.xml Contain servlet code and JavaBeans not in standard JAR files classes lib Contains required classes that are packaged in standard JAR files index.html welcome.jsp
EJB JARs • Are specialized JARs for packaging EJBs • Have a fixed directory structure • Have a deployment descriptor for the EJB components myEJB META-INF ejb-jar.xml Contain the class files for the EJBs, usually in a package directory structure EJB Classes Remote, Home and Bean classes
EARs • The EAR files: • Are specialized archives for packagingJ2EE-compliant enterprise applications for deployment • Have a deployment descriptor • May have Web modules • May have EJB modules • May have client modules
EAR File Structure for a J2EE Application: Example <appname> |-------META-INF | |-------application.xml |-------<ejb_module> | |-------EJB classes | |-------META-INF | |-------ejb-jar.xml |-------<web_module> | |-------index.html | |-------JSP pages | |-------WEB-INF | |----web.xml | |----classes | |-------Servlet classes |-------<client_module> | |-------Client classes | |-------META-INF | |-------application-client.xml
OC4J Architecture Oracle HTTPServer AJP13 Webcontainer JNDI HTTP JMS AJP mod_oc4j JDBC JTA Client JAAS EJB container ORMI JCA JavaMail ORMI JAF EJB client OC4J server process
OC4J Server Configuration Files OC4J Server XML Files Server Configuration server.xml Web site Web site Web site jazn.xml* default-web-site.xml jazn-data.xml* data-sources.xml rmi.xml jms.xml Oracle HTTP Server configuration files mod_oc4j.conf
Relation of Configuration Files <application name="lesson02" path="../applications/lesson02.ear" /> • When an application is deployed, an entry is made in the \config\server.xml file: • For each Web module within the application, a context root is defined in \config\default-web-site.xml: <web-app application="lesson02" name="webapp1" root="/lesson02"/> • The modules of the application are defined in \applications\lesson02\META-INF\application.xml: <web><web-uri>webapp1.war</web-uri></web>
Data Sources • A data source is the instantiation of an object that implements the javax.sql.DataSource interface, which enables you to retrieve a connection to a database server. • OC4J data sources are defined in data-sources.xml. • J2EE applications use JNDI to look up these DataSource objects.
Application Logging • Application logging in Oracle Application Server 10g is configured by specifying the location of a log file in the application.xml file: • To create a log file formatted in XML, use Oracle Diagnostic Logging (ODL): <log> <file path="practice02-oc4j-app.log"/> </log> <log> <odl path="practice02-oc4j-app.log"/> </log>
J2EE Application Deployment to Oracle Application Server 10g • Deploying to OC4J can be done in multiple ways: Step 1: Create WAR,EAR file Step 2: Deploy Step 2: Deploy Use a command-line tool (such as ANT). • Use Oracle Enterprise Manager (installed with Oracle Application Server 10g): Access the Enterprise Manager Web site http://localhost:1810 (requires login). Use JDeveloper – specify anApplication Server and click 'Deploy' Use JDeveloper. Use JDeveloper: Specify an application server and click “Deploy.”
Oracle Enterprise Manager localhost
JDeveloper JDeveloper and J2EE • JDeveloper provides: • Integrated development, deployment, and testing support for Web-tier and business-tier components • A J2EE framework for rapid development • Application Development Framework (ADF) business components • Data tags • Integration with Struts • UML modeling • Visual editors for Web clients • Easy deployment to Oracle Application Server 10g
Oracle JDeveloper 10g Environment Customizable code editor Wizards for JSPs, servlets, and EJBs Error checking for HTMLand JSP EAR, WAR deployment to J2EE server Code insight
Oracle JDeveloper 10gVisual Design Tools Drag JSP and HTML elements Modify values in property inspector Design in visual or code views
Summary • In this lesson, you should have learned that: • J2EE is a set of Java technologies that support end-to-end application development • Components are the foundation of the J2EE architecture • Web components (servlets, JSPs) generate dynamic content • Business components (EJBs) are server-side components that contain business logic • Applications can be built by using Oracle JDeveloper 10g and deployed to a J2EE server, such as Oracle Application Server 10g
Practice 2-1: Overview • This practice covers the following topics: • Navigating to the OC4J console by using Oracle Enterprise Manager • Mapping a data source in OC4J • Restarting the OC4J server instance from Oracle Enterprise Manager • Deploying an EAR file by using Oracle Enterprise Manager