- Hands-On Cloud Development with WildFly
- Tomasz Adamski
- 348字
- 2021-08-27 19:38:41
The basic architecture of Java EE applications
Java EE applications are written in the Java language and run on Java virtual machine (JVM). On top of the standard Java SE functionality, the Java EE implementation provider implements a number of services, which can be used by those applications. Examples of such services may be security, transactions, or dependency injection.
Applications don't interact with enterprise services directly. Instead, the specifications define the component and containers concepts. Components are software units written in the Java language and configured and built in a similar way to standard Java classes. The difference is that metatada provided with the component allows it to be run using a runtime provided by the Java EE implementation. Such a runtime, which may differ for the different types of component, is called a container. The container is responsible for providing access to all enterprise services required by the component.
As an example, let's take a look at the following component:
package org.tadamski.examples.javaee;
import org.tadamski.examples.java.ee.model.Foo;
import javax.ejb.Stateless;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import javax.persistence.EntityManager;
//1
@Stateless
public class FooDaoBean implements FooDao {
//2
@Inject
private EntityManager em;
public void save(Foo foo) throws Exception {
//3
em.persist(foo);
}
}
The preceding script presents an ejb component (1), that is, FooDaoBean, which is responsible for saving objects of the Foo type into the database.
The ejb container in which this component will run will be responsible for pooling instances of this component and managing the lifecycle for all of them. Furthermore, this concrete component takes advantage of the number of enterprise services: dependency injection (2), ORM persistence (3), and transactions (the default for this kind of component).
In general, the goal of the Java EE runtime is to take care of all technical aspects of enterprise applications so that the application developer can concentrate on writing business code. The preceding example demonstrates how it is realized in Java EE: the application developer writes their code using POJOs with minimal configuration (provided mostly by annotations). The code written by an application developer implements business functionalities declaratively, informing middleware about its technical requirements.
- 廣電5G從入門到精通
- 連接未來:從古登堡到谷歌的網絡革命
- C++黑客編程揭秘與防范
- Oracle SOA Suite 11g Performance Tuning Cookbook
- Drush User’s Guide
- 智慧城市中的移動互聯網技術
- 數字通信同步技術的MATLAB與FPGA實現:Altera/Verilog版(第2版)
- 中國互聯網發展報告2018
- 夢工廠之材質N次方:Maya材質手冊
- 高級網絡技術
- Getting Started with tmux
- Cisco無線局域網配置基礎
- Corona SDK Application Design
- 網絡空間作戰:機理與籌劃
- LiveCode Mobile Development Beginner's Guide