Tutorial for building j2ee applications using jboss and eclipse -2

xiaoxiao2021-03-06  78

Chapter 2.

Overview of J2EE Technology and Concepts

The Java 2 Enterprise Edition (J2EE) is a multitiered architecture for implementing enterprise-class applications and web based applications. This technology supports a variety of application types from large scale web applications to small client server applications. The main aim of J2EE technology is to create a simple development model for enterprise applications using component based application model in this model such components use services provided by the container, which would otherwise typically need to be incorporated in application code Note this may not be ideal in all scenarios:.. for example A Small Scale Application Might Be a better Fit for a Light-Weight Java Technology Solution (EG Servlets, JSPS, ETC.).

J2EE Components:

J2EE applications are made up of different components. A J2EE component is a self-contained functional software unit that is assembled into a J2EE application with its helper classes and files and that communicates with other components in the application. The J2EE specification defines the following J2EE Components:

Application Clients and Applets Are Components That Run on The Client.

Java Servlet and JavaServer Pages Technology Components Are Web Components That Run on The Web Server.

Enterprise JavaBeans Components (Enterprise Beans) Are Business Components That Run on The Application Server.

All these J2EE components are assembled into a J2EE application, verified to be well formed and in compliance with the J2EE specification, and deployed to production, where they are run and managed by the J2EE application server.

In Additional To The Primary Components, IT INCLUDES Standard Services and Supporting Technologies Which Are: Java Database Connectivity (JDBC) Technology To Relational Database Systems.

Java Transaction API (JTA) or Java Transaction Service (JTS) Provides Transaction Support for J2EE Components.

Java Messaging Service (JMS) for Asynchronous Communication Between J2EE Components.

Java Naming and Directory Interface (JNDI) Provides Naming and Directory Access.

NOTE: All J2EE Components Are Written in The Java Programming Language

J2EE Clients:

.................

A Web client consists of two parts, dynamic Web pages containing various types of markup language (HTML, XML and others), which are generated by Web components running in the Web tier, and a Web browser, which draws the pages received from the server . Another category of web clients are sometimes called as thin client. Thin clients usually do not do things like query databases, execute complex business rules, or connect to any legacy applications. When we use a thin client, heavyweight operations like these are handled by Enterprise Beans Executing on The J2EE Server Where Where Can Leverage The Security, Speed, Services, and Reliability Of J2EE Server-Side Technology Of J2EE Server-Side Technology.

A Web page received from the Web tier can include an embedded applet. An applet is a small client application written in the Java programming language that executes in the Java virtual machine installed in the Web browser. However, client systems will need the Java Plug- in and possibly a security policy file in order to execute applets successfully in the Web browser. Web components are often a preferred API for creating a Web client program because no plug-ins or security policy files are needed on the client systems. moreover this allows cleaner and more modular application design because they provide a means to separate application logic from Web page design.An Application client runs on a client machine and provides a way for users to handle tasks that require a richer user interface than can be provided by a markup LANGUAGE. IT NORMALLY HAS A Graphical User Interface (GUI) Created Using The Swing OR Abstract Window Toolkit (AWT) APIS. Application Clients Directly Access Enterprise ....................... ..

Note: if Required, a Command Line Interface Can Be.

Web Components:

J2EE Web components can be either servlets or JSP pages. Servlets are Java programming language classes that dynamically process requests and construct responses. JSP pages are text-based documents that execute as servlets but allow a more natural approach to creating static content. HTML pages and applets are bundled with Web components during application assembly, but are not considered Web components by the J2EE specification. Similarly, server-side utility classes can also be bundled with Web components like HTML pages, but are not considered Web components by the J2EE specification. Shown below in figure is Web components communication.The Web tier might include a JavaBeans component to manage the user input and send that input to enterprise beans running in the business tier for processing as shown above in the figure ..

Business Components:

Business Code, Which Is Logic That Solves Or Meets The Needs of a Particular Business Domain Such As Banking, Retail, OR Finance, IS Handled by Enterprise Beans Running In The Business Tier.

The figure above shows communication with business components, where an enterprise bean receives data from client programs, processes it (if necessary), and sends it to the enterprise information system tier for storage. An enterprise bean also retrieves data from storage, processes it ( If Necessary, And Sends It Back to the Client Program.

There are three kinds of enterprise beans: session beans (stateless and stateful), entity beans (bean managed and container managed), and message-driven beans A session bean represents a transient conversation with a client When the client finishes executing, the.. session bean and its data are gone. in contrast, an entity bean represents persistent data stored in one row of a database relation / table. If the client terminates or if the server shuts down, the underlying services ensure that the entity bean data is saved . A message-driven bean combines features of a session bean and a Java Message Service (JMS) message listener, allowing a business component to receive JMS messages asynchronously.Note: Java Beans are not considered J2EE components by the J2EE specification as JavaBeans are different From Enterprise Beans. Javabeans Component Architecture Can Be Used In Both Server and Client Tiers To Manage The Communication Between An Application Client OR Applet and Components Running on the J2EE server or between server components and a database, whereas Enterprise JavaBeans components are only used in the business tier as a part of the server tier. JavaBeans have instance variables and has an accessor and mutator methods to access properties of bean or say, Accessing The Data in The Instance Variables Which Simplifies The Design and Implementation of JavaBeans Components.

Enterprise Information System Tier:

The enterprise information system tier handles enterprise information system software and includes enterprise infrastructure systems such as enterprise resource planning (ERP), mainframe transaction processing, database systems, and other legacy information systems. J2EE application components might need access to enterprise information systems for database connectivity .J2ee containers:

J2EE containers provide access to the underlying services of the J2EE Server environment via containers for different types of components. Traditionally, application developers have to write code for handling transaction, state management, multithreading, resource pooling etc. Now the J2EE container provides these services allowing You to Concentrate On Solving Business Problems.

Containers are the interface between a component and the low-level platform-specific functionality that supports the component. For example, before a Web, enterprise bean, or application client component can be executed, it must be assembled into a J2EE application 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. Container settings customize the underlying support provided by the J2EE server, which includes services such as Java Naming and Directory Interface, security, transaction management etc.

The J2EE server provides Enterprise JavaBeans (EJB) and Web containers. EJB container manages the execution of enterprise beans for J2EE applications, whereas Web container manages the execution of JSP page and servlet components for J2EE applications. Other than these two containers there are an Application client container and Applet container, which are not part of J2EE server as these reside on the client's machine as shown below.An Application client container manages the execution of application client components whereas an Applet container manages the execution of applets. These are typically the JRE (Java Runtime Environment) and a java-enabled Web Browser Respectively.

Packaging:

In order to deploy a J2EE application, after developing different components, it is packaged into special archive files that contain the relevant class files and XML deployment descriptors. These XML deployment descriptors contain information specific to each bundled component and are a mechanism for configuring application behavior At Assembly or Deployment Time. There Are Bund Into Different Archive Types for Different Component Types.

Web components are archived in Web Archive (.war) file which contains servlets, JSP and static components such as HTML and image files. The .war file contains classes and files used in web tier along with a Web component deployment descriptor.

Business Components Are Archived In Java Archive (.jar) File Which Contains An EJB Deployment Descriptor, Remote, And Object Interface Files Along With helper files required by EJB Component.

Client Side Class Files and Deployment Descriptors Are Archived In Java Archive (.jar) File Which make up the client application.

J2EE application is bundled in an Enterprise Archive (.ear) file which contains the whole application along with deployment descriptor that provides information about the application and its assembled components.J2EE Platform Roles:

BUILDING THE DIFFERENTS OF A J2EE Application Involves Various Roles in The Development of An Enterprise Application.

The Application Component Provider Develops The Reusable Components Of J2EE Application, Which Can Be Web Components, Enterprise Beans, Applets, or Application Clients for Use in J2EE Applications.

............

.

The System Administrator Is Responsible for Configuration And Administration of Computing Systems in An Enterprise.

The Tool Provider is a vendor Used to develop, package and deploy j2ee coplications.

NOTE: All these Above exerciseed Roles Can Be Assigned to a person or an organization.

Distributed Architecture in j2ee:

All the J2EE applications implement a distributed architecture. In this an object is associated with a name, where names are provided by naming service, by advertising to various components and resolving client references to these service components as shown in figure below.

As a result of that, object references are obtained, by looking up for an object by its advertised name, once found, reference is obtained, and A remote object advertises its availability then carry out the necessary operations on that object using the host's services. with the name service using a logical name and the name service translates the name to the physical location of the object in the J2EE environment. Once the client request obtains a reference to a remote component, it can send requests to the remote component. The runtime system system handles the distributed communication between the remote objects, which includes serialization and deserialization of parameters.Note: Various naming services used in distributed systems are RMI (for Java-only implementations), CORBA naming services, LDAP, DNS, NIS The JBOSS. Application Server Uses RMI As ITS Naming Service.

SERIALIZATION AND DeSerialization Are The Same As Marshalling and UNMARSHALLING for Those Familiar with rpc terminology.

Java Naming Directory Interface (JNDI) Architecture:

J2EE uses the JNDI API to generically access naming and directory services using Java technology. The JNDI API resides between application and a naming service and makes the underlying naming service implementation transparent to application components.

A client can look up references to EJB components and other resources in a naming service as mentioned above. The client code remains unchanged, regardless of what naming service is used or what technology it is based on, as this does not make any difference to Clients Locating Remote Objects via the JNDI API.

转载请注明原文地址:https://www.9cbs.com/read-121916.html

New Post(0)